decocms 3.82.0 → 3.83.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 (214) hide show
  1. package/dist/client/assets/{AlertCircle-DifM-3Ys.js → AlertCircle-CqXnKI3D.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-DTNfyjlQ.js → ArrowUpRight-D_A_c-WP.js} +1 -1
  3. package/dist/client/assets/{CheckCircle-DmLgOHHp.js → CheckCircle-B6_BlhWA.js} +1 -1
  4. package/dist/client/assets/{ChevronDown-BY59w4Qk.js → ChevronDown-CsJyvcQs.js} +1 -1
  5. package/dist/client/assets/{ChevronLeft-DVIgNVyn.js → ChevronLeft-cwkPjMhb.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-CM2UCxLV.js → ChevronRight-DbmfCIOT.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-ELVqY6cz.js → ChevronUp-DTH787oJ.js} +1 -1
  8. package/dist/client/assets/{DotsVertical-FbZSolmB.js → DotsVertical-DXADESRu.js} +1 -1
  9. package/dist/client/assets/{Eye-8PGvC0iK.js → Eye-Cd9WdjRO.js} +1 -1
  10. package/dist/client/assets/{FilterLines-Cf2PdvFM.js → FilterLines-DDE5Z7pT.js} +1 -1
  11. package/dist/client/assets/{Globe01-B90chNia.js → Globe01-BtWLhdgc.js} +1 -1
  12. package/dist/client/assets/{Globe04-Dw4nWd3A.js → Globe04-DVbA5z-S.js} +1 -1
  13. package/dist/client/assets/{HardDrive-CKn4i_9T.js → HardDrive-Dv021FxK.js} +1 -1
  14. package/dist/client/assets/{Key01-oftOkafI.js → Key01-AxVsjzoW.js} +1 -1
  15. package/dist/client/assets/{LayoutLeft-Bij2Lb4X.js → LayoutLeft-DFQX2HQS.js} +1 -1
  16. package/dist/client/assets/{LinkExternal01-9FNotiMN.js → LinkExternal01-DFJC7MKi.js} +1 -1
  17. package/dist/client/assets/{Monitor01-CR1JDEQ7.js → Monitor01-DzIaslp9.js} +1 -1
  18. package/dist/client/assets/{Palette-ArrfZuOV.js → Palette-DRyOxvc4.js} +1 -1
  19. package/dist/client/assets/{Play-BB5dP1L8.js → Play-BGOeSWeu.js} +1 -1
  20. package/dist/client/assets/{Plus-CglBKrb5.js → Plus-zfs5-JeK.js} +1 -1
  21. package/dist/client/assets/{SearchMd-Bmh_sD0S.js → SearchMd-DUUd_hhd.js} +1 -1
  22. package/dist/client/assets/{Settings02-RazZjdiv.js → Settings02-Gfe6bidH.js} +1 -1
  23. package/dist/client/assets/{Shield01-D44r3AdO.js → Shield01-5ohBHD7b.js} +1 -1
  24. package/dist/client/assets/{Star01-C9VN0Du_.js → Star01-BfbfCcYt.js} +1 -1
  25. package/dist/client/assets/{Stars01-CoxwYWLP.js → Stars01-CDSyPsDa.js} +1 -1
  26. package/dist/client/assets/{Stars02-l9mDD3eo.js → Stars02-CNjkSD-c.js} +1 -1
  27. package/dist/client/assets/{Sun-D-fwbx_z.js → Sun-CduMeE8P.js} +1 -1
  28. package/dist/client/assets/{SwitchHorizontal01-DO04KALD.js → SwitchHorizontal01-C-8MujcR.js} +1 -1
  29. package/dist/client/assets/{Tool01-CqbO1hX2.js → Tool01-CyFZLY0Y.js} +1 -1
  30. package/dist/client/assets/{Trash01-DUxygeaL.js → Trash01-BwZvbUqV.js} +1 -1
  31. package/dist/client/assets/{Upload01-CEAuuYpa.js → Upload01-BENZkUL6.js} +1 -1
  32. package/dist/client/assets/{User01-fdrqbZOX.js → User01-C6id_Jz0.js} +1 -1
  33. package/dist/client/assets/{Users01-BQH1rUR7.js → Users01-DoemHjk2.js} +1 -1
  34. package/dist/client/assets/{Users03-V7VYPOVz.js → Users03-DNFFVYi5.js} +1 -1
  35. package/dist/client/assets/{X-DH6rpzm4.js → X-DbKbpx_s.js} +1 -1
  36. package/dist/client/assets/{XCircle-CNgW1bnA.js → XCircle-Dcz0bhP7.js} +1 -1
  37. package/dist/client/assets/{XClose-DY_H1WmQ.js → XClose-c_WWFEvr.js} +1 -1
  38. package/dist/client/assets/{Zap-jC0lbn1q.js → Zap-iEV7Y0HC.js} +1 -1
  39. package/dist/client/assets/{ZapSquare-wbaFJ6J6.js → ZapSquare-C6FRNhWU.js} +1 -1
  40. package/dist/client/assets/{ZoomOut-XI-iJG4j.js → ZoomOut-B6sxahLJ.js} +1 -1
  41. package/dist/client/assets/{access-gate-DDQd7LZ9.js → access-gate-Bw0npMv7.js} +1 -1
  42. package/dist/client/assets/{add-section-modal-DbYQ6fO0.js → add-section-modal-KIiwcyif.js} +1 -1
  43. package/dist/client/assets/{agent-icon-BUISstKv.js → agent-icon-Dwg5FgWW.js} +1 -1
  44. package/dist/client/assets/{agents-list-CLbNQC9z.js → agents-list-BXDz7sZv.js} +1 -1
  45. package/dist/client/assets/{ai-providers-61qxW7f5.js → ai-providers-VH8M6hT6.js} +1 -1
  46. package/dist/client/assets/{alert-VlhASuYO.js → alert-CrUsXKEE.js} +1 -1
  47. package/dist/client/assets/{alert-dialog-Dh6V_14o.js → alert-dialog-Cv06ffuC.js} +1 -1
  48. package/dist/client/assets/{app-editor-BI1KpS86.js → app-editor-DjhMgCk8.js} +1 -1
  49. package/dist/client/assets/{auth-COC6Da1O.js → auth-DEpXDpCk.js} +1 -1
  50. package/dist/client/assets/{auth-catchall-DjeD5XiQ.js → auth-catchall-CPgG-EzL.js} +1 -1
  51. package/dist/client/assets/{auth-entry-DDP2v7bj.js → auth-entry-DSjmtoLb.js} +1 -1
  52. package/dist/client/assets/{auth-split-layout-CYQ7PKOY.js → auth-split-layout-BkUGPb-7.js} +1 -1
  53. package/dist/client/assets/{authenticate-and-persist-oauth-7kSYvcg8.js → authenticate-and-persist-oauth-BELZfB_M.js} +1 -1
  54. package/dist/client/assets/{automation-list-row-DCvQVGai.js → automation-list-row-BQBXbnVC.js} +1 -1
  55. package/dist/client/assets/{automation-runs-DMkXGxyD.js → automation-runs-Dm8vrkrz.js} +1 -1
  56. package/dist/client/assets/{automations-CRTazwGA.js → automations-DA5a6gqY.js} +1 -1
  57. package/dist/client/assets/{avatar-yxz7fyGH.js → avatar-DPNVdynG.js} +1 -1
  58. package/dist/client/assets/{badge-CQquKN9p.js → badge-BAgfu3s3.js} +1 -1
  59. package/dist/client/assets/{block-document-BBSIfcJ0.js → block-document-L8I5bPmf.js} +1 -1
  60. package/dist/client/assets/{brand-context-gRadlp6o.js → brand-context-CULMCcpa.js} +1 -1
  61. package/dist/client/assets/{buckets-CHaLsSDx.js → buckets-DMU0eaXD.js} +1 -1
  62. package/dist/client/assets/{capability-load-error-geYLJLvZ.js → capability-load-error-DNDjRRk_.js} +1 -1
  63. package/dist/client/assets/{card-Bj8otFuN.js → card-Trr9Smsl.js} +1 -1
  64. package/dist/client/assets/category-editor-BJlYKlYH.js +1 -0
  65. package/dist/client/assets/{chat-context-D2XCyHNy.js → chat-context-D2JYAjtU.js} +1 -1
  66. package/dist/client/assets/{checkbox-Da1mUHNU.js → checkbox-BkY2CRaN.js} +1 -1
  67. package/dist/client/assets/{cli-auth-success-DGCDjW3a.js → cli-auth-success-CDezhRu8.js} +1 -1
  68. package/dist/client/assets/{collection-detail-B8ehy7SJ.js → collection-detail-wY7wsRFe.js} +1 -1
  69. package/dist/client/assets/{collection-display-button-BbDeI4M_.js → collection-display-button-BhW4iJuC.js} +1 -1
  70. package/dist/client/assets/{collection-search-Bde6_LbH.js → collection-search-IIs4O29o.js} +1 -1
  71. package/dist/client/assets/{collection-tabs-CmheS0lt.js → collection-tabs-DStxKs6K.js} +1 -1
  72. package/dist/client/assets/{command-D_g4Qh6z.js → command-DziWV9Wl.js} +1 -1
  73. package/dist/client/assets/{commerce-onboarding-hTRnas9I.js → commerce-onboarding-CyEeXl3T.js} +1 -1
  74. package/dist/client/assets/{connect-desktop-dialog-CSA1yCDL.js → connect-desktop-dialog-CEg8fHOJ.js} +1 -1
  75. package/dist/client/assets/{connection-card-BavDtRRe.js → connection-card-CX4CTBla.js} +1 -1
  76. package/dist/client/assets/{connection-detail-BluTRGVx.js → connection-detail-BDjbD-IX.js} +1 -1
  77. package/dist/client/assets/{connection-form-helpers-vW7WD93k.js → connection-form-helpers-_Xw7Jp1j.js} +1 -1
  78. package/dist/client/assets/{connections-C6JDIrTa.js → connections-DJEG78Dv.js} +1 -1
  79. package/dist/client/assets/{context-menu-CFoKwdsl.js → context-menu-WSPOvmVH.js} +1 -1
  80. package/dist/client/assets/{decopilot-DgdLPSeb.js → decopilot-CPXrk6Nc.js} +1 -1
  81. package/dist/client/assets/{decopilot-sse-pool-BRv-o5yu.js → decopilot-sse-pool-Dc69PdCV.js} +1 -1
  82. package/dist/client/assets/{dialog-D9WjjXCi.js → dialog-DC6TTwSU.js} +1 -1
  83. package/dist/client/assets/{domain-settings-BzX_jmew.js → domain-settings-C1pK704i.js} +1 -1
  84. package/dist/client/assets/{drawer-B07QIoON.js → drawer-D-qJMn42.js} +1 -1
  85. package/dist/client/assets/{dropdown-menu-Cym0YADL.js → dropdown-menu-B3yjOr3B.js} +1 -1
  86. package/dist/client/assets/{empty-state-Dc-tsC-2.js → empty-state-WkcHfsbi.js} +1 -1
  87. package/dist/client/assets/{extract-connection-data-BSTqgqHH.js → extract-connection-data-D0kn1CiV.js} +1 -1
  88. package/dist/client/assets/{file-explorer-BfDoSrZk.js → file-explorer-rTq33vqz.js} +1 -1
  89. package/dist/client/assets/{file-type-icon-DtYuEk9O.js → file-type-icon-BphKjXRo.js} +1 -1
  90. package/dist/client/assets/{files-Brjfptic.js → files-B7FZKUGh.js} +1 -1
  91. package/dist/client/assets/{form-2979wdxX.js → form-g86n2zay.js} +1 -1
  92. package/dist/client/assets/{general-CTI0wRux.js → general-DQFzRc7X.js} +1 -1
  93. package/dist/client/assets/{github-repo-picker-BkDPWKjv.js → github-repo-picker-C6HuqJ8f.js} +1 -1
  94. package/dist/client/assets/{hooks-CMSXeMFL.js → hooks-CpWosBE0.js} +1 -1
  95. package/dist/client/assets/{import-from-deco-dialog-D-c4LLRp.js → import-from-deco-dialog-DHQFK9MP.js} +1 -1
  96. package/dist/client/assets/{index-D6hU96vm.js → index-3BRPugsV.js} +1 -1
  97. package/dist/client/assets/{index-eQTuHKl6.js → index-B1povjSt.js} +1 -1
  98. package/dist/client/assets/index-BTDSQgHj.js +503 -0
  99. package/dist/client/assets/{index-ndGiTd2H.js → index-Bnq_KeQl.js} +1 -1
  100. package/dist/client/assets/{index-Y-0r87FI.js → index-CKZ2Jo27.js} +1 -1
  101. package/dist/client/assets/{index-CHiBkNe7.js → index-CmTvfvqV.js} +1 -1
  102. package/dist/client/assets/{index-DFxFL0tW.js → index-D0VHzTLF.js} +1 -1
  103. package/dist/client/assets/index-DBaGwpyP.css +1 -0
  104. package/dist/client/assets/{index-CfQz19re.js → index-DDYqxneq.js} +1 -1
  105. package/dist/client/assets/{index-CcHBEZaL.js → index-DEAvf9Ss.js} +1 -1
  106. package/dist/client/assets/{index-gNo-Kuqg.js → index-DPmafiSm.js} +1 -1
  107. package/dist/client/assets/{index-DXI2OWA9.js → index-DPpLkDX2.js} +1 -1
  108. package/dist/client/assets/{index-CkgRi4X3.js → index-DeuQtcBQ.js} +1 -1
  109. package/dist/client/assets/{index-BYx78v24.js → index-UunSb5mF.js} +1 -1
  110. package/dist/client/assets/{index-vUJ0Rroa.js → index-V_z4g85O.js} +3 -3
  111. package/dist/client/assets/{index-redirect-C7otwZuS.js → index-redirect-CgRpP2To.js} +1 -1
  112. package/dist/client/assets/{input-D475ckPl.js → input-DVRfAVU3.js} +1 -1
  113. package/dist/client/assets/{integration-icon-DWC1E-NM.js → integration-icon-DdvXmN6b.js} +1 -1
  114. package/dist/client/assets/{label-Ds5L98Th.js → label-D1MGSLX0.js} +1 -1
  115. package/dist/client/assets/{login-Bna6EQXB.js → login-DlviF7QT.js} +1 -1
  116. package/dist/client/assets/{mcp-oauth-BuJKTbpq.js → mcp-oauth-DlBIPcRz.js} +1 -1
  117. package/dist/client/assets/{members-CfxGG4ms.js → members-HLvKGfjN.js} +1 -1
  118. package/dist/client/assets/{monaco-editor-BIbmj68Y.js → monaco-editor-Adha2rD5.js} +1 -1
  119. package/dist/client/assets/{monitoring-stats-row-FEqgyaSm.js → monitoring-stats-row-DoSzHe4u.js} +1 -1
  120. package/dist/client/assets/{oauth-callback-BTT9yfsW.js → oauth-callback-BLm1iokb.js} +1 -1
  121. package/dist/client/assets/{oauth-callback-ai-provider-NTmJLpKs.js → oauth-callback-ai-provider-8sG6eagR.js} +1 -1
  122. package/dist/client/assets/{onboarding-Bg6NNcXN.js → onboarding-iZKUv6aI.js} +1 -1
  123. package/dist/client/assets/{org-install-DU4xYSjy.js → org-install-C9Svi1Dd.js} +1 -1
  124. package/dist/client/assets/{org-layout-BI-1sw6-.js → org-layout-B46TOnBU.js} +1 -1
  125. package/dist/client/assets/{organization-choice-BKBCasUi.js → organization-choice-D5AMR6f-.js} +1 -1
  126. package/dist/client/assets/{page-seo-form-UXOt1Xq8.js → page-seo-form-DnlsqJ-m.js} +1 -1
  127. package/dist/client/assets/page-seo-sheet-BB-bVgSe.js +1 -0
  128. package/dist/client/assets/{popover-BEzlzjXA.js → popover-ChpnNBG6.js} +1 -1
  129. package/dist/client/assets/{post-editor-Dlb8m7Iz.js → post-editor-BI1JMrba.js} +1 -1
  130. package/dist/client/assets/{preview-dialog-DtFiLW4L.js → preview-dialog-CNgWM1Nd.js} +1 -1
  131. package/dist/client/assets/{primitives-BSQDvGLE.js → primitives-1UYw8T7c.js} +1 -1
  132. package/dist/client/assets/{profile-BnTQMGfC.js → profile-DlyPm-rk.js} +1 -1
  133. package/dist/client/assets/project-app-view-CxdK6kb-.js +1 -0
  134. package/dist/client/assets/record-editor-BPS6LmYc.js +1 -0
  135. package/dist/client/assets/registry-B54461Ff.js +2 -0
  136. package/dist/client/assets/{registry-layout-Che-hfuD.js → registry-layout-k5bH_SdU.js} +1 -1
  137. package/dist/client/assets/{require-capability-BPVqafNl.js → require-capability-Cnsb8ohV.js} +1 -1
  138. package/dist/client/assets/{required-auth-layout-0H2r_sG0.js → required-auth-layout-BrqLeeGH.js} +1 -1
  139. package/dist/client/assets/{reset-password-BnD36W_y.js → reset-password-Du_C_DrW.js} +1 -1
  140. package/dist/client/assets/{roles-E1DxEKKj.js → roles-DLI7p3m9.js} +1 -1
  141. package/dist/client/assets/{save-status-lTcRFIDk.js → save-status-B7sExUGT.js} +1 -1
  142. package/dist/client/assets/{scroll-area-BcHB6NVX.js → scroll-area-wkOEFA0d.js} +1 -1
  143. package/dist/client/assets/{search-input-DLLGaO2O.js → search-input-R9PP00jU.js} +1 -1
  144. package/dist/client/assets/{secrets-CPwF9JEQ.js → secrets-BBIIYJQL.js} +1 -1
  145. package/dist/client/assets/{sections-editor-C33mQAPq.js → sections-editor-Din5M3E7.js} +1 -1
  146. package/dist/client/assets/{select-wPD7z-7a.js → select-iQPDKsQJ.js} +1 -1
  147. package/dist/client/assets/{select-model-DRzRHvEm.js → select-model-GwKBIN6-.js} +1 -1
  148. package/dist/client/assets/{seo-editor-DVLMhS9K.js → seo-editor-C4-hewoS.js} +1 -1
  149. package/dist/client/assets/{settings-layout-D_rTN8X_.js → settings-layout-nQ4HGRFy.js} +1 -1
  150. package/dist/client/assets/{settings-section-DTFkKe0k.js → settings-section-C5yP5Si0.js} +1 -1
  151. package/dist/client/assets/{sheet-D7Sq65N5.js → sheet-B6_wuIQB.js} +1 -1
  152. package/dist/client/assets/{shell-controls-MZoa2pcn.js → shell-controls-BCEkmDxf.js} +1 -1
  153. package/dist/client/assets/{shell-layout-CicMe8M5.js → shell-layout-vJZz5HSU.js} +1 -1
  154. package/dist/client/assets/{shell-route-loading-ALc0mrI8.js → shell-route-loading-BpGUKC4D.js} +1 -1
  155. package/dist/client/assets/{sidebar-BBRwD7tX.js → sidebar-BC3PqZZk.js} +1 -1
  156. package/dist/client/assets/{skeleton-Et7A2pSm.js → skeleton-D_8-XLai.js} +1 -1
  157. package/dist/client/assets/{sortable.esm-DHRoGvrT.js → sortable.esm-g-r61mRK.js} +1 -1
  158. package/dist/client/assets/{sso-C92vsbFf.js → sso-D-jPiEUA.js} +1 -1
  159. package/dist/client/assets/{store-BkJbUZAQ.js → store-CdLz3AFq.js} +1 -1
  160. package/dist/client/assets/store-registry-cn1ZHxyv.js +2 -0
  161. package/dist/client/assets/{studio-tools-BZzXzwRs.js → studio-tools-CcWLJIL3.js} +1 -1
  162. package/dist/client/assets/{switch-CS7rft2F.js → switch-DAdK-1sZ.js} +1 -1
  163. package/dist/client/assets/{table-6zTgSv0k.js → table-DlwTq8lg.js} +1 -1
  164. package/dist/client/assets/{tabs-NT5hIgye.js → tabs-B6a4ZhCv.js} +1 -1
  165. package/dist/client/assets/{task-status-BGl9HRbw.js → task-status-CG5Li56E.js} +1 -1
  166. package/dist/client/assets/{textarea-Dv2h0FHy.js → textarea-DkgswAud.js} +1 -1
  167. package/dist/client/assets/{toggle-group-BlIuQKMU.js → toggle-group-BYYV7q2R.js} +1 -1
  168. package/dist/client/assets/{toolbar-Dqn0u_dp.js → toolbar-CMnKNoMl.js} +1 -1
  169. package/dist/client/assets/{tooltip-CMUaL9C1.js → tooltip-Bodmhuae.js} +1 -1
  170. package/dist/client/assets/{types-BSxSWkiR.js → types-IxCSiIKg.js} +1 -1
  171. package/dist/client/assets/{use-ai-providers-DzNi6Q_V.js → use-ai-providers-Dr3wiSPj.js} +1 -1
  172. package/dist/client/assets/{use-automations-DBCBw7t_.js → use-automations-CktQtzNu.js} +1 -1
  173. package/dist/client/assets/{use-capability-hUlYEzZt.js → use-capability-mUGdJwF_.js} +1 -1
  174. package/dist/client/assets/{use-clock-tick-BQWtBapt.js → use-clock-tick-Db61_Lpl.js} +1 -1
  175. package/dist/client/assets/{use-collections-CmcFURA8.js → use-collections-gMfZ5Rvk.js} +1 -1
  176. package/dist/client/assets/{use-connection-BlyaSvk_.js → use-connection-DY54rYyd.js} +1 -1
  177. package/dist/client/assets/{use-copy-Ck1s3Ly_.js → use-copy-BaIsIuIB.js} +1 -1
  178. package/dist/client/assets/{use-create-virtual-mcp-C6iKxwna.js → use-create-virtual-mcp-C92AqYem.js} +1 -1
  179. package/dist/client/assets/{use-debounced-autosave-B3PmQihS.js → use-debounced-autosave-CgWI7Lb7.js} +1 -1
  180. package/dist/client/assets/{use-delete-connection-QgWRMpRZ.js → use-delete-connection-BP5srM_m.js} +1 -1
  181. package/dist/client/assets/{use-file-configs-D4iNPF8_.js → use-file-configs-CxuIY0bl.js} +1 -1
  182. package/dist/client/assets/{use-infinite-scroll-D0Uygp_Y.js → use-infinite-scroll-CcoRA6NH.js} +1 -1
  183. package/dist/client/assets/{use-join-requests-BVSkwLEZ.js → use-join-requests-CezHwAN7.js} +1 -1
  184. package/dist/client/assets/{use-mcp-client-CbMJzr4L.js → use-mcp-client-DsIzdxc1.js} +1 -1
  185. package/dist/client/assets/{use-mcp-prompts-BCcxOooU.js → use-mcp-prompts-CwZBO4qi.js} +1 -1
  186. package/dist/client/assets/{use-mcp-tools-CoU1W6We.js → use-mcp-tools-BAGnYViX.js} +1 -1
  187. package/dist/client/assets/{use-members-BkVP92fJ.js → use-members-Rhm6WZIF.js} +1 -1
  188. package/dist/client/assets/{use-navigate-to-agent-DAdQNXr7.js → use-navigate-to-agent-BzP0osS7.js} +1 -1
  189. package/dist/client/assets/{use-org-auth-client-BVVEzYWX.js → use-org-auth-client-CL0p_f0y.js} +1 -1
  190. package/dist/client/assets/{use-org-sso-BwpmbYKY.js → use-org-sso-CFcfBOij.js} +1 -1
  191. package/dist/client/assets/{use-organization-roles-CubNpt4Q.js → use-organization-roles-Banmg_pK.js} +1 -1
  192. package/dist/client/assets/{use-organization-settings-BlTbQ8o8.js → use-organization-settings-C13VUvc7.js} +1 -1
  193. package/dist/client/assets/{use-registry-connections-6RdLigQp.js → use-registry-connections-D7CDGVjW.js} +1 -1
  194. package/dist/client/assets/{use-secrets-fz_TrA3p.js → use-secrets-C6okhs5V.js} +1 -1
  195. package/dist/client/assets/{use-status-sounds-BRVcePS8.js → use-status-sounds-C-rHNkXR.js} +1 -1
  196. package/dist/client/assets/{use-view-mode-BHx0KhQn.js → use-view-mode-Brlii9ZZ.js} +1 -1
  197. package/dist/client/assets/{use-virtual-mcp-BgEUqJv7.js → use-virtual-mcp-oC_oTaOn.js} +1 -1
  198. package/dist/client/assets/useInfiniteQuery-BDW2fh8c.js +1 -0
  199. package/dist/client/assets/useSuspenseInfiniteQuery-Bfsxp_qn.js +1 -0
  200. package/dist/client/assets/{variant-calendar-cujTqFIv.js → variant-calendar-DrknBuXM.js} +1 -1
  201. package/dist/client/assets/{view-mode-toggle-Bpaa83uS.js → view-mode-toggle-Dgssa66x.js} +1 -1
  202. package/dist/client/index.html +2 -2
  203. package/dist/server/cli.js +1 -1
  204. package/package.json +1 -1
  205. package/dist/client/assets/category-editor-UeZPwCgj.js +0 -1
  206. package/dist/client/assets/index-pvUD-kUc.js +0 -503
  207. package/dist/client/assets/index-xCrqP1qS.css +0 -1
  208. package/dist/client/assets/page-seo-sheet-Cb5cCBSA.js +0 -1
  209. package/dist/client/assets/project-app-view-C9CksfQE.js +0 -1
  210. package/dist/client/assets/record-editor-BjHlAGT_.js +0 -1
  211. package/dist/client/assets/registry-Bq0zziYB.js +0 -2
  212. package/dist/client/assets/store-registry-Pmy6lYa3.js +0 -2
  213. package/dist/client/assets/useInfiniteQuery-ChBCbSD3.js +0 -1
  214. package/dist/client/assets/useSuspenseInfiniteQuery-COloy4Cl.js +0 -1
@@ -1,503 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-C33mQAPq.js","assets/index-vUJ0Rroa.js","assets/index-xCrqP1qS.css","assets/ChevronDown-BY59w4Qk.js","assets/ChevronLeft-DVIgNVyn.js","assets/ChevronRight-CM2UCxLV.js","assets/ChevronUp-ELVqY6cz.js","assets/agent-icon-BUISstKv.js","assets/AlertCircle-DifM-3Ys.js","assets/Tool01-CqbO1hX2.js","assets/SwitchHorizontal01-DO04KALD.js","assets/Settings02-RazZjdiv.js","assets/XCircle-CNgW1bnA.js","assets/ArrowUpRight-DTNfyjlQ.js","assets/ZapSquare-wbaFJ6J6.js","assets/Users03-V7VYPOVz.js","assets/CheckCircle-DmLgOHHp.js","assets/DotsVertical-FbZSolmB.js","assets/Stars02-l9mDD3eo.js","assets/Eye-8PGvC0iK.js","assets/ZoomOut-XI-iJG4j.js","assets/Globe01-B90chNia.js","assets/FilterLines-Cf2PdvFM.js","assets/Star01-C9VN0Du_.js","assets/Globe04-Dw4nWd3A.js","assets/HardDrive-CKn4i_9T.js","assets/Key01-oftOkafI.js","assets/LayoutLeft-Bij2Lb4X.js","assets/LinkExternal01-9FNotiMN.js","assets/Monitor01-CR1JDEQ7.js","assets/Sun-D-fwbx_z.js","assets/Palette-ArrfZuOV.js","assets/Play-BB5dP1L8.js","assets/Plus-CglBKrb5.js","assets/SearchMd-Bmh_sD0S.js","assets/Shield01-D44r3AdO.js","assets/Stars01-CoxwYWLP.js","assets/Trash01-DUxygeaL.js","assets/Upload01-CEAuuYpa.js","assets/User01-fdrqbZOX.js","assets/Users01-BQH1rUR7.js","assets/XClose-DY_H1WmQ.js","assets/X-DH6rpzm4.js","assets/Zap-jC0lbn1q.js","assets/scroll-area-BcHB6NVX.js","assets/use-clock-tick-BQWtBapt.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-Ck1s3Ly_.js","assets/tooltip-CMUaL9C1.js","assets/file-type-icon-DtYuEk9O.js","assets/dialog-D9WjjXCi.js","assets/tab-id-BptcWVWa.js","assets/content-blocks-o63cs2vh.js","assets/types-BSxSWkiR.js","assets/use-mcp-client-CbMJzr4L.js","assets/auth-COC6Da1O.js","assets/chat-context-D2XCyHNy.js","assets/hooks-CMSXeMFL.js","assets/decopilot-sse-pool-BRv-o5yu.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/use-virtual-mcp-BgEUqJv7.js","assets/use-collections-CmcFURA8.js","assets/use-ai-providers-DzNi6Q_V.js","assets/studio-tools-BZzXzwRs.js","assets/use-organization-settings-BlTbQ8o8.js","assets/shell-layout-CicMe8M5.js","assets/avatar-yxz7fyGH.js","assets/required-auth-layout-0H2r_sG0.js","assets/use-org-sso-BwpmbYKY.js","assets/sheet-D7Sq65N5.js","assets/integration-icon-DWC1E-NM.js","assets/use-navigate-to-agent-DAdQNXr7.js","assets/use-connection-BlyaSvk_.js","assets/use-mcp-prompts-BCcxOooU.js","assets/form-2979wdxX.js","assets/label-Ds5L98Th.js","assets/input-D475ckPl.js","assets/select-wPD7z-7a.js","assets/dropdown-menu-Cym0YADL.js","assets/sortable.esm-DHRoGvrT.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-BavDtRRe.js","assets/use-registry-connections-6RdLigQp.js","assets/useInfiniteQuery-ChBCbSD3.js","assets/use-infinite-scroll-D0Uygp_Y.js","assets/extract-connection-data-BSTqgqHH.js","assets/card-Bj8otFuN.js","assets/collection-search-Bde6_LbH.js","assets/collection-tabs-CmheS0lt.js","assets/badge-CQquKN9p.js","assets/drawer-B07QIoON.js","assets/textarea-Dv2h0FHy.js","assets/connection-form-helpers-vW7WD93k.js","assets/authenticate-and-persist-oauth-7kSYvcg8.js","assets/mcp-oauth-BuJKTbpq.js","assets/useSuspenseInfiniteQuery-COloy4Cl.js","assets/page-seo-form-UXOt1Xq8.js","assets/switch-CS7rft2F.js","assets/add-section-modal-DbYQ6fO0.js","assets/index-Y-0r87FI.js","assets/tabs-NT5hIgye.js","assets/toggle-group-BlIuQKMU.js","assets/connect-desktop-dialog-CSA1yCDL.js","assets/decopilot-DgdLPSeb.js","assets/checkbox-Da1mUHNU.js","assets/skeleton-Et7A2pSm.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-DTFkKe0k.js","assets/popover-BEzlzjXA.js","assets/command-D_g4Qh6z.js","assets/index-BYx78v24.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-BRVcePS8.js","assets/empty-state-Dc-tsC-2.js","assets/toolbar-Dqn0u_dp.js","assets/preview-dialog-DtFiLW4L.js","assets/index-D6hU96vm.js","assets/use-mcp-tools-CoU1W6We.js","assets/use-capability-hUlYEzZt.js","assets/shell-route-loading-ALc0mrI8.js","assets/index-CkgRi4X3.js","assets/alert-dialog-Dh6V_14o.js","assets/use-debounced-autosave-B3PmQihS.js","assets/index-DXI2OWA9.js","assets/sidebar-BBRwD7tX.js","assets/search-input-DLLGaO2O.js","assets/github-repo-picker-BkDPWKjv.js","assets/use-secrets-fz_TrA3p.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/view-mode-toggle-Bpaa83uS.js","assets/automation-runs-DMkXGxyD.js","assets/table-6zTgSv0k.js","assets/use-members-BkVP92fJ.js","assets/use-org-auth-client-BVVEzYWX.js","assets/task-status-BGl9HRbw.js","assets/use-automations-DBCBw7t_.js","assets/use-file-configs-D4iNPF8_.js","assets/monaco-editor-BIbmj68Y.js","assets/select-model-DRzRHvEm.js","assets/automation-list-row-DCvQVGai.js","assets/page-seo-sheet-Cb5cCBSA.js","assets/file-explorer-BfDoSrZk.js","assets/context-menu-CFoKwdsl.js","assets/app-editor-BI1KpS86.js","assets/save-status-lTcRFIDk.js","assets/post-editor-Dlb8m7Iz.js","assets/primitives-BSQDvGLE.js","assets/block-document-BBSIfcJ0.js","assets/record-editor-BjHlAGT_.js","assets/category-editor-UeZPwCgj.js","assets/seo-editor-DVLMhS9K.js","assets/variant-calendar-cujTqFIv.js","assets/project-app-view-C9CksfQE.js"])))=>i.map(i=>d[i]);
2
- import{c as U,r as D,l as ae,j as n,i as Oe,v as Me,a as $i,a2 as Zt,b as qt,u as eo,e as Fh,s as qp,L as Gp,k as Es,K as Et,m as oi,a3 as to,a4 as Yp,a5 as Xp,t as he,B as ie,a6 as Hh,a7 as Jp,a8 as Zp,q as Ke,a9 as Uh,aa as Qp,ab as so,ac as Pn,ad as Ht,ae as eg,E as Wh,C as tg,x as Vh,af as Ut,P as Kh,ag as sg,U as ig,$ as qh,W as ng,ah as rg,Q as og,ai as ag,d as ai,y as pr,aj as pn,z as ns,ak as ls}from"./index-vUJ0Rroa.js";import{C as it,a as lg,w as cg,u as ll,s as oa,T as dg,b as hg,g as ug,c as fg}from"./index-Y-0r87FI.js";import{u as li,a as Ts,b as cl,c as Gh,S as dl,t as mg,d as pg}from"./chat-context-D2XCyHNy.js";import{i as zi}from"./AlertCircle-DifM-3Ys.js";import{i as Yh}from"./CheckCircle-DmLgOHHp.js";import{n as Tc}from"./ChevronLeft-DVIgNVyn.js";import{a as gg,b as _g,i as vg}from"./XCircle-CNgW1bnA.js";import{s as Hs}from"./XClose-DY_H1WmQ.js";import{a as vs,u as hl,b as Xh,c as xg}from"./use-virtual-mcp-BgEUqJv7.js";import{c as bg,u as yg,a as Jh,O as Sg,t as aa,S as Fi,T as wg,b as Zh,R as Cg,C as kg,G as jg,d as Ng,i as Eg,E as Tg,g as Ag,s as Rg,e as Pg,f as Dg,h as Ig}from"./scroll-area-BcHB6NVX.js";import{I as xs}from"./integration-icon-DWC1E-NM.js";import{a as Qh,u as Pt,S as ul,b as Lg,c as Og,i as Bg,d as eu}from"./use-mcp-client-CbMJzr4L.js";import{a as Mg}from"./Users03-V7VYPOVz.js";import{t as cs}from"./ChevronDown-BY59w4Qk.js";import{u as $g,h as zg,a as Wn,i as tu,j as ti,g as Fg,A as Hg,b as su,c as wr,K as iu,P as nu,D as ru,d as ou,S as au,v as lu,k as cu,l as la,e as du,C as hu,s as uu,m as Ug,n as Wg}from"./sortable.esm-DHRoGvrT.js";import{u as fu}from"./use-ai-providers-DzNi6Q_V.js";import{u as Vg}from"./connect-desktop-dialog-CSA1yCDL.js";import{r as Kg,b as fl,i as qg}from"./shell-layout-CicMe8M5.js";import{u as ml,T as Ne,a as Ee,b as Te,c as mu}from"./tooltip-CMUaL9C1.js";import{u as Gg}from"./use-status-sounds-BRVcePS8.js";import{E as Cr}from"./empty-state-Dc-tsC-2.js";import{r as ca,a as Yg,p as pu,f as Ac,b as gu,c as _u,d as vu,e as Xg,F as Jg,i as Zg,g as Qg,h as xu,j as bu}from"./tab-id-BptcWVWa.js";import{u as yu,a as Su}from"./hooks-CMSXeMFL.js";import{T as Rc,a as gn}from"./toolbar-Dqn0u_dp.js";import{u as e_,a as t_,b as s_,c as i_,g as n_,d as wu,e as Pc,f as r_,F as o_,h as a_,i as l_,j as c_,k as d_,l as h_,m as u_,H as f_,L as m_,R as Cu,n as p_,o as g_,T as pl,p as __,q as v_}from"./preview-dialog-DtFiLW4L.js";import{g as Dn,h as gl,j as ku,k as x_,p as io,l as ci,m as _l,n as ju,o as da,q as wo,r as Dc,A as Ic,s as b_,t as y_,u as S_,v as w_,w as C_,x as Nu,y as k_,z as j_,B as N_,C as E_,D as Hi,E as T_,F as Lc,G as Oc,H as A_,d as R_,I as P_,J as D_,K as Ni,L as kr,M as no,N as I_,O as L_,P as O_,Q as B_,R as M_,S as $_,T as Eu,U as Ri,V as Bc,W as Tu,X as ro,Y as z_,Z as F_,_ as H_,$ as U_,a0 as W_,a1 as Mc,a2 as V_,a3 as K_,a4 as q_,a5 as Au,a6 as G_}from"./agent-icon-BUISstKv.js";import{i as Ui,n as Y_}from"./Globe01-B90chNia.js";import{i as Ru}from"./Monitor01-CR1JDEQ7.js";import{u as Vn,a as vl,b as Pu}from"./use-connection-BlyaSvk_.js";import{u as oo,a as Du,b as Iu}from"./use-mcp-tools-CoU1W6We.js";import{g as Lu}from"./types-BSxSWkiR.js";import{u as di}from"./studio-tools-BZzXzwRs.js";import{u as X_}from"./use-capability-hUlYEzZt.js";import{F as Pi,M as xl,O as J_}from"./file-type-icon-DtYuEk9O.js";import{P as As,a as Rs,b as Ps}from"./popover-BEzlzjXA.js";import{b as kt,c as Rt,S as jt,a as tt,d as Nt}from"./select-wPD7z-7a.js";import{D as Wt,a as Vt,b as Kt,c as Ue,d as ha,e as ua,f as fa,g as Cn,h as In,i as Co,j as ko}from"./dropdown-menu-Cym0YADL.js";import{d as Bt,c as Mt,D as ts,a as ss,e as Ws,b as Wi}from"./dialog-D9WjjXCi.js";import{I as ze}from"./input-D475ckPl.js";import{T as zs,a as ao,b as Ei,c as lo}from"./tabs-NT5hIgye.js";import{T as Ln}from"./textarea-Dv2h0FHy.js";import{a as as,s as Z_}from"./Eye-8PGvC0iK.js";import{t as Zs}from"./Stars01-CoxwYWLP.js";import{l as Q_,w as e1}from"./index-D6hU96vm.js";import{i as Vi}from"./ChevronRight-CM2UCxLV.js";import{a as ma,b as Ou,c as bl}from"./ZoomOut-XI-iJG4j.js";import{S as t1}from"./shell-route-loading-ALc0mrI8.js";import{a as s1}from"./extract-connection-data-BSTqgqHH.js";import{A as jo}from"./avatar-yxz7fyGH.js";import{T as Bu,u as Mu,I as i1,R as n1,a as r1}from"./index-CkgRi4X3.js";import{a as o1,i as $c}from"./mcp-oauth-BuJKTbpq.js";import{s as $u,g as a1}from"./connection-slug-eyAPH6o3.js";import{f as jr,a as Nr,b as Er,c as Tr,d as Ar,e as Rr,A as Pr,g as Dr}from"./alert-dialog-Dh6V_14o.js";import{C as yl,a as Ir}from"./card-Bj8otFuN.js";import{L as Ve}from"./label-Ds5L98Th.js";import{S as On}from"./switch-CS7rft2F.js";import{i as Di}from"./Play-BB5dP1L8.js";import{s as Dt}from"./Plus-CglBKrb5.js";import{a as l1,i as zu}from"./Settings02-RazZjdiv.js";import{s as es}from"./Trash01-DUxygeaL.js";import{u as Lr}from"./use-debounced-autosave-B3PmQihS.js";import{i as Bn}from"./SearchMd-Bmh_sD0S.js";import{i as Kn}from"./Upload01-CEAuuYpa.js";import{i as c1}from"./LayoutLeft-Bij2Lb4X.js";import{P as os}from"./index-DXI2OWA9.js";import{C as Ki}from"./checkbox-Da1mUHNU.js";import{S as Fu}from"./search-input-DLLGaO2O.js";import{C as Hu}from"./collection-tabs-CmheS0lt.js";import{u as d1}from"./use-mcp-prompts-BCcxOooU.js";import{b as h1,a as u1,D as f1}from"./drawer-B07QIoON.js";import{i as js}from"./ChevronUp-ELVqY6cz.js";import{i as Sl}from"./Key01-oftOkafI.js";import{a as Uu,G as m1}from"./github-repo-picker-BkDPWKjv.js";import{S as wl}from"./skeleton-Et7A2pSm.js";import{s as p1}from"./User01-fdrqbZOX.js";import{t as co}from"./Users01-BQH1rUR7.js";import{u as g1,a as _1}from"./use-secrets-fz_TrA3p.js";import{f as v1}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as hi}from"./LinkExternal01-9FNotiMN.js";import{s as si}from"./Star01-C9VN0Du_.js";import{i as Wu,s as kn}from"./Stars02-l9mDD3eo.js";import{V as x1}from"./view-mode-toggle-Bpaa83uS.js";import{n as pa}from"./ZapSquare-wbaFJ6J6.js";import{i as b1,a as Ii,b as Cl,c as kl}from"./Tool01-CqbO1hX2.js";import{i as y1,c as Vu,a as S1}from"./SwitchHorizontal01-DO04KALD.js";import{i as jl}from"./X-DH6rpzm4.js";import{i as w1,a as C1}from"./DotsVertical-FbZSolmB.js";import{C as k1,A as j1}from"./automation-runs-DMkXGxyD.js";import{b as Nl,C as El,a as Or,e as Br,c as Tl,d as Ku,f as N1}from"./command-D_g4Qh6z.js";import{u as E1,a as qu}from"./use-file-configs-D4iNPF8_.js";import{u as T1}from"./useInfiniteQuery-ChBCbSD3.js";import{i as A1}from"./FilterLines-Cf2PdvFM.js";import{M as Gu}from"./monaco-editor-BIbmj68Y.js";import{B as R1}from"./badge-CQquKN9p.js";import{M as P1}from"./select-model-DRzRHvEm.js";import{u as qn,a as D1,b as I1,c as L1,d as O1}from"./use-automations-DBCBw7t_.js";import{i as Mn}from"./Zap-jC0lbn1q.js";import{A as B1}from"./automation-list-row-DCvQVGai.js";function nn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function zc(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 M1(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function $1(t){const e=U.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(z1),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 z1(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 F1(t){const e=U.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,d=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 h;e[2]!==l?(h=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==d?(u=d>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${d}%`}}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==h||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,h,u]}),e[6]=c,e[7]=h,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 g;e[13]!==p?(g=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]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let b;e[16]!==l?(b=l.toFixed(1),e[16]=l,e[17]=b):b=e[17];let x;e[18]!==b?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",b,"%"]})]}),e[18]=b,e[19]=x):x=e[19];let v;e[20]!==d||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 ",d.toFixed(1),"%"]})]}),e[20]=d,e[21]=r,e[22]=v):v=e[22];let y;e[23]!==x||e[24]!==v||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,v]}),e[23]=x,e[24]=v,e[25]=g,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 H1(t){const e=U.c(11),{agentId:s,isError:i}=t,r=vs(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(xs,{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 d=i?"text-destructive":"text-foreground";let c;e[3]!==d?(c=ae("shrink-0 font-medium",d),e[3]=d,e[4]=c):c=e[4];let h;e[5]!==o||e[6]!==c?(h=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=n.jsxs(n.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function U1(t){const e=U.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(xs,{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=ae("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 W1(t){const e=U.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(U1,{isError:o}),e[0]=o,e[1]=l):l=e[1];let d;e[2]!==i||e[3]!==o?(d=n.jsx(H1,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=n.jsx(D.Suspense,{fallback:l,children:d}),e[5]=l,e[6]=d,e[7]=c):c=e[7];let h;e[8]!==s.input?(h=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]=h):h=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(Oe,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(gg,{size:12,className:"text-destructive"}):a?n.jsx(zi,{size:12,className:"text-warning"}):n.jsx(Yh,{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]!==h||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,h,u]}),e[14]=c,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function V1(t){const e=U.c(55),{onClose:s,back:i,className:r}=t,[o,a]=D.useState(null),{messages:l}=li(),{activeTask:d}=Ts(),{selectedModel:c,selectedVirtualMcp:h}=cl();let u,f,m,p,g,_,b,x;if(e[0]!==d||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==h?.title){x=Symbol.for("react.early_return_sentinel");e:{const S=bg(l),w=[...l].reverse().find(sv),C=w?.metadata?.usage,N=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,E=C?.contextTokens??0,R=N&&N>0?(E/N*100).toFixed(1):null,T=l;let k;e[16]!==T?(k=T.filter(tv).reduce(ev,0),e[16]=T,e[17]=k):k=e[17];const j=k,I=l;let A;e[18]!==I?(A=I.filter(Q1).reduce(Z1,0),e[18]=I,e[19]=A):A=e[19];const O=A,L=Math.max(0,S.totalTokens-j-O),P=l[0],B=l.at(-1),F=P?.metadata?.created_at??d?.created_at,H=B?.metadata?.created_at??d?.updated_at,z=l.filter(J1),W=l.flatMap(Y1),q=c?.modelId?M1(c.modelId):"—",K=h?.title??"Decopilot",Z=[{label:"Session",value:d?.title??"New chat"},{label:"Messages",value:z.length},{label:"Agent",value:K},{label:"Model",value:q},{label:"Context Limit",value:N?nn(N):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?nn(S.totalTokens):"0"},{label:"Usage",value:R!==null?`${R}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?nn(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?nn(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?nn(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:zc(F)},{label:"Last Activity",value:zc(H)}];if(!d&&z.length===0){let $;e[20]!==r?($=ae("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=$):$=e[21];let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=X):X=e[22];let V;e[23]!==i?(V=i?n.jsx(Tc,{size:14,className:"text-muted-foreground"}):n.jsx(Hs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=V):V=e[24];let se;e[25]!==s||e[26]!==V?(se=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[X,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:V})]}),e[25]=s,e[26]=V,e[27]=se):se=e[27];let ee;e[28]===Symbol.for("react.memo_cache_sentinel")?(ee=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]=ee):ee=e[28];let le;e[29]!==$||e[30]!==se?(le=n.jsxs("div",{className:$,children:[se,ee]}),e[29]=$,e[30]=se,e[31]=le):le=e[31],x=le;break e}e[32]!==r?(_=ae("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=_):_=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Y):Y=e[34];let G;e[35]!==i?(G=i?n.jsx(Tc,{size:14}):n.jsx(Hs,{size:14}),e[35]=i,e[36]=G):G=e[36],e[37]!==s||e[38]!==G?(b=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,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:G})]}),e[37]=s,e[38]=G,e[39]=b):b=e[39],u="flex flex-col gap-8 p-6",f=W.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:W.map(G1)})]}),m=n.jsx($1,{items:Z});let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=Q):Q=e[40],e[41]!==O||e[42]!==L||e[43]!==j?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[Q,n.jsx(F1,{userTokens:j,assistantTokens:O,otherTokens:L})]}),e[41]=O,e[42]=L,e[43]=j,e[44]=p):p=e[44],g=z.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:z.map($=>{const X=$.metadata?.created_at,V=o?.id===$.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(V?null:$),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:ae("shrink-0 font-medium",$.role==="user"?"text-chart-1":"text-chart-2"),children:$.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:$.id})]}),X&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(X).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),V&&n.jsxs(n.Fragment,{children:[$.role==="assistant"&&(()=>{const se=$.metadata?._request;if(!se)return null;const ee=se.systemSections??[],le=Math.max(1,...ee.map(q1)),ce=ee.reduce(K1,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:[se.activeTools??0," / ",se.tools??0," ","tools active"]})]}),ee.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(ce/4).toLocaleString()," ","tok"]})]}),ee.map((fe,J)=>{const te=fe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${J}`,oe=fe.chars/le*100,de=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:te}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",de.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:`${oe}%`}})})]},J)})]})]})})(),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($,null,2)})]})]},$.id)})})]})}e[0]=d,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=b,e[15]=x}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],b=e[14],x=e[15];if(x!==Symbol.for("react.early_return_sentinel"))return x;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(v=n.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=v):v=e[50];let y;return e[51]!==_||e[52]!==b||e[53]!==v?(y=n.jsxs("div",{className:_,children:[b,v]}),e[51]=_,e[52]=b,e[53]=v,e[54]=y):y=e[54],y}function K1(t,e){return t+e.chars}function q1(t){return t.chars}function G1(t,e){return n.jsx(W1,{part:t},e)}function Y1(t){return(t.parts??[]).filter(X1)}function X1(t){return t.type==="tool-subtask"}function J1(t){return t.role!=="system"}function Z1(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Q1(t){return t.role==="assistant"}function ev(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function tv(t){return t.role==="user"}function sv(t){return t.role==="assistant"&&t.metadata?.usage}function iv(t){const e=U.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let d;e[0]!==r||e[1]!==s?(d=!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]=d):d=e[2];let c;e[3]!==o||e[4]!==d?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[d,o]}),e[3]=o,e[4]=d,e[5]=c):c=e[5];let h;e[6]!==a||e[7]!==s?(h=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=h):h=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==h?(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,h]})}),e[9]=l,e[10]=c,e[11]=h,e[12]=u):u=e[12],u}function nv(t){const e=U.c(25),{onOpenContextPanel:s}=t,{org:i}=Me(),{selectedVirtualMcp:r}=cl();let o;e[0]!==i.id?(o=Qh(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,d=vs(l.id),c=Gh(),{data:h}=$i.useSession(),u=h?.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(Mg,{size:32}),e[2]=p):p=e[2];let g;e[3]!==l.icon||e[4]!==l.title?(g=n.jsx(xs,{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]=g):g=e[5];let _;e[6]!==l.title?(_=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=_):_=e[7];const b=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let x;e[8]!==b?(x=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:b}),e[8]=b,e[9]=x):x=e[9];let v;e[10]!==g||e[11]!==_||e[12]!==x?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[g,_,x]}),e[10]=g,e[11]=_,e[12]=x,e[13]=v):v=e[13];const y=c?.currentBranch??null;let S;e[14]!==d||e[15]!==y?(S=n.jsx(lg,{virtualMcp:d,currentBranch:y}),e[14]=d,e[15]=y,e[16]=S):S=e[16];let w;e[17]!==s?(w=n.jsx(it.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(it.IceBreakers,{}),e[19]=C):C=e[19];let N;return e[20]!==m||e[21]!==w||e[22]!==v||e[23]!==S?(N=n.jsx(iv,{readOnly:m,identity:v,aboveRow:S,input:w,iceBreakers:C}),e[20]=m,e[21]=w,e[22]=v,e[23]=S,e[24]=N):N=e[24],N}function Fc(t){const e=U.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=ae(a),e[0]=a,e[1]=l):l=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=d):d=e[2];const c=i&&"-rotate-90";let h;e[3]!==c?(h=ae("size-4 text-muted-foreground transition-transform",c),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==h?(u=n.jsx(cs,{className:h}),e[5]=h,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:[d,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(rv)}),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 rv(t){return n.jsx(Sg,{file:t},t.key)}function ov(){const t=U.c(13),e=Gh()?.taskId??null,s=yg();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Jh(e,i),[o,a]=D.useState(!1),[l,d]=D.useState(!0);if(!e||!r||r.length===0)return null;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>a(lv),t[2]=c):c=t[2];let h;t[3]!==o||t[4]!==r?(h=n.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:n.jsx(Fc,{variant:"card",outputs:r,collapsed:o,onToggle:c})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>d(av),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(Fc,{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]!==h||t[11]!==f?(m=n.jsxs(n.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function av(t){return!t}function lv(t){return!t}function cv(){const t=U.c(26),{org:e}=Me(),s=fu(),{isChatEmpty:i}=li(),[r,o]=D.useState("chat"),a=$g(),l=Vg();if(s.length===0&&!zg(l)){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(it,{className:"animate-in fade-in-0 duration-200",children:n.jsx(it.Main,{className:"flex flex-col items-center",children:n.jsx(it.EmptyState,{children:n.jsx(it.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let c;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!cg(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=c):c=t[7];const h=c;let u;t[8]!==h?(u=h&&n.jsx(it.CreditsEmptyState,{}),t[8]=h,t[9]=u):u=t[9];const f=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;t[10]!==f?(m=ae("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[10]=f,t[11]=m):m=t[11];let p;t[12]!==i?(p=i?n.jsx(it.Main,{children:n.jsx(nv,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(it.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(ov,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(it.Messages,{})})]}),n.jsx(it.Footer,{children:n.jsx(it.Input,{onOpenContextPanel:()=>o("context")})})]}),t[12]=i,t[13]=p):p=t[13];let g;t[14]!==m||t[15]!==p?(g=n.jsx("div",{className:m,children:p}),t[14]=m,t[15]=p,t[16]=g):g=t[16];const _=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let b;t[17]!==_?(b=ae("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=b):b=t[18];let x;t[19]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(V1,{back:!0,onClose:()=>o("chat")}),t[19]=x):x=t[19];let v;t[20]!==b?(v=n.jsx("div",{className:b,children:x}),t[20]=b,t[21]=v):v=t[21];let y;return t[22]!==u||t[23]!==g||t[24]!==v?(y=n.jsxs(it,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[u,g,v]}),t[22]=u,t[23]=g,t[24]=v,t[25]=y):y=t[25],y}function Yu(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(it.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Zt,{fallback:e,children:n.jsx(D.Suspense,{fallback:n.jsx(it.Skeleton,{}),children:n.jsx(cv,{})})}),t[1]=s):s=t[1],s}function dv(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 Hc(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 hv(t,e){return t===1?!0:t===0?!1:e}function uv(t,e){const s=qt(),i=eo({strict:!1}),r=Fh({strict:!1}),{create:o}=yu(),{locator:a}=Me(),{virtualMcpId:l,orgSlug:d,isAgentRoute:c}=e,h=dv({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=hv(i.chat,h.chatOpen),f=h.mainOpen,m=D.useRef(crypto.randomUUID()),p=r.taskId??m.current,g="/$org/$taskId",_=E=>({org:d,taskId:E}),b=c?{virtualmcpid:l}:{},x=(E,R)=>{s({to:g,params:_(p),search:T=>({...T,...E}),replace:R?.replace??!1})},v=(E,R)=>{s({to:g,params:_(E),search:T=>{const k={};return R?k.virtualmcpid=R:c&&(k.virtualmcpid=l),k}})},y=()=>{f?x({main:"0"},{replace:!0}):x({main:ca(t)},{replace:!0})},S=()=>{x({chat:u?0:1},{replace:!0})},w=()=>{u||x({chat:1},{replace:!0})},C=async()=>{const E=crypto.randomUUID(),R=Kg(d,a,p);try{await o({id:E,virtual_mcp_id:l,...R?{branch:R}:{}})}catch{}s({to:g,params:_(E),search:T=>({...b,chat:1})})},N=E=>{x({main:E},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:y,toggleChat:S,openChat:w,createNewTask:C,openTab:N}}const Al=45;function Xu(t,e=Al){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function fv(t){return Xu(t,Al)}function mv(){const t=U.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Gp.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=qp(e,fv);let r;t[1]!==s?(r=Xu(s,Al),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 pv(t){try{return JSON.parse(t)}catch{return null}}function gv(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?pv(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function ui(t){const e=gv(t);return e===null?null:e}function Rl(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 _v(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=Rl(s);return!i||!s?null:{number:i,htmlUrl:s}}const Uc=/[\r\n<>]/,vv=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Gn(t){const e=t?.userName?.trim();if(!e||Uc.test(e))return null;const s=t?.userEmail?.trim();return!s||Uc.test(s)?{userName:e}:vv.test(s)?{userName:e,userEmail:s}:{userName:e}}function xv(t){return t.split(`
3
- `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
4
- `).trimEnd()}function bv(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function Ju(t,e){const s=Gn(e);if(!s)return t;const i=xv(t),r=bv(s);if(i.includes(r))return i;const o=i.trimEnd();return o.length>0?`${o}
5
-
6
- ${r}`:r}function Zu(t,e){const s=t?.trim();return s?Ju(s,e):s||void 0}const yv=["dev","start"];function Sv(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(i=>i.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function Pl(t){const e=Sv(t);if(e)throw new Error(e)}function Qu(t,e){for(const s of e){const i=t[s];if(typeof i=="string"&&i.length>0)return i}}function ef(t,e){for(const s of e){const i=t[s];if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"&&/^\d+$/.test(i)){const r=Number(i);if(r>0)return r}}}function wv(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function Cv(t,e){return wv(t)===e}function tf(t){const e=ui(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const i of["pull_requests","items","data"]){const r=s[i];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function kv(t){const e=Qu(t,["html_url","htmlUrl","url","URL"]),s=ef(t,["number","pullNumber"])??Rl(e);return!s||!e?null:{number:s,htmlUrl:e}}function jv(t){Pl(t);const e=_v(t);if(e)return e;const s=ui(t);if(s&&typeof s=="object"){const i=Qu(s,["url","URL","html_url","htmlUrl"]),r=ef(s,["number","pullNumber"])??Rl(i);if(r&&i)return{number:r,htmlUrl:i}}throw new Error("Failed to open pull request")}function Nv(t){return/already exists|pull request already/i.test(t)}async function Ev(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return Pl(s),tf(s)}async function Wc(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const i of s){const o=(await Ev(t,{owner:e.owner,repo:e.repo,head:i})).find(l=>Cv(l,e.branch)),a=o?kv(o):null;if(a)return a}return null}async function Tv(t,e){const s=Zu(e.body,Gn(e.coAuthor));if(s)try{await t.callTool({name:"update_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,body:s}})}catch{}}async function Av(t,e){const s=Zu(e.body,Gn(e.coAuthor)),i=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:s||void 0,head:e.head,base:e.base}});return jv(i)}async function Vc(t,e){const s=await Wc(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return await Tv(t,{owner:e.owner,repo:e.repo,pullNumber:s.number,body:e.body,coAuthor:e.coAuthor}),s;try{return await Av(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base,coAuthor:e.coAuthor})}catch(i){const r=i instanceof Error?i.message:String(i);if(!Nv(r))throw i;const o=await Wc(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw i}}async function sf(t,e){const s=Gn(e.coAuthor),i=s?Ju(e.commitMessage?.trim()??"",s):e.commitMessage?.trim()||void 0,r=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{},...i?{commit_message:i}:{}}});Pl(r);const o=ui(r);if(!o||o.merged!==!0)throw new Error(o?.message??"Failed to merge pull request");return{merged:!0,message:o.message??"Pull request merged"}}const Dl=6e4,Il=3e4;function Ll(t){const e=U.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Pt(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==i||e[12]!==o||e[13]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:Dl,refetchIntervalInBackground:!1,staleTime:Il,select:Rv},e[11]=i,e[12]=o,e[13]=a,e[14]=l):l=e[14],oo(l)}function Rv(t){const e=tf(t);if(e.length===0)return null;const s=e[0],i=s.base,r=s.head,o=s.user;return{number:s.number??0,title:s.title??"",body:s.body??"",state:s.state==="closed"?"closed":"open",merged:s.merged_at!=null,mergedAt:s.merged_at??null,base:i?.ref??"main",head:r?.ref??"",headSha:r?.sha??"",htmlUrl:s.html_url??"",author:o?.login??""}}function nf(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Pt(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Dl,refetchIntervalInBackground:!1,staleTime:Il,select:Pv},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],oo(l)}function Pv(t){const e=ui(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Dv)}function Dv(t){const e=t.started_at,s=t.completed_at,i=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:i}}function Iv(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Pt(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Dl,refetchIntervalInBackground:!1,staleTime:Il,select:Lv},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],oo(l)}function Lv(t){const e=ui(t);return Array.isArray(e)?e.map(Ov):[]}function Ov(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function rf(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function Bv(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&rf(s))return s}return null}function Mv(t){const e=t.previewUrl??t.getFallbackPreviewUrl?.()??Bv();if(e&&rf(e))return new URL("/.decofile",e).toString();const s=new URLSearchParams({path:"/.decofile"});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${s.toString()}`}function Ol(t,e){const s=U.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=Et.decofile(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=await fetch(Mv(t),{cache:"no-store"});if(!c.ok){const h=new Error(`Failed to fetch decofile: ${c.status}`);throw h.status=c.status,h}return await c.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let d;return s[4]!==o||s[5]!==a||s[6]!==l?(d={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:zv,retryDelay:$v},s[4]=o,s[5]=a,s[6]=l,s[7]=d):d=s[7],Es(d)}function $v(t){return Math.min(1e3*2**t,5e3)}function zv(t,e){return e.status!==502&&t<2}function Bl(t,e){const s=U.c(9),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}/${t.previewUrl??""}`:"",r=e?.fetchEnabled??!0,o=t?.previewUrl;let a;s[0]!==i?(a=Et.liveMeta(i),s[0]=i,s[1]=a):a=s[1];let l;s[2]!==o?(l=async()=>{const u=new URL("/live/_meta",o).href,f=await fetch(u,{cache:"no-store"});if(!f.ok){const m=new Error(`Failed to fetch live meta: ${f.status}`);throw m.status=f.status,m}return await f.json()},s[2]=o,s[3]=l):l=s[3];const d=!!t&&!!o&&r,c=e?.refetchInterval;let h;return s[4]!==a||s[5]!==l||s[6]!==d||s[7]!==c?(h={queryKey:a,queryFn:l,enabled:d,refetchInterval:c,refetchIntervalInBackground:!1,staleTime:3e5,retry:Hv,retryDelay:Fv},s[4]=a,s[5]=l,s[6]=d,s[7]=c,s[8]=h):h=s[8],Es(h)}function Fv(t){return Math.min(1e3*2**t,5e3)}function Hv(t,e){return e.status!==502&&t<3}function Uv(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function Mr(t){return t.includes("@")}function ga(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function Kc(t,e){if(t===e)return!0;const s=ga(t);return s?e===s||ga(e)===s:!1}function Ml(t,e){const s=t.manifest?.blocks??{};for(const[i,r]of Object.entries(s))if(e in r)return i;return null}function of(t,e){const s=Ml(t,e);return s!==null&&s.includes("sections")}function Wv(t,e){const s=Ml(t,e);return s!==null&&s.includes("apps")}function Vv(t,e){const s=Ml(t,e);return s!==null&&s.includes("matchers")}function Ns(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function af(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const lf="oklch(0.7278 0.151 289)",cf="website/matchers/always.ts",$l="website/matchers/never.ts",qi="website/flags/multivariate.ts",Yn="website/flags/multivariate/section.ts";function Li(){return{__resolveType:cf}}function ut(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())||t}const Kv=12,_i=8;function qv(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function Gv(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const r=s.properties?.__resolveType?.enum;return Array.isArray(r)&&typeof r[0]=="string"}const Yv="VideoWidget";function df(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function zl(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function Fl(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function hf(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function uf(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const i=zl(t)??Fl(t);if(i){for(const l of hf(i.vendor,i.app))for(const d of Object.values(s))if(d[l])return d[l]}const r=df(t);for(const l of Object.values(s))if(l[r])return l[r];const o=e.schema??{};return(o.$defs??o.definitions??{})[r]?{$ref:`#/definitions/${r}`}:{}}function ff(t,e){if(Wv(t,e))return!0;const s=zl(e)??Fl(e);if(!s)return!1;const i=t.manifest?.blocks?.apps??{};if(hf(s.vendor,s.app).some(a=>a in i))return!0;const r=df(e),o=t.schema?.$defs??t.schema?.definitions??{};return r in o}function mf(t){return t==="site/apps/site.ts"?!1:zl(t)!==null||Fl(t)!==null}function Us(t,e){const s=e.schema??{},i=uf(t,e),r=s.$defs??s.definitions??{},o=_=>{const b=_.split("/").pop()??"";return r[b]??{}};let a;typeof i.$ref=="string"?a=o(i.$ref):Object.keys(i).length>0?a=i:a=s;const l=_=>typeof _.$ref=="string"?o(_.$ref):_,d=_=>{const x=l(_).properties?.type;if(x){if(typeof x.const=="string")return x.const;if(typeof x.default=="string")return x.default;if(Array.isArray(x.enum)&&typeof x.enum[0]=="string")return x.enum[0]}},c=(_,b)=>{const x=l(_);return typeof x.title=="string"&&!x.title.startsWith("#")?x.title:b},h=(_,b=new Set)=>{if(typeof _.$ref!="string"||_.properties||_.anyOf||_.allOf||_.oneOf||_.type)return _;const x=_.$ref.split("/").pop()??"";return!x||b.has(x)?_:h(o(_.$ref),new Set([...b,x]))},u=_=>{const b=_.hide;return b===!0||b==="true"},f=(_,b=new Set,x=0)=>{if(x>Kv)return{};if(typeof _.$ref=="string"){const y=_.$ref.split("/").pop()??"";return b.has(y)?{}:f(o(_.$ref),new Set([...b,y]),x+1)}let v={};if(_.properties&&typeof _.properties=="object"&&(v={...v,..._.properties}),Array.isArray(_.required)){const y=Array.isArray(v.__required)?v.__required:[];v.__required=[...y,..._.required]}for(const y of["allOf","anyOf","oneOf"]){const S=_[y];if(Array.isArray(S))for(const w of S)v={...v,...f(w,b,x+1)}}return v},m=(_,b=0)=>{let x=_;typeof _.$ref=="string"&&(x=o(_.$ref),(_.$ref.split("/").pop()??"")===Yv&&!x.format&&(x={...x,format:"video-uri"})),x=h(x);let v;{const R=x.anyOf??x.oneOf;if(Array.isArray(R)){const T=R.filter(j=>!(j.type==="null"||j.type===null)),k=j=>{if(typeof j.const=="string"||typeof j.const=="number")return j.const;if(Array.isArray(j.enum)&&j.enum.length===1&&(typeof j.enum[0]=="string"||typeof j.enum[0]=="number"))return j.enum[0]};T.length>0&&T.every(j=>k(j)!==void 0)&&(v=T.map(j=>k(j)))}}let y,S;if(x.type)y=Array.isArray(x.type)?String(x.type.find(R=>R!=="null")??x.type[0]):String(x.type);else if(x.anyOf||x.allOf||x.oneOf){const T=(x.anyOf??x.allOf??x.oneOf).filter(k=>!(k.type==="null"||k.type===null));if(T.length===0)y="null";else if(T.length===1){const k=T[0];S=k,y=k.type?Array.isArray(k.type)?String(k.type[0]):String(k.type):typeof k.$ref=="string"?"object":"string"}else{if(v)return{type:"string",title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,enum:v};const k=T.filter(P=>{const B=P.properties?.__resolveType?.enum;return Array.isArray(B)&&typeof B[0]=="string"}),j=T.find(qv),I=k.some(P=>{const B=P.properties?.__resolveType?.enum;return Array.isArray(B)&&B[0]===qi});if(j){if(!Gv(j,o)&&T.length>1){const B=m(j,b+1);return{...B,type:"array",title:typeof x.title=="string"?x.title:B.title,description:typeof x.description=="string"?x.description:B.description}}if(I){const B=m(j,b+1);return{...B,type:"array",title:typeof x.title=="string"?x.title:B.title,description:typeof x.description=="string"?x.description:B.description}}}if(k.length>0){const P=k.map(H=>{const W=H.properties?.__resolveType?.enum??[],q=String(W[0]);return{resolveType:q,title:typeof H.title=="string"?H.title:ut(q),description:typeof H.description=="string"?H.description:void 0,schema:b+1<_i?m(H,b+1):void 0}}),B=T.filter(H=>!k.includes(H)),F=B.length===1&&b+1<_i?m(B[0],b+1):void 0;return{type:"block-ref",title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,anyOfRefs:P,plainSchema:F,hidden:u(x)||u(_)?!0:void 0}}const A=T.map(P=>d(P));if(T.length>1&&A.every(P=>typeof P=="string")){const P=T.map((B,F)=>{const H=l(B),z=A[F];return{resolveType:z,title:c(B,z),description:typeof H.description=="string"?H.description:void 0,discriminatorValue:z,schema:b+1<_i?m(H,b+1):void 0}});return{type:"block-ref",title:typeof _.title=="string"?_.title:typeof x.title=="string"?x.title:void 0,description:typeof _.description=="string"?_.description:typeof x.description=="string"?x.description:void 0,discriminatorKey:"type",anyOfRefs:P,hidden:u(x)||u(_)?!0:void 0}}if(T.every(P=>typeof P.$ref=="string")){const P=[];for(const B of T){const F=o(B.$ref);let H,z;if(typeof F.title=="string"){const q=Uv(F.title);q&&(H=q.blockId,z=q.blockId)}if(!H&&Array.isArray(F.allOf))for(const q of F.allOf){const Y=((q.properties??{}).__resolveType??{}).enum;if(Array.isArray(Y)&&typeof Y[0]=="string"){H=Y[0];break}}if(!H){const K=F.properties?.__resolveType?.enum;Array.isArray(K)&&typeof K[0]=="string"&&(H=K[0])}H||(H=B.$ref.split("/").pop()??"");const W=d(B);P.push({resolveType:W??H,title:z??(typeof F.title=="string"&&!F.title.startsWith("#")?F.title:ut(H)),description:typeof F.description=="string"?F.description:void 0,discriminatorValue:W,schema:b+1<_i?m(F,b+1):void 0})}return{type:"block-ref",title:typeof x.title=="string"?x.title:void 0,description:typeof x.description=="string"?x.description:void 0,anyOfRefs:P,hidden:u(x)||u(_)?!0:void 0}}y="object"}}else typeof _.$ref=="string"&&(y="object");let w;if(b<_i){const R=f(x),T=Object.entries(R).filter(([k])=>!k.startsWith("__")&&k!=="@type");if(T.length>0){w={};for(const[k,j]of T)w[k]=m(j,b+1)}}let C;if((y==="array"||x.type==="array")&&b<_i){let R=x.items;R&&(typeof R.$ref=="string"&&(R=o(R.$ref)),C=m(R,b+1),typeof R.title=="string"&&R.title.includes("{{")&&(C.titleBy=R.title))}const N=R=>{const T=S?.[R];return typeof T=="string"?T:void 0},E=()=>{if("default"in _)return _.default;if("default"in x)return x.default;if(S&&"default"in S)return S.default};return{type:y??"string",title:typeof _.title=="string"?_.title:typeof x.title=="string"?x.title:N("title"),description:typeof _.description=="string"?_.description:typeof x.description=="string"?x.description:N("description"),default:E(),enum:Array.isArray(x.enum)?x.enum:v??void 0,format:typeof x.format=="string"?x.format:N("format"),properties:w,items:C,hidden:u(x)||u(_)?!0:void 0,titleBy:typeof x.titleBy=="string"?x.titleBy:N("titleBy"),image:typeof x.image=="string"?x.image:N("image"),options:typeof x.options=="string"?x.options:N("options")}},p=f(a),g={};for(const[_,b]of Object.entries(p))_.startsWith("__")||_==="@type"||(g[_]=m(b,0));return Object.keys(g).length===0?null:{type:"object",title:typeof a.title=="string"?a.title:void 0,properties:g}}function fi(t,e){const s=e.schema??{},i=uf(t,e),r=s.$defs??s.definitions??{},o=typeof i.$ref=="string"?r[i.$ref.split("/").pop()??""]??{}:Object.keys(i).length>0?i:{...s,...i},a=o.icon,l=o.logo;return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0}}function Ti(t){return t.replace(/\/+$/,"")||"/"}function Xv(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function Hl(t){const e=t.trim();return e?Xv(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const Jv=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],qc="website/sections/Rendering/Lazy.tsx";function Tt(t){return Jv.some(e=>t.endsWith(e))}const pf=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],gf=new Set(pf),Zv=new Set(["site/sections/Theme/Theme.tsx"]);function ho(t){return!!(Zv.has(t)||Tt(t)||t.toLowerCase().includes("preview"))}function _f(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const i of Object.keys(s))if(gf.has(i))return i;return pf[0]}function _a(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return _a(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(..._a(s));return e}return[]}function Qv(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("sections"))for(const o of Object.keys(r)){if(ho(o))continue;const a=fi(o,t);s.push({resolveType:o,title:a.title??ut(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function ex(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("sections"))for(const o of Object.keys(r))ho(o)||s.push({resolveType:o,title:ut(o)});return s.sort((i,r)=>i.title.localeCompare(r.title))}function vf(t,e){const s=[];for(const[i,r]of Object.entries(e)){if(i.includes("/")||af(i)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(gf.has(a)||typeof o.path!="string"&&(ho(a)||of(t,a)&&s.push({resolveType:i,title:i,description:typeof o.name=="string"?o.name:void 0,previewBlock:i,isSavedBlock:!0})))}return s}function tx(t,e){const s=Ns(e.resolveType),i=s?{}:fi(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||i.title||ut(e.resolveType),description:e.description??i.description,previewBlock:e.resolveType,isSavedBlock:s}}function Y6(t,e){const s=_f(t),i=Us(s,t),r=_a(i?.properties?.sections),o=new Map,a=l=>{if(!ho(l.resolveType)){if(Ns(l.resolveType)){af(l.resolveType)||o.set(l.resolveType,l);return}of(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of Qv(t))a(l);for(const l of r)a(tx(t,l));for(const l of vf(t,e))a(l);return[...o.values()].sort((l,d)=>l.title.localeCompare(d.title))}function X6(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}function sx(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function ix(t,e,s){const i=Ti;if(s){const o=t.find(a=>a.key===s);if(o)return o}const r=t.filter(o=>i(o.path)===i(e));return r.length===0?null:r.length===1?r[0]??null:[...r].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const xf=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),_n="site",Ul="site/apps/site.ts";function $r(t,e){return t===_n?!0:e.__resolveType===Ul}function Wl(t,e){return t?Vl(t).length>0?!0:e?ql(t,e).length>0||va(t,e)?!0:nx(t,e).length>0:!1:!1}function Vl(t){const e=[];for(const[s,i]of Object.entries(t))if(i&&typeof i=="object"&&!Array.isArray(i)){const r=i;typeof r.__resolveType=="string"&&xf.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:sx(s),path:r.path})}return e}function Kl(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function zr(t,e,s){const i=typeof e.__resolveType=="string"?e.__resolveType:"",r=i?fi(i,s):{};if(r.title)return r.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function va(t,e){const s=t[_n];if(s&&typeof s=="object"&&!Array.isArray(s)){const i=s,r=i.__resolveType;if(typeof r=="string"&&($r(_n,i)||ff(e,r)))return{key:_n,name:zr(_n,i,e),resolveType:r}}for(const[i,r]of Object.entries(t)){if(i.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;if(!$r(i,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:Ul;return{key:i,name:zr(i,o,e),resolveType:a}}return null}function nx(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;typeof a=="string"&&(xf.has(a)||typeof o.path!="string"&&($r(i,o)||!ff(e,a)&&!mf(a)||s.push({key:i,name:zr(i,o,e),resolveType:a})))}return s.sort((i,r)=>i.name.localeCompare(r.name))}function ql(t,e){return vf(e,t).map(s=>{const i=t[s.resolveType],r=typeof i.__resolveType=="string"?i.__resolveType:"";return{key:s.resolveType,name:s.description??Kl(s.resolveType,i),resolveType:r}}).sort((s,i)=>s.name.localeCompare(i.name))}const rx={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},bf=D.createContext(rx),Gc=16384;class ox{data="";append(e){this.data+=e,this.data.length>Gc&&(this.data=this.data.slice(this.data.length-Gc))}get(){return this.data}clear(){this.data=""}}const ax=1e3,lx=3e4,cx=3e3,Yc=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],Xc="log";function dx(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function hx(t){return t===404}async function ux(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(cx)});return await e.body?.cancel().catch(()=>{}),hx(e.status)}catch{return!1}}function fx({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:i=!0,children:r}){const{org:o}=Me(),a=oi(),[l,d]=D.useState(null),[c,h]=D.useState({phase:"idle"}),[u,f]=D.useState({state:"running"}),[m,p]=D.useState({kind:"unknown"}),[g,_]=D.useState(!1),[b,x]=D.useState([]),[v,y]=D.useState([]),[,S]=D.useState(0),w=D.useRef(new Map),C=D.useRef(new Set),N=D.useRef(new Set),E=D.useRef(null),R=dx(s),T=j=>{let I=w.current.get(j);return I||(I=new ox,w.current.set(j,I)),I};D.useEffect(()=>{if(d(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),E.current=null,_(!1),x([]),y([]),w.current.clear(),!t||!e||!i)return;const j=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let I=!1,A=0,O=null,L=null,P=null,B=null;const F=G=>{try{const Q=JSON.parse(G.data);d(Q),Q.kind!=="failed"&&(_(!1),A=0),Q.kind==="ready"&&K()}catch(Q){console.warn("[vm-events] bad phase payload",Q)}},H=()=>{_(!0),d(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),x([]),y([]),w.current.clear()},z=G=>{try{const Q=JSON.parse(G.data);if(typeof Q.data!="string")return;A=0;const $=Q.data.replace(/\r?\n/g,`\r
7
- `);T(Q.source).append($);for(const X of C.current)try{X(Q.source,$)}catch{}S(X=>X+1)}catch{}},W=G=>{const Q=G.type;try{const $=JSON.parse(G.data);switch(A=0,Q){case"lifecycle":{const X=$;h(X.state);const V=X.state.phase==="running"?X.state.port:null,se=E.current;if(E.current=V,se!==null&&V!==null&&se!==V)for(const ee of N.current)try{ee()}catch{}return}case"status":f($);return;case"tasks":{const V=$.active.map(se=>se.logName??"").filter(Boolean);y(V);return}case"scripts":x($.scripts);return;case"branch":{const X=$.meta;p(X);return}case"reload":for(const X of N.current)try{X()}catch{}return;case"file-changed":{const{path:X}=$,V=`${o.slug}/${t}/${e}`;X.startsWith(".deco/")?a.invalidateQueries({queryKey:Et.decofile(V)}):(L&&clearTimeout(L),L=setTimeout(()=>{L=null,a.invalidateQueries({predicate:se=>{const ee=se.queryKey;return ee[0]==="live-meta"&&typeof ee[1]=="string"&&ee[1].startsWith(`${V}/`)}})},1e3));return}}}catch{}};function q(){if(I)return;const G=new EventSource(j);P=G,G.onopen=()=>{},G.onerror=()=>{P===G&&G.readyState===EventSource.CLOSED&&Y("studio")},G.addEventListener("phase",F),G.addEventListener("gone",H),G.addEventListener(Xc,z);for(const Q of Yc)G.addEventListener(Q,W)}function K(){if(I||!R||B)return;const G=new EventSource(R);B=G;let Q=!1;G.onopen=()=>{if(I||B!==G)return;Q=!0,A=0;const $=P;P=null,$?.close()},G.onerror=()=>{B===G&&G.readyState===EventSource.CLOSED&&Z(G,Q)},G.addEventListener(Xc,z);for(const $ of Yc)G.addEventListener($,W)}async function Z(G,Q){const $=R?await ux(R):!1;if(!(I||B!==G)){if(G.close(),B=null,$){H(),P||q();return}Q&&Y("direct")}}function Y(G){if(I||O)return;const Q=Math.min(ax*2**A,lx);A++,O=setTimeout(()=>{if(O=null,!I){if(G==="direct"){B?.close(),B=null,K();return}P?.close(),P=null,q()}},Q)}return q(),()=>{I=!0,P?.close(),B?.close(),O&&clearTimeout(O),L&&clearTimeout(L)}},[t,e,o.slug,i,R,a]);const k={phase:l,lifecycle:c,status:u,branch:m,notFound:g,scripts:b,activeProcesses:v,getBuffer:j=>w.current.get(j)?.get()??"",hasData:j=>(w.current.get(j)?.get().length??0)>0,subscribeChunks:j=>(C.current.add(j),()=>{C.current.delete(j)}),subscribeReload:j=>(N.current.add(j),()=>{N.current.delete(j)})};return n.jsx(bf,{value:k,children:r})}function bs(){return D.use(bf)}function yf(t){const{subscribeChunks:e}=bs(),s=D.useRef(t);s.current=t,D.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function mx(t){const{subscribeReload:e}=bs(),s=D.useRef(t);s.current=t,D.useEffect(()=>e(()=>{s.current?.()}),[e])}function Sf(t){const e=Object.values(t),[s]=e;return s?e.find(i=>i.sandboxProviderKind!=="user-desktop")??s:null}function wf(t){return t.appPaused||t.userStopped?{kind:"suspended"}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}function px(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted}function gx(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&t.deadVmId!==t.lastDeadVmId}function _x(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting"}}const vx={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{}},Cf=D.createContext(vx);function Gl(){return D.use(Cf)}function xx({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:i,sandboxMap:r,sandboxProviderKind:o,children:a}){const{org:l}=Me(),{setCurrentTaskBranch:d}=Ts(),c=bs(),h=oi(),u=Pt({connectionId:ul,orgId:l.id,orgSlug:l.slug}),f=ll(u),{mutate:m,reset:p}=f,g=D.useRef(new Set),_=D.useRef(null),b=s&&e?to(r?.[s]?.[e]):{},x=o?b[o]??null:Sf(b),v=x?.previewUrl??null,y=!!t&&!!e&&oa.isStopped(t,e),S=c.status.state==="paused",w=wf({previewUrl:v,appPaused:S,userStopped:y}),C=_x(w),N=e??"",E=g.current.has(N),R=px({hasActiveGithubRepo:i,userId:s,vmEntry:x,userStopped:y,isPending:f.isPending,attempted:E});D.useEffect(()=>{if(!R||!t)return;g.current.add(N);const B={virtualMcpId:t};e&&(B.branch=e),o&&(B.sandboxProviderKind=o),m(B,{onSuccess:F=>{F?.branch&&!e&&d(F.branch)},onError:F=>{console.error("[sandbox-lifecycle] auto-start failed:",F)}})},[R,N,e,t,o,m,d]);const T=c.notFound?x?.sandboxHandle??null:null,k=gx({notFound:c.notFound,deadVmId:T,lastDeadVmId:_.current,isPending:f.isPending,userStopped:y});D.useEffect(()=>{if(!k||!T||!t)return;_.current=T;const B={virtualMcpId:t};e&&(B.branch=e),o&&(B.sandboxProviderKind=o),m(B,{onSuccess:F=>{F?.branch&&!e&&d(F.branch)},onError:F=>{console.error("[sandbox-lifecycle] self-heal failed:",F)}})},[k,T,t,e,o,m,d]);const j=()=>{if(!t)return;const B={virtualMcpId:t};e&&(B.branch=e),m(B,{onSuccess:F=>{F?.branch&&!e&&d(F.branch)},onError:F=>{console.error("[sandbox-lifecycle] user start failed:",F)}})},I=async()=>{if(!t||!e)return;const B=x?.sandboxProviderKind;if(B){oa.mark(t,e);try{await u.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:B}})}catch{}Yp(h)}},A=async()=>{await I(),j()},O=()=>{g.current=new Set,_.current=null,p(),j()},P={branch:e,previewState:w,status:C,vmEntry:x,previewUrl:v,userStopped:y,start:j,stop:I,restart:A,retry:O,resume:O};return n.jsx(Cf,{value:P,children:a})}const bx={settings:x_,automations:ku,preview:Ui,content:gl,git:Dn};function Jc(t){const e=io(t);if(e.type==="icon"){const s=ci(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function No(t){if(t.kind==="system")return{kind:"component",Component:bx[t.tabId]};const e=Jc(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Jc(s.icon);return i||{kind:"fallback"}}function yx(t){const{org:e}=Me(),s=di(),i=Su(),r=D.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=Xp({queryKey:Et.ensureTask(e.id,t),queryFn:async()=>{if(!t)return null;try{const{item:l}=await s.call("COLLECTION_THREADS_GET",{id:t});return l??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function Yl(t){const e=U.c(35),s=qt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=eo(i),o=vs(t.virtualMcpId),a=yx(t.taskId),{org:l}=Me(),{currentBranch:d}=Ts();let c;e[1]!==o?(c=Wn(o),e[1]=o,e[2]=c):c=e[2];const h=c,u=h?.connectionId??"",f=h?.owner??"",m=h?.name??"",p=h?d:null;let g;e[3]!==l.id||e[4]!==l.slug||e[5]!==u||e[6]!==f||e[7]!==m||e[8]!==p?(g={orgId:l.id,orgSlug:l.slug,connectionId:u,owner:f,repo:m,branch:p},e[3]=l.id,e[4]=l.slug,e[5]=u,e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const _=Ll(g),b=_.data?.state==="open",x=o?.metadata?.ui??null,v=x?.layout??null,y=v?.tabs??[],S=o?.id?Lg(o.id):null,w=a?.expanded_tools??[],C=tu(o),N=o?.metadata;let E;e[10]!==N?(E=ti(N),e[10]=N,e[11]=E):E=e[11];const R=E,{granted:T}=X_("agents:manage");let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k={includeVirtual:!0},e[12]=k):k=e[12];const j=Vn(k),I=bs(),{vmEntry:A,previewUrl:O}=Gl(),L=I.lifecycle.phase==="running";let P;e[13]!==O||e[14]!==A?.sandboxProviderKind?(P=A?.sandboxProviderKind==="user-desktop"&&O?`${O.replace(/\/+$/,"")}/api/mcp`:void 0,e[13]=O,e[14]=A?.sandboxProviderKind,e[15]=P):P=e[15];const B=P,F=Og({connectionId:S??void 0,orgId:l.id,orgSlug:l.slug,mcpUrl:B}),H=F,z=!!F&&L;let W;e[16]!==H||e[17]!==z?(W={client:H,enabled:z},e[16]=H,e[17]=z,e[18]=W):W=e[18];const{data:q}=Du(W),K=S&&L?(q?.tools??[]).filter(Cx).map(pe=>({connectionId:S,toolName:pe.name,label:aa(pe.name),icon:null})):[],Z=K[0],Y=Z?K:x?.pinnedViews??[],G=Z&&S?{type:"ext-apps",id:S,toolName:Z.toolName}:v?.defaultMainView??null;let Q;e[19]!==d||e[20]!==o||e[21]!==R||e[22]!==l.slug||e[23]!==O?(Q=R&&o?.id&&d?{orgSlug:l.slug,virtualMcpId:o.id,branch:d,previewUrl:O}:null,e[19]=d,e[20]=o,e[21]=R,e[22]=l.slug,e[23]=O,e[24]=Q):Q=e[24];const $=Q;let X;e[25]!==L?(X={fetchEnabled:L},e[25]=L,e[26]=X):X=e[26];const{data:V}=Ol($,X);let se;e[27]!==L?(se={fetchEnabled:L},e[27]=L,e[28]=se):se=e[28];const{data:ee}=Bl($,se),le=Wl(V,ee),{activeTab:ce,mainOpen:fe}=Yg({mainParam:r.main,metadata:G||v?{defaultMainView:G,tabs:y.map(wx)}:null}),J=C&&(b||_.isPending&&ce==="git"),te=G||v?{defaultMainView:G,tabs:y.map(Sx)}:null,oe=ce==="git"&&!J&&!_.isPending?ca(te):ce==="content"&&!le?ca(te):ce,de=ce==="git"&&!J&&!_.isPending?!1:fe,be=pu(oe),ve=[];R&&(ve.push({id:"preview",title:"Preview"}),le&&ve.push({id:"content",title:"Content"})),J&&ve.push({id:"git",title:"Review changes"}),T&&ve.push({id:"settings",title:"Settings"}),ve.push({id:"automations",title:"Automations"});const we=new Map;for(const pe of w){const $e=Ac(pe.appId,pe.toolName);we.set($e,{id:$e,title:pe.toolName,appId:pe.appId,iconKey:pe.toolName})}for(const pe of Y){const $e=Ac(pe.connectionId,pe.toolName);we.set($e,{id:$e,title:pe.label||pe.toolName,appId:pe.connectionId,iconKey:pe.toolName,iconUrl:pe.icon??null})}const De=gu(oe),Be=De?De.key.split("/").pop()??De.key:null,Pe=Be?[{id:oe,title:Be,kind:"file",icon:{kind:"component",Component:pe=>D.createElement(Pi,{filename:Be,...pe})}}]:[],Fe=_u(oe),xe=Fe?[{id:oe,title:(Fe.path.split("/").pop()??Fe.path).replace(/\.html$/i,""),kind:"file",icon:{kind:"component",Component:pe=>D.createElement(Fe.path.startsWith("pages/")?Ui:Ru,pe)}}]:[],ye=vu(oe),Ie=ye?ye.path.split("/").pop()??ye.path:null,Le=Ie?[{id:oe,title:Ie,kind:"file",icon:{kind:"component",Component:pe=>D.createElement(Pi,{filename:Ie,...pe})}}]:[];let qe;e[29]!==j?(qe=pe=>({id:pe.id,title:pe.title,kind:"agent",icon:No({tabId:pe.id,kind:"agent",appId:pe.view.appId,connections:j})}),e[29]=j,e[30]=qe):qe=e[30];const st=[...Pe,...xe,...Le,...y.map(qe),...Array.from(we.values()).map(pe=>({id:pe.id,title:pe.title,kind:"expanded",icon:No({tabId:pe.iconKey,kind:"expanded",appId:pe.appId,iconUrl:pe.iconUrl,connections:j})})),...ve.map(pe=>({id:pe.id,title:pe.title,kind:"system",icon:No({tabId:pe.id,kind:"system",connections:j})}))];let ct;return e[31]!==oe||e[32]!==de||e[33]!==s?(ct=pe=>{const $e=Xg({clickedId:pe,activeTab:oe,mainOpen:de});s({to:".",search:Ge=>({...Ge,main:$e}),replace:!0})},e[31]=oe,e[32]=de,e[33]=s,e[34]=ct):ct=e[34],{activeTab:oe,mainOpen:de,setActiveTab:ct,systemTabs:ve,layoutTabs:y,expandedTools:w,automationTabParsed:be,tabs:st}}function Sx(t){return{id:t.id}}function wx(t){return{id:t.id}}function Cx(t){return!!Lu(t._meta)}function kf(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:o}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
8
- <current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function kx(t){const e=U.c(9),s=di();let i;e[0]!==t?(i=Et.user(t),e[0]=t,e[1]=i):i=e[1];let r;e[2]!==s||e[3]!==t?(r=async()=>{const{user:l}=await s.call("USER_GET",{id:t});return l},e[2]=s,e[3]=t,e[4]=r):r=e[4];const o=!!t;let a;return e[5]!==i||e[6]!==r||e[7]!==o?(a={queryKey:i,queryFn:r,staleTime:3e5,retry:1,enabled:o},e[5]=i,e[6]=r,e[7]=o,e[8]=a):a=e[8],Es(a)}function jf(t){const e=U.c(36),{id:s,size:i,showEmail:r,avatarOnly:o,className:a}=t,l=i===void 0?"xs":i,d=r===void 0?!1:r,c=o===void 0?!1:o,{data:h,isLoading:u,isError:f}=kx(s);if(u){let x;e[0]!==a?(x=ae("flex items-center gap-2",a),e[0]=a,e[1]=x):x=e[1];let v;e[2]!==l?(v=n.jsx(jo.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=v):v=e[3];let y;e[4]!==c||e[5]!==d?(y=!c&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),d&&n.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=c,e[5]=d,e[6]=y):y=e[6];let S;return e[7]!==x||e[8]!==v||e[9]!==y?(S=n.jsxs("div",{className:x,children:[v,y]}),e[7]=x,e[8]=v,e[9]=y,e[10]=S):S=e[10],S}if(f||!h){let x;e[11]!==a?(x=ae("flex items-center gap-2",a),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==l?(v=n.jsx(jo,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=v):v=e[14];let y;e[15]!==c?(y=!c&&n.jsx("div",{className:"flex flex-col",children:n.jsx("div",{className:"text-sm text-muted-foreground",children:"Unknown User"})}),e[15]=c,e[16]=y):y=e[16];let S;return e[17]!==x||e[18]!==v||e[19]!==y?(S=n.jsxs("div",{className:x,children:[v,y]}),e[17]=x,e[18]=v,e[19]=y,e[20]=S):S=e[20],S}let m;e[21]!==a?(m=ae("flex items-center gap-2",a),e[21]=a,e[22]=m):m=e[22];const p=h.image??void 0;let g;e[23]!==l||e[24]!==p||e[25]!==h.name?(g=n.jsx(jo,{shape:"circle",size:l,url:p,fallback:h.name}),e[23]=l,e[24]=p,e[25]=h.name,e[26]=g):g=e[26];let _;e[27]!==c||e[28]!==d||e[29]!==h.email||e[30]!==h.name?(_=!c&&n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:"text-sm font-medium",children:h.name}),d&&n.jsx("div",{className:"text-xs text-muted-foreground",children:h.email})]}),e[27]=c,e[28]=d,e[29]=h.email,e[30]=h.name,e[31]=_):_=e[31];let b;return e[32]!==m||e[33]!==g||e[34]!==_?(b=n.jsxs("div",{className:m,children:[g,_]}),e[32]=m,e[33]=g,e[34]=_,e[35]=b):b=e[35],b}function jx(t){const e=U.c(86),{value:s,onChange:i,onColorChange:r,name:o,size:a,className:l,avatarClassName:d,showHoverOverlay:c,disabled:h}=t,u=a===void 0?"lg":a,f=c===void 0?!0:c,m=h===void 0?!1:h,[p,g]=D.useState(!1),[_,b]=D.useState("icons"),[x,v]=D.useState(""),[y,S]=D.useState("blue");let w;e[0]!==s?(w=io(s),e[0]=s,e[1]=w):w=e[1];const C=w,N=C.type==="icon"||C.type==="url"&&C.color?C.color:y;let E;e[2]!==i||e[3]!==N?(E=we=>{i(wo(we,N))},e[2]=i,e[3]=N,e[4]=E):E=e[4];const R=E;let T;e[5]!==i||e[6]!==r||e[7]!==C.name||e[8]!==C.type||e[9]!==C.url?(T=we=>{S(we),r?.(we),C.type==="icon"?i(wo(C.name,we)):C.type==="url"&&i(Dc(C.url,we))},e[5]=i,e[6]=r,e[7]=C.name,e[8]=C.type,e[9]=C.url,e[10]=T):T=e[10];const k=T;let j;e[11]!==i||e[12]!==N?(j=we=>{i(Dc(we,N)),g(!1)},e[11]=i,e[12]=N,e[13]=j):j=e[13];const I=j;let A;e[14]!==i||e[15]!==N?(A=()=>{const we=_l(),De=we[Math.floor(Math.random()*we.length)];i(wo(De,N))},e[14]=i,e[15]=N,e[16]=A):A=e[16];const O=A;let L,P,B,F,H,z,W,q,K;if(e[17]!==l||e[18]!==m||e[19]!==p||e[20]!==u){const we={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};P=As,W=m?!1:p,q=g,L=Rs,z=!0,K="button",B="icon-picker-trigger",F=m,H=ae("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",we[u],l),e[17]=l,e[18]=m,e[19]=p,e[20]=u,e[21]=L,e[22]=P,e[23]=B,e[24]=F,e[25]=H,e[26]=z,e[27]=W,e[28]=q,e[29]=K}else L=e[21],P=e[22],B=e[23],F=e[24],H=e[25],z=e[26],W=e[27],q=e[28],K=e[29];let Z;e[30]!==d||e[31]!==o||e[32]!==u||e[33]!==s?(Z=n.jsx(Ic,{icon:s,name:o,size:u,className:d}),e[30]=d,e[31]=o,e[32]=u,e[33]=s,e[34]=Z):Z=e[34];let Y;e[35]!==m||e[36]!==f?(Y=f&&!m&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(gl,{size:16,className:"text-white"})}),e[35]=m,e[36]=f,e[37]=Y):Y=e[37];let G;e[38]!==B||e[39]!==F||e[40]!==H||e[41]!==Z||e[42]!==Y||e[43]!==K?(G=n.jsxs("button",{type:K,"data-testid":B,disabled:F,className:H,children:[Z,Y]}),e[38]=B,e[39]=F,e[40]=H,e[41]=Z,e[42]=Y,e[43]=K,e[44]=G):G=e[44];let Q;e[45]!==L||e[46]!==z||e[47]!==G?(Q=n.jsx(L,{asChild:z,children:G}),e[45]=L,e[46]=z,e[47]=G,e[48]=Q):Q=e[48];let $;e[49]!==o||e[50]!==s?($=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(Ic,{icon:s,name:o,size:"xl"})}),e[49]=o,e[50]=s,e[51]=$):$=e[51];let X;e[52]===Symbol.for("react.memo_cache_sentinel")?(X=()=>b("icons"),e[52]=X):X=e[52];const V=_==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let se;e[53]!==V?(se=ae("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",V),e[53]=V,e[54]=se):se=e[54];let ee;e[55]!==se?(ee=n.jsx("button",{type:"button",onClick:X,className:se,children:"Icons"}),e[55]=se,e[56]=ee):ee=e[56];let le;e[57]===Symbol.for("react.memo_cache_sentinel")?(le=()=>b("upload"),e[57]=le):le=e[57];const ce=_==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let fe;e[58]!==ce?(fe=ae("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ce),e[58]=ce,e[59]=fe):fe=e[59];let J;e[60]!==fe?(J=n.jsx("button",{type:"button",onClick:le,className:fe,children:"Upload"}),e[60]=fe,e[61]=J):J=e[61];let te;e[62]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx("div",{className:"flex-1"}),e[62]=te):te=e[62];let oe;e[63]!==ee||e[64]!==J?(oe=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[ee,J,te]}),e[63]=ee,e[64]=J,e[65]=oe):oe=e[65];let de;e[66]!==k||e[67]!==O||e[68]!==R||e[69]!==I||e[70]!==C.name||e[71]!==C.type||e[72]!==x||e[73]!==N||e[74]!==_?(de=_==="icons"?n.jsx(Ax,{search:x,onSearchChange:v,selectedColor:N,onColorChange:k,onSelectIcon:R,onRandom:O,currentIconName:C.type==="icon"?C.name:null}):n.jsx(Rx,{onUpload:I}),e[66]=k,e[67]=O,e[68]=R,e[69]=I,e[70]=C.name,e[71]=C.type,e[72]=x,e[73]=N,e[74]=_,e[75]=de):de=e[75];let be;e[76]!==$||e[77]!==oe||e[78]!==de?(be=n.jsx(Ps,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Nx,children:n.jsxs("div",{className:"flex flex-col",children:[$,oe,de]})}),e[76]=$,e[77]=oe,e[78]=de,e[79]=be):be=e[79];let ve;return e[80]!==P||e[81]!==W||e[82]!==q||e[83]!==Q||e[84]!==be?(ve=n.jsxs(P,{open:W,onOpenChange:q,children:[Q,be]}),e[80]=P,e[81]=W,e[82]=q,e[83]=Q,e[84]=be,e[85]=ve):ve=e[85],ve}function Nx(t){return t.preventDefault()}function Ex(t){const e=U.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=D.useState(!1);let a,l,d,c,h,u,f;if(e[0]!==r||e[1]!==s){const x=ju(s);l=As,u=r,f=o,a=Rs,h=!0,d="button",c=ae("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=d,e[5]=c,e[6]=h,e[7]=u,e[8]=f}else a=e[2],l=e[3],d=e[4],c=e[5],h=e[6],u=e[7],f=e[8];let m;e[9]!==d||e[10]!==c?(m=n.jsx("button",{type:d,className:c,title:"Change color"}),e[9]=d,e[10]=c,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==h||e[14]!==m?(p=n.jsx(a,{asChild:h,children:m}),e[12]=a,e[13]=h,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==i||e[17]!==s?(g=y_.map(x=>n.jsx("button",{type:"button",onClick:()=>{i(x.name),o(!1)},className:ae("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=g):g=e[18];let _;e[19]!==g?(_=n.jsx(Ps,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Tx,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:g})}),e[19]=g,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==p||e[25]!==_?(b=n.jsxs(l,{open:u,onOpenChange:f,children:[p,_]}),e[21]=l,e[22]=u,e[23]=f,e[24]=p,e[25]=_,e[26]=b):b=e[26],b}function Tx(t){return t.preventDefault()}function Ax(t){const e=U.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:d}=t;let c,h,u,f,m,p,g;if(e[0]!==d||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const y=_l(),S=ju(r);h=s.trim()?y.filter(k=>{const j=da(k),I=s.toLowerCase();return j.includes(I)||k.toLowerCase().includes(I)}):y,p="flex flex-col";let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Bn,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=w):w=e[14];let C;e[15]!==i?(C=k=>i(k.target.value),e[15]=i,e[16]=C):C=e[16];let N;e[17]!==s||e[18]!==C?(N=n.jsxs("div",{className:"relative flex-1",children:[w,n.jsx(ze,{value:s,onChange:C,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=C,e[19]=N):N=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(b_,{size:14,className:"text-muted-foreground"}),e[20]=E):E=e[20];let R;e[21]!==l?(R=n.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:E}),e[21]=l,e[22]=R):R=e[22];let T;e[23]!==o||e[24]!==r?(T=n.jsx(Ex,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=T):T=e[25],e[26]!==R||e[27]!==T||e[28]!==N?(g=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[N,R,T]}),e[26]=R,e[27]=T,e[28]=N,e[29]=g):g=e[29],c=Fi,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=h.map(k=>{const j=ci(k);return j?n.jsx("button",{type:"button",onClick:()=>a(k),className:ae("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",d===k?ae(S.bg,S.text):ae(S.text,"hover:bg-accent")),title:k,children:n.jsx(j,{size:18})},k):null}),e[0]=d,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=h,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else c=e[7],h=e[8],u=e[9],f=e[10],m=e[11],p=e[12],g=e[13];let _;e[30]!==u||e[31]!==f?(_=n.jsx("div",{className:u,children:f}),e[30]=u,e[31]=f,e[32]=_):_=e[32];let b;e[33]!==h.length?(b=h.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=h.length,e[34]=b):b=e[34];let x;e[35]!==c||e[36]!==m||e[37]!==_||e[38]!==b?(x=n.jsxs(c,{className:m,children:[_,b]}),e[35]=c,e[36]=m,e[37]=_,e[38]=b,e[39]=x):x=e[39];let v;return e[40]!==p||e[41]!==g||e[42]!==x?(v=n.jsxs("div",{className:p,children:[g,x]}),e[40]=p,e[41]=g,e[42]=x,e[43]=v):v=e[43],v}function Rx(t){const e=U.c(27),{onUpload:s}=t,i=D.useRef(null);let r;e[0]!==s?(r=w=>{const C=w.target.files?.[0];if(!C)return;if(C.size>2097152){he.error("Image must be smaller than 2MB"),w.target.value="";return}const N=new FileReader;N.onerror=()=>{he.error("Failed to read image file"),i.current&&(i.current.value="")},N.onloadend=()=>{N.readyState===FileReader.DONE&&N.result&&s(N.result),i.current&&(i.current.value="")},N.readAsDataURL(C)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=D.useState("");let d;e[2]!==s||e[3]!==a?(d=()=>{const w=a.trim();w&&(s(w),l(""))},e[2]=s,e[3]=a,e[4]=d):d=e[4];const c=d;let h;e[5]!==o?(h=n.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsxs("button",{type:"button",onClick:u,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[n.jsx(Kn,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=w=>l(w.target.value),e[10]=p):p=e[10];let g;e[11]!==c?(g=w=>{w.key==="Enter"&&(w.preventDefault(),c())},e[11]=c,e[12]=g):g=e[12];let _;e[13]!==a||e[14]!==g?(_=n.jsx(ze,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:g}),e[13]=a,e[14]=g,e[15]=_):_=e[15];let b;e[16]!==a?(b=a.trim(),e[16]=a,e[17]=b):b=e[17];const x=!b;let v;e[18]!==c||e[19]!==x?(v=n.jsx(ie,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:x,children:"Apply"}),e[18]=c,e[19]=x,e[20]=v):v=e[20];let y;e[21]!==v||e[22]!==_?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,v]}),e[21]=v,e[22]=_,e[23]=y):y=e[23];let S;return e[24]!==y||e[25]!==h?(S=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[h,f,m,y]}),e[24]=y,e[25]=h,e[26]=S):S=e[26],S}function Px(t){const e=U.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=io(s);if(o.type==="icon"){const a=ci(o.name);if(a){let l;e[2]!==a?(l=n.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(c1,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function Dx(t){const e=U.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=D.useState(!1),[d,c]=D.useState("");let h;e[0]!==s?(h=io(s),e[0]=s,e[1]=h):h=e[1];const u=h,f=u.type==="icon"?u.name:null;let m,p,g,_,b,x,v,y,S,w,C,N,E,R,T;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==d||e[8]!==s){const P=_l();_=d.trim()?P.filter(K=>{const Z=d.toLowerCase();return da(K).includes(Z)||K.toLowerCase().includes(Z)}):P,g=As,b=o?!1:a,x=l;const B=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let F;e[24]!==r||e[25]!==B?(F=ae("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",B,r),e[24]=r,e[25]=B,e[26]=F):F=e[26];let H;e[27]!==s?(H=n.jsx(Px,{value:s}),e[27]=s,e[28]=H):H=e[28],e[29]!==o||e[30]!==F||e[31]!==H?(v=n.jsx(Rs,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:F,children:H})}),e[29]=o,e[30]=F,e[31]=H,e[32]=v):v=e[32],p=Ps,E="start",R="w-64 p-0",T=Ix,C="flex flex-col";let z;e[33]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Bn,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=z):z=e[33];let W;e[34]===Symbol.for("react.memo_cache_sentinel")?(W=K=>c(K.target.value),e[34]=W):W=e[34],e[35]!==d?(N=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[z,n.jsx(ze,{value:d,onChange:W,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=d,e[36]=N):N=e[36],m=Fi,w="h-48",y="grid grid-cols-8 gap-0.5 px-2 pb-2";let q;e[37]!==f||e[38]!==i?(q=K=>{const Z=ci(K);return Z?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:ae("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:da(K),children:n.jsx(Z,{size:16})},K):null},e[37]=f,e[38]=i,e[39]=q):q=e[39],S=_.map(q),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=d,e[8]=s,e[9]=m,e[10]=p,e[11]=g,e[12]=_,e[13]=b,e[14]=x,e[15]=v,e[16]=y,e[17]=S,e[18]=w,e[19]=C,e[20]=N,e[21]=E,e[22]=R,e[23]=T}else m=e[9],p=e[10],g=e[11],_=e[12],b=e[13],x=e[14],v=e[15],y=e[16],S=e[17],w=e[18],C=e[19],N=e[20],E=e[21],R=e[22],T=e[23];let k;e[40]!==y||e[41]!==S?(k=n.jsx("div",{className:y,children:S}),e[40]=y,e[41]=S,e[42]=k):k=e[42];let j;e[43]!==_.length?(j=_.length===0&&n.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=_.length,e[44]=j):j=e[44];let I;e[45]!==m||e[46]!==k||e[47]!==j||e[48]!==w?(I=n.jsxs(m,{className:w,children:[k,j]}),e[45]=m,e[46]=k,e[47]=j,e[48]=w,e[49]=I):I=e[49];let A;e[50]!==I||e[51]!==C||e[52]!==N?(A=n.jsxs("div",{className:C,children:[N,I]}),e[50]=I,e[51]=C,e[52]=N,e[53]=A):A=e[53];let O;e[54]!==p||e[55]!==A||e[56]!==E||e[57]!==R||e[58]!==T?(O=n.jsx(p,{align:E,className:R,onOpenAutoFocus:T,children:A}),e[54]=p,e[55]=A,e[56]=E,e[57]=R,e[58]=T,e[59]=O):O=e[59];let L;return e[60]!==g||e[61]!==b||e[62]!==x||e[63]!==v||e[64]!==O?(L=n.jsxs(g,{open:b,onOpenChange:x,children:[v,O]}),e[60]=g,e[61]=b,e[62]=x,e[63]=v,e[64]=O,e[65]=L):L=e[65],L}function Ix(t){return t.preventDefault()}const Lx=25*1024*1024,Eo="home",To="knowledge";function Zc(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ks(t){return t.split("/").pop()??t}function Ox(t){const e=U.c(52),{form:s}=t,{upload:i}=e_(Eo),r=t_(),o=D.useRef(null),[a,l]=D.useState(!1),[d,c]=D.useState(""),[h,u]=D.useState(!1);let f;e[0]!==a?(f={enabled:a},e[0]=a,e[1]=f):f=e[1];const{data:m}=s_(60,f),p=m===void 0?[]:m;let g;e[2]!==a?(g={enabled:a},e[2]=a,e[3]=g):g=e[3];const{data:_}=i_(g),b=_===void 0?[]:_;let x;e[4]!==s?(x=()=>s.getValues("metadata.knowledge")??[],e[4]=s,e[5]=x):x=e[5];const[v,y]=D.useState(x);let S;e[6]!==s?(S=J=>{y(J),s.setValue("metadata.knowledge",J,{shouldDirty:!0})},e[6]=s,e[7]=S):S=e[7];const w=S;let C;e[8]!==r||e[9]!==v||e[10]!==w||e[11]!==i?(C=async J=>{if(!J||J.length===0)return;const te=Array.from(J).filter(Fx);if(te.length!==0){try{await i.mutateAsync({dir:To,files:te})}catch(oe){const de=oe;he.error(de instanceof Error?de.message:"Failed to upload file.");return}w([...v,...te.map(oe=>({id:crypto.randomUUID(),name:oe.name,volume:Eo,path:`${To}/${oe.name}`,url:r(Eo,`${To}/${oe.name}`),contentType:oe.type||null,size:oe.size,addedAt:new Date().toISOString()}))])}},e[8]=r,e[9]=v,e[10]=w,e[11]=i,e[12]=C):C=e[12];const N=C;let E;e[13]!==r||e[14]!==v||e[15]!==w?(E=J=>{v.some(te=>te.volume===J.volume&&te.path===J.path)||(w([...v,{id:crypto.randomUUID(),name:Ks(J.path),volume:J.volume,path:J.path,url:r(J.volume,J.path),contentType:null,size:J.size??null,addedAt:new Date().toISOString()}]),l(!1))},e[13]=r,e[14]=v,e[15]=w,e[16]=E):E=e[16];const R=E;let T;e[17]!==r||e[18]!==v||e[19]!==w?(T=J=>{v.some(te=>te.volume===J.volume&&te.path===J.path)||(w([...v,{id:crypto.randomUUID(),name:Ks(J.path),kind:"skill",volume:J.volume,path:J.path,url:r(J.volume,J.path),contentType:null,size:null,addedAt:new Date().toISOString()}]),l(!1))},e[17]=r,e[18]=v,e[19]=w,e[20]=T):T=e[20];const k=T;let j;e[21]!==v||e[22]!==w?(j=J=>{w(v.filter(te=>te.id!==J))},e[21]=v,e[22]=w,e[23]=j):j=e[23];const I=j;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=J=>{l(J),J&&c("")},e[24]=A):A=e[24];const O=A;let L;e[25]!==v?(L=new Set(v.map(zx)),e[25]=v,e[26]=L):L=e[26];const P=L,B=d.toLowerCase();let F;e[27]!==P?(F=J=>!P.has(`${J.volume}/${J.path}`),e[27]=P,e[28]=F):F=e[28];const H=p.filter($x).filter(F).filter(J=>Ks(J.path).toLowerCase().includes(B)).slice(0,5);let z;e[29]!==P?(z=J=>!P.has(`${J.volume}/${J.path}`),e[29]=P,e[30]=z):z=e[30];const W=b.filter(z).filter(J=>Ks(J.path).toLowerCase().includes(B)).slice(0,5),q=J=>n.jsxs(Wt,{open:a,onOpenChange:O,children:[n.jsx(Vt,{asChild:!0,children:J}),n.jsxs(Kt,{align:"end",className:"w-56",children:[n.jsxs(Ue,{onSelect:()=>{o.current?.click()},children:[n.jsx(S_,{size:16}),"Upload file"]}),n.jsxs(ha,{children:[n.jsxs(ua,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[n.jsx(ma,{size:16}),"Select file or folder"]}),n.jsxs(fa,{className:"w-72 p-0",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[n.jsx(Bn,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("input",{value:d,onChange:te=>c(te.target.value),onKeyDown:Mx,placeholder:"Search files...",className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),n.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:H.length===0?n.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:"No files found."}):H.map(te=>n.jsxs(Ue,{onSelect:()=>R(te),children:[n.jsx(Pi,{filename:Ks(te.path),className:"h-5 w-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:Ks(te.path)}),te.size!=null&&n.jsx("span",{className:"text-xs text-muted-foreground",children:Zc(te.size)})]},`${te.volume}/${te.path}`))})]})]}),n.jsxs(ha,{children:[n.jsxs(ua,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[n.jsx(Zs,{size:16}),"Select skill"]}),n.jsxs(fa,{className:"w-72 p-0",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[n.jsx(Bn,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("input",{value:d,onChange:te=>c(te.target.value),onKeyDown:Bx,placeholder:"Search skills...",className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),n.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:W.length===0?n.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:"No skills found."}):W.map(te=>n.jsxs(Ue,{onSelect:()=>k(te),children:[n.jsx(Zs,{size:16,className:"shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:Ks(te.path)})]},`${te.volume}/${te.path}`))})]})]})]})]}),K="flex flex-col gap-3";let Z;e[31]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Files and skills"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Attach files and skills the agent can always reference."})]}),e[31]=Z):Z=e[31];const Y=v.length>0&&q(n.jsxs(ie,{variant:"outline",size:"sm",disabled:i.isPending,children:[i.isPending?n.jsx(dl,{size:"xs"}):n.jsx(Dt,{size:14}),"Add"]}));let G;e[32]!==Y?(G=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[Z,Y]}),e[32]=Y,e[33]=G):G=e[33];let Q;e[34]!==N?(Q=n.jsx("input",{ref:o,type:"file",multiple:!0,className:"hidden",onChange:J=>{N(J.target.files),J.target.value=""}}),e[34]=N,e[35]=Q):Q=e[35];let $,X;e[36]===Symbol.for("react.memo_cache_sentinel")?($=J=>{J.preventDefault(),u(!0)},X=()=>u(!1),e[36]=$,e[37]=X):($=e[36],X=e[37]);let V;e[38]!==N?(V=J=>{J.preventDefault(),u(!1),N(J.dataTransfer.files)},e[38]=N,e[39]=V):V=e[39];const se=h&&"outline outline-2 outline-dashed outline-primary";let ee;e[40]!==se?(ee=ae("flex flex-col gap-2 rounded-lg",se),e[40]=se,e[41]=ee):ee=e[41];const le=v.length===0?q(n.jsxs("button",{type:"button",className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(Dt,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:"No files or skills yet. Add one or drag and drop here."})]})):v.map(J=>n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-card",children:[J.kind==="skill"?n.jsx("div",{className:"flex items-center justify-center h-8 w-6.5 shrink-0 rounded-md bg-muted text-muted-foreground",children:n.jsx(Zs,{size:16})}):n.jsx(Pi,{filename:J.name,className:"h-8 w-6.5 shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:J.name}),n.jsx("p",{className:"text-xs text-muted-foreground",children:J.kind==="skill"?"Skill":J.size!=null?Zc(J.size):"File"})]}),n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>I(J.id),"aria-label":`Remove ${J.name}`,children:n.jsx(es,{size:16})})]},J.id));let ce;e[42]!==$||e[43]!==X||e[44]!==V||e[45]!==ee||e[46]!==le?(ce=n.jsx("div",{onDragOver:$,onDragLeave:X,onDrop:V,className:ee,children:le}),e[42]=$,e[43]=X,e[44]=V,e[45]=ee,e[46]=le,e[47]=ce):ce=e[47];let fe;return e[48]!==G||e[49]!==Q||e[50]!==ce?(fe=n.jsxs("section",{className:K,children:[G,Q,ce]}),e[48]=G,e[49]=Q,e[50]=ce,e[51]=fe):fe=e[51],fe}function Bx(t){return t.stopPropagation()}function Mx(t){return t.stopPropagation()}function $x(t){return t.kind!=="dir"}function zx(t){return`${t.volume}/${t.path}`}function Fx(t){return t.size<=Lx}function Hx(t){return t==null?"all":t.length===0?"self":"selected"}function Ux(t){const e=U.c(65),{form:s,currentAgentId:i}=t,{org:r}=Me(),o=hl(),[a,l]=D.useState(!1);let d;e[0]!==s?(d=s.getValues("metadata.subAgents")??null,e[0]=s,e[1]=d):d=e[1];const c=d;let h;e[2]!==c?(h=()=>Hx(c),e[2]=c,e[3]=h):h=e[3];const[u,f]=D.useState(h);let m;e[4]!==c?(m=c??[],e[4]=c,e[5]=m):m=e[5];const[p,g]=D.useState(m);let _,b,x,v,y,S;if(e[6]!==o||e[7]!==i||e[8]!==s||e[9]!==u||e[10]!==r||e[11]!==p){let E;e[18]!==i||e[19]!==r?(E=Y=>Y.id!==i&&Y.id!==r.id&&Y.status==="active",e[18]=i,e[19]=r,e[20]=E):E=e[20],_=o.filter(E);let R;e[21]!==p?(R=Y=>p.includes(Y.id),e[21]=p,e[22]=R):R=e[22];const T=_.filter(R);let k;e[23]!==s?(k=(Y,G)=>s.setValue("metadata.subAgents",Y==="all"?null:Y==="self"?[]:G,{shouldDirty:!0}),e[23]=s,e[24]=k):k=e[24];const j=k;let I;e[25]!==j||e[26]!==p?(I=Y=>{f(Y),j(Y,p)},e[25]=j,e[26]=p,e[27]=I):I=e[27];const A=I;let O;e[28]!==j||e[29]!==p?(O=Y=>{const G=p.includes(Y)?p.filter(Q=>Q!==Y):[...p,Y];g(G),j("selected",G)},e[28]=j,e[29]=p,e[30]=O):O=e[30],b=O,y="flex flex-col gap-3";let L;e[31]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sub-agents"}),e[31]=L):L=e[31];let P;e[32]!==u?(P=u==="all"&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"Can delegate to any agent in the organization."}),e[32]=u,e[33]=P):P=e[33];let B;e[34]!==u?(B=u==="self"&&n.jsx("p",{className:"text-sm text-muted-foreground",children:"Can only delegate to a fresh copy of itself, no other agents."}),e[34]=u,e[35]=B):B=e[35];let F;e[36]!==P||e[37]!==B?(F=n.jsxs("div",{className:"flex flex-col gap-1",children:[L,P,B]}),e[36]=P,e[37]=B,e[38]=F):F=e[38];const H=u==="selected"&&T.length>0&&n.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>l(!0),children:[n.jsx(Dt,{size:14}),"Add sub-agent"]});let z;e[39]!==A?(z=Y=>A(Y),e[39]=A,e[40]=z):z=e[40];let W;e[41]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(kt,{size:"sm",className:"w-auto",children:n.jsx(Rt,{})}),e[41]=W):W=e[41];let q;e[42]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsxs(jt,{align:"end",children:[n.jsx(tt,{value:"all",children:"Any agent"}),n.jsx(tt,{value:"selected",children:"Specific agents"}),n.jsx(tt,{value:"self",children:"Only itself"})]}),e[42]=q):q=e[42];let K;e[43]!==u||e[44]!==z?(K=n.jsxs(Nt,{value:u,onValueChange:z,children:[W,q]}),e[43]=u,e[44]=z,e[45]=K):K=e[45];let Z;e[46]!==H||e[47]!==K?(Z=n.jsxs("div",{className:"flex items-center gap-2",children:[H,K]}),e[46]=H,e[47]=K,e[48]=Z):Z=e[48],e[49]!==F||e[50]!==Z?(S=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[F,Z]}),e[49]=F,e[50]=Z,e[51]=S):S=e[51],x="flex flex-col gap-2",v=u==="selected"&&(T.length>0?T.map(Y=>n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-background",children:[n.jsx(xs,{icon:Y.icon,name:Y.title,size:"sm",className:"shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:Y.title}),Y.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Y.description})]}),n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>b(Y.id),children:n.jsx(Hs,{size:16})})]},Y.id)):n.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(Dt,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"No sub-agents selected yet. Add one — until then this agent can only delegate to itself."})]})),e[6]=o,e[7]=i,e[8]=s,e[9]=u,e[10]=r,e[11]=p,e[12]=_,e[13]=b,e[14]=x,e[15]=v,e[16]=y,e[17]=S}else _=e[12],b=e[13],x=e[14],v=e[15],y=e[16],S=e[17];let w;e[52]!==x||e[53]!==v?(w=n.jsx("div",{className:x,children:v}),e[52]=x,e[53]=v,e[54]=w):w=e[54];let C;e[55]!==_||e[56]!==b||e[57]!==a||e[58]!==p?(C=n.jsx(Wx,{open:a,onOpenChange:l,candidates:_,selectedIds:p,onToggle:b}),e[55]=_,e[56]=b,e[57]=a,e[58]=p,e[59]=C):C=e[59];let N;return e[60]!==y||e[61]!==S||e[62]!==w||e[63]!==C?(N=n.jsxs("section",{className:y,children:[S,w,C]}),e[60]=y,e[61]=S,e[62]=w,e[63]=C,e[64]=N):N=e[64],N}function Wx(t){const e=U.c(32),{open:s,onOpenChange:i,candidates:r,selectedIds:o,onToggle:a}=t,[l,d]=D.useState("");let c,h,u,f,m,p,g,_,b;if(e[0]!==r||e[1]!==i||e[2]!==a||e[3]!==s||e[4]!==l||e[5]!==o){const S=l.toLowerCase(),w=r.filter(C=>C.title.toLowerCase().includes(S)||C.description?.toLowerCase().includes(S));h=Bt,_=s,b=i,c=Mt,m="max-w-md",e[15]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ts,{children:n.jsx(ss,{children:"Sub-agents"})}),e[15]=p):p=e[15],e[16]!==l?(g=n.jsx(Fu,{value:l,onChange:d,placeholder:"Search agents...",className:"w-full"}),e[16]=l,e[17]=g):g=e[17],u="flex flex-col gap-1 max-h-80 overflow-y-auto",f=w.length===0?n.jsx("p",{className:"text-sm text-muted-foreground px-1 py-4 text-center",children:"No agents found."}):w.map(C=>n.jsxs("button",{type:"button",onClick:()=>a(C.id),className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-accent/50 transition-colors cursor-pointer w-full text-left",children:[n.jsx(Ki,{checked:o.includes(C.id),className:"pointer-events-none",tabIndex:-1}),n.jsx(xs,{icon:C.icon,name:C.title,size:"sm",className:"shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:C.title}),C.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:C.description})]})]},C.id)),e[0]=r,e[1]=i,e[2]=a,e[3]=s,e[4]=l,e[5]=o,e[6]=c,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=b}else c=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],b=e[14];let x;e[18]!==u||e[19]!==f?(x=n.jsx("div",{className:u,children:f}),e[18]=u,e[19]=f,e[20]=x):x=e[20];let v;e[21]!==c||e[22]!==m||e[23]!==p||e[24]!==g||e[25]!==x?(v=n.jsxs(c,{className:m,children:[p,g,x]}),e[21]=c,e[22]=m,e[23]=p,e[24]=g,e[25]=x,e[26]=v):v=e[26];let y;return e[27]!==h||e[28]!==_||e[29]!==b||e[30]!==v?(y=n.jsx(h,{open:_,onOpenChange:b,children:v}),e[27]=h,e[28]=_,e[29]=b,e[30]=v,e[31]=y):y=e[31],y}function vn(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsx(Oe,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function er(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[n.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:n.jsx(Hh,{className:"h-6 w-6 text-destructive"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),n.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function Nf(t){const e=U.c(23),{item:s,isSelected:i,onToggle:r,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let d;e[0]!==a||e[1]!==l?(d=ae("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=d):d=e[2];let c;e[3]!==s.name?(c=n.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let h;e[5]!==s.tags?(h=s.tags&&n.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=h):h=e[6];let u;e[7]!==c||e[8]!==h?(u=n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,h]}),e[7]=c,e[8]=h,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==u||e[13]!==f?(m=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==i||e[17]!==r?(p=n.jsx(Ki,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=p):p=e[18];let g;return e[19]!==d||e[20]!==m||e[21]!==p?(g=n.jsxs("label",{className:d,children:[m,p]}),e[19]=d,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function Xl(t){const e=U.c(13),{items:s,selections:i,onToggle:r,emptyMessage:o,disabled:a}=t;let l,d,c;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const u=s.map(Vx);if(s.length===0){let f;e[8]!==o?(f=n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",d=s.map(f=>n.jsx(Nf,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=d,e[7]=c}else l=e[5],d=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let h;return e[10]!==l||e[11]!==d?(h=n.jsx("div",{className:l,children:d}),e[10]=l,e[11]=d,e[12]=h):h=e[12],h}function Vx(t){return t.id}function Kx(t){const e=U.c(18),{connectionId:s,toolSelections:i,onToggleTool:r}=t,{org:o}=Me();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=Pt(a);let d;e[4]!==l?(d={client:l},e[4]=l,e[5]=d):d=e[5];const{data:c}=Iu(d),h=c.tools;let u,f,m;if(e[6]!==c.tools||e[7]!==r||e[8]!==i){m=Symbol.for("react.early_return_sentinel");e:{const g=h.map(Gx);let _;e[12]!==i?(_=v=>i===null||i.includes(v.name),e[12]=i,e[13]=_):_=e[13];const x=c.tools.filter(_).map(qx);if(x.length===0){let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:"No active tools selected"})}),e[14]=v):v=e[14],m=v;break e}u="flex-1 overflow-auto px-4 py-3 space-y-1",f=x.map(v=>n.jsx(Nf,{item:v,isSelected:!0,onToggle:()=>r(v.id,g)},v.id))}e[6]=c.tools,e[7]=r,e[8]=i,e[9]=u,e[10]=f,e[11]=m}else u=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;let p;return e[15]!==u||e[16]!==f?(p=n.jsx("div",{className:u,children:f}),e[15]=u,e[16]=f,e[17]=p):p=e[17],p}function qx(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(Bu,{annotations:t.annotations,_meta:t._meta})}}function Gx(t){return t.name}function Yx(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=Me();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const d=Pt(l);let c;e[4]!==d?(c={client:d},e[4]=d,e[5]=c):c=e[5];const{data:h}=Iu(c);let u;e[6]!==h.tools?(u=h.tools.map(Xx),e[6]=h.tools,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(Xl,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function Xx(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(Bu,{annotations:t.annotations,_meta:t._meta})}}function Jx(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=Me();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const d=Pt(l);let c;e[4]!==d?(c={client:d},e[4]=d,e[5]=c):c=e[5];const{data:h}=Jp(c);let u;e[6]!==h.resources?(u=h.resources.map(Zx),e[6]=h.resources,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(Xl,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function Zx(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Qx(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=Me();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const d=Pt(l);let c;e[4]!==d?(c={client:d},e[4]=d,e[5]=c):c=e[5];const{data:h}=d1(c);let u;e[6]!==h.prompts?(u=h.prompts.map(eb),e[6]=h.prompts,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(Xl,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function eb(t){return{id:t.name,name:t.name,description:t.description}}function tb(t){const e=U.c(61),{currentConnection:s,activeTab:i,selectedId:r,formData:o,toggleTool:a,toggleResource:l,togglePrompt:d,toggleAllTools:c,toggleAllResources:h,toggleAllPrompts:u,onTabChange:f}=t,m=o[r],p=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:i==="prompts"?m?.prompts===null:!1,g=i!=="active";let _;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==h||e[4]!==c?(_=()=>{i==="tools"?c(r):i==="resources"?h(r):i==="prompts"&&u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=h,e[4]=c,e[5]=_):_=e[5];const b=_;let x;e[6]!==s.icon||e[7]!==s.title?(x=n.jsx(xs,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=x):x=e[8];let v;e[9]!==s.title?(v=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=v):v=e[10];let y;e[11]!==s.description?(y=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=y):y=e[12];let S;e[13]!==v||e[14]!==y?(S=n.jsxs("div",{className:"flex-1 min-w-0",children:[v,y]}),e[13]=v,e[14]=y,e[15]=S):S=e[15];let w;e[16]!==x||e[17]!==S?(w=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[x,S]})}),e[16]=x,e[17]=S,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[{id:"tools",label:"Tools"},{id:"active",label:"Active"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=C):C=e[19];let N;e[20]!==f?(N=P=>f(P),e[20]=f,e[21]=N):N=e[21];let E;e[22]!==i||e[23]!==N?(E=n.jsx(Hu,{tabs:C,activeTab:i,onTabChange:N}),e[22]=i,e[23]=N,e[24]=E):E=e[24];let R;e[25]!==b||e[26]!==p||e[27]!==g?(R=g&&n.jsx("button",{type:"button",onClick:b,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:p?"Deselect all":"Select all"}),e[25]=b,e[26]=p,e[27]=g,e[28]=R):R=e[28];let T;e[29]!==R||e[30]!==E?(T=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[E,R]}),e[29]=R,e[30]=E,e[31]=T):T=e[31];let k;e[32]!==i||e[33]!==o||e[34]!==r||e[35]!==a?(k=i==="active"&&n.jsx(Zt,{fallback:er("Tools not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx(vn,{}),children:n.jsx(Kx,{connectionId:r,toolSelections:o[r]?o[r].tools:[],onToggleTool:(P,B)=>a(r,P,B)})})}),e[32]=i,e[33]=o,e[34]=r,e[35]=a,e[36]=k):k=e[36];let j;e[37]!==i||e[38]!==o||e[39]!==r||e[40]!==a?(j=i==="tools"&&n.jsx(Zt,{fallback:er("Tools not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx(vn,{}),children:n.jsx(Yx,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(P,B)=>a(r,P,B)})})}),e[37]=i,e[38]=o,e[39]=r,e[40]=a,e[41]=j):j=e[41];let I;e[42]!==i||e[43]!==o||e[44]!==r||e[45]!==l?(I=i==="resources"&&n.jsx(Zt,{fallback:er("Resources not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx(vn,{}),children:n.jsx(Jx,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(P,B)=>l(r,P,B)})})}),e[42]=i,e[43]=o,e[44]=r,e[45]=l,e[46]=I):I=e[46];let A;e[47]!==i||e[48]!==o||e[49]!==r||e[50]!==d?(A=i==="prompts"&&n.jsx(Zt,{fallback:er("Prompts not supported by this server"),children:n.jsx(D.Suspense,{fallback:n.jsx(vn,{}),children:n.jsx(Qx,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(P,B)=>d(r,P,B)})})}),e[47]=i,e[48]=o,e[49]=r,e[50]=d,e[51]=A):A=e[51];let O;e[52]!==k||e[53]!==j||e[54]!==I||e[55]!==A?(O=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[k,j,I,A]}),e[52]=k,e[53]=j,e[54]=I,e[55]=A,e[56]=O):O=e[56];let L;return e[57]!==T||e[58]!==O||e[59]!==w?(L=n.jsxs(n.Fragment,{children:[w,T,O]}),e[57]=T,e[58]=O,e[59]=w,e[60]=L):L=e[60],L}function sb(t){const e=U.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=Mu(o);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:n.jsx(w_,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),n.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=h):h=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&n.jsx(ie,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let f;return e[7]!==u?(f=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,h,u]}),e[7]=u,e[8]=f):f=e[8],f}let d;return e[9]!==r?(d=n.jsx(n.Fragment,{children:r}),e[9]=r,e[10]=d):d=e[10],d}function ib(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Qc(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function nb(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function rb(t){const e=U.c(49),{open:s,onOpenChange:i,selectedId:r,form:o,connections:a,onAuthenticate:l}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activeTab:"tools"},e[0]=d):d=e[0];const[c,h]=D.useReducer(nb,d),u=vl(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=ib(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=(z,W,q,K)=>{const Z=p[z]?.[W];let Y;Z===null?Y=K.filter(Q=>Q!==q):Z?.includes(q)?Y=Z.filter(Q=>Q!==q):(Y=[...Z??[],q],Y.length===K.length&&(Y=null));const G={...p};G[z]?G[z]={...G[z]}:G[z]={tools:null,resources:null,prompts:null},G[z][W]=Y,o.setValue("connections",Qc(G),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const _=g;let b;e[8]!==o||e[9]!==p?(b=(z,W)=>{const K=p[z]?.[W]===null?[]:null,Z={...p};Z[z]?Z[z]={...Z[z]}:Z[z]={tools:null,resources:null,prompts:null},Z[z][W]=K,o.setValue("connections",Qc(Z),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=b):b=e[10];const x=b;let v;e[11]!==_?(v=(z,W,q)=>_(z,"tools",W,q),e[11]=_,e[12]=v):v=e[12];const y=v;let S;e[13]!==_?(S=(z,W,q)=>_(z,"resources",W,q),e[13]=_,e[14]=S):S=e[14];const w=S;let C;e[15]!==_?(C=(z,W,q)=>_(z,"prompts",W,q),e[15]=_,e[16]=C):C=e[16];const N=C;let E;e[17]!==x?(E=z=>x(z,"tools"),e[17]=x,e[18]=E):E=e[18];const R=E;let T;e[19]!==x?(T=z=>x(z,"resources"),e[19]=x,e[20]=T):T=e[20];const k=T;let j;e[21]!==x?(j=z=>x(z,"prompts"),e[21]=x,e[22]=j):j=e[22];const I=j;if(!r||!u)return null;let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(vn,{}),e[23]=A):A=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=z=>h({type:"SET_ACTIVE_TAB",payload:z}),e[24]=O):O=e[24];let L;e[25]!==u||e[26]!==c.activeTab||e[27]!==p||e[28]!==r||e[29]!==I||e[30]!==k||e[31]!==R||e[32]!==N||e[33]!==w||e[34]!==y?(L=n.jsx(tb,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:p,toggleTool:y,toggleResource:w,togglePrompt:N,toggleAllTools:R,toggleAllResources:k,toggleAllPrompts:I,onTabChange:O},r),e[25]=u,e[26]=c.activeTab,e[27]=p,e[28]=r,e[29]=I,e[30]=k,e[31]=R,e[32]=N,e[33]=w,e[34]=y,e[35]=L):L=e[35];let P;e[36]!==l||e[37]!==r||e[38]!==L?(P=n.jsx(D.Suspense,{fallback:A,children:n.jsx(sb,{connectionId:r,onAuthenticate:l,children:L})}),e[36]=l,e[37]=r,e[38]=L,e[39]=P):P=e[39];let B;e[40]!==i?(B=n.jsx(Ws,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(ie,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=B):B=e[41];let F;e[42]!==P||e[43]!==B?(F=n.jsxs(Mt,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[P,B]}),e[42]=P,e[43]=B,e[44]=F):F=e[44];let H;return e[45]!==i||e[46]!==s||e[47]!==F?(H=n.jsx(Bt,{open:s,onOpenChange:i,children:F}),e[45]=i,e[46]=s,e[47]=F,e[48]=H):H=e[48],H}const Ao={tools:null,resources:null,prompts:null},ob=Zp.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function ab(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function lb(t){const e=U.c(11),{url:s,agentId:i}=t,[r,o]=D.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Ke("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),he.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let d;e[3]!==r?(d=r?n.jsx(js,{size:20,className:"text-green-600"}):n.jsx(as,{size:20}),e[3]=r,e[4]=d):d=e[4];const c=r?"Copied!":"Copy URL";let h;e[5]!==c?(h=n.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=h):h=e[6];let u;return e[7]!==l||e[8]!==d||e[9]!==h?(u=n.jsxs(ie,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,h]}),e[7]=l,e[8]=d,e[9]=h,e[10]=u):u=e[10],u}function cb(t){const e=U.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{Ke("agent_connect_action",{agent_id:r,action:"install_cursor"});const h=$u(i),f=ab(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(h)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),he.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),d=n.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=d):(l=e[4],d=e[5]);let c;return e[6]!==a?(c=n.jsxs(ie,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,d]}),e[6]=a,e[7]=c):c=e[7],c}function db(t){const e=U.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=D.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Ke("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=$u(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),_=`claude mcp add-json "${m}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(_),a(!0),he.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const d=l;let c;e[4]!==o?(c=o?n.jsx(js,{size:20,className:"text-green-600"}):n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=o,e[5]=c):c=e[5];const h=o?"Copied!":"Install on Claude Code";let u;e[6]!==h?(u=n.jsx("span",{className:"text-xs font-medium",children:h}),e[6]=h,e[7]=u):u=e[7];let f;return e[8]!==d||e[9]!==c||e[10]!==u?(f=n.jsxs(ie,{type:"button",variant:"outline",onClick:d,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,u]}),e[8]=d,e[9]=c,e[10]=u,e[11]=f):f=e[11],f}function hb({virtualMcp:t}){const e=di(),[s,i]=D.useState(null),[r,o]=D.useState(!1),[a,l]=D.useState(!1),d=t.id,c=t.title||`agent-${d.slice(0,8)}`,h=s?`bunx @decocms/typegen@latest --mcp ${d} --key ${s} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,u=async()=>{o(!0);try{const{key:m}=await e.call("API_KEY_CREATE",{name:`typegen-${c}`,permissions:{[d]:["*"]}});if(!m)throw new Error("No key in response");i(m),Ke("agent_typegen_key_generated",{agent_id:d})}catch{Ke("agent_typegen_key_failed",{agent_id:d}),he.error("Failed to generate API key")}finally{o(!1)}},f=async()=>{Ke("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!s}),await navigator.clipboard.writeText(h),l(!0),he.success("Command copied to clipboard"),setTimeout(()=>l(!1),2e3)};return n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",n.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!s&&n.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:u,disabled:r,children:[r?n.jsx(Oe,{size:14,className:"animate-spin"}):n.jsx(Sl,{size:14}),n.jsx("span",{children:r?"Generating…":"Generate API key"})]})]}),s&&n.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:h}),n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:f,children:a?n.jsx(js,{size:12,className:"text-green-600"}):n.jsx(as,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(ub,{apiKey:s,agentId:d})]})}function ub(t){const e=U.c(21),{apiKey:s,agentId:i}=t,[r,o]=D.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",d=`MESH_BASE_URL=${a}`,c=`${l}
9
- ${d}`;let h;e[0]!==i||e[1]!==s||e[2]!==c?(h=async()=>{Ke("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=h):h=e[3];const u=h,f=!s;let m;e[4]!==f?(m=ae({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=n.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,_;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("br",{}),_=n.jsx("span",{children:d}),e[9]=g,e[10]=_):(g=e[9],_=e[10]);let b;e[11]!==p?(b=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,_]}),e[11]=p,e[12]=b):b=e[12];let x;e[13]!==r?(x=r?n.jsx(js,{size:12,className:"text-green-600"}):n.jsx(as,{size:12}),e[13]=r,e[14]=x):x=e[14];let v;e[15]!==u||e[16]!==x?(v=n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:x}),e[15]=u,e[16]=x,e[17]=v):v=e[17];let y;return e[18]!==b||e[19]!==v?(y=n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[b,v]})}),e[18]=b,e[19]=v,e[20]=y):y=e[20],y}function fb(t){const e=U.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(hb,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}const mb={self:["COLLECTION_THREADS_CREATE","COLLECTION_THREADS_GET","COLLECTION_THREAD_MESSAGES_LIST","COLLECTION_THREADS_LIST"]},pb=3600*24*90;function gb({virtualMcp:t}){const e=di(),{org:s}=Me(),[i,r]=D.useState(null),[o,a]=D.useState(!1),[l,d]=D.useState(!1),c=t.id,h=t.title||`agent-${c.slice(0,8)}`,f=[`MESH_BASE_URL=${window.location.origin}`,`MESH_ORG=${s.slug}`,`MESH_AGENT_ID=${c}`,`MESH_API_KEY=${i??"<api-key>"}`].join(`
10
- `),m=async()=>{a(!0);try{const{key:g}=await e.call("API_KEY_CREATE",{name:`chat-bridge-${h}`,permissions:mb,expiresIn:pb});if(!g)throw new Error("No key in response");r(g),Ke("agent_chat_bridge_key_generated",{agent_id:c})}catch{Ke("agent_chat_bridge_key_failed",{agent_id:c}),he.error("Failed to create API key")}finally{a(!1)}},p=async()=>{Ke("agent_connect_action",{agent_id:c,action:"chat_bridge_copy_env",has_api_key:!!i}),await navigator.clipboard.writeText(f),d(!0),he.success("Connection details copied to clipboard"),setTimeout(()=>d(!1),2e3)};return n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Call from your app"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Create a scoped API key to start a thread, run this agent, and stream results from an external system (e.g. a chatbot webhook)."})]}),!i&&n.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:o,children:[o?n.jsx(Oe,{size:14,className:"animate-spin"}):n.jsx(Sl,{size:14}),n.jsx("span",{children:o?"Creating…":"Create API key"})]})]}),i&&n.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Connection details"}),n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:f}),n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:p,children:l?n.jsx(js,{size:12,className:"text-green-600"}):n.jsx(as,{size:12})})]})})]})}function _b(t){const e=U.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(gb,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function vb(t){const e=U.c(41),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:o}=Me(),a=`/api/${o.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const d=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const h=c,u=ml();let f;e[5]!==r.id||e[6]!==d.href?(f=n.jsx(lb,{url:d.href,agentId:r.id}),e[5]=r.id,e[6]=d.href,e[7]=f):f=e[7];let m,p;e[8]!==h||e[9]!==r.id||e[10]!==d.href?(m=n.jsx(cb,{url:d.href,serverName:h,agentId:r.id}),p=n.jsx(db,{url:d.href,serverName:h,agentId:r.id}),e[8]=h,e[9]=r.id,e[10]=d.href,e[11]=m,e[12]=p):(m=e[11],p=e[12]);let g;e[13]!==f||e[14]!==m||e[15]!==p?(g=n.jsx("div",{className:"flex flex-col gap-3 pt-2",children:n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,m,p]})}),e[13]=f,e[14]=m,e[15]=p,e[16]=g):g=e[16];let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"border-t border-border"}),e[17]=_):_=e[17];let b;e[18]!==r?(b=n.jsx(fb,{virtualMcp:r}),e[18]=r,e[19]=b):b=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"border-t border-border"}),e[20]=x):x=e[20];let v;e[21]!==r?(v=n.jsx(_b,{virtualMcp:r}),e[21]=r,e[22]=v):v=e[22];let y;e[23]!==v||e[24]!==g||e[25]!==b?(y=n.jsxs("div",{className:"flex flex-col gap-6",children:[g,_,b,x,v]}),e[23]=v,e[24]=g,e[25]=b,e[26]=y):y=e[26];const S=y;if(u){let E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(h1,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[27]=E):E=e[27];let R;e[28]!==S?(R=n.jsx(u1,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[E,S]})}),e[28]=S,e[29]=R):R=e[29];let T;return e[30]!==i||e[31]!==s||e[32]!==R?(T=n.jsx(f1,{open:s,onOpenChange:i,children:R}),e[30]=i,e[31]=s,e[32]=R,e[33]=T):T=e[33],T}let w;e[34]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ts,{children:n.jsx(ss,{children:"Connect"})}),e[34]=w):w=e[34];let C;e[35]!==S?(C=n.jsxs(Mt,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[w,S]}),e[35]=S,e[36]=C):C=e[36];let N;return e[37]!==i||e[38]!==s||e[39]!==C?(N=n.jsx(Bt,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=N):N=e[40],N}function xb(t){const e=U.c(43),{virtualMcp:s}=t,i=hl(),r=Xh(),[o,a]=D.useState(!1);let l,d,c,h,u,f,m,p,g;if(e[0]!==r||e[1]!==i||e[2]!==s.id||e[3]!==s.metadata){g=Symbol.for("react.early_return_sentinel");e:{const S=Fg(i);if(Bg(s.id)||ti(s.metadata)||S.has(s.id)){g=null;break e}let w;e[13]!==i||e[14]!==s.id?(w=(i??[]).find(A=>A.metadata?.liveAgentId===s.id)??null,e[13]=i,e[14]=s.id,e[15]=w):w=e[15];const C=w,N=C?.id??null;let E;e[16]!==r.update?(E=(A,O)=>r.update.mutateAsync({id:A,data:{metadata:{liveAgentId:O}}}).catch(yb),e[16]=r.update,e[17]=E):E=e[17];const R=E;let T;e[18]!==R||e[19]!==s.id?(T=A=>{R(A,s.id)},e[18]=R,e[19]=s.id,e[20]=T):T=e[20],c=T;let k;e[21]!==N||e[22]!==R?(k=()=>{N&&R(N,null)},e[21]=N,e[22]=R,e[23]=k):k=e[23];const j=k,I=(i??[]).filter(A=>A.id!==s.id&&ti(A.metadata)&&!S.has(A.id));m="flex flex-col gap-3",e[24]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Development agent"}),e[24]=p):p=e[24],d=yl,f="p-6 gap-4",l=Ir,h="p-0 space-y-4",u=N?n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[n.jsx("span",{className:"text-sm text-foreground truncate",children:C?C.title:N}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Linked dev agent — its sandbox dev server powers the Develop/Live toggle in the header."})]}),n.jsx(ie,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:"Unlink"})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Link a GitHub-backed dev agent. Its sandbox dev server powers a Develop/Live toggle so you can develop and test this agent's MCP app."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(ie,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>a(!0),children:[n.jsx(Uu,{className:"size-4"}),"Import from GitHub"]}),I.length>0?n.jsxs(Nt,{onValueChange:c,children:[n.jsx(kt,{size:"sm",className:"w-56",children:n.jsx(Rt,{placeholder:"Or link an existing dev agent…"})}),n.jsx(jt,{children:I.map(bb)})]}):null]})]})}e[0]=r,e[1]=i,e[2]=s.id,e[3]=s.metadata,e[4]=l,e[5]=d,e[6]=c,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g}else l=e[4],d=e[5],c=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let _;e[25]!==l||e[26]!==h||e[27]!==u?(_=n.jsx(l,{className:h,children:u}),e[25]=l,e[26]=h,e[27]=u,e[28]=_):_=e[28];let b;e[29]!==d||e[30]!==f||e[31]!==_?(b=n.jsx(d,{className:f,children:_}),e[29]=d,e[30]=f,e[31]=_,e[32]=b):b=e[32];let x;e[33]!==c?(x=S=>{const{virtualMcpId:w}=S;a(!1),c(w)},e[33]=c,e[34]=x):x=e[34];let v;e[35]!==o||e[36]!==x?(v=n.jsx(m1,{open:o,onOpenChange:a,title:"Import a dev agent from GitHub",onImportComplete:x}),e[35]=o,e[36]=x,e[37]=v):v=e[37];let y;return e[38]!==v||e[39]!==m||e[40]!==p||e[41]!==b?(y=n.jsxs("div",{className:m,children:[p,b,v]}),e[38]=v,e[39]=m,e[40]=p,e[41]=b,e[42]=y):y=e[42],y}function bb(t){return n.jsx(tt,{value:t.id,children:t.title},t.id)}function yb(){}const Sb=/^[A-Za-z_][A-Za-z0-9_]*$/;function wb(t){const e={},s=t.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=(s[i]??"").trim();if(!r||r.startsWith("#"))continue;r.startsWith("export ")&&(r=r.slice(7).trim());const o=r.indexOf("=");if(o<0)throw new Error(`Line ${i+1}: missing '='`);const a=r.slice(0,o).trim();if(!Sb.test(a))throw new Error(`Line ${i+1}: invalid key "${a}"`);let l=r.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const Cb=/^[A-Za-z0-9_.-]+$/;function kb(t){const e=U.c(14),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-baseline justify-between gap-2",children:n.jsx(Ve,{className:"font-normal text-foreground",children:"Environment variables"})}),l=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Injected into the sandbox on every start. Reference an org/user secret to keep values out of metadata; literals are stored inline."}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let d;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==r?(d=n.jsx(Nb,{control:s,form:i,virtualMcpId:r,orgSlug:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=r,e[6]=d):d=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(wl,{className:"h-9 w-full"}),e[7]=c):c=e[7];let h;e[8]!==s||e[9]!==i?(h=n.jsx(Zt,{fallback:jb,children:n.jsx(D.Suspense,{fallback:c,children:n.jsx(Tb,{control:s,form:i})})}),e[8]=s,e[9]=i,e[10]=h):h=e[10];let u;return e[11]!==d||e[12]!==h?(u=n.jsxs("div",{className:"space-y-2",children:[a,l,d,h]}),e[11]=d,e[12]=h,e[13]=u):u=e[13],u}function jb(t){const{error:e}=t;return n.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:e?.message??"Failed to load secrets"})}function Nb(t){const e=U.c(24),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t,l=$i.useSession().data?.user?.id,d="metadata.runtime.env",c="metadata.sandboxMap";let h;e[0]!==i?(h=()=>JSON.stringify(ed(i.getValues(d))),e[0]=i,e[1]=h):h=e[1];const[u,f]=D.useState(h);let m;e[2]!==s?(m={control:s,name:d},e[2]=s,e[3]=m):m=e[3];const p=Uh(m);let g;e[4]!==p?(g=JSON.stringify(ed(p)),e[4]=p,e[5]=g):g=e[5];const _=g,b=_!==u;let x;e[6]!==i?(x=i.getValues(c),e[6]=i,e[7]=x):x=e[7];const v=x;let y;e[8]!==v||e[9]!==l?(y=l?Object.keys(v?.[l]??{}):[],e[8]=v,e[9]=l,e[10]=y):y=e[10];const S=y,w=S.length>0,[C,N]=D.useState(!1);if(!b||!w)return null;let E;e[11]!==_||e[12]!==o||e[13]!==S||e[14]!==r?(E=async()=>{N(!0);const A=await Promise.allSettled(S.map(async L=>{const P=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(r)}/${encodeURIComponent(L)}/setup/start`,B=await fetch(P,{method:"POST"});if(!B.ok){const F=await B.text().catch(()=>B.statusText);throw new Error(F||B.statusText)}}));N(!1);const O=A.filter(Eb).length;O===0?(f(_),he.success(S.length===1?"Restarted dev with new env":`Restarted ${S.length} branches with new env`)):he.error(`Failed to restart ${O} of ${S.length} branch(es)`)},e[11]=_,e[12]=o,e[13]=S,e[14]=r,e[15]=E):E=e[15];const R=E;let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-amber-900 dark:text-amber-200",children:[n.jsx(Hh,{className:"size-3.5 shrink-0"}),n.jsx("span",{className:"truncate",children:"Your sandbox is running. Restart the dev script to apply the new env."})]}),e[16]=T):T=e[16];let k;e[17]!==C?(k=C?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Pn,{className:"size-3.5"}),e[17]=C,e[18]=k):k=e[18];const j=C?"Restarting…":"Restart dev";let I;return e[19]!==R||e[20]!==C||e[21]!==k||e[22]!==j?(I=n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs dark:border-amber-900/40 dark:bg-amber-950/30",children:[T,n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:C,className:"shrink-0",children:[k,j]})]}),e[19]=R,e[20]=C,e[21]=k,e[22]=j,e[23]=I):I=e[23],I}function Eb(t){return t.status==="rejected"}function Tb(t){const e=U.c(48),{control:s,form:i}=t,r="metadata.runtime.env";let o;e[0]!==s?(o={control:s,name:r},e[0]=s,e[1]=o):o=e[1];const a=Qp(o),{fields:l,append:d,remove:c}=a;let h;e[2]!==i?(h=(A,O)=>{i.setValue(`${r}.${A}`,O,{shouldDirty:!0,shouldTouch:!0})},e[2]=i,e[3]=h):h=e[3];const u=h,f=g1();let m;if(e[4]!==f){m=new Map;for(const A of f)m.set(A.id,A);e[4]=f,e[5]=m}else m=e[5];const[p,g]=D.useState(null);let _;e[6]!==d?(_=()=>{d({key:"",kind:"literal",value:""})},e[6]=d,e[7]=_):_=e[7];const b=_;let x;e[8]!==d||e[9]!==i?(x=async()=>{let A;try{A=await navigator.clipboard.readText()}catch{he.error("Couldn't read clipboard");return}if(!A.trim()){he.error("Clipboard is empty");return}let O;try{O=wb(A)}catch(z){const W=z;he.error(W.message);return}const L=Object.entries(O);if(L.length===0){he.error("Nothing to add");return}const P=i.getValues(r)??[],B=new Set;for(const z of P){const W=(z.key??"").trim();W&&B.add(W)}let F=0,H=0;for(const[z,W]of L){if(B.has(z)){H++;continue}d({key:z,kind:"literal",value:W}),B.add(z),F++}F===0&&H>0?he.message(`All ${H} key${H===1?"":"s"} already exist`):he.success(H>0?`Added ${F} var${F===1?"":"s"} (${H} already existed)`:`Added ${F} var${F===1?"":"s"}`)},e[8]=d,e[9]=i,e[10]=x):x=e[10];const v=x;let y;if(e[11]!==s||e[12]!==l||e[13]!==i||e[14]!==c||e[15]!==m||e[16]!==f||e[17]!==u){let A;e[19]!==s||e[20]!==i||e[21]!==c||e[22]!==m||e[23]!==f||e[24]!==u?(A=(O,L)=>n.jsx("li",{className:"rounded-md border border-border bg-background",children:n.jsx(Ab,{index:L,control:s,form:i,onUpdateEntry:u,fieldPath:r,secrets:f,secretById:m,onSaveAsSecret:(P,B)=>g({kind:"save-literal",index:L,presetKey:P,presetValue:B}),onCreateNewSecret:P=>g({kind:"create-new",index:L,presetKey:P}),onRemove:()=>c(L)})},O.id),e[19]=s,e[20]=i,e[21]=c,e[22]=m,e[23]=f,e[24]=u,e[25]=A):A=e[25],y=l.map(A),e[11]=s,e[12]=l,e[13]=i,e[14]=c,e[15]=m,e[16]=f,e[17]=u,e[18]=y}else y=e[18];let S;e[26]!==y?(S=n.jsx("ul",{className:"space-y-2",children:y}),e[26]=y,e[27]=S):S=e[27];let w;e[28]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Dt,{className:"size-3.5"}),e[28]=w):w=e[28];let C;e[29]!==b?(C=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:b,className:"flex-1",children:[w,"Add env var"]}),e[29]=b,e[30]=C):C=e[30];let N;e[31]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(C_,{className:"size-3.5"}),e[31]=N):N=e[31];let E;e[32]!==v?(E=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:v,"aria-label":"Paste .env",children:[N,"Paste .env"]})}),e[32]=v,e[33]=E):E=e[33];let R;e[34]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Ee,{children:"Read a .env blob from the clipboard. Each pair is staged as a literal — save individual rows as secrets after."}),e[34]=R):R=e[34];let T;e[35]!==E?(T=n.jsxs(Te,{children:[E,R]}),e[35]=E,e[36]=T):T=e[36];let k;e[37]!==T||e[38]!==C?(k=n.jsxs("div",{className:"flex items-center gap-2",children:[C,T]}),e[37]=T,e[38]=C,e[39]=k):k=e[39];let j;e[40]!==p||e[41]!==i||e[42]!==u?(j=p!==null?n.jsx(Db,{mode:p,onClose:()=>g(null),onSaved:A=>{const O=i.getValues(`${r}.${p.index}.key`)?.trim()??"";u(p.index,{key:O,kind:"secret",secretId:A}),g(null)}}):null,e[40]=p,e[41]=i,e[42]=u,e[43]=j):j=e[43];let I;return e[44]!==k||e[45]!==j||e[46]!==S?(I=n.jsxs("div",{className:"space-y-2",children:[S,k,j]}),e[44]=k,e[45]=j,e[46]=S,e[47]=I):I=e[47],I}function Ab(t){const e=U.c(55),{index:s,control:i,form:r,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:d,onSaveAsSecret:c,onCreateNewSecret:h,onRemove:u}=t,f=`${a}.${s}.key`,m=`${a}.${s}.value`,p=`${a}.${s}.secretId`,g=`${a}.${s}.kind`;let _;e[0]!==i||e[1]!==g?(_={control:i,name:g},e[0]=i,e[1]=g,e[2]=_):_=e[2];const x=Uh(_)==="secret"?"secret":"literal";let v;e[3]!==r||e[4]!==s||e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==m?(v=F=>{const H=r.getValues(f)?.trim()??"";if(F==="literal"){o(s,{key:H,kind:"literal",value:""});return}const z=r.getValues(m)??"";if(z.length>0){c(H,z);return}o(s,{key:H,kind:"secret",secretId:""})},e[3]=r,e[4]=s,e[5]=f,e[6]=c,e[7]=o,e[8]=m,e[9]=v):v=e[9];const y=v;let S;e[10]!==s?(S=F=>{const{field:H}=F,z=(H.value??"").trim(),W=z.length>0&&!so.test(z);return n.jsxs("div",{className:"space-y-1",children:[n.jsx(ze,{...H,value:H.value??"",placeholder:"KEY",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:ae("font-mono",W&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":W,"aria-label":`Env var ${s+1} key`,onBlur:q=>{const K=q.target.value.trim();H.onChange(K),H.onBlur()}}),W?n.jsx("p",{className:"text-[11px] text-destructive",children:"Letters, digits, underscores. Must start with a letter or underscore."}):null]})},e[10]=s,e[11]=S):S=e[11];let w;e[12]!==i||e[13]!==f||e[14]!==S?(w=n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(Ht,{control:i,name:f,render:S})}),e[12]=i,e[13]=f,e[14]=S,e[15]=w):w=e[15];let C;e[16]!==y?(C=F=>y(F),e[16]=y,e[17]=C):C=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(kt,{className:"h-9 w-[110px]",children:n.jsx(Rt,{})}),e[18]=N):N=e[18];let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(tt,{value:"literal",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Sl,{className:"size-3.5"}),"Literal"]})}),e[19]=E):E=e[19];let R;e[20]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsxs(jt,{children:[E,n.jsx(tt,{value:"secret",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(eg,{className:"size-3.5"}),"Secret"]})})]}),e[20]=R):R=e[20];let T;e[21]!==x||e[22]!==C?(T=n.jsx("div",{className:"shrink-0",children:n.jsxs(Nt,{value:x,onValueChange:C,children:[N,R]})}),e[21]=x,e[22]=C,e[23]=T):T=e[23];let k;e[24]!==i||e[25]!==r||e[26]!==s||e[27]!==f||e[28]!==x||e[29]!==h||e[30]!==d||e[31]!==p||e[32]!==l||e[33]!==m?(k=n.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:x==="literal"?n.jsx(Ht,{control:i,name:m,render:F=>{const{field:H}=F;return n.jsx(ze,{...H,value:H.value??"",type:"password",placeholder:"value",spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":`Env var ${s+1} value`,onBlur:z=>{H.onChange(z.target.value),H.onBlur()}})}}):n.jsxs(n.Fragment,{children:[n.jsx(Ht,{control:i,name:p,render:F=>{const{field:H}=F;return n.jsxs(Nt,{value:H.value||"",onValueChange:z=>H.onChange(z),children:[n.jsx(kt,{className:ae("h-9 w-full",!H.value&&"text-muted-foreground"),children:n.jsx(Rt,{placeholder:"Pick a secret…",children:n.jsx(Pb,{field:H,secretById:d})})}),n.jsx(jt,{children:l.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No secrets yet. Use the “+” to create one."}):l.map(Rb)})]})}}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:()=>{const F=r.getValues(f)?.trim()??"";h(F)},children:n.jsx(Dt,{className:"size-3.5"})})}),n.jsx(Ee,{children:"Create new secret"})]})]})}),e[24]=i,e[25]=r,e[26]=s,e[27]=f,e[28]=x,e[29]=h,e[30]=d,e[31]=p,e[32]=l,e[33]=m,e[34]=k):k=e[34];let j;e[35]!==r||e[36]!==f||e[37]!==x||e[38]!==c||e[39]!==m?(j=x==="literal"?n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Save value as secret",onClick:()=>{const F=r.getValues(f)?.trim()??"",H=r.getValues(m)??"";c(F,H)},children:n.jsx(Nu,{className:"size-3.5"})})}),n.jsx(Ee,{children:"Save value as secret"})]}):null,e[35]=r,e[36]=f,e[37]=x,e[38]=c,e[39]=m,e[40]=j):j=e[40];let I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(es,{className:"size-3.5"}),e[41]=I):I=e[41];let A;e[42]!==u?(A=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove env var",onClick:u,children:I})}),e[42]=u,e[43]=A):A=e[43];let O;e[44]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ee,{children:"Remove"}),e[44]=O):O=e[44];let L;e[45]!==A?(L=n.jsxs(Te,{children:[A,O]}),e[45]=A,e[46]=L):L=e[46];let P;e[47]!==j||e[48]!==L?(P=n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[j,L]}),e[47]=j,e[48]=L,e[49]=P):P=e[49];let B;return e[50]!==k||e[51]!==P||e[52]!==w||e[53]!==T?(B=n.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[w,T,k,P]}),e[50]=k,e[51]=P,e[52]=w,e[53]=T,e[54]=B):B=e[54],B}function Rb(t){return n.jsx(tt,{value:t.id,children:n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(Ef,{scope:t.scope}),n.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function Pb(t){const e=U.c(12),{field:s,secretById:i}=t,r=s.value||"";if(!r)return null;let o;e[0]!==r||e[1]!==i?(o=i.get(r),e[0]=r,e[1]=i,e[2]=o):o=e[2];const a=o;if(!a){let h;return e[3]!==r?(h=n.jsxs("span",{className:"text-destructive",children:["Missing secret (",r,")"]}),e[3]=r,e[4]=h):h=e[4],h}let l;e[5]!==a.scope?(l=n.jsx(Ef,{scope:a.scope}),e[5]=a.scope,e[6]=l):l=e[6];let d;e[7]!==a.name?(d=n.jsx("span",{className:"truncate font-mono",children:a.name}),e[7]=a.name,e[8]=d):d=e[8];let c;return e[9]!==l||e[10]!==d?(c=n.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[l,d]}),e[9]=l,e[10]=d,e[11]=c):c=e[11],c}function Ef(t){const e=U.c(2),{scope:s}=t,i=s==="user"?p1:co;let r;return e[0]!==i?(r=n.jsx(i,{className:"size-3 text-muted-foreground"}),e[0]=i,e[1]=r):r=e[1],r}function Db({mode:t,onClose:e,onSaved:s}){const i=t.kind==="save-literal"?t.presetValue:"",r=t.presetKey,[o,a]=D.useState(()=>Ib(r)),[l,d]=D.useState("organization"),[c,h]=D.useState(i),[u,f]=D.useState(""),m=_1(),p=o.trim(),g=c.length>0&&p.length>0&&Cb.test(p),_=async v=>{if(v.preventDefault(),!!g)try{const y=await m.mutateAsync({scope:l,name:p,value:c,description:u.trim()||void 0});he.success(`Saved secret "${y.name}"`),s(y.id)}catch(y){he.error(y instanceof Error?y.message:"Failed to save")}},b=t.kind==="save-literal"?"Save value as secret":"Create new secret",x=t.kind==="save-literal"?"Move this value into the encrypted vault. The env var will then reference the secret by id — its value never leaves the server.":"Stored encrypted in the credential vault. The env var will reference the new secret by id.";return n.jsx(Bt,{open:!0,onOpenChange:v=>{v||e()},children:n.jsxs(Mt,{className:"sm:max-w-md",children:[n.jsxs(ts,{children:[n.jsx(ss,{children:b}),n.jsx(Wi,{children:x})]}),n.jsxs("form",{onSubmit:_,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-scope",children:"Scope"}),n.jsxs(Nt,{value:l,onValueChange:v=>d(v),children:[n.jsx(kt,{id:"save-secret-scope",children:n.jsx(Rt,{})}),n.jsxs(jt,{children:[n.jsx(tt,{value:"organization",children:"Organization — visible to all members"}),n.jsx(tt,{value:"user",children:"Private — only visible to me"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-name",children:"Name"}),n.jsx(ze,{id:"save-secret-name",value:o,onChange:v=>a(v.target.value),placeholder:"STRIPE_API_KEY",autoComplete:"off",required:!0}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters, digits, underscore, dot, hyphen. Independent of the env var key."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-value",children:"Value"}),n.jsx(ze,{id:"save-secret-value",type:"password",value:c,onChange:v=>h(v.target.value),placeholder:"secret value",autoComplete:"new-password",required:!0})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ve,{htmlFor:"save-secret-description",children:"Description (optional)"}),n.jsx(Ln,{id:"save-secret-description",value:u,onChange:v=>f(v.target.value),rows:2,placeholder:"What is this secret used for?"})]}),n.jsxs(Ws,{children:[n.jsx(ie,{type:"button",variant:"outline",onClick:e,disabled:m.isPending,children:"Cancel"}),n.jsx(ie,{type:"submit",disabled:!g||m.isPending,children:m.isPending?"Saving…":"Save secret"})]})]})]})})}function ed(t){if(!Array.isArray(t))return[];const e=[];for(const s of t){if(!s||typeof s!="object")continue;const i=s,r=(i.key??"").trim();if(!(!r||!so.test(r))){if(i.kind==="literal"){e.push({key:r,kind:"literal",value:i.value??""});continue}i.kind==="secret"&&i.secretId&&e.push({key:r,kind:"secret",secretId:i.secretId})}}return e}function Ib(t){const e=t.trim();return e&&so.test(e)?e:""}function Lb(t){const e=U.c(12),{repo:s,className:i}=t;let r;e[0]!==i?(r=ae("space-y-2",i),e[0]=i,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Ve,{children:"Repository"}),e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Uu,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(Ne,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[a,n.jsx("div",{className:"min-w-0 flex-1",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):n.jsx("div",{className:"text-sm text-muted-foreground",children:"No repository connected"})})]})}),e[4]=s,e[5]=l):l=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Ee,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=d):d=e[6];let c;e[7]!==l?(c=n.jsxs(Te,{children:[l,d]}),e[7]=l,e[8]=c):c=e[8];let h;return e[9]!==r||e[10]!==c?(h=n.jsxs("div",{className:r,children:[o,c]}),e[9]=r,e[10]=c,e[11]=h):h=e[11],h}const Ob={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function Bb(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const Mb=Object.keys(Ob),Ro="__none__";function $b(t){const e=U.c(20),{control:s}=t,i=D.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Ve,{htmlFor:"runtime-pm",children:"Package manager"}),e[0]=r):r=e[0];let o;e[1]!==s?(o=n.jsxs("div",{className:"space-y-2",children:[r,n.jsx(Ht,{control:s,name:"metadata.runtime.selected",render:Fb})]}),e[1]=s,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ve,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(Ht,{control:s,name:"metadata.runtime.path",render:zb}),e[4]=s,e[5]=l):l=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Path (relative to repo root) to the directory containing package.json. Leave blank for the repo root."}),e[6]=d):d=e[6];let c;e[7]!==l?(c=n.jsxs("div",{className:"space-y-2",children:[a,l,d]}),e[7]=l,e[8]=c):c=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ve,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=h):h=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=_=>{const{field:b}=_;return n.jsx(ze,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:b.value??"",onBlur:x=>{const v=Bb(x.target.value);v.ok?b.onChange(v.value):i.current&&(i.current.value=b.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=n.jsx(Ht,{control:s,name:"metadata.runtime.port",render:u}),e[11]=s,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to let the runner pick."}),e[13]=m):m=e[13];let p;e[14]!==f?(p=n.jsxs("div",{className:"space-y-2",children:[h,f,m]}),e[14]=f,e[15]=p):p=e[15];let g;return e[16]!==p||e[17]!==o||e[18]!==c?(g=n.jsxs("div",{className:"space-y-5",children:[o,c,p]}),e[16]=p,e[17]=o,e[18]=c,e[19]=g):g=e[19],g}function zb(t){const{field:e}=t;return n.jsx(ze,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const i=s.target.value.trim();e.onChange(i===""?null:i)}})}function Fb(t){const{field:e}=t;return n.jsxs(Nt,{value:e.value??Ro,onValueChange:s=>e.onChange(s===Ro?null:s),children:[n.jsx(kt,{id:"runtime-pm",children:n.jsx(Rt,{placeholder:"Auto-detect"})}),n.jsxs(jt,{children:[n.jsx(tt,{value:Ro,children:"Auto-detect"}),Mb.map(Hb)]})]})}function Hb(t){return n.jsx(tt,{value:t,children:t},t)}function Ub(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Wb(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function Vb(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(i=>{if(!i||typeof i!="object")return!1;const r=(i.key??"").trim();return!r||!so.test(r)?!1:i.kind==="literal"?!0:i.kind==="secret"?!!i.secretId:!1});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}function Kb(t){const e=U.c(23),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:d}=t,c=vl(s),{org:h}=Me();if(!c)return null;let u;e[0]!==c?(u=a1(c),e[0]=c,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=n.jsx(Xb,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.status||e[9]!==c.title||e[10]!==s||e[11]!==a||e[12]!==d||e[13]!==r||e[14]!==o||e[15]!==l||e[16]!==h.slug||e[17]!==f||e[18]!==i?(p=n.jsx(Yb,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,connectionStatus:c.status,slug:f,orgSlug:h.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:d}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.status,e[9]=c.title,e[10]=s,e[11]=a,e[12]=d,e[13]=r,e[14]=o,e[15]=l,e[16]=h.slug,e[17]=f,e[18]=i,e[19]=p):p=e[19];let g;return e[20]!==m||e[21]!==p?(g=n.jsx(D.Suspense,{fallback:m,children:p}),e[20]=m,e[21]=p,e[22]=g):g=e[22],g}const td="__new_instance__";async function qb(t,e){const s=t?.idToken??null;if(s){const r=sd(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return sd(e)}function sd(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Gb(t){const e=U.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:o,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const d=Vn(l);if(d.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==o?(c=g=>{g===td?a?.():o(i,g)},e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(kt,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(Rt,{})}),e[6]=h):h=e[6];let u;if(e[7]!==i||e[8]!==d||e[9]!==r){let g;e[11]!==i||e[12]!==r?(g=_=>n.jsx(tt,{value:_.id,className:"text-xs",disabled:_.id!==i&&r.has(_.id),children:_.title},_.id),e[11]=i,e[12]=r,e[13]=g):g=e[13],u=d.map(g),e[7]=i,e[8]=d,e[9]=r,e[10]=u}else u=e[10];let f;e[14]!==a?(f=a&&n.jsx(tt,{value:td,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=n.jsxs(jt,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==i||e[20]!==c||e[21]!==m?(p=n.jsxs(Nt,{value:i,onValueChange:c,children:[h,m]}),e[19]=i,e[20]=c,e[21]=m,e[22]=p):p=e[22],p}function Yb({connection_id:t,connectionTitle:e,connectionDescription:s,connectionIcon:i,connectionType:r,connectionStatus:o,slug:a,orgSlug:l,appName:d,usedConnectionIds:c,onOpenSettings:h,onRemove:u,onAuthenticate:f,onSwitchInstance:m,onNewInstance:p}){const g=Mu({connectionId:t}),_=Pu(),x=!(r==="VIRTUAL")&&g.supportsOAuth&&!g.isAuthenticated,v=o!=="active",y=async S=>{try{await _.update.mutateAsync({id:t,data:{status:S}}),he.success(S==="active"?"Connection enabled":"Connection disabled")}catch{he.error("Failed to update connection")}};return n.jsxs("div",{className:ae("rounded-xl border overflow-hidden transition-colors",x||v?"border-destructive/50 bg-destructive/5":"border-border bg-card"),children:[n.jsxs(Vh,{to:"/$org/settings/connections/$appSlug",params:{org:l,appSlug:a},className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[n.jsx(xs,{icon:i,name:e,size:"sm",className:"shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:e}),x?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):v?n.jsx("span",{className:"text-xs text-destructive font-medium",children:o==="error"?"Disabled (error)":"Disabled"}):s&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]}),x?n.jsx(ie,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:S=>{S.preventDefault(),S.stopPropagation(),f(t)},children:"Authorize"}):v?n.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 shrink-0",onClick:S=>{S.preventDefault(),S.stopPropagation(),y("active")},children:[n.jsx(j_,{size:13}),"Enable"]}):n.jsxs(Te,{delayDuration:0,children:[n.jsx(Ne,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:n.jsx(l1,{size:16})})}),n.jsx(Ee,{side:"bottom",children:"Connection settings"})]})]}),n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[d&&n.jsx(Gb,{appName:d,connectionId:t,usedConnectionIds:c,onSwitchInstance:m,onNewInstance:p}),n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[n.jsxs(Te,{delayDuration:0,children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":"Configure resources",children:n.jsx(N_,{size:13})})}),n.jsx(Ee,{side:"bottom",children:"Configure resources"})]}),!v&&n.jsxs(Te,{delayDuration:0,children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>y("inactive"),"aria-label":"Disable connection",children:n.jsx(E_,{size:13})})}),n.jsx(Ee,{side:"bottom",children:"Disable"})]}),n.jsxs(Te,{delayDuration:0,children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:u,"aria-label":"Remove connection",children:n.jsx(Hs,{size:13})})}),n.jsx(Ee,{side:"bottom",children:"Remove"})]})]})]})]})}function Xb(t){const e=U.c(17),{connection_id:s}=t,i=vl(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Tf,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(xs,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let o;e[4]!==i.title?(o=n.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=n.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let d;e[11]!==r||e[12]!==l?(d=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=d):d=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let h;return e[15]!==d?(h=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[d,c]}),e[15]=d,e[16]=h):h=e[16],h}function Tf(){const t=U.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function Jb({virtualMcpId:t,form:e,flushAndSave:s}){const i=di(),r=vs(t),o=(r?.connections??[]).map(k=>k.connection_id).sort(),{data:a}=Es({queryKey:Et.projectConnectionDetails(t,o),enabled:o.length>0,queryFn:async()=>await Promise.all(o.map(async j=>{try{const{item:I}=await i.call("COLLECTION_CONNECTIONS_GET",{id:j}),A=(I?.tools??[]).flatMap(O=>{const L=Lu(O._meta);return L?[{name:O.name,title:O.title,description:O.description,resourceUri:L}]:[]});return{fetchOk:!0,id:j,title:I?.title??j,icon:I?.icon??null,uiTools:A}}catch{return{fetchOk:!1,id:j,title:j,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(k=>k.uiTools.length>0),d=new Set(Jg),c=e.watch("metadata.ui.pinnedViews")??[],h=e.watch("metadata.ui.layout")??null,u=h?.defaultMainView??null,f=h?.chatDefaultOpen??!1,m=!u||u.type==="chat"?"chat":u.type==="instructions"||u.type==="connections"||u.type==="layout"?"settings":d.has(u.type)?u.type:`${u.type}:${u.id??""}:${u.toolName??""}`,p=k=>{const[j,I,A]=k.split(":");return j?j==="chat"?{type:j}:d.has(j)?{type:j}:j==="ext-apps"&&I?{type:"ext-apps",id:I,toolName:A||void 0}:null:null},g=k=>{e.setValue("metadata.ui.pinnedViews",k,{shouldDirty:!0})},_=k=>{e.setValue("metadata.ui.layout",{...h,...k},{shouldDirty:!0})},b=D.useRef(!1);if(a&&a.length>0&&!b.current){b.current=!0;const k=new Set((a??[]).filter(A=>A.fetchOk).map(A=>A.id)),j=new Set(l.flatMap(A=>A.uiTools.map(O=>`${A.id}:${O.name}`))),I=c.filter(A=>!k.has(A.connectionId)||j.has(`${A.connectionId}:${A.toolName}`));I.length!==c.length&&(g(I),u?.type==="ext-apps"&&!I.some(A=>A.connectionId===u.id&&A.toolName===u.toolName)&&_({defaultMainView:{type:"chat"}}))}const x=(k,j)=>{if(c.some(A=>A.connectionId===k&&A.toolName===j)){const A=c.filter(L=>!(L.connectionId===k&&L.toolName===j));g(A);const O=`ext-apps:${k}:${j}`;m===O&&_({defaultMainView:{type:"chat"}})}else{const A=l.find(O=>O.id===k)?.uiTools.find(O=>O.name===j)?.title;g([...c,{connectionId:k,toolName:j,label:A??aa(j),icon:null}])}s()},v=(k,j,I)=>{g(c.map(A=>A.connectionId===k&&A.toolName===j?{...A,label:I}:A))},y=()=>{s()},S=(k,j,I)=>{g(c.map(A=>A.connectionId===k&&A.toolName===j?{...A,icon:I}:A)),s()},w=k=>{_({defaultMainView:p(k)}),s()},C=o.length===0,N=a&&l.length===0,E=ti(r?.metadata),R=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];E&&R.push({value:"preview",label:"Preview"});for(const k of c)R.push({value:`ext-apps:${k.connectionId}:${k.toolName}`,label:k.label||k.toolName});const T=l.length>0||C||N;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),n.jsxs(yl,{className:"p-6 gap-5",children:[n.jsxs(Ir,{className:"p-0 space-y-5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Ve,{className:"font-normal text-foreground",children:"Main view"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),n.jsxs(Nt,{value:m,onValueChange:w,children:[n.jsx(kt,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(Rt,{})}),n.jsx(jt,{children:R.map(k=>n.jsx(tt,{value:k.value,className:"capitalize",children:k.label},k.value))})]})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Ve,{className:"font-normal text-foreground",children:"Show chat"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),n.jsxs(Te,{delayDuration:0,children:[n.jsx(Ne,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(On,{checked:m==="chat"?!0:f,disabled:m==="chat",onCheckedChange:k=>{_({chatDefaultOpen:k}),s()}})})}),m==="chat"&&n.jsx(Ee,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),T&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(Ir,{className:"p-0 space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-4",children:n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Ve,{className:"font-normal text-foreground",children:"Pinned views"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),C&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),N&&!C&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:l.map((k,j)=>n.jsxs("div",{children:[j>0&&n.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),n.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[n.jsx(xs,{icon:k.icon,name:k.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:k.title})]}),n.jsx("div",{className:"space-y-1.5",children:k.uiTools.map(I=>{const A=c.some(L=>L.connectionId===k.id&&L.toolName===I.name),O=c.find(L=>L.connectionId===k.id&&L.toolName===I.name);return n.jsxs("div",{className:ae("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",A?"bg-accent/40 border-border":"bg-transparent border-border"),children:[n.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[n.jsx(Dx,{value:O?.icon??null,onChange:L=>S(k.id,I.name,L),disabled:!A}),n.jsx(ze,{value:A&&O?O.label:I.title??aa(I.name),onChange:L=>v(k.id,I.name,L.target.value),onBlur:y,className:"h-7 text-sm w-40",disabled:!A,readOnly:!A})]}),n.jsx(On,{checked:A,onCheckedChange:()=>x(k.id,I.name)})]},I.name)})})]},k.id))})]})]})]})]})}function Zb({virtualMcp:t,hideOwnTitle:e}){const{org:s}=Me(),i=Xh(),{data:r}=xg([t.id]),o=r?.get(t.id)?.last_used_at,a=Pu(),l=oi(),d=di(),c=Wh({resolver:tg(ob),defaultValues:t}),h=c.watch("connections"),u=tu(t),f=Wn(t),m=f?{owner:f.owner,name:f.name,url:f.url}:null,[p,g]=D.useReducer(Ub,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[_,b]=D.useState(!1),[x,v]=D.useState(!1),{createNewTask:y,setChatOpen:S}=fl(),{sendMessage:w}=li(),C=async()=>{if(x)return;const $=c.getValues("metadata.instructions");if($?.trim()){v(!0);try{j(),Ke("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:$.length}),S(!0),await w({tiptapDoc:kf({managerAgentId:eu.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:$})})}finally{v(!1)}}},N=()=>{j(),Ke("agent_test_clicked",{agent_id:t.id}),y()},[E,R]=D.useReducer(Wb,null),T=()=>{E!==null&&(Ke("agent_updated",{agent_id:t.id,fields:Array.from(E.fields),instructions_length:E.instructionsLength,save_count:E.saveCount,edit_duration_ms:Date.now()-E.start}),R({type:"reset"}))},{schedule:k,flush:j}=Lr({delayMs:3e4,save:async()=>T()}),I=async()=>{const $=Object.keys(c.control._formState.dirtyFields);if($.length===0)return;const X=$.includes("metadata"),V=c.getValues();c.reset(V,{keepValues:!0});const se=Vb(V);await i.update.mutateAsync({id:t.id,data:se}),R({type:"accumulate",now:Date.now(),fields:$,instructionsLength:X?V.metadata?.instructions?.length??0:null}),k()},{schedule:A,flush:O}=Lr({save:I});D.useEffect(()=>{const $=c.watch(()=>A());return()=>$.unsubscribe()},[]);const L=()=>{Ke("connections_dialog_opened",{source:"agent_settings",mode:"add"}),g({type:"SET_ADD_DIALOG_OPEN",payload:!0})},P=async $=>{const X=c.getValues("connections");if(X.some(ee=>ee.connection_id===$))return;c.setValue("connections",[...X,{connection_id:$,selected_tools:Ao.tools,selected_resources:Ao.resources,selected_prompts:Ao.prompts}],{shouldDirty:!0}),g({type:"SET_ADD_DIALOG_OPEN",payload:!1});const V=new URL(`/api/${s.slug}/mcp/${$}`,window.location.origin),se=await $c({url:V.href,token:null,orgId:s.id});se.supportsOAuth&&!se.isAuthenticated&&await W($)},B=$=>{const V=c.getValues("connections").filter(se=>se.connection_id!==$);c.setValue("connections",V,{shouldDirty:!0})},F=($,X)=>{const V=c.getValues("connections");if(V.some(se=>se.connection_id===X)){he.error("This instance is already added to the agent");return}c.setValue("connections",V.map(se=>se.connection_id===$?{...se,connection_id:X}:se),{shouldDirty:!0})},H=async $=>{if(c.getValues("connections").find(V=>V.connection_id===$))try{const{item:V}=await d.call("COLLECTION_CONNECTIONS_GET",{id:$});if(!V)return;const se=V.title.replace(/\s*\(.*?\)\s*$/,""),ee=s1("conn"),le=`${se} (${Date.now().toString(36).slice(-4)})`;await a.create.mutateAsync({id:ee,title:le,description:V.description??null,connection_type:V.connection_type,connection_url:V.connection_url??null,connection_token:null,icon:V.icon??null,app_name:V.app_name??null,app_id:V.app_id??null,connection_headers:V.connection_headers??null});const ce=new URL(`/api/${s.slug}/mcp/${ee}`,window.location.origin),fe=await $c({url:ce.href,token:null,orgId:s.id});if(fe.supportsOAuth&&!fe.isAuthenticated){const J=await W(ee);if(!J){await a.delete.mutateAsync(ee);return}await a.update.mutateAsync({id:ee,data:{title:`${se} (${J})`}})}F($,ee),he.success("New instance created")}catch(V){console.error("Failed to create instance:",V),he.error("Failed to create instance")}},z=$=>{g({type:"OPEN_SETTINGS",payload:$})},W=async $=>{const{token:X,tokenInfo:V,error:se}=await o1({connectionId:$,orgSlug:s.slug,scope:"offline_access"});if(se||!X)return he.error(`Authentication failed: ${se}`),null;if(V)try{const le=await fetch(`/api/${s.slug}/connections/${$}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:V.accessToken,refreshToken:V.refreshToken,expiresIn:V.expiresIn,scope:V.scope,clientId:V.clientId,clientSecret:V.clientSecret,tokenEndpoint:V.tokenEndpoint})});if(!le.ok)console.error("Failed to save OAuth token:",await le.text()),await a.update.mutateAsync({id:$,data:{connection_token:X}});else try{await a.update.mutateAsync({id:$,data:{}})}catch(ce){console.warn("Failed to refresh connection tools after OAuth:",ce)}}catch(le){console.error("Error saving OAuth token:",le),await a.update.mutateAsync({id:$,data:{connection_token:X}})}else await a.update.mutateAsync({id:$,data:{connection_token:X}});const ee=new URL(`/api/${s.slug}/mcp/${$}`,window.location.origin);return await l.invalidateQueries({queryKey:Et.isMCPAuthenticated(ee.href,null)}),he.success("Authentication successful"),qb(V,X)},q=()=>{const $=c.getValues("metadata.instructions")??"",X=`<role>
11
- Define who this agent is and what it specializes in.
12
- Example: You are a support triage agent for B2B merchants.
13
- </role>
14
-
15
- <capabilities>
16
- List what this agent can do using its connected tools.
17
- - Investigate issues using connected data sources.
18
- - Summarize findings and recommend next steps.
19
- </capabilities>
20
-
21
- <constraints>
22
- Set clear boundaries on what the agent must not do.
23
- - Do not perform destructive actions without confirmation.
24
- - Escalate to a human when the request is outside your expertise.
25
- </constraints>
26
-
27
- <workflows>
28
- Define step-by-step how the agent should handle requests.
29
-
30
- ## Default workflow
31
- 1. Read the user's request and gather context.
32
- 2. Use the appropriate tools to investigate or act.
33
- 3. Summarize the result and propose next steps.
34
- 4. Ask for confirmation before making any changes.
35
- </workflows>`,V=$.trim()?`${$}
36
-
37
- ${X}`:X;c.setValue("metadata.instructions",V,{shouldDirty:!0})},K=new Set(h.map($=>$.connection_id)),Z=qt(),[Y,G]=D.useState(!1),Q=async()=>{j();try{await i.delete.mutateAsync(t.id),Ke("agent_deleted",{agent_id:t.id,source:"agent_detail"}),he.success(`Deleted "${t.title}"`),Z({to:"/$org",params:{org:s.slug}})}catch{}};return n.jsxs(os,{children:[n.jsx(os.Content,{children:n.jsx(os.Body,{children:n.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&n.jsx(os.Title,{actions:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(ie,{variant:"outline",size:"sm",onClick:N,children:[n.jsx(Di,{size:14,className:"size-[14px]!"}),"Test Agent"]}),n.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>G(!0),children:n.jsx(es,{size:14})})]}),children:"Settings"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ht,{name:"icon",control:c.control,render:({field:$})=>n.jsx(jx,{value:$.value??null,onChange:X=>{$.onChange(X),O()},onColorChange:X=>{c.setValue("metadata.ui.themeColor",X,{shouldDirty:!0}),O()},name:c.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2"})}),n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsx(Ht,{name:"title",control:c.control,render:({field:$})=>n.jsx("input",{...$,type:"text",value:$.value??"",onChange:X=>{$.onChange(X)},onBlur:()=>{$.onBlur(),O()},disabled:u,placeholder:"Agent name",className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),n.jsx(Ht,{name:"description",control:c.control,render:({field:$})=>n.jsx("input",{...$,type:"text",value:$.value??"",onChange:X=>{$.onChange(X)},onBlur:()=>{$.onBlur(),O()},disabled:u,placeholder:"Add a description...",className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),n.jsxs(ie,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Ke("agent_connect_modal_opened",{agent_id:t.id}),g({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[n.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[n.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),n.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),n.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-sm text-muted-foreground",children:[n.jsx(jf,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsxs("span",{children:["Created"," ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{children:o?`Last used ${v1(new Date(o),{addSuffix:!0})}`:"Never used"})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&n.jsxs(ie,{variant:"outline",size:"sm",onClick:L,children:[n.jsx(Dt,{size:14}),"Add connection"]})]}),n.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?n.jsxs("button",{type:"button",onClick:L,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(Dt,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map($=>n.jsx(Zt,{fallback:()=>null,children:n.jsx(D.Suspense,{fallback:n.jsx(Tf,{}),children:n.jsx(Kb,{connection_id:$.connection_id,usedConnectionIds:K,onOpenSettings:()=>z($.connection_id),onRemove:()=>B($.connection_id),onAuthenticate:W,onSwitchInstance:F,onNewInstance:()=>H($.connection_id)})})},$.connection_id))})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),n.jsxs("div",{className:"flex items-center gap-2",children:[!c.watch("metadata.instructions")?.trim()&&n.jsx(ie,{variant:"outline",size:"sm",onClick:q,children:"+ Prompt template"}),n.jsxs(ie,{variant:"outline",size:"sm",disabled:x||!c.watch("metadata.instructions")?.trim(),onClick:C,children:[n.jsx(Zs,{size:13}),"Improve"]})]})]}),n.jsx(Ht,{name:"metadata.instructions",control:c.control,render:({field:$})=>n.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[n.jsx(Ln,{...$,value:$.value??"",onChange:X=>{$.onChange(X)},onBlur:()=>{$.onBlur(),O()},placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),n.jsxs(Te,{delayDuration:0,children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>b(!0),"aria-label":"Open fullscreen editor",children:n.jsx(k_,{size:14})})}),n.jsx(Ee,{side:"left",children:"Fullscreen"})]})]})})]}),n.jsx(Ox,{form:c}),n.jsx(Zt,{fallback:()=>null,children:n.jsx(D.Suspense,{fallback:n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sub-agents"}),n.jsx("div",{className:"h-16 rounded-lg border border-dashed border-border animate-pulse"})]}),children:n.jsx(Ux,{form:c,currentAgentId:t.id})})}),n.jsx(Jb,{virtualMcpId:t.id,form:c,flushAndSave:O}),n.jsx(xb,{virtualMcp:t}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sandbox"})}),n.jsx(yl,{className:"p-6 gap-5",children:n.jsxs(Ir,{className:"p-0 space-y-5",children:[n.jsx(Lb,{repo:m}),n.jsx($b,{control:c.control}),n.jsx(kb,{control:c.control,form:c,virtualMcpId:t.id,orgSlug:s.slug})]})})]}),n.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),n.jsxs(ie,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>G(!0),children:[n.jsx(es,{size:14}),"Delete agent"]})]})]})})}),n.jsx(jr,{open:Y,onOpenChange:G,children:n.jsxs(Nr,{children:[n.jsxs(Er,{children:[n.jsx(Tr,{children:"Delete Agent?"}),n.jsxs(Ar,{children:["This action cannot be undone. This will permanently delete"," ",n.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),n.jsxs(Rr,{children:[n.jsx(Pr,{children:"Cancel"}),n.jsx(Dr,{onClick:Q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),n.jsx(Hg,{open:p.addDialogOpen,onOpenChange:$=>g({type:"SET_ADD_DIALOG_OPEN",payload:$}),agentId:t.id,addedConnectionIds:K,onAdd:P}),n.jsx(rb,{open:p.settingsDialogOpen,onOpenChange:$=>{$||g({type:"CLOSE_SETTINGS"})},selectedId:p.settingsConnectionId,form:c,connections:h,onAuthenticate:W}),n.jsx(vb,{open:p.shareDialogOpen,onOpenChange:$=>g({type:"SET_SHARE_DIALOG_OPEN",payload:$}),virtualMcp:t}),n.jsx(Bt,{open:_,onOpenChange:b,children:n.jsxs(Mt,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[n.jsx(ts,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:n.jsx(ss,{children:"Instructions"})}),n.jsx("div",{className:"flex-1 min-h-0 p-6",children:n.jsx(Ht,{name:"metadata.instructions",control:c.control,render:({field:$})=>n.jsx(Ln,{...$,value:$.value??"",onChange:X=>{$.onChange(X)},onBlur:()=>{$.onBlur(),O()},disabled:u,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function Qb(t){const e=U.c(9),{virtualMcpId:s,hideOwnTitle:i}=t,r=qt(),{org:o}=Me(),a=vs(s);if(!a){let c;return e[0]!==r||e[1]!==o.slug?(c=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(Cr,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:n.jsx(ie,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:o.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=o.slug,e[2]=c):c=e[2],c}let l;e[3]!==a?(l=Wn(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let d;return e[5]!==i||e[6]!==l||e[7]!==a?(d=n.jsx(Zb,{virtualMcp:a,hideOwnTitle:i},l),e[5]=i,e[6]=l,e[7]=a,e[8]=d):d=e[8],d}function id(t){const e=U.c(2),{virtualMcpId:s}=t;let i;return e[0]!==s?(i=n.jsx(Qb,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=i):i=e[1],i}const ey={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function $n(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const i=Number.parseInt(s.slice(2),16);return Number.isFinite(i)?String.fromCodePoint(i):e}if(s.startsWith("#")){const i=Number.parseInt(s.slice(1),10);return Number.isFinite(i)?String.fromCodePoint(i):e}return ey[s]??e}):""}const ty=10;function sy(t){const e=t;if(e.isError)return null;const s=e.content?.find(r=>r.type==="resource"),i=s?.resource?.text??s?.text;if(!i)return null;try{const r=JSON.parse(i);return typeof r=="string"?r:r&&typeof r=="object"&&"content"in r&&typeof r.content=="string"?r.content:JSON.stringify(r,null,2)}catch{return i}}async function tr(t,e,s){try{const i=await t.callTool({name:"get_file_contents",arguments:{owner:e.owner,repo:e.repo,path:e.path,...s}});return sy(i)}catch{return null}}function iy(t){const e=ui(t);return Array.isArray(e)?e.map(s=>{const i=Number(s.additions??0),r=Number(s.changes??i),o=Number(s.deletions??Math.max(0,r-i));return{filename:String(s.filename??""),status:s.status??"modified",additions:i,deletions:o,blobUrl:typeof s.blob_url=="string"?s.blob_url:null}}):[]}async function ny(t,e,s){if(t.length===0)return;let i=0;async function r(){for(;i<t.length;){const o=i++;await s(t[o])}}await Promise.all(Array.from({length:Math.min(e,t.length)},()=>r()))}async function nd(t,e){const s=await t.callTool({name:"pull_request_read",arguments:{method:"get_files",owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,perPage:100}}),i=iy(s).filter(a=>a.filename.length>0),r={},o=e.mergeBaseSha?{sha:e.mergeBaseSha}:{ref:e.base};return await ny(i,ty,async a=>{const l=a.filename;if(a.status==="added"){r[l]={from:null,to:await tr(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})};return}if(a.status==="removed"){r[l]={from:await tr(t,{owner:e.owner,repo:e.repo,path:l},o),to:null};return}const[d,c]=await Promise.all([tr(t,{owner:e.owner,repo:e.repo,path:l},o),tr(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})]);r[l]={from:d,to:c}}),{diffs:r}}function Af(t){return t?Object.keys(t.diffs).length:0}function Gi(t,e,s,i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${i}`}class Rf extends Error{constructor(e,s){super(e),this.status=s,this.name="SandboxGitError"}status}function Jl(t){return t instanceof Rf&&(t.status===503||t.status===410||t.status===404)}async function Yi(t){const e=await t.json();if(!t.ok)throw new Rf(typeof e.error=="string"?e.error:`Request failed (${t.status})`,t.status);return e}function Xi(t,e){return fetch(t,{cache:"no-store",...e})}async function gr(t,e,s){const i=await Xi(Gi(t,e,s,"status"));return Yi(i)}async function Pf(t,e,s,i){const r=i?.base||i?.headSha?{...i.base?{base:i.base}:{},...i.headSha?{headSha:i.headSha}:{}}:void 0,o=await Xi(Gi(t,e,s,"diff"),{method:"POST",headers:r?{"content-type":"application/json"}:void 0,body:r?JSON.stringify(r):void 0});return Yi(o)}async function rd(t,e,s,i){const r=await Xi(Gi(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i??{})});return Yi(r)}async function Po(t,e,s,i){const r=await Xi(Gi(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:i})});await Yi(r)}async function ry(t,e,s,i){const r=await Xi(Gi(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:i})});await Yi(r)}function oy(t){return t==="blocks.gen.json"||t.endsWith("/blocks.gen.json")}function ay(t){return t==="static/tailwind.css"||t.endsWith("/static/tailwind.css")}function od(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>s===".deco"||s.startsWith(".deco/")||oy(s)||ay(s))}const ly="Code changes can't be published directly — use Submit for review";async function ad(t,e,s,i){const r=await Xi(Gi(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:i})});await Yi(r)}const cy="current";function Zl(t){return t?.[cy]??null}function dy(t,e,s){return["sandbox-git-status",t,e,s]}function Df(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function If(t){return t?Df(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function Lf(t){return t?If(t)||t.ahead>0||(t.unpushed??0)>0?!0:t.unpushed===void 0&&(t.aheadOfBase??0)>0&&t.tracking==null:!1}function hy(t,e){return t?Lf(t)||e!=null&&Object.keys(e.diffs).length>0:!1}function uy(t){return Math.max(t.unpushed??0,t.ahead)}function fy(t){return t.aheadOfBase??0}function my(t){return t.behindBase??0}function py(t,e){if(!e)return t;const s=If(e),i=Zl(e),r=uy(e),o=fy(e),a=my(e),l=e.base??"main",d=e.headSha??"";return t.kind==="ready"?{...t,branch:i??t.branch,base:e.base??t.base,workingTreeDirty:s,unpushed:Math.max(t.unpushed,r),aheadOfBase:Math.max(t.aheadOfBase,o),behindBase:e.behindBase!==void 0?Math.max(t.behindBase,a):t.behindBase,headSha:d||t.headSha}:!s&&o===0&&r===0?t:{kind:"ready",branch:i??"",base:l,workingTreeDirty:s,unpushed:r,aheadOfBase:o,behindBase:a,headSha:d}}function gy(t,e,s,i,r,o,a){return["pr-diff",t,e,s,i,r,o,a]}function _y(t){const e=U.c(26),{orgSlug:s,orgId:i,virtualMcpId:r,branch:o,base:a,headSha:l,pullNumber:d,connectionId:c,owner:h,repo:u,enabled:f}=t,m=f===void 0?!0:f;let p;e[0]!==c||e[1]!==i||e[2]!==s?(p={connectionId:c,orgId:i,orgSlug:s},e[0]=c,e[1]=i,e[2]=s,e[3]=p):p=e[3];const g=Pt(p);let _;e[4]!==a||e[5]!==o||e[6]!==c||e[7]!==l||e[8]!==s||e[9]!==d||e[10]!==r?(_=gy(s,r,o,a,l,d,c),e[4]=a,e[5]=o,e[6]=c,e[7]=l,e[8]=s,e[9]=d,e[10]=r,e[11]=_):_=e[11];let b;e[12]!==a||e[13]!==o||e[14]!==g||e[15]!==l||e[16]!==s||e[17]!==h||e[18]!==d||e[19]!==u||e[20]!==r?(b=async()=>{try{const y=await Pf(s,r,o,{base:a,headSha:l});return Af(y)>0?y:nd(g,{owner:h,repo:u,pullNumber:d,base:a,headSha:l,mergeBaseSha:y.mergeBaseSha})}catch{return nd(g,{owner:h,repo:u,pullNumber:d,base:a,headSha:l})}},e[12]=a,e[13]=o,e[14]=g,e[15]=l,e[16]=s,e[17]=h,e[18]=d,e[19]=u,e[20]=r,e[21]=b):b=e[21];const x=m&&!!o&&!!l&&!!c;let v;return e[22]!==_||e[23]!==b||e[24]!==x?(v={queryKey:_,queryFn:b,enabled:x,refetchInterval:3e4,staleTime:1e4},e[22]=_,e[23]=b,e[24]=x,e[25]=v):v=e[25],Es(v)}Q_.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function vy(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function Of(t){const e=U.c(9),{diff:s,emptyMessage:i,rowClassName:r,onDiscardFile:o}=t,a=i===void 0?"No file changes in the working tree":i,l=r===void 0?"px-6":r,[d,c]=D.useState(null),[h,u]=D.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=vy(),e[0]=f):f=e[0];const m=f;if(!s||Object.keys(s.diffs).length===0){let g;return e[1]!==a?(g=n.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:a}),e[1]=a,e[2]=g):g=e[2],g}let p;return e[3]!==s.diffs||e[4]!==h||e[5]!==d||e[6]!==o||e[7]!==l?(p=n.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(g=>{const[_,b]=g,{from:x,to:v}=b,y=d===_,S=x===null,w=v===null,C=_.startsWith("/")?_.slice(1):_,N=C.lastIndexOf("/"),E=N>=0?C.slice(N+1):C,R=N>=0?C.slice(0,N):null,T=n_(_),k=S?"bg-green-500":w?"bg-red-500":"bg-amber-500";return n.jsxs("div",{children:[n.jsxs("div",{className:ae("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[n.jsx("button",{type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-transform hover:text-foreground",onClick:()=>c(y?null:_),children:n.jsx(Vi,{className:ae("h-3.5 w-3.5 transition-transform",y&&"rotate-90")})}),n.jsx("div",{className:ae("h-2.5 w-2.5 shrink-0 rounded-full",k)}),n.jsx(Ou,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:E}),R&&n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:R}),o?n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:n.jsx(Hi,{className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{align:"end",children:n.jsx(Ue,{className:"text-destructive focus:text-destructive",onSelect:()=>u(_),children:"Discard changes"})})]}):null]}),h===_&&o?n.jsxs("div",{className:ae("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[n.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",n.jsx("span",{className:"font-medium",children:E}),"? This cannot be undone."]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(null),children:"Cancel"}),n.jsx(ie,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u(null),o(_)},children:"Discard"})]})]}):null,y&&n.jsx("div",{className:"border-t",children:n.jsx(e1,{original:x??"",modified:v??"",language:T,theme:m,height:"380px",options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12}})})]},_)})}),e[3]=s.diffs,e[4]=h,e[5]=d,e[6]=o,e[7]=l,e[8]=p):p=e[8],p}function xy(t){const e=U.c(4),{diffQuery:s}=t;if(s.isLoading){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[n.jsx(Oe,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading changes…"})]}),e[0]=r):r=e[0],r}if(s.isError){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"py-10 text-sm text-destructive",children:"Couldn't load PR changes."}),e[1]=r):r=e[1],r}let i;return e[2]!==s.data?(i=n.jsx(Of,{diff:s.data,rowClassName:"px-0",emptyMessage:"No committed changes in this pull request"}),e[2]=s.data,e[3]=i):i=e[3],i}const mi="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function by(t){return`Reopen PR #${t.prNumber}. ${mi}`}function yy(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${mi}`}function Sy(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${mi}`}function wy(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${mi}`}function Cy(t){return`Mark PR #${t.prNumber} ready for review. ${mi}`}function ky(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${mi}`}function jy(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${mi}`}function Ny(t){const e=U.c(24),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=Me(),l=li();let d;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(d={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=d):d=e[6];const c=nf(d);let h;e[7]!==l||e[8]!==s.number?(h=_=>l.sendMessage({parts:[{type:"text",text:Sy({prNumber:s.number,checkName:_})}]}),e[7]=l,e[8]=s.number,e[9]=h):h=e[9];const u=h;if(c.isLoading){let _;return e[10]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[10]=_):_=e[10],_}if(c.isError){let _;return e[11]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[11]=_):_=e[11],_}let f;e[12]!==c.data?(f=c.data??[],e[12]=c.data,e[13]=f):f=e[13];const m=f;if(m.length===0){let _;return e[14]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[14]=_):_=e[14],_}let p;if(e[15]!==l||e[16]!==m||e[17]!==u){let _;e[19]!==l||e[20]!==u?(_=b=>n.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Ey,{check:b}),n.jsx("span",{className:"truncate",children:b.name}),b.durationMs!=null&&n.jsx("span",{className:"text-xs text-muted-foreground",children:Ty(b.durationMs)})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[b.htmlUrl&&n.jsx("a",{href:b.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:"View run",children:n.jsx(hi,{className:"h-3.5 w-3.5"})}),b.conclusion==="failure"&&n.jsx(ie,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(b.name),children:"Re-run"})]})]},b.id),e[19]=l,e[20]=u,e[21]=_):_=e[21],p=m.map(_),e[15]=l,e[16]=m,e[17]=u,e[18]=p}else p=e[18];let g;return e[22]!==p?(g=n.jsx("ul",{className:"flex flex-col gap-0.5",children:p}),e[22]=p,e[23]=g):g=e[23],g}function Ey(t){const e=U.c(5),{check:s}=t;if(s.status!=="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=o):o=e[0],o}if(s.conclusion==="success"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=o):o=e[1],o}if(s.conclusion==="failure"){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=o):o=e[2],o}const i=s.conclusion??"—";let r;return e[3]!==i?(r=n.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[3]=i,e[4]=r):r=e[4],r}function Ty(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}var ds="Accordion",Ay=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ql,Ry,Py]=sg(ds),[uo]=ig(ds,[Py,Zh]),ec=Zh(),Bf=Ut.forwardRef((t,e)=>{const{type:s,...i}=t,r=i,o=i;return n.jsx(Ql.Provider,{scope:t.__scopeAccordion,children:s==="multiple"?n.jsx(Oy,{...o,ref:e}):n.jsx(Ly,{...r,ref:e})})});Bf.displayName=ds;var[Mf,Dy]=uo(ds),[$f,Iy]=uo(ds,{collapsible:!1}),Ly=Ut.forwardRef((t,e)=>{const{value:s,defaultValue:i,onValueChange:r=()=>{},collapsible:o=!1,...a}=t,[l,d]=qh({prop:s,defaultProp:i??"",onChange:r,caller:ds});return n.jsx(Mf,{scope:t.__scopeAccordion,value:Ut.useMemo(()=>l?[l]:[],[l]),onItemOpen:d,onItemClose:Ut.useCallback(()=>o&&d(""),[o,d]),children:n.jsx($f,{scope:t.__scopeAccordion,collapsible:o,children:n.jsx(zf,{...a,ref:e})})})}),Oy=Ut.forwardRef((t,e)=>{const{value:s,defaultValue:i,onValueChange:r=()=>{},...o}=t,[a,l]=qh({prop:s,defaultProp:i??[],onChange:r,caller:ds}),d=Ut.useCallback(h=>l((u=[])=>[...u,h]),[l]),c=Ut.useCallback(h=>l((u=[])=>u.filter(f=>f!==h)),[l]);return n.jsx(Mf,{scope:t.__scopeAccordion,value:a,onItemOpen:d,onItemClose:c,children:n.jsx($f,{scope:t.__scopeAccordion,collapsible:!0,children:n.jsx(zf,{...o,ref:e})})})}),[By,fo]=uo(ds),zf=Ut.forwardRef((t,e)=>{const{__scopeAccordion:s,disabled:i,dir:r,orientation:o="vertical",...a}=t,l=Ut.useRef(null),d=ng(l,e),c=Ry(s),u=rg(r)==="ltr",f=og(t.onKeyDown,m=>{if(!Ay.includes(m.key))return;const p=m.target,g=c().filter(N=>!N.ref.current?.disabled),_=g.findIndex(N=>N.ref.current===p),b=g.length;if(_===-1)return;m.preventDefault();let x=_;const v=0,y=b-1,S=()=>{x=_+1,x>y&&(x=v)},w=()=>{x=_-1,x<v&&(x=y)};switch(m.key){case"Home":x=v;break;case"End":x=y;break;case"ArrowRight":o==="horizontal"&&(u?S():w());break;case"ArrowDown":o==="vertical"&&S();break;case"ArrowLeft":o==="horizontal"&&(u?w():S());break;case"ArrowUp":o==="vertical"&&w();break}const C=x%b;g[C].ref.current?.focus()});return n.jsx(By,{scope:s,disabled:i,direction:r,orientation:o,children:n.jsx(Ql.Slot,{scope:s,children:n.jsx(Kh.div,{...a,"data-orientation":o,ref:d,onKeyDown:i?void 0:f})})})}),Fr="AccordionItem",[My,tc]=uo(Fr),Ff=Ut.forwardRef((t,e)=>{const{__scopeAccordion:s,value:i,...r}=t,o=fo(Fr,s),a=Dy(Fr,s),l=ec(s),d=ag(),c=i&&a.value.includes(i)||!1,h=o.disabled||t.disabled;return n.jsx(My,{scope:s,open:c,disabled:h,triggerId:d,children:n.jsx(Cg,{"data-orientation":o.orientation,"data-state":qf(c),...l,...r,ref:e,disabled:h,open:c,onOpenChange:u=>{u?a.onItemOpen(i):a.onItemClose(i)}})})});Ff.displayName=Fr;var Hf="AccordionHeader",Uf=Ut.forwardRef((t,e)=>{const{__scopeAccordion:s,...i}=t,r=fo(ds,s),o=tc(Hf,s);return n.jsx(Kh.h3,{"data-orientation":r.orientation,"data-state":qf(o.open),"data-disabled":o.disabled?"":void 0,...i,ref:e})});Uf.displayName=Hf;var xa="AccordionTrigger",Wf=Ut.forwardRef((t,e)=>{const{__scopeAccordion:s,...i}=t,r=fo(ds,s),o=tc(xa,s),a=Iy(xa,s),l=ec(s);return n.jsx(Ql.ItemSlot,{scope:s,children:n.jsx(wg,{"aria-disabled":o.open&&!a.collapsible||void 0,"data-orientation":r.orientation,id:o.triggerId,...l,...i,ref:e})})});Wf.displayName=xa;var Vf="AccordionContent",Kf=Ut.forwardRef((t,e)=>{const{__scopeAccordion:s,...i}=t,r=fo(ds,s),o=tc(Vf,s),a=ec(s);return n.jsx(kg,{role:"region","aria-labelledby":o.triggerId,"data-orientation":r.orientation,...a,...i,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});Kf.displayName=Vf;function qf(t){return t?"open":"closed"}var $y=Bf,zy=Ff,Fy=Uf,Hy=Wf,Uy=Kf;function Wy(t){const e=U.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=n.jsx($y,{"data-slot":"accordion",...s}),e[2]=s,e[3]=i):i=e[3],i}function Vy(t){const e=U.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("border-b last:border-b-0",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(zy,{"data-slot":"accordion-item",className:r,...i}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function Ky(t){const e=U.c(11);let s,i,r;e[0]!==t?({className:i,children:s,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let o;e[4]!==i?(o=ae("focus-visible:border-ring focus-visible:ring-ring/20 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[2px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",i),e[4]=i,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Vi,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==r||e[9]!==o?(l=n.jsx(Fy,{className:"flex",children:n.jsxs(Hy,{"data-slot":"accordion-trigger",className:o,...r,children:[s,a]})}),e[7]=s,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function qy(t){const e=U.c(12);let s,i,r;e[0]!==t?({className:i,children:s,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let o;e[4]!==i?(o=ae("pt-0 pb-4",i),e[4]=i,e[5]=o):o=e[5];let a;e[6]!==s||e[7]!==o?(a=n.jsx("div",{className:o,children:s}),e[6]=s,e[7]=o,e[8]=a):a=e[8];let l;return e[9]!==r||e[10]!==a?(l=n.jsx(Uy,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...r,children:a}),e[9]=r,e[10]=a,e[11]=l):l=e[11],l}function Gy(t){const e=U.c(10),{comments:s,isLoading:i,isError:r}=t;if(i||r||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=n.jsxs(Ky,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(Yy),e[3]=s,e[4]=l):l=e[4];let d;e[5]!==l?(d=n.jsx(qy,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=d):d=e[6];let c;return e[7]!==a||e[8]!==d?(c=n.jsx(Wy,{type:"single",collapsible:!0,className:"border-t border-border",children:n.jsxs(Vy,{value:"comments",className:"border-b-0",children:[a,d]})}),e[7]=a,e[8]=d,e[9]=c):c=e[9],c}function Yy(t){return n.jsxs("div",{className:"rounded-md border border-border p-3",children:[n.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",Xy(t.createdAt)]}),n.jsx(xl,{id:`pr-comment-${t.id}`,text:$n(t.body)})]},t.id)}function Xy(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const i=Math.floor(s/864e5);if(i>0)return`${i}d ago`;const r=Math.floor(s/36e5);if(r>0)return`${r}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function Jy(t){const e=U.c(19),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=Me();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const d=Iv(l);let c;e[7]!==s.body||e[8]!==s.number?(c=s.body&&n.jsx("div",{className:"text-sm",children:n.jsx(xl,{id:`pr-body-${s.number}`,text:$n(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=c):c=e[9];let h;e[10]!==d.data?(h=d.data??[],e[10]=d.data,e[11]=h):h=e[11];let u;e[12]!==d.isError||e[13]!==d.isLoading||e[14]!==h?(u=n.jsx(Gy,{comments:h,isLoading:d.isLoading,isError:d.isError}),e[12]=d.isError,e[13]=d.isLoading,e[14]=h,e[15]=u):u=e[15];let f;return e[16]!==c||e[17]!==u?(f=n.jsxs("div",{className:"space-y-8",children:[c,u]}),e[16]=c,e[17]=u,e[18]=f):f=e[18],f}function Zy(t){const e=U.c(68),{pr:s,virtualMcpId:i,branch:r,connectionId:o,owner:a,repo:l}=t,{org:d}=Me();let c;e[0]!==r||e[1]!==o||e[2]!==d.id||e[3]!==d.slug||e[4]!==a||e[5]!==s.base||e[6]!==s.headSha||e[7]!==s.number||e[8]!==l||e[9]!==i?(c={orgSlug:d.slug,orgId:d.id,virtualMcpId:i,branch:r,base:s.base,headSha:s.headSha,pullNumber:s.number,connectionId:o,owner:a,repo:l},e[0]=r,e[1]=o,e[2]=d.id,e[3]=d.slug,e[4]=a,e[5]=s.base,e[6]=s.headSha,e[7]=s.number,e[8]=l,e[9]=i,e[10]=c):c=e[10];const h=_y(c);let u;e[11]!==h.data?(u=h.data?Af(h.data):void 0,e[11]=h.data,e[12]=u):u=e[12];const f=u,[m,p]=D.useState("changes");let g;e[13]!==s.title?(g=$n(s.title),e[13]=s.title,e[14]=g):g=e[14];let _;e[15]!==g?(_=n.jsx("h1",{className:"text-lg font-semibold leading-tight",children:g}),e[15]=g,e[16]=_):_=e[16];const b=`Open PR #${s.number} on GitHub`;let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(hi,{className:"h-3.5 w-3.5"}),e[17]=x):x=e[17];let v;e[18]!==s.htmlUrl||e[19]!==s.number||e[20]!==b?(v=n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":b,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,x]}),e[18]=s.htmlUrl,e[19]=s.number,e[20]=b,e[21]=v):v=e[21];let y;e[22]!==s.author?(y=s.author?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("span",{children:["@",s.author]})]}):null,e[22]=s.author,e[23]=y):y=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("span",{children:"·"}),e[24]=S):S=e[24];let w;e[25]!==s.base?(w=n.jsx("span",{className:"font-mono text-xs",children:s.base}),e[25]=s.base,e[26]=w):w=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("span",{children:"←"}),e[27]=C):C=e[27];let N;e[28]!==s.head?(N=n.jsx("span",{className:"font-mono text-xs",children:s.head}),e[28]=s.head,e[29]=N):N=e[29];let E;e[30]!==w||e[31]!==N||e[32]!==v||e[33]!==y?(E=n.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 text-sm text-muted-foreground",children:[v,y,S,w,C,N]}),e[30]=w,e[31]=N,e[32]=v,e[33]=y,e[34]=E):E=e[34];let R;e[35]!==E||e[36]!==_?(R=n.jsx("div",{className:"shrink-0 space-y-3 pb-4",children:n.jsxs("div",{className:"space-y-1",children:[_,E]})}),e[35]=E,e[36]=_,e[37]=R):R=e[37];let T;e[38]===Symbol.for("react.memo_cache_sentinel")?(T=W=>p(W),e[38]=T):T=e[38];let k;e[39]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(zs,{value:"description",className:"px-3 text-xs",children:"Description"}),e[39]=k):k=e[39];const j=f!==void 0?` ${f}`:"";let I;e[40]!==j?(I=n.jsxs(zs,{value:"changes",className:"px-3 text-xs",children:["Changes",j]}),e[40]=j,e[41]=I):I=e[41];let A;e[42]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(zs,{value:"checks",className:"px-3 text-xs",children:"Checks"}),e[42]=A):A=e[42];let O;e[43]!==I?(O=n.jsxs(ao,{className:"h-8 w-fit max-w-[600px] shrink-0",variant:"pill",children:[k,I,A]}),e[43]=I,e[44]=O):O=e[44];let L;e[45]!==o||e[46]!==a||e[47]!==s||e[48]!==l?(L=n.jsx(Ei,{value:"description",className:"mt-0",children:n.jsx(Jy,{pr:s,connectionId:o,owner:a,repo:l})}),e[45]=o,e[46]=a,e[47]=s,e[48]=l,e[49]=L):L=e[49];let P;e[50]!==h?(P=n.jsx(Ei,{value:"changes",className:"mt-0",children:n.jsx(xy,{diffQuery:h})}),e[50]=h,e[51]=P):P=e[51];let B;e[52]!==o||e[53]!==a||e[54]!==s||e[55]!==l?(B=n.jsx(Ei,{value:"checks",className:"mt-0",children:n.jsx(Ny,{pr:s,connectionId:o,owner:a,repo:l})}),e[52]=o,e[53]=a,e[54]=s,e[55]=l,e[56]=B):B=e[56];let F;e[57]!==L||e[58]!==P||e[59]!==B?(F=n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pt-5",children:[L,P,B]}),e[57]=L,e[58]=P,e[59]=B,e[60]=F):F=e[60];let H;e[61]!==m||e[62]!==O||e[63]!==F?(H=n.jsxs(lo,{value:m,onValueChange:T,className:"flex min-h-0 flex-1 flex-col",children:[O,F]}),e[61]=m,e[62]=O,e[63]=F,e[64]=H):H=e[64];let z;return e[65]!==R||e[66]!==H?(z=n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[R,H]}),e[65]=R,e[66]=H,e[67]=z):z=e[67],z}function Qy(t){const e=U.c(5),{pr:s}=t,i=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(hi,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let o;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==i?(o=n.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":i,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:["PR #",s.number,r]})}),e[1]=s.htmlUrl,e[2]=s.number,e[3]=i,e[4]=o):o=e[4],o}function e0(t){const e=U.c(10),{virtualMcpId:s}=t,{org:i}=Me(),r=vs(s),{currentBranch:o}=Ts(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:"This virtualmcp is not linked to a GitHub repository."}),e[0]=d):d=e[0],d}if(!o){let d;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[n.jsx(Dn,{className:"h-6 w-6 text-muted-foreground"}),n.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),n.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the header to see PR status."})]}),e[1]=d):d=e[1],d}let l;return e[2]!==o||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==i.id||e[7]!==i.slug||e[8]!==s?(l=n.jsx(t0,{orgId:i.id,orgSlug:i.slug,virtualMcpId:s,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:o}),e[2]=o,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=i.id,e[7]=i.slug,e[8]=s,e[9]=l):l=e[9],l}function t0(t){const e=U.c(47),{orgId:s,orgSlug:i,virtualMcpId:r,connectionId:o,owner:a,repo:l,branch:d}=t;let c;e[0]!==d||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l?(c={orgId:s,orgSlug:i,connectionId:o,owner:a,repo:l,branch:d},e[0]=d,e[1]=o,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=c):c=e[6];const{data:h,isLoading:u,isError:f}=Ll(c),m=s0;if(u){let v;return e[7]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[7]=v):v=e[7],v}if(f){let v;return e[8]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[8]=v):v=e[8],v}const p=`https://github.com/${a}/${l}/tree/${d}`;if(h&&h.state==="closed"){let v;e[9]!==h?(v=n.jsx(Qy,{pr:h}),e[9]=h,e[10]=v):v=e[10];const y=h.merged?"✓ Merged":"✗ Closed";let S;e[11]!==h.mergedAt?(S=h.mergedAt&&n.jsxs(n.Fragment,{children:[" · ",new Date(h.mergedAt).toLocaleDateString()]}),e[11]=h.mergedAt,e[12]=S):S=e[12];let w;e[13]!==h.author?(w=h.author&&n.jsxs(n.Fragment,{children:[" · by @",h.author]}),e[13]=h.author,e[14]=w):w=e[14];let C;e[15]!==h.base||e[16]!==y||e[17]!==S||e[18]!==w?(C=n.jsxs("div",{className:"text-sm text-success",children:[y," into ",h.base,S,w]}),e[15]=h.base,e[16]=y,e[17]=S,e[18]=w,e[19]=C):C=e[19];let N;e[20]!==h.title?(N=$n(h.title),e[20]=h.title,e[21]=N):N=e[21];let E;e[22]!==N?(E=n.jsx("h1",{className:"text-lg font-semibold",children:N}),e[22]=N,e[23]=E):E=e[23];let R;e[24]!==h.body||e[25]!==h.number?(R=h.body&&n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:n.jsx(xl,{id:`pr-body-${h.number}`,text:$n(h.body)})}),e[24]=h.body,e[25]=h.number,e[26]=R):R=e[26];let T;e[27]!==C||e[28]!==E||e[29]!==R?(T=n.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[C,E,R]}),e[27]=C,e[28]=E,e[29]=R,e[30]=T):T=e[30];let k;return e[31]!==v||e[32]!==T?(k=n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[v,T]}),e[31]=v,e[32]=T,e[33]=k):k=e[33],k}if(h&&h.state==="open"){let v;return e[34]!==d||e[35]!==o||e[36]!==a||e[37]!==h||e[38]!==l||e[39]!==r?(v=n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col px-6 py-5",children:n.jsx(Zy,{pr:h,virtualMcpId:r,branch:d,connectionId:o,owner:a,repo:l})})}),e[34]=d,e[35]=o,e[36]=a,e[37]=h,e[38]=l,e[39]=r,e[40]=v):v=e[40],v}let g;e[41]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:`This branch doesn't have an open pull request. Click "Submit for review" in the header to open one; the agent will draft the title and summary from the current state of the branch.`}),e[41]=g):g=e[41];let _;e[42]!==p?(_=()=>m(p),e[42]=p,e[43]=_):_=e[43];let b;e[44]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(hi,{className:"mr-1.5 h-4 w-4"}),e[44]=b):b=e[44];let x;return e[45]!==_?(x=n.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[g,n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(ie,{size:"sm",variant:"outline",onClick:_,children:[b,"Open branch on GitHub"]})})]}),e[45]=_,e[46]=x):x=e[46],x}function s0(t){window.open(t,"_blank","noopener,noreferrer")}const i0=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function n0(t){return t.includes("matchers")||t.includes("Match")}function r0(t,e){const s=t.__resolveType;return typeof s!="string"||!s||i0.has(s)?!1:e?Vv(e,s):n0(s)}function Ji(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!Ns(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:r0(r,s)}function o0(t,e,s){return Ji(t,e,s)?t?.__resolveType??null:null}function Gf(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Ji(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:d,name:c,...h}=a;return{resolveType:l,data:h,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function a0(t,e,s){const i=Gf(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function J6(t,e,s){if(t)return Ji(t,e,s)?a0(t,e,s):t}function l0(t,e,s,i){if(!t)return"Default";if(Ji(t,e,i)){const r=t.__resolveType??"",o=e[r];return Kl(r,o)}return s(t)}function Z6(t,e,s){return{__resolveType:t,...e,name:s}}function Q6(t){return{__resolveType:t}}function eE(t,e,s){const i=Gf(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}const ld="x-deco-matchers-override";function Yf({pageKey:t,prefix:e,variants:s,selectedIndex:i,decofile:r,meta:o}){if(!t||i<0||i>=s.length)return[];const a=[];for(let l=0;l<=i;l++){const d=s[l];if(!d)continue;const c=d.rule,h=l===i?"1":"0",f=(Ji(c,r,o)?o0(c,r,o):null)??`${t}@${e}.${l}.rule`;a.push(`${f}=${h}`)}return a}function tE(t,e,s,i){return!e.multivariate||e.variants.length<=1?[]:Yf({pageKey:t,prefix:"sections.variants",variants:e.variants,selectedIndex:e.index,decofile:s,meta:i})}function sE({pageKey:t,page:e,sectionIndex:s,sectionLazy:i,mvObj:r,selectedVariantIndex:o,decofile:a,meta:l}){if(s<0)return[];const c=`${e.multivariate?`sections.variants.${e.index}.value`:"sections"}.${s}${i?".section":""}.variants`,h=Array.isArray(r.variants)?r.variants:[];return Yf({pageKey:t,prefix:c,variants:h,selectedIndex:o,decofile:a,meta:l})}function c0(t,e){if(e.length===0)return t;const s=new URL(t,"http://local");s.searchParams.delete(ld);for(const i of e)s.searchParams.append(ld,i);return t.startsWith("http")?s.toString():`${s.pathname}${s.search}${s.hash}`}function Xf(t,e){return t.map((s,i)=>{const r=s.__resolveType??"",o=Tt(r);if(!o&&r!==""&&Ns(r)&&r in e){const c=e[r],h=typeof c?.name=="string"&&c.name||r.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${i+1}`;return{index:i,resolveType:r,label:h,isLazy:!1,isSavedBlock:!0}}const a=o?s.section:void 0,l=o?a?.__resolveType??"":r;if(l===qi||l===Yn){const c=o?a:s,h=Array.isArray(c?.variants)?c.variants:[];if(h.length===1&&(h[0]?.rule?.__resolveType??"")===$l){const m=h[0]?.value??{};let p=m.__resolveType??"";const g=Tt(p);return g&&(p=m.section?.__resolveType??p),{index:i,resolveType:r,label:ut(p)||`Section ${i+1}`,isHidden:!0,isLazy:g}}const u=h[0]?.value?.__resolveType,f=u?ut(u):"Section";return{index:i,resolveType:r,label:`Variants of ${f}`,isMultivariate:!0,isLazy:o}}const d=o?s.section?.__resolveType??r:r;if(o&&d!==""&&Ns(d)&&d in e){const c=e[d],h=typeof c?.name=="string"&&c.name||d.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${i+1}`;return{index:i,resolveType:r,label:h,isLazy:!0,isSavedBlock:!0}}return{index:i,resolveType:r,label:ut(d)||`Section ${i+1}`,isLazy:o}})}function Jf(t){const e=t.__resolveType??"";return Tt(e)?t.section??t:t}function Hr(t){const r=(Tt(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==$l?null:r?.value??null}function iE(t){const e=Jf(t);return{__resolveType:Yn,variants:[{value:e,rule:{__resolveType:$l}}]}}function nE(t){const e=t.__resolveType??"";if(!e)return null;if(Tt(e))return t.section??null;const s=Hr(t);return s?Tt(s.__resolveType??"")?s:{__resolveType:qc,section:Jf(s)}:{__resolveType:qc,section:t}}function sr(t){const e=t.__resolveType??"";if(!e)return null;if(Tt(e)){const s=t.section,i=s?.__resolveType??"";return!i||!s?null:{resolveType:i,data:s}}return{resolveType:e,data:t}}function rE(t){const e=Hr(t);if(e)return sr(e);if(Tt(t.__resolveType??"")){const i=t.section;if(!i)return null;const r=Hr(i);return sr(r||i)}return sr(t)}function oE(t){return Hr(t)}const d0=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function sc(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:d0.includes(e)||e.includes("always")}function h0(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>sc(i.rule));return s!==-1?s:e.length-1}function aE(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=h0(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function Zf(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function lE(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 cE(t,e){const s=t.__resolveType??"";if(!s)return null;if(Tt(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 u0(t,e){const s=t.__resolveType??"";return Tt(s)?{...t,section:e}:e}function f0(t,e,s){return e.isLazy?{...t,section:s}:s}function dE(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:u0(o,s)},{...t,variants:i}}function hE(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function uE(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function fE(t,e,s){const i=[...t.variants??[]];if(e===s||e<0||s<0||e>=i.length||s>=i.length)return t;const[r]=i.splice(e,1);return r?(i.splice(s,0,r),{...t,variants:i}):t}function mE(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function ba(t){return{rule:Li(),value:structuredClone(t)}}function Qf(t,e){return{...e,__resolveType:Yn,variants:t}}function pE(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function m0(t,e){if(e.isHidden)return null;if(e.isMultivariate){const i=Zf(t,e)?.variants??[],r=i[i.length-1]?.value;return r?structuredClone(r):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function p0(t,e,s){if(e.isMultivariate||e.isHidden)return null;const i=m0(t,e);if(!i)return null;const r=Qf([ba(i),ba(i)]);return e.isLazy?{...t,section:r}:r}function gE(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const r=Zf(t,e);if(!r)return null;const o=r.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=Qf([...o,ba(a)],r);return{section:f0(t,e,l),newVariantIndex:o.length}}const i=p0(t,e);return i?{section:i,newVariantIndex:1}:null}const g0=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function mo(t){return t.anyOfRefs?.some(e=>e.resolveType!==qi?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function Ur(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===qi}function _0(t){if(!Ur(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 v0(t,e){if(!Ur(t))return e;const s=structuredClone(t),i=[...s.variants??[]];return i.length===0?i.push({rule:Li(),value:e}):i[0]={...i[0],value:e},{...s,variants:i}}function x0(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&g0.has(e.__resolveType)&&typeof e.path=="string"}function em(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 tm(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 _E(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(d=>l0(d.rule,e,s)),a=o.reduce((d,c)=>(d[c]=(d[c]??0)+1,d),{}),l={};return r.map((d,c)=>{const h=o[c]??`Variant ${c+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(d.value)?d.value:[],rule:d.rule}})}}return[]}function rn(t){return{rule:Li(),value:t}}function Ai(t,e){return{...e,__resolveType:qi,variants:t}}function b0(t,e){const s=structuredClone(e);if(Array.isArray(t))return Ai([rn(t),rn(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Ai([...i.variants,rn(s)],i):null}return Ai([rn([]),rn(s)])}function vE(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function xE(t,e){if(e.length===0)return Ai([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!sc(i))return Ai(e,t);if(Array.isArray(s?.value))return s.value}return Ai(e,t)}function y0(t,e){for(const[s,i]of Object.entries(t)){if(!x0(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 bE(t,e,s){let i=0;return y0(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Ji(r,t,s)&&i++}),i}function sm(t){return btoa(encodeURIComponent(t))}function S0(t,e,s){const i=new URL(t).origin,r=new URL(`/live/previews/${encodeURIComponent(e)}`,i);return r.searchParams.set("path","/"),r.searchParams.set("pathTemplate","/"),r.searchParams.set("props",sm(JSON.stringify({path:"/",sections:[{__resolveType:s}]}))),r.searchParams.set("__cb",crypto.randomUUID()),r.toString()}function yE(t,e,s,i){const r=new URL(t).origin,o=new URL(`/live/previews/${encodeURIComponent(e)}`,r);o.searchParams.set("__d","");const a=[{__resolveType:"preview",block:s}];return i&&a.push(i),o.searchParams.set("props",sm(JSON.stringify({sections:a}))),o.toString()}const cd={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function ic(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function im(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:cd.seoResolveType},__resolveType:cd.resolveType}}const w0=700;function nc(t){const e=U.c(21),{orgSlug:s,virtualMcpId:i,branch:r}=t,o=oi();let a;e[0]!==r||e[1]!==s||e[2]!==i?(a=async u=>{const{blockKey:f,data:m}=u,p=wu(f),g=JSON.stringify(m,null,2),_=await fetch(`/api/${s}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(r)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:p,content:g})});if(!_.ok){const b=await _.json().catch(C0);throw new Error(b.error??`Write failed (${_.status})`)}return _.json()},e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r||e[5]!==s||e[6]!==o||e[7]!==i?(l=async u=>{const{blockKey:f,data:m}=u,p=`${s}/${i}/${r}`,g=Et.decofile(p);await o.cancelQueries({queryKey:g});const _=o.getQueryData(g);return o.setQueryData(g,b=>({...b??{},[f]:m})),{previous:_,queryKey:g}},e[4]=r,e[5]=s,e[6]=o,e[7]=i,e[8]=l):l=e[8];let d;e[9]!==o?(d=(u,f,m)=>{m?.queryKey&&o.setQueryData(m.queryKey,m.previous)},e[9]=o,e[10]=d):d=e[10];let c;e[11]!==r||e[12]!==s||e[13]!==o||e[14]!==i?(c=(u,f)=>{const{blockKey:m,data:p}=f,g=`${s}/${i}/${r}`;o.setQueryData(Et.decofile(g),_=>({..._??{},[m]:p}))},e[11]=r,e[12]=s,e[13]=o,e[14]=i,e[15]=c):c=e[15];let h;return e[16]!==a||e[17]!==l||e[18]!==d||e[19]!==c?(h={mutationFn:a,onMutate:l,onError:d,onSuccess:c},e[16]=a,e[17]=l,e[18]=d,e[19]=c,e[20]=h):h=e[20],ai(h)}function C0(){return{}}function k0(t,e){const s=U.c(15),i=nc(t);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,s[0]=r):r=s[0];const o=D.useRef(r);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=D.useRef(a);let d;s[2]!==e||s[3]!==i?(d=b=>{const x=o.current.get(b);if(!x)return;const v=typeof x=="function"?x():x;o.current.delete(b),v&&i.mutate({blockKey:b,data:v},{onSuccess:()=>e?.onSaved?.(),onError:j0})},s[2]=e,s[3]=i,s[4]=d):d=s[4];const c=d;let h;s[5]!==c?(h=()=>{for(const b of l.current.values())clearTimeout(b);l.current.clear();for(const b of[...o.current.keys()])c(b)},s[5]=c,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const b=l.current;return()=>{for(const x of b.values())clearTimeout(x)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),D.useEffect(f,m);let p;s[9]!==c?(p=(b,x)=>{o.current.set(b,x);const v=l.current.get(b);v&&clearTimeout(v),l.current.set(b,setTimeout(()=>{l.current.delete(b),c(b)},w0))},s[9]=c,s[10]=p):p=s[10];const g=p;let _;return s[11]!==u||s[12]!==g||s[13]!==i.isPending?(_={save:g,flush:u,isPending:i.isPending},s[11]=u,s[12]=g,s[13]=i.isPending,s[14]=_):_=s[14],_}function j0(t){return he.error(`Save failed: ${t.message}`)}function N0(t){const e=U.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const i=nc(s);let r;return e[2]!==t||e[3]!==i?(r={mutationFn:async o=>{const{name:a,path:l}=o;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const d=ic(a),c=im(a,l);return await i.mutateAsync({blockKey:d,data:c}),{key:d,name:a,path:l}}},e[2]=t,e[3]=i,e[4]=r):r=e[4],ai(r)}function E0(t){const e=U.c(50),{open:s,onOpenChange:i,isPending:r,error:o,onSubmit:a}=t,l=r===void 0?!1:r,[d,c]=D.useState("My New Page"),[h,u]=D.useState("/example-path"),[f,m]=D.useState(null),[p,g]=D.useState(s);s!==p&&(g(s),s&&(c("My New Page"),u("/example-path"),m(null)));let _;e[0]!==l||e[1]!==i?(_=z=>{!z&&!l&&(m(null),i(!1))},e[0]=l,e[1]=i,e[2]=_):_=e[2];const b=_;let x;e[3]!==l||e[4]!==d||e[5]!==a||e[6]!==h?(x=async z=>{z.preventDefault();const W=d.trim(),q=h.trim();if(!W||!q||l)return;const K=Hl(q);if(K){m(K);return}m(null),await a({name:W,path:q})},e[3]=l,e[4]=d,e[5]=a,e[6]=h,e[7]=x):x=e[7];const v=x,y=f??o;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(ts,{children:n.jsx(ss,{children:"Create new page"})}),e[8]=S):S=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[9]=w):w=e[9];let C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=z=>c(z.target.value),e[10]=C):C=e[10];let N;e[11]!==l||e[12]!==d?(N=n.jsxs("div",{className:"space-y-1.5",children:[w,n.jsx(ze,{id:"new-page-name",value:d,onChange:C,placeholder:"My New Page",autoFocus:!0,disabled:l})]}),e[11]=l,e[12]=d,e[13]=N):N=e[13];let E;e[14]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[14]=E):E=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=z=>u(z.target.value),e[15]=R):R=e[15];let T;e[16]!==l||e[17]!==h?(T=n.jsxs("div",{className:"space-y-1.5",children:[E,n.jsx(ze,{id:"new-page-path",value:h,onChange:R,placeholder:"/example-path",disabled:l})]}),e[16]=l,e[17]=h,e[18]=T):T=e[18];let k;e[19]!==y?(k=y&&n.jsx("p",{className:"text-xs text-destructive",children:y}),e[19]=y,e[20]=k):k=e[20];let j;e[21]!==T||e[22]!==k||e[23]!==N?(j=n.jsxs("div",{className:"space-y-4 py-4",children:[N,T,k]}),e[21]=T,e[22]=k,e[23]=N,e[24]=j):j=e[24];let I;e[25]!==i?(I=()=>i(!1),e[25]=i,e[26]=I):I=e[26];let A;e[27]!==l||e[28]!==I?(A=n.jsx(ie,{type:"button",variant:"outline",onClick:I,disabled:l,children:"Cancel"}),e[27]=l,e[28]=I,e[29]=A):A=e[29];let O;e[30]!==l||e[31]!==d||e[32]!==h?(O=!d.trim()||!h.trim()||l,e[30]=l,e[31]=d,e[32]=h,e[33]=O):O=e[33];let L;e[34]!==l?(L=l?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Creating…"]}):"Create",e[34]=l,e[35]=L):L=e[35];let P;e[36]!==O||e[37]!==L?(P=n.jsx(ie,{type:"submit",disabled:O,children:L}),e[36]=O,e[37]=L,e[38]=P):P=e[38];let B;e[39]!==A||e[40]!==P?(B=n.jsxs(Ws,{children:[A,P]}),e[39]=A,e[40]=P,e[41]=B):B=e[41];let F;e[42]!==v||e[43]!==j||e[44]!==B?(F=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:v,children:[S,j,B]})}),e[42]=v,e[43]=j,e[44]=B,e[45]=F):F=e[45];let H;return e[46]!==b||e[47]!==s||e[48]!==F?(H=n.jsx(Bt,{open:s,onOpenChange:b,children:F}),e[46]=b,e[47]=s,e[48]=F,e[49]=H):H=e[49],H}const T0=pr({tag:ns(),id:ns(),classes:ns(),text:ns(),html:ns(),manifestKey:ns().nullable(),componentName:ns().nullable(),parents:ns(),url:ns(),path:ns(),viewport:pr({width:pn(),height:pn()}),position:pr({x:pn(),y:pn()})}),A0=`(function() {
38
- if (window.__visualEditorActive) return;
39
- window.__visualEditorActive = true;
40
-
41
- var cursorStyle = document.createElement("style");
42
- cursorStyle.textContent = "* { cursor: default !important; }";
43
- document.head.appendChild(cursorStyle);
44
-
45
- var highlight = document.createElement("div");
46
- highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
47
- document.body.appendChild(highlight);
48
-
49
- var badge = document.createElement("div");
50
- badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
51
- document.body.appendChild(badge);
52
-
53
- var lastTarget = null;
54
- var rafPending = false;
55
- var moveHandler = function(e) {
56
- if (rafPending) return;
57
- rafPending = true;
58
- var target = e.target;
59
- requestAnimationFrame(function() {
60
- rafPending = false;
61
- var el = target;
62
- if (!el || el === highlight || el === badge) return;
63
- if (el === lastTarget) return;
64
- lastTarget = el;
65
- var r = el.getBoundingClientRect();
66
- highlight.style.display = "block";
67
- highlight.style.top = r.top + "px";
68
- highlight.style.left = r.left + "px";
69
- highlight.style.width = r.width + "px";
70
- highlight.style.height = r.height + "px";
71
- var tag = el.tagName.toLowerCase();
72
- var id = el.id ? "#" + el.id : "";
73
- var cls = el.className && typeof el.className === "string"
74
- ? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
75
- : "";
76
- badge.textContent = tag + id + cls;
77
- badge.style.display = "block";
78
- badge.style.top = Math.max(0, r.top - 20) + "px";
79
- badge.style.left = r.left + "px";
80
- });
81
- };
82
- document.addEventListener("mousemove", moveHandler, true);
83
-
84
- var outHandler = function(e) {
85
- if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
86
- highlight.style.display = "none";
87
- badge.style.display = "none";
88
- lastTarget = null;
89
- }
90
- };
91
- document.addEventListener("mouseout", outHandler, true);
92
-
93
- var clickHandler = function(e) {
94
- e.preventDefault();
95
- e.stopImmediatePropagation();
96
- var el = e.target;
97
- if (!el || el === highlight || el === badge) return;
98
-
99
- highlight.style.outline = "2px solid #a855f7";
100
- highlight.style.background = "rgba(168,85,247,0.15)";
101
- setTimeout(function() {
102
- highlight.style.outline = "2px solid #a855f7";
103
- highlight.style.background = "rgba(168,85,247,0.08)";
104
- }, 400);
105
-
106
- var tag = el.tagName.toLowerCase();
107
- var id = el.id || "";
108
- var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
109
- var text = (el.textContent || "").trim().slice(0, 200);
110
- var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");
111
-
112
- var closestSection = el.closest("section[data-manifest-key]");
113
- var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;
114
-
115
- var ancestor = el;
116
- var componentName = null;
117
- for (var i = 0; i < 10 && ancestor; i++) {
118
- if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
119
- ancestor = ancestor.parentElement;
120
- }
121
-
122
- var parents = [];
123
- var p = el.parentElement;
124
- for (var j = 0; j < 4 && p && p !== document.body; j++) {
125
- var pTag = p.tagName ? p.tagName.toLowerCase() : "";
126
- var pId = p.id ? "#" + p.id : "";
127
- var pCls = p.className && typeof p.className === "string"
128
- ? "." + p.className.trim().split(/\\s+/)[0]
129
- : "";
130
- parents.unshift(pTag + pId + pCls);
131
- p = p.parentElement;
132
- }
133
-
134
- window.parent.postMessage({
135
- type: "visual-editor::element-clicked",
136
- payload: {
137
- tag: tag, id: id, classes: classes, text: text, html: html,
138
- manifestKey: manifestKey, componentName: componentName,
139
- parents: parents.join(" > "),
140
- url: window.location.href, path: window.location.pathname,
141
- viewport: { width: window.innerWidth, height: window.innerHeight },
142
- position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
143
- }
144
- }, "*");
145
- };
146
- document.addEventListener("click", clickHandler, true);
147
-
148
- window.addEventListener("message", function(e) {
149
- if (e.data && e.data.type === "visual-editor::deactivate") {
150
- highlight.remove();
151
- badge.remove();
152
- cursorStyle.remove();
153
- document.removeEventListener("mousemove", moveHandler, true);
154
- document.removeEventListener("mouseout", outHandler, true);
155
- document.removeEventListener("click", clickHandler, true);
156
- window.__visualEditorActive = false;
157
- }
158
- });
159
- })();`,R0=pr({sectionIndex:pn(),manifestKey:ns()}),P0=`(function() {
160
- if (window.__cmsEditorActive) return;
161
- window.__cmsEditorActive = true;
162
-
163
- // Preserve scroll across variant-override navigations and save-reloads.
164
- // Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
165
- // or reloads it, which would otherwise jump to the top. We persist the scroll
166
- // offset to sessionStorage (survives reload, same-origin) keyed by pathname
167
- // (the override only changes the query, so the key is stable), then restore it
168
- // on the next load — retried for ~1s so it outlasts re-hydration and lazy
169
- // sections that grow the page after load. The recency guard avoids restoring a
170
- // stale offset on a genuinely fresh visit.
171
- var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
172
- var saveScroll = function() {
173
- try {
174
- sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
175
- x: window.scrollX, y: window.scrollY, t: Date.now()
176
- }));
177
- } catch (_) {}
178
- };
179
- var saveScrollPending = false;
180
- window.addEventListener("scroll", function() {
181
- if (saveScrollPending) return;
182
- saveScrollPending = true;
183
- requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
184
- }, { passive: true });
185
- (function restoreScroll() {
186
- var raw = null;
187
- try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
188
- if (!raw) return;
189
- var saved = null;
190
- try { saved = JSON.parse(raw); } catch (_) { return; }
191
- if (!saved || (Date.now() - saved.t) > 10000) return;
192
- if (!saved.x && !saved.y) return;
193
- var attempts = 0;
194
- var apply = function() {
195
- attempts++;
196
- window.scrollTo(saved.x || 0, saved.y || 0);
197
- if (attempts < 8) setTimeout(apply, 120);
198
- };
199
- apply();
200
- })();
201
-
202
- var highlight = document.createElement("div");
203
- highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
204
- document.body.appendChild(highlight);
205
-
206
- var badge = document.createElement("div");
207
- badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
208
- document.body.appendChild(badge);
209
-
210
- var isTopLevelSection = function(el) {
211
- return el && el.parentElement
212
- ? !el.parentElement.closest("section[data-manifest-key]")
213
- : true;
214
- };
215
-
216
- // All top-level page sections in DOM order (deco renders page sections as
217
- // <section data-manifest-key>; nested islands/sections carry the attribute
218
- // too, hence the top-level filter). This is the full DOM run, framework
219
- // sections included — getAllSections() narrows it to the editable window.
220
- var topLevelSections = function() {
221
- return Array.from(document.querySelectorAll("section[data-manifest-key]"))
222
- .filter(isTopLevelSection);
223
- };
224
-
225
- // Candidate manifest keys per editable section, sent by the editor. Each
226
- // entry is an array of acceptable DOM keys: [] = wildcard (e.g. multivariate,
227
- // whose rendered key we can't predict); a Lazy lists both its loader key and
228
- // the inner section's key, since the classic runtime keeps the Lazy wrapper
229
- // at top level while TanStack renders the inner section directly.
230
- var sectionCandidates = [];
231
-
232
- // Best in-order assignment of editable sections to DOM sections, maximizing
233
- // key matches (DP / LCS-style). deco injects framework sections (SEO, Theme,
234
- // Session, …) that may lead, trail, OR interleave with the editable run; this
235
- // skips whichever don't match, on any runtime — no hardcoded list.
236
- var computeAlignment = function(tops) {
237
- var N = sectionCandidates.length, M = tops.length;
238
- if (!N || M < N) return tops.slice();
239
- var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
240
- var match = function(i, j) {
241
- var c = sectionCandidates[i];
242
- if (!c || !c.length) return 1;
243
- return c.indexOf(domKeys[j]) >= 0 ? 1 : 0;
244
- };
245
- var dp = [], bt = [], i, j;
246
- for (i = 0; i <= N; i++) { dp.push(new Array(M + 1).fill(0)); bt.push(new Array(M + 1).fill(0)); }
247
- for (i = 1; i <= N; i++) {
248
- for (j = i; j <= M; j++) {
249
- var assign = dp[i - 1][j - 1] + match(i - 1, j - 1);
250
- var skip = dp[i][j - 1];
251
- if (j - 1 >= i && skip >= assign) { dp[i][j] = skip; bt[i][j] = 0; }
252
- else { dp[i][j] = assign; bt[i][j] = 1; }
253
- }
254
- }
255
- var res = new Array(N);
256
- i = N; j = M;
257
- while (i > 0) {
258
- if (bt[i][j] === 1) { res[i - 1] = tops[j - 1]; i--; j--; }
259
- else { j--; }
260
- }
261
- return res;
262
- };
263
-
264
- // Editable sections, indexed to match the decofile array the panel uses.
265
- // Recomputed from the live DOM each call (cheap, rAF-throttled) so it
266
- // self-heals as client-rendered/lazy sections mount. Until the editor sends
267
- // candidates, fall back to the full top-level run.
268
- var getAllSections = function() {
269
- var tops = topLevelSections();
270
- return sectionCandidates.length ? computeAlignment(tops) : tops;
271
- };
272
-
273
- // Resolve to the OUTERMOST page-level section (clicking nested content still
274
- // maps to the top-level section the panel indexes); null if it isn't in the
275
- // aligned editable set (a framework section deco injected).
276
- var findSection = function(el) {
277
- var node = el;
278
- var found = null;
279
- while (node && node !== document.body) {
280
- if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
281
- found = node;
282
- }
283
- node = node.parentElement;
284
- }
285
- if (!found) return null;
286
- return getAllSections().indexOf(found) >= 0 ? found : null;
287
- };
288
-
289
- // Lazy sections async-render their real section inside a wrapper, so the
290
- // wrapper's key is just the loader. Show the inner section's key instead
291
- // (falling back to the wrapper while the content hasn't loaded yet).
292
- var LAZY_KEY = "website/sections/Rendering/Lazy.tsx";
293
- var displayKey = function(section) {
294
- var key = section.getAttribute("data-manifest-key") || "section";
295
- if (key === LAZY_KEY) {
296
- var inner = section.querySelector("section[data-manifest-key]");
297
- if (inner) return inner.getAttribute("data-manifest-key") || key;
298
- }
299
- return key;
300
- };
301
-
302
- // Per-section metadata sent by the editor, aligned by index with
303
- // getAllSections(). labels: names the DOM can't carry (a global section or a
304
- // global inside async rendering); kinds: section type that drives the color.
305
- var sectionLabels = [];
306
- var sectionKinds = [];
307
- var labelFor = function(section) {
308
- var idx = getAllSections().indexOf(section);
309
- if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
310
- return displayKey(section);
311
- };
312
- var kindFor = function(section) {
313
- var idx = getAllSections().indexOf(section);
314
- return (idx >= 0 && sectionKinds[idx]) || "normal";
315
- };
316
-
317
- // Highlight palette by section kind: global = light purple, variant = green,
318
- // normal = blue.
319
- var COLORS = {
320
- normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
321
- global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
322
- variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
323
- };
324
- var applyColor = function(kind) {
325
- var c = COLORS[kind] || COLORS.normal;
326
- highlight.style.outline = "2px solid " + c.solid;
327
- highlight.style.background = c.bg;
328
- badge.style.background = c.solid;
329
- };
330
-
331
- var lastSection = null;
332
- var lastLabel = "";
333
- var lastKind = "normal";
334
- var rafPending = false;
335
-
336
- // Document-relative coordinates (rect + scroll) on absolutely-positioned
337
- // nodes, so the browser scrolls the highlight together with the page
338
- // natively — no per-frame JS repositioning, no scroll lag.
339
- var positionHighlight = function(section) {
340
- var r = section.getBoundingClientRect();
341
- var top = r.top + window.scrollY;
342
- var left = r.left + window.scrollX;
343
- highlight.style.display = "block";
344
- highlight.style.top = top + "px";
345
- highlight.style.left = left + "px";
346
- highlight.style.width = r.width + "px";
347
- highlight.style.height = r.height + "px";
348
- badge.textContent = lastLabel || displayKey(section);
349
- badge.style.display = "block";
350
- badge.style.top = Math.max(0, top - 20) + "px";
351
- badge.style.left = left + "px";
352
- };
353
-
354
- var moveHandler = function(e) {
355
- if (rafPending) return;
356
- rafPending = true;
357
- var target = e.target;
358
- requestAnimationFrame(function() {
359
- rafPending = false;
360
- if (!target || target === highlight || target === badge) return;
361
- var section = findSection(target);
362
- if (section === lastSection) return;
363
- lastSection = section;
364
- if (!section) {
365
- highlight.style.display = "none";
366
- badge.style.display = "none";
367
- return;
368
- }
369
- lastLabel = labelFor(section);
370
- lastKind = kindFor(section);
371
- applyColor(lastKind);
372
- positionHighlight(section);
373
- });
374
- };
375
- document.addEventListener("mousemove", moveHandler, true);
376
-
377
- // Window scroll is handled natively by the absolute positioning above; this
378
- // only re-syncs on resize and on scrolls inside nested scroll containers
379
- // (capture=true catches those), where document coordinates do shift.
380
- var reposition = function() {
381
- if (!lastSection || highlight.style.display === "none") return;
382
- if (rafPending) return;
383
- rafPending = true;
384
- requestAnimationFrame(function() {
385
- rafPending = false;
386
- if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
387
- });
388
- };
389
- window.addEventListener("scroll", reposition, { capture: true, passive: true });
390
- window.addEventListener("resize", reposition, { passive: true });
391
-
392
- var outHandler = function(e) {
393
- if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
394
- highlight.style.display = "none";
395
- badge.style.display = "none";
396
- lastSection = null;
397
- }
398
- };
399
- document.addEventListener("mouseout", outHandler, true);
400
-
401
- var clickHandler = function(e) {
402
- e.preventDefault();
403
- e.stopImmediatePropagation();
404
- var target = e.target;
405
- if (!target || target === highlight || target === badge) return;
406
- var section = findSection(target);
407
- if (!section) return;
408
-
409
- var sections = getAllSections();
410
- var sectionIndex = sections.indexOf(section);
411
- var manifestKey = section.getAttribute("data-manifest-key") || "";
412
-
413
- var c = COLORS[lastKind] || COLORS.normal;
414
- highlight.style.outline = "2px solid " + c.solid;
415
- highlight.style.background = c.active;
416
- setTimeout(function() {
417
- highlight.style.background = c.bg;
418
- }, 400);
419
-
420
- window.parent.postMessage({
421
- type: "cms-editor::section-clicked",
422
- payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
423
- }, "*");
424
- };
425
- document.addEventListener("click", clickHandler, true);
426
-
427
- window.addEventListener("message", function(e) {
428
- if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
429
- sectionLabels = e.data.labels;
430
- if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
431
- if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
432
- if (lastSection) {
433
- lastLabel = labelFor(lastSection);
434
- lastKind = kindFor(lastSection);
435
- applyColor(lastKind);
436
- if (highlight.style.display !== "none") positionHighlight(lastSection);
437
- }
438
- return;
439
- }
440
- if (e.data && e.data.type === "cms-editor::deactivate") {
441
- highlight.remove();
442
- badge.remove();
443
- document.removeEventListener("mousemove", moveHandler, true);
444
- document.removeEventListener("mouseout", outHandler, true);
445
- document.removeEventListener("click", clickHandler, true);
446
- window.removeEventListener("scroll", reposition, { capture: true });
447
- window.removeEventListener("resize", reposition);
448
- window.__cmsEditorActive = false;
449
- }
450
- });
451
- })();`;function vi(t){return t.replace(/[`*_]/g,"\\$&")}function D0(t,e){const s=[`The user selected an element on the live preview and asked: **"${vi(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section source file:** \`${vi(t.manifestKey)}\``,"");const i=`<${t.tag}${t.classes?` class="${vi(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${i}\``),t.parents&&s.push(`**DOM breadcrumb:** ${vi(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${vi(t.text)}"`),t.componentName&&s.push(`**Component name:** ${vi(t.componentName)}`);const r=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",r,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
452
- `)}function I0(t,e,s=320,i=44,r=12){const{x:o,y:a}=t,{width:l,height:d}=e,c=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/d>.68?Math.max(r,a-i-18):Math.min(a+18,d-i-r);return{leftPct:c/l*100,topPct:u/d*100}}function L0(t){const e=U.c(32),{element:s,onDismiss:i}=t,[r,o]=D.useState(""),a=D.useRef(null),{sendMessage:l}=li(),{setChatOpen:d}=fl();let c;e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==d?(c=()=>{if(!r.trim())return;const R=D0(s,r);d(!0),l({parts:[{type:"text",text:R}]}),i()},e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=d,e[5]=c):c=e[5];const h=c;let u;e[6]!==s.position||e[7]!==s.viewport?(u=I0(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let _;e[12]!==h?(_=R=>{R.preventDefault(),h()},e[12]=h,e[13]=_):_=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=R=>o(R.target.value),e[14]=b):b=e[14];let x;e[15]!==i?(x=R=>{R.key==="Escape"&&i()},e[15]=i,e[16]=x):x=e[16];let v;e[17]!==r||e[18]!==x?(v=n.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:b,onKeyDown:x,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=x,e[19]=v):v=e[19];let y;e[20]!==r?(y=r.trim(),e[20]=r,e[21]=y):y=e[21];const S=!y;let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[n.jsx("title",{children:"Send"}),n.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=w):w=e[22];let C;e[23]!==S?(C=n.jsx("button",{type:"submit",disabled:S,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:w}),e[23]=S,e[24]=C):C=e[24];let N;e[25]!==C||e[26]!==_||e[27]!==v?(N=n.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:_,children:[v,C]}),e[25]=C,e[26]=_,e[27]=v,e[28]=N):N=e[28];let E;return e[29]!==N||e[30]!==g?(E=n.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:N}),e[29]=N,e[30]=g,e[31]=E):E=e[31],E}const nm={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},O0=["provision","cloning","install","dev"];function rm(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function B0(t){switch(t){case"starting":return"Starting your sandbox";case"suspended":return"Sandbox is paused"}}function M0(t){return O0.indexOf(t.step)}const dd=48,om=28,am=3,$0=(()=>{const t=[];let e=0;for(let s=0;s<dd;s++)s===om?t.push(null):(t.push(e/(dd-1)*am),e++);return t})(),z0={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function F0(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?nm[e.kind].long:z0[t.step]}const ms="bg-foreground/[0.05]",Xt="bg-foreground/[0.09]",H0=Array.from({length:35},()=>Math.random()*1.8),U0=Array.from({length:35},()=>Math.random()<.4);function W0(t){const e=U.c(30),{progress:s,claimPhase:i}=t;let r;e[0]!==s?(r=M0(s),e[0]=s,e[1]=r):r=e[1];const o=r;let a;e[2]!==i||e[3]!==s?(a=F0(s,i),e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(jg,{}),e[5]=d):d=e[5];const c=`${s.step}-${l}`;let h;e[6]!==l||e[7]!==c?(h=n.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[d,n.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},c)]}),e[6]=l,e[7]=c,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(V0,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=n.jsx(ir,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(q0,{}),e[12]=m):m=e[12];let p;e[13]!==o?(p=n.jsx(ir,{phase:1,current:o,children:m}),e[13]=o,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(G0,{}),e[15]=g):g=e[15];let _;e[16]!==o?(_=n.jsx(ir,{phase:2,current:o,children:g}),e[16]=o,e[17]=_):_=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(X0,{}),e[18]=b):b=e[18];let x;e[19]!==o?(x=n.jsx(ir,{phase:3,current:o,children:b}),e[19]=o,e[20]=x):x=e[20];let v;e[21]!==_||e[22]!==x||e[23]!==f||e[24]!==p?(v=n.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,p,_,x]}),e[21]=_,e[22]=x,e[23]=f,e[24]=p,e[25]=v):v=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("style",{children:`
453
- @keyframes vm-pulse-soft {
454
- 0%, 100% { opacity: 0.25; }
455
- 50% { opacity: 1; }
456
- }
457
- @keyframes vm-breathe {
458
- 0%, 100% { opacity: 0.5; }
459
- 50% { opacity: 1; }
460
- }
461
- @keyframes vm-rack-scan {
462
- 0%, 100% { opacity: 0; }
463
- 8% { opacity: 1; }
464
- 22% { opacity: 0; }
465
- }
466
- `}),e[26]=y):y=e[26];let S;return e[27]!==v||e[28]!==h?(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:[h,v,y]}),e[27]=v,e[28]=h,e[29]=S):S=e[29],S}function ir(t){const e=U.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,d=a?90:o*-22,c=a?.94:1-Math.max(o,0)*.04,h=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=ae("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(${d}px) scale(${c})`,g=l?"auto":"none";let _;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(_={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=_):_=e[5];let b;return e[6]!==r||e[7]!==f||e[8]!==_?(b=n.jsx("div",{"aria-hidden":f,className:m,style:_,children:r}),e[6]=r,e[7]=f,e[8]=_,e[9]=b):b=e[9],b}function po(t){const e=U.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:ae("size-2.5 rounded-full",Xt)}),o=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),a=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),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:ae("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",ms)}),e[3]=i,e[4]=l):l=e[4];let d;return e[5]!==l?(d=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]=d):d=e[6],d}function V0(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),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:$0.map(K0)})})]}),t[1]=s):s=t[1],s}function K0(t,e){if(e===om)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:ae("relative rounded-md",Xt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${am}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function q0(){const t=U.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:ae("w-[18%] rounded-md",ms),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:ae("rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:ae("rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function G0(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),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:H0.map(Y0)})})]}),t[1]=s):s=t[1],s}function Y0(t,e){return n.jsx("div",{className:ae("aspect-square rounded-md",U0[e]?"bg-chart-2/70":Xt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function X0(){const t=U.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{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:ae("h-1.5 w-[70%] rounded-sm",Xt)}),r=n.jsx("div",{className:ae("h-1.5 w-[55%] rounded-sm",Xt)}),o=n.jsx("div",{className:ae("h-1.5 w-[80%] rounded-sm",Xt)}),a=n.jsx("div",{className:ae("h-1.5 w-[50%] rounded-sm",Xt)}),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:ae("h-4 rounded-md",Xt)})})]}),t[6]=l):l=t[6];let d;t[7]===Symbol.for("react.memo_cache_sentinel")?(d=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:ae("h-1.5 w-[55%] rounded-sm",ms)})]})}),t[7]=d):d=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:ae("h-4 w-10 rounded-full",ms)}),n.jsx("div",{className:ae("h-4 w-14 rounded-full",ms)})]}),t[8]=c):c=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:ae("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",ms),children:[n.jsx("div",{className:ae("h-1.5 w-[50%] rounded-sm",Xt)}),n.jsx("div",{className:ae("h-1 w-[75%] rounded-sm",Xt)})]}),t[9]=h):h=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:[d,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:[h,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:ae("rounded-md",ms)}),n.jsx("div",{className:ae("rounded-md",ms)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Wr(t){const e=U.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(W0,{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(T_,{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:B0("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(Di,{className:"size-4"}),e[6]=o):o=e[6];let a;return e[7]!==t.onResume?(a=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}function J0(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==i?(l=Et.sandboxRepoDir(s,i,r),e[0]=r,e[1]=s,e[2]=i,e[3]=l):l=e[3];let d;e[4]!==r||e[5]!==s||e[6]!==i?(d=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=i,e[7]=d):d=e[7];let c;return e[8]!==a||e[9]!==l||e[10]!==d?(c={queryKey:l,queryFn:d,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=d,e[11]=c):c=e[11],Es(c).data??null}const hd="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",ud="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",Z0=D.lazy(()=>ls(()=>import("./sections-editor-C33mQAPq.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])).then(t=>({default:t.SectionsEditor}))),Q0=D.lazy(()=>ls(()=>import("./page-seo-sheet-Cb5cCBSA.js"),__vite__mapDeps([141,1,2,70,42,44,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,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,71,72,73,74,75,76,77,78,97,98,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,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])).then(t=>({default:t.SeoSheet}))),e2=D.lazy(()=>ls(()=>import("./file-explorer-BfDoSrZk.js"),__vite__mapDeps([142,1,2,117,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,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,122,143,116,106,79,109,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,107,108,110,111,112,113,114,115,118,119,120,121,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.FileExplorer}))),Do=500,t2={mobile:375,tablet:768,desktop:null},Io=["desktop","mobile","tablet"],s2={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"},i2="website/sections/Rendering/Lazy.tsx";function ya(t,e){let s=t,i=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let r=0;i&&r<5;r++){const o=e[i];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==i){s=o,i=a;continue}}break}if(!i)return[];if(i.includes("flags/multivariate")){const r=Array.isArray(s.variants)?s.variants:[],o=[];for(const a of r){const l=a?.value;if(l&&typeof l=="object")for(const d of ya(l,e))o.includes(d)||o.push(d)}return o}if(i===i2){const r=s.section&&typeof s.section=="object"?ya(s.section,e):[];return r.length?[i,...r]:[i]}return[i]}function n2(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function r2(){const t=gi(),{currentBranch:e}=Ts(),[s,i]=D.useState("preview"),[r,o]=D.useState("desktop"),[a,l]=D.useState(null),d=D.useRef(null),c=s==="cms",[h,u]=D.useState(null),[f,m]=D.useState(null),[p,g]=D.useState(384),_=D.useRef(!1),b=D.useRef(0),x=D.useRef(0),v=D.useRef(null),[y,S]=D.useState(!1),[w,C]=D.useState(""),N=D.useRef(null),[E,R]=D.useState(!1),[T,k]=D.useState(),[j,I]=D.useState(null),[A,O]=D.useState(null),[L,P]=D.useState("/"),[B,F]=D.useState(null),[H,z]=D.useState(!1),[W,q]=D.useState(!1),[K,Z]=D.useState(null),Y=t?.entity?.id??null,{org:G}=Me(),Q=bs(),$=Gl(),X=$.vmEntry,V=$.previewUrl,se=Q.lifecycle.phase,ee=se==="running",le=X?.sandboxProviderKind==="user-desktop",ce=J0({orgSlug:G.slug,virtualMcpId:Y??"",branch:e??"",enabled:le&&ee&&!!Y&&!!e}),fe=le?ce:null,J=Y&&e&&ee?{orgSlug:G.slug,virtualMcpId:Y,branch:e,previewUrl:V}:null,{data:te}=Ol(J,{fetchEnabled:ee}),{data:oe}=Bl(J,{fetchEnabled:ee}),de=Y&&e?{orgSlug:G.slug,virtualMcpId:Y,branch:e}:null,be=N0(de),ve=te?Vl(te).sort((ne,je)=>ne.name.localeCompare(je.name)):[],we=te&&oe?ql(te,oe):[],De=Ti,Be=ve.filter(ne=>{if(!w)return!0;const je=w.toLowerCase();return ne.name.toLowerCase().includes(je)||ne.path.toLowerCase().includes(je)}),Pe=we.filter(ne=>{if(!w)return!0;const je=w.toLowerCase();return ne.name.toLowerCase().includes(je)||ne.key.toLowerCase().includes(je)||ne.resolveType.toLowerCase().includes(je)}),Fe=j?null:ix(ve,L,B),xe=j?j.name:Fe?.name,ye=Fe?.key??null,Ie=te&&ye?tm(te,ye,0):[],Le=te?Xf(Ie,te):[],qe=Le.map(ne=>ne.isSavedBlock?ne.label:""),st=Le.map(ne=>ne.isSavedBlock?"global":ne.isMultivariate?"variant":"normal"),ct=Ie.map(ne=>ya(ne,te??{})),Se=D.useRef(null),pe=D.useRef(null);mx(()=>{const ne=d.current,je=Se.current;!ne||!je||(ne.src=je)});const $e=Q.status.state==="paused",Ge=Q.phase,He=rm({claimPhase:Ge,lifecycle:Q.lifecycle}),Ye=$.previewState,M=$.userStopped,ue=Ye.kind==="starting"||Ye.kind==="iframe"&&He.status==="doing",ge=Ye.kind==="iframe"?c0(n2(A??new URL(L,Ye.previewUrl).href,r),c&&f?f:[]):null,[ke,Je]=D.useState(null);if(Ye.kind==="iframe"&&ke!==Ye.previewUrl){const ne=ke!==null;Je(Ye.previewUrl),ne&&(pe.current=null,P("/"),O(null),F(null),I(null))}Se.current=ge;const mt=!!Y&&!!e&&!Q.notFound&&!M&&!$e&&(Ge?.kind==="ready"||se!=="idle"),Vs=Ye.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;D.useEffect(()=>{if(!V)return;let ne;try{ne=new URL(V,window.location.href).origin}catch{return}const je=bt=>{if(bt.origin===ne){if(bt.data?.type==="visual-editor::element-clicked"){const yt=T0.safeParse(bt.data.payload);yt.success&&l(yt.data)}else if(bt.data?.type==="cms-editor::section-clicked"){const yt=R0.safeParse(bt.data.payload);yt.success&&u(yt.data.sectionIndex)}}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[V]),D.useEffect(()=>{if(!y)return;const ne=je=>{N.current?.contains(je.target)||(S(!1),C(""))};return document.addEventListener("pointerdown",ne),()=>document.removeEventListener("pointerdown",ne)},[y]),D.useEffect(()=>{if(!c)return;const ne=bt=>{const yt=bt.target;yt&&yt!==d.current&&(v.current=yt)},je=()=>{requestAnimationFrame(()=>{const bt=document.activeElement;(bt===document.body||bt===d.current)&&v.current&&v.current.focus()})};return document.addEventListener("focusin",ne),document.addEventListener("blur",je,!0),()=>{document.removeEventListener("focusin",ne),document.removeEventListener("blur",je,!0)}},[c]);const tn=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::activate",script:A0},"*")},Ip=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::deactivate"},"*")},Nc=()=>{const ne=d.current?.contentWindow;ne&&(ne.postMessage({type:"visual-editor::activate",script:P0},"*"),ne.postMessage({type:"cms-editor::set-labels",labels:qe,kinds:st,keys:ct},"*"))},Lp=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"cms-editor::deactivate"},"*")},sn=ne=>{const je=s;i(ne),l(null),ne!=="code"&&Z(null),ne!=="cms"&&(u(null),m(null)),je==="visual"&&Ip(),je==="cms"&&Lp(),ne==="visual"&&tn(),ne==="cms"&&Nc()},Op=()=>{if(!d.current||!ge)return;const ne=d.current;ne.src=ge},Bp=ne=>{m(ne)},Mp=()=>{const ne=d.current;if(!ne)return;const je=document.activeElement,bt=ne.tabIndex;ne.tabIndex=-1,ne.style.pointerEvents="none",ne.blur();try{ne.contentWindow?.location.reload()}catch{const is=Se.current;is&&(ne.src=is)}const yt=()=>{ne.tabIndex=bt,ne.style.pointerEvents="",je?.focus(),ne.removeEventListener("load",yt)};ne.addEventListener("load",yt),setTimeout(yt,3e3)},$p=()=>{if(!d.current||!ge)return;const ne=ge.includes("?")?"&":"?";d.current.src=`${ge}${ne}_r=${Date.now()}`},zp=()=>{const ne=Io.indexOf(r);o(Io[(ne+1)%Io.length])},Fp=()=>{const ne=d.current?.contentWindow?.location?.href??ge??V;ne&&navigator.clipboard.writeText(ne)},Hp=(()=>{if(!V)return"No server running";if(j)return j.name;try{const ne=new URL(V),je=L==="/"?"":L;return`${ne.host}${je}`}catch{return V}})(),Ec=ne=>{pe.current=ne.path,I(null),O(null),F(ne.key),P(ne.path),u(null),z(!1)},Up=ne=>{if(!V||!oe){he.error("Preview metadata not ready yet");return}pe.current=null;const je=_f(oe),bt=S0(V,je,ne.key);I(ne),O(bt),u(null)},Wp=async({name:ne,path:je})=>{if(!Y||!e)return;const bt=Hl(je);if(bt){k(bt);return}const yt=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(ve.some(is=>De(is.path)===De(yt))){k(`A page with path "${yt}" already exists.`);return}k(void 0);try{const is=await be.mutateAsync({name:ne,path:yt});R(!1),he.success(`Page "${ne}" created`),await new Promise(Kp=>setTimeout(Kp,Do)),Ec({key:is.key,name:is.name,path:is.path}),sn("cms")}catch(is){k(is instanceof Error?is.message:"Failed to create page")}},Vp=[{value:"preview",icon:n.jsx(Lc,{size:14}),tooltip:"Interactive"},...Ye.kind==="iframe"?[{value:"visual",icon:n.jsx(Oc,{size:14}),tooltip:"Visual editor"}]:[],...Ye.kind==="iframe"&&Wl(te,oe)?[{value:"cms",icon:n.jsx(A_,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(R_,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[mt&&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(x1,{value:Vs,onValueChange:sn,options:Vp,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),Ye.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ae("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:Op,children:n.jsx(Pn,{size:14})})}),n.jsx(Ee,{side:"bottom",children:"Refresh"})]}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:zp,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(P_,{size:14}),r==="tablet"&&n.jsx(D_,{size:14}),r==="desktop"&&n.jsx(Lc,{size:14})]},r)})}),n.jsx(Ee,{side:"bottom",children:s2[r]})]}),n.jsxs("div",{ref:N,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:()=>S(ne=>!ne),children:[j&&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(si,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Hp}),xe&&!j&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:xe}),n.jsx(cs,{size:12,className:ae("shrink-0 text-muted-foreground transition-transform",y&&"rotate-180")})]}),y&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Wu,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:w,onChange:ne=>C(ne.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:ne=>{ne.preventDefault(),S(!1),C(""),k(void 0),R(!0)},children:[n.jsx(Dt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),Be.length===0&&Pe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ve.length===0&&we.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:[Be.length>0&&n.jsx("div",{className:"p-1.5",children:Be.map(ne=>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:je=>{je.preventDefault(),S(!1),C(""),Ec(ne)},children:[n.jsx(Ni,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.path})]},ne.key))}),Pe.length>0&&n.jsxs("div",{className:ae("p-1.5",Be.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),Pe.map(ne=>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:je=>{je.preventDefault(),S(!1),C(""),Up(ne)},children:[n.jsx(si,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ne.key))]})]})]})]})]}),n.jsxs("div",{className:ae("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const ne=ge??Ye.previewUrl;ne&&window.open(ne,"_blank","noopener")},children:n.jsx(hi,{size:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",children:n.jsx(Hi,{size:14})})}),n.jsxs(Kt,{align:"end",className:"w-44",children:[n.jsx(Ue,{onClick:$p,children:"Hard Reload"}),n.jsx(Ue,{onClick:Fp,children:"Copy Current URL"}),te&&oe&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),ye&&n.jsxs(Ue,{onClick:()=>{z(!0),sn("cms")},children:[n.jsx(kr,{size:14}),"Edit SEO"]}),ye&&n.jsxs(Ue,{onClick:()=>{try{Z(Pc(ye)),sn("code")}catch{he.error("Invalid page block key")}},children:[n.jsx(no,{size:14}),"View JSON"]}),n.jsxs(Ue,{onClick:()=>q(!0),children:[n.jsx(kr,{size:14}),"Site SEO"]})]}),fe&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsxs(Ue,{onClick:()=>window.open(`vscode://file${fe}?windowId=_blank`),children:[n.jsx("img",{src:hd,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),n.jsxs(Ue,{onClick:()=>window.open(`cursor://file${fe}?windowId=_blank`),children:[n.jsx("img",{src:ud,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})]})]}),s==="code"&&fe&&n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(`vscode://file${fe}?windowId=_blank`),children:n.jsx("img",{src:hd,alt:"VSCode",width:14,height:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in VSCode"})]}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(`cursor://file${fe}?windowId=_blank`),children:n.jsx("img",{src:ud,alt:"Cursor",width:14,height:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in Cursor"})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&V&&e&&Y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Z0,{orgSlug:G.slug,virtualMcpId:Y,branch:e,previewReady:ee,previewUrl:V,currentPath:L,activePageBlockKey:ye,activeGlobalBlockKey:j?.key??null,externalSelectedIndex:j?null:h,onSaved:()=>{setTimeout(Mp,Do)},initialEditSeo:H,onExitSeo:()=>z(!1),onViewJsonFile:ne=>{try{Z(Pc(ne)),sn("code")}catch{he.error("Invalid page block key")}},onVariantPreviewOverride:Bp})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:ne=>{_.current=!0,b.current=ne.clientX,x.current=p,ne.currentTarget.setPointerCapture(ne.pointerId)},onPointerMove:ne=>{if(!_.current)return;const je=ne.clientX-b.current;g(Math.max(240,Math.min(640,x.current+je)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:ae("flex-1 relative overflow-hidden",r!=="desktop"&&Ye.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[ue&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Wr,{kind:"starting",progress:He,claimPhase:Ge})}),Ye.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Wr,{kind:"suspended",onResume:$.resume})}),Vs==="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(Oc,{size:12}),"Click any element to ask the AI"]}),Vs==="visual"&&a&&n.jsx(L0,{element:a,onDismiss:()=>l(null)}),s==="code"&&mt&&Y&&e&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(e2,{orgSlug:G.slug,virtualMcpId:Y,branch:e,openPath:K})})}),Ye.kind==="iframe"&&ge&&n.jsx("div",{className:ae("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%":`${t2[r]}px`},children:n.jsx("iframe",{ref:d,src:ge,className:ae("w-full h-full border-0",s==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:c?-1:void 0,onLoad:()=>{if(Ke("vm_preview_loaded",{view_mode:s,vm_id:X?.sandboxHandle??null}),!j)try{const ne=d.current?.contentWindow?.location?.pathname;if(!ne)return;const je=pe.current;if(je!==null){pe.current=null,De(ne)===De(je)&&P(ne);return}P(ne)}catch{}s==="visual"&&tn(),s==="cms"&&Nc()}},Ye.previewUrl)})]})]}),n.jsx(E0,{open:E,onOpenChange:R,isPending:be.isPending,error:T,onSubmit:Wp}),W&&te&&oe&&n.jsx(D.Suspense,{fallback:null,children:n.jsx(Q0,{open:W,onOpenChange:q,orgSlug:G.slug,virtualMcpId:Y??"",branch:e??"",decofile:te,meta:oe,onSaved:()=>{setTimeout(()=>{const ne=d.current;if(ne)try{ne.contentWindow?.location.reload()}catch{const je=Se.current;je&&(ne.src=je)}},Do)},target:{kind:"site"}})})]})}function o2(t){const e=U.c(2),{virtualMcpId:s}=t,i=vs(s);if(!ti(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(zi,{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(r2,{}),e[1]=o):o=e[1],o}function a2(t){const e=U.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("grid gap-3",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(n1,{"data-slot":"radio-group",className:r,...i}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function fd(t){const e=U.c(9);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[2px] disabled:opacity-50",s),e[3]=s,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(r1,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:n.jsx(w1,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})}),e[5]=o):o=e[5];let a;return e[6]!==i||e[7]!==r?(a=n.jsx(i1,{"data-slot":"radio-group-item",className:r,...i,children:o}),e[6]=i,e[7]=r,e[8]=a):a=e[8],a}function l2(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 c2(t,e,s){return typeof t!="string"?null:l2(Us(t,e),s)}function lm(t,e,s){if(!e||typeof t!="string")return!1;const i=c2(t,e,s);return!!i&&Object.keys(i.properties??{}).length>0}function d2({orgSlug:t,virtualMcpId:e,branch:s}){const i=oi();return ai({mutationFn:async({blockKey:r})=>{const o=wu(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=Et.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,d=>{if(!d)return d;const{[r]:c,...h}=d;return h}),{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:Et.liveMeta(r)})}})}function go(t,e){return`${t}-${e}`}function cm(t,e){return`site/apps/${t}/${e}.ts`}function dm(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 h2(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function u2(t){return t==="local"?"Custom":"Installed"}function hm(t,e,s){const i=new Set([go(t,e),e].map(o=>o.toLowerCase())),r=cm(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 f2(t,e){const s=t.vendor.alias,i=t.name,r=hm(s,i,e);return{id:go(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:cm(s,i),blockKey:r,installed:r!==null}}function m2(t,e,s){if(t===Ul)return null;const i=dm(t);if(!i)return null;const{vendor:r,app:o}=i,a=hm(r,o,s),l=fi(t,e);return{id:go(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 p2(t,e,s){const i=e.__resolveType;if(typeof i!="string"||$r(t,e)||!mf(i))return null;const r=dm(i)??h2(t);if(!r)return null;const o=fi(i,s),{vendor:a,app:l}=r;return{id:go(a,l),app:l,vendor:a,title:o.title??zr(t,e,s),description:o.description??"",category:u2(a),logo:o.logo??o.icon,resolveType:i,blockKey:t,installed:!0}}function g2(t,e,s){const i=new Map;for(const o of t){const a=f2(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=m2(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=p2(o,a,e);!l||i.has(l.id)||i.set(l.id,l)}return[...i.values()].sort(_2)}function _2(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function v2(){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 x2(t,e,s){const i=U.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=Et.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:v2,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=Es(a);let d;i[3]!==e||i[4]!==t||i[5]!==l.data?(d=t&&e?g2(l.data??[],t,e):[],i[3]=e,i[4]=t,i[5]=l.data,i[6]=d):d=i[6];const c=d,h=l.isLoading&&!l.isError;let u;return i[7]!==c||i[8]!==l.isError||i[9]!==l.refetch||i[10]!==h?(u={catalog:c,isLoading:h,isError:l.isError,refetch:l.refetch},i[7]=c,i[8]=l.isError,i[9]=l.refetch,i[10]=h,i[11]=u):u=i[11],u}function SE(t,e,s,i,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[i]&&(l[i]={...l[i],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function wE(t){return structuredClone(t)}function CE(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function b2(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"");return/^[A-Za-z]/.test(e)?e:e?`Block${e}`:""}function y2(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_-]*$/.test(s)?null:"Use letters, numbers, hyphens, or underscores. Must start with a letter.":"Block name is required."}function S2(t){return(e,s)=>{r_(e),t(e,s)}}const w2=new Set(["http:","https:","mailto:","tel:","ftp:"]);function C2(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return w2.has(e.protocol)}catch{return!1}}function ys(t){const e=U.c(8),{active:s,label:i,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ae("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let d;return e[2]!==s||e[3]!==o||e[4]!==i||e[5]!==r||e[6]!==l?(d=n.jsx("button",{type:"button","aria-label":i,"aria-pressed":s,onMouseDown:k2,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=i,e[5]=r,e[6]=l,e[7]=d):d=e[7],d}function k2(t){return t.preventDefault()}function j2({schema:t,value:e,onChange:s,path:i,label:r}){const o=typeof e=="string"?e:"",a=D.useRef(s);a.current=s;const l=Ng({extensions:[Eg.configure({heading:{levels:[1,2,3]}})],content:o||"",editorProps:{attributes:{class:ae("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:d})=>{const c=d.getHTML();a.current(c==="<p></p>"?"":c)}});return l?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(Ve,{htmlFor:i,children:r}),t.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[n.jsx(ys,{active:l.isActive("bold"),label:"Bold",onClick:()=>l.chain().focus().toggleBold().run(),children:n.jsx(I_,{size:14})}),n.jsx(ys,{active:l.isActive("italic"),label:"Italic",onClick:()=>l.chain().focus().toggleItalic().run(),children:n.jsx(L_,{size:14})}),n.jsx(ys,{active:l.isActive("underline"),label:"Underline",onClick:()=>l.chain().focus().toggleUnderline().run(),children:n.jsx(O_,{size:14})}),n.jsx(ys,{active:l.isActive("strike"),label:"Strikethrough",onClick:()=>l.chain().focus().toggleStrike().run(),children:n.jsx(B_,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("heading",{level:1}),label:"Heading 1",onClick:()=>l.chain().focus().toggleHeading({level:1}).run(),children:n.jsx(M_,{size:14})}),n.jsx(ys,{active:l.isActive("heading",{level:2}),label:"Heading 2",onClick:()=>l.chain().focus().toggleHeading({level:2}).run(),children:n.jsx($_,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("bulletList"),label:"Bullet list",onClick:()=>l.chain().focus().toggleBulletList().run(),children:n.jsx(y1,{size:14})}),n.jsx(ys,{active:l.isActive("orderedList"),label:"Ordered list",onClick:()=>l.chain().focus().toggleOrderedList().run(),children:n.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("link"),label:"Link",onClick:()=>{const d=l.getAttributes("link").href,c=window.prompt("Link URL",d??"https://");c!==null&&(c===""?l.chain().focus().unsetLink().run():C2(c)&&l.chain().focus().setLink({href:c}).run())},children:n.jsx(_g,{size:14})})]}),n.jsx(Tg,{editor:l})]})]}):null}const Ci=t=>String(t).padStart(2,"0"),N2="1900-01-01",E2="2099-12-31",T2="1900-01-01T00:00",A2="2099-12-31T23:59";function R2(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${Ci(s.getUTCMonth()+1)}-${Ci(s.getUTCDate())}`}function P2(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function D2(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Ci(e.getMonth()+1)}-${Ci(e.getDate())}T${Ci(e.getHours())}:${Ci(e.getMinutes())}`}function I2(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function L2(t){const e=U.c(29),{id:s,withTime:i,value:r,onChange:o}=t,[a,l]=D.useState(!1);let d;e[0]!==r||e[1]!==i?(d=i?D2(r):R2(r),e[0]=r,e[1]=i,e[2]=d):d=e[2];const c=d;let h;e[3]!==o||e[4]!==i?(h=E=>{o(i?I2(E.target.value):P2(E.target.value))},e[3]=o,e[4]=i,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const E=r?new Date(r):null;f=E&&!Number.isNaN(E.getTime())?E:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==i?(p=E=>{E&&(i&&m?E.setHours(m.getHours(),m.getMinutes(),0,0):E.setHours(0,0,0,0),o(E.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=i,e[11]=p):p=e[11];const g=p,_=i?"datetime-local":"date",b=i?T2:N2,x=i?A2:E2;let v;e[12]!==u||e[13]!==s||e[14]!==c||e[15]!==_||e[16]!==b||e[17]!==x?(v=n.jsx(ze,{id:s,type:_,min:b,max:x,value:c,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=c,e[15]=_,e[16]=b,e[17]=x,e[18]=v):v=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Rs,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:n.jsx(Eu,{className:"h-4 w-4"})})}),e[19]=y):y=e[19];const S=m??void 0;let w;e[20]!==g||e[21]!==S?(w=n.jsx(Ps,{className:"w-auto p-0",align:"end",children:n.jsx(k1,{mode:"single",selected:S,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=S,e[22]=w):w=e[22];let C;e[23]!==a||e[24]!==w?(C=n.jsxs(As,{open:a,onOpenChange:l,children:[y,w]}),e[23]=a,e[24]=w,e[25]=C):C=e[25];let N;return e[26]!==C||e[27]!==v?(N=n.jsxs("div",{className:"flex gap-1",children:[v,C]}),e[26]=C,e[27]=v,e[28]=N):N=e[28],N}function nr(t){const e=U.c(8),{htmlFor:s,label:i,description:r}=t;let o;e[0]!==s||e[1]!==i?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function rr(t){const e=U.c(67),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="string"?i:"",d=s.format;if(d==="rich-text"||d==="rich-text-inline"||d==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==i?(g=n.jsx(j2,{schema:s,value:i,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=i,e[5]=g):g=e[5],g}if(d==="textarea"||d==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let _;e[10]!==r?(_=v=>r(v.target.value),e[10]=r,e[11]=_):_=e[11];let b;e[12]!==o||e[13]!==l||e[14]!==_?(b=n.jsx(Ln,{id:o,value:l,onChange:_,rows:4}),e[12]=o,e[13]=l,e[14]=_,e[15]=b):b=e[15];let x;return e[16]!==g||e[17]!==b?(x=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[16]=g,e[17]=b,e[18]=x):x=e[18],x}if(d==="date"||d==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const _=d==="date-time";let b;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==_?(b=n.jsx(L2,{id:o,withTime:_,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=_,e[27]=b):b=e[27];let x;return e[28]!==g||e[29]!==b?(x=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[28]=g,e[29]=b,e[30]=x):x=e[30],x}if(d==="color-input"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const _=l||"#000000";let b;e[35]!==r?(b=C=>r(C.target.value),e[35]=r,e[36]=b):b=e[36];let x;e[37]!==_||e[38]!==b?(x=n.jsx("input",{type:"color",value:_,onChange:b,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=_,e[38]=b,e[39]=x):x=e[39];let v;e[40]!==r?(v=C=>r(C.target.value),e[40]=r,e[41]=v):v=e[41];let y;e[42]!==o||e[43]!==l||e[44]!==v?(y=n.jsx(ze,{id:o,value:l,onChange:v,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=v,e[45]=y):y=e[45];let S;e[46]!==x||e[47]!==y?(S=n.jsxs("div",{className:"flex items-center gap-2",children:[x,y]}),e[46]=x,e[47]=y,e[48]=S):S=e[48];let w;return e[49]!==g||e[50]!==S?(w=n.jsxs("div",{className:"space-y-2",children:[g,S]}),e[49]=g,e[50]=S,e[51]=w):w=e[51],w}let c;e[52]!==a||e[53]!==o||e[54]!==s.description?(c=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=c):c=e[55];const h=d==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=n.jsx(ze,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==c||e[65]!==m?(p=n.jsxs("div",{className:"space-y-2",children:[c,m]}),e[64]=c,e[65]=m,e[66]=p):p=e[66],p}function O2(t){const e=U.c(17),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="number"?i:"";let d;e[0]!==a||e[1]!==o?(d=n.jsx(Ve,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=d):d=e[2];let c;e[3]!==s.description?(c=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=c):c=e[4];let h;e[5]!==d||e[6]!==c?(h=n.jsxs("div",{className:"space-y-0.5",children:[d,c]}),e[5]=d,e[6]=c,e[7]=h):h=e[7];let u;e[8]!==r?(u=p=>{const g=p.target.value;r(g===""?void 0:Number(g))},e[8]=r,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==o||e[12]!==u?(f=n.jsx(ze,{id:o,type:"number",value:l,onChange:u,className:"h-10"}),e[10]=l,e[11]=o,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"space-y-2",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}function B2(t){const e=U.c(17),{value:s,onChange:i,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let d;e[0]!==o||e[1]!==r?(d=n.jsx(Ve,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=d):d=e[2];let c;e[3]!==a.description?(c=a.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=c):c=e[4];let h;e[5]!==d||e[6]!==c?(h=n.jsxs("div",{className:"space-y-0.5",children:[d,c]}),e[5]=d,e[6]=c,e[7]=h):h=e[7];let u;e[8]!==i?(u=p=>i(p),e[8]=i,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=n.jsx(On,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const rc="__enum_empty__";function oc(t){return t===""?rc:String(t)}function M2(t,e){if(t===rc)return"";const s=e.find(i=>oc(i)===t);return s!==void 0?s:t}function $2(t,e){return t==null?e.some(s=>s==="")?rc:void 0:oc(t)}function z2(t){return t===""?"":String(t)}function F2(t){const e=U.c(28),{schema:s,value:i,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const d=l;let c;e[2]!==d||e[3]!==i?(c=$2(i,d),e[2]=d,e[3]=i,e[4]=c):c=e[4];const h=c;let u;e[5]!==a||e[6]!==o?(u=n.jsx(Ve,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=n.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==d?(p=y=>r(M2(y,d)),e[13]=r,e[14]=d,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(kt,{className:"h-10",children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=g):g=e[16];let _;e[17]!==d?(_=d.map(H2),e[17]=d,e[18]=_):_=e[18];let b;e[19]!==_?(b=n.jsx(jt,{children:_}),e[19]=_,e[20]=b):b=e[20];let x;e[21]!==h||e[22]!==p||e[23]!==b?(x=n.jsxs(Nt,{value:h,onValueChange:p,children:[g,b]}),e[21]=h,e[22]=p,e[23]=b,e[24]=x):x=e[24];let v;return e[25]!==x||e[26]!==m?(v=n.jsxs("div",{className:"space-y-2",children:[m,x]}),e[25]=x,e[26]=m,e[27]=v):v=e[27],v}function H2(t){const e=oc(t);return n.jsx(tt,{value:e,children:z2(t)},e)}function ac(t){const e=t.__resolveType;if(typeof e!="string")return null;if(Tt(e)){const i=t.section?.__resolveType;return typeof i=="string"?i:e}return e}function U2(t){return t.includes("flags/multivariate")}function W2(t){return ut(t)}function V2(t,e){const s=[...t],i=new Set(s.map(o=>o.resolveType)),r=(o,a)=>{!o||i.has(o)||(i.add(o),s.push({resolveType:o,title:a??W2(o)}))};if(e.savedBlockKey&&r(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=ac(e.editorValue);o?.includes("/")&&r(o)}return s}function K2(t,e,s){const i=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return i;const r=t,o=r.__resolveType;if(typeof o=="string"){if(Ns(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const c=e.find(u=>Kc(u.resolveType,o));if(c)return c.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof r.type=="string"?r.type:void 0;if(a){const c=e.find(h=>h.discriminatorValue===a||h.resolveType===a||Kc(h.resolveType,a));if(c)return c.resolveType}let l=i,d=-1;for(const c of e){if(!c.schema?.properties)continue;const u=Object.keys(c.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>r[f]!==void 0).length;u>0&&u>d&&(d=u,l=c.resolveType)}return d>0,l}function md(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const i=ac(t);if(!i)return s??null;if(!e)return i.includes("/")?null:s??null;const r=Us(i,e);return r||(i.includes("/")?null:s??null)}function q2(t,e){if(!t?.properties||!e)return t??null;if(!(e in t.properties))return t;const s={...t.properties};return delete s[e],{...t,properties:s}}function um(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!Tt(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function G2(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,i=ac(s);return i&&U2(i)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(r=>!r.startsWith("__")&&r!=="@type")}function lc(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,i=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof i?.value=="string")return i.value;const r=s.find(o=>typeof o.value=="string");if(r)return r.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function Y2(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function X2(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(r=>r.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const i=e.find(r=>typeof r.value=="string");if(i)return i.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function fm(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(fm);const e=t;return e.__resolveType?X2(e)??t:mm(e)}function mm(t){const e={};for(const[s,i]of Object.entries(t))e[s]=fm(i);return e}function J2(t,e){return e.split(".").reduce((s,i)=>{if(!(s==null||typeof s!="object"))return s[i]},t)}function pm(t){return t==null?"":Array.isArray(t)?t.map(pm).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function cc(t,e){if(!t.includes("{"))return;const s=mm(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(r,o,a)=>{const l=(o??a??"").trim();return pm(J2(s,l))}).trim()||void 0}function Z2(t){return t.replace(/<[^>]*>/g,"").trim()}function Q2(t,e){if(e.includes("{"))return cc(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const i=s.map(r=>r==null?"":String(r)).filter(Boolean).join(",");if(i)return i}}function Xs(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let i=t;const r=um(i);if(r&&(i=r),s?.titleBy){const a=Q2(i,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=i[a];if(typeof l=="string"&&l.trim()){const d=s?.properties?.[a]?.format;if(d==="rich-text"||d==="html"){const c=Z2(l);if(c)return c;continue}return l}if(Array.isArray(l)){const d=l.map(c=>c==null?"":String(c)).filter(Boolean).join(",");if(d)return d}}const o=i.__resolveType;if(typeof o=="string"&&o)return ut(o);if(s?.title){const a=cc(s.title,i);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function eS(t){if(!t)return;if(typeof t.image=="string"&&t.image.includes("{"))return t.image;const e=t.properties?.image;if(!e)return;if(e.format==="image-uri")return"{{{image}}}";const s=e.properties;return s?.mobile?"{{{image.mobile}}}":s?.desktop?"{{{image.desktop}}}":"{{{image}}}"}function pd(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=eS(e);if(!s)return;const i=cc(s,t);if(!i)return;const r=lc(i)||i;return Y2(r)}function gm(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function ii(t){return t.normalize("NFC").trim()}function St(t,e){return ii(t)===ii(e)}function gd(t,e){return ii(t).replace(/\s+/g,"").toLowerCase()===ii(e).replace(/\s+/g,"").toLowerCase()}function or(t,e,s){const i=ii(s);if(t.some(a=>St(a,i)||St(a,s)))return t;const r=[...t];return r.some(a=>St(a,e))||r.push(e),r.push(s),r}function tS(t,e,s){if(s.length===0)return s;const i=jn(t,e),r=s[0];return St(r,i)||St(r,t)?s.slice(1):s}function jn(t,e){return e.title??gm(t)}function kE(t,e){return e<=0?[]:t.slice(0,e)}function Lo(t,e){const s=ii(e);return t.findIndex(i=>ii(i)===s)}function _d(t,e){return t.type==="array"&&t.items||mo(t)?!0:Array.isArray(e)}function sS(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function zn(t,e,s,i){if(i.length===0)return null;const r=i[0];for(const a of t){const l=e[a];if(!l||!_d(l,s[a]))continue;const d=jn(a,l);if(St(r,d)||St(r,a)||i.some(c=>St(c,d)||St(c,a)))return a}for(const a of t){const l=e[a];if(!l||!_d(l,s[a]))continue;const d=s[a];if(!Array.isArray(d))continue;const c=l.items;for(let h=0;h<d.length;h++){const u=Xs(d[h],h,c);if(St(u,r))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const d=Object.keys(l.properties),c=sS(s[a]),h=jn(a,l);if(zn(d,l.properties,c,i)||(St(r,h)||St(r,a))&&zn(d,l.properties,c,i.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const d=jn(a,l);if(!(r!==d&&r!==a)){if(i.length>1){const c=s[a];if(c&&typeof c=="object"&&!Array.isArray(c)){const h=i[1];if(Object.keys(c).some(f=>!f.startsWith("__")&&(gd(gm(f),h)||gd(f,h))))return a}}o||(o=a)}}return o||null}function iS(t,e,s,i){return zn(t,e,s,i)}function nS(t,e,s,i,r){if(r.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(zn(o,s.properties,i,r))return!0;const a=r[0];return!St(a,e)&&!St(a,t)?!1:r.length>1||zn(o,s.properties,i,r.slice(1))!==null}function rS(t,e,s,i){if(e.length===0)return null;for(let o=0;o<e.length;o++){const a=e[o],l=s.findIndex((d,c)=>St(Xs(d,c,i),a));if(l>=0)return{index:l,innerPath:e.slice(o+1)}}const r=e.findIndex(o=>St(o,t));if(r>=0&&e.length>r+1){const o=e[r+1],a=s.findIndex((l,d)=>St(Xs(l,d,i),o));if(a>=0)return{index:a,innerPath:e.slice(r+2)}}return null}function Oo(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Yn}function oS(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>Oo(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>Oo(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>Oo(s.resolveType)):!1}function aS(t,e){if(e==="global"||e==="sections"||mo(t))return!0;const s=t.type==="array"?t.items:void 0;return s?oS(s):!1}function vd(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function lS(t,e,s,i,r){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=Us(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&i&&r){const a=Us(i,s)?.properties?.[r]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function cS(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function _m(t){return t.map((e,s)=>({...e,index:s}))}function dS(t,e){if(e===t.length)return t;if(e<t.length)return _m(t.slice(0,e));const s=Array.from({length:e-t.length},(i,r)=>({id:crypto.randomUUID(),index:t.length+r}));return[...t,...s]}function hS(t){const e=U.c(8),{labelText:s,imageSrc:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(bl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=r):r=e[0];let o;e[1]!==i?(o=i&&n.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=i,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs(n.Fragment,{children:[r,n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function uS(t){const e=U.c(37),{sortableId:s,labelText:i,imageSrc:r,onOpen:o,onRemove:a}=t;let l;e[0]!==s?(l={id:s,animateLayoutChanges:pS},e[0]=s,e[1]=l):l=e[1];const{attributes:d,listeners:c,setNodeRef:h,transform:u,isDragging:f}=du(l);let m;e[2]!==u?(m=hu.Transform.toString(u?{...u,x:0}:null),e[2]=u,e[3]=m):m=e[3];const p=f?0:void 0;let g;e[4]!==m||e[5]!==p?(g={transform:m,opacity:p},e[4]=m,e[5]=p,e[6]=g):g=e[6];const _=g;let b;e[7]!==o?(b=I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),o())},e[7]=o,e[8]=b):b=e[8];const x=f?"cursor-grabbing":"cursor-pointer";let v;e[9]!==x?(v=ae("group flex min-w-0 items-center gap-2.5 rounded-lg px-2 py-2.5 hover:bg-accent hover:text-accent-foreground touch-none",x),e[9]=x,e[10]=v):v=e[10];let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(bl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=y):y=e[11];let S;e[12]!==r?(S=r&&n.jsx("img",{src:r,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=r,e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i}),e[14]=i,e[15]=w):w=e[15];const C=`Open actions for ${i}`;let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Hi,{size:14}),e[16]=N):N=e[16];let E;e[17]!==C?(E=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":C,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:mS,onPointerDown:fS,children:N})}),e[17]=C,e[18]=E):E=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(es,{size:14}),e[19]=R):R=e[19];let T;e[20]!==a?(T=n.jsx(Kt,{align:"end",children:n.jsxs(Ue,{className:"text-destructive focus:text-destructive",onClick:a,children:[R,"Delete"]})}),e[20]=a,e[21]=T):T=e[21];let k;e[22]!==E||e[23]!==T?(k=n.jsxs(Wt,{children:[E,T]}),e[22]=E,e[23]=T,e[24]=k):k=e[24];let j;return e[25]!==d||e[26]!==i||e[27]!==c||e[28]!==o||e[29]!==h||e[30]!==_||e[31]!==w||e[32]!==k||e[33]!==b||e[34]!==v||e[35]!==S?(j=n.jsxs("div",{ref:h,style:_,...d,...c,role:"button",tabIndex:0,onClick:o,onKeyDown:b,className:v,title:i,children:[y,S,w,k]}),e[25]=d,e[26]=i,e[27]=c,e[28]=o,e[29]=h,e[30]=_,e[31]=w,e[32]=k,e[33]=b,e[34]=v,e[35]=S,e[36]=j):j=e[36],j}function fS(t){return t.stopPropagation()}function mS(t){return t.stopPropagation()}function pS(){return!1}function ar(t){const e=U.c(24),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,containerResolveType:f,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}=t,b=l===void 0?[]:l,x=Array.isArray(i)?i:[],v=s.items,y=cS(o),S=aS(s,y),w=rS(a,b,x,v),C=w?.index??null,[N,E]=D.useState(()=>vd(x.length)),[R,T]=D.useState(null),[k,j]=D.useState(o),[I,A]=D.useState(x.length),O=D.useRef(!1);k!==o?(j(o),A(x.length),E(vd(x.length))):I!==x.length&&(A(x.length),E(xe=>dS(xe,x.length)));let L;e[0]!==v?(L=(xe,ye)=>Xs(xe,ye,v),e[0]=v,e[1]=L):L=e[1];const P=L,B=xe=>{if(O.current)return;const ye=P(x[xe],xe);d?.(or(b,a,ye))},F=xe=>{const ye=[...x,xe];r(ye);const Ie=ye.length-1,Le=Xs(xe,Ie,v);d?.(or(b,a,Le))},H=()=>{const xe=v?.type,ye=v?.default!==void 0?v.default:xe==="object"?{}:xe==="block-ref"?(()=>{const st=v?.anyOfRefs?.[0]?.resolveType;return typeof st!="string"||Mr(st)?{}:{__resolveType:st}})():xe==="number"||xe==="integer"?0:xe==="boolean"?!1:xe==="array"?[]:"",Ie=[...x,ye];r(Ie);const Le=Ie.length-1,qe=Xs(ye,Le,v);d?.(or(b,a,qe))},z=()=>{if(S){if(!m){he.error("Start the preview dev server to add sections.");return}if(g){g({append:F});return}he.error("Section picker is not available in this editor.");return}H()},W=xe=>{if(r(x.filter((ye,Ie)=>Ie!==xe)),C===xe){const ye=P(x[xe],xe),Ie=Lo(b,ye);d?.(Ie>=0?b.slice(0,Ie):[])}},q=(xe,ye)=>{const Ie=[...x];if(Ie[xe]=ye,r(Ie),xe===C&&C!==null){const Le=P(x[xe],xe),qe=Xs(ye,xe,v);if(Le!==qe){const st=Lo(b,Le);if(st>=0){const ct=[...b];ct[st]=qe,d?.(ct)}}}};let K;e[2]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{distance:8}},e[2]=K):K=e[2];let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={coordinateGetter:uu},e[3]=Z):Z=e[3];const Y=su(wr(nu,K),wr(iu,Z)),G=N.map(gS);let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q=xe=>{T(String(xe.active.id))},e[4]=Q):Q=e[4];const $=Q,X=xe=>{T(null);const{active:ye,over:Ie}=xe;if(!Ie||ye.id===Ie.id)return;const Le=G.indexOf(String(ye.id)),qe=G.indexOf(String(Ie.id));Le===-1||qe===-1||(E(st=>_m(la([...st],Le,qe))),r(la([...x],Le,qe)),O.current=!0,requestAnimationFrame(()=>{O.current=!1}))};let V;e[5]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{T(null)},e[5]=V):V=e[5];const se=V,ee=R?N.find(xe=>xe.id===R):null,le=ee!=null?x[ee.index]:void 0,ce=ee!=null&&le!==void 0?P(le,ee.index):null,fe=ee!=null&&le!==void 0?pd(le,v):void 0;if(C!==null&&C<x.length){const xe=x[C],ye=lS(xe,v,c,f,y),Ie=()=>{const Le=P(xe,C),qe=or(b,a,Le),st=Lo(qe,Le);return st>=0?qe.slice(0,st+1):qe};return n.jsx("div",{className:"min-w-0",children:ye?.type==="object"&&ye.properties?n.jsx(Zi,{schema:ye,value:xe,onChange:Le=>q(C,Le),basePath:`${o}.${C}`,breadcrumbPath:w?.innerPath??[],onBreadcrumbChange:Le=>{d?.([...Ie(),...Le])},meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}):ye?uc({schema:ye,value:xe,onChange:Le=>q(C,Le),path:`${o}.${C}`,label:ye.title??`Item ${C+1}`,breadcrumbPath:w?.innerPath??[],onBreadcrumbChange:Le=>{d?.([...Ie(),...Le])},meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}):null})}const J="space-y-2";let te;e[6]!==a?(te=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=te):te=e[7];const oe=x.length>0&&n.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:x.length});let de;e[8]!==te||e[9]!==oe?(de=n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[te,oe]}),e[8]=te,e[9]=oe,e[10]=de):de=e[10];let be;e[11]!==s.description?(be=s.description&&n.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=be):be=e[12];let ve;e[13]!==de||e[14]!==be?(ve=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[de,be]}),e[13]=de,e[14]=be,e[15]=ve):ve=e[15];const we=x.length>0&&n.jsx("div",{className:ae(R&&"cursor-grabbing"),children:n.jsxs(ru,{sensors:Y,collisionDetection:ou,onDragStart:$,onDragEnd:X,onDragCancel:se,children:[n.jsx(au,{items:G,strategy:lu,children:n.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:N.map(xe=>{const ye=x[xe.index];if(ye===void 0)return null;const Ie=P(ye,xe.index),Le=pd(ye,v);return n.jsx(uS,{sortableId:xe.id,labelText:Ie,imageSrc:Le,onOpen:()=>B(xe.index),onRemove:()=>W(xe.index)},xe.id)})})}),n.jsx(cu,{dropAnimation:null,children:ce?n.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:n.jsx(hS,{labelText:ce,imageSrc:fe})}):null})]})});let De;e[16]===Symbol.for("react.memo_cache_sentinel")?(De=n.jsx(Dt,{size:14}),e[16]=De):De=e[16];const Be=S?"Add section":"Add item";let Pe;e[17]!==z||e[18]!==Be?(Pe=n.jsxs("button",{type:"button",onClick:z,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[De,Be]}),e[17]=z,e[18]=Be,e[19]=Pe):Pe=e[19];let Fe;return e[20]!==ve||e[21]!==we||e[22]!==Pe?(Fe=n.jsxs("div",{className:J,children:[ve,we,Pe]}),e[20]=ve,e[21]=we,e[22]=Pe,e[23]=Fe):Fe=e[23],Fe}function gS(t){return t.id}function _S(t){const e=U.c(44),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let _;e[0]!==l?(_=l===void 0?[]:l,e[0]=l,e[1]=_):_=e[1];const b=_,[x,v]=D.useState(!1);let y;e[2]!==i?(y=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},e[2]=i,e[3]=y):y=e[3];const S=y;if(!s.properties)return null;let w;e[4]!==o?(w=o.split(".").pop()??o,e[4]=o,e[5]=w):w=e[5];const C=w;let N;e[6]!==b||e[7]!==C||e[8]!==a||e[9]!==S||e[10]!==s?(N=nS(C,a,s,S,b),e[6]=b,e[7]=C,e[8]=a,e[9]=S,e[10]=s,e[11]=N):N=e[11];const R=x||N,T=`${o}-fields`;let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>v(vS),e[12]=k):k=e[12];let j;e[13]!==R?(j=n.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:R?n.jsx(cs,{size:16}):n.jsx(Vi,{size:16})}),e[13]=R,e[14]=j):j=e[14];let I;e[15]!==a?(I=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=I):I=e[16];let A;e[17]!==T||e[18]!==R||e[19]!==j||e[20]!==I?(A=n.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":T,onClick:k,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[j,I]}),e[17]=T,e[18]=R,e[19]=j,e[20]=I,e[21]=A):A=e[21];let O;e[22]!==s.description?(O=s.description&&n.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=O):O=e[23];let L;e[24]!==b||e[25]!==T||e[26]!==h||e[27]!==R||e[28]!==c||e[29]!==S||e[30]!==m||e[31]!==d||e[32]!==r||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(L=R&&n.jsx("div",{id:T,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:n.jsx(Zi,{schema:s,value:S,onChange:r,basePath:o,breadcrumbPath:b,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=b,e[25]=T,e[26]=h,e[27]=R,e[28]=c,e[29]=S,e[30]=m,e[31]=d,e[32]=r,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=L):L=e[39];let P;return e[40]!==O||e[41]!==L||e[42]!==A?(P=n.jsxs("div",{className:"min-w-0 space-y-2",children:[A,O,L]}),e[40]=O,e[41]=L,e[42]=A,e[43]=P):P=e[43],P}function vS(t){return!t}function vm(t){return t===Yn||t===qi}function _o(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},i=s.__resolveType??t;return{data:{...s},resolveType:i}}function Vr(t,e){const s=t.__resolveType??"";if(!s)return null;if(Tt(s)){const i=t.section??{};return xm(i,e)}if(vm(s)){const i=t.variants?.[0]?.value;return i?Vr(i,e):null}return!Ns(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:_o(s,e)}function xm(t,e){const s=t.__resolveType??"";if(!s)return null;if(vm(s)){const i=t.variants?.[0]?.value;return i?Vr(i,e):null}return!Ns(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:_o(s,e)}function xS(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const i=t.__resolveType;if(typeof i!="string"||!Ns(i)||!Object.hasOwn(e,i))return null;const r=_o(i,e);return r?{blockKey:i,...r}:null}function bS(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const i=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return _o(i,s)}if(e.isHidden){const o=(Tt(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Vr(o,s)}if(e.isLazy||Tt(t.__resolveType)){const i=t.section??{};return xm(i,s)}return Vr(t,s)}function yS(t){if(!t?.properties)return{};const e={};for(const[s,i]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(i.default!==void 0?e[s]=i.default:i.type==="boolean"?e[s]=!1:i.type==="string"?e[s]="":i.type==="number"||i.type==="integer"?e[s]=0:i.type==="object"&&(e[s]={}));return e}function SS(t){const e=U.c(3),{blockKey:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ne,{asChild:!0,children:n.jsxs("span",{className:"inline-flex shrink-0 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(Ui,{size:11}),"Global"]})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Te,{children:[i,n.jsxs(Ee,{side:"top",className:"max-w-[260px]",children:["Edits the saved block “",s,"”. Changes apply everywhere this loader is referenced on your site."]})]}),e[1]=s,e[2]=r):r=e[2],r}function wS(t){const e=U.c(28),{path:s,open:i,onOpenChange:r,title:o,nested:a,nestedBlockRef:l,globalBlockKey:d}=t,c=`${s}-loader-config`,h=l&&"ml-1";let u;e[0]!==h?(u=ae("rounded-lg border border-border/80 bg-muted/30",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==r||e[3]!==i?(f=()=>r(!i),e[2]=r,e[3]=i,e[4]=f):f=e[4];let m;e[5]!==i?(m=n.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:i?n.jsx(cs,{size:16}):n.jsx(Vi,{size:16})}),e[5]=i,e[6]=m):m=e[6];let p;e[7]!==o?(p=n.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=p):p=e[8];let g;e[9]!==d?(g=d&&n.jsx(SS,{blockKey:d}),e[9]=d,e[10]=g):g=e[10];let _;e[11]!==p||e[12]!==g?(_=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[11]=p,e[12]=g,e[13]=_):_=e[13];let b;e[14]!==c||e[15]!==i||e[16]!==f||e[17]!==m||e[18]!==_?(b=n.jsxs("button",{type:"button","aria-expanded":i,"aria-controls":c,onClick:f,className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-accent/50",children:[m,_]}),e[14]=c,e[15]=i,e[16]=f,e[17]=m,e[18]=_,e[19]=b):b=e[19];let x;e[20]!==c||e[21]!==a||e[22]!==i?(x=i&&n.jsx("div",{id:c,className:"border-t border-border/60 px-4 pb-4 pt-3",children:n.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[20]=c,e[21]=a,e[22]=i,e[23]=x):x=e[23];let v;return e[24]!==u||e[25]!==b||e[26]!==x?(v=n.jsxs("div",{className:u,children:[b,x]}),e[24]=u,e[25]=b,e[26]=x,e[27]=v):v=e[27],v}function xd(t){const e=U.c(35),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=(s.anyOfRefs??[]).filter(jS),p=h&&i?xS(i,h):null,g=p?.data??i,_=p?null:um(g),b=_??g,x=V2(m,{savedBlockKey:p?.blockKey,editorValue:g}),v=x.length>0?K2(g,x,p?.blockKey):x[0]?.resolveType??"",S=s.type==="block-ref"&&x.some(kS);let w;e[0]!==a||e[1]!==o?(w=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=w):w=e[2];const C=w;let N;e[3]!==l?(N=l??[],e[3]=l,e[4]=N):N=e[4];const E=N,R=S&&E[0]===C?E.slice(1):E,T=S?K=>{d?.([C,...K])}:d,[k,j]=D.useState(v),[I,A]=D.useState(v);I!==v&&(A(v),j(v));const[O,L]=D.useState(()=>G2(g,p?.blockKey));if(x.length>0){const K=k||v;let Z;e[5]!==K?(Z=oe=>oe.resolveType===K,e[5]=K,e[6]=Z):Z=e[6];const Y=x.find(Z),G=md(g,c,Y?.schema),Q=q2(G??Y?.schema??null,s.discriminatorKey),$=s.discriminatorKey,X=oe=>{j(oe);const de=x.find(Pe=>Pe.resolveType===oe),be=md(g,c,de?.schema),ve=new Set(Object.keys((be??de?.schema)?.properties??{})),we=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{},De=Object.fromEntries(Object.entries(we).filter(Pe=>{const[Fe]=Pe;return ve.has(Fe)})),Be={...yS(de?.schema),...De};if($){const Pe=de?.discriminatorValue??oe;r({...Be,[$]:Pe});return}if(Mr(oe)){r(Be);return}r({...Be,__resolveType:oe})};let V;e[7]!==K||e[8]!==$||e[9]!==r?(V=oe=>{if($||!Mr(K)||oe===null||typeof oe!="object"||Array.isArray(oe)){r(oe);return}const{__resolveType:de,...be}=oe;r(be)},e[7]=K,e[8]=$,e[9]=r,e[10]=V):V=e[10];const se=V,ee=Q?.properties?n.jsx(Zi,{schema:Q,value:b,onChange:oe=>{if(p&&u){u(p.blockKey,oe);return}if(_){r({...g,section:oe});return}se(oe)},basePath:o,breadcrumbPath:R,onBreadcrumbChange:T,meta:c,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let le;e[11]!==o?(le=o.includes("."),e[11]=o,e[12]=le):le=e[12];const ce=le;let fe;e[13]!==a||e[14]!==o?(fe=n.jsx(Ve,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=fe):fe=e[15];let J;e[16]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(kt,{children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=J):J=e[16];let te;return e[17]!==s.description?(te=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[17]=s.description,e[18]=te):te=e[18],n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[fe,n.jsxs(Nt,{value:K||void 0,onValueChange:X,children:[J,n.jsx(jt,{children:x.map(CS)})]}),te]}),ee&&(S?n.jsx(wS,{path:o,open:O,onOpenChange:L,title:ce?"Configuration":"Loader configuration",nested:ee,nestedBlockRef:ce,globalBlockKey:p?.blockKey}):ee)]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let P;e[19]!==a||e[20]!==o?(P=n.jsx(Ve,{htmlFor:o,children:a}),e[19]=a,e[20]=o,e[21]=P):P=e[21];const B=i!=null?String(i):"";let F;e[22]!==r?(F=K=>r(K.target.value),e[22]=r,e[23]=F):F=e[23];const H=s.description??"";let z;e[24]!==o||e[25]!==B||e[26]!==F||e[27]!==H?(z=n.jsx("input",{id:o,type:"text",value:B,onChange:F,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:H}),e[24]=o,e[25]=B,e[26]=F,e[27]=H,e[28]=z):z=e[28];let W;e[29]!==s.description?(W=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=W):W=e[30];let q;return e[31]!==P||e[32]!==z||e[33]!==W?(q=n.jsxs("div",{className:"space-y-1.5",children:[P,z,W]}),e[31]=P,e[32]=z,e[33]=W,e[34]=q):q=e[34],q}function CS(t){const e=t.title&&!t.title.includes("/")?t.title:ga(t.resolveType)??ut(t.resolveType);return n.jsx(tt,{value:t.resolveType,children:e},t.resolveType)}function kS(t){return t.resolveType.includes("/")&&!Mr(t.resolveType)}function jS(t){return t.resolveType!==""}function NS(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const i=s;e.push({value:String(i.value),label:typeof i.label=="string"?i.label:String(i.value),image:typeof i.image=="string"?i.image:void 0})}return e}async function ES(t,e,s){const i={};s&&(i.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return NS(l)}function bd(t){const e=U.c(8),{path:s,label:i,description:r}=t;let o;e[0]!==i||e[1]!==s?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=i,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function TS(t){const e=U.c(71),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=s.options,c=l?.previewUrl,[h,u]=D.useState(!1),[f,m]=D.useState(""),[p,g]=D.useState(""),_=D.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=G=>{m(G),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{g(G)},300)},e[0]=b):b=e[0];const x=b,v=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"";let y;e[1]!==p||e[2]!==d||e[3]!==v?(y=Et.sandboxInvoke(v,`dynamic-options:${d??""}:${p}`),e[1]=p,e[2]=d,e[3]=v,e[4]=y):y=e[4];let S;e[5]!==p||e[6]!==d||e[7]!==c?(S=()=>ES(c,d,p||void 0),e[5]=p,e[6]=d,e[7]=c,e[8]=S):S=e[8];const w=!!c&&!!d&&h;let C;e[9]!==y||e[10]!==S||e[11]!==w?(C={queryKey:y,queryFn:S,enabled:w,staleTime:6e4,retry:1},e[9]=y,e[10]=S,e[11]=w,e[12]=C):C=e[12];const N=Es(C);let E;e[13]!==N.data?(E=N.data??[],e[13]=N.data,e[14]=E):E=e[14];const R=E,T=typeof i=="string"?i:"";let k;if(e[15]!==T||e[16]!==R){let G;e[18]!==T?(G=Q=>Q.value===T,e[18]=T,e[19]=G):G=e[19],k=R.find(G),e[15]=T,e[16]=R,e[17]=k}else k=e[17];const j=k;if(!c||!d){let G;e[20]!==a||e[21]!==o||e[22]!==s.description?(G=n.jsx(bd,{path:o,label:a,description:s.description}),e[20]=a,e[21]=o,e[22]=s.description,e[23]=G):G=e[23];let Q;e[24]!==r?(Q=V=>r(V.target.value),e[24]=r,e[25]=Q):Q=e[25];let $;e[26]!==T||e[27]!==o||e[28]!==Q?($=n.jsx(ze,{id:o,type:"text",value:T,onChange:Q}),e[26]=T,e[27]=o,e[28]=Q,e[29]=$):$=e[29];let X;return e[30]!==$||e[31]!==G?(X=n.jsxs("div",{className:"space-y-2",children:[G,$]}),e[30]=$,e[31]=G,e[32]=X):X=e[32],X}let I;e[33]!==a||e[34]!==o||e[35]!==s.description?(I=n.jsx(bd,{path:o,label:a,description:s.description}),e[33]=a,e[34]=o,e[35]=s.description,e[36]=I):I=e[36];let A;e[37]!==T||e[38]!==j?(A=j?n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[j.image&&n.jsx("img",{src:j.image,alt:"",referrerPolicy:"no-referrer",className:"h-6 w-6 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:j.label??j.value})]}):T?n.jsx("span",{className:"truncate",children:T}):n.jsx("span",{className:"text-muted-foreground",children:"Select..."}),e[37]=T,e[38]=j,e[39]=A):A=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(b1,{className:"size-4 shrink-0 opacity-50"}),e[40]=O):O=e[40];let L;e[41]!==h||e[42]!==A?(L=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",role:"combobox","aria-expanded":h,className:"h-10 w-full justify-between font-normal",children:[A,O]})}),e[41]=h,e[42]=A,e[43]=L):L=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P={width:"var(--radix-popover-trigger-width)"},e[44]=P):P=e[44];let B;e[45]!==f?(B=n.jsx(Nl,{placeholder:"Search...",className:"h-9",value:f,onValueChange:x}),e[45]=f,e[46]=B):B=e[46];const F=N.isLoading?"Loading...":"No results found.";let H;e[47]!==F?(H=n.jsx(El,{children:F}),e[47]=F,e[48]=H):H=e[48];let z;if(e[49]!==T||e[50]!==r||e[51]!==R){let G;e[53]!==T||e[54]!==r?(G=Q=>n.jsxs(Or,{value:Q.value,onSelect:()=>{r(Q.value===T?"":Q.value),u(!1)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[Q.image&&n.jsx("img",{src:Q.image,alt:"",referrerPolicy:"no-referrer",className:"h-9 w-9 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:Q.label??Q.value})]}),n.jsx(js,{className:ae("ml-auto size-4 shrink-0",T===Q.value?"opacity-100":"opacity-0")})]},Q.value),e[53]=T,e[54]=r,e[55]=G):G=e[55],z=R.map(G),e[49]=T,e[50]=r,e[51]=R,e[52]=z}else z=e[52];let W;e[56]!==z?(W=n.jsx(Br,{children:z}),e[56]=z,e[57]=W):W=e[57];let q;e[58]!==H||e[59]!==W?(q=n.jsxs(Tl,{children:[H,W]}),e[58]=H,e[59]=W,e[60]=q):q=e[60];let K;e[61]!==B||e[62]!==q?(K=n.jsx(Ps,{className:"p-0",style:P,children:n.jsxs(Ku,{shouldFilter:!1,children:[B,q]})}),e[61]=B,e[62]=q,e[63]=K):K=e[63];let Z;e[64]!==h||e[65]!==L||e[66]!==K?(Z=n.jsxs(As,{open:h,onOpenChange:u,children:[L,K]}),e[64]=h,e[65]=L,e[66]=K,e[67]=Z):Z=e[67];let Y;return e[68]!==Z||e[69]!==I?(Y=n.jsxs("div",{className:"space-y-2",children:[I,Z]}),e[68]=Z,e[69]=I,e[70]=Y):Y=e[70],Y}function AS(t){const e=U.c(10),{org:s}=Me(),i=di();let r;e[0]!==s.id||e[1]!==t.configId?(r=Et.filePickerObjects(s.id,t.configId),e[0]=s.id,e[1]=t.configId,e[2]=r):r=e[2];const o=t.enabled!==!1&&!!t.configId;let a;e[3]!==t.configId||e[4]!==i?(a=async d=>{const{pageParam:c}=d;return await i.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:c??void 0})},e[3]=t.configId,e[4]=i,e[5]=a):a=e[5];let l;return e[6]!==r||e[7]!==o||e[8]!==a?(l={queryKey:r,enabled:o,staleTime:3e4,initialPageParam:null,queryFn:a,getNextPageParam:RS},e[6]=r,e[7]=o,e[8]=a,e[9]=l):l=e[9],T1(l)}function RS(t){return t.nextCursor??void 0}function dc(){const t=U.c(2),{org:e}=Me();let s;return t[0]!==e?(s={mutationFn:async i=>{const r=i.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(i.configId)}/upload?filename=${encodeURIComponent(i.file.name)}`,{method:"POST",headers:{"Content-Type":r},body:i.file});if(!o.ok){const a=await o.text().catch(PS);let l=`${o.status} ${o.statusText}`;try{const d=JSON.parse(a);d.message&&(l=d.message)}catch{a&&(l=a.slice(0,200))}throw new Error(`Upload failed: ${l}`)}return await o.json()}},t[0]=e,t[1]=s):s=t[1],ai(s)}function PS(){return""}const vo="file-picker:last-config-id";function bm(t){const e=U.c(19),s=t.mode==="image"?"Pick an image":"Pick a file";let i;e[0]!==s?(i=n.jsx(ss,{children:s}),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Wi,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=r):r=e[2];let o;e[3]!==i?(o=n.jsxs(ts,{children:[i,r]}),e[3]=i,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(wl,{className:"h-64 w-full"}),e[5]=a):a=e[5];let l;e[6]!==t?(l=u=>{t.onSelect(u),t.onOpenChange(!1)},e[6]=t,e[7]=l):l=e[7];let d;e[8]!==t.lockedConfigId||e[9]!==t.mode||e[10]!==l?(d=n.jsx(Zt,{fallback:DS,children:n.jsx(D.Suspense,{fallback:a,children:n.jsx(LS,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:l})})}),e[8]=t.lockedConfigId,e[9]=t.mode,e[10]=l,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==d?(c=n.jsxs(Mt,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,d]}),e[12]=o,e[13]=d,e[14]=c):c=e[14];let h;return e[15]!==t.onOpenChange||e[16]!==t.open||e[17]!==c?(h=n.jsx(Bt,{open:t.open,onOpenChange:t.onOpenChange,children:c}),e[15]=t.onOpenChange,e[16]=t.open,e[17]=c,e[18]=h):h=e[18],h}function DS(t){const{error:e}=t;return n.jsx(IS,{error:e??new Error("Failed to load buckets")})}function IS(t){const e=U.c(3),{error:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(zi,{size:16}),e[0]=i):i=e[0];let r;return e[1]!==s.message?(r=n.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[i,n.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=r):r=e[2],r}function LS(t){const e=U.c(32),{mode:s,lockedConfigId:i,onSelect:r}=t,o=E1();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(MS,{}),e[0]=p):p=e[0],p}if(i){let p;if(e[1]!==o||e[2]!==i){let _;e[4]!==i?(_=b=>b.id===i,e[4]=i,e[5]=_):_=e[5],p=o.find(_),e[1]=o,e[2]=i,e[3]=p}else p=e[3];const g=p;if(g){let _;return e[6]!==g||e[7]!==s||e[8]!==r?(_=n.jsx(Bo,{config:g,mode:s,onSelect:r}),e[6]=g,e[7]=s,e[8]=r,e[9]=_):_=e[9],_}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==r?(g=n.jsx(Bo,{config:p,mode:s,onSelect:r}),e[10]=p,e[11]=s,e[12]=r,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(vo):null,e[14]=a):a=e[14];const l=a;let d;e[15]!==o?(d=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=d):d=e[16];const c=d;let h;e[17]!==o?(h=o.map(OS),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=n.jsx(ao,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==r){let p;e[25]!==s||e[26]!==r?(p=g=>n.jsx(Ei,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:n.jsx(Bo,{config:g,mode:s,onSelect:r})},g.id),e[25]=s,e[26]=r,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=r,e[24]=f}else f=e[24];let m;return e[28]!==c||e[29]!==u||e[30]!==f?(m=n.jsxs(lo,{defaultValue:c,onValueChange:BS,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=c,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function OS(t){return n.jsx(zs,{value:t.id,children:t.name},t.id)}function BS(t){typeof window<"u"&&window.localStorage.setItem(vo,t)}function MS(){const t=U.c(4),{org:e}=Me();let s,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:n.jsx(Kn,{size:20,className:"text-muted-foreground"})}),i=n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),t[0]=s,t[1]=i):(s=t[0],i=t[1]);let r;return t[2]!==e.slug?(r=n.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[s,i,n.jsx(ie,{asChild:!0,size:"sm",className:"mt-2",children:n.jsx(Vh,{to:"/$org/settings/files",params:{org:e.slug},children:"Configure a bucket"})})]}),t[2]=e.slug,t[3]=r):r=t[3],r}function Bo({config:t,mode:e,onSelect:s}){const i=AS({configId:t.id}),r=dc(),[o,a]=D.useState(!1),l=D.useRef(null),d=e==="image"?"image/*":void 0;async function c(_){if(!_)return;const b=Array.from(_);if(b.length===0)return;let x=null;const v=[];for(const y of b)try{const S=await r.mutateAsync({configId:t.id,file:y});x??=S.publicUrl}catch(S){v.push(`${y.name} (${S instanceof Error?S.message:"upload failed"})`)}await i.refetch(),v.length>0&&he.error(v.length===b.length?`Upload failed: ${v.join("; ")}`:`Some files failed: ${v.join("; ")}`),x&&s(x)}function h(_){_.preventDefault(),a(!0)}function u(){a(!1)}function f(_){_.preventDefault(),a(!1),c(_.dataTransfer.files)}const p=(i.data?.pages??[]).flatMap(_=>_.items),g=p.filter(_=>e==="image"?ym(_.key):!0);return n.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[n.jsxs("button",{type:"button",onClick:()=>l.current?.click(),onDragOver:h,onDragLeave:u,onDrop:f,className:ae("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",o&&"border-primary bg-primary/5",r.isPending&&"opacity-60 pointer-events-none"),children:[n.jsx(Kn,{size:18,className:"text-muted-foreground"}),n.jsx("p",{className:"text-sm font-medium",children:r.isPending?"Uploading…":"Drop files here or click to upload"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),n.jsx("input",{ref:l,type:"file",accept:d,multiple:!0,className:"hidden",onChange:_=>{const b=Array.from(_.target.files??[]);_.target.value="",c(b)}})]}),i.isFetching&&!i.isFetchingNextPage?n.jsx("div",{className:"flex justify-end",children:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading…"})}):null,n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[g.length===0?e==="image"&&p.length>0?n.jsx(zS,{}):n.jsx($S,{}):e==="image"?n.jsx(HS,{items:g,onSelect:s}):n.jsx(US,{items:g,onSelect:s}),i.hasNextPage&&n.jsx("div",{className:"flex justify-center py-4",children:n.jsx(ie,{type:"button",variant:"outline",size:"sm",disabled:i.isFetchingNextPage,onClick:()=>i.fetchNextPage(),children:i.isFetchingNextPage?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function $S(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(Ii,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),t[0]=e):e=t[0],e}function zS(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(Ii,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),t[0]=e):e=t[0],e}function ym(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function FS(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function HS(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx(Sm,{item:l,variant:"image",onSelect:i},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:r}),e[5]=r,e[6]=o):o=e[6],o}function US(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx("li",{children:n.jsx(Sm,{item:l,variant:"row",onSelect:i})},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:r}),e[5]=r,e[6]=o):o=e[6],o}function Sm(t){const e=U.c(58),{item:s,variant:i,onSelect:r}=t;let o;e[0]!==s.key?(o=FS(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(i==="image"){let v;e[2]!==s.publicUrl||e[3]!==r?(v=()=>r(s.publicUrl),e[2]=s.publicUrl,e[3]=r,e[4]=v):v=e[4];let y;e[5]!==s.key||e[6]!==s.publicUrl?(y=n.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:WS}),e[5]=s.key,e[6]=s.publicUrl,e[7]=y):y=e[7];let S;e[8]!==s.key||e[9]!==v||e[10]!==y?(S=n.jsx("button",{type:"button",onClick:v,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:y}),e[8]=s.key,e[9]=v,e[10]=y,e[11]=S):S=e[11];let w;e[12]!==a?(w=n.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let C;e[14]!==s||e[15]!==r?(C=n.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx(yd,{item:s,onSelect:r})}),e[14]=s,e[15]=r,e[16]=C):C=e[16];let N;e[17]!==s.key?(N=Sd(s.key),e[17]=s.key,e[18]=N):N=e[18];let E;e[19]!==N?(E=n.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("p",{className:"truncate text-xs text-white",children:N})}),e[19]=N,e[20]=E):E=e[20];let R;return e[21]!==S||e[22]!==w||e[23]!==C||e[24]!==E?(R=n.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[S,w,C,E]}),e[21]=S,e[22]=w,e[23]=C,e[24]=E,e[25]=R):R=e[25],R}let l;e[26]!==s.publicUrl||e[27]!==r?(l=()=>r(s.publicUrl),e[26]=s.publicUrl,e[27]=r,e[28]=l):l=e[28];let d;e[29]!==s.key?(d=n.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:ym(s.key)?n.jsx(Ii,{size:16,className:"text-muted-foreground"}):n.jsx(Ri,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=d):d=e[30];let c;e[31]!==s.key?(c=Sd(s.key),e[31]=s.key,e[32]=c):c=e[32];let h;e[33]!==c?(h=n.jsx("p",{className:"truncate text-sm font-medium",children:c}),e[33]=c,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=n.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=n.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=GS(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let _;e[46]!==g||e[47]!==l||e[48]!==d||e[49]!==f||e[50]!==m?(_=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[d,f,m,g]}),e[46]=g,e[47]=l,e[48]=d,e[49]=f,e[50]=m,e[51]=_):_=e[51];let b;e[52]!==s||e[53]!==r?(b=n.jsx(yd,{item:s,onSelect:r}),e[52]=s,e[53]=r,e[54]=b):b=e[54];let x;return e[55]!==_||e[56]!==b?(x=n.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[_,b]}),e[55]=_,e[56]=b,e[57]=x):x=e[57],x}function WS(t){t.target.style.display="none"}function yd(t){const e=U.c(22),{item:s,onSelect:i}=t,[r,o]=D.useState(!1);let a;e[0]!==s.publicUrl?(a=async function(v){v.preventDefault(),v.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{he.error("Failed to copy URL")}},e[0]=s.publicUrl,e[1]=a):a=e[1];const l=a;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:qS,"aria-label":"Asset actions",children:n.jsx(C1,{size:14})})}),e[2]=d):d=e[2];let c;e[3]!==s.publicUrl||e[4]!==i?(c=()=>i(s.publicUrl),e[3]=s.publicUrl,e[4]=i,e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(js,{size:14}),e[6]=h):h=e[6];let u;e[7]!==c?(u=n.jsxs(Ue,{onClick:c,children:[h,"Use this"]}),e[7]=c,e[8]=u):u=e[8];let f;e[9]!==r?(f=r?n.jsx(js,{size:14}):n.jsx(as,{size:14}),e[9]=r,e[10]=f):f=e[10];const m=r?"Copied":"Copy URL";let p;e[11]!==l||e[12]!==f||e[13]!==m?(p=n.jsxs(Ue,{onClick:l,children:[f,m]}),e[11]=l,e[12]=f,e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(hi,{size:14}),e[15]=g):g=e[15];let _;e[16]!==s.publicUrl?(_=n.jsx(Ue,{asChild:!0,children:n.jsxs("a",{href:s.publicUrl,target:"_blank",rel:"noreferrer",onClick:VS,children:[g,"Open in new tab"]})}),e[16]=s.publicUrl,e[17]=_):_=e[17];let b;return e[18]!==_||e[19]!==u||e[20]!==p?(b=n.jsxs(Wt,{children:[d,n.jsxs(Kt,{align:"end",onClick:KS,children:[u,p,_]})]}),e[18]=_,e[19]=u,e[20]=p,e[21]=b):b=e[21],b}function VS(t){return t.stopPropagation()}function KS(t){return t.stopPropagation()}function qS(t){return t.stopPropagation()}function Sd(t){const e=t.split("/");return e[e.length-1]??t}function GS(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wm(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(i=>{const r=i.bucket.toLowerCase();return i.siteSlug?.toLowerCase()===s||r===s||r===`deco-assets-${s}`})??null}function wd(t){const e=U.c(2),{ext:s}=t;if(!s)return null;let i;return e[0]!==s?(i=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1],i}function YS(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function XS(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}function JS(t){const e=U.c(79),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=s.format==="video-uri",c=lc(i),[h,u]=D.useState(!1),[f,m]=D.useState(!1),p=c?YS(c):"",g=p?XS(p):"",_=qu(),b=dc();let x;e[0]!==_.data?.configs?(x=_.data?.configs??[],e[0]=_.data?.configs,e[1]=x):x=e[1];const v=l?.siteSlug;let y;e[2]!==x||e[3]!==v?(y=wm(x,v),e[2]=x,e[3]=v,e[4]=y):y=e[4];const S=y;let w;e[5]!==_.data?.configs||e[6]!==S?(w=function(){if(S)return S.id;const J=_.data?.configs??[];if(J.length===1)return J[0].id;if(J.length===0)return null;const te=typeof window<"u"?window.localStorage.getItem(vo):null;return J.some(oe=>oe.id===te)?te:null},e[5]=_.data?.configs,e[6]=S,e[7]=w):w=e[7];const C=w;let N;e[8]!==d||e[9]!==r||e[10]!==C||e[11]!==u||e[12]!==b?(N=async function(J){if(!J)return;let te=Array.from(J);if(te.length===0)return;if(d&&(te=te.filter(ZS),te.length===0)){he.error("Please drop a video file (mp4, webm, …).");return}const oe=C();if(!oe){u(!0);return}try{const de=await b.mutateAsync({configId:oe,file:te[0]});r(de.publicUrl),te.length>1&&he.info(`Uploaded ${te[0].name}; extra files were ignored (single-select field).`)}catch(de){const be=de;he.error(be instanceof Error?be.message:"Upload failed")}},e[8]=d,e[9]=r,e[10]=C,e[11]=u,e[12]=b,e[13]=N):N=e[13];const E=N;let R;e[14]!==m?(R=function(J){J.preventDefault(),J.dataTransfer.types.includes("Files")&&m(!0)},e[14]=m,e[15]=R):R=e[15];const T=R;let k;e[16]!==m?(k=function(J){J.currentTarget===J.target&&m(!1)},e[16]=m,e[17]=k):k=e[17];const j=k;let I;e[18]!==E||e[19]!==m?(I=function(J){J.preventDefault(),m(!1),E(J.dataTransfer.files)},e[18]=E,e[19]=m,e[20]=I):I=e[20];const A=I;let O;e[21]!==a||e[22]!==o?(O=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[21]=a,e[22]=o,e[23]=O):O=e[23];let L;e[24]!==s.description?(L=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[24]=s.description,e[25]=L):L=e[25];let P;e[26]!==L||e[27]!==O?(P=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[O,L]}),e[26]=L,e[27]=O,e[28]=P):P=e[28];const B=f&&"border-primary ring-2 ring-primary/30",F=b.isPending&&"pointer-events-none opacity-60";let H;e[29]!==B||e[30]!==F?(H=ae("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",B,F),e[29]=B,e[30]=F,e[31]=H):H=e[31];let z;e[32]!==g||e[33]!==p||e[34]!==d||e[35]!==u||e[36]!==c||e[37]!==b.isPending?(z=c?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"relative h-40 w-full overflow-hidden bg-black",children:n.jsx("video",{src:c,preload:"metadata",className:"h-full w-full object-contain"},c)}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx(Bc,{size:14,className:"shrink-0 text-muted-foreground"}),n.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:p}),n.jsx(wd,{ext:g})]})]}):n.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[n.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:n.jsx(Ri,{size:18,className:"text-muted-foreground"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:p}),n.jsx("p",{className:"truncate text-xs text-muted-foreground",children:c})]}),n.jsx(wd,{ext:g})]}):n.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[d?n.jsx(Bc,{size:20}):n.jsx(Ri,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:b.isPending?"Uploading…":d?"Drop a video here or click to browse":"Drop a file or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Up to 100 MB"})]}),e[32]=g,e[33]=p,e[34]=d,e[35]=u,e[36]=c,e[37]=b.isPending,e[38]=z):z=e[38];let W;e[39]!==f?(W=f&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[39]=f,e[40]=W):W=e[40];let q;e[41]!==j||e[42]!==T||e[43]!==A||e[44]!==H||e[45]!==z||e[46]!==W?(q=n.jsxs("div",{onDragOver:T,onDragLeave:j,onDrop:A,className:H,children:[z,W]}),e[41]=j,e[42]=T,e[43]=A,e[44]=H,e[45]=z,e[46]=W,e[47]=q):q=e[47];let K;e[48]!==r?(K=fe=>r(fe.target.value),e[48]=r,e[49]=K):K=e[49];let Z;e[50]!==o||e[51]!==c||e[52]!==K?(Z=n.jsx(ze,{id:o,type:"url",value:c,onChange:K,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[50]=o,e[51]=c,e[52]=K,e[53]=Z):Z=e[53];let Y;e[54]!==u?(Y=()=>u(!0),e[54]=u,e[55]=Y):Y=e[55];let G;e[56]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Kn,{size:14}),e[56]=G):G=e[56];const Q=c?"Replace":"Browse";let $;e[57]!==Y||e[58]!==Q?($=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:Y,className:"h-9 shrink-0",children:[G,Q]}),e[57]=Y,e[58]=Q,e[59]=$):$=e[59];let X;e[60]!==r||e[61]!==c?(X=c&&n.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(""),className:"h-9 shrink-0","aria-label":"Remove file",children:n.jsx(es,{size:14})}),e[60]=r,e[61]=c,e[62]=X):X=e[62];let V;e[63]!==Z||e[64]!==$||e[65]!==X?(V=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[Z,$,X]}),e[63]=Z,e[64]=$,e[65]=X,e[66]=V):V=e[66];let se;e[67]!==r?(se=fe=>r(fe),e[67]=r,e[68]=se):se=e[68];const ee=S?.id??null;let le;e[69]!==h||e[70]!==u||e[71]!==se||e[72]!==ee?(le=n.jsx(bm,{open:h,onOpenChange:u,mode:"any",onSelect:se,lockedConfigId:ee}),e[69]=h,e[70]=u,e[71]=se,e[72]=ee,e[73]=le):le=e[73];let ce;return e[74]!==P||e[75]!==q||e[76]!==V||e[77]!==le?(ce=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[P,q,V,le]}),e[74]=P,e[75]=q,e[76]=V,e[77]=le,e[78]=ce):ce=e[78],ce}function ZS(t){return t.type.startsWith("video/")}function QS(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function ew(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const tw=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function sw(t){const e=U.c(86),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=lc(i),[c,h]=D.useState(!1),[u,f]=D.useState(!1),[m,p]=D.useState(!1),[g,_]=D.useState(!1),b=d?QS(d):"",x=b?ew(b):"",v=qu(),y=dc();let S;e[0]!==v.data?.configs?(S=v.data?.configs??[],e[0]=v.data?.configs,e[1]=S):S=e[1];const w=l?.siteSlug;let C;e[2]!==S||e[3]!==w?(C=wm(S,w),e[2]=S,e[3]=w,e[4]=C):C=e[4];const N=C;let E;e[5]!==r||e[6]!==_||e[7]!==p?(E=function(ve){p(!1),_(!1),r(ve)},e[5]=r,e[6]=_,e[7]=p,e[8]=E):E=e[8];const R=E;let T;e[9]!==v.data?.configs||e[10]!==N?(T=function(){if(N)return N.id;const ve=v.data?.configs??[];if(ve.length===1)return ve[0].id;if(ve.length===0)return null;const we=typeof window<"u"?window.localStorage.getItem(vo):null;return ve.some(De=>De.id===we)?we:null},e[9]=v.data?.configs,e[10]=N,e[11]=T):T=e[11];const k=T;let j;e[12]!==k||e[13]!==h||e[14]!==R||e[15]!==y?(j=async function(ve){if(!ve)return;const we=Array.from(ve).filter(iw);if(we.length===0){he.error("Only image files are accepted here.");return}const De=k();if(!De){h(!0);return}try{const Be=await y.mutateAsync({configId:De,file:we[0]});R(Be.publicUrl),we.length>1&&he.info(`Uploaded ${we[0].name}; extra files were ignored (single-select field).`)}catch(Be){const Pe=Be;he.error(Pe instanceof Error?Pe.message:"Upload failed")}},e[12]=k,e[13]=h,e[14]=R,e[15]=y,e[16]=j):j=e[16];const I=j;let A;e[17]!==f?(A=function(ve){ve.preventDefault(),ve.dataTransfer.types.includes("Files")&&f(!0)},e[17]=f,e[18]=A):A=e[18];const O=A;let L;e[19]!==f?(L=function(ve){ve.currentTarget===ve.target&&f(!1)},e[19]=f,e[20]=L):L=e[20];const P=L;let B;e[21]!==I||e[22]!==f?(B=function(ve){ve.preventDefault(),f(!1),I(ve.dataTransfer.files)},e[21]=I,e[22]=f,e[23]=B):B=e[23];const F=B;let H;e[24]!==a||e[25]!==o?(H=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[24]=a,e[25]=o,e[26]=H):H=e[26];let z;e[27]!==s.description?(z=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[27]=s.description,e[28]=z):z=e[28];let W;e[29]!==H||e[30]!==z?(W=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[H,z]}),e[29]=H,e[30]=z,e[31]=W):W=e[31];const q=u&&"border-primary ring-2 ring-primary/30",K=y.isPending&&"pointer-events-none opacity-60";let Z;e[32]!==q||e[33]!==K?(Z=ae("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",q,K),e[32]=q,e[33]=K,e[34]=Z):Z=e[34];let Y;e[35]!==x||e[36]!==b||e[37]!==g||e[38]!==m||e[39]!==a||e[40]!==_||e[41]!==p||e[42]!==h||e[43]!==d||e[44]!==y.isPending?(Y=d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"relative h-40 w-full bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&n.jsx("img",{src:d,alt:a,className:ae("h-full w-full object-contain transition-opacity",!m&&"opacity-0"),onLoad:()=>p(!0),onError:()=>_(!0)},d),g&&n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[n.jsx(Ii,{size:20}),n.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!m&&!g&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"})]}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:b}),x&&n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:x})]})]}):n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[n.jsx(Ii,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:y.isPending?"Uploading…":"Drop an image or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[35]=x,e[36]=b,e[37]=g,e[38]=m,e[39]=a,e[40]=_,e[41]=p,e[42]=h,e[43]=d,e[44]=y.isPending,e[45]=Y):Y=e[45];let G;e[46]!==u?(G=u&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[46]=u,e[47]=G):G=e[47];let Q;e[48]!==P||e[49]!==O||e[50]!==F||e[51]!==Z||e[52]!==Y||e[53]!==G?(Q=n.jsxs("div",{onDragOver:O,onDragLeave:P,onDrop:F,className:Z,children:[Y,G]}),e[48]=P,e[49]=O,e[50]=F,e[51]=Z,e[52]=Y,e[53]=G,e[54]=Q):Q=e[54];let $;e[55]!==R?($=be=>R(be.target.value),e[55]=R,e[56]=$):$=e[56];let X;e[57]!==o||e[58]!==d||e[59]!==$?(X=n.jsx(ze,{id:o,type:"url",value:d,onChange:$,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[57]=o,e[58]=d,e[59]=$,e[60]=X):X=e[60];let V;e[61]!==h?(V=()=>h(!0),e[61]=h,e[62]=V):V=e[62];let se;e[63]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(Kn,{size:14}),e[63]=se):se=e[63];const ee=d?"Replace":"Browse";let le;e[64]!==V||e[65]!==ee?(le=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:V,className:"h-9 shrink-0",children:[se,ee]}),e[64]=V,e[65]=ee,e[66]=le):le=e[66];let ce;e[67]!==R||e[68]!==d?(ce=d&&n.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>R(""),className:"h-9 shrink-0","aria-label":"Remove image",children:n.jsx(es,{size:14})}),e[67]=R,e[68]=d,e[69]=ce):ce=e[69];let fe;e[70]!==X||e[71]!==le||e[72]!==ce?(fe=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[X,le,ce]}),e[70]=X,e[71]=le,e[72]=ce,e[73]=fe):fe=e[73];let J;e[74]!==R?(J=be=>R(be),e[74]=R,e[75]=J):J=e[75];const te=N?.id??null;let oe;e[76]!==c||e[77]!==h||e[78]!==J||e[79]!==te?(oe=n.jsx(bm,{open:c,onOpenChange:h,mode:"image",onSelect:J,lockedConfigId:te}),e[76]=c,e[77]=h,e[78]=J,e[79]=te,e[80]=oe):oe=e[80];let de;return e[81]!==W||e[82]!==Q||e[83]!==fe||e[84]!==oe?(de=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[W,Q,fe,oe]}),e[81]=W,e[82]=Q,e[83]=fe,e[84]=oe,e[85]=de):de=e[85],de}function iw(t){return tw.has(t.type||"")}const nw="oklch(0.65 0.15 160)",rw="text-[oklch(0.45_0.15_160)] hover:bg-[oklch(0.65_0.15_160/0.12)] dark:text-[oklch(0.78_0.15_160)] dark:hover:bg-[oklch(0.65_0.15_160/0.15)]",Cm="text-[oklch(0.45_0.15_160)] bg-[oklch(0.65_0.15_160/0.18)] dark:text-[oklch(0.78_0.15_160)] dark:bg-[oklch(0.65_0.15_160/0.2)]",jE="text-[oklch(0.45_0.15_160)] focus:bg-[oklch(0.65_0.15_160/0.12)] focus:text-[oklch(0.45_0.15_160)] dark:text-[oklch(0.78_0.15_160)] dark:focus:bg-[oklch(0.65_0.15_160/0.15)] dark:focus:text-[oklch(0.78_0.15_160)]";function Cd(t){return t.map(e=>e.label).join(`
467
- `)}function Mo(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function ow(t){return t.map((e,s)=>({...e,index:s}))}function km(t){const e=U.c(17),{label:s,canDelete:i,dragging:r,onDuplicate:o,onDelete:a}=t,l=r?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==l?(d=ae("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",l),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=n.jsx(bl,{className:d}),e[2]=d,e[3]=c):c=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ni,{className:"h-4 w-4 shrink-0",style:{color:nw}}),e[4]=h):h=e[4];let u;e[5]!==s?(u=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==r||e[9]!==s||e[10]!==a||e[11]!==o?(f=!r&&n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":`Open actions for ${s}`,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:lw,onPointerDown:aw,children:n.jsx(Hi,{size:14})})}),n.jsxs(Kt,{align:"end",children:[n.jsxs(Ue,{onClick:p=>{p.stopPropagation(),o?.()},children:[n.jsx(as,{size:14}),"Duplicate"]}),n.jsxs(Ue,{variant:"destructive",disabled:!i,onClick:p=>{p.stopPropagation(),a?.()},children:[n.jsx(es,{size:14}),"Delete"]})]})]}),e[7]=i,e[8]=r,e[9]=s,e[10]=a,e[11]=o,e[12]=f):f=e[12];let m;return e[13]!==c||e[14]!==u||e[15]!==f?(m=n.jsxs(n.Fragment,{children:[c,h,u,f]}),e[13]=c,e[14]=u,e[15]=f,e[16]=m):m=e[16],m}function aw(t){return t.stopPropagation()}function lw(t){return t.stopPropagation()}function cw(t){const e=U.c(26),{entry:s,selected:i,canDelete:r,onSelect:o,onDuplicate:a,onDelete:l}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:dw},e[0]=s.id,e[1]=d):d=e[1];const{attributes:c,listeners:h,setNodeRef:u,transform:f,isDragging:m}=du(d);let p;e[2]!==f?(p=hu.Transform.toString(f?{...f,x:0}:null),e[2]=f,e[3]=p):p=e[3];const g=m?0:void 0;let _;e[4]!==p||e[5]!==g?(_={transform:p,opacity:g},e[4]=p,e[5]=g,e[6]=_):_=e[6];const b=_;let x;e[7]!==o?(x=N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o())},e[7]=o,e[8]=x):x=e[8];const v=m?"cursor-grabbing":"cursor-grab",y=i?Cm:rw;let S;e[9]!==v||e[10]!==y?(S=ae("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",v,y),e[9]=v,e[10]=y,e[11]=S):S=e[11];let w;e[12]!==r||e[13]!==s.label||e[14]!==l||e[15]!==a?(w=n.jsx(km,{label:s.label,canDelete:r,onDuplicate:a,onDelete:l}),e[12]=r,e[13]=s.label,e[14]=l,e[15]=a,e[16]=w):w=e[16];let C;return e[17]!==c||e[18]!==h||e[19]!==o||e[20]!==u||e[21]!==b||e[22]!==x||e[23]!==S||e[24]!==w?(C=n.jsx("div",{ref:u,style:b,...c,...h,onClick:o,onKeyDown:x,className:S,children:w}),e[17]=c,e[18]=h,e[19]=o,e[20]=u,e[21]=b,e[22]=x,e[23]=S,e[24]=w,e[25]=C):C=e[25],C}function dw(){return!1}function hw(t){const e=U.c(81),{listKey:s,variants:i,selectedIndex:r,onSelect:o,onDuplicate:a,onDelete:l,onRemoveAll:d,onReorder:c,onAdd:h}=t,u=i.length>1;let f;e[0]!==i?(f=()=>Mo(i),e[0]=i,e[1]=f):f=e[1];const[m,p]=D.useState(f),[g,_]=D.useState(null),[b,x]=D.useState(s),[v,y]=D.useState(i.length);let S;e[2]!==i?(S=()=>Cd(i),e[2]=i,e[3]=S):S=e[3];const[w,C]=D.useState(S),N=D.useRef(!1),E=Cd(i);b!==s?(x(s),y(i.length),C(E),p(Mo(i))):v!==i.length?(y(i.length),C(E),p(Mo(i))):w!==E&&(C(E),p(oe=>i.map((de,be)=>({id:oe[be]?.id??crypto.randomUUID(),index:de.index,label:de.label}))));let R;e[4]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},e[4]=R):R=e[4];let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:uu},e[5]=T):T=e[5];const k=su(wr(nu,R),wr(iu,T));let j;e[6]!==m?(j=m.map(uw),e[6]=m,e[7]=j):j=e[7];const I=j;let A;e[8]!==m?(A=oe=>{const de=String(oe.active.id);_(m.find(be=>be.id===de)??null)},e[8]=m,e[9]=A):A=e[9];const O=A;let L;e[10]!==I||e[11]!==c?(L=oe=>{_(null);const{active:de,over:be}=oe;if(!be||de.id===be.id)return;const ve=I.indexOf(String(de.id)),we=I.indexOf(String(be.id));ve===-1||we===-1||(p(De=>ow(la([...De],ve,we))),N.current=!0,requestAnimationFrame(()=>{N.current=!1}),c(ve,we))},e[10]=I,e[11]=c,e[12]=L):L=e[12];const P=L;let B;e[13]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{_(null)},e[13]=B):B=e[13];const F=B;let H,z,W,q,K,Z,Y,G,Q,$,X,V,se;if(e[14]!==u||e[15]!==m||e[16]!==I||e[17]!==P||e[18]!==O||e[19]!==h||e[20]!==l||e[21]!==a||e[22]!==d||e[23]!==o||e[24]!==r||e[25]!==k){const oe=ye=>{N.current||o(ye)};X="space-y-1 border-b p-2";let de;e[39]===Symbol.for("react.memo_cache_sentinel")?(de=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Variants"}),e[39]=de):de=e[39];let be;e[40]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Dt,{size:14}),e[40]=be):be=e[40];let ve;e[41]!==h?(ve=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Add variant",className:"size-6",onClick:h,children:be})}),e[41]=h,e[42]=ve):ve=e[42];let we;e[43]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(Ee,{children:"Add variant"}),e[43]=we):we=e[43];let De;e[44]!==ve?(De=n.jsxs(Te,{children:[ve,we]}),e[44]=ve,e[45]=De):De=e[45];let Be;e[46]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(es,{size:14}),e[46]=Be):Be=e[46];let Pe;e[47]!==d?(Pe=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove all variants",className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Be})}),e[47]=d,e[48]=Pe):Pe=e[48];let Fe;e[49]===Symbol.for("react.memo_cache_sentinel")?(Fe=n.jsx(Ee,{children:"Remove all variants"}),e[49]=Fe):Fe=e[49];let xe;e[50]!==Pe?(xe=n.jsxs(Te,{children:[Pe,Fe]}),e[50]=Pe,e[51]=xe):xe=e[51],e[52]!==De||e[53]!==xe?(V=n.jsxs("div",{className:"flex items-center justify-between",children:[de,n.jsxs("div",{className:"flex items-center gap-0.5",children:[De,xe]})]}),e[52]=De,e[53]=xe,e[54]=V):V=e[54],z=ru,Z=k,Y=ou,G=O,Q=P,$=F,H=au,q=I,K=lu,se="space-y-0.5",W=m.map(ye=>n.jsx(cw,{entry:ye,selected:ye.index===r,canDelete:u,onSelect:()=>oe(ye.index),onDuplicate:()=>a(ye.index),onDelete:()=>l(ye.index)},ye.id)),e[14]=u,e[15]=m,e[16]=I,e[17]=P,e[18]=O,e[19]=h,e[20]=l,e[21]=a,e[22]=d,e[23]=o,e[24]=r,e[25]=k,e[26]=H,e[27]=z,e[28]=W,e[29]=q,e[30]=K,e[31]=Z,e[32]=Y,e[33]=G,e[34]=Q,e[35]=$,e[36]=X,e[37]=V,e[38]=se}else H=e[26],z=e[27],W=e[28],q=e[29],K=e[30],Z=e[31],Y=e[32],G=e[33],Q=e[34],$=e[35],X=e[36],V=e[37],se=e[38];let ee;e[55]!==W||e[56]!==se?(ee=n.jsx("div",{className:se,children:W}),e[55]=W,e[56]=se,e[57]=ee):ee=e[57];let le;e[58]!==H||e[59]!==q||e[60]!==K||e[61]!==ee?(le=n.jsx(H,{items:q,strategy:K,children:ee}),e[58]=H,e[59]=q,e[60]=K,e[61]=ee,e[62]=le):le=e[62];let ce;e[63]!==g||e[64]!==u?(ce=g?n.jsx("div",{className:ae("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",Cm),children:n.jsx(km,{label:g.label,canDelete:u,dragging:!0})}):null,e[63]=g,e[64]=u,e[65]=ce):ce=e[65];let fe;e[66]!==ce?(fe=n.jsx(cu,{dropAnimation:null,children:ce}),e[66]=ce,e[67]=fe):fe=e[67];let J;e[68]!==z||e[69]!==Z||e[70]!==Y||e[71]!==G||e[72]!==Q||e[73]!==$||e[74]!==le||e[75]!==fe?(J=n.jsxs(z,{sensors:Z,collisionDetection:Y,onDragStart:G,onDragEnd:Q,onDragCancel:$,children:[le,fe]}),e[68]=z,e[69]=Z,e[70]=Y,e[71]=G,e[72]=Q,e[73]=$,e[74]=le,e[75]=fe,e[76]=J):J=e[76];let te;return e[77]!==X||e[78]!==V||e[79]!==J?(te=n.jsxs("div",{className:X,children:[V,J]}),e[77]=X,e[78]=V,e[79]=J,e[80]=te):te=e[80],te}function uw(t){return t.id}const fw=[[/always|matchalways/i,"Users03"],[/device|matchdevice/i,"Phone02"],[/date|matchdate/i,"Calendar"],[/random|matchrandom/i,"Shuffle01"],[/host|matchhost/i,"Globe02"],[/location|matchlocation/i,"MarkerPin01"],[/pathname/i,"Link03"],[/cron|matchcron/i,"Clock"],[/multi|matchmulti/i,"FilterLines"],[/never|matchnever/i,"EyeOff"],[/environment|matchenvironment/i,"Cloud01"],[/eq\.ts|\/eq$/i,"Brackets"],[/user|requser|isdecouser/i,"User01"],[/site|template/i,"LayoutAlt01"]],mw={"device-mobile":"Phone02","device-desktop":"Monitor01","device-tablet":"Tablet01","calendar-event":"Calendar","calendar-month":"Calendar",clock:"Clock","current-location":"MarkerPin01","map-2":"MarkerPin01","world-search":"Globe02",shuffle:"Shuffle01",filter:"FilterLines","eye-off":"EyeOff",flask:"Beaker02",link:"Link03","git-merge":"GitBranch01",users:"Users03",flag:"Flag01","cloud-storm":"Cloud01",campaign:"Announcement01",experiment:"Beaker02",language:"Globe02","hand-click":"CursorClick01"};function $o(t){return ci(t)!==void 0}function jm(t,e){if(e){if($o(e))return e;const s=mw[e];if(s&&$o(s))return s}for(const[s,i]of fw)if(s.test(t)&&$o(i))return i;return"FilterLines"}function pw(t){return ci(t)??A1}function kd(t){const e=U.c(11),{iconName:s,size:i,className:r}=t,o=i===void 0?"md":i;let a;e[0]!==s?(a=pw(s),e[0]=s,e[1]=a):a=e[1];const l=a,d=o==="sm"?"size-7":"size-9",c=o==="sm"?16:18;let h;e[2]!==d||e[3]!==r?(h=ae("flex shrink-0 items-center justify-center rounded-full bg-muted",d,r),e[2]=d,e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==c?(u=n.jsx(l,{size:c,className:"text-muted-foreground"}),e[5]=l,e[6]=c,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=n.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const Nm="Users03";function gw(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("matchers"))for(const o of Object.keys(r)){if(o.includes("always"))continue;const a=fi(o,t);s.push({resolveType:o,title:a.title??ut(o),description:a.description,iconName:jm(o,a.icon)})}return s}function _w(t,e){if(!t)return Nm;const s=e.find(i=>i.resolveType===t);return s?s.iconName:jm(t)}function vw(t){const e=U.c(41),{currentRt:s,currentLabel:i,matchers:r,onSelect:o}=t,[a,l]=D.useState(!1);let d;if(e[0]!==s||e[1]!==r){const j=_w(s,r);d=ci(j),e[0]=s,e[1]=r,e[2]=d}else d=e[2];const c=d;let h;e[3]!==o?(h=j=>{o(j),l(!1)},e[3]=o,e[4]=h):h=e[4];const u=h;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(!0),e[5]=f):f=e[5];let m;e[6]!==c?(m=c&&n.jsx(c,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[6]=c,e[7]=m):m=e[7];let p;e[8]!==i?(p=n.jsx("span",{className:"flex-1 truncate",children:i}),e[8]=i,e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(cs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[10]=g):g=e[10];let _;e[11]!==m||e[12]!==p?(_=n.jsxs("button",{type:"button",onClick:f,className:"flex h-10 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-left text-sm shadow-xs transition-colors hover:bg-accent/40 cursor-pointer",children:[m,p,g]}),e[11]=m,e[12]=p,e[13]=_):_=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Nl,{placeholder:"Search rules..."}),e[14]=b):b=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(El,{children:"No rules found."}),e[15]=x):x=e[15];let v;e[16]!==u?(v=()=>u(""),e[16]=u,e[17]=v):v=e[17];const y=!s&&"bg-accent/60";let S;e[18]!==y?(S=ae("gap-2.5",y),e[18]=y,e[19]=S):S=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(kd,{iconName:Nm,size:"sm"}),e[20]=w):w=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:"Always"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Target all users"})]}),e[21]=C):C=e[21];let N;e[22]!==v||e[23]!==S?(N=n.jsxs(Or,{value:"always Target all users",onSelect:v,className:S,children:[w,C]}),e[22]=v,e[23]=S,e[24]=N):N=e[24];let E;if(e[25]!==s||e[26]!==u||e[27]!==r){let j;e[29]!==s||e[30]!==u?(j=I=>n.jsxs(Or,{value:`${I.title} ${I.resolveType} ${I.description??""}`,onSelect:()=>u(I.resolveType),className:ae("gap-2.5",s===I.resolveType&&"bg-accent/60"),children:[n.jsx(kd,{iconName:I.iconName,size:"sm"}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:I.title}),I.description&&n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:I.description})]})]},I.resolveType),e[29]=s,e[30]=u,e[31]=j):j=e[31],E=r.map(j),e[25]=s,e[26]=u,e[27]=r,e[28]=E}else E=e[28];let R;e[32]!==N||e[33]!==E?(R=n.jsxs(Tl,{children:[x,n.jsxs(Br,{children:[N,E]})]}),e[32]=N,e[33]=E,e[34]=R):R=e[34];let T;e[35]!==a||e[36]!==R?(T=n.jsxs(N1,{open:a,onOpenChange:l,title:"Choose a rule",description:"Pick how to target users for this variant",className:"sm:max-w-lg",children:[b,R]}),e[35]=a,e[36]=R,e[37]=T):T=e[37];let k;return e[38]!==T||e[39]!==_?(k=n.jsxs(n.Fragment,{children:[_,T]}),e[38]=T,e[39]=_,e[40]=k):k=e[40],k}const xw=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),bw=5,yw=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function jd(t){const{start:e,end:s}=t,i=typeof e=="string"?e:"",r=typeof s=="string"?s:"";if(!i&&!r)return null;const o=d=>{if(!d)return null;const c=new Date(d);return Number.isNaN(c.getTime())?null:yw.format(c)},a=o(i),l=o(r);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function hc(t,e=0){if(!t)return"Default";if(e>bw)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:r,tablet:o,desktop:a,devices:l=[]}=t,d=[...l];return r&&d.push("Mobile"),o&&d.push("Tablet"),a&&d.push("Desktop"),d.length>0?d.map(xw).join(" & "):ut(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return jd(t)??ut(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:r}=t;return typeof r=="number"?`${Math.ceil(r*100)}% of sessions`:ut(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:r,match:o}=t,a=[];return r&&a.push(r),o&&a.push(o),a.length>0?a.join(" - "):ut(s)}case"website/matchers/pathname.ts":{const r=t.case,{type:o,pathname:a}=r??{};return o&&a?`Pathname ${o} ${a}`:ut(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:r,excludeLocations:o}=t,a=c=>[c.city,c.regionCode,c.country].filter(Boolean).join(" - "),l=r?.[0];if(l){const c=(r?.length??0)-1;return`${a(l)}${c>0?` +${c}`:""}`}const d=o?.[0];if(d){const c=(o?.length??0)-1;return`Except ${a(d)}${c>0?` +${c}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:r,op:o="AND"}=t;if(r&&r.length>0){const a=o==="OR"?"OR":"AND";return r.map(l=>hc(l,e+1)).join(` ${a} `)}return ut(s)}default:{const r=jd(t);return r||ut(s)||"Default"}}}function Sw(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function ww(t,e){return{__resolveType:e,variants:[{rule:Li(),value:structuredClone(t)},{rule:Li(),value:structuredClone(t)}]}}function Cw(t){const e=t.variants;if(e.length===0)return;const s=e.find(i=>sc(i.rule));return s?s.value:e[e.length-1]?.value}function kw(t){const e=[...t.variants],s=e[e.length-1],i={rule:Li(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,i]}}function jw(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function Nw(t,e){const s=[...t.variants],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function Ew(t,e,s){const i=[...t.variants];if(e===s||e<0||s<0||e>=i.length||s>=i.length)return t;const[r]=i.splice(e,1);return r?(i.splice(s,0,r),{...t,variants:i}):t}function Tw(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,value:s},{...t,variants:i}):t}function Nd(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,rule:s},{...t,variants:i}):t}const Ed=new WeakMap,Td=new Map;function Aw(t){let e=Ed.get(t);return e||(e=gw(t),Ed.set(t,e)),e}function Rw(t,e){let s=Td.get(t);return s===void 0&&(s=Us(t,e),Td.set(t,s)),s}function Pw(t){const e=U.c(3),{multivariateResolveType:s,renderInnerField:i,...r}=t,{value:o,onChange:a,meta:l,path:d}=r,[c,h]=D.useState(0);if(!Sw(o)){let L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Tu,{size:14}),e[0]=L):L=e[0];let P;return e[1]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Ee,{children:"Add variant"}),e[1]=P):P=e[1],n.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":"Add variant",onClick:()=>{a(ww(o,s)),h(0)},children:L})}),P]}),i(r)]})}const u=o,f=u.variants,m=Math.min(c,f.length-1),p=f.map(Dw),g=f[m],_=g?.rule??{},b=_.__resolveType??"",x=g?.value,v=l?Aw(l):[],y=b&&l?Rw(b,l):null,{__resolveType:S,...w}=_,C=()=>{a(Cw(u)),h(0)},N=()=>{const L=kw(u);a(L),h(L.variants.length-1)},E=L=>{const P=jw(u,L);P&&(a(P),m>=P.variants.length&&h(P.variants.length-1))},R=L=>{const P=Nw(u,L);a(P),h(L+1)},T=(L,P)=>{const B=Ew(u,L,P);a(B),m===L&&h(P)},k=L=>{a(Nd(u,m,L?{__resolveType:L}:{__resolveType:cf}))},j=L=>{const P=L,B=b?{...P,__resolveType:b}:{...P};a(Nd(u,m,B))},I=L=>{a(Tw(u,m,L))},A=`${d}-${u.__resolveType}`;let O;return e[2]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ve,{className:"text-xs text-muted-foreground",children:"Rule"}),e[2]=O):O=e[2],n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[n.jsx(hw,{listKey:A,variants:p,selectedIndex:m,onSelect:h,onDuplicate:R,onDelete:E,onRemoveAll:C,onReorder:T,onAdd:N}),n.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[O,n.jsx(vw,{currentRt:b,currentLabel:hc(_),matchers:v,onSelect:k}),y&&n.jsx("div",{className:"pt-1",children:n.jsx(Zi,{schema:y,value:w,onChange:j,basePath:""})})]}),i({...r,value:x,onChange:I})]})]})}function Dw(t,e){return{index:e,label:hc(t.rule)||`Variant ${e+1}`}}const Iw="website/loaders/secret.ts";function Nn(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t.__resolveType;return typeof e=="string"&&(e.endsWith("/secret.ts")||e.includes("loaders/secret"))}function Lw(){return{__resolveType:Iw,name:"",encrypted:""}}function Ow(t){const{value:e,...s}=t;return s}function zo(t){const e=U.c(45),{schema:s,value:i,onChange:r,label:o,path:a}=t;if(typeof i=="string"||i==null&&!Nn(i)){const C=typeof i=="string"?i:"";let N;e[0]!==o||e[1]!==a?(N=n.jsx(Ve,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=N):N=e[2];let E;e[3]!==s.description?(E=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=E):E=e[4];let R;e[5]!==r?(R=j=>r(j.target.value),e[5]=r,e[6]=R):R=e[6];let T;e[7]!==a||e[8]!==C||e[9]!==R?(T=n.jsx(ze,{id:a,type:"password",value:C,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:"Secret value",onChange:R,className:"h-10"}),e[7]=a,e[8]=C,e[9]=R,e[10]=T):T=e[10];let k;return e[11]!==N||e[12]!==E||e[13]!==T?(k=n.jsxs("div",{className:"space-y-2",children:[N,E,T]}),e[11]=N,e[12]=E,e[13]=T,e[14]=k):k=e[14],k}let l;e[15]!==i?(l=Nn(i)?i:Lw(),e[15]=i,e[16]=l):l=e[16];const d=l,c=typeof d.name=="string"?d.name:"",h=typeof d.encrypted=="string"&&d.encrypted,u=`${a}-name`;let f;e[17]!==o||e[18]!==u?(f=n.jsx(Ve,{htmlFor:u,className:"text-sm font-medium",children:o}),e[17]=o,e[18]=u,e[19]=f):f=e[19];let m;e[20]!==s.description?(m=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=m):m=e[21];const p=`${a}-name`;let g;e[22]!==d||e[23]!==r?(g=C=>r({...d,name:C.target.value}),e[22]=d,e[23]=r,e[24]=g):g=e[24];let _;e[25]!==c||e[26]!==p||e[27]!==g?(_=n.jsx(ze,{id:p,value:c,placeholder:"Secret name",onChange:g,className:"h-10"}),e[25]=c,e[26]=p,e[27]=g,e[28]=_):_=e[28];const b=`${a}-value`,x=h?"Leave blank to keep current value":"Secret value";let v;e[29]!==d||e[30]!==h||e[31]!==r?(v=C=>{const N=C.target.value;if(!N){r(h?Ow(d):d);return}r({...d,value:N})},e[29]=d,e[30]=h,e[31]=r,e[32]=v):v=e[32];let y;e[33]!==v||e[34]!==b||e[35]!==x?(y=n.jsx(ze,{id:b,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:x,onChange:v,className:"h-10"}),e[33]=v,e[34]=b,e[35]=x,e[36]=y):y=e[36];let S;e[37]!==h?(S=h&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A secret value is stored."}),e[37]=h,e[38]=S):S=e[38];let w;return e[39]!==y||e[40]!==S||e[41]!==f||e[42]!==m||e[43]!==_?(w=n.jsxs("div",{className:"space-y-2",children:[f,m,_,y,S]}),e[39]=y,e[40]=S,e[41]=f,e[42]=m,e[43]=_,e[44]=w):w=e[44],w}function Bw(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[i,r]of Object.entries(e))i.startsWith("__")||(typeof r=="string"?s[i]={type:"string"}:typeof r=="number"?s[i]={type:"number"}:typeof r=="boolean"&&(s[i]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const Mw=new Set(["__resolveType","@type"]);function $w(t){if(t.type!=="block-ref"||!t.anyOfRefs?.length||t.anyOfRefs.length!==1)return!1;const e=t.anyOfRefs[0].schema;return!!(e?.properties?.variants||!e&&t.plainSchema)}function zw(t){if(mo(t))for(const e of t.anyOfRefs??[]){const r=e.schema?.properties?.variants?.items?.properties?.value;if(r?.type==="array"&&r.items)return r.items}}function Ad(t){if(t.type==="array"&&t.items)return t;const e=t.items??zw(t);return e?{...t,type:"array",items:e}:null}function Fw(t,e){if(e!==void 0)return e;switch(t){case"string":return"";case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return null}}function uc(t){const{schema:e,value:s}=t;if(Ur(s)){const a=_0(s),l=Ad(e);if(a!==null&&l)return n.jsx(ar,{...t,schema:l,value:a,onChange:d=>t.onChange(v0(s,d))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&mo(e)){const a=Ad(e);if(a)return n.jsx(ar,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!Ur(s)&&e.type==="block-ref"){const a=Bw(s);if(a){const l={...e,type:"array",items:a};return n.jsx(ar,{...t,schema:l,value:s,onChange:t.onChange},t.path)}}if(e.type==="block-ref"||s!==null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&e.anyOfRefs){if($w(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,d=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},c=h=>uc({...h,schema:d});return n.jsx(Pw,{...t,multivariateResolveType:a.resolveType,renderInnerField:c},t.path)}return e.anyOfRefs?n.jsx(xd,{...t},t.path):null}if(e.format==="image-uri")return n.jsx(sw,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return n.jsx(JS,{...t},t.path);if(e.format==="dynamic-options"&&e.options)return n.jsx(TS,{...t},t.path);if(e.enum&&e.enum.length>0)return n.jsx(F2,{...t},t.path);if(e.type==="anyOf")return n.jsx(xd,{...t},t.path);if(Nn(s)||e.format==="password"||s==null&&e.format==="password")return n.jsx(zo,{...t},t.path);const i=s??Fw(e.type,e.default);if(i==null)return Nn(s)?n.jsx(zo,{...t},t.path):null;if(Nn(i))return n.jsx(zo,{...t,value:i},t.path);const r={...t,value:i},o=s==null?e.type??typeof i:Array.isArray(i)?"array":typeof i;if(o==="array"||Array.isArray(i))return n.jsx(ar,{...r},t.path);switch(o){case"boolean":return n.jsx(B2,{...r},t.path);case"number":case"integer":return n.jsx(O2,{...r},t.path);case"string":{const a=e.format;return a==="color-input"?n.jsx(rr,{...r},t.path):a==="textarea"||a==="rich-text"||a==="html"?n.jsx(rr,{...r},t.path):n.jsx(rr,{...r},t.path)}case"object":return i!==null&&typeof i=="object"&&!Array.isArray(i)?n.jsx(_S,{...r},t.path):null;default:return n.jsx(rr,{...r},t.path)}}function Zi(t){const e=U.c(16),{schema:s,value:i,onChange:r,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:d,decofile:c,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,_;if(e[0]!==o||e[1]!==c||e[2]!==d||e[3]!==f||e[4]!==l||e[5]!==r||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s.properties||e[11]!==a||e[12]!==i){_=Symbol.for("react.early_return_sentinel");e:{const b=a===void 0?[]:a,x=s.properties;if(!x){_=null;break e}const v=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},y=Object.keys(x).filter(T=>!Mw.has(T)&&x[T]?.hidden!==!0);if(y.length===0){let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[15]=T):T=e[15],_=T;break e}const S=(T,k)=>{r({...v,[T]:k})},w=typeof v.__resolveType=="string"?v.__resolveType:void 0,C=b.length>0?iS(y,x,v,b):null,N=C?x[C]:null,E=C&&N?[C]:y,R=C&&N?tS(C,N,b):b;g=n.jsx("div",{className:"min-w-0 space-y-6",children:E.map(T=>{const k=x[T];if(!k)return null;const j=o?`${o}.${T}`:T,I=jn(T,k);return uc({schema:k,value:v[T],onChange:A=>S(T,A),path:j,label:I,breadcrumbPath:R,onBreadcrumbChange:l,meta:d,decofile:c,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=c,e[2]=d,e[3]=f,e[4]=l,e[5]=r,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s.properties,e[11]=a,e[12]=i,e[13]=g,e[14]=_}else g=e[13],_=e[14];return _!==Symbol.for("react.early_return_sentinel")?_:g}function Hw(t){const e=U.c(37),{open:s,onOpenChange:i,defaultBlockId:r,isPending:o,onSubmit:a}=t,l=r===void 0?"":r,d=o===void 0?!1:o,[c,h]=D.useState(l),[u,f]=D.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==d||e[1]!==i?(m=j=>{!j&&!d&&i(!1)},e[0]=d,e[1]=i,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async j=>{j.preventDefault();const I=c.trim();!I||d||await a(I)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const _=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsxs(ts,{children:[n.jsx(ss,{children:"Save as global"}),n.jsx(Wi,{children:"Save this section as a global block so it can be reused on other pages."})]}),e[7]=b):b=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:"Block name"}),e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=j=>h(j.target.value),e[9]=v):v=e[9];let y;e[10]!==c||e[11]!==d?(y=n.jsxs("div",{className:"py-4 space-y-2",children:[x,n.jsx(ze,{id:"block-id",value:c,onChange:v,placeholder:"MyNewBlock",autoFocus:!0,disabled:d})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let S;e[13]!==i?(S=()=>i(!1),e[13]=i,e[14]=S):S=e[14];let w;e[15]!==d||e[16]!==S?(w=n.jsx(ie,{type:"button",variant:"outline",onClick:S,disabled:d,children:"Cancel"}),e[15]=d,e[16]=S,e[17]=w):w=e[17];let C;e[18]!==c||e[19]!==d?(C=!c.trim()||d,e[18]=c,e[19]=d,e[20]=C):C=e[20];let N;e[21]!==d?(N=d?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[21]=d,e[22]=N):N=e[22];let E;e[23]!==C||e[24]!==N?(E=n.jsx(ie,{type:"submit",disabled:C,children:N}),e[23]=C,e[24]=N,e[25]=E):E=e[25];let R;e[26]!==w||e[27]!==E?(R=n.jsxs(Ws,{children:[w,E]}),e[26]=w,e[27]=E,e[28]=R):R=e[28];let T;e[29]!==_||e[30]!==R||e[31]!==y?(T=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:_,children:[b,y,R]})}),e[29]=_,e[30]=R,e[31]=y,e[32]=T):T=e[32];let k;return e[33]!==p||e[34]!==s||e[35]!==T?(k=n.jsx(Bt,{open:s,onOpenChange:p,children:T}),e[33]=p,e[34]=s,e[35]=T,e[36]=k):k=e[36],k}function Uw(t){const e=U.c(60),{orgSlug:s,virtualMcpId:i,branch:r,previewUrl:o,meta:a,decofile:l,resolveType:d,title:c,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=gi(),g=p?.entity?.id===i?p.entity.metadata?.siteSlug??null:null;let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];const[b,x]=D.useState(_);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[1]=v):v=e[1];const[y,S]=D.useState(v),[w,C]=D.useState(0),[N,E]=D.useState(!1);let R;e[2]!==a||e[3]!==d?(R=Us(d,a),e[2]=a,e[3]=d,e[4]=R):R=e[4];const T=R;let k;e[5]!==d?(k=d.split("/").pop()?.replace(/\.tsx?$/,"")??d,e[5]=d,e[6]=k):k=e[6];const j=k,I=o??void 0;let A;e[7]!==g||e[8]!==r||e[9]!==s||e[10]!==I||e[11]!==i?(A={orgSlug:s,virtualMcpId:i,branch:r,previewUrl:I,siteSlug:g},e[7]=g,e[8]=r,e[9]=s,e[10]=I,e[11]=i,e[12]=A):A=e[12];const O=A;let L;e[13]!==y||e[14]!==c?(L=[c,...y],e[13]=y,e[14]=c,e[15]=L):L=e[15];const P=L;let B;e[16]!==y?(B=ce=>{S(y.slice(0,ce)),C(Ww)},e[16]=y,e[17]=B):B=e[17];const F=B;let H;e[18]!==l||e[19]!==b||e[20]!==f?(H=async ce=>{const fe=y2(ce,l);if(fe){he.error(fe);return}await f(ce,b),E(!1)},e[18]=l,e[19]=b,e[20]=f,e[21]=H):H=e[21];const z=H;let W;e[22]!==F||e[23]!==P?(W=n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:P.map((ce,fe)=>{const J=fe===P.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[fe>0&&n.jsx(Vi,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>F(fe),title:ce,className:ae("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",J?"font-medium text-foreground":"text-muted-foreground"),children:ce})]},`${ce}-${fe}`)})}),e[22]=F,e[23]=P,e[24]=W):W=e[24];let q;e[25]===Symbol.for("react.memo_cache_sentinel")?(q=()=>E(!0),e[25]=q):q=e[25];let K;e[26]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Nu,{size:14}),e[26]=K):K=e[26];let Z;e[27]!==u?(Z=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:q,"aria-label":"Save as global section",children:K})}),e[27]=u,e[28]=Z):Z=e[28];let Y;e[29]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx(Ee,{side:"bottom",children:"Save as global section"}),e[29]=Y):Y=e[29];let G;e[30]!==Z?(G=n.jsxs(Te,{children:[Z,Y]}),e[30]=Z,e[31]=G):G=e[31];let Q;e[32]!==W||e[33]!==G?(Q=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[W,G]}),e[32]=W,e[33]=G,e[34]=Q):Q=e[34];let $;e[35]!==j?($=n.jsxs("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:[j," — edits stay local until you save this as a global section."]}),e[35]=j,e[36]=$):$=e[36];let X;e[37]!==Q||e[38]!==$?(X=n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[Q,$]}),e[37]=Q,e[38]=$,e[39]=X):X=e[39];let V;e[40]!==l||e[41]!==y||e[42]!==w||e[43]!==b||e[44]!==a||e[45]!==m||e[46]!==O||e[47]!==T?(V=n.jsx(Fi,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:T?n.jsx(Zi,{schema:T,value:b,onChange:ce=>x(ce),basePath:"",breadcrumbPath:y,onBreadcrumbChange:S,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:O},w):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),e[40]=l,e[41]=y,e[42]=w,e[43]=b,e[44]=a,e[45]=m,e[46]=O,e[47]=T,e[48]=V):V=e[48];let se;e[49]!==X||e[50]!==V?(se=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[X,V]}),e[49]=X,e[50]=V,e[51]=se):se=e[51];let ee;e[52]!==h||e[53]!==z||e[54]!==u||e[55]!==N?(ee=n.jsx(Hw,{open:N,onOpenChange:E,defaultBlockId:h,isPending:u,onSubmit:z}),e[52]=h,e[53]=z,e[54]=u,e[55]=N,e[56]=ee):ee=e[56];let le;return e[57]!==se||e[58]!==ee?(le=n.jsxs("div",{className:"flex h-full w-full min-w-0",children:[se,ee]}),e[57]=se,e[58]=ee,e[59]=le):le=e[59],le}function Ww(t){return t+1}function Vw(t,e){const s={__resolveType:t},i=Xf([s],e)[0];return i?bS(s,i,e):null}function Kw({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:r,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const d=gi(),c=d?.entity?.id===e?d.entity.metadata?.siteSlug??null:null,[h]=D.useState(()=>Vw(a,o)),[u,f]=D.useState(h?.data??{}),[m,p]=D.useState([]),[g,_]=D.useState(0),[b,x]=D.useState(!1),[v,y]=D.useState(null),S=v!==null,{save:w,flush:C}=k0({orgSlug:t,virtualMcpId:e,branch:s}),N=h?.resolveType?Us(h.resolveType,r):null,E=o[a],R=E?Kl(a,E):a,T={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i??void 0,siteSlug:c},k=L=>{f(L),w(a,L)},j=()=>{S?(y(null),x(!1),_(L=>L+1)):y(JSON.stringify(u,null,2))},I=L=>{const P=L??"";try{const B=JSON.parse(P);if(B&&typeof B=="object"&&!Array.isArray(B)){x(!1),k(B);return}x(!0)}catch{x(!0)}},A=[R,...m],O=L=>{p(m.slice(0,L)),_(P=>P+1)};return n.jsx("div",{className:"flex h-full w-full min-w-0",children:n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[n.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:lf},"aria-hidden":!0}),n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:A.map((L,P)=>{const B=P===A.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[P>0&&n.jsx(Vi,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>O(P),title:L,className:ae("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",B?"font-medium text-foreground":"text-muted-foreground"),children:L})]},`${L}-${P}`)})}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:S?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:j,"aria-label":S?"Close JSON editor":"Edit as JSON","aria-pressed":S,children:S?n.jsx(jl,{size:14}):n.jsx(no,{size:14})})}),n.jsx(Ee,{side:"bottom",children:S?"Close JSON editor":"Edit as JSON"})]})]}),n.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:"Global section — changes save automatically and apply everywhere it's used."})]}),n.jsxs("div",{className:"relative min-h-0 flex-1",children:[n.jsx(Fi,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:N?n.jsx(Zi,{schema:N,value:u,onChange:L=>k(L),basePath:"",breadcrumbPath:m,onBreadcrumbChange:p,meta:r,decofile:o,onSaveReferencedBlock:l,sandbox:T},g):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),v!==null&&n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[b&&n.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Gu,{language:"json",height:"100%",code:v,onChange:I,onSave:L=>{I(L),C()}})})]})]})]})})}function Rd(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 qw(t,e){const s=Ti,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 Gw(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 Yw(t){const e=ic(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function Xw(t,e){return im(t,e)}const Jw=1e3;function Zw(t,e){for(let s=0;s<Jw;s++){const i=ic(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Qw={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},eC={create:"Create",duplicate:"Duplicate",rename:"Save"},tC={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function sC(t){const e=U.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:d,onSubmit:c,onOpenChange:h}=t,u=a===void 0?!1:a,[f,m]=D.useState(r),[p,g]=D.useState(o),[_,b]=D.useState(null),[x,v]=D.useState(s);s!==x&&(v(s),s&&(m(r),g(o),b(null)));let y;e[0]!==u||e[1]!==h?(y=Y=>{!Y&&!u&&(b(null),h(!1))},e[0]=u,e[1]=h,e[2]=y):y=e[2];const S=y;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==d?(w=async Y=>{Y.preventDefault();const G=f.trim(),Q=p.trim();if(!G||!Q||u)return;const $=Hl(Q);if($){b($);return}const X=d?.({name:G,path:Q});if(X){b(X);return}b(null),await c({name:G,path:Q})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=d,e[8]=w):w=e[8];const C=w,N=_??l,E=Qw[i];let R;e[9]!==E?(R=n.jsx(ts,{children:n.jsx(ss,{children:E})}),e[9]=E,e[10]=R):R=e[10];let T;e[11]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=T):T=e[11];let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=Y=>m(Y.target.value),e[12]=k):k=e[12];let j;e[13]!==u||e[14]!==f?(j=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(ze,{id:"page-form-name",value:f,onChange:k,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=j):j=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=I):I=e[16];let A;e[17]===Symbol.for("react.memo_cache_sentinel")?(A=Y=>g(Y.target.value),e[17]=A):A=e[17];let O;e[18]!==u||e[19]!==p?(O=n.jsxs("div",{className:"space-y-1.5",children:[I,n.jsx(ze,{id:"page-form-path",value:p,onChange:A,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=O):O=e[20];let L;e[21]!==N?(L=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=L):L=e[22];let P;e[23]!==O||e[24]!==L||e[25]!==j?(P=n.jsxs("div",{className:"space-y-4 py-4",children:[j,O,L]}),e[23]=O,e[24]=L,e[25]=j,e[26]=P):P=e[26];let B;e[27]!==h?(B=()=>h(!1),e[27]=h,e[28]=B):B=e[28];let F;e[29]!==u||e[30]!==B?(F=n.jsx(ie,{type:"button",variant:"outline",onClick:B,disabled:u,children:"Cancel"}),e[29]=u,e[30]=B,e[31]=F):F=e[31];let H;e[32]!==u||e[33]!==f||e[34]!==p?(H=!f.trim()||!p.trim()||u,e[32]=u,e[33]=f,e[34]=p,e[35]=H):H=e[35];let z;e[36]!==u||e[37]!==i?(z=u?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),tC[i]]}):eC[i],e[36]=u,e[37]=i,e[38]=z):z=e[38];let W;e[39]!==H||e[40]!==z?(W=n.jsx(ie,{type:"submit",disabled:H,children:z}),e[39]=H,e[40]=z,e[41]=W):W=e[41];let q;e[42]!==F||e[43]!==W?(q=n.jsxs(Ws,{children:[F,W]}),e[42]=F,e[43]=W,e[44]=q):q=e[44];let K;e[45]!==C||e[46]!==P||e[47]!==q||e[48]!==R?(K=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:C,children:[R,P,q]})}),e[45]=C,e[46]=P,e[47]=q,e[48]=R,e[49]=K):K=e[49];let Z;return e[50]!==S||e[51]!==s||e[52]!==K?(Z=n.jsx(Bt,{open:s,onOpenChange:S,children:K}),e[50]=S,e[51]=s,e[52]=K,e[53]=Z):Z=e[53],Z}function iC(t){const e=U.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,d=o===void 0?!1:o,[c,h]=D.useState(r),[u,f]=D.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==d||e[1]!==l?(m=O=>{!O&&!d&&l(!1)},e[0]=d,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async O=>{O.preventDefault();const L=c.trim();!L||d||await a(L)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const _=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsxs(ts,{children:[n.jsx(ss,{children:"Rename section"}),n.jsx(Wi,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=b):b=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=O=>h(O.target.value),e[9]=v):v=e[9];let y;e[10]!==d||e[11]!==c?(y=n.jsxs("div",{className:"space-y-1.5",children:[x,n.jsx(ze,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:d})]}),e[10]=d,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 w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(ze,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let C;e[16]!==y||e[17]!==w?(C=n.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=C):C=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let E;e[21]!==d||e[22]!==N?(E=n.jsx(ie,{type:"button",variant:"outline",onClick:N,disabled:d,children:"Cancel"}),e[21]=d,e[22]=N,e[23]=E):E=e[23];let R;e[24]!==d||e[25]!==c?(R=!c.trim()||d,e[24]=d,e[25]=c,e[26]=R):R=e[26];let T;e[27]!==d?(T=d?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=d,e[28]=T):T=e[28];let k;e[29]!==R||e[30]!==T?(k=n.jsx(ie,{type:"submit",disabled:R,children:T}),e[29]=R,e[30]=T,e[31]=k):k=e[31];let j;e[32]!==E||e[33]!==k?(j=n.jsxs(Ws,{children:[E,k]}),e[32]=E,e[33]=k,e[34]=j):j=e[34];let I;e[35]!==_||e[36]!==C||e[37]!==j?(I=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:_,children:[b,C,j]})}),e[35]=_,e[36]=C,e[37]=j,e[38]=I):I=e[38];let A;return e[39]!==p||e[40]!==s||e[41]!==I?(A=n.jsx(Bt,{open:s,onOpenChange:p,children:I}),e[39]=p,e[40]=s,e[41]=I,e[42]=A):A=e[42],A}const Fo={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},fc=["posts","authors","categories"],En={posts:"post",authors:"author",categories:"category"};function Tn(t){return fc.includes(t)}const mc={posts:"post",authors:"author",categories:"category"},Em={posts:Fo.post,authors:Fo.author,categories:Fo.category},nC=Object.fromEntries(Object.entries(Em).map(([t,e])=>[e,t]));function rC(t){return typeof t=="string"?nC[t]??null:null}function Oi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function rs(t){return typeof t=="string"?t:""}function oC(t,e){switch(t){case"posts":return{label:rs(e.title)||"Untitled post",subtitle:rs(e.slug)};case"authors":return{label:rs(e.name)||"Unnamed author",subtitle:rs(e.email)};case"categories":return{label:rs(e.name)||"Unnamed category",subtitle:rs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function Tm(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=Oi(i);if(!r)continue;const o=rC(r.__resolveType);if(!o)continue;const a=Oi(r[mc[o]])??{},{label:l,subtitle:d}=oC(o,a);e[o].push({key:s,kind:o,label:l,subtitle:d})}for(const s of fc)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function aC(t,e){return Tm(t)[e]}function Kr(t,e){return aC(t,e).map(s=>({key:s.key,payload:Sa(Oi(t[s.key])??void 0,e)}))}function Sa(t,e){return t?Oi(t[mc[e]])??{}:{}}function Ho(t,e,s){return{name:t,__resolveType:Em[e],[mc[e]]:s}}function Am(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function qr(t){return Array.isArray(t)?t:[]}function pc(t){if(typeof t=="string")return t;const e=Oi(t);return e?rs(e.slug):""}function lC(t){if(typeof t=="string")return t;const e=Oi(t);return e?rs(e.email):""}function cC(t){return Kr(t,"posts").map(({key:e,payload:s})=>({key:e,title:rs(s.title)||"Untitled post",slug:rs(s.slug),date:rs(s.date),categorySlugs:qr(s.categories).map(pc).filter(Boolean),authorEmails:qr(s.authors).map(lC).filter(Boolean)}))}function dC(t,e){const s=qr(t.categories);return s.some(i=>pc(i)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function hC(t,e){const s=qr(t.categories);return s.length===1&&pc(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function wa(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 Pd(t,e){const s=`collections/blog/${e}/${wa(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function uC(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${wa(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-${wa(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const fC={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Dd="Box";function mC(t){return t.startsWith("site/")?"site":"app"}function pC(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function on(...t){for(const e of t)if(e!==void 0)return e}function NE(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(!vC(o)||e.has(o))continue;e.add(o);const a=fi(o,t),l=gC(o),d=fC[l],c=mC(o),h=(c==="site"?on(a.title,d?.title):on(d?.title,a.title))??l,u=c==="site"?on(a.description,d?.description):on(d?.description,a.description),f=c==="site"?a.icon:void 0,m=f&&pC(f)?f:void 0,p=m!==void 0?d?.iconName??Dd:on(f,d?.iconName)??Dd;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:c})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function gC(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const _C=["blog/sections/blocks/","site/sections/Blog/Post/"];function vC(t){return _C.some(e=>t.startsWith(e))}function Rm({orgSlug:t,virtualMcpId:e,branch:s}){return Et.decofile(`${t}/${e}/${s}`)}function Pm({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function xC(t){const e=U.c(11),s=oi();let i;e[0]!==t?(i=async l=>{const{blockKey:d,data:c}=l,h=await fetch(Pm(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:Am(d),content:JSON.stringify(c,null,2)})});if(!h.ok){const u=await h.json().catch(bC);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=i):i=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:d,data:c}=l,h=Rm(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[d]:c})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,d,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],ai(a)}function bC(){return{}}function yC(t){const e=oi();return ai({mutationFn:async({blockKey:s})=>{const i=await fetch(Pm(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:Am(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=Rm(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 SC(t){const e=U.c(20),{open:s,onOpenChange:i,pageKey:r,decofile:o}=t,[a,l]=D.useState(!1),d=o[r];let c;e[0]!==d?(c=d===void 0?"// Page not found.":JSON.stringify(d,null,2),e[0]=d,e[1]=c):c=e[1];const h=c;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ss,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?n.jsx(Yh,{size:12}):n.jsx(as,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let _;e[7]!==f||e[8]!==p||e[9]!==g?(_=n.jsxs(ts,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,n.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=_):_=e[10];let b;e[11]!==h?(b=n.jsx(Fi,{className:"max-h-[70vh]",children:n.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=b):b=e[12];let x;e[13]!==_||e[14]!==b?(x=n.jsxs(Mt,{className:"max-w-2xl p-0 gap-0",children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let v;return e[16]!==i||e[17]!==s||e[18]!==x?(v=n.jsx(Bt,{open:s,onOpenChange:i,children:x}),e[16]=i,e[17]=s,e[18]=x,e[19]=v):v=e[19],v}const Id=D.lazy(()=>ls(()=>import("./app-editor-BI1KpS86.js"),__vite__mapDeps([144,1,2,5,44,7,8,9,10,11,12,13,14,15,16,6,3,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,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,99,145,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.AppEditor}))),wC=D.lazy(()=>ls(()=>import("./post-editor-Dlb8m7Iz.js"),__vite__mapDeps([146,1,2,3,28,7,8,9,10,11,12,13,14,15,16,6,4,5,17,18,19,20,21,22,23,24,25,26,27,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,131,84,85,87,132,114,133,134,135,136,96,90,105,110,111,109,92,147,145,148,80,81,82,83,86,88,89,91,93,94,95,100,101,102,103,104,106,107,108,79,112,113,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,137,138,139,140])).then(t=>({default:t.PostEditor}))),CC=D.lazy(()=>ls(()=>import("./record-editor-BjHlAGT_.js"),__vite__mapDeps([149,1,2,77,76,92,147,33,37,145,8,6,100,56,57,54,55,58,59,60,61,62,63,64,51,65,44,7,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,35,36,38,39,40,41,42,43,45,46,47,48,49,50,52,53,66,67,68,69,70,71,72,73,74,75,78,91,88,101,102,80,81,82,83,84,85,86,87,89,90,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.RecordEditor}))),kC=D.lazy(()=>ls(()=>import("./category-editor-UeZPwCgj.js"),__vite__mapDeps([150,1,2,12,7,8,9,10,11,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,77,76,147,145,148,80,81,82,83,73,62,54,55,65,64,84,85,86,87,71,88,89,90,50,91,48,75,78,92,93,94,95,96,63,110,111,109,44,45,46,47,49,51,52,53,56,57,58,59,60,61,66,67,68,69,70,72,74,100,101,102,103,104,105,106,107,108,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.CategoryEditor}))),jC=D.lazy(()=>ls(()=>import("./sections-editor-C33mQAPq.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])).then(t=>({default:t.SectionsEditor}))),NC=D.lazy(()=>ls(()=>import("./seo-editor-DVLMhS9K.js"),__vite__mapDeps([151,1,2,5,7,8,9,10,11,12,13,14,15,16,6,3,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,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,97,98,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,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])).then(t=>({default:t.SeoEditor}))),EC=D.lazy(()=>ls(()=>import("./variant-calendar-cujTqFIv.js"),__vite__mapDeps([152,1,2,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,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,130])).then(t=>({default:t.VariantCalendar}))),Ca="oklch(0.65 0.15 160)";function TC(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function AC(t){const e=new Map;for(const s of t){const i=TC(s.resolveType),r=e.get(i);r?r.push(s):e.set(i,[s])}return[...e.entries()].map(([s,i])=>({label:s,sections:i})).sort((s,i)=>s.label.localeCompare(i.label))}function RC(){const t=U.c(18),e=gi(),{data:s}=$i.useSession(),{currentBranch:i}=Ts(),{org:r}=Me(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,d=a&&i?to(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(d),u=(c.find(PC)??c[0])?.previewUrl??null,f=bs(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:ul,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const g=Pt(p),_=ll(g);let b;t[3]!==i||t[4]!==_||t[5]!==o?(b=()=>{if(!o)return;const w={virtualMcpId:o};i&&(w.branch=i),_.mutate(w)},t[3]=i,t[4]=_,t[5]=o,t[6]=b):b=t[6];const x=b,v=!!o&&!!i&&oa.isStopped(o,i),y=wf({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(y.kind!=="iframe"){let w;return t[7]!==y||t[8]!==x||t[9]!==f.lifecycle||t[10]!==f.phase?(w=n.jsx(QC,{state:y,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:x}),t[7]=y,t[8]=x,t[9]=f.lifecycle,t[10]=f.phase,t[11]=w):w=t[11],w}if(!o||!i){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ki,{title:"Waiting for sandbox context…"}),t[12]=w):w=t[12],w}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(IC,{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 PC(t){return t.sandboxProviderKind!=="user-desktop"}const Ld=2e3,DC=15;function Od(t,e,s,i){return typeof e!="string"||s&&(lm(e,s,i)||t.state.dataUpdateCount>=DC)?!1:Ld}function IC({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i},{data:o,isLoading:a}=Ol(r),[l,d]=D.useState("pages"),[c,h]=D.useState(null),[u,f]=D.useState(null),[m,p]=D.useState(""),[g,_]=D.useState(null),[b,x]=D.useState(null),[v,y]=D.useState("date-desc"),[S,w]=D.useState(()=>new Set),[C,N]=D.useState(l);C!==l&&(N(l),p(""),_(null),x(null),y("date-desc"),w(new Set));const{data:E,isLoading:R,isFetching:T}=Bl(r,{refetchInterval:M=>{const ue=M.state.data;if(l==="apps"&&c&&c.collection==="apps"){const ge=o?.[c.key];return Od(M,typeof ge?.__resolveType=="string"?ge.__resolveType:void 0,ue)}if(l==="site"&&o){const ge=ue?va(o,ue):null,ke=o.site,Je=ge?.resolveType??(typeof ke?.__resolveType=="string"?ke.__resolveType:void 0);return Od(M,Je,ue,["seo"])}return!1}}),k=(M,ue)=>!lm(M,E,ue)&&(R||T),{catalog:j,isLoading:I}=x2(E??void 0,o??void 0,{enabled:l==="apps"}),A=nc(r),O=d2(r),L=xC(r),P=yC(r),[B,F]=D.useState(null),[H,z]=D.useState(),[W,q]=D.useState(null),[K,Z]=D.useState(null),[Y,G]=D.useState(null),[Q,$]=D.useState(null);if(a||R)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!E)return n.jsx(ki,{title:"Could not load site data."});const X=Vl(o).sort((M,ue)=>M.name.localeCompare(ue.name)),V=ql(o,E),se=l==="sections"?ex(E):[],ee=va(o,E),le=Tm(o),ce=fc.some(M=>le[M].length>0),fe=Tn(l)?le[l]:[],J=(ce?Kr(o,"categories"):[]).map(({key:M,payload:ue})=>{const ge=typeof ue.slug=="string"?ue.slug:"",ke=typeof ue.name=="string"?ue.name:"";return{slug:ge||M,name:ke||ge||M}}).filter(M=>M.slug).sort((M,ue)=>M.name.localeCompare(ue.name));if(!Wl(o,E)&&!ce)return n.jsx(ki,{icon:zi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const te={pages:X.length,sections:V.length,apps:j.length,posts:le.posts.length,authors:le.authors.length,categories:le.categories.length},oe=new Set(X.map(M=>Ti(M.path))),de=new Set(X.map(M=>M.name)),be=new Set(V.map(M=>M.name)),ve=async M=>{const ue=o[M.key];if(!ue)return;const ge=em(o,M.key),ke=tm(o,M.key,Math.max(0,ge-1)),Je=b0(ue.sections,ke);if(Je)try{await A.mutateAsync({blockKey:M.key,data:{...ue,sections:Je}}),he.success(`Variant added to "${M.name}"`),h({collection:"pages",key:M.key,path:M.path})}catch(mt){he.error(mt instanceof Error?mt.message:"Could not add variant")}},we=()=>{z(void 0),F({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},De=M=>{z(void 0),F({mode:"duplicate",sourceKey:M.key,initialName:Rd(de,M.name),initialPath:qw(oe,M.path)})},Be=M=>{z(void 0),F({mode:"rename",sourceKey:M.key,initialName:M.name,initialPath:M.path})},Pe=async M=>{if(!B)return;const{mode:ue,sourceKey:ge}=B;try{if(ue==="create"){const ke=Xw(M.name,M.path),Je=Zw(o,M.name);await A.mutateAsync({blockKey:Je,data:ke}),he.success(`Created "${M.name}"`),h({collection:"pages",key:Je,path:M.path})}else if(ue==="duplicate"&&ge){const ke=o[ge];if(!ke)throw new Error("Source page not found");const{key:Je,data:mt}=Yw({source:ke,pages:X,newName:M.name,newPath:M.path});await A.mutateAsync({blockKey:Je,data:mt}),he.success(`Duplicated as "${M.name}"`),h({collection:"pages",key:Je,path:M.path})}else if(ue==="rename"&&ge){const ke=o[ge];if(!ke)throw new Error("Page not found");const Je={...ke,name:M.name,path:M.path};await A.mutateAsync({blockKey:ge,data:Je}),he.success("Page updated"),c?.collection==="pages"&&c.key===ge&&h({collection:"pages",key:ge,path:M.path})}F(null)}catch(ke){z(ke instanceof Error?ke.message:"Save failed")}},Fe=({path:M})=>{if(!B)return null;const ue=Ti(M);return(B.mode==="rename"?Ti(B.initialPath):null)!==ue&&oe.has(ue)?`A page with path "${M}" already exists.`:null},xe=async(M,ue,ge)=>{await A.mutateAsync({blockKey:ue,data:{...ge,name:ue,__resolveType:M}}),he.success(`Created section "${ue}"`),h({collection:"sections",key:ue})},ye=S2((M,ue)=>A.mutate({blockKey:M,data:ue})),Ie=async M=>{const ue=o[M.key];if(!ue){he.error("Section not found.");return}const ge=Gw(o,M.key),ke=Rd(be,M.name),Je={...ue,name:ke};try{await A.mutateAsync({blockKey:ge,data:Je}),he.success(`Duplicated "${M.name}"`),h({collection:"sections",key:ge})}catch(mt){he.error(mt instanceof Error?mt.message:"Duplicate failed")}},Le=async M=>{if(!W)return;const ue=o[W];if(!ue){he.error("Section not found.");return}try{await A.mutateAsync({blockKey:W,data:{...ue,name:M}}),he.success("Section renamed"),q(null)}catch(ge){he.error(ge instanceof Error?ge.message:"Rename failed")}},qe=async M=>{const ue=Pd(o,M),ge=Ho(ue,M,uC(M));try{await L.mutateAsync({blockKey:ue,data:ge}),he.success(`Created ${En[M]}`),h({collection:M,key:ue})}catch(ke){he.error(ke instanceof Error?ke.message:"Could not create")}},st=async M=>{const ue=o[M.key];if(!ue){he.error("Record not found.");return}const ge=Pd(o,M.kind),ke=M.kind==="posts"?"title":"name",Je={...structuredClone(Sa(ue,M.kind)),[ke]:`${M.label} (copy)`};try{await L.mutateAsync({blockKey:ge,data:Ho(ge,M.kind,Je)}),he.success(`Duplicated "${M.label}"`),h({collection:M.kind,key:ge})}catch(mt){he.error(mt instanceof Error?mt.message:"Duplicate failed")}},ct=M=>{w(ue=>{const ge=new Set(ue);return ge.has(M)?ge.delete(M):ge.add(M),ge})},Se=M=>{d("posts"),N("posts"),h(null),f(null),p(""),_(M),x(null),y("date-desc"),w(new Set)},pe=async(M,ue)=>{const ge=[...S];let ke=0;for(const Je of ge){const mt=o[Je],Vs=Sa(mt,"posts"),tn=M==="add"?dC(Vs,ue):hC(Vs,ue);tn!==Vs&&(await L.mutateAsync({blockKey:Je,data:Ho(Je,"posts",tn)}),ke+=1)}return ke},$e=async(M,ue)=>{const ge=S.size;try{const ke=await pe(M,ue),Je=M==="add"?"Added to":"Moved",mt=ge-ke;he.success(`${Je} ${ke} ${ke===1?"post":"posts"}`+(mt>0?` (${mt} already set)`:"")),w(new Set),$(null)}catch(ke){he.error(ke instanceof Error?ke.message:"Bulk update failed")}},Ge=async()=>{if(K)try{if(K.kind==="blog-bulk"){for(const ke of K.keys)await P.mutateAsync({blockKey:ke});he.success(`Deleted ${K.count} ${K.count===1?"post":"posts"}`),c&&c.collection!=="available-section"&&K.keys.includes(c.key)&&h(null),w(new Set),Z(null);return}const{kind:M,key:ue,label:ge}=K;M==="blog"?await P.mutateAsync({blockKey:ue}):await O.mutateAsync({blockKey:ue}),he.success(`Deleted "${ge}"`),c&&c.collection!=="available-section"&&c.key===ue&&h(null),Z(null)}catch(M){he.error(M instanceof Error?M.message:"Delete failed")}},He=O.isPending||P.isPending,Ye=K?.kind==="blog"?En[K.blogKind]:K?.kind==="blog-bulk"?`${K.count} ${K.count===1?"post":"posts"}`:K?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(OC,{active:l,counts:te,showBlog:ce,onSelect:M=>{d(M),h(null),f(null)}}),l!=="seo"&&l!=="site"&&l!=="calendar"&&n.jsx(BC,{activeCollection:l,pages:X,sections:V,availableSections:se,appCatalog:j,appCatalogLoading:I,blogEntries:fe,decofile:o,searchQuery:m,onSearchChange:p,postCategoryFilter:g,postAuthorFilter:b,postSort:v,onPostCategoryFilterChange:M=>{_(M),w(new Set)},onPostAuthorFilterChange:M=>{x(M),w(new Set)},onPostSortChange:y,selectedPostKeys:S,onTogglePostSelect:ct,onSelectAllPosts:M=>w(new Set(M)),onClearPostSelection:()=>w(new Set),onBulkUpdateCategory:()=>$({count:S.size}),onBulkDeletePosts:()=>Z({kind:"blog-bulk",keys:[...S],count:S.size}),selection:c,onSelect:M=>{h(M),f(null)},onCreate:()=>{l==="pages"?we():Tn(l)&&qe(l)},onDuplicatePage:De,onRenamePage:Be,onAddPageVariant:ve,onDeletePage:M=>Z({kind:"page",key:M.key,label:M.name}),onEditPageSeo:M=>{h({collection:"pages",key:M.key,path:M.path}),f(M.key)},onViewPageJson:M=>G(M.key),onDuplicateSection:Ie,onRenameSection:M=>q(M.key),onDeleteSection:M=>Z({kind:"section",key:M.key,label:M.name}),onDuplicateBlog:st,onDeleteBlog:M=>Z({kind:"blog",blogKind:M.kind,key:M.key,label:M.label})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="calendar"?n.jsx(EC,{decofile:o}):l==="site"?ee?n.jsx(Id,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:ee.key,block:o[ee.key],decofile:o,meta:E,title:"Site",excludeFields:["seo"],schemaPending:k(ee.resolveType,["seo"]),previewBaseUrl:i},`site:${ee.key}`):n.jsx(ki,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(NC,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:E,target:{kind:"site"},previewBaseUrl:i}):l==="sections"?n.jsx(LC,{selection:c?.collection==="sections"||c?.collection==="available-section"?c:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:E,decofile:o,isCreating:A.isPending,onCreateAvailable:xe,onSaveReferencedBlock:ye}):c&&c.collection!=="available-section"?c.collection==="apps"?n.jsx(Id,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,previewBaseUrl:i,schemaPending:k(typeof o[c.key]?.__resolveType=="string"?String(o[c.key].__resolveType):void 0)},`app:${c.key}`):c.collection==="posts"?n.jsx(wC,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,previewBaseUrl:i},`post:${c.key}`):c.collection==="categories"?n.jsx(kC,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,onManagePosts:Se},`category:${c.key}`):c.collection==="authors"?n.jsx(CC,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:c.key,block:o[c.key]},`authors:${c.key}`):n.jsx(jC,{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(ki,{title:`Select ${Tn(l)?`a ${En[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.'})})}),B&&n.jsx(sC,{open:!!B,mode:B.mode,initialName:B.initialName,initialPath:B.initialPath,isPending:A.isPending,error:H,validate:Fe,onSubmit:Pe,onOpenChange:M=>{M||(F(null),z(void 0))}}),W&&n.jsx(iC,{open:!!W,blockKey:W,initialName:V.find(M=>M.key===W)?.name??W,isPending:A.isPending,onSubmit:Le,onOpenChange:M=>{M||q(null)}}),Y&&n.jsx(SC,{open:!!Y,onOpenChange:M=>{M||G(null)},pageKey:Y,decofile:o}),Q&&n.jsx(YC,{count:Q.count,categories:J,isPending:L.isPending,onApply:(M,ue)=>{$e(M,ue)},onOpenChange:M=>{!M&&!L.isPending&&$(null)}}),n.jsx(jr,{open:!!K,onOpenChange:M=>{!M&&!He&&Z(null)},children:n.jsxs(Nr,{children:[n.jsxs(Er,{children:[n.jsx(Tr,{children:`Delete ${Ye}?`}),n.jsx(Ar,{children:K?.kind==="section"?`"${K.label}" will be removed. Pages that still reference it will lose this section.`:K?.kind==="blog-bulk"?`${K.count} ${K.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:K?`"${K.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Rr,{children:[n.jsx(Pr,{disabled:He,children:"Cancel"}),n.jsx(Dr,{onClick:M=>{M.preventDefault(),Ge()},disabled:He,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:He?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function LC(t){const e=U.c(30),{selection:s,orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,isCreating:c,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ki,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,_=s.title;let b;e[1]!==s.title?(b=b2(s.title),e[1]=s.title,e[2]=b):b=e[2];let x;e[3]!==h||e[4]!==s.resolveType?(x=(y,S)=>h(s.resolveType,y,S),e[3]=h,e[4]=s.resolveType,e[5]=x):x=e[5];let v;return e[6]!==o||e[7]!==d||e[8]!==c||e[9]!==l||e[10]!==u||e[11]!==i||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==b||e[17]!==x||e[18]!==r?(v=n.jsx(Uw,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,resolveType:g,title:_,defaultBlockId:b,isCreating:c,onCreate:x,onSaveReferencedBlock:u},p),e[6]=o,e[7]=d,e[8]=c,e[9]=l,e[10]=u,e[11]=i,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=b,e[17]=x,e[18]=r,e[19]=v):v=e[19],v}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==d||e[22]!==l||e[23]!==u||e[24]!==i||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=n.jsx(Kw,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=d,e[22]=l,e[23]=u,e[24]=i,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function Bd(t){const e=U.c(8),{icon:s,label:i,className:r}=t;let o;e[0]!==r?(o=ae("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=n.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:o,children:[a,i]}),e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function OC(t){const e=U.c(37),{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 d;e[1]!==i.pages||e[2]!==o||e[3]!==l?(d=n.jsx(Ss,{id:"pages",icon:Ni,label:"Pages",count:i.pages,active:l,onSelect:o}),e[1]=i.pages,e[2]=o,e[3]=l,e[4]=d):d=e[4];const c=s==="sections";let h;e[5]!==i.sections||e[6]!==o||e[7]!==c?(h=n.jsx(Ss,{id:"sections",icon:si,label:"Sections",count:i.sections,active:c,onSelect:o}),e[5]=i.sections,e[6]=o,e[7]=c,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==i.apps||e[10]!==o||e[11]!==u?(f=n.jsx(Ss,{id:"apps",icon:Vu,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];const m=s==="calendar";let p;e[13]!==o||e[14]!==m?(p=n.jsx(Ss,{id:"calendar",icon:Eu,label:"Calendar",active:m,onSelect:o}),e[13]=o,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==s||e[17]!==i.authors||e[18]!==i.categories||e[19]!==i.posts||e[20]!==o||e[21]!==r?(g=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(pa,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(Ss,{id:"posts",icon:Ri,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(Ss,{id:"authors",icon:co,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(Ss,{id:"categories",icon:ro,label:"Categories",count:i.categories,active:s==="categories",onSelect:o})]}),e[16]=s,e[17]=i.authors,e[18]=i.categories,e[19]=i.posts,e[20]=o,e[21]=r,e[22]=g):g=e[22];const _=s==="site";let b;e[23]!==o||e[24]!==_?(b=n.jsx(Ss,{id:"site",icon:z_,label:"Site",active:_,onSelect:o}),e[23]=o,e[24]=_,e[25]=b):b=e[25];const x=s==="seo";let v;e[26]!==o||e[27]!==x?(v=n.jsx(Ss,{id:"seo",icon:kr,label:"SEO",active:x,onSelect:o}),e[26]=o,e[27]=x,e[28]=v):v=e[28];let y;return e[29]!==g||e[30]!==b||e[31]!==v||e[32]!==d||e[33]!==h||e[34]!==f||e[35]!==p?(y=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[d,h,f,p,g,b,v]})]}),e[29]=g,e[30]=b,e[31]=v,e[32]=d,e[33]=h,e[34]=f,e[35]=p,e[36]=y):y=e[36],y}function Ss(t){const e=U.c(18),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let d;e[0]!==s||e[1]!==l?(d=()=>l(s),e[0]=s,e[1]=l,e[2]=d):d=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==c?(h=ae("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]=h):h=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:ae("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]!==d||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=n.jsxs("button",{type:"button",onClick:d,className:h,children:[u,f,m]}),e[12]=d,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function BC(t){const e=U.c(75),{activeCollection:s,pages:i,sections:r,availableSections:o,appCatalog:a,appCatalogLoading:l,blogEntries:d,decofile:c,searchQuery:h,onSearchChange:u,postCategoryFilter:f,postAuthorFilter:m,postSort:p,onPostCategoryFilterChange:g,onPostAuthorFilterChange:_,onPostSortChange:b,selectedPostKeys:x,onTogglePostSelect:v,onSelectAllPosts:y,onClearPostSelection:S,onBulkUpdateCategory:w,onBulkDeletePosts:C,selection:N,onSelect:E,onCreate:R,onDuplicatePage:T,onRenamePage:k,onAddPageVariant:j,onDeletePage:I,onEditPageSeo:A,onViewPageJson:O,onDuplicateSection:L,onRenameSection:P,onDeleteSection:B,onDuplicateBlog:F,onDeleteBlog:H}=t;let z,W,q,K,Z,Y,G;if(e[0]!==s||e[1]!==a||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==c||e[6]!==j||e[7]!==C||e[8]!==w||e[9]!==S||e[10]!==R||e[11]!==H||e[12]!==I||e[13]!==B||e[14]!==F||e[15]!==T||e[16]!==L||e[17]!==A||e[18]!==_||e[19]!==g||e[20]!==b||e[21]!==k||e[22]!==P||e[23]!==u||e[24]!==E||e[25]!==y||e[26]!==v||e[27]!==O||e[28]!==i||e[29]!==m||e[30]!==f||e[31]!==p||e[32]!==h||e[33]!==r||e[34]!==x||e[35]!==N){const V=h.toLowerCase(),se=i.filter(M=>!V||M.name.toLowerCase().includes(V)||M.path.toLowerCase().includes(V)),ee=r.filter(M=>!V||M.name.toLowerCase().includes(V)||M.key.toLowerCase().includes(V)||M.resolveType.toLowerCase().includes(V)),le=o.filter(M=>!V||M.title.toLowerCase().includes(V)||M.resolveType.toLowerCase().includes(V)||(M.description?.toLowerCase().includes(V)??!1)),ce=AC(ee),fe=a.filter(M=>!V||M.title.toLowerCase().includes(V)||M.app.toLowerCase().includes(V)||M.vendor.toLowerCase().includes(V)||M.category.toLowerCase().includes(V)),J=d.filter(M=>!V||M.label.toLowerCase().includes(V)||M.subtitle.toLowerCase().includes(V)),te=s==="posts",oe=FC,de=te?cC(c):[],be=new Map,ve=new Map;for(const M of de){for(const ue of M.categorySlugs)be.set(ue,(be.get(ue)??0)+1);for(const ue of M.authorEmails)ve.set(ue,(ve.get(ue)??0)+1)}const we=(te?Kr(c,"categories"):[]).map(M=>{const{key:ue,payload:ge}=M,ke=oe(ge.slug)||ue;return{slug:ke,name:oe(ge.name)||oe(ge.slug)||ue,count:be.get(ke)??0}}).filter(zC),De=(te?Kr(c,"authors"):[]).map(M=>{const{key:ue,payload:ge}=M,ke=oe(ge.email);return{email:ke,name:oe(ge.name)||oe(ge.email)||ue,count:ve.get(ke)??0}}).filter($C);let Be;e[43]!==f?(Be=M=>!f||M.categorySlugs.includes(f),e[43]=f,e[44]=Be):Be=e[44];let Pe;e[45]!==m?(Pe=M=>!m||M.authorEmails.includes(m),e[45]=m,e[46]=Pe):Pe=e[46];let Fe;e[47]!==p?(Fe=(M,ue)=>{if(p==="az")return M.title.localeCompare(ue.title);if(p==="za")return ue.title.localeCompare(M.title);const ge=M.date.localeCompare(ue.date);return p==="date-asc"?ge:-ge},e[47]=p,e[48]=Fe):Fe=e[48];const xe=de.filter(M=>!V||M.title.toLowerCase().includes(V)||M.slug.toLowerCase().includes(V)).filter(Be).filter(Pe).sort(Fe),ye=x.size,Ie=xe.map(MC),Le=Ie.length>0&&Ie.every(M=>x.has(M)),qe=ye>0,st=()=>{Le?S():y(Ie)},ct=`Search ${s}…`,Se=Tn(s)?`Create new ${En[s]}`:"Create new page",pe=s!=="apps"&&s!=="sections";Z="w-[300px] shrink-0 border-r flex flex-col min-h-0";let $e;e[49]===Symbol.for("react.memo_cache_sentinel")?($e=n.jsx(Wu,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[49]=$e):$e=e[49];let Ge;e[50]!==u?(Ge=M=>u(M.target.value),e[50]=u,e[51]=Ge):Ge=e[51];let He;e[52]!==ct||e[53]!==h||e[54]!==Ge?(He=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[$e,n.jsx("input",{type:"text",value:h,onChange:Ge,placeholder:ct,"aria-label":ct,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[52]=ct,e[53]=h,e[54]=Ge,e[55]=He):He=e[55];let Ye;e[56]!==Se||e[57]!==R||e[58]!==pe?(Ye=pe&&n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:R,"aria-label":Se,children:n.jsx(Dt,{size:14})})}),n.jsx(Ee,{side:"bottom",children:Se})]}),e[56]=Se,e[57]=R,e[58]=pe,e[59]=Ye):Ye=e[59],e[60]!==He||e[61]!==Ye?(Y=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[He,Ye]}),e[60]=He,e[61]=Ye,e[62]=Y):Y=e[62],G=te&&(qe?n.jsx(GC,{count:ye,allSelected:Le,onToggleSelectAll:st,onUpdateCategory:w,onDelete:C,onClear:S}):n.jsx(UC,{categories:we,authors:De,categoryFilter:f,authorFilter:m,sort:p,hasPosts:de.length>0,allSelected:Le,onToggleSelectAll:st,onCategoryFilterChange:g,onAuthorFilterChange:_,onSortChange:b})),z=Fi,K="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",W="flex flex-col gap-1 p-1.5",q=s==="pages"?se.length===0?n.jsx(an,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):se.map(M=>{const ue=N?.collection==="pages"&&N.key===M.key,ge=em(c,M.key);return n.jsx(bi,{icon:Ni,title:M.name,subtitle:M.path,active:ue,variantCount:ge,onClick:()=>E({collection:"pages",key:M.key,path:M.path}),menu:n.jsx(lr,{onDuplicate:()=>T(M),onRename:()=>k(M),onAddVariant:()=>j(M),onEditSeo:()=>A(M),onViewJson:()=>O(M),onDelete:()=>I(M)})},M.key)}):s==="sections"?ee.length===0&&le.length===0?n.jsx(an,{hasItems:r.length>0||o.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):n.jsxs(n.Fragment,{children:[ce.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bd,{icon:si,label:"Saved sections"}),ce.map(M=>n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:M.label}),M.sections.map(ue=>{const ge=N?.collection==="sections"&&N.key===ue.key;return n.jsx(bi,{icon:si,accent:"global",title:ue.name,subtitle:M.label,active:ge,onClick:()=>E({collection:"sections",key:ue.key}),menu:n.jsx(lr,{onDuplicate:()=>L(ue),onRename:()=>P(ue),onDelete:()=>B(ue)})},ue.key)})]},M.label))]}),le.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bd,{icon:Ni,label:"Available sections",className:ae(ce.length>0&&"mt-3")}),le.map(M=>{const ue=N?.collection==="available-section"&&N.resolveType===M.resolveType,ge=M.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(bi,{icon:Ni,title:M.title,subtitle:ge??M.resolveType,active:ue,onClick:()=>E({collection:"available-section",resolveType:M.resolveType,title:M.title})},M.resolveType)})]})]}):s==="apps"?l?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Oe,{size:18,className:"animate-spin text-muted-foreground"})}):fe.length===0?n.jsx(an,{hasItems:a.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):fe.map(M=>{const ue=N?.collection==="apps"&&M.blockKey!==null&&N.key===M.blockKey;return n.jsx(bi,{icon:Vu,logoUrl:M.logo,title:M.title,subtitle:M.category,active:ue,trailing:M.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(!M.installed||!M.blockKey){he.message(`${M.title} is not installed on this site.`);return}E({collection:"apps",key:M.blockKey})}},M.id)}):te?xe.length===0?n.jsx(an,{hasItems:de.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):xe.map(M=>{const ue={key:M.key,kind:"posts",label:M.title,subtitle:M.slug};return n.jsx(bi,{icon:Ri,title:M.title,subtitle:M.slug,active:N?.collection==="posts"&&N.key===M.key,selectable:!0,selectionActive:qe,selected:x.has(M.key),onToggleSelect:()=>v(M.key),onClick:()=>E({collection:"posts",key:M.key}),menu:n.jsx(lr,{onDuplicate:()=>F(ue),onDelete:()=>H(ue)})},M.key)}):J.length===0?n.jsx(an,{hasItems:d.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Tn(s)?En[s]:"item"}.`}):J.map(M=>{const ue=N?.collection===M.kind&&N.key===M.key;return n.jsx(bi,{icon:M.kind==="posts"?Ri:M.kind==="authors"?co:ro,title:M.label,subtitle:M.subtitle,active:ue,onClick:()=>E({collection:M.kind,key:M.key}),menu:n.jsx(lr,{onDuplicate:()=>F(M),onDelete:()=>H(M)})},M.key)}),e[0]=s,e[1]=a,e[2]=l,e[3]=o,e[4]=d,e[5]=c,e[6]=j,e[7]=C,e[8]=w,e[9]=S,e[10]=R,e[11]=H,e[12]=I,e[13]=B,e[14]=F,e[15]=T,e[16]=L,e[17]=A,e[18]=_,e[19]=g,e[20]=b,e[21]=k,e[22]=P,e[23]=u,e[24]=E,e[25]=y,e[26]=v,e[27]=O,e[28]=i,e[29]=m,e[30]=f,e[31]=p,e[32]=h,e[33]=r,e[34]=x,e[35]=N,e[36]=z,e[37]=W,e[38]=q,e[39]=K,e[40]=Z,e[41]=Y,e[42]=G}else z=e[36],W=e[37],q=e[38],K=e[39],Z=e[40],Y=e[41],G=e[42];let Q;e[63]!==W||e[64]!==q?(Q=n.jsx("div",{className:W,children:q}),e[63]=W,e[64]=q,e[65]=Q):Q=e[65];let $;e[66]!==z||e[67]!==K||e[68]!==Q?($=n.jsx(z,{className:K,children:Q}),e[66]=z,e[67]=K,e[68]=Q,e[69]=$):$=e[69];let X;return e[70]!==Z||e[71]!==Y||e[72]!==G||e[73]!==$?(X=n.jsxs("div",{className:Z,children:[Y,G,$]}),e[70]=Z,e[71]=Y,e[72]=G,e[73]=$,e[74]=X):X=e[74],X}function MC(t){return t.key}function $C(t){return t.email}function zC(t){return t.slug}function FC(t){return typeof t=="string"?t:""}const xi="__all__",Dm={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},HC={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},Uo=D.forwardRef(function(e,s){const i=U.c(20);let r,o,a,l,d;i[0]!==e?({icon:r,active:o,value:d,className:a,...l}=e,i[0]=e,i[1]=r,i[2]=o,i[3]=a,i[4]=l,i[5]=d):(r=i[1],o=i[2],a=i[3],l=i[4],d=i[5]);const c=o?"text-foreground":"text-muted-foreground";let h;i[6]!==a||i[7]!==c?(h=ae("h-7 gap-1 px-1.5 text-xs",c,a),i[6]=a,i[7]=c,i[8]=h):h=i[8];let u;i[9]!==r?(u=n.jsx(r,{size:14,className:"shrink-0"}),i[9]=r,i[10]=u):u=i[10];let f;i[11]!==d?(f=d&&n.jsx("span",{className:"min-w-0 flex-1 truncate",children:d}),i[11]=d,i[12]=f):f=i[12];let m;i[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(cs,{size:12,className:"shrink-0 opacity-60"}),i[13]=m):m=i[13];let p;return i[14]!==l||i[15]!==s||i[16]!==h||i[17]!==u||i[18]!==f?(p=n.jsxs(ie,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),i[14]=l,i[15]=s,i[16]=h,i[17]=u,i[18]=f,i[19]=p):p=i[19],p});function Im(t){const e=U.c(2),{count:s}=t;let i;return e[0]!==s?(i=n.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=i):i=e[1],i}function UC(t){const e=U.c(64),{categories:s,authors:i,categoryFilter:r,authorFilter:o,sort:a,hasPosts:l,allSelected:d,onToggleSelectAll:c,onCategoryFilterChange:h,onAuthorFilterChange:u,onSortChange:f}=t;let m;if(e[0]!==s||e[1]!==r){let V;e[3]!==r?(V=se=>se.slug===r,e[3]=r,e[4]=V):V=e[4],m=s.find(V),e[0]=s,e[1]=r,e[2]=m}else m=e[2];const p=m;let g;if(e[5]!==o||e[6]!==i){let V;e[8]!==o?(V=se=>se.email===o,e[8]=o,e[9]=V):V=e[9],g=i.find(V),e[5]=o,e[6]=i,e[7]=g}else g=e[7];const _=g,b=!l;let x;e[10]!==d||e[11]!==c||e[12]!==b?(x=n.jsx(Lm,{checked:d,disabled:b,onToggle:c}),e[10]=d,e[11]=c,e[12]=b,e[13]=x):x=e[13];const v=!!r,y=p?.name;let S;e[14]!==v||e[15]!==y?(S=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:ro,active:v,value:y,className:"min-w-0 shrink"})}),e[14]=v,e[15]=y,e[16]=S):S=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Co,{children:"Filter by category"}),e[17]=w):w=e[17];const C=r??xi;let N;e[18]!==h?(N=V=>h(V===xi?null:V),e[18]=h,e[19]=N):N=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(In,{value:xi,children:"All categories"}),e[20]=E):E=e[20];let R;e[21]!==s?(R=s.map(KC),e[21]=s,e[22]=R):R=e[22];let T;e[23]!==N||e[24]!==R||e[25]!==C?(T=n.jsxs(Kt,{align:"start",className:"max-h-80 w-56 overflow-y-auto",children:[w,n.jsxs(ko,{value:C,onValueChange:N,children:[E,R]})]}),e[23]=N,e[24]=R,e[25]=C,e[26]=T):T=e[26];let k;e[27]!==T||e[28]!==S?(k=n.jsxs(Wt,{children:[S,T]}),e[27]=T,e[28]=S,e[29]=k):k=e[29];const j=!!o,I=_?.name;let A;e[30]!==j||e[31]!==I?(A=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:co,active:j,value:I,className:"min-w-0 shrink"})}),e[30]=j,e[31]=I,e[32]=A):A=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Co,{children:"Filter by author"}),e[33]=O):O=e[33];const L=o??xi;let P;e[34]!==u?(P=V=>u(V===xi?null:V),e[34]=u,e[35]=P):P=e[35];let B;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(In,{value:xi,children:"All authors"}),e[36]=B):B=e[36];let F;e[37]!==i?(F=i.map(VC),e[37]=i,e[38]=F):F=e[38];let H;e[39]!==L||e[40]!==P||e[41]!==F?(H=n.jsxs(Kt,{align:"start",className:"max-h-80 w-56 overflow-y-auto",children:[O,n.jsxs(ko,{value:L,onValueChange:P,children:[B,F]})]}),e[39]=L,e[40]=P,e[41]=F,e[42]=H):H=e[42];let z;e[43]!==A||e[44]!==H?(z=n.jsxs(Wt,{children:[A,H]}),e[43]=A,e[44]=H,e[45]=z):z=e[45];const W=HC[a];let q;e[46]!==W?(q=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:F_,active:!0,value:W})}),e[46]=W,e[47]=q):q=e[47];let K;e[48]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Co,{children:"Sort by"}),e[48]=K):K=e[48];let Z;e[49]!==f?(Z=V=>f(V),e[49]=f,e[50]=Z):Z=e[50];let Y;e[51]===Symbol.for("react.memo_cache_sentinel")?(Y=Object.keys(Dm),e[51]=Y):Y=e[51];let G;e[52]===Symbol.for("react.memo_cache_sentinel")?(G=Y.map(WC),e[52]=G):G=e[52];let Q;e[53]!==a||e[54]!==Z?(Q=n.jsxs(Kt,{align:"end",className:"w-44",children:[K,n.jsx(ko,{value:a,onValueChange:Z,children:G})]}),e[53]=a,e[54]=Z,e[55]=Q):Q=e[55];let $;e[56]!==q||e[57]!==Q?($=n.jsxs(Wt,{children:[q,Q]}),e[56]=q,e[57]=Q,e[58]=$):$=e[58];let X;return e[59]!==k||e[60]!==z||e[61]!==$||e[62]!==x?(X=n.jsxs("div",{className:"flex min-w-0 items-center gap-0.5 overflow-hidden border-b px-2 py-1.5",children:[x,k,z,$]}),e[59]=k,e[60]=z,e[61]=$,e[62]=x,e[63]=X):X=e[63],X}function WC(t){return n.jsx(In,{value:t,children:Dm[t]},t)}function VC(t){return n.jsxs(In,{value:t.email,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(Im,{count:t.count})]},t.email)}function KC(t){return n.jsxs(In,{value:t.slug,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(Im,{count:t.count})]},t.slug)}function Lm(t){const e=U.c(12),{checked:s,disabled:i,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==a?(l=n.jsx(Ne,{asChild:!0,children:n.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:qC,children:n.jsx(Ki,{checked:s,disabled:i,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=l):l=e[6];const d=s?"Deselect all":"Select all";let c;e[7]!==d?(c=n.jsx(Ee,{side:"bottom",children:d}),e[7]=d,e[8]=c):c=e[8];let h;return e[9]!==l||e[10]!==c?(h=n.jsxs(Te,{children:[l,c]}),e[9]=l,e[10]=c,e[11]=h):h=e[11],h}function qC(t){return t.stopPropagation()}function GC(t){const e=U.c(31),{count:s,allSelected:i,onToggleSelectAll:r,onUpdateCategory:o,onDelete:a,onClear:l}=t;let d;e[0]!==i||e[1]!==r?(d=n.jsx(Lm,{checked:i,onToggle:r}),e[0]=i,e[1]=r,e[2]=d):d=e[2];let c;e[3]!==s?(c=n.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ro,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o?(u=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:o,"aria-label":"Update category for selected posts",children:[h,"Category"]})}),e[6]=o,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ee,{side:"bottom",children:"Update category"}),e[8]=f):f=e[8];let m;e[9]!==u?(m=n.jsxs(Te,{children:[u,f]}),e[9]=u,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(es,{size:14}),e[11]=p):p=e[11];let g;e[12]!==a?(g=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:a,"aria-label":"Delete selected posts",children:p})}),e[12]=a,e[13]=g):g=e[13];let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ee,{side:"bottom",children:"Delete selected"}),e[14]=_):_=e[14];let b;e[15]!==g?(b=n.jsxs(Te,{children:[g,_]}),e[15]=g,e[16]=b):b=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(jl,{size:14}),e[17]=x):x=e[17];let v;e[18]!==l?(v=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:l,"aria-label":"Clear selection",children:x})}),e[18]=l,e[19]=v):v=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ee,{side:"bottom",children:"Clear selection"}),e[20]=y):y=e[20];let S;e[21]!==v?(S=n.jsxs(Te,{children:[v,y]}),e[21]=v,e[22]=S):S=e[22];let w;e[23]!==b||e[24]!==S||e[25]!==m?(w=n.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,b,S]}),e[23]=b,e[24]=S,e[25]=m,e[26]=w):w=e[26];let C;return e[27]!==d||e[28]!==w||e[29]!==c?(C=n.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[d,c,w]}),e[27]=d,e[28]=w,e[29]=c,e[30]=C):C=e[30],C}function YC(t){const e=U.c(48),{count:s,categories:i,isPending:r,onApply:o,onOpenChange:a}=t,[l,d]=D.useState(i[0]?.slug??""),[c,h]=D.useState("add");let u;if(e[0]!==i||e[1]!==l){let P;e[3]!==l?(P=B=>B.slug===l,e[3]=l,e[4]=P):P=e[4],u=i.find(P),e[0]=i,e[1]=l,e[2]=u}else u=e[2];const f=u;let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ss,{children:"Update category"}),e[5]=m):m=e[5];const p=s===1?"post":"posts";let g;e[6]!==s||e[7]!==p?(g=n.jsxs(ts,{children:[m,n.jsxs(Wi,{children:["Choose a category to apply to ",s," ",p,"."]})]}),e[6]=s,e[7]=p,e[8]=g):g=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ve,{children:"Category"}),e[9]=_):_=e[9];let b;e[10]!==i||e[11]!==l?(b=n.jsxs("div",{className:"space-y-2",children:[_,i.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"No categories yet — create one in the Categories collection."}):n.jsxs(Nt,{value:l,onValueChange:d,children:[n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select a category"})}),n.jsx(jt,{children:i.map(XC)})]})]}),e[10]=i,e[11]=l,e[12]=b):b=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=P=>h(P),e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(fd,{value:"add",id:"cat-mode-add",className:"mt-0.5"}),e[14]=v):v=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsxs(Ve,{htmlFor:"cat-mode-add",className:"flex cursor-pointer items-start gap-2.5 rounded-lg border p-3",children:[v,n.jsxs("span",{className:"space-y-0.5",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Add category"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Keep existing categories and add this one."})]})]}),e[15]=y):y=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(fd,{value:"replace",id:"cat-mode-replace",className:"mt-0.5"}),e[16]=S):S=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsxs(Ve,{htmlFor:"cat-mode-replace",className:"flex cursor-pointer items-start gap-2.5 rounded-lg border p-3",children:[S,n.jsxs("span",{className:"space-y-0.5",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Replace category"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Remove all current categories and set only this one."})]})]}),e[17]=w):w=e[17];let C;e[18]!==c?(C=n.jsxs(a2,{value:c,onValueChange:x,className:"gap-2",children:[y,w]}),e[18]=c,e[19]=C):C=e[19];let N;e[20]!==C||e[21]!==b?(N=n.jsxs("div",{className:"space-y-4 py-2",children:[b,C]}),e[20]=C,e[21]=b,e[22]=N):N=e[22];let E;e[23]!==a?(E=()=>a(!1),e[23]=a,e[24]=E):E=e[24];let R;e[25]!==r||e[26]!==E?(R=n.jsx(ie,{type:"button",variant:"outline",onClick:E,disabled:r,children:"Cancel"}),e[25]=r,e[26]=E,e[27]=R):R=e[27];const T=!f||r;let k;e[28]!==c||e[29]!==o||e[30]!==f?(k=()=>f&&o(c,{name:f.name,slug:f.slug}),e[28]=c,e[29]=o,e[30]=f,e[31]=k):k=e[31];let j;e[32]!==r?(j=r?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Updating…"]}):"Apply",e[32]=r,e[33]=j):j=e[33];let I;e[34]!==T||e[35]!==k||e[36]!==j?(I=n.jsx(ie,{type:"button",disabled:T,onClick:k,children:j}),e[34]=T,e[35]=k,e[36]=j,e[37]=I):I=e[37];let A;e[38]!==R||e[39]!==I?(A=n.jsxs(Ws,{children:[R,I]}),e[38]=R,e[39]=I,e[40]=A):A=e[40];let O;e[41]!==N||e[42]!==A||e[43]!==g?(O=n.jsxs(Mt,{className:"sm:max-w-md",children:[g,N,A]}),e[41]=N,e[42]=A,e[43]=g,e[44]=O):O=e[44];let L;return e[45]!==a||e[46]!==O?(L=n.jsx(Bt,{open:!0,onOpenChange:a,children:O}),e[45]=a,e[46]=O,e[47]=L):L=e[47],L}function XC(t){return n.jsx(tt,{value:t.slug,children:n.jsx("span",{className:"truncate",children:t.name})},t.slug)}function bi(t){const e=U.c(37),{icon:s,logoUrl:i,title:r,subtitle:o,active:a,accent:l,variantCount:d,trailing:c,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,_=l==="global";let b;e[0]!==s||e[1]!==a||e[2]!==_||e[3]!==i||e[4]!==d?(b=d&&d>1?n.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Ca}})}),n.jsxs(Ee,{side:"right",children:[d," variants"]})]})}):i?n.jsx("img",{src:i,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):n.jsx("span",{className:ae("flex size-8 shrink-0 items-center justify-center rounded-lg",_?"bg-global-section/15":"bg-muted"),children:n.jsx(s,{size:16,className:ae("shrink-0",!_&&(a?"text-accent-foreground":"text-muted-foreground")),style:_?{color:lf}:void 0})}),e[0]=s,e[1]=a,e[2]=_,e[3]=i,e[4]=d,e[5]=b):b=e[5];const x=b,v=a?_?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":_?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==v?(y=ae("group relative flex min-w-0 items-center rounded-md transition-colors",v),e[6]=v,e[7]=y):y=e[7];let S;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(S=h&&n.jsx("span",{className:ae("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:JC,children:n.jsx(Ki,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=S):S=e[13];let w;e[14]!==r?(w=n.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const C=a?"text-accent-foreground/70":"text-muted-foreground";let N;e[16]!==C?(N=ae("block truncate text-xs",C),e[16]=C,e[17]=N):N=e[17];let E;e[18]!==o||e[19]!==N?(E=n.jsx("span",{className:N,children:o}),e[18]=o,e[19]=N,e[20]=E):E=e[20];let R;e[21]!==w||e[22]!==E?(R=n.jsxs("span",{className:"min-w-0 flex-1",children:[w,E]}),e[21]=w,e[22]=E,e[23]=R):R=e[23];let T;e[24]!==p||e[25]!==x||e[26]!==R||e[27]!==c?(T=n.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[x,R,c]}),e[24]=p,e[25]=x,e[26]=R,e[27]=c,e[28]=T):T=e[28];let k;e[29]!==a||e[30]!==g?(k=g&&n.jsx("div",{className:ae("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=k):k=e[31];let j;return e[32]!==T||e[33]!==k||e[34]!==y||e[35]!==S?(j=n.jsxs("div",{className:y,children:[S,T,k]}),e[32]=T,e[33]=k,e[34]=y,e[35]=S,e[36]=j):j=e[36],j}function JC(t){return t.stopPropagation()}function lr(t){const e=U.c(21),{onDuplicate:s,onRename:i,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Vt,{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:ZC,children:n.jsx(Hi,{size:14})})}),e[0]=d):d=e[0];let c;e[1]!==i?(c=i&&n.jsxs(Ue,{onClick:i,children:[n.jsx(Cl,{size:14}),"Rename"]}),e[1]=i,e[2]=c):c=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(as,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=n.jsxs(Ue,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsxs(Ue,{onClick:r,className:"cursor-pointer",style:{color:Ca},children:[n.jsx(Tu,{size:14,style:{color:Ca}}),"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(Cn,{}),o&&n.jsxs(Ue,{onClick:o,children:[n.jsx(kr,{size:14}),"Edit SEO"]}),a&&n.jsxs(Ue,{onClick:a,children:[n.jsx(no,{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(Cn,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(es,{size:14}),e[12]=g):g=e[12];let _;e[13]!==l?(_=n.jsxs(Ue,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=_):_=e[14];let b;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==_?(b=n.jsxs(Wt,{children:[d,n.jsxs(Kt,{align:"end",className:"w-44",children:[c,u,f,m,p,_]})]}),e[15]=c,e[16]=u,e[17]=f,e[18]=m,e[19]=_,e[20]=b):b=e[20],b}function ZC(t){return t.stopPropagation()}function an(t){const e=U.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 QC(t){const e=U.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=rm({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(Wr,{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(Wr,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function ki(t){const e=U.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 d;return e[6]!==o||e[7]!==a||e[8]!==l?(d=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]=d):d=e[9],d}function e3(t){const e=U.c(2),{virtualMcpId:s}=t,i=vs(s);if(!ti(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(zi,{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(RC,{}),e[1]=o):o=e[1],o}const Wo={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:ku},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Zs},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:V_}},t3=["fast","smart","thinking"];function s3(t){const e=U.c(15),{tier:s,onSelect:i}=t,[r,o]=D.useState(!1),a=Wo[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 d=Wo[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(cs,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let h;e[3]!==l||e[4]!==d.label?(h=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,d.label,c]})}),e[3]=l,e[4]=d.label,e[5]=h):h=e[5];let u;e[6]!==i||e[7]!==s?(u=t3.map(p=>{const g=Wo[p],_=g.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:ae("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[n.jsx(_,{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:g.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&n.jsx(js,{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(Ps,{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]!==h||e[13]!==f?(m=n.jsxs(As,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function i3(t){const e=U.c(15),{tier:s,onTierChange:i,override:r,onOverrideChange:o}=t,[a,l]=D.useState(r!==null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=d):d=e[0];let c;e[1]!==o||e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a?(c=a?n.jsx(D.Suspense,{fallback:n.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(n3,{override:r,onOverrideChange:o})}):n.jsx(s3,{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 h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||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(On,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,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:[d,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 n3(t){const e=U.c(10),{override:s,onOverrideChange:i}=t,r=fu(),o=r[0]?.id??null,[a,l]=D.useState(s?.credentialId??o);let d;e[0]!==s?(d=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]=d):d=e[1];const c=d;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 h;e[3]!==a||e[4]!==i?(h=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]=h):h=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==h?(u=n.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:n.jsx(P1,{variant:"bordered",placeholder:"Pick a model",model:c,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=c,e[8]=h,e[9]=u):u=e[9],u}const Om=[{key:"capabilities",heading:"Built-in capabilities",icon:kl,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Ui},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:Ii},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:Dn},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:H_}]},{key:"files",heading:"Files & code",icon:ma,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Ou},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Cl},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:U_},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Bn},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:ma},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:W_}]},{key:"context",heading:"Context",icon:Mc,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Mc},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:pa},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:pa}]},{key:"browser",heading:"Browser",icon:si,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:Ru},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:si},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:no}]}],r3=Om.flatMap(t=>t.tools.map(e=>e.name));function o3(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function a3(t){const e=U.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(D.Suspense,{fallback:n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(kl,{size:14}),"Loading tools…"]}),children:n.jsx(l3,{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 Md(t){const e=U.c(17),{value:s,checked:i,onToggle:r,title:o,description:a,leading:l}=t;let d;e[0]!==i?(d=n.jsx(Ki,{checked:i,className:"pointer-events-none mt-0.5"}),e[0]=i,e[1]=d):d=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 h;e[4]!==o?(h=n.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=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]!==h||e[9]!==u?(f=n.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==d||e[13]!==c||e[14]!==f||e[15]!==s?(m=n.jsxs(Or,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[d,c,f]}),e[11]=r,e[12]=d,e[13]=c,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function $d(t){const e=U.c(20),{conn:s,label:i,icon:r,on:o,total:a,onToggle:l}=t,d=o===a;let c;e[0]!==r||e[1]!==s?(c=s?n.jsx(xs,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(K_,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=c):c=e[2];const h=s?.title??i??"Other tools";let u;e[3]!==h?(u=n.jsx("span",{className:"truncate",children:h}),e[3]=h,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=x=>{x.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=d?"None":"All";let g;e[10]!==m||e[11]!==p?(g=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]=g):g=e[12];let _;e[13]!==f||e[14]!==g?(_=n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=_):_=e[15];let b;return e[16]!==c||e[17]!==u||e[18]!==_?(b=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,_]}),e[16]=c,e[17]=u,e[18]=_,e[19]=b):b=e[19],b}function l3(t){const e=U.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Me(),[a,l]=D.useState(!1);let d;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(d={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=d):d=e[3];const c=Pt(d);let h;e[4]!==c?(h={client:c},e[4]=c,e[5]=h):h=e[5];const{data:u,isLoading:f}=Du(h),m=Vn();let p,g,_,b,x,v,y,S,w,C,N,E,R;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const A=new Map(m.map(f3)),O=new Map;for(const J of u?.tools??[]){const te=Ag(J._meta)??"__other__",oe=Rg(J.name,te==="__other__"?void 0:te),de=J.title,be=de&&de!==J.name?de:o3(oe);O.has(te)||O.set(te,{clientId:te,conn:A.get(te),tools:[]}),O.get(te).tools.push({name:J.name,display:be,description:J.description})}const L=[...O.values()].sort(u3),P=(u?.tools??[]).map(h3),B=[...r3,...P],F=i===null?new Set(B):new Set(i),H=B.every(J=>F.has(J)),z=J=>r(B.every(te=>J.has(te))?null:[...J]),W=J=>{const te=new Set(F);te.has(J)?te.delete(J):te.add(J),z(te)},q=(J,te)=>{const oe=new Set(F);for(const de of J)te?oe.add(de):oe.delete(de);z(oe)};b=As,R=a,x=l;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(kl,{size:14,className:"text-muted-foreground"}),e[25]=K):K=e[25];const Z=H?"All tools":"Tools",Y=!H&&n.jsxs(R1,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",B.length]});let G;e[26]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(cs,{size:14,className:"text-muted-foreground"}),e[26]=G):G=e[26],e[27]!==Z||e[28]!==Y?(v=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[K,Z,Y,G]})}),e[27]=Z,e[28]=Y,e[29]=v):v=e[29],_=Ps,N="p-0 w-80",E="start",g=Ku,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Nl,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const Q=H?`All ${B.length} tools enabled`:`${F.size} of ${B.length} enabled`;let $;e[31]!==Q?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:Q}),e[31]=Q,e[32]=$):$=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let V;e[35]!==H||e[36]!==X?(V=n.jsx("button",{type:"button",onClick:X,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]=X,e[37]=V):V=e[37];let se;e[38]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=se):se=e[38];let ee;e[39]!==r?(ee=()=>r([]),e[39]=r,e[40]=ee):ee=e[40];const le=F.size===0;let ce;e[41]!==ee||e[42]!==le?(ce=n.jsx("button",{type:"button",onClick:ee,disabled:le,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=ee,e[42]=le,e[43]=ce):ce=e[43];let fe;e[44]!==V||e[45]!==ce?(fe=n.jsxs("div",{className:"flex items-center gap-2",children:[V,se,ce]}),e[44]=V,e[45]=ce,e[46]=fe):fe=e[46],e[47]!==$||e[48]!==fe?(C=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[$,fe]}),e[47]=$,e[48]=fe,e[49]=C):C=e[49],p=Tl,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(El,{children:"No tools found"}),Om.map(J=>{const te=J.tools.map(d3),oe=te.filter(de=>F.has(de)).length;return n.jsx(Br,{heading:n.jsx($d,{label:J.heading,icon:J.icon,on:oe,total:te.length,onToggle:()=>q(te,oe!==te.length)}),children:J.tools.map(de=>n.jsx(Md,{value:`${de.title} ${de.name}`,checked:F.has(de.name),onToggle:()=>W(de.name),title:de.title,description:de.description,leading:n.jsx(de.icon,{size:16,className:"text-muted-foreground"})},de.name))},J.key)}),L.map(J=>{const te=J.tools.map(c3),oe=te.filter(de=>F.has(de)).length;return n.jsx(Br,{heading:n.jsx($d,{conn:J.conn,on:oe,total:te.length,onToggle:()=>q(te,oe!==te.length)}),children:J.tools.map(de=>n.jsx(Md,{value:`${de.display} ${de.name} ${J.conn?.title??""}`,checked:F.has(de.name),onToggle:()=>W(de.name),title:de.display,description:de.description},de.name))},J.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]=g,e[14]=_,e[15]=b,e[16]=x,e[17]=v,e[18]=y,e[19]=S,e[20]=w,e[21]=C,e[22]=N,e[23]=E,e[24]=R}else p=e[12],g=e[13],_=e[14],b=e[15],x=e[16],v=e[17],y=e[18],S=e[19],w=e[20],C=e[21],N=e[22],E=e[23],R=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==S?(T=n.jsx(p,{className:y,children:S}),e[50]=p,e[51]=y,e[52]=S,e[53]=T):T=e[53];let k;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==C?(k=n.jsxs(g,{children:[w,C,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=C,e[58]=k):k=e[58];let j;e[59]!==_||e[60]!==k||e[61]!==N||e[62]!==E?(j=n.jsx(_,{className:N,align:E,children:k}),e[59]=_,e[60]=k,e[61]=N,e[62]=E,e[63]=j):j=e[63];let I;return e[64]!==b||e[65]!==x||e[66]!==v||e[67]!==j||e[68]!==R?(I=n.jsxs(b,{open:R,onOpenChange:x,children:[v,j]}),e[64]=b,e[65]=x,e[66]=v,e[67]=j,e[68]=R,e[69]=I):I=e[69],I}function c3(t){return t.name}function d3(t){return t.name}function h3(t){return t.name}function u3(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function f3(t){return[t.id,t]}function An(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function m3(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"),d=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${d} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${d} at ${c}:${h} UTC`}return t}function p3(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 g3(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 _3(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const v3=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function x3({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=qn(),[l,d]=D.useState(!1),c=e??l,h=m=>{s?s(m):d(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),he.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";he.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):he.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";he.error(p)}};return n.jsxs(Wt,{open:c,onOpenChange:h,children:[n.jsx(Vt,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",children:[n.jsx(Dt,{size:14}),"Add Starter"]})}),n.jsxs(Kt,{align:"end",className:"w-[200px]",children:[n.jsxs(ha,{children:[n.jsxs(ua,{className:"gap-2.5",children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(fa,{className:"w-[160px]",children:v3.map(m=>n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{h(!1),i?.()},children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Ui,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Bm(t){const e=U.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,d=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,[h,u]=D.useState(null),[f,m]=D.useState("curl"),[p,g]=D.useState("header"),_=D.useId();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=async(A,O)=>{try{await navigator.clipboard.writeText(A),u(O),he.success("Copied"),setTimeout(()=>u(null),1500)}catch{he.error("Failed to copy")}},e[0]=b):b=e[0];const x=b;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}" \\
468
- -H "Authorization: Bearer ${o}" \\
469
- -H "Content-Type: application/json" \\
470
- -d '{"hello":"world"}'`:`curl -X POST "${y}" \\
471
- -H "Content-Type: application/json" \\
472
- -d '{"hello":"world"}'`:"",w=r&&o?p==="header"?`await fetch("${y}", {
473
- method: "POST",
474
- headers: {
475
- Authorization: "Bearer ${o}",
476
- "Content-Type": "application/json",
477
- },
478
- body: JSON.stringify({ hello: "world" }),
479
- });`:`await fetch("${y}", {
480
- method: "POST",
481
- headers: {
482
- "Content-Type": "application/json",
483
- },
484
- body: JSON.stringify({ hello: "world" }),
485
- });`:"",C=f==="curl"?S:w;let N;e[5]!==d?(N=n.jsx(ss,{children:d}),e[5]=d,e[6]=N):N=e[6];let E;e[7]!==c?(E=n.jsx(Wi,{children:c}),e[7]=c,e[8]=E):E=e[8];let R;e[9]!==N||e[10]!==E?(R=n.jsxs(ts,{children:[N,E]}),e[9]=N,e[10]=E,e[11]=R):R=e[11];let T;e[12]!==p||e[13]!==h||e[14]!==y||e[15]!==f||e[16]!==C||e[17]!==o||e[18]!==_||e[19]!==r?(T=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(ie,{size:"sm",variant:"outline",onClick:()=>x(y,"url"),children:[n.jsx(as,{size:13}),h==="url"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>x(o,"token"),children:[n.jsx(as,{size:13}),h==="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(lo,{value:f,onValueChange:A=>m(A),children:n.jsxs(ao,{className:"h-8 p-[2px]",children:[n.jsx(zs,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(zs,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),n.jsxs("label",{htmlFor:_,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Ki,{id:_,checked:p==="url",onCheckedChange:A=>g(A?"url":"header")}),"Token in URL"]})]}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>x(C,"example"),children:[n.jsx(as,{size:13}),h==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(Gu,{code:C,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=h,e[14]=y,e[15]=f,e[16]=C,e[17]=o,e[18]=_,e[19]=r,e[20]=T):T=e[20];let k;e[21]!==i?(k=n.jsx(Ws,{children:n.jsx(ie,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=k):k=e[22];let j;e[23]!==R||e[24]!==T||e[25]!==k?(j=n.jsxs(Mt,{className:"max-w-lg",children:[R,T,k]}),e[23]=R,e[24]=T,e[25]=k,e[26]=j):j=e[26];let I;return e[27]!==i||e[28]!==s||e[29]!==j?(I=n.jsx(Bt,{open:s,onOpenChange:i,children:j}),e[27]=i,e[28]=s,e[29]=j,e[30]=I):I=e[30],I}function b3(t){const e=U.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=qn(),[d,c]=D.useState(!1),[h,u]=D.useState(!1),[f,m]=D.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?g3(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const g=p,[_,b]=D.useState(g?.count??1),[x,v]=D.useState(!1),[y,S]=D.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,C=s.type==="cron",N=s.type==="webhook";let E;e[2]!==i||e[3]!==a||e[4]!==s.id?(E=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),he.success("Starter removed")}catch{he.error("Failed to remove starter")}c(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=E):E=e[5];const R=E;let T;e[6]!==o||e[7]!==i||e[8]!==y||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(T=async()=>{const te=y.trim();if(!te||!An(te)||te===s.cron_expression){v(!1),S(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:te}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),v(!1)}catch{he.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]=T):T=e[12];const k=T;let j;e[13]!==i||e[14]!==l||e[15]!==s.id?(j=async()=>{u(!1);try{const te=await l.mutateAsync({trigger_id:s.id,automation_id:i});m({url:te.url,token:te.token})}catch(te){const oe=te,de=oe instanceof Error?oe.message:"Failed to rotate token";he.error(de)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=j):j=e[16];const I=j;let A;e[17]!==o||e[18]!==i||e[19]!==g||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(A=async te=>{if(!g)return;const oe=g.unit==="minutes"?5:1,de=Math.max(oe,te);de!==te&&b(de);const be=p3(de,g.unit);if(be!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:be}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{he.error("Failed to update starter"),b(g.count)}},e[17]=o,e[18]=i,e[19]=g,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=A):A=e[23];const O=A;let L;e[24]!==C||e[25]!==N?(L=C?n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}):N?n.jsx(Ui,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=C,e[25]=N,e[26]=L):L=e[26];let P;e[27]!==r||e[28]!==_||e[29]!==y||e[30]!==O||e[31]!==k||e[32]!==g||e[33]!==C||e[34]!==x||e[35]!==w||e[36]!==N||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(P=g&&C?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:g.unit==="minutes"?5:1,value:_,onChange:te=>b(parseInt(te.target.value)||1),onBlur:()=>O(_),onKeyDown:te=>{te.key==="Enter"&&te.target.blur(),te.key==="Escape"&&b(g.count)},disabled:w,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),n.jsx("span",{className:"text-sm",children:_3(g.unit,_)})]}):C&&x?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:y,onChange:te=>S(te.target.value),onBlur:k,onKeyDown:te=>{te.key==="Enter"&&te.target.blur(),te.key==="Escape"&&(v(!1),S(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),y&&!An(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:C?m3(s.cron_expression??""):N?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!C&&!N&&s.params&&Object.keys(s.params).length>0&&n.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(y3).join(", ")})]}),e[27]=r,e[28]=_,e[29]=y,e[30]=O,e[31]=k,e[32]=g,e[33]=C,e[34]=x,e[35]=w,e[36]=N,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=P):P=e[40];let B;e[41]!==w?(B=w&&n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=B):B=e[42];let F;e[43]!==g||e[44]!==C||e[45]!==x||e[46]!==s.cron_expression?(F=C&&!g&&!x&&n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{S(s.cron_expression??""),v(!0)},children:n.jsx(Cl,{size:13,className:"text-muted-foreground"})}),e[43]=g,e[44]=C,e[45]=x,e[46]=s.cron_expression,e[47]=F):F=e[47];let H;e[48]!==N?(H=N&&n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:n.jsx(Pn,{size:13,className:"text-muted-foreground"})}),e[48]=N,e[49]=H):H=e[49];let z;e[50]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:n.jsx(Hs,{size:13,className:"text-muted-foreground"})}),e[50]=z):z=e[50];let W;e[51]!==H||e[52]!==B||e[53]!==F?(W=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[B,F,H,z]}),e[51]=H,e[52]=B,e[53]=F,e[54]=W):W=e[54];let q;e[55]!==W||e[56]!==L||e[57]!==P?(q=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[L,P,W]}),e[55]=W,e[56]=L,e[57]=P,e[58]=q):q=e[58];let K;e[59]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsxs(Er,{children:[n.jsx(Tr,{children:"Remove Starter"}),n.jsx(Ar,{children:"Are you sure you want to remove this starter?"})]}),e[59]=K):K=e[59];let Z;e[60]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(Pr,{children:"Cancel"}),e[60]=Z):Z=e[60];let Y;e[61]!==R?(Y=n.jsxs(Nr,{children:[K,n.jsxs(Rr,{children:[Z,n.jsx(Dr,{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=R,e[62]=Y):Y=e[62];let G;e[63]!==d||e[64]!==Y?(G=n.jsx(jr,{open:d,onOpenChange:c,children:Y}),e[63]=d,e[64]=Y,e[65]=G):G=e[65];let Q;e[66]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsxs(Er,{children:[n.jsx(Tr,{children:"Rotate webhook token"}),n.jsx(Ar,{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]=Q):Q=e[66];let $;e[67]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(Pr,{children:"Cancel"}),e[67]=$):$=e[67];let X;e[68]!==I?(X=n.jsxs(Nr,{children:[Q,n.jsxs(Rr,{children:[$,n.jsx(Dr,{onClick:I,children:"Rotate"})]})]}),e[68]=I,e[69]=X):X=e[69];let V;e[70]!==h||e[71]!==X?(V=n.jsx(jr,{open:h,onOpenChange:u,children:X}),e[70]=h,e[71]=X,e[72]=V):V=e[72];const se=f!==null;let ee;e[73]===Symbol.for("react.memo_cache_sentinel")?(ee=te=>{te||m(null)},e[73]=ee):ee=e[73];const le=f?.url??null,ce=f?.token??null;let fe;e[74]!==se||e[75]!==le||e[76]!==ce?(fe=n.jsx(Bm,{open:se,onOpenChange:ee,url:le,token:ce,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=se,e[75]=le,e[76]=ce,e[77]=fe):fe=e[77];let J;return e[78]!==q||e[79]!==G||e[80]!==V||e[81]!==fe?(J=n.jsxs(n.Fragment,{children:[q,G,V,fe]}),e[78]=q,e[79]=G,e[80]=V,e[81]=fe,e[82]=J):J=e[82],J}function y3(t){const[e,s]=t;return`${e}: ${s}`}const S3=30;function w3(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 C3(t){const e=U.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=Vn(r),[a,l]=D.useState(),[d,c]=D.useState();let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={},e[1]=h):h=e[1];const[u,f]=D.useState(h),{triggerAdd:m}=qn(),{data:p,isLoading:g}=D1(a);let _,b,x,v,y,S;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==d||e[6]!==g||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==p){const N=p?.find(P=>P.type===d);let E;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==d||e[21]!==i||e[22]!==u?(E=async()=>{if(!(!a||!d))try{await m.mutateAsync({automation_id:s,type:"event",event_type:d,connection_id:a,params:u}),Ke("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:d}),he.success("Event trigger added"),i()}catch{he.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=d,e[21]=i,e[22]=u,e[23]=E):E=e[23],_=E,b="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let R,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),R=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=R,e[25]=T):(R=e[24],T=e[25]);let k;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Hs,{size:13}),e[26]=k):k=e[26],e[27]!==i?(x=n.jsxs("div",{className:"flex items-center gap-2",children:[T,R,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]=x):x=e[28];const j=a??"";let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=P=>{l(P),c(void 0),f({})},e[29]=I):I=e[29];let A;e[30]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select connection..."})}),e[30]=A):A=e[30];let O;e[31]!==o?(O=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(N3),e[31]=o,e[32]=O):O=e[32];let L;e[33]!==O?(L=n.jsx(jt,{children:O}),e[33]=O,e[34]=L):L=e[34],e[35]!==j||e[36]!==L?(v=n.jsxs(Nt,{value:j,onValueChange:I,children:[A,L]}),e[35]=j,e[36]=L,e[37]=v):v=e[37],e[38]!==a||e[39]!==d||e[40]!==g||e[41]!==p?(y=a&&n.jsxs(Nt,{value:d??"",onValueChange:P=>{c(P),f({})},children:[n.jsx(kt,{className:"w-full",children:g?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Oe,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Rt,{placeholder:"Select event type...",children:d??"Select event type..."})}),n.jsx(jt,{children:p?.map(j3)})]}),e[38]=a,e[39]=d,e[40]=g,e[41]=p,e[42]=y):y=e[42],S=N?.paramsSchema&&Object.keys(N.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(N.paramsSchema).map(P=>{const[B,F]=P;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[B,F.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",F.description]})]}),F.enum?n.jsxs(Nt,{value:u[B]??"",onValueChange:H=>f(z=>({...z,[B]:H})),children:[n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:`Select ${B}...`})}),n.jsx(jt,{children:F.enum.map(k3)})]}):n.jsx("input",{type:"text",value:u[B]??"",onChange:H=>f(z=>({...z,[B]:H.target.value})),placeholder:F.description??B,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},B)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=d,e[6]=g,e[7]=i,e[8]=u,e[9]=o,e[10]=p,e[11]=_,e[12]=b,e[13]=x,e[14]=v,e[15]=y,e[16]=S}else _=e[11],b=e[12],x=e[13],v=e[14],y=e[15],S=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==d||e[46]!==_?(w=a&&d&&n.jsx(ie,{size:"sm",onClick:_,disabled:m.isPending,children:m.isPending?n.jsx(Oe,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=d,e[46]=_,e[47]=w):w=e[47];let C;return e[48]!==b||e[49]!==x||e[50]!==v||e[51]!==y||e[52]!==S||e[53]!==w?(C=n.jsxs("div",{className:b,children:[x,v,y,S,w]}),e[48]=b,e[49]=x,e[50]=v,e[51]=y,e[52]=S,e[53]=w,e[54]=C):C=e[54],C}function k3(t){return n.jsx(tt,{value:t,children:t},t)}function j3(t){return n.jsx(tt,{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 N3(t){return n.jsx(tt,{value:t.id,children:t.title},t.id)}function E3({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=Me(),{update:a,triggerAdd:l,run:d}=qn(),c=Vn(),h=new Map(c.map(ee=>[ee.id,ee.title])),{openTask:u}=Ts(),{setChatOpen:f}=fl(),{sendMessage:m}=li(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[g,_]=D.useState(p),[b,x]=D.useState(!1),[v,y]=D.useState(!1),[S,w]=D.useState(!1),[C,N]=D.useState(""),[E,R]=D.useState(!1),[T,k]=D.useState(null),[j,I]=D.useState(!1),[A,O]=D.useState(!1),[L,P]=D.useState(!1),B=async()=>{if(j)return;const le=pg(g).filter(ce=>ce.type==="text").map(ce=>ce.text).join(`
486
- `);if(le.trim()){I(!0);try{X(),Ke("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:le.length}),f(!0),await m({tiptapDoc:kf({managerAgentId:eu.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:le})})}finally{I(!1)}}},F=e.models?.tier??"smart",H=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,z=Wh({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),W=z.watch("active"),[q,K]=D.useReducer(w3,null),Z=()=>{q!==null&&(Ke("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(q.fields),save_count:q.saveCount,edit_duration_ms:Date.now()-q.start}),K({type:"reset"}))},Y=async()=>{const ee=z.control._formState.dirtyFields,le=Object.keys(ee);if(le.length===0&&!L)return!0;const ce=z.getValues(),fe=z.control._defaultValues;z.reset(ce,{keepValues:!0});const J=L;P(!1);const te={tier:ce.tier,...ce.modelOverride?{modelId:ce.modelOverride.modelId,credentialId:ce.modelOverride.credentialId,modelTitle:ce.modelOverride.title}:{}},oe={id:t,name:ce.name,active:ce.active,models:te,tools:ce.tools,maxAgentSteps:ce.maxAgentSteps,messages:mg(g),temperature:0};try{await a.mutateAsync(oe)}catch{return z.reset(fe,{keepValues:!0}),J&&P(!0),!1}const de=[...le];return J&&de.push("messages"),K({type:"accumulate",now:Date.now(),fields:de}),$(),!0},{schedule:G,flush:Q}=Lr({save:Y}),{schedule:$,flush:X}=Lr({delayMs:3e4,save:async()=>Z()});D.useEffect(()=>{const ee=z.watch(()=>G());return()=>ee.unsubscribe()},[]);const V=ee=>{if(_(ee),!A){O(!0);return}P(!0),G()},se=async()=>{Ke("automation_test_clicked",{automation_id:t,agent_id:r});const ee=await Q();if(X(),!!ee){if(!g){he.error("No instructions configured for this automation");return}try{const le=await d.mutateAsync(t);le.threadId&&(f(!0),u(le.threadId))}catch{}}};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(zu,{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(Ht,{control:z.control,name:"name",render:({field:ee})=>n.jsx(ze,{...ee,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(es,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ht,{control:z.control,name:"active",render:({field:ee})=>n.jsx(On,{checked:ee.value,onCheckedChange:le=>{ee.onChange(le),Q()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(jf,{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(x3,{automationId:t,open:b,onOpenChange:x,onCustomSelect:()=>{w(!0),R(!1),N("")},onEventSelect:()=>{R(!0),w(!1)},onWebhookCreated:ee=>{Ke("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),k(ee)}})]}),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:()=>x(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ee=>n.jsx(b3,{trigger:ee,automationId:t,connectionName:ee.connection_id?h.get(ee.connection_id):void 0},ee.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(kn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:C,onChange:ee=>N(ee.target.value),onBlur:async()=>{const ee=C.trim();if(!(!ee||!An(ee)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ee}),Ke("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),he.success("Starter added"),w(!1),N("")}catch{he.error("Failed to add starter")}},onKeyDown:async ee=>{const le=C.trim();ee.key==="Enter"&&le&&An(le)&&ee.target.blur(),ee.key==="Escape"&&(w(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),C&&!An(C)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),N("")},children:n.jsx(Hs,{size:13})})]}),E&&n.jsx(D.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(Oe,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(C3,{automationId:t,onDone:()=>R(!1)})}),n.jsx(Bm,{open:T!==null,onOpenChange:ee=>{ee||k(null)},url:T?.url??null,token:T?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:j||!g,onClick:B,children:[n.jsx(Zs,{size:13}),"Improve"]})]}),n.jsx(dg,{tiptapDoc:g,setTiptapDoc:V,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(hg,{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(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:se,disabled:!r,children:[n.jsx(S1,{size:16}),"Test"]})}),n.jsx(Ee,{children:"Test Automation"})]})})]})})]}),n.jsxs(Pg,{open:v,onOpenChange:y,className:"flex flex-col gap-2.5",children:[n.jsxs(Dg,{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(cs,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(Ig,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(i3,{tier:z.watch("tier"),onTierChange:ee=>z.setValue("tier",ee,{shouldDirty:!0}),override:z.watch("modelOverride"),onOverrideChange:ee=>z.setValue("modelOverride",ee,{shouldDirty:!0})}),n.jsx(a3,{agentId:r||null,value:z.watch("tools"),onChange:ee=>z.setValue("tools",ee,{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(ze,{type:"number",min:1,max:100,className:"w-40",placeholder:`${S3} (default)`,value:z.watch("maxAgentSteps")??"",onChange:ee=>{const le=ee.target.value.trim(),ce=le===""?null:Number(le);z.setValue("maxAgentSteps",ce===null||Number.isNaN(ce)?null:ce,{shouldDirty:!0})}})]})]})]})]})]})}function Bi(){const t=U.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(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const Mm=[{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 $m(t){const e=Mm.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function T3(t){const e=U.c(12),{automationId:s,triggerIds:i}=t,[r,o]=D.useState("30d"),[a,l]=D.useState(R3);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=p=>{const g=p;o(g),l($m(g))},e[0]=d):d=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(kt,{className:"w-44",children:n.jsx(Rt,{})}),e[1]=c):c=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(jt,{children:Mm.map(A3)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(Nt,{value:r,onValueChange:d,children:[c,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==i?(f=n.jsx(j1,{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 A3(t){return n.jsx(tt,{value:t.key,children:t.label},t.key)}function R3(){return $m("30d")}function P3(t){const e=U.c(5),{tabId:s}=t;let i;e[0]!==s?(i=pu(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(Bi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(D.Suspense,{fallback:o,children:n.jsx(D3,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function D3(t){const e=U.c(24),{id:s}=t,i=qt(),{data:r,isLoading:o}=I1(s),[a,l]=D.useState("settings");let d;e[0]!==i?(d=()=>{i({to:".",search:L3,replace:!0})},e[0]=i,e[1]=d):d=e[1];const c=d;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Bi,{}),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 h;e[4]!==r.triggers?(h=r.triggers.map(I3),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zu,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(ie,{variant:"ghost",size:"sm",onClick:c,children:[f,"Back to list"]}),e[7]=c,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let _;e[11]!==a?(_=n.jsx(Hu,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=_):_=e[12];let b;e[13]!==m||e[14]!==_?(b=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,_]}),e[13]=m,e[14]=_,e[15]=b):b=e[15];let x;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(x=a==="settings"?n.jsx(E3,{automationId:s,automation:r}):n.jsx(T3,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=x):x=e[20];let v;return e[21]!==b||e[22]!==x?(v=n.jsx(os,{children:n.jsx(os.Content,{children:n.jsxs(os.Body,{children:[b,x]})})}),e[21]=b,e[22]=x,e[23]=v):v=e[23],v}function I3(t){return t.id}function L3(t){return{...t,main:"automations"}}function O3(t){const e=U.c(20),{virtualMcpId:s}=t,i=qt(),{data:r}=L1(s),o=r===void 0?[]:r,{create:a}=qn(),[l,d]=D.useState(""),c=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(c));let u;e[0]!==i?(u=T=>i({to:".",search:k=>({...k,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ke("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(O1(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Dt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=n.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const _=g,b=os,x=os,v=os;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(os.Title,{children:"Automations"}),e[6]=y):y=e[6];const S=o.length>0&&n.jsx(Fu,{value:l,onChange:d,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==_||e[8]!==S?(w=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,_]})]}),e[7]=_,e[8]=S,e[9]=w):w=e[9];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Cr,{image:n.jsx(Mn,{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:_})}):h.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Cr,{image:n.jsx(Mn,{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:h.map(T=>n.jsx(B1,{automation:T,onClick:()=>f(T.id)},T.id))});let N;e[10]!==C||e[11]!==v.Body||e[12]!==w?(N=n.jsxs(v.Body,{children:[w,C]}),e[10]=C,e[11]=v.Body,e[12]=w,e[13]=N):N=e[13];let E;e[14]!==N||e[15]!==x.Content?(E=n.jsx(x.Content,{children:N}),e[14]=N,e[15]=x.Content,e[16]=E):E=e[16];let R;return e[17]!==b||e[18]!==E?(R=n.jsx(b,{children:E}),e[17]=b,e[18]=E,e[19]=R):R=e[19],R}function B3(t){const e=U.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Bi,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(O3,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function M3(t){const e=U.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx(Pi,{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=l_(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 d;e[7]!==r||e[8]!==o||e[9]!==l?(d=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]=d):d=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Y_,{size:14}),e[11]=c):c=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx("a",{href:s.downloadUrl,download:s.filename,children:c})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ee,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=n.jsxs(Te,{children:[h,u]}),e[16]=h,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(hi,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ee,{side:"bottom",children:"Open in new tab"}),e[23]=_):_=e[23];let b;e[24]!==g?(b=n.jsxs(Te,{children:[g,_]}),e[24]=g,e[25]=b):b=e[25];let x;e[26]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Hs,{size:14}),e[26]=x):x=e[26];let v;e[27]!==i?(v=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:i,children:x})}),e[27]=i,e[28]=v):v=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ee,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let S;e[30]!==v?(S=n.jsxs(Te,{children:[v,y]}),e[30]=v,e[31]=S):S=e[31];let w;return e[32]!==b||e[33]!==S||e[34]!==d||e[35]!==f?(w=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[d,f,b,S]}),e[32]=b,e[33]=S,e[34]=d,e[35]=f,e[36]=w):w=e[36],w}function $3(t){const e=U.c(24),{fileKey:s,taskId:i}=t,r=qt(),{data:o,isPending:a}=Jh(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 d=l;let c;e[3]!==r?(c=()=>r({to:".",search:z3,replace:!0}),e[3]=r,e[4]=c):c=e[4];const h=c;if(!d){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(o_,{})}),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 g;e[8]!==p?(g=n.jsx(Pi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=_):_=e[10];let b;e[11]!==h?(b=n.jsx(ie,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=b):b=e[12];let x;return e[13]!==g||e[14]!==b?(x=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,_,b]}),e[13]=g,e[14]=b,e[15]=x):x=e[15],x}let u;e[16]!==d||e[17]!==h?(u=n.jsx(M3,{file:d,onClose:h}),e[16]=d,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==d?(f=n.jsx("div",{className:"relative min-h-0 flex-1",children:n.jsx(a_,{file:d})}),e[19]=d,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 z3(t){return{...t,main:"0"}}const Vo="home";function F3(t){const e=U.c(5),{label:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(wl,{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 H3(t){const e=U.c(15),{path:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={refetchIntervalWhenAbsent:2e3},e[0]=i):i=e[0];const r=c_(Vo,s,i),o=d_(Vo)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=n.jsx(F3,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=h_(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",d=r.data.effectivePublic??!1,c=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==d||e[8]!==c?(h=n.jsx(u_,{volume:Vo,path:s,shareMode:l,effectivePublic:d,url:c}),e[5]=s,e[6]=l,e[7]=d,e[8]=c,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=n.jsx(f_,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function U3(t){const e=U.c(5),{path:s}=t,i=qt();let r;e[0]!==i?(r=()=>i({to:".",search:W3,replace:!0}),e[0]=i,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=n.jsx(m_,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function W3(t){return{...t,main:"0"}}const zd=D.lazy(()=>ls(()=>import("./project-app-view-C9CksfQE.js"),__vite__mapDeps([153,1,2,44,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,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,118,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.AppViewContent})));function V3(t){const e=U.c(53),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(Zg(s)){let v;return e[0]!==i?(v=n.jsx(id,{virtualMcpId:i}),e[0]=i,e[1]=v):v=e[1],v}if(s==="git"){let v;return e[2]!==i?(v=n.jsx(e0,{virtualMcpId:i}),e[2]=i,e[3]=v):v=e[3],v}if(s==="automations"){let v;return e[4]!==i?(v=n.jsx(B3,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(o2,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(e3,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(P3,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let d;e[12]!==s?(d=_u(s),e[12]=s,e[13]=d):d=e[13];const c=d;if(c){let v;return e[14]!==c.path?(v=n.jsx(H3,{path:c.path},c.path),e[14]=c.path,e[15]=v):v=e[15],v}let h;e[16]!==s?(h=gu(s),e[16]=s,e[17]=h):h=e[17];const u=h;if(u){let v;return e[18]!==u.key||e[19]!==r?(v=n.jsx($3,{fileKey:u.key,taskId:r}),e[18]=u.key,e[19]=r,e[20]=v):v=e[20],v}let f;e[21]!==s?(f=vu(s),e[21]=s,e[22]=f):f=e[22];const m=f;if(m){let v;return e[23]!==m.path?(v=n.jsx(U3,{path:m.path},m.path),e[23]=m.path,e[24]=v):v=e[24],v}let p;e[25]!==s?(p=Qg(s),e[25]=s,e[26]=p):p=e[26];const g=p;if(g){let v;if(e[27]!==a||e[28]!==g.connectionId||e[29]!==g.toolName){let N;e[31]!==g.connectionId||e[32]!==g.toolName?(N=E=>E.appId===g.connectionId&&E.toolName===g.toolName,e[31]=g.connectionId,e[32]=g.toolName,e[33]=N):N=e[33],v=a.find(N),e[27]=a,e[28]=g.connectionId,e[29]=g.toolName,e[30]=v}else v=e[30];const y=v;let S;e[34]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Bi,{}),e[34]=S):S=e[34];const w=y?.args;let C;return e[35]!==s||e[36]!==g.connectionId||e[37]!==g.toolName||e[38]!==w?(C=n.jsx(D.Suspense,{fallback:S,children:n.jsx(zd,{connectionId:g.connectionId,toolName:g.toolName,args:w},s)}),e[35]=s,e[36]=g.connectionId,e[37]=g.toolName,e[38]=w,e[39]=C):C=e[39],C}let _;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],_=o.find(v),e[40]=s,e[41]=o,e[42]=_}else _=e[42];const b=_;if(b){let v;e[45]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Bi,{}),e[45]=v):v=e[45];let y;return e[46]!==s||e[47]!==b.id||e[48]!==b.view.appId||e[49]!==b.view.args?(y=n.jsx(D.Suspense,{fallback:v,children:n.jsx(zd,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[46]=s,e[47]=b.id,e[48]=b.view.appId,e[49]=b.view.args,e[50]=y):y=e[50],y}let x;return e[51]!==i?(x=n.jsx(id,{virtualMcpId:i}),e[51]=i,e[52]=x):x=e[52],x}function K3(t){const e=U.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:d}=Yl(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Bi,{}),e[3]=c):c=e[3];let h;e[4]!==o||e[5]!==d||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==i?(h=n.jsx(D.Suspense,{fallback:c,children:n.jsx(V3,{activeTab:o,virtualMcpId:i,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:d})}),e[4]=o,e[5]=d,e[6]=l,e[7]=a,e[8]=s,e[9]=i,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=n.jsx(Zt,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const Qs="setup";function q3(t){const e=U.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===Qs?t.onToggle():t.onSelectTab(Qs)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Qs;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(G3,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let d;e[11]!==t?(d=t.scriptTabs.map(m=>n.jsx(X3,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=d):d=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(J3,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let h;e[16]!==l||e[17]!==d||e[18]!==c?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,d,c]}),e[16]=l,e[17]=d,e[18]=c,e[19]=h):h=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(Z3,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Y3,{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]!==h||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:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function G3(t){const e=U.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 d;e[0]!==l?(d=ae("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(q_,{className:"size-3.5"}),e[2]=c):c=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==d?(h=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:d,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=d,e[7]=h):h=e[7],h}function Y3(t){const e=U.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Di,{className:"size-3.5"}),e[0]=d):d=e[0];let c;return e[1]!==i?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:i,children:[d," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Di,{className:"size-3.5"}),e[3]=d):d=e[3];let c;return e[4]!==a?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[d," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Pn,{className:"size-3.5"}),e[6]=d):d=e[6];let c;return e[7]!==l?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[d," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const d=s==="running"&&!!o,c=d?"rounded-r-none border-r-0":void 0;let h;e[9]!==c?(h=ae(c),e[9]=c,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Au,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ee,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Te,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==d?(g=d&&n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(cs,{className:"size-3"})})}),n.jsx(Kt,{align:"end",children:n.jsxs(Ue,{onClick:o,children:[n.jsx(Pn,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=d,e[20]=g):g=e[20];let _;return e[21]!==p||e[22]!==g?(_=n.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=_):_=e[23],_}return null}function X3(t){const e=U.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=ae("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const d=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==d||e[3]!==c?(h=ae("flex h-full items-center",d,c),e[2]=d,e[3]=c,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==h?(u=n.jsx("button",{type:"button",onClick:i,className:h,children:o}),e[5]=o,e[6]=i,e[7]=h,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(jl,{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 J3(t){const e=U.c(10),{scripts:s,onRun:i}=t,[r,o]=D.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(Rs,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Dt,{className:"size-3.5"})})})}),n.jsx(Ee,{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 d;e[2]!==i||e[3]!==s?(d=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]=d):d=e[4];let c;e[5]!==d?(c=n.jsxs(Ps,{align:"start",className:"p-1 w-56",children:[l,d]}),e[5]=d,e[6]=c):c=e[6];let h;return e[7]!==r||e[8]!==c?(h=n.jsxs(As,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=h):h=e[9],h}function Z3(t){const e=U.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Oe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Di,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ee,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Te,{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(Au,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Ee,{children:"Stop process"}),e[10]=d):d=e[10];let c;return e[11]!==l?(c=n.jsxs(Te,{children:[l,d]}),e[11]=l,e[12]=c):c=e[12],c}var zm=Object.defineProperty,Q3=Object.getOwnPropertyDescriptor,ek=(t,e)=>{for(var s in e)zm(t,s,{get:e[s],enumerable:!0})},rt=(t,e,s,i)=>{for(var r=i>1?void 0:i?Q3(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&&zm(e,s,r),r},_e=(t,e)=>(s,i)=>e(s,i,t),Fd="Terminal input",ka={get:()=>Fd,set:t=>Fd=t},Hd="Too much output to announce, navigate to rows manually to read",ja={get:()=>Hd,set:t=>Hd=t};function tk(t){return t.replace(/\r?\n/g,"\r")}function sk(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function ik(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function nk(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Fm(r,e,s,i)}}function Fm(t,e,s,i){t=tk(t),t=sk(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Hm(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 Ud(t,e,s,i,r){Hm(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ms(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function xo(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 rk=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}},ok=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,d=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,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let _=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,b=_-p;for(;c<b;){if(c>=s)return 0;if(g=t[c++],(g&192)!==128){c--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(_===2?m<128?c--:e[i++]=m:_===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let h=s-4,u=c;for(;u<s;){for(;u<h&&!((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(d=(r&31)<<6|o&63,d<128){u--;continue}e[i++]=d}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(d=(r&15)<<12|(o&63)<<6|a&63,d<2048||d>=55296&&d<=57343||d===65279)continue;e[i++]=d}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(d=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,d<65536||d>1114111)continue;e[i++]=d}}return i}},Um="",$s=" ",Xn=class Wm{constructor(){this.fg=0,this.bg=0,this.extended=new Gr}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 Wm;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}},Gr=class Vm{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 Vm(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Qt=class Km extends Xn{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Gr,this.combinedData=""}static fromCharData(e){let s=new Km;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?Ms(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()]}},Wd="di$target",Na="di$dependencies",Ko=new Map;function ak(t){return t[Na]||[]}function xt(t){if(Ko.has(t))return Ko.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");lk(e,s,r)};return e._id=t,Ko.set(t,e),e}function lk(t,e,s){e[Wd]===e?e[Na].push({id:t,index:s}):(e[Na]=[{id:t,index:s}],e[Wd]=e)}var It=xt("BufferService"),qm=xt("CoreMouseService"),pi=xt("CoreService"),ck=xt("CharsetService"),gc=xt("InstantiationService"),Gm=xt("LogService"),Lt=xt("OptionsService"),Ym=xt("OscLinkService"),dk=xt("UnicodeService"),Jn=xt("DecorationService"),Ea=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 Qt,a=s.getTrimmedLength(),l=-1,d=-1,c=!1;for(let h=0;h<a;h++)if(!(d===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(d===-1){d=h,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else d!==-1&&(c=!0);if(c||d!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:d+1,y:t},end:{x:h+(!c&&h===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,g)=>r?r.activate(p,g,f):hk(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(d=h,l=o.extended.urlId):(d=-1,l=-1)}}e(i)}};Ea=rt([_e(0,It),_e(1,Lt),_e(2,Ym)],Ea);function hk(t,e){if(confirm(`Do you want to navigate to ${e}?
487
-
488
- 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 bo=xt("CharSizeService"),Ds=xt("CoreBrowserService"),_c=xt("MouseService"),Is=xt("RenderService"),uk=xt("SelectionService"),Xm=xt("CharacterJoinerService"),Qi=xt("ThemeService"),Jm=xt("LinkProviderService"),fk=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Vd.isErrorNoTelemetry(t)?new Vd(t.message+`
489
-
490
- `+t.stack):new Error(t.message+`
491
-
492
- `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},mk=new fk;function _r(t){pk(t)||mk.onUnexpectedError(t)}var Ta="Canceled";function pk(t){return t instanceof gk?!0:t instanceof Error&&t.name===Ta&&t.message===Ta}var gk=class extends Error{constructor(){super(Ta),this.name=this.message}};function _k(t){return new Error(`Illegal argument: ${t}`)}var Vd=class Aa extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Aa)return e;let s=new Aa;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Ra=class Zm extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,Zm.prototype)}};function $t(t,e=0){return t[t.length-(1+e)]}var vk;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function i(o){return o>0}t.isGreaterThan=i;function r(o){return o===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(vk||={});function xk(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var Qm;(t=>{function e(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(y){yield y}t.single=r;function o(y){return e(y)?y:r(y)}t.wrap=o;function a(y){return y||s}t.from=a;function*l(y){for(let S=y.length-1;S>=0;S--)yield y[S]}t.reverse=l;function d(y){return!y||y[Symbol.iterator]().next().done===!0}t.isEmpty=d;function c(y){return y[Symbol.iterator]().next().value}t.first=c;function h(y,S){let w=0;for(let C of y)if(S(C,w++))return!0;return!1}t.some=h;function u(y,S){for(let w of y)if(S(w))return w}t.find=u;function*f(y,S){for(let w of y)S(w)&&(yield w)}t.filter=f;function*m(y,S){let w=0;for(let C of y)yield S(C,w++)}t.map=m;function*p(y,S){let w=0;for(let C of y)yield*S(C,w++)}t.flatMap=p;function*g(...y){for(let S of y)yield*S}t.concat=g;function _(y,S,w){let C=w;for(let N of y)C=S(C,N);return C}t.reduce=_;function*b(y,S,w=y.length){for(S<0&&(S+=y.length),w<0?w+=y.length:w>y.length&&(w=y.length);S<w;S++)yield y[S]}t.slice=b;function x(y,S=Number.POSITIVE_INFINITY){let w=[];if(S===0)return[w,y];let C=y[Symbol.iterator]();for(let N=0;N<S;N++){let E=C.next();if(E.done)return[w,t.empty()];w.push(E.value)}return[w,{[Symbol.iterator](){return C}}]}t.consume=x;async function v(y){let S=[];for await(let w of y)S.push(w);return Promise.resolve(S)}t.asyncToArray=v})(Qm||={});function ni(t){if(Qm.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function bk(...t){return Ze(()=>ni(t))}function Ze(t){return{dispose:xk(()=>{t()})}}var ep=class tp{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ni(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?tp.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};ep.DISABLE_DISPOSED_WARNING=!1;var Fs=ep,Re=class{constructor(){this._store=new Fs,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Re.None=Object.freeze({dispose(){}});var Mi=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},ks=typeof window=="object"?window:globalThis,Pa=class Da{constructor(e){this.element=e,this.next=Da.Undefined,this.prev=Da.Undefined}};Pa.Undefined=new Pa(void 0);var Qe=Pa,Kd=class{constructor(){this._first=Qe.Undefined,this._last=Qe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Qe.Undefined}clear(){let t=this._first;for(;t!==Qe.Undefined;){let e=t.next;t.prev=Qe.Undefined,t.next=Qe.Undefined,t=e}this._first=Qe.Undefined,this._last=Qe.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new Qe(t);if(this._first===Qe.Undefined)this._first=s,this._last=s;else if(e){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==Qe.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==Qe.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==Qe.Undefined&&t.next!==Qe.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===Qe.Undefined&&t.next===Qe.Undefined?(this._first=Qe.Undefined,this._last=Qe.Undefined):t.next===Qe.Undefined?(this._last=this._last.prev,this._last.next=Qe.Undefined):t.prev===Qe.Undefined&&(this._first=this._first.next,this._first.prev=Qe.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==Qe.Undefined;)yield t.element,t=t.next}},yk=globalThis.performance&&typeof globalThis.performance.now=="function",Sk=class sp{static create(e){return new sp(e)}constructor(e){this._now=yk&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},wt;(t=>{t.None=()=>Re.None;function e(k,j){return u(k,()=>{},0,void 0,!0,void 0,j)}t.defer=e;function s(k){return(j,I=null,A)=>{let O=!1,L;return L=k(P=>{if(!O)return L?L.dispose():O=!0,j.call(I,P)},null,A),O&&L.dispose(),L}}t.once=s;function i(k,j,I){return c((A,O=null,L)=>k(P=>A.call(O,j(P)),null,L),I)}t.map=i;function r(k,j,I){return c((A,O=null,L)=>k(P=>{j(P),A.call(O,P)},null,L),I)}t.forEach=r;function o(k,j,I){return c((A,O=null,L)=>k(P=>j(P)&&A.call(O,P),null,L),I)}t.filter=o;function a(k){return k}t.signal=a;function l(...k){return(j,I=null,A)=>{let O=bk(...k.map(L=>L(P=>j.call(I,P))));return h(O,A)}}t.any=l;function d(k,j,I,A){let O=I;return i(k,L=>(O=j(O,L),O),A)}t.reduce=d;function c(k,j){let I,A={onWillAddFirstListener(){I=k(O.fire,O)},onDidRemoveLastListener(){I?.dispose()}},O=new me(A);return j?.add(O),O.event}function h(k,j){return j instanceof Array?j.push(k):j&&j.add(k),k}function u(k,j,I=100,A=!1,O=!1,L,P){let B,F,H,z=0,W,q={leakWarningThreshold:L,onWillAddFirstListener(){B=k(Z=>{z++,F=j(F,Z),A&&!H&&(K.fire(F),F=void 0),W=()=>{let Y=F;F=void 0,H=void 0,(!A||z>1)&&K.fire(Y),z=0},typeof I=="number"?(clearTimeout(H),H=setTimeout(W,I)):H===void 0&&(H=0,queueMicrotask(W))})},onWillRemoveListener(){O&&z>0&&W?.()},onDidRemoveLastListener(){W=void 0,B.dispose()}},K=new me(q);return P?.add(K),K.event}t.debounce=u;function f(k,j=0,I){return t.debounce(k,(A,O)=>A?(A.push(O),A):[O],j,void 0,!0,void 0,I)}t.accumulate=f;function m(k,j=(A,O)=>A===O,I){let A=!0,O;return o(k,L=>{let P=A||!j(L,O);return A=!1,O=L,P},I)}t.latch=m;function p(k,j,I){return[t.filter(k,j,I),t.filter(k,A=>!j(A),I)]}t.split=p;function g(k,j=!1,I=[],A){let O=I.slice(),L=k(F=>{O?O.push(F):B.fire(F)});A&&A.add(L);let P=()=>{O?.forEach(F=>B.fire(F)),O=null},B=new me({onWillAddFirstListener(){L||(L=k(F=>B.fire(F)),A&&A.add(L))},onDidAddFirstListener(){O&&(j?setTimeout(P):P())},onDidRemoveLastListener(){L&&L.dispose(),L=null}});return A&&A.add(B),B.event}t.buffer=g;function _(k,j){return(I,A,O)=>{let L=j(new x);return k(function(P){let B=L.evaluate(P);B!==b&&I.call(A,B)},void 0,O)}}t.chain=_;let b=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(j){return this.steps.push(j),this}forEach(j){return this.steps.push(I=>(j(I),I)),this}filter(j){return this.steps.push(I=>j(I)?I:b),this}reduce(j,I){let A=I;return this.steps.push(O=>(A=j(A,O),A)),this}latch(j=(I,A)=>I===A){let I=!0,A;return this.steps.push(O=>{let L=I||!j(O,A);return I=!1,A=O,L?O:b}),this}evaluate(j){for(let I of this.steps)if(j=I(j),j===b)break;return j}}function v(k,j,I=A=>A){let A=(...B)=>P.fire(I(...B)),O=()=>k.on(j,A),L=()=>k.removeListener(j,A),P=new me({onWillAddFirstListener:O,onDidRemoveLastListener:L});return P.event}t.fromNodeEventEmitter=v;function y(k,j,I=A=>A){let A=(...B)=>P.fire(I(...B)),O=()=>k.addEventListener(j,A),L=()=>k.removeEventListener(j,A),P=new me({onWillAddFirstListener:O,onDidRemoveLastListener:L});return P.event}t.fromDOMEventEmitter=y;function S(k){return new Promise(j=>s(k)(j))}t.toPromise=S;function w(k){let j=new me;return k.then(I=>{j.fire(I)},()=>{j.fire(void 0)}).finally(()=>{j.dispose()}),j.event}t.fromPromise=w;function C(k,j){return k(I=>j.fire(I))}t.forward=C;function N(k,j,I){return j(I),k(A=>j(A))}t.runAndSubscribe=N;class E{constructor(j,I){this._observable=j,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{j.addObserver(this)},onDidRemoveLastListener:()=>{j.removeObserver(this)}};this.emitter=new me(A),I&&I.add(this.emitter)}beginUpdate(j){this._counter++}handlePossibleChange(j){}handleChange(j,I){this._hasChanged=!0}endUpdate(j){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function R(k,j){return new E(k,j).emitter.event}t.fromObservable=R;function T(k){return(j,I,A)=>{let O=0,L=!1,P={beginUpdate(){O++},endUpdate(){O--,O===0&&(k.reportChanges(),L&&(L=!1,j.call(I)))},handlePossibleChange(){},handleChange(){L=!0}};k.addObserver(P),k.reportChanges();let B={dispose(){k.removeObserver(P)}};return A instanceof Fs?A.add(B):Array.isArray(A)&&A.push(B),B}}t.fromObservableLight=T})(wt||={});var Ia=class La{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${La._idPool++}`,La.all.add(this)}start(e){this._stopWatch=new Sk,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Ia.all=new Set,Ia._idPool=0;var wk=Ia,Ck=-1,ip=class np{constructor(e,s,i=(np._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let d=new Nk(l,o);this._errorHandler(d)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[i,r]of this._stacks)(!e||s<r)&&(e=[i,r],s=r);return e}};ip._idPool=1;var kk=ip,jk=class rp{constructor(e){this.value=e}static create(){let e=new Error;return new rp(e.stack??"")}print(){console.warn(this.value.split(`
493
- `).slice(2).join(`
494
- `))}},Nk=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Ek=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},Tk=0,qo=class{constructor(t){this.value=t,this.id=Tk++}},Ak=2,Rk,me=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new kk(t?.onListenerError??_r,this._options?.leakWarningThreshold??Ck):void 0,this._perfMon=this._options?._profName?new wk(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],d=new Ek(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||_r)(d),Re.None}if(this._disposed)return Re.None;e&&(t=t.bind(e));let i=new qo(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=jk.create(),r=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof qo?(this._deliveryQueue??=new Pk,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=Ze(()=>{r?.(),this._removeListener(i)});return s instanceof Fs?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Ak<=e.length){let r=0;for(let o=0;o<e.length;o++)e[o]?e[r++]=e[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||_r;if(!s){t.value(e);return}try{t.value(e)}catch(i){s(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof qo)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Pk=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Oa=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new me,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new me,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Oa.INSTANCE=new Oa;var vc=Oa;function Dk(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}vc.INSTANCE.onDidChangeZoomLevel;function Ik(t){return vc.INSTANCE.getZoomFactor(t)}vc.INSTANCE.onDidChangeFullscreen;var en=typeof navigator=="object"?navigator.userAgent:"",Ba=en.indexOf("Firefox")>=0,Lk=en.indexOf("AppleWebKit")>=0,xc=en.indexOf("Chrome")>=0,Ok=!xc&&en.indexOf("Safari")>=0;en.indexOf("Electron/")>=0;en.indexOf("Android")>=0;var Go=!1;if(typeof ks.matchMedia=="function"){let t=ks.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=ks.matchMedia("(display-mode: fullscreen)");Go=t.matches,Dk(ks,t,({matches:s})=>{Go&&e.matches||(Go=s)})}var ji="en",Ma=!1,$a=!1,vr=!1,op=!1,cr,xr=ji,qd=ji,Bk,Cs,ei=globalThis,Ft;typeof ei.vscode<"u"&&typeof ei.vscode.process<"u"?Ft=ei.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ft=process);var Mk=typeof Ft?.versions?.electron=="string",$k=Mk&&Ft?.type==="renderer";if(typeof Ft=="object"){Ma=Ft.platform==="win32",$a=Ft.platform==="darwin",vr=Ft.platform==="linux",vr&&Ft.env.SNAP&&Ft.env.SNAP_REVISION,Ft.env.CI||Ft.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cr=ji,xr=ji;let t=Ft.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);cr=e.userLocale,qd=e.osLocale,xr=e.resolvedLanguage||ji,Bk=e.languagePack?.translationsConfigFile}catch{}op=!0}else typeof navigator=="object"&&!$k?(Cs=navigator.userAgent,Ma=Cs.indexOf("Windows")>=0,$a=Cs.indexOf("Macintosh")>=0,(Cs.indexOf("Macintosh")>=0||Cs.indexOf("iPad")>=0||Cs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,vr=Cs.indexOf("Linux")>=0,Cs?.indexOf("Mobi")>=0,xr=globalThis._VSCODE_NLS_LANGUAGE||ji,cr=navigator.language.toLowerCase(),qd=cr):console.error("Unable to resolve platform.");var ap=Ma,gs=$a,zk=vr,Gd=op,_s=Cs,Ls=xr,Fk;(t=>{function e(){return Ls}t.value=e;function s(){return Ls.length===2?Ls==="en":Ls.length>=3?Ls[0]==="e"&&Ls[1]==="n"&&Ls[2]==="-":!1}t.isDefaultVariant=s;function i(){return Ls==="en"}t.isDefault=i})(Fk||={});var Hk=typeof ei.postMessage=="function"&&!ei.importScripts;(()=>{if(Hk){let t=[];ei.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let o=t[i];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),o.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),ei.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var Uk=!!(_s&&_s.indexOf("Chrome")>=0);_s&&_s.indexOf("Firefox")>=0;!Uk&&_s&&_s.indexOf("Safari")>=0;_s&&_s.indexOf("Edg/")>=0;_s&&_s.indexOf("Android")>=0;var yi=typeof navigator=="object"?navigator:{};Gd||document.queryCommandSupported&&document.queryCommandSupported("copy")||yi&&yi.clipboard&&yi.clipboard.writeText,Gd||yi&&yi.clipboard&&yi.clipboard.readText;var bc=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Yo=new bc,Yd=new bc,Xd=new bc,Wk=new Array(230),lp;(t=>{function e(l){return Yo.keyCodeToStr(l)}t.toString=e;function s(l){return Yo.strToKeyCode(l)}t.fromString=s;function i(l){return Yd.keyCodeToStr(l)}t.toUserSettingsUS=i;function r(l){return Xd.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function o(l){return Yd.strToKeyCode(l)||Xd.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Yo.keyCodeToStr(l)}t.toElectronAccelerator=a})(lp||={});var Vk=class cp{constructor(e,s,i,r,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(e){return e instanceof cp&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Kk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Kk=class{constructor(t){if(t.length===0)throw _k("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function qk(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return lp.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(Ba)switch(e){case 59:return 85;case 60:if(zk)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(gs)return 57;break}else if(Lk&&(gs&&e===93||!gs&&e===92))return 57;return Wk[e]||0}var Gk=gs?256:2048,Yk=512,Xk=1024,Jk=gs?2048:256,Jd=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=qk(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=Gk),this.altKey&&(e|=Yk),this.shiftKey&&(e|=Xk),this.metaKey&&(e|=Jk),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new Vk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},Zd=new WeakMap;function Zk(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var Qk=class{static getSameOriginWindowChain(t){let e=Zd.get(t);if(!e){e=[],Zd.set(t,e);let s=t,i;do i=Zk(s),i?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(t);for(let o of r){let a=o.window.deref();if(s+=a?.scrollY??0,i+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},dr=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Qk.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Qd=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let i=!1;if(xc){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(t){let r=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*a):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Ba&&!gs?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")Ok&&ap?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Ba&&!gs?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(i?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},dp=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),ej;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof tj?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:wt.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:dp})})(ej||={});var tj=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?dp:(this._emitter||(this._emitter=new me),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},yc=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new Ra("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new Ra("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},sj=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new Ra("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=Ze(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},ij;(t=>{async function e(i){let r,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return o}t.settled=e;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(a){o(a)}})}t.withAsyncBody=s})(ij||={});var eh=class Yt{static fromArray(e){return new Yt(s=>{s.emitMany(e)})}static fromPromise(e){return new Yt(async s=>{s.emitMany(await e)})}static fromPromises(e){return new Yt(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new Yt(async s=>{await Promise.all(e.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new me,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await wt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new Yt(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return Yt.map(this,e)}static filter(e,s){return new Yt(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return Yt.filter(this,e)}static coalesce(e){return Yt.filter(e,s=>!!s)}coalesce(){return Yt.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return Yt.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};eh.EMPTY=eh.fromArray([]);var{getWindow:ps,getWindowId:nj,onDidRegisterWindow:rj}=(function(){let t=new Map,e={window:ks,disposables:new Fs};t.set(ks.vscodeWindowId,e);let s=new me,i=new me,r=new me;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(a){if(t.has(a.vscodeWindowId))return Re.None;let l=new Fs,d={window:a,disposables:l.add(new Fs)};return t.set(a.vscodeWindowId,d),l.add(Ze(()=>{t.delete(a.vscodeWindowId),i.fire(a)})),l.add(Ce(a,pt.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(d),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let d=a;return d?.view?d.view.window:ks},getDocument(a){return ps(a).document}}})(),oj=class{constructor(t,e,s,i){this._node=t,this._type=e,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ce(t,e,s,i){return new oj(t,e,s,i)}var th=function(t,e,s,i){return Ce(t,e,s,i)},Sc,aj=class extends sj{constructor(t){super(),this.defaultTarget=t&&ps(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},sh=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){_r(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),i.set(o,!0);a.length>0;)a.sort(sh.sort),a.shift().execute();i.set(o,!1)};Sc=(o,a,l=0)=>{let d=nj(o),c=new sh(a,l),h=t.get(d);return h||(h=[],t.set(d,h)),h.push(c),s.get(d)||(s.set(d,!0),o.requestAnimationFrame(()=>r(d))),c}})();function lj(t){let e=t.getBoundingClientRect(),s=ps(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var pt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},cj=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Ot(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Ot(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Ot(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Ot(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Ot(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Ot(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Ot(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Ot(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Ot(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Ot(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Ot(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Ot(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Ot(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Ot(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Ot(t){return typeof t=="number"?`${t}px`:t}function Rn(t){return new cj(t)}var hp=class{constructor(){this._hooks=new Fs,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=t;try{t.setPointerCapture(e),this._hooks.add(Ze(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=ps(t)}this._hooks.add(Ce(o,pt.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Ce(o,pt.POINTER_UP,a=>this.stopMonitoring(!0)))}};function dj(t,e,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${e}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[o]}}var fs;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(fs||={});var xn=class Ct extends Re{constructor(){super(),this.dispatched=!1,this.targets=new Kd,this.ignoreTargets=new Kd,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(wt.runAndSubscribe(rj,({window:e,disposables:s})=>{s.add(Ce(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Ce(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(Ce(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:ks,disposables:this._store}))}static addTarget(e){if(!Ct.isTouchDevice())return Re.None;Ct.INSTANCE||(Ct.INSTANCE=new Ct);let s=Ct.INSTANCE.targets.push(e);return Ze(s)}static ignoreTarget(e){if(!Ct.isTouchDevice())return Re.None;Ct.INSTANCE||(Ct.INSTANCE=new Ct);let s=Ct.INSTANCE.ignoreTargets.push(e);return Ze(s)}static isTouchDevice(){return"ontouchstart"in ks||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=e.targetTouches.length;i<r;i++){let o=e.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(fs.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let d=this.activeTouches[l.identifier],c=Date.now()-d.initialTimeStamp;if(c<Ct.HOLD_DELAY&&Math.abs(d.initialPageX-$t(d.rollingPageX))<30&&Math.abs(d.initialPageY-$t(d.rollingPageY))<30){let h=this.newGestureEvent(fs.Tap,d.initialTarget);h.pageX=$t(d.rollingPageX),h.pageY=$t(d.rollingPageY),this.dispatchEvent(h)}else if(c>=Ct.HOLD_DELAY&&Math.abs(d.initialPageX-$t(d.rollingPageX))<30&&Math.abs(d.initialPageY-$t(d.rollingPageY))<30){let h=this.newGestureEvent(fs.Contextmenu,d.initialTarget);h.pageX=$t(d.rollingPageX),h.pageY=$t(d.rollingPageY),this.dispatchEvent(h)}else if(r===1){let h=$t(d.rollingPageX),u=$t(d.rollingPageY),f=$t(d.rollingTimestamps)-d.rollingTimestamps[0],m=h-d.rollingPageX[0],p=u-d.rollingPageY[0],g=[...this.targets].filter(_=>d.initialTarget instanceof Node&&_.contains(d.initialTarget));this.inertia(e,g,i,Math.abs(m)/f,m>0?1:-1,h,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(fs.End,d.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(e){if(e.type===fs.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ct.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===fs.Change||e.type===fs.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let r=0,o=e.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,i,r,o,a,l,d,c){this.handle=Sc(e,()=>{let h=Date.now(),u=h-i,f=0,m=0,p=!0;r+=Ct.SCROLL_FRICTION*u,l+=Ct.SCROLL_FRICTION*u,r>0&&(p=!1,f=o*r*u),l>0&&(p=!1,m=d*l*u);let g=this.newGestureEvent(fs.Change);g.translationX=f,g.translationY=m,s.forEach(_=>_.dispatchEvent(g)),p||this.inertia(e,s,h,r,o,a+f,l,d,c+m)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let o=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(fs.Change,a.initialTarget);l.translationX=o.pageX-$t(a.rollingPageX),l.translationY=o.pageY-$t(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};xn.SCROLL_FRICTION=-.005,xn.HOLD_DELAY=700,xn.CLEAR_TAP_COUNT_TIME=400,rt([dj],xn,"isTouchDevice",1);var hj=xn,wc=class extends Re{onclick(t,e){this._register(Ce(t,pt.CLICK,s=>e(new dr(ps(t),s))))}onmousedown(t,e){this._register(Ce(t,pt.MOUSE_DOWN,s=>e(new dr(ps(t),s))))}onmouseover(t,e){this._register(Ce(t,pt.MOUSE_OVER,s=>e(new dr(ps(t),s))))}onmouseleave(t,e){this._register(Ce(t,pt.MOUSE_LEAVE,s=>e(new dr(ps(t),s))))}onkeydown(t,e){this._register(Ce(t,pt.KEY_DOWN,s=>e(new Jd(s))))}onkeyup(t,e){this._register(Ce(t,pt.KEY_UP,s=>e(new Jd(s))))}oninput(t,e){this._register(Ce(t,pt.INPUT,e))}onblur(t,e){this._register(Ce(t,pt.BLUR,e))}onfocus(t,e){this._register(Ce(t,pt.FOCUS,e))}onchange(t,e){this._register(Ce(t,pt.CHANGE,e))}ignoreGesture(t){return hj.ignoreTarget(t)}},ih=11,uj=class extends wc{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=ih+"px",this.domNode.style.height=ih+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new hp),this._register(th(this.bgDomNode,pt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(th(this.domNode,pt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new aj),this._pointerdownScheduleRepeatTimer=this._register(new yc)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ps(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},fj=class za{constructor(e,s,i,r,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new za(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new za(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let i=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,d=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:d}}},mj=class extends Re{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new me),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new fj(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;e?i=new rh(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=rh.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},nh=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function Xo(t,e){let s=e-t;return function(i){return t+s*_j(i)}}function pj(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var rh=class Fa{constructor(e,s,i,r){this.from=e,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,i){if(Math.abs(e-s)>2.5*i){let r,o;return e<s?(r=e+.75*i,o=s-.75*i):(r=e-.75*i,o=s+.75*i),pj(Xo(e,r),Xo(o,s),.33)}return Xo(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new nh(i,r,!1)}return new nh(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return Fa.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new Fa(e,s,r,i)}};function gj(t){return Math.pow(t,3)}function _j(t){return 1-gj(1-t)}var vj=class extends Re{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new yc)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},xj=140,up=class extends wc{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new vj(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new hp),this._shouldRender=!0,this.domNode=Rn(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ce(this.domNode.domNode,pt.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new uj(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=Rn(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ce(this.slider.domNode,pt.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),i=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(t);s<=r&&r<=i?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let r=lj(this.domNode.domNode);e=t.pageX-r.left,s=t.pageY-r.top}let i=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-s);if(ap&&a>xj){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(r)-e;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},fp=class Ha{constructor(e,s,i,r,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ha(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,i,r,o){let a=Math.max(0,i-e),l=Math.max(0,a-2*s),d=r>0&&r>i;if(!d)return{computedAvailableSize:Math.round(a),computedIsNeeded:d,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/r))),h=(l-c)/(r-i),u=o*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:d,computedSliderSize:Math.round(c),computedSliderRatio:h,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=Ha._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},bj=class extends up{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new fp(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},yj=class extends up{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new fp(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},Sj=500,oh=50,wj=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Ua=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,i=1,r=this._rear;do{let o=r===this._front?e:Math.pow(2,-i);if(e-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(xc){let s=ps(e.browserEvent),i=Ik(s);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,i){let r=null,o=new wj(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),s){let r=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),d=Math.max(Math.min(r,a),1),c=Math.max(Math.min(o,l),1),h=Math.max(r,a),u=Math.max(o,l);h%d===0&&u%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Ua.INSTANCE=new Ua;var Cj=Ua,kj=class extends wc{constructor(t,e,s){super(),this._onScroll=this._register(new me),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new me),this.onWillScroll=this._onWillScroll.event,this._options=Nj(e),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new yj(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new bj(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Rn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Rn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Rn(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new yc),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ni(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,gs&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new Qd(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ni(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new Qd(s))};this._mouseWheelToDispose.push(Ce(this._listenOnDomNode,pt.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=Cj.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let a=!gs&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),d={};if(r){let c=oh*r,h=l.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(d,h)}if(o){let c=oh*o,h=l.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(d,h)}d=this._scrollable.validateScrollPosition(d),(l.scrollLeft!==d.scrollLeft||l.scrollTop!==d.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(d):this._scrollable.setScrollPositionNow(d),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,i=s?" left":"",r=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Sj)}},jj=class extends kj{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Nj(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,gs&&(e.className+=" mac"),e}var Wa=class extends Re{constructor(t,e,s,i,r,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new me),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let d=this._register(new mj({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>Sc(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{d.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new jj(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},d)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(wt.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(Ze(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(Ze(()=>this._styleElement.remove())),this._register(wt.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
495
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Wa=rt([_e(2,It),_e(3,Ds),_e(4,qm),_e(5,Qi),_e(6,Lt),_e(7,Is)],Wa);var Va=class extends Re{constructor(t,e,s,i,r){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(Ze(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};Va=rt([_e(1,It),_e(2,Ds),_e(3,Jn),_e(4,Is)],Va);var Ej=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},hs={full:0,left:0,center:0,right:0},Os={full:0,left:0,center:0,right:0},ln={full:0,left:0,center:0,right:0},Yr=class extends Re{constructor(t,e,s,i,r,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Ej,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Ze(()=>this._canvas?.remove()));let d=this._canvas.getContext("2d");if(d)this._ctx=d;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Os.full=this._canvas.width,Os.left=t,Os.center=e,Os.right=t,this._refreshDrawHeightConstants(),ln.full=1,ln.left=1,ln.center=1+Os.left,ln.right=1+Os.left+Os.center}_refreshDrawHeightConstants(){hs.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);hs.left=e,hs.center=e,hs.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hs.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(ln[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-hs[t.position||"full"]/2),Os[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+hs[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Yr=rt([_e(2,It),_e(3,Jn),_e(4,Is),_e(5,Lt),_e(6,Qi),_e(7,Ds)],Yr);var re;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
496
- `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(re||={});var br;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(br||={});var mp;(t=>t.ST=`${re.ESC}\\`)(mp||={});var Ka=class{constructor(t,e,s,i,r,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${re.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Ka=rt([_e(2,It),_e(3,Lt),_e(4,pi),_e(5,Is)],Ka);var gt=0,_t=0,vt=0,nt=0,ah={css:"#00000000",rgba:0},lt;(t=>{function e(r,o,a,l){return l!==void 0?`#${qs(r)}${qs(o)}${qs(a)}${qs(l)}`:`#${qs(r)}${qs(o)}${qs(a)}`}t.toCss=e;function s(r,o,a,l=255){return(r<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function i(r,o,a,l){return{css:t.toCss(r,o,a,l),rgba:t.toRgba(r,o,a,l)}}t.toColor=i})(lt||={});var Xe;(t=>{function e(d,c){if(nt=(c.rgba&255)/255,nt===1)return{css:c.css,rgba:c.rgba};let h=c.rgba>>24&255,u=c.rgba>>16&255,f=c.rgba>>8&255,m=d.rgba>>24&255,p=d.rgba>>16&255,g=d.rgba>>8&255;gt=m+Math.round((h-m)*nt),_t=p+Math.round((u-p)*nt),vt=g+Math.round((f-g)*nt);let _=lt.toCss(gt,_t,vt),b=lt.toRgba(gt,_t,vt);return{css:_,rgba:b}}t.blend=e;function s(d){return(d.rgba&255)===255}t.isOpaque=s;function i(d,c,h){let u=yr.ensureContrastRatio(d.rgba,c.rgba,h);if(u)return lt.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=i;function r(d){let c=(d.rgba|255)>>>0;return[gt,_t,vt]=yr.toChannels(c),{css:lt.toCss(gt,_t,vt),rgba:c}}t.opaque=r;function o(d,c){return nt=Math.round(c*255),[gt,_t,vt]=yr.toChannels(d.rgba),{css:lt.toCss(gt,_t,vt,nt),rgba:lt.toRgba(gt,_t,vt,nt)}}t.opacity=o;function a(d,c){return nt=d.rgba&255,o(d,nt*c/255)}t.multiplyOpacity=a;function l(d){return[d.rgba>>24&255,d.rgba>>16&255,d.rgba>>8&255]}t.toColorRGB=l})(Xe||={});var et;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return gt=parseInt(r.slice(1,2).repeat(2),16),_t=parseInt(r.slice(2,3).repeat(2),16),vt=parseInt(r.slice(3,4).repeat(2),16),lt.toColor(gt,_t,vt);case 5:return gt=parseInt(r.slice(1,2).repeat(2),16),_t=parseInt(r.slice(2,3).repeat(2),16),vt=parseInt(r.slice(3,4).repeat(2),16),nt=parseInt(r.slice(4,5).repeat(2),16),lt.toColor(gt,_t,vt,nt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return gt=parseInt(o[1]),_t=parseInt(o[2]),vt=parseInt(o[3]),nt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),lt.toColor(gt,_t,vt,nt);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[gt,_t,vt,nt]=e.getImageData(0,0,1,1).data,nt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:lt.toRgba(gt,_t,vt,nt),css:r}}t.toColor=i})(et||={});var At;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,o){let a=i/255,l=r/255,d=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4);return c*.2126+h*.7152+u*.0722}t.relativeLuminance2=s})(At||={});var yr;(t=>{function e(a,l){if(nt=(l&255)/255,nt===1)return l;let d=l>>24&255,c=l>>16&255,h=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return gt=u+Math.round((d-u)*nt),_t=f+Math.round((c-f)*nt),vt=m+Math.round((h-m)*nt),lt.toRgba(gt,_t,vt)}t.blend=e;function s(a,l,d){let c=At.relativeLuminance(a>>8),h=At.relativeLuminance(l>>8);if(ws(c,h)<d){if(h<c){let m=i(a,l,d),p=ws(c,At.relativeLuminance(m>>8));if(p<d){let g=r(a,l,d),_=ws(c,At.relativeLuminance(g>>8));return p>_?m:g}return m}let u=r(a,l,d),f=ws(c,At.relativeLuminance(u>>8));if(f<d){let m=i(a,l,d),p=ws(c,At.relativeLuminance(m>>8));return f>p?u:m}return u}}t.ensureContrastRatio=s;function i(a,l,d){let c=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=ws(At.relativeLuminance2(f,m,p),At.relativeLuminance2(c,h,u));for(;g<d&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=ws(At.relativeLuminance2(f,m,p),At.relativeLuminance2(c,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.reduceLuminance=i;function r(a,l,d){let c=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=ws(At.relativeLuminance2(f,m,p),At.relativeLuminance2(c,h,u));for(;g<d&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=ws(At.relativeLuminance2(f,m,p),At.relativeLuminance2(c,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.increaseLuminance=r;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(yr||={});function qs(t){let e=t.toString(16);return e.length<2?"0"+e:e}function ws(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var Tj=class extends Xn{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Xr=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Qt}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],i=e.translateToString(!0),r=0,o=0,a=0,l=e.getFg(0),d=e.getBg(0);for(let c=0;c<e.getTrimmedLength();c++)if(e.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==d){if(c-r>1){let h=this._getJoinedRanges(i,a,o,e,r);for(let u=0;u<h.length;u++)s.push(h[u])}r=c,a=o,l=this._workCell.fg,d=this._workCell.bg}o+=this._workCell.getChars().length||$s.length}if(this._bufferService.cols-r>1){let c=this._getJoinedRanges(i,a,o,e,r);for(let h=0;h<c.length;h++)s.push(c[h])}return s}_getJoinedRanges(t,e,s,i,r){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let d=this._characterJoiners[l].handler(o);for(let c=0;c<d.length;c++)Xr._mergeRanges(a,d[c])}catch(d){console.error(d)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,o=0,a=t[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let d=e.getWidth(l),c=e.getString(l).length||$s.length;if(d!==0){if(!r&&a[0]<=o&&(a[0]=l,r=!0),a[1]<=o){if(a[1]=l,a=t[++i],!a)break;a[0]<=o?(a[0]=l,r=!0):r=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let i=0;i<t.length;i++){let r=t[i];if(s){if(e[1]<=r[0])return t[i-1][1]=e[1],t;if(e[1]<=r[1])return t[i-1][1]=Math.max(e[1],r[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=r[0])return t.splice(i,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Xr=rt([_e(0,It)],Xr);function Aj(t){return 57508<=t&&t<=57558}function Rj(t){return 9472<=t&&t<=9631}function Pj(t){return Aj(t)||Rj(t)}function Dj(){return{css:{canvas:hr(),cell:hr()},device:{canvas:hr(),cell:hr(),char:{width:0,height:0,left:0,top:0}}}}function hr(){return{width:0,height:0}}var qa=class{constructor(t,e,s,i,r,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new Qt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,i,r,o,a,l,d,c,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,_=0,b="",x=0,v=0,y=0,S=0,w=!1,C=0,N=!1,E=0,R=0,T=[],k=c!==-1&&h!==-1;for(let j=0;j<p;j++){t.loadCell(j,this._workCell);let I=this._workCell.getWidth();if(I===0)continue;let A=!1,O=j>=R,L=j,P=this._workCell;if(f.length>0&&j===f[0][0]&&O){let se=f.shift(),ee=this._isCellInSelection(se[0],e);for(x=se[0]+1;x<se[1];x++)O&&=ee===this._isCellInSelection(x,e);O&&=!s||o<se[0]||o>=se[1],O?(A=!0,P=new Tj(this._workCell,t.translateToString(!0,se[0],se[1]),se[1]-se[0]),L=se[1]-1,I=P.getWidth()):R=se[1]}let B=this._isCellInSelection(j,e),F=s&&j===o,H=k&&j>=c&&j<=h,z=!1;this._decorationService.forEachDecorationAtCell(j,e,void 0,se=>{z=!0});let W=P.getChars()||$s;if(W===" "&&(P.isUnderline()||P.isOverline())&&(W=" "),E=I*l-d.get(W,P.isBold(),P.isItalic()),!g)g=this._document.createElement("span");else if(_&&(B&&N||!B&&!N&&P.bg===v)&&(B&&N&&m.selectionForeground||P.fg===y)&&P.extended.ext===S&&H===w&&E===C&&!F&&!A&&!z&&O){P.isInvisible()?b+=$s:b+=W,_++;continue}else _&&(g.textContent=b),g=this._document.createElement("span"),_=0,b="";if(v=P.bg,y=P.fg,S=P.extended.ext,w=H,C=E,N=B,A&&o>=j&&o<=L&&(o=j),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if(T.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&T.push("xterm-cursor-blink"),T.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":T.push("xterm-cursor-outline");break;case"block":T.push("xterm-cursor-block");break;case"bar":T.push("xterm-cursor-bar");break;case"underline":T.push("xterm-cursor-underline");break}}if(P.isBold()&&T.push("xterm-bold"),P.isItalic()&&T.push("xterm-italic"),P.isDim()&&T.push("xterm-dim"),P.isInvisible()?b=$s:b=P.getChars()||$s,P.isUnderline()&&(T.push(`xterm-underline-${P.extended.underlineStyle}`),b===" "&&(b=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${Xn.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let se=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&se<8&&(se+=8),g.style.textDecorationColor=m.ansi[se].css}P.isOverline()&&(T.push("xterm-overline"),b===" "&&(b=" ")),P.isStrikethrough()&&T.push("xterm-strikethrough"),H&&(g.style.textDecoration="underline");let q=P.getFgColor(),K=P.getFgColorMode(),Z=P.getBgColor(),Y=P.getBgColorMode(),G=!!P.isInverse();if(G){let se=q;q=Z,Z=se;let ee=K;K=Y,Y=ee}let Q,$,X=!1;this._decorationService.forEachDecorationAtCell(j,e,void 0,se=>{se.options.layer!=="top"&&X||(se.backgroundColorRGB&&(Y=50331648,Z=se.backgroundColorRGB.rgba>>8&16777215,Q=se.backgroundColorRGB),se.foregroundColorRGB&&(K=50331648,q=se.foregroundColorRGB.rgba>>8&16777215,$=se.foregroundColorRGB),X=se.options.layer==="top")}),!X&&B&&(Q=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,Z=Q.rgba>>8&16777215,Y=50331648,X=!0,m.selectionForeground&&(K=50331648,q=m.selectionForeground.rgba>>8&16777215,$=m.selectionForeground)),X&&T.push("xterm-decoration-top");let V;switch(Y){case 16777216:case 33554432:V=m.ansi[Z],T.push(`xterm-bg-${Z}`);break;case 50331648:V=lt.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(g,`background-color:#${lh((Z>>>0).toString(16),"0",6)}`);break;default:G?(V=m.foreground,T.push("xterm-bg-257")):V=m.background}switch(Q||P.isDim()&&(Q=Xe.multiplyOpacity(V,.5)),K){case 16777216:case 33554432:P.isBold()&&q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(q+=8),this._applyMinimumContrast(g,V,m.ansi[q],P,Q,void 0)||T.push(`xterm-fg-${q}`);break;case 50331648:let se=lt.toColor(q>>16&255,q>>8&255,q&255);this._applyMinimumContrast(g,V,se,P,Q,$)||this._addStyle(g,`color:#${lh(q.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,V,m.foreground,P,Q,$)||G&&T.push("xterm-fg-257")}T.length&&(g.className=T.join(" "),T.length=0),!F&&!A&&!z&&O?_++:g.textContent=b,E!==this.defaultSpacing&&(g.style.letterSpacing=`${E}px`),u.push(g),j=L}return g&&_&&(g.textContent=b),u}_applyMinimumContrast(t,e,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Pj(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let d=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=Xe.ensureContrastRatio(r||e,o||s,d),a.setColor((r||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?t>=s[0]&&e>=s[1]&&t<i[0]&&e<=i[1]:t<s[0]&&e>=s[1]&&t>=i[0]&&e<=i[1]:e>s[1]&&e<i[1]||s[1]===i[1]&&e===s[1]&&t>=s[0]&&t<i[0]||s[1]<i[1]&&e===i[1]&&t<i[0]||s[1]<i[1]&&e===s[1]&&t>=s[0]}};qa=rt([_e(1,Xm),_e(2,Lt),_e(3,Ds),_e(4,pi),_e(5,Jn),_e(6,Qi)],qa);function lh(t,e,s){for(;t.length<s;)t=e+t;return t}var Ij=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,i){t===this._font&&e===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(t,e,s){let i=0;if(!e&&!s&&t.length===1&&(i=t.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(t,0);return a>0&&(this._flat[i]=a),a}let r=t;e&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(r,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},Lj=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,i=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let r=t.buffers.active.ydisp,o=e[1]-r,a=s[1]-r,l=Math.max(o,0),d=Math.min(a,t.rows-1);if(l>=t.rows||d<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=d,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function Oj(){return new Lj}var Jo="xterm-dom-renderer-owner-",Gt="xterm-rows",ur="xterm-fg-",ch="xterm-bg-",cn="xterm-focus",fr="xterm-selection",Bj=1,Ga=class extends Re{constructor(t,e,s,i,r,o,a,l,d,c,h,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=d,this._optionsService=c,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=Bj++,this._rowElements=[],this._selectionRenderModel=Oj(),this.onRequestRedraw=this._register(new me).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Gt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(fr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Dj(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(qa,document),this._element.classList.add(Jo+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(Ze(()=>{this._element.classList.remove(Jo+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ij(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${Gt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${Gt} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${Gt} .xterm-dim { color: ${Xe.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${i} { 50% { box-shadow: none; }}`,e+=`@keyframes ${r} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${Gt}.${cn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Gt}.${cn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Gt}.${cn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Gt} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Gt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Gt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Gt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Gt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${fr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${fr} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${fr} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${ur}${o} { color: ${a.css}; }${this._terminalSelector} .${ur}${o}.xterm-dim { color: ${Xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${ch}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${ur}257 { color: ${Xe.opaque(t.background).css}; }${this._terminalSelector} .${ur}257.xterm-dim { color: ${Xe.multiplyOpacity(Xe.opaque(t.background),.5).css}; }${this._terminalSelector} .${ch}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(cn),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(cn),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let d=t[0]>e[0];l.appendChild(this._createSelectionElement(o,d?e[0]:t[0],d?t[0]:e[0],a-o+1))}else{let d=i===o?t[0]:0,c=o===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,d,c));let h=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==a){let u=r===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,i=1){let r=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let d=t;d<=e;d++){let c=d+s.ydisp,h=this._rowElements[d],u=s.lines.get(c);if(!h||!u)break;h.replaceChildren(...this._rowFactory.createRow(u,c,c===i,a,l,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Jo}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,i,r,o){s<0&&(t=0),i<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,d=l.ybase+l.y,c=Math.min(l.x,r-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=i;++m){let p=m+l.ydisp,g=this._rowElements[m],_=l.lines.get(p);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,p,p===d,u,f,c,h,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===i?e:r)-1:-1))}}};Ga=rt([_e(7,gc),_e(8,bo),_e(9,Lt),_e(10,It),_e(11,pi),_e(12,Ds),_e(13,Qi)],Ga);var Ya=class extends Re{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new me),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new $j(this._optionsService))}catch{this._measureStrategy=this._register(new Mj(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Ya=rt([_e(2,Lt)],Ya);var pp=class extends Re{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},Mj=class extends pp{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},$j=class extends pp{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},zj=class extends Re{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Fj(this._window)),this._onDprChange=this._register(new me),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new me),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(wt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ce(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ce(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Fj=class extends Re{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new Mi),this._onDprChange=this._register(new me),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ze(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ce(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Hj=class extends Re{constructor(){super(),this.linkProviders=[],this._register(Ze(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Cc(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-o,e.clientY-i.top-a]}function Uj(t,e,s,i,r,o,a,l,d){if(!o)return;let c=Cc(t,e,s);if(c)return c[0]=Math.ceil((c[0]+(d?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(d?1:0)),c[1]=Math.min(Math.max(c[1],1),r),c}var Xa=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return Uj(window,t,e,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(t,e){let s=Cc(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Xa=rt([_e(0,Is),_e(1,bo)],Xa);var Wj=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},gp={};ek(gp,{getSafariVersion:()=>Kj,isChromeOS:()=>bp,isFirefox:()=>_p,isIpad:()=>qj,isIphone:()=>Gj,isLegacyEdge:()=>Vj,isLinux:()=>kc,isMac:()=>Jr,isNode:()=>yo,isSafari:()=>vp,isWindows:()=>xp});var yo=typeof process<"u"&&"title"in process,Zn=yo?"node":navigator.userAgent,Qn=yo?"node":navigator.platform,_p=Zn.includes("Firefox"),Vj=Zn.includes("Edge"),vp=/^((?!chrome|android).)*safari/i.test(Zn);function Kj(){if(!vp)return 0;let t=Zn.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Jr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Qn),qj=Qn==="iPad",Gj=Qn==="iPhone",xp=["Windows","Win16","Win32","WinCE"].includes(Qn),kc=Qn.indexOf("Linux")>=0,bp=/\bCrOS\b/.test(Zn),yp=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,i=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),r=t.timeRemaining(),s*1.5>r){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=r}this.clear()}},Yj=class extends yp{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Xj=class extends yp{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Zr=!yo&&"requestIdleCallback"in window?Xj:Yj,Jj=class{constructor(){this._queue=new Zr}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Ja=class extends Re{constructor(t,e,s,i,r,o,a,l,d){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new Mi),this._pausedResizeTask=new Jj,this._observerDisposable=this._register(new Mi),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new me),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new me),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new me),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new me),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Wj((c,h)=>this._renderRows(c,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Zj(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ze(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(d.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=Ze(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let i=this._syncOutputHandler.flush();i&&(t=Math.min(t,i.start),e=Math.max(e,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Ja=rt([_e(2,Lt),_e(3,bo),_e(4,pi),_e(5,Jn),_e(6,It),_e(7,Ds),_e(8,Qi)],Ja);var Zj=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Qj(t,e,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return s5(r,o,t,e,s,i)+So(o,e,s,i)+i5(r,o,t,e,s,i);let a;if(o===e)return a=r>t?"D":"C",Hn(Math.abs(r-t),Fn(a,i));a=o>e?"D":"C";let l=Math.abs(o-e),d=t5(o>e?t:r,s)+(l-1)*s.cols+1+e5(o>e?r:t);return Hn(d,Fn(a,i))}function e5(t,e){return t-1}function t5(t,e){return e.cols-t}function s5(t,e,s,i,r,o){return So(e,i,r,o).length===0?"":Hn(wp(t,e,t,e-ri(e,r),!1,r).length,Fn("D",o))}function So(t,e,s,i){let r=t-ri(t,s),o=e-ri(e,s),a=Math.abs(r-o)-n5(t,e,s);return Hn(a,Fn(Sp(t,e),i))}function i5(t,e,s,i,r,o){let a;So(e,i,r,o).length>0?a=i-ri(i,r):a=e;let l=i,d=r5(t,e,s,i,r,o);return Hn(wp(t,a,s,l,d==="C",r).length,Fn(d,o))}function n5(t,e,s){let i=0,r=t-ri(t,s),o=e-ri(e,s);for(let a=0;a<Math.abs(r-o);a++){let l=Sp(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&i++}return i}function ri(t,e){let s=0,i=e.buffer.lines.get(t),r=i?.isWrapped;for(;r&&t>=0&&t<e.rows;)s++,i=e.buffer.lines.get(--t),r=i?.isWrapped;return s}function r5(t,e,s,i,r,o){let a;return So(s,i,r,o).length>0?a=i-ri(i,r):a=e,t<s&&a<=i||t>=s&&a<i?"C":"D"}function Sp(t,e){return t>e?"A":"B"}function wp(t,e,s,i,r,o){let a=t,l=e,d="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=r?1:-1,r&&a>o.cols-1?(d+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(d+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return d+o.buffer.translateBufferLineToString(l,!1,t,a)}function Fn(t,e){let s=e?"O":"[";return re.ESC+s+t}function Hn(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var o5=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function dh(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Zo=50,a5=15,l5=50,c5=500,d5=" ",h5=new RegExp(d5,"g"),Za=class extends Re{constructor(t,e,s,i,r,o,a,l,d){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Qt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new me),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new me),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new me),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new me),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new o5(this._bufferService),this._activeSelectionMode=0,this._register(Ze(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let r=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,o);i.push(l)}}else{let r=t[1]===e[1]?e[0]:void 0;i.push(s.translateBufferLineToString(t[1],!0,t[0],r));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?i[i.length-1]+=l:i.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(h5," ")).join(xp?`\r
497
- `:`
498
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),kc&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!e?!1:this._areCoordsInSelection(e,s,i)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([t,e],s,i)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=dh(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(t);return i?(this._selectWordAt(i,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=Cc(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-Zo),Zo),e/=Zo,e/Math.abs(e)+Math.round(e*(a5-1)))}shouldForceSelection(t){return Jr?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),l5)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(Jr&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<c5&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Qj(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let i=0;e>=i;i++){let r=t.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&e!==i&&(s+=r-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,i=!0){if(t[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(t[1]);if(!o)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),d=l,c=t[0]-l,h=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;d<a.length&&a.charAt(d+1)===" ";)d++}else{let _=t[0],b=t[0];o.getWidth(_)===0&&(h++,_--),o.getWidth(b)===2&&(u++,b++);let x=o.getString(b).length;for(x>1&&(m+=x-1,d+=x-1);_>0&&l>0&&!this._isCharWordSeparator(o.loadCell(_-1,this._workCell));){o.loadCell(_-1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,_--):v>1&&(f+=v-1,l-=v-1),l--,_--}for(;b<o.length&&d+1<a.length&&!this._isCharWordSeparator(o.loadCell(b+1,this._workCell));){o.loadCell(b+1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,b++):v>1&&(m+=v-1,d+=v-1),d++,b++}}d++;let p=l+c-h+f,g=Math.min(this._bufferService.cols,d-l+h+u-f-m);if(!(!e&&a.slice(l,d).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let _=r.lines.get(t[1]-1);if(_&&o.isWrapped&&_.getCodePoint(this._bufferService.cols-1)!==32){let b=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(b){let x=this._bufferService.cols-b.start;p-=x,g+=x}}}if(i&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let _=r.lines.get(t[1]+1);if(_?.isWrapped&&_.getCodePoint(0)!==32){let b=this._getWordAt([0,t[1]+1],!1,!1,!0);b&&(g+=b.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=dh(s,this._bufferService.cols)}};Za=rt([_e(3,It),_e(4,pi),_e(5,_c),_e(6,Lt),_e(7,Is),_e(8,Ds)],Za);var hh=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},uh=class{constructor(){this._color=new hh,this._css=new hh}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},dt=Object.freeze((()=>{let t=[et.toColor("#2e3436"),et.toColor("#cc0000"),et.toColor("#4e9a06"),et.toColor("#c4a000"),et.toColor("#3465a4"),et.toColor("#75507b"),et.toColor("#06989a"),et.toColor("#d3d7cf"),et.toColor("#555753"),et.toColor("#ef2929"),et.toColor("#8ae234"),et.toColor("#fce94f"),et.toColor("#729fcf"),et.toColor("#ad7fa8"),et.toColor("#34e2e2"),et.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=e[s/36%6|0],r=e[s/6%6|0],o=e[s%6];t.push({css:lt.toCss(i,r,o),rgba:lt.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:lt.toCss(i,i,i),rgba:lt.toRgba(i,i,i)})}return t})()),Gs=et.toColor("#ffffff"),bn=et.toColor("#000000"),fh=et.toColor("#ffffff"),mh=bn,dn={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},u5=Gs,Qa=class extends Re{constructor(t){super(),this._optionsService=t,this._contrastCache=new uh,this._halfContrastCache=new uh,this._onChangeColors=this._register(new me),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Gs,background:bn,cursor:fh,cursorAccent:mh,selectionForeground:void 0,selectionBackgroundTransparent:dn,selectionBackgroundOpaque:Xe.blend(bn,dn),selectionInactiveBackgroundTransparent:dn,selectionInactiveBackgroundOpaque:Xe.blend(bn,dn),scrollbarSliderBackground:Xe.opacity(Gs,.2),scrollbarSliderHoverBackground:Xe.opacity(Gs,.4),scrollbarSliderActiveBackground:Xe.opacity(Gs,.5),overviewRulerBorder:Gs,ansi:dt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=We(t.foreground,Gs),e.background=We(t.background,bn),e.cursor=Xe.blend(e.background,We(t.cursor,fh)),e.cursorAccent=Xe.blend(e.background,We(t.cursorAccent,mh)),e.selectionBackgroundTransparent=We(t.selectionBackground,dn),e.selectionBackgroundOpaque=Xe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=We(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=Xe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?We(t.selectionForeground,ah):void 0,e.selectionForeground===ah&&(e.selectionForeground=void 0),Xe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=Xe.opacity(e.selectionBackgroundTransparent,.3)),Xe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=Xe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=We(t.scrollbarSliderBackground,Xe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=We(t.scrollbarSliderHoverBackground,Xe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=We(t.scrollbarSliderActiveBackground,Xe.opacity(e.foreground,.5)),e.overviewRulerBorder=We(t.overviewRulerBorder,u5),e.ansi=dt.slice(),e.ansi[0]=We(t.black,dt[0]),e.ansi[1]=We(t.red,dt[1]),e.ansi[2]=We(t.green,dt[2]),e.ansi[3]=We(t.yellow,dt[3]),e.ansi[4]=We(t.blue,dt[4]),e.ansi[5]=We(t.magenta,dt[5]),e.ansi[6]=We(t.cyan,dt[6]),e.ansi[7]=We(t.white,dt[7]),e.ansi[8]=We(t.brightBlack,dt[8]),e.ansi[9]=We(t.brightRed,dt[9]),e.ansi[10]=We(t.brightGreen,dt[10]),e.ansi[11]=We(t.brightYellow,dt[11]),e.ansi[12]=We(t.brightBlue,dt[12]),e.ansi[13]=We(t.brightMagenta,dt[13]),e.ansi[14]=We(t.brightCyan,dt[14]),e.ansi[15]=We(t.brightWhite,dt[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let i=0;i<s;i++)e.ansi[i+16]=We(t.extendedAnsi[i],dt[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Qa=rt([_e(0,Lt)],Qa);function We(t,e){if(t!==void 0)try{return et.toColor(t)}catch{}return e}var f5=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},m5=class{constructor(){this._services=new f5,this._services.set(gc,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=ak(t).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let r=s.length>0?s[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},p5={trace:0,debug:1,info:2,warn:3,error:4,off:5},g5="xterm.js: ",el=class extends Re{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=p5[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":g5)+e,...s)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};el=rt([_e(0,Lt)],el);var ph=class extends Re{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new me),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new me),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new me),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(t,e,...s){if(e){for(let i=t;i<this._length-e;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=e-1;r>=0;r--)this.set(t+r+s,this.get(t+r));let i=t+e+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<e;i++)this.set(t+i+s,this.get(t+i))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},Ae=3,at=Object.freeze(new Xn),mr=0,Qo=2,yn=class Cp{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Ae);let r=s||Qt.fromCharData([0,Um,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*Ae+0],i=s&2097151;return[this._data[e*Ae+1],s&2097152?this._combined[e]:i?Ms(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*Ae+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*Ae+0]=e|2097152|s[2]<<22):this._data[e*Ae+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*Ae+0]>>22}hasWidth(e){return this._data[e*Ae+0]&12582912}getFg(e){return this._data[e*Ae+1]}getBg(e){return this._data[e*Ae+2]}hasContent(e){return this._data[e*Ae+0]&4194303}getCodePoint(e){let s=this._data[e*Ae+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*Ae+0]&2097152}getString(e){let s=this._data[e*Ae+0];return s&2097152?this._combined[e]:s&2097151?Ms(s&2097151):""}isProtected(e){return this._data[e*Ae+2]&536870912}loadCell(e,s){return mr=e*Ae,s.content=this._data[mr+0],s.fg=this._data[mr+1],s.bg=this._data[mr+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*Ae+0]=s.content,this._data[e*Ae+1]=s.fg,this._data[e*Ae+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Ae+0]=s|i<<22,this._data[e*Ae+1]=r.fg,this._data[e*Ae+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*Ae+0];r&2097152?this._combined[e]+=Ms(s):r&2097151?(this._combined[e]=Ms(r&2097151)+Ms(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*Ae+0]=r}insertCells(e,s,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length-e){let r=new Qt;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,r));for(let o=0;o<s;++o)this.setCell(e+o,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,s,i){if(e%=this.length,s<this.length-e){let r=new Qt;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,s,i,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.setCell(e++,i)}resize(e,s){if(e===this.length)return this._data.length*4*Qo<this._data.buffer.byteLength;let i=e*Ae;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=e&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,i*4*Qo<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Qo<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new Cp(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ae+0]&4194303)return e+(this._data[e*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ae+0]&4194303||this._data[e*Ae+2]&50331648)return e+(this._data[e*Ae+0]>>22);return 0}copyCellsFrom(e,s,i,r,o){let a=e._data;if(o)for(let d=r-1;d>=0;d--){for(let c=0;c<Ae;c++)this._data[(i+d)*Ae+c]=a[(s+d)*Ae+c];a[(s+d)*Ae+2]&268435456&&(this._extendedAttrs[i+d]=e._extendedAttrs[s+d])}else for(let d=0;d<r;d++){for(let c=0;c<Ae;c++)this._data[(i+d)*Ae+c]=a[(s+d)*Ae+c];a[(s+d)*Ae+2]&268435456&&(this._extendedAttrs[i+d]=e._extendedAttrs[s+d])}let l=Object.keys(e._combined);for(let d=0;d<l.length;d++){let c=parseInt(l[d],10);c>=s&&(this._combined[c-s+i]=e._combined[c])}}translateToString(e,s,i,r){s=s??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let a=this._data[s*Ae+0],l=a&2097151,d=a&2097152?this._combined[s]:l?Ms(l):$s;if(o+=d,r)for(let c=0;c<d.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),o}};function _5(t,e,s,i,r,o){let a=[];for(let l=0;l<t.length-1;l++){let d=l,c=t.get(++d);if(!c.isWrapped)continue;let h=[t.get(l)];for(;d<t.length&&c.isWrapped;)h.push(c),c=t.get(++d);if(!o&&i>=l&&i<d){l+=h.length-1;continue}let u=0,f=Un(h,u,e),m=1,p=0;for(;m<h.length;){let _=Un(h,m,e),b=_-p,x=s-f,v=Math.min(b,x);h[u].copyCellsFrom(h[m],p,f,v,!1),f+=v,f===s&&(u++,f=0),p+=v,p===_&&(m++,p=0),f===0&&u!==0&&h[u-1].getWidth(s-1)===2&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,r))}h[u].replaceCells(f,s,r);let g=0;for(let _=h.length-1;_>0&&(_>u||h[_].getTrimmedLength()===0);_--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}function v5(t,e){let s=[],i=0,r=e[i],o=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++i];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,r=e[++i]}else s.push(a);return{layout:s,countRemoved:o}}function x5(t,e){let s=[];for(let i=0;i<e.length;i++)s.push(t.get(e[i]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=e.length}function b5(t,e,s){let i=[],r=t.map((d,c)=>Un(t,c,e)).reduce((d,c)=>d+c),o=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}o+=s;let d=Un(t,a,e);o>d&&(o-=d,a++);let c=t[a].getWidth(o-1)===2;c&&o--;let h=c?s-1:s;i.push(h),l+=h}return i}function Un(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,r=t[e+1].getWidth(0)===2;return i&&r?s-1:s}var kp=class jp{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=jp._nextId++,this._onDispose=this.register(new me),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ni(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};kp._nextId=1;var y5=kp,ft={},Ys=ft.B;ft[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ft.A={"#":"£"};ft.B=void 0;ft[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ft.C=ft[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ft.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ft.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ft.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ft.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ft.E=ft[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ft.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ft.H=ft[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ft["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var gh=4294967295,_h=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=at.clone(),this.savedCharset=Ys,this.markers=[],this._nullCell=Qt.fromCharData([0,Um,1,0]),this._whitespaceCell=Qt.fromCharData([0,$s,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Zr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ph(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Gr),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Gr),this._whitespaceCell}getBlankLine(t,e){return new yn(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>gh?gh:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=at);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ph(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(at),i=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(t,s);let o=0;if(this._rows<e)for(let a=this._rows;a<e;a++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new yn(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new yn(t,s)));else for(let a=this._rows;a>e;a--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let a=this.lines.length-r;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=_5(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(at),s);if(i.length>0){let r=v5(this.lines,i);x5(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(at),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new yn(t,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(at),r=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let d=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),d.unshift(l);if(!s){let v=this.ybase+this.y;if(v>=a&&v<a+d.length)continue}let c=d[d.length-1].getTrimmedLength(),h=b5(d,this._cols,t),u=h.length-d.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let v=0;v<u;v++){let y=this.getBlankLine(at,!0);m.push(y)}m.length>0&&(r.push({start:a+d.length+o,newLines:m}),o+=m.length),d.push(...m);let p=h.length-1,g=h[p];g===0&&(p--,g=h[p]);let _=d.length-u-1,b=c;for(;_>=0;){let v=Math.min(b,g);if(d[p]===void 0)break;if(d[p].copyCellsFrom(d[_],b-v,g-v,v,!0),g-=v,g===0&&(p--,g=h[p]),b-=v,b===0){_--;let y=Math.max(_,0);b=Un(d,y,this._cols)}}for(let v=0;v<d.length;v++)h[v]<t&&d[v].setCell(h[v],i);let x=u-f;for(;x-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+e-1)}if(r.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let d=this.lines.length,c=d-1,h=0,u=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,d+o-1);g>=0;g--)if(u&&u.start>c+f){for(let _=u.newLines.length-1;_>=0;_--)this.lines.set(g--,u.newLines[_]);g++,a.push({index:c+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++h]}else this.lines.set(g,l[c--]);let m=0;for(let g=a.length-1;g>=0;g--)a[g].index+=m,this.lines.onInsertEmitter.fire(a[g]),m+=a[g].amount;let p=Math.max(0,d+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,i){let r=this.lines.get(t);return r?r.translateToString(e,s,i):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new y5(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},S5=class extends Re{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new me),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new _h(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new _h(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},Np=2,Ep=1,tl=class extends Re{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new me),this.onResize=this._onResize.event,this._onScroll=this._register(new me),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Np),this.rows=Math.max(t.rawOptions.rows||0,Ep),this.buffers=this._register(new S5(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=s.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),i!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};tl=rt([_e(0,Lt)],tl);var Si={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Jr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},w5=["normal","bold","100","200","300","400","500","600","700","800","900"],C5=class extends Re{constructor(t){super(),this._onOptionChange=this._register(new me),this.onOptionChange=this._onOptionChange.event;let e={...Si};for(let s in t)if(s in e)try{let i=t[s];e[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(Ze(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in Si))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Si))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Si[t]),!k5(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Si[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=w5.includes(e)?e:Si[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function k5(t){return t==="block"||t==="underline"||t==="bar"}function Sn(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let i in t)s[i]=e<=1?t[i]:t[i]&&Sn(t[i],e-1);return s}var vh=Object.freeze({insertMode:!1}),xh=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),sl=class extends Re{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new me),this.onData=this._onData.event,this._onUserInput=this._register(new me),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new me),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new me),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Sn(vh),this.decPrivateModes=Sn(xh)}reset(){this.modes=Sn(vh),this.decPrivateModes=Sn(xh)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(i=>i.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};sl=rt([_e(0,It),_e(1,Gm),_e(2,Lt)],sl);var bh={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function ea(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var ta=String.fromCharCode,yh={DEFAULT:t=>{let e=[ea(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${ta(e[0])}${ta(e[1])}${ta(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${ea(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${ea(t,!0)};${t.x};${t.y}${e}`}},il=class extends Re{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new me),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(bh))this.addProtocol(i,bh[i]);for(let i of Object.keys(yh))this.addEncoding(i,yh[i]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let i=e/s,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};il=rt([_e(0,It),_e(1,pi),_e(2,Lt)],il);var sa=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],j5=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],ht;function N5(t,e){let s=0,i=e.length-1,r;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=s;)if(r=s+i>>1,t>e[r][1])s=r+1;else if(t<e[r][0])i=r-1;else return!0;return!1}var E5=class{constructor(){if(this.version="6",!ht){ht=new Uint8Array(65536),ht.fill(1),ht[0]=0,ht.fill(0,1,32),ht.fill(0,127,160),ht.fill(2,4352,4448),ht[9001]=2,ht[9002]=2,ht.fill(2,11904,42192),ht[12351]=1,ht.fill(2,44032,55204),ht.fill(2,63744,64256),ht.fill(2,65040,65050),ht.fill(2,65072,65136),ht.fill(2,65280,65377),ht.fill(2,65504,65511);for(let t=0;t<sa.length;++t)ht.fill(0,sa[t][0],sa[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?ht[t]:N5(t,j5)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),i=s===0&&e!==0;if(i){let r=Js.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Js.createPropertyValue(0,s,i)}},Js=class Sr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new me,this.onChange=this._onChange.event;let e=new E5;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,i=!1){return(e&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,i=0,r=e.length;for(let o=0;o<r;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=r)return s+this.wcwidth(a);let c=e.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),d=Sr.extractWidth(l);Sr.extractShouldJoin(l)&&(d-=Sr.extractWidth(i)),s+=d,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},T5=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function Sh(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var hn=2147483647,A5=256,Tp=class nl{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>A5)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new nl;if(!e.length)return s;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let r=e[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let e=new nl(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>hn?hn:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>hn?hn:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(e[s]=this._subParams.slice(i,r))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+e,hn):e}},un=[],R5=class{constructor(){this._state=0,this._active=un,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=un}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=un,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||un,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",xo(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let i=t[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=un,this._id=-1,this._state=0}}},zt=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=xo(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},fn=[],P5=class{constructor(){this._handlers=Object.create(null),this._active=fn,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fn}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=fn,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||fn,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",xo(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=fn,this._ident=0}},wn=new Tp;wn.addParam(0);var wh=class{constructor(t){this._handler=t,this._data="",this._params=wn,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():wn,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=xo(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=wn,this._data="",this._hitLimit=!1,s));return this._params=wn,this._data="",this._hitLimit=!1,e}},D5=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,i){this.table[e<<8|t]=s<<4|i}addMany(t,e,s,i){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=s<<4|i}},Jt=160,I5=(function(){let t=new D5(4095),e=Array.apply(null,Array(256)).map((l,d)=>d),s=(l,d)=>e.slice(l,d),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(i,0,2,0);for(a in o)t.addMany([24,26,153,154],a,3,0),t.addMany(s(128,144),a,3,0),t.addMany(s(144,152),a,3,0),t.add(156,a,0,0),t.add(27,a,11,1),t.add(157,a,4,8),t.addMany([152,158,159],a,0,7),t.add(155,a,11,3),t.add(144,a,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(i,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Jt,0,2,0),t.add(Jt,8,5,8),t.add(Jt,6,0,6),t.add(Jt,11,0,11),t.add(Jt,13,13,13),t})(),L5=class extends Re{constructor(t=I5){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Tp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ze(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new R5),this._dcsParser=this._register(new P5),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<t.intermediates.length;++r){let o=t.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(t.final.length!==1)throw new Error("final must be a single byte");let i=t.final.charCodeAt(0);if(e[0]>i||i>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=i,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,s,i,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(t,e,s){let i=0,r=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,d=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&d>-1){for(;d>=0&&(a=l[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._parseStack.handlerPos=d,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&d>-1){for(;d>=0&&(a=l[d](),a!==!0);d--)if(a instanceof Promise)return this._parseStack.handlerPos=d,a}this._parseStack.handlers=[];break;case 6:if(i=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=t[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<e;++l){switch(i=t[l],r=this._transitions.table[this.currentState<<8|(i<160?i:Jt)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<Jt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<Jt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<Jt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<Jt){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let d=this._csiHandlers[this._collect<<8|i],c=d?d.length-1:-1;for(;c>=0&&(a=d[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,d,c,r,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<e&&(i=t[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let h=this._escHandlers[this._collect<<8|i],u=h?h.length-1:-1;for(;u>=0&&(a=h[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,h,u,r,l),a;u<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(i=t[f])===24||i===26||i===27||i>127&&i<Jt){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=e||(i=t[f])<32||i>127&&i<Jt){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},O5=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,B5=/^[\da-f]+$/;function Ch(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=O5.exec(e);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),B5.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function ia(t,e){let s=t.toString(16),i=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function M5(t,e=16){let[s,i,r]=t;return`rgb:${ia(s,e)}/${ia(i,e)}/${ia(r,e)}`}var $5={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bs=131072,kh=10;function jh(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var Nh=5e3,Eh=0,z5=class extends Re{constructor(t,e,s,i,r,o,a,l,d=new L5){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=d,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rk,this._utf8Decoder=new ok,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=at.clone(),this._eraseAttrDataInternal=at.clone(),this._onRequestBell=this._register(new me),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new me),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new me),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new me),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new me),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new me),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new me),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new me),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new me),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new me),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new me),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new me),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new me),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new rl(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:h.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,h,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:h,data:u})}),this._parser.setDcsHandlerFallback((c,h,u)=>{h==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:h,payload:u})}),this._parser.setPrintHandler((c,h,u)=>this.print(c,h,u)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(re.BEL,()=>this.bell()),this._parser.setExecuteHandler(re.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(re.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(re.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(re.BS,()=>this.backspace()),this._parser.setExecuteHandler(re.HT,()=>this.tab()),this._parser.setExecuteHandler(re.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(re.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(br.IND,()=>this.index()),this._parser.setExecuteHandler(br.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(br.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new zt(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new zt(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new zt(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new zt(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new zt(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new zt(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new zt(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new zt(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new zt(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new zt(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new zt(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new zt(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in ft)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new wh((c,h)=>this.requestStatusString(c,h)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Nh))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Nh} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Bs&&(o=this._parseStack.position+Bs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(c=>c.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Bs&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Bs))),a||this._dirtyRowTracker.clearRange(),t.length>Bs)for(let c=o;c<t.length;c+=Bs){let h=c+Bs<t.length?c+Bs:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(c,h),this._parseBuffer):this._utf8Decoder.decode(t.subarray(c,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(i,r,u,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,r,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),d=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);d<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(d,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let i,r,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,d=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(i=t[m],i<127&&o){let b=o[String.fromCharCode(i)];b&&(i=b.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);r=Js.extractWidth(p);let g=Js.extractShouldJoin(p),_=g?Js.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Ms(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-_>l){if(d){let b=u,x=this._activeBuffer.x-_;for(this._activeBuffer.x=_,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_>0&&u instanceof yn&&u.copyCellsFrom(b,x,0,_,!1);x<l;)b.setCellFromCodepoint(x++,0,1,h)}else if(this._activeBuffer.x=l-1,r===2)continue}if(g&&this._activeBuffer.x){let b=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-b,i,r);for(let x=r-_;--x>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(c&&(u.insertCells(this._activeBuffer.x,r-_,this._activeBuffer.getNullCell(h)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,h),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>jh(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new wh(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new zt(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(at));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,i=Js.extractWidth(e),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let h=o.codePointAt(c)||0;a[l++]=h,c+=h>65535?2:1}let d=l;for(let c=1;c<s;++c)a.copyWithin(d,0,l),d+=l;return this.print(a,0,d),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(re.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(re.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(re.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(re.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(re.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Ys),this._charsetService.setgCharset(1,Ys),this._charsetService.setgCharset(2,Ys),this._charsetService.setgCharset(3,Ys);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:d}=this._bufferService,{active:c,alt:h}=l,u=this._optionsService.rawOptions,f=(g,_)=>(a.triggerDataEvent(`${re.ESC}[${e?"":"?"}${g};${_}$y`),!0),m=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,m(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(i.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?d===80?2:d===132?1:0:0):p===6?f(p,m(i.origin)):p===7?f(p,m(i.wraparound)):p===8?f(p,3):p===9?f(p,m(r==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!a.isCursorHidden)):p===45?f(p,m(i.reverseWraparound)):p===66?f(p,m(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(r==="VT200")):p===1002?f(p,m(r==="DRAG")):p===1003?f(p,m(r==="ANY")):p===1004?f(p,m(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(o==="SGR")):p===1015?f(p,4):p===1016?f(p,m(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(c===h)):p===2004?f(p,m(i.bracketedPasteMode)):p===2026?f(p,m(i.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=Xn.fromColorRGB([s,i,r])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do i[1]===5&&(r=1),i[o+l+1+r]=a[l];while(++l<a.length&&l+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+e<t.length&&o+r<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=at.fg,t.bg=at.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,i=this._curAttrData;for(let r=0;r<e;r++)s=t.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=at.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=at.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(t,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=at.fg&16777215,i.bg&=-67108864,i.bg|=at.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${re.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${re.ESC}[?${e};${s}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=at.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!jh(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${re.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>kh&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>kh&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(Th(o))if(r==="?")e.push({type:0,index:o});else{let a=Ch(r);a&&e.push({type:1,index:o,color:a})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),i=t.slice(e+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let i=0;i<s.length&&!(e>=this._specialColors.length);++i,++e)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=Ch(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);Th(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Ys),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset($5[t[0]],ft[t[1]]||Ys),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=at.clone(),this._eraseAttrDataInternal=at.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Qt;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,i=this._activeBuffer.lines.get(s);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${re.ESC}${a}${re.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},rl=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Eh=t,t=e,e=Eh),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};rl=rt([_e(0,It)],rl);function Th(t){return 0<=t&&t<256}var F5=5e7,Ah=12,H5=50,U5=class extends Re{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new me),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>F5)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,e);if(r){let a=l=>performance.now()-s>=Ah?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Ah)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>H5&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},ol=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),d={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(d,l)),this._dataByLinkId.set(d.id,d),d.id}let s=t,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,e.ybase+e.y),r.id;let o=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};ol=rt([_e(0,It)],ol);var Rh=!1,W5=class extends Re{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Mi),this._onBinary=this._register(new me),this.onBinary=this._onBinary.event,this._onData=this._register(new me),this.onData=this._onData.event,this._onLineFeed=this._register(new me),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new me),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new me),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new me),this._instantiationService=new m5,this.optionsService=this._register(new C5(t)),this._instantiationService.setService(Lt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(tl)),this._instantiationService.setService(It,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(el)),this._instantiationService.setService(Gm,this._logService),this.coreService=this._register(this._instantiationService.createInstance(sl)),this._instantiationService.setService(pi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(il)),this._instantiationService.setService(qm,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Js)),this._instantiationService.setService(dk,this.unicodeService),this._charsetService=this._instantiationService.createInstance(T5),this._instantiationService.setService(ck,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ol),this._instantiationService.setService(Ym,this._oscLinkService),this._inputHandler=this._register(new z5(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(wt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(wt.forward(this._bufferService.onResize,this._onResize)),this._register(wt.forward(this.coreService.onData,this._onData)),this._register(wt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new U5((e,s)=>this._inputHandler.parse(e,s))),this._register(wt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new me),this._onScroll.event(t=>{this._onScrollApi?.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!Rh&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Rh=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,Np),e=Math.max(e,Ep),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(Sh.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(Sh(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ze(()=>{for(let e of t)e.dispose()})}}},V5={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function K5(t,e,s,i){let r={type:0,cancel:!1,key:void 0},o=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=re.ESC+"OA":r.key=re.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=re.ESC+"OD":r.key=re.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=re.ESC+"OC":r.key=re.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=re.ESC+"OB":r.key=re.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":re.DEL,t.altKey&&(r.key=re.ESC+r.key);break;case 9:if(t.shiftKey){r.key=re.ESC+"[Z";break}r.key=re.HT,r.cancel=!0;break;case 13:r.key=t.altKey?re.ESC+re.CR:re.CR,r.cancel=!0;break;case 27:r.key=re.ESC,t.altKey&&(r.key=re.ESC+re.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=re.ESC+"[1;"+(o+1)+"D":e?r.key=re.ESC+"OD":r.key=re.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=re.ESC+"[1;"+(o+1)+"C":e?r.key=re.ESC+"OC":r.key=re.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=re.ESC+"[1;"+(o+1)+"A":e?r.key=re.ESC+"OA":r.key=re.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=re.ESC+"[1;"+(o+1)+"B":e?r.key=re.ESC+"OB":r.key=re.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=re.ESC+"[2~");break;case 46:o?r.key=re.ESC+"[3;"+(o+1)+"~":r.key=re.ESC+"[3~";break;case 36:o?r.key=re.ESC+"[1;"+(o+1)+"H":e?r.key=re.ESC+"OH":r.key=re.ESC+"[H";break;case 35:o?r.key=re.ESC+"[1;"+(o+1)+"F":e?r.key=re.ESC+"OF":r.key=re.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=re.ESC+"[5;"+(o+1)+"~":r.key=re.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=re.ESC+"[6;"+(o+1)+"~":r.key=re.ESC+"[6~";break;case 112:o?r.key=re.ESC+"[1;"+(o+1)+"P":r.key=re.ESC+"OP";break;case 113:o?r.key=re.ESC+"[1;"+(o+1)+"Q":r.key=re.ESC+"OQ";break;case 114:o?r.key=re.ESC+"[1;"+(o+1)+"R":r.key=re.ESC+"OR";break;case 115:o?r.key=re.ESC+"[1;"+(o+1)+"S":r.key=re.ESC+"OS";break;case 116:o?r.key=re.ESC+"[15;"+(o+1)+"~":r.key=re.ESC+"[15~";break;case 117:o?r.key=re.ESC+"[17;"+(o+1)+"~":r.key=re.ESC+"[17~";break;case 118:o?r.key=re.ESC+"[18;"+(o+1)+"~":r.key=re.ESC+"[18~";break;case 119:o?r.key=re.ESC+"[19;"+(o+1)+"~":r.key=re.ESC+"[19~";break;case 120:o?r.key=re.ESC+"[20;"+(o+1)+"~":r.key=re.ESC+"[20~";break;case 121:o?r.key=re.ESC+"[21;"+(o+1)+"~":r.key=re.ESC+"[21~";break;case 122:o?r.key=re.ESC+"[23;"+(o+1)+"~":r.key=re.ESC+"[23~";break;case 123:o?r.key=re.ESC+"[24;"+(o+1)+"~":r.key=re.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=re.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=re.DEL:t.keyCode===219?r.key=re.ESC:t.keyCode===220?r.key=re.FS:t.keyCode===221&&(r.key=re.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=V5[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=re.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,d=String.fromCharCode(l);t.shiftKey&&(d=d.toUpperCase()),r.key=re.ESC+d}else if(t.keyCode===32)r.key=re.ESC+(t.ctrlKey?re.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=re.ESC+l,r.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=re.US),t.key==="@"&&(r.key=re.NUL));break}return r}var ot=0,q5=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Zr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Zr,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),e=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(i[r]=t[e],e++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(ot=this._search(e),ot===-1)||this._getKey(this._array[ot])!==e)return!1;do if(this._array[ot]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ot),!0;while(++ot<this._array.length&&this._getKey(this._array[ot])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,o)=>r-o),e=0,s=new Array(this._array.length-t.length),i=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ot=this._search(t),!(ot<0||ot>=this._array.length)&&this._getKey(this._array[ot])===t))do yield this._array[ot];while(++ot<this._array.length&&this._getKey(this._array[ot])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ot=this._search(t),!(ot<0||ot>=this._array.length)&&this._getKey(this._array[ot])===t))do e(this._array[ot]);while(++ot<this._array.length&&this._getKey(this._array[ot])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let i=e+s>>1,r=this._getKey(this._array[i]);if(r>t)s=i-1;else if(r<t)e=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===t;)i--;return i}}return e}},na=0,Ph=0,G5=class extends Re{constructor(){super(),this._decorations=new q5(t=>t?.marker.line),this._onDecorationRegistered=this._register(new me),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new me),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ze(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Y5(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(e))i=o.options.x??0,r=i+(o.options.width??1),t>=i&&t<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{na=r.options.x??0,Ph=na+(r.options.width??1),t>=na&&t<Ph&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},Y5=class extends Fs{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new me),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new me),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=et.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=et.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},X5=1e3,J5=class{constructor(t,e=X5){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},Dh=20,Qr=class extends Re{constructor(t,e,s,i){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new J5(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
499
- `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ce(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ze(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Dh+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
500
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Dh+1&&(this._liveRegion.textContent+=ja.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=t;r<=e;r++){let o=s.lines.get(s.ydisp+r),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",d=(s.ydisp+r+1).toString(),c=this._rowElements[r];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",d),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||t.relatedTarget!==i)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let d=this._createAccessibilityTreeNode();this._rowElements.unshift(d),this._rowContainer.insertAdjacentElement("afterbegin",d)}else{let d=this._createAccessibilityTreeNode();this._rowElements.push(d),this._rowContainer.appendChild(d)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:l,offset:d})=>{let c=l instanceof Text?l.parentNode:l,h=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=d<u.length?u[d]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=r(e),a=r(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};Qr=rt([_e(1,gc),_e(2,Ds),_e(3,Is)],Qr);var al=class extends Re{constructor(t,e,s,i,r){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new me),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new me),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ze(()=>{ni(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ce(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ce(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ce(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ce(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,t,s)):r.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(i,a),s=this._checkLinkProviderResult(i,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let i=0;i<e.size;i++){let r=e.get(i);if(r)for(let o=0;o<r.length;o++){let a=r[o],l=a.link.range.start.y<t?0:a.link.range.start.x,d=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=d;c++){if(s.has(c)){r.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&i){let o=i.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&Z5(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ni(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,i=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return s<=r&&r<=i}_positionFromMouseEvent(t,e,s){let i=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,i,r){return{x1:t,y1:e,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};al=rt([_e(1,_c),_e(2,Is),_e(3,It),_e(4,Jm)],al);function Z5(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var Q5=class extends W5{constructor(t={}){super(t),this._linkifier=this._register(new Mi),this.browser=gp,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Mi),this._onCursorMove=this._register(new me),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new me),this.onKey=this._onKey.event,this._onRender=this._register(new me),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new me),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new me),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new me),this.onBell=this._onBell.event,this._onFocus=this._register(new me),this._onBlur=this._register(new me),this._onA11yCharEmitter=this._register(new me),this._onA11yTabEmitter=this._register(new me),this._onWillOpen=this._register(new me),this._setup(),this._decorationService=this._instantiationService.createInstance(G5),this._instantiationService.setService(Jn,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Hj),this._instantiationService.setService(Jm,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ea)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(wt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(wt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(wt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(wt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Ze(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,i="";switch(e.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+e.index}switch(e.type){case 0:let r=Xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${re.ESC}]${i};${M5(r)}${mp.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=lt.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=lt.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Qr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(re.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ce(this.element,"copy",e=>{this.hasSelection()&&ik(e,this._selectionService)}));let t=e=>nk(e,this.textarea,this.coreService,this.optionsService);this._register(Ce(this.textarea,"paste",t)),this._register(Ce(this.element,"paste",t)),_p?this._register(Ce(this.element,"mousedown",e=>{e.button===2&&Ud(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ce(this.element,"contextmenu",e=>{Ud(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),kc&&this._register(Ce(this.element,"auxclick",e=>{e.button===1&&Hm(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ce(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(Ce(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(Ce(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(Ce(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ce(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(Ce(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ce(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ce(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ka.get()),bp||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(zj,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ds,this._coreBrowserService),this._register(Ce(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(Ce(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ya,this._document,this._helperContainer),this._instantiationService.setService(bo,this._charSizeService),this._themeService=this._instantiationService.createInstance(Qa),this._instantiationService.setService(Qi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Xr),this._instantiationService.setService(Xm,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ja,this.rows,this.screenElement)),this._instantiationService.setService(Is,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Ka,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Xa),this._instantiationService.setService(_c,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(al,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Wa,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Za,this.element,this.screenElement,i)),this._instantiationService.setService(uk,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(wt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Va,this.screenElement)),this._register(Ce(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Qr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Yr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Yr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ga,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,d;switch(o.overrideType||o.type){case"mousemove":d=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":d=0,l=o.button<3?o.button:3;break;case"mousedown":d=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let c=o.deltaY;if(c===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;d=c<0?0:1,l=4;break;default:return!1}return d===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:d,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ce(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Ce(e,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=re.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(t,e){this._renderService?.refreshRows(t,e)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){Fm(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(t,e){this._selectionService?.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=K5(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===re.ETX||s.key===re.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(e4(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(at));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(re.ESC+"[I"):this.coreService.triggerDataEvent(re.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${re.ESC}[4;${s};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${re.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function e4(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var t4=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},s4=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new Qt)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Ih=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new s4(e)}getNullCell(){return new Qt}},i4=class extends Re{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new me),this.onBufferChange=this._onBufferChange.event,this._normal=new Ih(this._core.buffers.normal,"normal"),this._alternate=new Ih(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},n4=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,i)=>e(s,i.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},r4=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},o4=["cols","rows"],us=0,a4=class extends Re{constructor(t){super(),this._core=this._register(new Q5(t)),this._addonManager=this._register(new t4),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:e.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(t){if(o4.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new n4(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new r4(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new i4(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
501
- `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return ka.get()},set promptLabel(t){ka.set(t)},get tooMuchOutput(){return ja.get()},set tooMuchOutput(t){ja.set(t)}}}_verifyIntegers(...t){for(us of t)if(us===1/0||isNaN(us)||us%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(us of t)if(us&&(us===1/0||isNaN(us)||us%1!==0||us<0))throw new Error("This API only accepts positive integers")}};var l4=2,c4=1,d4=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,d=a.right+a.left,c=i-l,h=r-d-e;return{cols:Math.max(l4,Math.floor(h/t.css.cell.width)),rows:Math.max(c4,Math.floor(c/t.css.cell.height))}}};function h4({source:t,onReady:e,onSelectionChange:s,className:i}){const r=D.useRef(null),o=D.useRef(null),a=D.useRef(s);a.current=s;const l=bs(),d=D.useRef(t);return d.current=t,yf((c,h)=>{c===d.current&&o.current?.write(h)}),D.useEffect(()=>{const c=r.current;if(!c)return;const h=getComputedStyle(document.documentElement),u=b=>h.getPropertyValue(b).trim()||void 0,f=new a4({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),m=new d4;f.loadAddon(m),f.open(c),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const g=f.onSelectionChange(()=>{const b=!!f.getSelection();a.current?.(b,()=>f.getSelection())}),_=new ResizeObserver(()=>{m.fit()});return _.observe(c),()=>{g.dispose(),_.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:ae("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function u4(t){const e=bs(),[s,i]=D.useState(Qs),[r,o]=D.useState([]),[a,l]=D.useState(new Set),d=D.useRef(!1);if(!d.current&&e.scripts.length>0){const y=yv.find(S=>e.scripts.includes(S));y&&(d.current=!0,o(S=>S.includes(y)?S:[...S,y]),i(y))}if(a.size>0){let y=!1;const S=new Set(a);for(const w of a)e.activeProcesses.includes(w)||(S.delete(w),y=!0);y&&l(S)}const c=()=>t.onOpenChange(!t.open),h=y=>{i(y),t.open||t.onOpenChange(!0)},u=y=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(y)}`,{method:"POST"}),f=y=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(y)}/kill`,{method:"POST"}),m=async y=>{o(S=>S.includes(y)?S:[...S,y]),i(y),t.onOpenChange(!0);try{const S=await u(y);if(S===null)return;if(!S.ok)throw new Error(`Exec failed: ${S.statusText}`)}catch{he.error("Failed to run "+y)}},p=async y=>{await f(y),o(S=>S.filter(w=>w!==y)),s===y&&i(Qs)},g=async()=>{const y=e.activeProcesses.includes(s);try{const S=await u(s);if(S===null)return;if(!S.ok)throw new Error(`Exec failed: ${S.statusText}`)}catch{he.error((y?"Failed to restart ":"Failed to run ")+s)}},_=async()=>{if(!a.has(s)){l(y=>new Set(y).add(s));try{const y=await f(s);if(y===null){l(S=>{const w=new Set(S);return w.delete(s),w});return}if(!y.ok)throw new Error(`Kill failed: ${y.statusText}`)}catch{l(y=>{const S=new Set(y);return S.delete(s),S}),he.error("Failed to stop "+s)}}},b=s!==Qs&&r.includes(s),x=b&&e.activeProcesses.includes(s),v=b&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(q3,{status:t.status,open:t.open,onToggle:c,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:s,scriptTabs:r,onSelectTab:h,onAddScript:m,onCloseScript:p,showScriptControls:b,scriptIsRunning:x,scriptIsKilling:v,onRunActiveScript:g,onStopActiveScript:_}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(f4,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:g})})]})}function f4(t){const e=U.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===Qs||r){let h;return e[0]!==i?(h=n.jsx(h4,{source:i,className:"h-full"},i),e[0]=i,e[1]=h):h=e[1],h}let a;e[2]!==i?(a=n.jsxs("p",{children:['Script "',n.jsx("span",{className:"font-mono text-foreground",children:i}),'" not running']}),e[2]=i,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Di,{className:"size-3.5"}),e[4]=l):l=e[4];let d;e[5]!==o?(d=n.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," Run"]}),e[5]=o,e[6]=d):d=e[6];let c;return e[7]!==a||e[8]!==d?(c=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,d]}),e[7]=a,e[8]=d,e[9]=c):c=e[9],c}const Ap=t=>`preview-drawer:${t}`,m4=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function p4(t){try{const e=localStorage.getItem(Ap(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function g4(t,e){try{localStorage.setItem(Ap(t),JSON.stringify({open:e}))}catch{}}function _4(){const t=U.c(21),e=gi(),{org:s}=Me(),i=e?.virtualMcpId??null,r=Gl(),o=bs(),a=D.useRef(null);let l;t[0]!==o||t[1]!==r||t[2]!==i?(l=x=>{x!=="setup"||!i||a.current!==i&&m4.test(o.getBuffer("setup"))&&(a.current=i,r.restart())},t[0]=o,t[1]=r,t[2]=i,t[3]=l):l=t[3],yf(l);const d=i??"__no-vmcp__",[c,h]=D.useState(null),u=D.useRef(null);u.current!==d&&(u.current=d,h(p4(d)));const f=c??!1;let m;t[4]!==d?(m=x=>{h(x),g4(d,x)},t[4]=d,t[5]=m):m=t[5];const p=m,g=r.vmEntry?.sandboxHandle??"no-vm",_=r.vmEntry?.sandboxHandle??null;let b;return t[6]!==o.scripts||t[7]!==p||t[8]!==r.branch||t[9]!==r.restart||t[10]!==r.resume||t[11]!==r.retry||t[12]!==r.start||t[13]!==r.status||t[14]!==r.stop||t[15]!==f||t[16]!==s.slug||t[17]!==g||t[18]!==_||t[19]!==i?(b=n.jsx(u4,{vmId:_,orgSlug:s.slug,virtualMcpId:i,branch:r.branch,status:r.status,scripts:o.scripts,open:f,onOpenChange:p,onStart:r.start,onStop:r.stop,onRestart:r.restart,onResume:r.resume,onRetry:r.retry},g),t[6]=o.scripts,t[7]=p,t[8]=r.branch,t[9]=r.restart,t[10]=r.resume,t[11]=r.retry,t[12]=r.start,t[13]=r.status,t[14]=r.stop,t[15]=f,t[16]=s.slug,t[17]=g,t[18]=_,t[19]=i,t[20]=b):b=t[20],b}function Rp(t){const e=U.c(10),{virtualMcpId:s,taskId:i}=t,o=gi()?.entity?.metadata;let a;e[0]!==o?(a=ti(o),e[0]=o,e[1]=a):a=e[1];const l=a;let d;e[2]!==i||e[3]!==s?(d=n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(K3,{taskId:i,virtualMcpId:s})}),e[2]=i,e[3]=s,e[4]=d):d=e[4];let c;e[5]!==l?(c=l&&n.jsx(_4,{}),e[5]=l,e[6]=c):c=e[6];let h;return e[7]!==d||e[8]!==c?(h=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d,c]}),e[7]=d,e[8]=c,e[9]=h):h=e[9],h}function v4(t){const e=U.c(9),{children:s,defaultSize:i,chatOpen:r,chatPanelWidth:o,onChatPanelResize:a}=t,[,l]=D.useTransition(),d=i>0&&i<100?o:i;let c;e[0]!==a?(c=p=>l(()=>{p>0&&p<100&&a(p)}),e[0]=a,e[1]=c):c=e[1];const h=c,u=r?"min-w-[348px]":"min-w-0";let f;e[2]!==u?(f=ae("overflow-hidden bg-sidebar",u),e[2]=u,e[3]=f):f=e[3];let m;return e[4]!==s||e[5]!==d||e[6]!==h||e[7]!==f?(m=n.jsx(Cu,{defaultSize:d,minSize:20,collapsible:!0,collapsedSize:0,className:f,onResize:h,order:1,children:s}),e[4]=s,e[5]=d,e[6]=h,e[7]=f,e[8]=m):m=e[8],m}function x4(t){const e=U.c(32),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=Hc(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const d=l,[c,h]=mv(),u=D.useRef(null);let f,m;e[3]!==r||e[4]!==c||e[5]!==o?(f=()=>{const R=u.current;if(!R)return;const T=Hc(r,o),k=T.chat>0&&T.chat<100?c:T.chat,j=T.chat>0&&T.chat<100?100-c:T.main;R.setLayout([k,j])},m=[r,o,c],e[3]=r,e[4]=c,e[5]=o,e[6]=f,e[7]=m):(f=e[6],m=e[7]),D.useEffect(f,m);const p=`${s}-${i}`;let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g={overflow:"visible"},e[8]=g):g=e[8];let _;e[9]!==a?(_=a??n.jsx(Yu,{}),e[9]=a,e[10]=_):_=e[10];let b;e[11]!==_?(b=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:_})}),e[11]=_,e[12]=b):b=e[12];let x;e[13]!==r||e[14]!==c||e[15]!==h||e[16]!==d.chat||e[17]!==b?(x=n.jsx(v4,{defaultSize:d.chat,chatOpen:r,chatPanelWidth:c,onChatPanelResize:h,children:b}),e[13]=r,e[14]=c,e[15]=h,e[16]=d.chat,e[17]=b,e[18]=x):x=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(p_,{className:"bg-sidebar"}),e[19]=v):v=e[19];const y=d.main;let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S={overflow:"visible"},e[20]=S):S=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=ae("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[21]=w):w=e[21];let C;e[22]!==i||e[23]!==s?(C=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(Rp,{taskId:i,virtualMcpId:s})})})}),e[22]=i,e[23]=s,e[24]=C):C=e[24];let N;e[25]!==d.main||e[26]!==C?(N=n.jsx(Cu,{className:"min-w-0 flex flex-col",order:2,defaultSize:y,style:S,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[25]=d.main,e[26]=C,e[27]=N):N=e[27];let E;return e[28]!==N||e[29]!==p||e[30]!==x?(E=n.jsxs(g_,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:g,children:[x,v,N]},p),e[28]=N,e[29]=p,e[30]=x,e[31]=E):E=e[31],E}function Lh(t){const e=U.c(16),{chatOpen:s,toggleChat:i,onNewTask:r,newTaskFirst:o}=t,a=o===void 0?!1:o;let l;e[0]!==s||e[1]!==i?(l=()=>{Ke("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[0]=s,e[1]=i,e[2]=l):l=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(G_,{size:16}),e[3]=d):d=e[3];let c;e[4]!==s||e[5]!==l?(c=n.jsx(Ne,{asChild:!0,children:n.jsx(Rc,{onClick:l,"aria-pressed":s,"aria-label":"Chat",active:s,children:d})}),e[4]=s,e[5]=l,e[6]=c):c=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ee,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let u;e[8]!==c?(u=n.jsxs(Te,{delayDuration:300,children:[c,h]}),e[8]=c,e[9]=u):u=e[9];const f=u;let m;e[10]!==r?(m=r&&n.jsxs(Te,{delayDuration:300,children:[n.jsx(Ne,{asChild:!0,children:n.jsx(Rc,{onClick:r,"aria-label":"New task",children:n.jsx(gl,{size:16})})}),n.jsx(Ee,{side:"bottom",children:"New task"})]}),e[10]=r,e[11]=m):m=e[11];const p=m;let g;return e[12]!==f||e[13]!==p||e[14]!==a?(g=n.jsx(n.Fragment,{children:a?n.jsxs(n.Fragment,{children:[p,f]}):n.jsxs(n.Fragment,{children:[f,p]})}),e[12]=f,e[13]=p,e[14]=a,e[15]=g):g=e[15],g}function b4(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(u=>u.id===e))return{visible:i,overflow:r};const a=r.findIndex(u=>u.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],d=r[a],c=[...i.slice(0,-1),d],h=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:h}}function y4(t){const e=U.c(13),{overflow:s,onSelect:i}=t,[r,o]=D.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Rs,{asChild:!0,children:n.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:n.jsx(Hi,{className:"size-4"})})}),e[2]=d):d=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(pl,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let h;e[8]!==c?(h=n.jsx(Ps,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=h):h=e[9];let u;return e[10]!==r||e[11]!==h?(u=n.jsxs(As,{open:r,onOpenChange:o,children:[d,h]}),e[10]=r,e[11]=h,e[12]=u):u=e[12],u}const S4=6;function w4(t){const e=U.c(20),{virtualMcpId:s,taskId:i}=t,r=qt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:d,setActiveTab:c}=Yl(o);let h,u,f,m;if(e[3]!==l||e[4]!==d||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const _=xu({activeTab:l,mainOpen:d}),b=w=>w.id==="automations"?_:d&&w.id===l,v=a.find(w=>b(w))?.id??null,{visible:y,overflow:S}=b4(a,v,S4);u=S,h=w=>{const C=a.find(E=>E.id===w),N=v===w&&d;if(Ke("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:w,tab_kind:C?.kind??null,was_active:N}),w==="automations"){const E=bu({activeTab:l,mainOpen:d});r({to:".",search:R=>({...R,main:E}),replace:!0});return}c(w)},f="flex items-center min-w-0 gap-0.5",m=y.map(w=>n.jsx(__,{title:w.title,icon:w.icon,active:b(w),onClick:()=>h(w.id)},w.id)),e[3]=l,e[4]=d,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=h,e[10]=u,e[11]=f,e[12]=m}else h=e[9],u=e[10],f=e[11],m=e[12];let p;e[13]!==h||e[14]!==u?(p=u.length>0&&n.jsx(y4,{overflow:u,onSelect:h}),e[13]=h,e[14]=u,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}const ra="__mobile-main-panel-tab-select__";function C4({tabs:t,activeTab:e,mainOpen:s}){const i=t.find(r=>r.id===e);return s?i?.title??"Main view":i?.title??t[0]?.title??"Main view"}function k4(t){const e=U.c(40),{virtualMcpId:s,taskId:i}=t,r=qt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:d,setActiveTab:c}=Yl(o);let h;e[3]!==l||e[4]!==d||e[5]!==a?(h=C4({tabs:a,activeTab:l,mainOpen:d}),e[3]=l,e[4]=d,e[5]=a,e[6]=h):h=e[6];const u=h;let f;e[7]!==l||e[8]!==d||e[9]!==a?(f=a.find(E=>E.id===l)??(d?null:a[0]),e[7]=l,e[8]=d,e[9]=a,e[10]=f):f=e[10];const m=f;let p;e[11]!==l||e[12]!==d?(p=xu({activeTab:l,mainOpen:d}),e[11]=l,e[12]=d,e[13]=p):p=e[13];const g=p;let _;e[14]!==l||e[15]!==g||e[16]!==d||e[17]!==r||e[18]!==c||e[19]!==a||e[20]!==s?(_=E=>{if(E===ra)return;const R=a.find(T=>T.id===E);if(Ke("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:E,tab_kind:R?.kind??null,was_active:E==="automations"?g:d&&l===E,source:"mobile_select"}),E==="automations"){const T=bu({activeTab:l,mainOpen:d});r({to:".",search:k=>({...k,main:T}),replace:!0});return}c(E)},e[14]=l,e[15]=g,e[16]=d,e[17]=r,e[18]=c,e[19]=a,e[20]=s,e[21]=_):_=e[21];const b=_;let x;e[22]!==m?(x=m&&n.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:n.jsx(pl,{icon:m.icon})}),e[22]=m,e[23]=x):x=e[23];let v;e[24]!==u?(v=n.jsx("span",{className:"min-w-0 truncate",children:u}),e[24]=u,e[25]=v):v=e[25];let y;e[26]!==x||e[27]!==v?(y=n.jsx(kt,{"aria-label":"Main panel tab",className:"h-10! w-full min-w-0 max-w-[7.5rem] rounded-md border-0 bg-transparent px-1.5 text-xs shadow-none [--card-shadow:none]",children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,v]})}),e[26]=x,e[27]=v,e[28]=y):y=e[28];let S;e[29]!==u?(S=n.jsx(tt,{value:ra,disabled:!0,hideCheck:!0,className:"hidden",children:u}),e[29]=u,e[30]=S):S=e[30];let w;e[31]!==a?(w=a.map(j4),e[31]=a,e[32]=w):w=e[32];let C;e[33]!==w||e[34]!==S?(C=n.jsxs(jt,{align:"end",className:"w-56",children:[S,w]}),e[33]=w,e[34]=S,e[35]=C):C=e[35];let N;return e[36]!==b||e[37]!==C||e[38]!==y?(N=n.jsxs(Nt,{value:ra,onValueChange:b,children:[y,C]}),e[36]=b,e[37]=C,e[38]=y,e[39]=N):N=e[39],N}function j4(t){return n.jsx(tt,{value:t.id,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n.jsx(pl,{icon:t.icon})}),n.jsx("span",{className:"min-w-0 truncate",children:t.title})]})},t.id)}function Pp(t){return Gn({userName:t?.name,userEmail:t?.email})??void 0}const Oh=3e3,N4=6e4;function E4(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o,l=r??"";let d;e[0]!==s||e[1]!==l||e[2]!==i?(d=dy(s,i,l),e[0]=s,e[1]=l,e[2]=i,e[3]=d):d=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==i?(c=()=>gr(s,i,r),e[4]=r,e[5]=s,e[6]=i,e[7]=c):c=e[7];const h=a&&!!r;let u;return e[8]!==d||e[9]!==c||e[10]!==h?(u={queryKey:d,queryFn:c,enabled:h,refetchInterval:A4,retry:T4,staleTime:1e3},e[8]=d,e[9]=c,e[10]=h,e[11]=u):u=e[11],Es(u)}function T4(t,e){return!Jl(e)}function A4(t){if(!Jl(t.state.error))return Oh;const e=t.state.fetchFailureCount;return Math.min(Oh*2**e,N4)}const R4=new Set(["main","master"]);function jc(t){return R4.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function P4(t){const e=U.c(24),{baseBranch:s,disabled:i,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let d;e[0]!==s?(d=jc(s),e[0]=s,e[1]=d):d=e[1];const c=d;let h;e[2]!==o?(h=()=>{o()},e[2]=o,e[3]=h):h=e[3];let u;e[4]!==l?(u=l?n.jsx(dl,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==h||e[9]!==u?(f=n.jsxs(ie,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:h,children:[u,c]}),e[6]=i,e[7]=c,e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(cs,{className:"h-3.5 w-3.5"}),e[11]=m):m=e[11];let p;e[12]!==i?(p=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:m})}),e[12]=i,e[13]=p):p=e[13];let g;e[14]!==a?(g=a?n.jsx(Ue,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=g):g=e[15];let _;e[16]!==g?(_=n.jsx(Kt,{align:"end",children:g}),e[16]=g,e[17]=_):_=e[17];let b;e[18]!==p||e[19]!==_?(b=n.jsxs(Wt,{children:[p,_]}),e[18]=p,e[19]=_,e[20]=b):b=e[20];let x;return e[21]!==b||e[22]!==f?(x=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,b]}),e[21]=b,e[22]=f,e[23]=x):x=e[23],x}class mn extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function D4(t){const e=U.c(10),[s,i]=D.useState(0);let r;e[0]!==t?(r=d=>{d&&i(I4),t.onOpenChange(d)},e[0]=t,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?n.jsx(L4,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=n.jsx(Bt,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function I4(t){return t+1}function L4({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:d,previewUrl:c,dialogIntent:h="publish",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:m,onPublished:p}){const g=Pt({connectionId:a,orgId:s,orgSlug:e}),_=Pt({connectionId:ul,orgId:s,orgSlug:e}),{data:b}=$i.useSession(),x=ll(_),v=Pp(b?.user),y=f?.state==="open",S=h==="publish",w=h==="open-pr"&&!y,[C,N]=D.useState(null),[E,R]=D.useState(null),[T,k]=D.useState(!0),[j,I]=D.useState(!1),[A,O]=D.useState(""),[L,P]=D.useState(""),[B,F]=D.useState(),[H,z]=D.useState(!1),[W,q]=D.useState(!1),[K,Z]=D.useState(),[Y,G]=D.useState(),[Q,$]=D.useState(!1),[X,V]=D.useState(!1),[se,ee]=D.useState(!1),le=D.useRef(!1),ce=D.useRef(!1),fe=async()=>{const Se=await gr(e,i,r),$e=w||!y&&(Se.aheadOfBase??0)>0?{base:o,...u?{headSha:u}:{}}:void 0,Ge=await Pf(e,i,r,$e);N(Se),R(Ge),O(`Changes from ${Se.current??r}`),ee(!0),rd(e,i,r,{status:Se,diff:Ge}).then(He=>{O(He.title),P(He.body)}).catch(()=>{}).finally(()=>ee(!1))};le.current||(le.current=!0,(async()=>{k(!0),F(void 0),R(null),O(""),P(""),Z(void 0),G(void 0);try{await fe()}catch(Se){if(Jl(Se)&&!ce.current){ce.current=!0;try{await x.mutateAsync({virtualMcpId:i,branch:r}),await fe();return}catch(pe){F(pe instanceof Error?pe.message:"Failed to load changes after re-provisioning the sandbox.");return}}F(Se instanceof Error?Se.message:"Failed to load changes.")}finally{k(!1)}})());const J=Zl(C)??r,te=jc(o),oe=()=>{!C||!E||(ee(!0),rd(e,i,r,{status:C,diff:E}).then(Se=>{O(Se.title),P(Se.body)}).catch(()=>{}).finally(()=>ee(!1)))},de=Df(C),be=E?Object.keys(E.diffs).length:de,ve=w?Lf(C):hy(C,E),we=!T&&(S?ve:ve||w),De=we&&od(E),Be=we&&!od(E)?ly:null,Pe=w||!y&&(C?.aheadOfBase??0)>0,Fe=!T&&(Pe||ve)&&(be>0||ve),xe=()=>[A.trim(),L.trim()].filter(Boolean).join(`
502
-
503
- `),ye=Se=>{j||H||W||t(Se)},Ie=async()=>{q(!0),G(void 0);try{const Se=xe()||A.trim()||`Changes from ${J}`;await Po(e,i,r,Se),he.success(f?`Saved changes to PR #${f.number}`:"Changes saved"),ye(!1),await m?.()}catch(Se){G(Se instanceof Error?Se.message:"Failed to save changes")}finally{q(!1)}},Le=async()=>{I(!0),F(void 0);let Se;try{const pe=A.trim()||`Changes from ${J}`,$e=L.trim()||void 0,Ge=xe()||pe;try{await Po(e,i,r,Ge)}catch(He){throw new mn(He instanceof Error?He.message:"Failed to push changes","push")}try{await ry(e,i,r,o)}catch(He){throw new mn(He instanceof Error?He.message:"Failed to rebase onto base","rebase")}try{Se=await Vc(g,{owner:l,repo:d,branch:J,title:pe,body:$e,base:o,coAuthor:v})}catch(He){throw new mn(He instanceof Error?He.message:"Failed to open pull request","open-pr")}try{await sf(g,{owner:l,repo:d,pullNumber:Se.number,commitTitle:pe,commitMessage:$e,coAuthor:v})}catch(He){throw new mn(He instanceof Error?He.message:"Failed to merge pull request","merge",Se)}he.success(`Published to ${o}`),ye(!1),R(null),O(""),P(""),await m?.(),await p?.()}catch(pe){if(pe instanceof mn&&pe.step==="merge"&&pe.pr){const $e=`Changes were pushed and PR #${pe.pr.number} is open, but merge failed: ${pe.message}`;F($e),he.error($e,{action:{label:"View PR",onClick:()=>window.open(pe.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await m?.();return}F(pe instanceof Error?pe.message:"Failed to publish")}finally{I(!1)}},qe=async Se=>{try{await ad(e,i,r,[Se]),he.success(`Discarded changes to ${Se}`),R($e=>{if(!$e)return $e;const Ge={...$e,diffs:{...$e.diffs}};return delete Ge.diffs[Se],Ge});const pe=await gr(e,i,r);N(pe)}catch(pe){he.error(pe instanceof Error?pe.message:"Failed to discard changes")}},st=async()=>{if(E){$(!1),V(!0);try{const Se=Object.keys(E.diffs);if(Se.length===0)return;await ad(e,i,r,Se),he.success("All changes discarded"),R(null);const pe=await gr(e,i,r);N(pe),ye(!1)}catch(Se){he.error(Se instanceof Error?Se.message:"Failed to discard changes")}finally{V(!1)}}},ct=async()=>{z(!0),Z(void 0);try{const Se=A.trim()||`Changes from ${J}`,pe=L.trim()||void 0,$e=xe()||Se;await Po(e,i,r,$e);const Ge=await Vc(g,{owner:l,repo:d,branch:J,title:Se,body:pe,base:o,coAuthor:v});he.success(`Submitted pull request #${Ge.number} for review`,{action:{label:"View on GitHub",onClick:()=>window.open(Ge.htmlUrl,"_blank","noopener,noreferrer")}}),ye(!1),await m?.()}catch(Se){Z(Se instanceof Error?Se.message:"Failed to submit for review")}finally{z(!1)}};return n.jsx(Mt,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:n.jsxs(lo,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[n.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:S?"Save changes":w?"Submit for review":te}),n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-green-500"}),be," ",be===1?"change":"changes"," ",S?"to save":w?"in this PR":"to publish"]})]}),Q?n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[n.jsx("span",{className:"text-xs text-destructive",children:"Discard all changes? This cannot be undone."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>$(!1),children:"Cancel"}),n.jsxs(ie,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:st,disabled:X,children:[X?n.jsx(Oe,{className:"h-3 w-3 animate-spin"}):null,"Discard all"]})]})]}):n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(ao,{className:"h-8 w-auto",variant:"pill",children:[n.jsx(zs,{value:"description",className:"px-3 text-xs",children:"Description"}),n.jsx(zs,{value:"changes",className:"px-3 text-xs",children:"Changes"})]}),be>0&&!w&&n.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>$(!0),disabled:j||X||W,children:"Discard all"})]})]}),n.jsx("div",{className:"border-t"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:T?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[n.jsx(Oe,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading changes…"})]}):n.jsxs(n.Fragment,{children:[n.jsx(Ei,{value:"description",className:"mt-0 px-6 py-5",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-sm font-medium",children:w?"Pull request":"Commit message"}),n.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:se||j||H||W,onClick:oe,children:[se?n.jsx(Oe,{className:"h-3 w-3 animate-spin"}):n.jsx(Zs,{className:"h-3 w-3"}),se?"Generating…":"Regenerate"]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:"Title"}),n.jsx(ze,{id:"publish-title",value:A,onChange:Se=>O(Se.target.value),placeholder:se?"Generating…":"Commit title…",disabled:j||H||W||se,className:"text-sm"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:"Description"}),n.jsx(Ln,{id:"publish-body",value:L,onChange:Se=>P(Se.target.value),placeholder:se?"Generating…":"Description (optional)…",disabled:j||H||W||se,rows:5,className:"resize-none text-sm"})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Branch: ",n.jsx("span",{className:"font-mono",children:r}),S?n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"text-foreground/80",children:y?`Commits and pushes to update open PR #${f.number}.`:"Commits and pushes to the branch without opening a pull request."})]}):n.jsxs(n.Fragment,{children:[" → ",n.jsx("span",{className:"font-mono",children:o})," · ",n.jsxs("span",{className:"text-foreground/80",children:["Submit for review keeps changes on the branch;"," ",te," squash-merges into ",o,"."]})]})]})]})}),n.jsx(Ei,{value:"changes",className:"mt-0",children:n.jsx(Of,{diff:E,onDiscardFile:qe})})]})}),n.jsx("div",{className:"shrink-0 border-t",children:n.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{c&&window.open(c,"_blank","noopener,noreferrer")},disabled:!c,children:[n.jsxs("span",{className:"flex items-center gap-3",children:[n.jsx(Z_,{className:"h-4 w-4 text-muted-foreground"}),"Visit preview"]}),n.jsx(vg,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:S&&!Pe?n.jsxs(n.Fragment,{children:[n.jsxs(ie,{type:"button",className:"w-full",onClick:Ie,disabled:!we||W,children:[W?n.jsx(Oe,{className:"h-4 w-4 animate-spin"}):null,"Save changes"]}),Y&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:Y})]}):S?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(ie,{type:"button",variant:"outline",className:"flex-1",onClick:Ie,disabled:!we||W||H,children:[W?n.jsx(Oe,{className:"h-4 w-4 animate-spin"}):null,"Save changes"]}),n.jsxs(ie,{type:"button",className:"flex-1",onClick:ct,disabled:!Fe||H||W,children:[H?n.jsx(Oe,{className:"h-4 w-4 animate-spin"}):n.jsx(Dn,{className:"h-4 w-4"}),"Submit for review"]})]}),Y&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:Y}),K&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:K})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(ie,{type:"button",variant:"outline",className:"flex-1",onClick:ct,disabled:!Fe||H||j,children:[H?n.jsx(Oe,{className:"h-4 w-4 animate-spin"}):n.jsx(Dn,{className:"h-4 w-4"}),"Submit for review"]}),n.jsx(O4,{label:te,canPublish:De,disabledReason:Be,isPublishing:j,isSubmittingForReview:H,onPublish:Le})]}),K&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:K}),B&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:B})]})})]})})}function O4(t){const e=U.c(14),{label:s,canPublish:i,disabledReason:r,isPublishing:o,isSubmittingForReview:a,onPublish:l}=t,d=!i||o||a;let c;e[0]!==o?(c=o?n.jsx(Oe,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let h;e[2]!==s||e[3]!==l||e[4]!==d||e[5]!==c?(h=n.jsxs(ie,{type:"button",variant:"success",className:"flex-1",onClick:l,disabled:d,children:[c,s]}),e[2]=s,e[3]=l,e[4]=d,e[5]=c,e[6]=h):h=e[6];const u=h;if(!r)return u;let f;e[7]!==u?(f=n.jsx(Ne,{asChild:!0,children:n.jsx("span",{className:"flex flex-1",children:u})}),e[7]=u,e[8]=f):f=e[8];let m;e[9]!==r?(m=n.jsx(Ee,{children:r}),e[9]=r,e[10]=m):m=e[10];let p;return e[11]!==f||e[12]!==m?(p=n.jsx(mu,{children:n.jsxs(Te,{children:[f,m]})}),e[11]=f,e[12]=m,e[13]=p):p=e[13],p}function B4(){return!1}function Dp(t,e){B4()&&console.log(`[github-header] ${t}`,e??"")}function M4(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return nm[t].short}const $4=new Set(["failure","timed_out","cancelled","action_required"]);function z4(t){return t.status==="completed"&&$4.has(t.conclusion)}function F4(t){return t.status==="queued"||t.status==="in_progress"}function H4(t){return t.isPending&&t.fetchStatus!=="idle"}function U4(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:o,loading:a}=t;if(a)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.phase){case"idle":return{label:t.claimPhase&&M4(t.claimPhase.kind)||"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`}}if(s.kind!=="ready")return{label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for branch metadata from the sandbox daemon"};const l=s;if(l.workingTreeDirty)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(l.unpushed>0&&!(i&&l.headSha&&i.headSha&&l.headSha===i.headSha))return i?{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Push local commits"}:{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push and open a PR for ${l.branch} → ${l.base}`};if(Dp("no local work — checking PR/sync state",{workingTreeDirty:l.workingTreeDirty,unpushed:l.unpushed,aheadOfBase:l.aheadOfBase,behindBase:l.behindBase,branch:l.branch,base:l.base,prMerged:i?.merged??null,prState:i?.state??null}),i?.merged)return!!l.headSha&&!!i.headSha&&l.headSha!==i.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${i.number} merged into ${i.base}`};if(l.aheadOfBase>0){if(i&&i.state==="closed"&&!i.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${i.number}`};if(!i)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${l.branch} → ${l.base}`};if((o?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${i.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${i.base} before merging`};const h=r.filter(z4).map(m=>m.name);if(h.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${h.join(", ")}`,meta:{failingChecks:h}};const u=r.filter(F4);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(o?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=o?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:o?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:jc(i.base),action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${i.number} into ${i.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${l.base}`}}function W4(t,e,s){if(!e)return s??null;const i=t?.[e];if(!i)return s??null;if(s&&i[s])return s;for(const[r,o]of Object.entries(i))if(o&&Object.keys(o).length>0)return r;return s??null}const V4=6e4,K4=3e4;function q4(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Pt(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:V4,refetchIntervalInBackground:!1,staleTime:K4,select:G4},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],oo(l)}function G4(t){const e=ui(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}const Y4={label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for sandbox branch"};function X4({virtualMcpId:t}){const{org:e}=Me(),{data:s}=$i.useSession(),i=vs(t),{currentBranch:r,setCurrentTaskBranch:o}=Ts(),a=li(),[l,d]=D.useState(!1),[c,h]=D.useState("publish"),[u,f]=D.useState(!1),m=D.useRef(""),p=Wn(i),g=s?.user?.id,_=Pt({connectionId:p?.connectionId??"",orgId:e.id,orgSlug:e.slug}),{lifecycle:b,branch:x,phase:v,notFound:y}=bs(),S=x.kind==="ready"?x.branch:null,w=W4(i?.metadata?.sandboxMap,g,r??S),C=r??S??w??void 0,N=b.phase==="cloning"||b.phase==="checking-out"||b.phase==="clone-failed",E=E4({orgSlug:e.slug,virtualMcpId:t,branch:C??null,enabled:!!p&&!!C&&!y&&!N}),R=Zl(E.data)??C??null,T=Ll({orgId:e.id,orgSlug:e.slug,connectionId:p?.connectionId??"",owner:p?.owner??"",repo:p?.name??"",branch:R}),k=T.data??null,j=nf({orgId:e.id,orgSlug:e.slug,connectionId:p?.connectionId??"",owner:p?.owner??"",repo:p?.name??"",prNumber:k&&k.state==="open"?k.number:null}),I=q4({orgId:e.id,orgSlug:e.slug,connectionId:p?.connectionId??"",owner:p?.owner??"",repo:p?.name??"",prNumber:k&&k.state==="open"?k.number:null}),A=py(x,E.data);if(!p)return null;const O=g&&R?to(i?.metadata?.sandboxMap?.[g]?.[R]):{},L=Object.values(O),B=(L.find($=>$.sandboxProviderKind!=="user-desktop")??L[0])?.previewUrl??null,F=R?U4({lifecycle:b,branch:A,claimPhase:v,pr:k,checks:j.data??[],reviews:I.data??null,loading:H4(T)}):Y4,H=JSON.stringify({label:F.label,branchKind:A.kind,workingTreeDirty:A.kind==="ready"?A.workingTreeDirty:null,gitModifiedCount:E.data?.modified.length??null,unpushed:A.kind==="ready"?A.unpushed:null,aheadOfBase:A.kind==="ready"?A.aheadOfBase:null,lifecycle:b.phase,githubHeadBranch:R});m.current!==H&&(m.current=H,Dp("header button",{label:F.label,tooltip:F.tooltip,action:F.action,chatBranch:r,sandboxBranch:S,sandboxMapBranch:w,sandboxRouteBranch:C,githubHeadBranch:R,branchMeta:x,effectiveBranchMeta:A,gitStatus:E.data??null,lifecyclePhase:b.phase,prNumber:k?.number??null,prState:k?.state??null}));const z=$=>a.sendMessage({parts:[{type:"text",text:$}]}),W=a.isStreaming,q=A.kind==="ready"?A.base:"main",K=async()=>{await Promise.all([T.refetch(),E.refetch(),j.refetch(),I.refetch()])},Z=async()=>{const $=ug();await o($)},Y=async $=>{if(!(!p?.connectionId||u)){f(!0);try{const X=Pp(s?.user);await sf(_,{owner:p.owner,repo:p.name,pullNumber:$,coAuthor:X}),he.success(`Published PR #${$}`),await K(),await Z()}catch(X){he.error(X instanceof Error?X.message:"Failed to merge pull request")}finally{f(!1)}}},G=$=>{if(!(!$||!R))switch($){case"commit-and-push":h("publish"),d(!0);return;case"create-pr":h("open-pr"),d(!0);return;case"reopen":if(W)return;k&&z(by({prNumber:k.number}));return;case"rebase":if(W)return;z(yy({branch:R}));return;case"fix-checks":if(W)return;k&&z(wy({prNumber:k.number,failingChecks:F.meta?.failingChecks??[]}));return;case"mark-ready":if(W)return;k&&z(Cy({prNumber:k.number}));return;case"resolve-comments":if(W)return;k&&z(ky({prNumber:k.number}));return;case"merge-split":return}},Q=u||W;return n.jsxs(n.Fragment,{children:[n.jsx(J4,{button:F,actionBusy:Q,githubActionPending:u,onActivate:G,prNumber:k?.number,prBase:k?.base,onSquashMerge:Y,onReview:k?()=>{W||z(jy({prNumber:k.number}))}:void 0}),C&&n.jsx(D4,{open:l,onOpenChange:d,orgSlug:e.slug,orgId:e.id,virtualMcpId:t,branch:C,baseBranch:q,githubConnectionId:p.connectionId??"",owner:p.owner,repo:p.name,previewUrl:B,dialogIntent:c,headSha:A.kind==="ready"?A.headSha:null,openPullRequest:k?.state==="open"?k:null,onPullRequestChanged:K,onPublished:Z})]})}function J4(t){const e=U.c(25),{button:s,actionBusy:i,githubActionPending:r}=t,o=i&&s.action!=="create-pr"&&s.action!=="commit-and-push"&&s.action!=="merge-split",a=!!s.disabled||o||r&&s.action==="merge-split",l=!!s.loading||r&&s.action==="merge-split",d=o?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let m;e[0]!==t?(m=()=>t.onSquashMerge(t.prNumber),e[0]=t,e[1]=m):m=e[1];let p;e[2]!==a||e[3]!==l||e[4]!==t.onReview||e[5]!==t.prBase||e[6]!==m?(p=n.jsx(P4,{baseBranch:t.prBase,disabled:a,loading:l,onPublish:m,onReview:t.onReview}),e[2]=a,e[3]=l,e[4]=t.onReview,e[5]=t.prBase,e[6]=m,e[7]=p):p=e[7];let g;return e[8]!==p||e[9]!==d?(g=n.jsx(Bh,{label:d,children:p}),e[8]=p,e[9]=d,e[10]=g):g=e[10],g}let c;e[11]!==s.action||e[12]!==t?(c=()=>{s.action&&t.onActivate(s.action)},e[11]=s.action,e[12]=t,e[13]=c):c=e[13];let h;e[14]!==l?(h=l?n.jsx(dl,{size:"xs",variant:"default"}):null,e[14]=l,e[15]=h):h=e[15];let u;e[16]!==s.label||e[17]!==s.variant||e[18]!==a||e[19]!==c||e[20]!==h?(u=n.jsxs(ie,{size:"sm",variant:s.variant,disabled:a,onClick:c,children:[h,s.label]}),e[16]=s.label,e[17]=s.variant,e[18]=a,e[19]=c,e[20]=h,e[21]=u):u=e[21];let f;return e[22]!==u||e[23]!==d?(f=n.jsx(Bh,{label:d,children:u}),e[22]=u,e[23]=d,e[24]=f):f=e[24],f}function Bh(t){const e=U.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(Ne,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(Ee,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(mu,{children:n.jsxs(Te,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function Z4(t){const e=U.c(11),{virtualMcp:s}=t,i=hl(),{org:r}=Me(),o=qt(),{create:a}=yu();let l,d;if(e[0]!==i||e[1]!==a||e[2]!==o||e[3]!==r||e[4]!==s){d=Symbol.for("react.early_return_sentinel");e:{const c=Ug(s,i);if(!c){d=null;break e}const h=c.mode==="dev";let u;e[7]!==a||e[8]!==o||e[9]!==r.slug?(u=async p=>{const g=crypto.randomUUID();try{await a({id:g,virtual_mcp_id:p})}catch{}o({to:"/$org/$taskId",params:{org:r.slug,taskId:g},search:{virtualmcpid:p}})},e[7]=a,e[8]=o,e[9]=r.slug,e[10]=u):u=e[10];const f=u,m=(p,g)=>n.jsx("button",{type:"button","aria-pressed":g,onClick:()=>{g||f(c.targetId)},className:ae("px-2.5 py-1 rounded-md transition-colors",g?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:p});l=n.jsxs("div",{className:"inline-flex items-center rounded-lg border border-border bg-muted p-0.5 text-xs font-medium",children:[m("Develop",h),m("Live",!h)]})}e[0]=i,e[1]=a,e[2]=o,e[3]=r,e[4]=s,e[5]=l,e[6]=d}else l=e[5],d=e[6];return d!==Symbol.for("react.early_return_sentinel")?d:l}function Q4(t){const e=U.c(8),{virtualMcp:s,inline:i}=t,r=i===void 0?!1:i;let o,a;e[0]!==s?(o=n.jsx(Z4,{virtualMcp:s}),a=Wg(s)?n.jsx(X4,{virtualMcpId:s.id}):null,e[0]=s,e[1]=o,e[2]=a):(o=e[1],a=e[2]);let l;e[3]!==o||e[4]!==a?(l=n.jsxs("div",{className:"flex items-center gap-2",children:[o,a]}),e[3]=o,e[4]=a,e[5]=l):l=e[5];const d=l;if(r)return d;let c;return e[6]!==d?(c=n.jsx(gn.Right,{children:d}),e[6]=d,e[7]=c):c=e[7],c}function eN(t,e){const s=U.c(34),i=Su(),r=D.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=D.useSyncExternalStore(i.threadsStatus.subscribe,i.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(v=>v.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[d,c]=D.useState(void 0);let h;s[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{c(void 0)},s[3]=h):h=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],D.useEffect(h,u);let f,m;s[6]!==d||s[7]!==t||s[8]!==l||s[9]!==i||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&d===void 0&&(c("pending"),i.fetchThread(t).then(v=>{c(v)})))},m=[t,l,o.kind,d,i],s[6]=d,s[7]=t,s[8]=l,s[9]=i,s[10]=o.kind,s[11]=f,s[12]=m):(f=s[11],m=s[12]),D.useEffect(f,m);let p;s[13]!==i||s[14]!==e?(p={mutationFn:async v=>i.create({id:v,virtual_mcp_id:e})},s[13]=i,s[14]=e,s[15]=p):p=s[15];const g=ai(p);let _,b;if(s[16]!==g||s[17]!==d||s[18]!==t||s[19]!==l||s[20]!==o.kind?(_=()=>{t&&(l||d===null&&o.kind!=="loading"&&(g.isPending||g.variables!==t&&g.mutate(t)))},b=[t,l,d,o.kind,g],s[16]=g,s[17]=d,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=_,s[22]=b):(_=s[21],b=s[22]),D.useEffect(_,b),!t){let v;return s[23]===Symbol.for("react.memo_cache_sentinel")?(v={status:"ready",task:null},s[23]=v):v=s[23],v}if(l){let v;return s[24]!==l?(v={status:"ready",task:l},s[24]=l,s[25]=v):v=s[25],v}if(d&&typeof d=="object"){let v;return s[26]!==d?(v={status:"ready",task:d},s[26]=d,s[27]=v):v=s[27],v}if(g.data){let v;return s[28]!==g.data?(v={status:"ready",task:g.data},s[28]=g.data,s[29]=v):v=s[29],v}if(g.isError){let v;return s[30]!==g.error?(v={status:"error",error:g.error},s[30]=g.error,s[31]=v):v=s[31],v}if(g.isPending||o.kind!=="loading"){let v;return s[32]===Symbol.for("react.memo_cache_sentinel")?(v={status:"creating"},s[32]=v):v=s[32],v}let x;return s[33]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[33]=x):x=s[33],x}function tN(){const t=U.c(6),e=ml(),s=qt();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},t[0]=i):i=t[0];const{preview:r}=eo(i);if(!e||!r)return null;let o;t[1]!==s?(o=()=>s({to:".",search:sN}),t[1]=s,t[2]=o):o=t[2];let a;return t[3]!==r||t[4]!==o?(a=n.jsx(v_,{previewPath:r,showSeeInLibrary:!0,onClose:o}),t[3]=r,t[4]=o,t[5]=a):a=t[5],a}function sN(t){const{preview:e,...s}=t;return s}const wi=D.createContext(null);function gi(){return D.use(wi)}function Mh(t){const e=U.c(6),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(it.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??n.jsx(Yu,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx(Zt,{fallback:i,children:n.jsx(D.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function $h(t){const e=U.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],D.useLayoutEffect(r),null}function zh(t){const e=U.c(23),{virtualMcpId:s,hasActiveGithubRepo:i,sandboxMap:r,children:o}=t,{currentBranch:a}=Ts(),{pendingSandboxProviderKind:l}=cl(),{data:d}=$i.useSession(),c=d?.user?.id,h=fg(s,a??void 0);let u,f;e[0]!==a||e[1]!==l||e[2]!==r||e[3]!==c?(u=c&&a?to(r?.[c]?.[a]):{},f=l?u[l]??null:Sf(u),e[0]=a,e[1]=l,e[2]=r,e[3]=c,e[4]=u,e[5]=f):(u=e[4],f=e[5]);const p=f?.previewUrl??null;let g;e[6]!==u||e[7]!==h?(g=Object.keys(u).length>0||h,e[6]=u,e[7]=h,e[8]=g):g=e[8];const _=g,b=a??null,x=a??null,v=c??null;let y;e[9]!==o||e[10]!==i||e[11]!==l||e[12]!==r||e[13]!==x||e[14]!==v||e[15]!==s?(y=n.jsx(xx,{virtualMcpId:s,branch:x,userId:v,hasActiveGithubRepo:i,sandboxMap:r,sandboxProviderKind:l,children:o}),e[9]=o,e[10]=i,e[11]=l,e[12]=r,e[13]=x,e[14]=v,e[15]=s,e[16]=y):y=e[16];let S;return e[17]!==p||e[18]!==_||e[19]!==b||e[20]!==y||e[21]!==s?(S=n.jsx(fx,{virtualMcpId:s,branch:b,previewUrl:p,enabled:_,children:y}),e[17]=p,e[18]=_,e[19]=b,e[20]=y,e[21]=s,e[22]=S):S=e[22],S}function iN(){const t=U.c(105),e=ml(),s=qt(),{org:i}=Me();Gg(i.slug);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const o=Fh(r),a=o.org??"";let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},t[1]=l):l=t[1];const d=eo(l);let c;t[2]!==i.id||t[3]!==d.virtualmcpid?(c=d.virtualmcpid??Qh(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=c):c=t[4];const h=c,u=eN(o.taskId??"",h),f=vs(h),m=f?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let _;t[7]!==f?(_=f&&Wn(f),t[7]=f,t[8]=_):_=t[8];const b=!!_;let x;t[9]!==a||t[10]!==h?(x={virtualMcpId:h,orgSlug:a,isAgentRoute:!0},t[9]=a,t[10]=h,t[11]=x):x=t[11];const v=uv(g,x),y=D.useRef(null);let S,w;t[12]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const W=q=>{qg(q)&&q.shiftKey&&q.code==="KeyS"&&!q.repeat&&(q.preventDefault(),y.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},w=[],t[12]=S,t[13]=w):(S=t[12],w=t[13]),D.useEffect(S,w);const C=h;let N;t[14]!==f||t[15]!==h?(N={virtualMcpId:h,entity:f},t[14]=f,t[15]=h,t[16]=N):N=t[16];const E=N;if(u.status==="creating"||u.status==="loading"){let W;t[17]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(Oe,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=W):W=t[17];let q;return t[18]!==E?(q=n.jsx(wi,{value:E,children:W}),t[18]=E,t[19]=q):q=t[19],q}if(u.status==="error"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=W):W=t[20];let q;t[21]!==u.error.message?(q=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[W,n.jsx("div",{className:"text-muted-foreground",children:u.error.message})]})}),t[21]=u.error.message,t[22]=q):q=t[22];let K;return t[23]!==E||t[24]!==q?(K=n.jsx(wi,{value:E,children:q}),t[23]=E,t[24]=q,t[25]=K):K=t[25],K}if(!f){let W;t[26]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(zi,{size:48,className:"text-muted-foreground"}),t[26]=W):W=t[26];const q=`The agent "${h}" does not exist in this organization.`;let K;t[27]!==s||t[28]!==a?(K=n.jsx(ie,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:a}}),children:"Go to organization home"}),t[27]=s,t[28]=a,t[29]=K):K=t[29];let Z;t[30]!==q||t[31]!==K?(Z=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Cr,{image:W,title:"Agent not found",description:q,actions:K})})}),t[30]=q,t[31]=K,t[32]=Z):Z=t[32];let Y;return t[33]!==E||t[34]!==Z?(Y=n.jsx(wi,{value:E,children:Z}),t[33]=E,t[34]=Z,t[35]=Y):Y=t[35],Y}if(e){const W=u.status==="ready"?u.task:null,q=f?.metadata?.sandboxMap;let K;t[36]!==v.createNewTask?(K=n.jsx($h,{onNewTaskRef:y,createNewTask:v.createNewTask}),t[36]=v.createNewTask,t[37]=K):K=t[37];const Z=!v.mainOpen;let Y;t[38]!==v.createNewTask||t[39]!==v.toggleMain||t[40]!==Z?(Y=n.jsx(gn.Toggles,{children:n.jsx(Lh,{chatOpen:Z,toggleChat:v.toggleMain,onNewTask:v.createNewTask,newTaskFirst:!0})}),t[38]=v.createNewTask,t[39]=v.toggleMain,t[40]=Z,t[41]=Y):Y=t[41];let G;t[42]!==C||t[43]!==v.taskId?(G=n.jsx(gn.Tabs,{children:n.jsx(k4,{virtualMcpId:C,taskId:v.taskId})}),t[42]=C,t[43]=v.taskId,t[44]=G):G=t[44];let Q;t[45]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(it.Skeleton,{}),t[45]=Q):Q=t[45];let $;t[46]!==C||t[47]!==v.mainOpen||t[48]!==v.taskId?($=n.jsx(D.Suspense,{fallback:Q,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:v.mainOpen?n.jsx(Zt,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Rp,{taskId:v.taskId,virtualMcpId:C})})}):n.jsx(Mh,{})})}),t[46]=C,t[47]=v.mainOpen,t[48]=v.taskId,t[49]=$):$=t[49];let X;t[50]!==v.taskId||t[51]!==Y||t[52]!==G||t[53]!==$?(X=n.jsxs(it.ActiveTaskProvider,{taskId:v.taskId,children:[Y,G,$]},v.taskId),t[50]=v.taskId,t[51]=Y,t[52]=G,t[53]=$,t[54]=X):X=t[54];let V;t[55]!==b||t[56]!==q||t[57]!==K||t[58]!==X||t[59]!==h?(V=n.jsxs(zh,{virtualMcpId:h,hasActiveGithubRepo:b,sandboxMap:q,children:[K,X]}),t[55]=b,t[56]=q,t[57]=K,t[58]=X,t[59]=h,t[60]=V):V=t[60];let se;t[61]!==C||t[62]!==V||t[63]!==W?(se=n.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:n.jsx(it.Provider,{virtualMcpId:C,task:W,children:V},C)}),t[61]=C,t[62]=V,t[63]=W,t[64]=se):se=t[64];let ee;return t[65]!==E||t[66]!==se?(ee=n.jsx(wi,{value:E,children:se}),t[65]=E,t[66]=se,t[67]=ee):ee=t[67],ee}let R;t[68]!==v.chatOpen||t[69]!==v.createNewTask||t[70]!==v.toggleChat?(R=n.jsx(gn.Toggles,{children:n.jsx(Lh,{chatOpen:v.chatOpen,toggleChat:v.toggleChat,onNewTask:v.createNewTask})}),t[68]=v.chatOpen,t[69]=v.createNewTask,t[70]=v.toggleChat,t[71]=R):R=t[71];const T=u.status==="ready"?u.task:null,k=f?.metadata?.sandboxMap;let j;t[72]!==v.taskId||t[73]!==h?(j=n.jsx(gn.Tabs,{children:n.jsx(w4,{virtualMcpId:h,taskId:v.taskId})}),t[72]=v.taskId,t[73]=h,t[74]=j):j=t[74];let I;t[75]!==v.createNewTask?(I=n.jsx($h,{onNewTaskRef:y,createNewTask:v.createNewTask}),t[75]=v.createNewTask,t[76]=I):I=t[76];let A;t[77]!==f?(A=n.jsx(Q4,{virtualMcp:f}),t[77]=f,t[78]=A):A=t[78];let O;t[79]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(it.Skeleton,{}),t[79]=O):O=t[79];let L;t[80]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Mh,{}),t[80]=L):L=t[80];let P;t[81]!==v.chatOpen||t[82]!==v.mainOpen||t[83]!==v.taskId||t[84]!==h?(P=n.jsx(D.Suspense,{fallback:O,children:n.jsx(x4,{virtualMcpId:h,taskId:v.taskId,chatOpen:v.chatOpen,mainOpen:v.mainOpen,chatContent:L})}),t[81]=v.chatOpen,t[82]=v.mainOpen,t[83]=v.taskId,t[84]=h,t[85]=P):P=t[85];let B;t[86]!==v.taskId||t[87]!==A||t[88]!==P?(B=n.jsxs(it.ActiveTaskProvider,{taskId:v.taskId,children:[A,P]},v.taskId),t[86]=v.taskId,t[87]=A,t[88]=P,t[89]=B):B=t[89];let F;t[90]!==b||t[91]!==k||t[92]!==j||t[93]!==I||t[94]!==B||t[95]!==h?(F=n.jsxs(zh,{virtualMcpId:h,hasActiveGithubRepo:b,sandboxMap:k,children:[j,I,B]}),t[90]=b,t[91]=k,t[92]=j,t[93]=I,t[94]=B,t[95]=h,t[96]=F):F=t[96];let H;t[97]!==C||t[98]!==T||t[99]!==F?(H=n.jsx(it.Provider,{virtualMcpId:C,task:T,children:F},C),t[97]=C,t[98]=T,t[99]=F,t[100]=H):H=t[100];let z;return t[101]!==E||t[102]!==H||t[103]!==R?(z=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsxs(wi,{value:E,children:[R,H]})}),t[101]=E,t[102]=H,t[103]=R,t[104]=z):z=t[104],z}function nN(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(t1,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(D.Suspense,{fallback:e,children:n.jsxs(J_,{children:[n.jsx(iN,{}),n.jsx(tN,{})]})}),t[1]=s):s=t[1],s}const AE=Object.freeze(Object.defineProperty({__proto__:null,default:nN,useInsetContext:gi},Symbol.toStringTag,{value:"Module"}));export{SE as $,hc as A,l0 as B,Hw as C,b2 as D,Ji as E,_E as F,lf as G,cE as H,gE as I,b0 as J,vE as K,o0 as L,vw as M,fE as N,f0 as O,SC as P,aE as Q,mE as R,hw as S,uE as T,S2 as U,jE as V,nE as W,oE as X,iE as Y,wE as Z,y2 as _,cc as a,a0,Gf as a1,Z6 as a2,Q6 as a3,tE as a4,sE as a5,xE as a6,hE as a7,w0 as a8,dE as a9,cC as aA,AE as aB,bE as aa,Zi as ab,cf as ac,_f as ad,_a as ae,Ns as af,uc as ag,Y6 as ah,X6 as ai,yE as aj,Dp as ak,dy as al,gr as am,Gw as an,c2 as ao,zr as ap,kE as aq,xC as ar,Sa as as,Ho as at,sw as au,Kr as av,rr as aw,gC as ax,vC as ay,NE as az,CE as b,pE as c,jm as d,J6 as e,Ol as f,Bl as g,gi as h,Tt as i,k0 as j,nc as k,d2 as l,Vl as m,ix as n,Kl as o,Us as p,Xf as q,rE as r,Y2 as s,Ur as t,Gl as u,bS as v,eE as w,gw as x,Zf as y,lE as z};