decocms 2.299.0 → 2.300.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/client/assets/{AlertCircle-aQgTv3kr.js → AlertCircle-CtSiN7Dh.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-C_pLc5t-.js → ArrowNarrowLeft-CjMD5YtT.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-Bws5ir-q.js → ArrowUpRight-VGEco3p8.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-Cwc7BvQq.js → CheckCircle-BOjQcSoZ.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-C4MI00HX.js → ChevronDown-B21GyFLP.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-DDkghuaf.js → ChevronRight-C7fFXCXU.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-BjFGxYUb.js → ChevronUp-DLJe-Ifh.js} +1 -1
  8. package/dist/client/assets/{Container-U4v06cth.js → Container-DVwtR0PY.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-BCK2nFhn.js → DotsVertical-_1yE4PFi.js} +1 -1
  10. package/dist/client/assets/{LinkExternal01-C_yQygSO.js → LinkExternal01-BeNjIA73.js} +1 -1
  11. package/dist/client/assets/{Lock01-rLvN1xbd.js → Lock01-y9D26Lk9.js} +1 -1
  12. package/dist/client/assets/{Palette-CA95sDHj.js → Palette-xIvgAE_U.js} +1 -1
  13. package/dist/client/assets/{Play-BlOman6C.js → Play-esUCyQh5.js} +1 -1
  14. package/dist/client/assets/{Plus-B5soxpbi.js → Plus-8zlfW9Nb.js} +1 -1
  15. package/dist/client/assets/{RefreshCcw01-onzNEsM4.js → RefreshCcw01-DV-_PfmV.js} +1 -1
  16. package/dist/client/assets/{SearchMd-fvAW1pa8.js → SearchMd-BgpZuBQH.js} +1 -1
  17. package/dist/client/assets/{Settings02-Cro6-7q4.js → Settings02-B2DHZxlV.js} +1 -1
  18. package/dist/client/assets/{Shield01-DtWtqZJ1.js → Shield01-CewVSi37.js} +1 -1
  19. package/dist/client/assets/{Star01-BHGJRtit.js → Star01-DupDdRAe.js} +1 -1
  20. package/dist/client/assets/{Sun-C6J9iUe_.js → Sun-B1MYWGMj.js} +1 -1
  21. package/dist/client/assets/{Tool01-DeRpug6W.js → Tool01-73PH4njb.js} +1 -1
  22. package/dist/client/assets/{Trash01-BSFNbfe8.js → Trash01-_-2EAUWH.js} +1 -1
  23. package/dist/client/assets/{User01-C-8Fo7RS.js → User01-DLnrd0WJ.js} +1 -1
  24. package/dist/client/assets/{Users03-C25Ink_E.js → Users03-CtQ_adLe.js} +1 -1
  25. package/dist/client/assets/{X-Cf3FFZEE.js → X-DavTUkoo.js} +1 -1
  26. package/dist/client/assets/{XCircle-CLM44_6-.js → XCircle-BKeTm8Ww.js} +1 -1
  27. package/dist/client/assets/{XClose-B9H_q-Ab.js → XClose-BpjQA_dF.js} +1 -1
  28. package/dist/client/assets/{Zap-BQvzqOLx.js → Zap-DT_tBFfJ.js} +1 -1
  29. package/dist/client/assets/{ZapSquare-CjSpwpWX.js → ZapSquare-BL-_ZEqM.js} +1 -1
  30. package/dist/client/assets/{accordion-YUzrCziW.js → accordion-pRq2Jalt.js} +1 -1
  31. package/dist/client/assets/{agent-icon-CyFFhaia.js → agent-icon-DnE1m294.js} +1 -1
  32. package/dist/client/assets/{agents-list-W7eiHZAH.js → agents-list-BoAFCp78.js} +1 -1
  33. package/dist/client/assets/ai-providers-CAEYBEbx.js +1 -0
  34. package/dist/client/assets/{alert-dialog-BRriT9Rx.js → alert-dialog-DvcLf48w.js} +1 -1
  35. package/dist/client/assets/{auth-catchall-dvNJT_HW.js → auth-catchall-CAJD1PoQ.js} +1 -1
  36. package/dist/client/assets/{automation-list-row-Dr5BqZcR.js → automation-list-row-DsEcFwqj.js} +1 -1
  37. package/dist/client/assets/{automations-DThDEBhK.js → automations-0IJqtFMr.js} +1 -1
  38. package/dist/client/assets/{avatar-DZ7Lcia3.js → avatar-B1YFr91G.js} +1 -1
  39. package/dist/client/assets/{badge-CNKFpwCQ.js → badge-BnwDLyJj.js} +1 -1
  40. package/dist/client/assets/{brand-context-FHNmQTmw.js → brand-context-D5_IL-aX.js} +1 -1
  41. package/dist/client/assets/{card-DVXldwSE.js → card-Hve9iIpZ.js} +1 -1
  42. package/dist/client/assets/{chat-context-clHOazkR.js → chat-context-C2vjARhO.js} +1 -1
  43. package/dist/client/assets/{checkbox-EVw79nds.js → checkbox-DmWLCJJH.js} +1 -1
  44. package/dist/client/assets/{collection-detail-C13v-yoJ.js → collection-detail-D8wvqyeL.js} +1 -1
  45. package/dist/client/assets/{collection-display-button-BM4OZbbR.js → collection-display-button-CQ2KlZSu.js} +1 -1
  46. package/dist/client/assets/{collection-search-DoSMDd39.js → collection-search-D_mJKf_N.js} +1 -1
  47. package/dist/client/assets/{collection-search-DjqZM35U.js → collection-search-DffILLk0.js} +1 -1
  48. package/dist/client/assets/{collection-table-wrapper-jyvgWmq5.js → collection-table-wrapper-fO254CQy.js} +1 -1
  49. package/dist/client/assets/{collection-tabs-Nu6UZ0Wa.js → collection-tabs-Bcs-_tfj.js} +1 -1
  50. package/dist/client/assets/{collections-_TpL4Kbd.js → collections-CISD8jzc.js} +1 -1
  51. package/dist/client/assets/{command-BGK9JNiv.js → command-CsVFknP_.js} +1 -1
  52. package/dist/client/assets/{connection-card-h503T7yE.js → connection-card-aTu5Xl4N.js} +1 -1
  53. package/dist/client/assets/{connection-detail-E3ZTKIWY.js → connection-detail-BUr0xwe0.js} +1 -1
  54. package/dist/client/assets/{connection-form-helpers-B5DiwUxU.js → connection-form-helpers-BEHWki2e.js} +1 -1
  55. package/dist/client/assets/{connections-Ba8EED2x.js → connections-BJwQ4V76.js} +1 -1
  56. package/dist/client/assets/{constants-lTcLVS5n.js → constants-BwurOShK.js} +1 -1
  57. package/dist/client/assets/{constants-CiJRSGoE.js → constants-DZ5y4NEu.js} +1 -1
  58. package/dist/client/assets/{dialog-BRB-AdlQ.js → dialog-BSlhJimL.js} +1 -1
  59. package/dist/client/assets/{domain-settings-vcc_x35P.js → domain-settings-D65HSgmV.js} +1 -1
  60. package/dist/client/assets/{drawer-rKfRlJNC.js → drawer-DwurUbp0.js} +1 -1
  61. package/dist/client/assets/{dropdown-menu-DaYjsctt.js → dropdown-menu-Dn3K1Gpo.js} +1 -1
  62. package/dist/client/assets/{dynamic-plugin-layout-Bs-dtzIc.js → dynamic-plugin-layout-uzPcJgAD.js} +1 -1
  63. package/dist/client/assets/{empty-state-DpWDEkDd.js → empty-state-B4R6bbr3.js} +1 -1
  64. package/dist/client/assets/{empty-state-DLaWKneQ.js → empty-state-DbgILpoj.js} +1 -1
  65. package/dist/client/assets/{extract-connection-data-DIDviCIp.js → extract-connection-data-Bp5NDOhQ.js} +1 -1
  66. package/dist/client/assets/{features-CE8oBb9H.js → features-MuQDQTKd.js} +1 -1
  67. package/dist/client/assets/{form-mI6GLCMQ.js → form-DTt4fIHo.js} +1 -1
  68. package/dist/client/assets/{general-27HuvgYf.js → general-C7YvzevF.js} +1 -1
  69. package/dist/client/assets/index-B4J1yAvl.css +1 -0
  70. package/dist/client/assets/{index-Ccm19Owr.js → index-BJz9Oj-t.js} +1 -1
  71. package/dist/client/assets/{index-B11-oLok.js → index-BTM4S0x-.js} +1 -1
  72. package/dist/client/assets/{index-D8ZWoKb1.js → index-BZwRn_mX.js} +1 -1
  73. package/dist/client/assets/index-CKNbLfs9.js +1 -0
  74. package/dist/client/assets/{index-cC9WxUf7.js → index-COQkJrV6.js} +1 -1
  75. package/dist/client/assets/{index-BdrUauLh.js → index-CbEM9IOV.js} +1 -1
  76. package/dist/client/assets/{index-oMBghIJJ.js → index-D1LVHcIe.js} +1 -1
  77. package/dist/client/assets/{index-BLqORW7O.js → index-D9wcQMm5.js} +1 -1
  78. package/dist/client/assets/{index-WenLlWbb.js → index-DBY00Q2Z.js} +19 -19
  79. package/dist/client/assets/{index-C4eEdhdn.js → index-DHKldY3y.js} +1 -1
  80. package/dist/client/assets/{index-hcEg81hB.js → index-DRnP8Xhy.js} +10 -10
  81. package/dist/client/assets/{index-CHiZkXhm.js → index-Day-HjXR.js} +1 -1
  82. package/dist/client/assets/{index-CD-vU91r.js → index-XlHohbXo.js} +1 -1
  83. package/dist/client/assets/{index-DHZDsons.js → index-h0Ny6VA2.js} +1 -1
  84. package/dist/client/assets/{index-B3FEpuQw.js → index-uTtq-reU.js} +1 -1
  85. package/dist/client/assets/{index-B3zZp_Qu.js → index-ygN6PiaU.js} +1 -1
  86. package/dist/client/assets/{infiniteQueryObserver-DkM0VxlF.js → infiniteQueryObserver-BFZ15R1_.js} +1 -1
  87. package/dist/client/assets/{input-Cuud93wX.js → input-liZY-axz.js} +1 -1
  88. package/dist/client/assets/{integration-icon-CsrRg2Lu.js → integration-icon-Cz-seBmA.js} +1 -1
  89. package/dist/client/assets/{label-Bk3DQN0Y.js → label-CrXFAdsO.js} +1 -1
  90. package/dist/client/assets/{layout-BtQea4Qg.js → layout-bMTJXFfz.js} +1 -1
  91. package/dist/client/assets/{lean-canvas-recruit-modal-CbbipZjJ.js → lean-canvas-recruit-modal-DZ6knxg9.js} +1 -1
  92. package/dist/client/assets/{login-BgZ8a57W.js → login-CWW3hrOg.js} +1 -1
  93. package/dist/client/assets/{members-BrEtD2C0.js → members-DKWnDmHd.js} +1 -1
  94. package/dist/client/assets/{monaco-editor-B5h0xAd0.js → monaco-editor-Cx68yuxi.js} +1 -1
  95. package/dist/client/assets/{monitoring-stats-row-FmuYstq7.js → monitoring-stats-row-BFqk7UYd.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-ai-provider-D2JxS3R_.js → oauth-callback-ai-provider-ONRq40Il.js} +1 -1
  97. package/dist/client/assets/{oauth-callback-BOHYAMsk.js → oauth-callback-nz50ugwL.js} +1 -1
  98. package/dist/client/assets/{onboarding-Dls-YBag.js → onboarding-CbZyKtbC.js} +1 -1
  99. package/dist/client/assets/{org-layout-B0WpG86a.js → org-layout-DkS2FRIV.js} +1 -1
  100. package/dist/client/assets/{org-plugin-layout-fSkxW1jN.js → org-plugin-layout-DnoycXXu.js} +1 -1
  101. package/dist/client/assets/{pair-CqYfP4a_.js → pair-rqe3skqp.js} +1 -1
  102. package/dist/client/assets/{plugin-empty-state-C3M4-bHq.js → plugin-empty-state-DAJtqa_X.js} +1 -1
  103. package/dist/client/assets/{plugin-header-Bhl8FTKN.js → plugin-header-DnTysGuR.js} +1 -1
  104. package/dist/client/assets/{plugin-layout-DOuAk8f9.js → plugin-layout-Zl5kAJLg.js} +1 -1
  105. package/dist/client/assets/{popover-BWawolwL.js → popover-B6ijC2Zf.js} +1 -1
  106. package/dist/client/assets/{profile-DKggoElb.js → profile-Wj3GJkbr.js} +1 -1
  107. package/dist/client/assets/{project-app-view-BTqqbkYN.js → project-app-view-DufFnF1s.js} +1 -1
  108. package/dist/client/assets/registry-D49ZAHvu.js +2 -0
  109. package/dist/client/assets/{registry-layout-Bcb0ETu2.js → registry-layout-BvfKYFzg.js} +1 -1
  110. package/dist/client/assets/{required-auth-layout-B0aP_BYa.js → required-auth-layout-CKQlCfyf.js} +1 -1
  111. package/dist/client/assets/{reset-password-DAQu9CHm.js → reset-password-4dmtvYgx.js} +1 -1
  112. package/dist/client/assets/{roles-CV8Id8qK.js → roles-DlsIbipv.js} +1 -1
  113. package/dist/client/assets/{scroll-area-0g8Z_dWS.js → scroll-area-D_0eTXQI.js} +1 -1
  114. package/dist/client/assets/{search-input-jyuCy7Ai.js → search-input-CbBz2_I7.js} +1 -1
  115. package/dist/client/assets/{select-hpzuL2n7.js → select-DwQCWni4.js} +1 -1
  116. package/dist/client/assets/{select-model-CtHOnPsy.js → select-model-CSzGroxj.js} +1 -1
  117. package/dist/client/assets/{settings-layout-ClllTp0r.js → settings-layout-D2TzHadG.js} +1 -1
  118. package/dist/client/assets/{settings-section-DTpTGGC-.js → settings-section-CVNbjkC4.js} +1 -1
  119. package/dist/client/assets/{shell-layout-B405kN5F.js → shell-layout-BK74oWLU.js} +1 -1
  120. package/dist/client/assets/{skeleton-B9GboYxM.js → skeleton-DnMJGIDK.js} +1 -1
  121. package/dist/client/assets/{sso-Dh1NgG1u.js → sso-ByZblLmU.js} +1 -1
  122. package/dist/client/assets/{store-2uy2qIUV.js → store-D02KrT4m.js} +1 -1
  123. package/dist/client/assets/store-registry-C02mfQOQ.js +2 -0
  124. package/dist/client/assets/{switch-CD5xHhwa.js → switch-BwYbkaPM.js} +1 -1
  125. package/dist/client/assets/{table-Bl-CW2Ey.js → table-dOL69UsN.js} +1 -1
  126. package/dist/client/assets/{tabs-8bRAvOFB.js → tabs-CGg7lV45.js} +1 -1
  127. package/dist/client/assets/{task-status-Df19deFg.js → task-status-DAgh3LfT.js} +1 -1
  128. package/dist/client/assets/{textarea-0ebJKTCS.js → textarea-CkxfQbxI.js} +1 -1
  129. package/dist/client/assets/{toggle-group-BqrVPEZw.js → toggle-group-C5VhmQig.js} +1 -1
  130. package/dist/client/assets/{tools-list-1YgWwNhM.js → tools-list-CwM3RxlF.js} +1 -1
  131. package/dist/client/assets/{tooltip-CGmvkTM6.js → tooltip-CUw8WpYG.js} +1 -1
  132. package/dist/client/assets/{types-CN-G9hqy.js → types-slR7lXH6.js} +1 -1
  133. package/dist/client/assets/{use-ai-providers-BtZzelvz.js → use-ai-providers-DespFg1Y.js} +1 -1
  134. package/dist/client/assets/{use-collections-DjbmBbmU.js → use-collections-CDG0ivO9.js} +1 -1
  135. package/dist/client/assets/{use-connection-CffI5S47.js → use-connection-DDedfw7l.js} +1 -1
  136. package/dist/client/assets/{use-copy-DNx2iDfI.js → use-copy-Czy0YFNn.js} +1 -1
  137. package/dist/client/assets/{use-create-virtual-mcp-BFp1mbc9.js → use-create-virtual-mcp-Bhi93QNY.js} +1 -1
  138. package/dist/client/assets/{use-decopilot-events-D5TlUkky.js → use-decopilot-events-DkzJQYGR.js} +1 -1
  139. package/dist/client/assets/{use-delete-connection-O5X9Xo4O.js → use-delete-connection-CG2J3Cjn.js} +1 -1
  140. package/dist/client/assets/{use-infinite-scroll-FZg8WuOv.js → use-infinite-scroll-qjXoMT8U.js} +1 -1
  141. package/dist/client/assets/{use-list-state-CbWjR069.js → use-list-state-D2VmPCpI.js} +1 -1
  142. package/dist/client/assets/{use-mcp-tools-CxZifaYv.js → use-mcp-tools-nd8RTEJZ.js} +1 -1
  143. package/dist/client/assets/{use-members-CXQMD9Vu.js → use-members-BWz4qY4v.js} +1 -1
  144. package/dist/client/assets/{use-navigate-to-agent-C0C5E43c.js → use-navigate-to-agent-Dj0boPYr.js} +1 -1
  145. package/dist/client/assets/{use-org-auth-client-Dy4G77my.js → use-org-auth-client-_7iLBAbg.js} +1 -1
  146. package/dist/client/assets/{use-org-sso-Drj77Zm1.js → use-org-sso-CXTYwYuw.js} +1 -1
  147. package/dist/client/assets/{use-organization-roles-DmSBxwGY.js → use-organization-roles-BmJJrwum.js} +1 -1
  148. package/dist/client/assets/{use-organization-settings--1KNcya1.js → use-organization-settings-C516uAxZ.js} +1 -1
  149. package/dist/client/assets/{use-registry-connections-BaBm7Ii1.js → use-registry-connections-BH65PVKK.js} +1 -1
  150. package/dist/client/assets/{use-status-sounds-BDL4IJ6A.js → use-status-sounds-COJng9ez.js} +1 -1
  151. package/dist/client/assets/{use-tasks-DF42FEXc.js → use-tasks-BMtiaufW.js} +1 -1
  152. package/dist/client/assets/{use-view-mode-CBcjjJZG.js → use-view-mode-B3HPjSsa.js} +1 -1
  153. package/dist/client/assets/{use-virtual-mcp-CTmQF3FY.js → use-virtual-mcp-Dkco3wCF.js} +1 -1
  154. package/dist/client/assets/useInfiniteQuery-mbgOLEDd.js +1 -0
  155. package/dist/client/assets/useSuspenseInfiniteQuery-DZGLPMRe.js +1 -0
  156. package/dist/client/assets/{user-DNhBNgsY.js → user-BCVAIUhB.js} +1 -1
  157. package/dist/client/assets/{view-mode-toggle-KbDgQNkg.js → view-mode-toggle-Bbj9P-zr.js} +1 -1
  158. package/dist/client/assets/{workflow-DZzf5GRI.js → workflow-DZKRFLJh.js} +1 -1
  159. package/dist/client/assets/workflow-detail-Bm0PdrL9.js +1 -0
  160. package/dist/client/index.html +2 -2
  161. package/dist/server/cli.js +3 -3
  162. package/dist/server/node_modules/ansi-regex/index.d.ts +33 -0
  163. package/dist/server/node_modules/ansi-regex/index.js +14 -0
  164. package/dist/server/node_modules/{ansi-styles → ansi-regex}/package.json +20 -13
  165. package/dist/server/node_modules/ansi-regex/readme.md +66 -0
  166. package/dist/server/node_modules/mimic-fn/index.d.ts +54 -0
  167. package/dist/server/node_modules/mimic-fn/index.js +13 -0
  168. package/dist/server/node_modules/mimic-fn/package.json +42 -0
  169. package/dist/server/node_modules/mimic-fn/readme.md +69 -0
  170. package/dist/server/node_modules/pg-int8/LICENSE +13 -0
  171. package/dist/server/node_modules/pg-int8/README.md +16 -0
  172. package/dist/server/node_modules/pg-int8/index.js +100 -0
  173. package/dist/server/node_modules/pg-int8/package.json +24 -0
  174. package/dist/server/node_modules/postgres-array/index.d.ts +4 -0
  175. package/dist/server/node_modules/postgres-array/index.js +97 -0
  176. package/dist/server/node_modules/postgres-array/license +21 -0
  177. package/dist/server/node_modules/postgres-array/package.json +35 -0
  178. package/dist/server/node_modules/postgres-array/readme.md +43 -0
  179. package/dist/server/node_modules/postgres-bytea/index.js +33 -0
  180. package/dist/server/node_modules/postgres-bytea/license +21 -0
  181. package/dist/server/node_modules/postgres-bytea/package.json +34 -0
  182. package/dist/server/node_modules/postgres-bytea/readme.md +34 -0
  183. package/dist/server/node_modules/postgres-date/index.js +116 -0
  184. package/dist/server/node_modules/postgres-date/license +21 -0
  185. package/dist/server/node_modules/postgres-date/package.json +33 -0
  186. package/dist/server/node_modules/postgres-date/readme.md +49 -0
  187. package/dist/server/node_modules/postgres-interval/index.d.ts +20 -0
  188. package/dist/server/node_modules/postgres-interval/index.js +125 -0
  189. package/dist/server/node_modules/postgres-interval/license +21 -0
  190. package/dist/server/node_modules/postgres-interval/package.json +36 -0
  191. package/dist/server/node_modules/postgres-interval/readme.md +48 -0
  192. package/dist/server/server.js +2 -2
  193. package/package.json +1 -1
  194. package/dist/client/assets/ai-providers-D112U5ed.js +0 -1
  195. package/dist/client/assets/index-CLgHTXwu.js +0 -1
  196. package/dist/client/assets/index-DT63_YMm.css +0 -1
  197. package/dist/client/assets/registry-BOvZQpcE.js +0 -2
  198. package/dist/client/assets/store-registry-LkT6leWD.js +0 -2
  199. package/dist/client/assets/useInfiniteQuery-BugVQNDu.js +0 -1
  200. package/dist/client/assets/useSuspenseInfiniteQuery-CMPA3kQv.js +0 -1
  201. package/dist/client/assets/workflow-detail-OXlDN5sZ.js +0 -1
  202. package/dist/server/node_modules/ansi-styles/index.d.ts +0 -236
  203. package/dist/server/node_modules/ansi-styles/index.js +0 -223
  204. package/dist/server/node_modules/ansi-styles/readme.md +0 -173
  205. package/dist/server/node_modules/environment/index.d.ts +0 -74
  206. package/dist/server/node_modules/environment/index.js +0 -47
  207. package/dist/server/node_modules/environment/license +0 -9
  208. package/dist/server/node_modules/environment/package.json +0 -74
  209. package/dist/server/node_modules/environment/readme.md +0 -94
  210. package/dist/server/node_modules/escape-string-regexp/index.d.ts +0 -18
  211. package/dist/server/node_modules/escape-string-regexp/index.js +0 -11
  212. package/dist/server/node_modules/escape-string-regexp/package.json +0 -43
  213. package/dist/server/node_modules/escape-string-regexp/readme.md +0 -29
  214. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  215. package/dist/server/node_modules/is-fullwidth-code-point/index.js +0 -12
  216. package/dist/server/node_modules/is-fullwidth-code-point/license +0 -9
  217. package/dist/server/node_modules/is-fullwidth-code-point/package.json +0 -53
  218. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +0 -31
  219. package/dist/server/node_modules/string-width/index.d.ts +0 -39
  220. package/dist/server/node_modules/string-width/index.js +0 -82
  221. package/dist/server/node_modules/string-width/license +0 -9
  222. package/dist/server/node_modules/string-width/package.json +0 -64
  223. package/dist/server/node_modules/string-width/readme.md +0 -66
  224. /package/dist/server/node_modules/{ansi-styles → ansi-regex}/license +0 -0
  225. /package/dist/server/node_modules/{escape-string-regexp → mimic-fn}/license +0 -0
@@ -1,10 +1,10 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-BTqqbkYN.js","assets/index-hcEg81hB.js","assets/index-DT63_YMm.css","assets/pair-CqYfP4a_.js","assets/agent-icon-CyFFhaia.js","assets/AlertCircle-aQgTv3kr.js","assets/Tool01-DeRpug6W.js","assets/XClose-B9H_q-Ab.js","assets/RefreshCcw01-onzNEsM4.js","assets/ArrowNarrowLeft-C_pLc5t-.js","assets/XCircle-CLM44_6-.js","assets/ArrowUpRight-Bws5ir-q.js","assets/ZapSquare-CjSpwpWX.js","assets/Users03-C25Ink_E.js","assets/CheckCircle-Cwc7BvQq.js","assets/ChevronDown-C4MI00HX.js","assets/ChevronRight-DDkghuaf.js","assets/ChevronUp-BjFGxYUb.js","assets/DotsVertical-BCK2nFhn.js","assets/Container-U4v06cth.js","assets/Star01-BHGJRtit.js","assets/Palette-CA95sDHj.js","assets/SearchMd-fvAW1pa8.js","assets/index-oMBghIJJ.js","assets/tooltip-CGmvkTM6.js","assets/X-Cf3FFZEE.js","assets/LinkExternal01-C_yQygSO.js","assets/Lock01-rLvN1xbd.js","assets/Sun-C6J9iUe_.js","assets/Play-BlOman6C.js","assets/Plus-B5soxpbi.js","assets/Settings02-Cro6-7q4.js","assets/Shield01-DtWtqZJ1.js","assets/Trash01-BSFNbfe8.js","assets/User01-C-8Fo7RS.js","assets/Zap-BQvzqOLx.js","assets/index-cC9WxUf7.js","assets/use-copy-DNx2iDfI.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BRB-AdlQ.js","assets/content-blocks-o63cs2vh.js","assets/types-CN-G9hqy.js","assets/constants-CiJRSGoE.js","assets/chat-context-clHOazkR.js","assets/use-virtual-mcp-CTmQF3FY.js","assets/use-collections-DjbmBbmU.js","assets/use-ai-providers-BtZzelvz.js","assets/use-decopilot-events-D5TlUkky.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DF42FEXc.js","assets/use-organization-settings--1KNcya1.js","assets/shell-layout-B405kN5F.js","assets/required-auth-layout-B0aP_BYa.js","assets/use-org-sso-Drj77Zm1.js","assets/integration-icon-CsrRg2Lu.js","assets/use-mcp-tools-CxZifaYv.js"])))=>i.map(i=>d[i]);
2
- import{o as Ht,r as A,p as jl,q as El,e as V,s as ye,K as As,n as Wo,a as Uo,c as te,j as o,l as Me,B as se,E as Qt,b as Si,v as ni,f as Mt,d as Yr,w as Tl,x as me,y as Dl,V as Rl,t as Se,z as Vo,C as Ml,D as Xt,F as Il,G as vn,L as Bl,H as Ai,I as Js,J as ct,M as Ko,P as Al,_ as Pl,Q as qo,R as Go,T as Ll,g as Ol}from"./index-hcEg81hB.js";import{C as je,u as zl,w as $l,A as Fl,T as Hl,a as Wl}from"./index-C4eEdhdn.js";import{I as ds}from"./integration-icon-CsrRg2Lu.js";import{S as It,u as Fe,g as Yo,a as Xo}from"./constants-CiJRSGoE.js";import{u as gt,a as Ul}from"./use-virtual-mcp-CTmQF3FY.js";import{a as Vl}from"./Users03-C25Ink_E.js";import{u as Jo,a as lt,b as yi,c as wi,t as Kl,d as xn}from"./chat-context-clHOazkR.js";import{i as as}from"./AlertCircle-aQgTv3kr.js";import{i as ql}from"./CheckCircle-Cwc7BvQq.js";import{n as bn,a as Gl}from"./ZapSquare-CjSpwpWX.js";import{i as Yl,a as Xl,b as Jl,c as Ci,d as Zl}from"./XCircle-CLM44_6-.js";import{s as ls,i as Ql}from"./XClose-B9H_q-Ab.js";import{c as ec,r as tc,p as Zo,f as Sn,a as sc,F as ic,t as yn,M as Xr,G as Qo,L as rc,i as nc,b as oc,d as ac,e as lc}from"./pair-CqYfP4a_.js";import{C as cc,a as wn,b as Cn,c as hc,d as dc,e as uc,f as fc}from"./command-BGK9JNiv.js";import{P as Hs,a as Ws,b as Us}from"./popover-BWawolwL.js";import{i as Ds,a as mi,b as mc,c as _c,p as ki,g as Ni,d as Jr,e as ea,h as ar,f as Pi,j as kn,A as Nn,k as ta,l as pc,m as gc,n as vc,t as xc,o as bc,q as sa,r as ia,s as ra,u as na,v as jn,w as Sc,x as Rs,y as yc,z as wc,B as Cc,C as oa}from"./agent-icon-CyFFhaia.js";import{u as us,a as kc}from"./use-mcp-tools-CxZifaYv.js";import{u as Nc,a as jc}from"./use-ai-providers-BtZzelvz.js";import{g as Bt,c as En,u as Ec,b as lr,d as Tc,e as Dc,f as Rc,T as Mc}from"./index-Ccm19Owr.js";import{u as Zr,i as Ic}from"./shell-layout-B405kN5F.js";import{i as Bc,P as at,u as Ac,c as Pc,d as Lc,e as Oc}from"./index-oMBghIJJ.js";import{u as aa,T as Ve,a as Ke,b as qe,c as zc}from"./tooltip-CGmvkTM6.js";import{u as $c}from"./use-status-sounds-BDL4IJ6A.js";import{E as Ps}from"./empty-state-DLaWKneQ.js";import{A as Fc,a as Hc,b as Wc,c as Uc,R as la,d as Vc,e as Kc}from"./accordion-YUzrCziW.js";import{u as ji,a as Qr,b as qc}from"./use-connection-CffI5S47.js";import{g as Gc}from"./constants-lTcLVS5n.js";import{u as Yc,g as Xc}from"./types-CN-G9hqy.js";import{U as ca}from"./user-DNhBNgsY.js";import{T as Jc,u as ha}from"./tools-list-1YgWwNhM.js";import{u as Li}from"./unwrap-tool-result-BYXdCQMg.js";import{s as da,g as Zc}from"./connection-slug-eyAPH6o3.js";import{A as ua,a as fa,b as ma,c as _a,d as pa,e as ga,f as va,g as xa}from"./alert-dialog-BRriT9Rx.js";import{D as Qc,a as en,b as tn,c as ba,d as Sa}from"./dialog-BRB-AdlQ.js";import{C as eh,a as Tn}from"./card-DVXldwSE.js";import{I as fs}from"./input-Cuud93wX.js";import{L as Ms}from"./label-Bk3DQN0Y.js";import{S as es,a as ts,b as ss,c as is,d as Rt}from"./select-hpzuL2n7.js";import{S as cr}from"./switch-CD5xHhwa.js";import{T as Dn}from"./textarea-0ebJKTCS.js";import{i as oi}from"./Play-BlOman6C.js";import{s as cs}from"./Plus-B5soxpbi.js";import{a as th}from"./Settings02-Cro6-7q4.js";import{t as ya}from"./Tool01-DeRpug6W.js";import{s as hr}from"./Trash01-BSFNbfe8.js";import{S as wa}from"./scroll-area-0g8Z_dWS.js";import{i as Ca,a as sh}from"./SearchMd-fvAW1pa8.js";import{C as ih}from"./collection-tabs-Nu6UZ0Wa.js";import{C as rh}from"./checkbox-EVw79nds.js";import{u as nh,T as Oi,a as oh,b as ah,c as zi}from"./tabs-8bRAvOFB.js";import{D as lh,a as ch,b as hh}from"./drawer-rKfRlJNC.js";import{i as Ei,t as dr}from"./ChevronDown-C4MI00HX.js";import{n as Wt}from"./LinkExternal01-C_yQygSO.js";import{D as rs,a as ns,b as os,c as yt,d as dh,e as uh,f as fh}from"./dropdown-menu-DaYjsctt.js";import{i as ka}from"./RefreshCcw01-onzNEsM4.js";import{V as mh}from"./view-mode-toggle-KbDgQNkg.js";import{G as _h}from"./lean-canvas-recruit-modal-CbbipZjJ.js";import{M as ph}from"./select-model-CtHOnPsy.js";import{u as Vs,a as gh,b as vh,c as xh,A as bh,d as Sh}from"./automation-list-row-Dr5BqZcR.js";import{i as Ls}from"./Zap-BQvzqOLx.js";import{S as yh}from"./search-input-jyuCy7Ai.js";import"./use-navigate-to-agent-C0C5E43c.js";import"./use-tasks-DF42FEXc.js";import"./use-collections-DjbmBbmU.js";import"./index-cC9WxUf7.js";import"./collection-search-DoSMDd39.js";import"./form-mI6GLCMQ.js";import"./Star01-BHGJRtit.js";import"./Lock01-rLvN1xbd.js";import"./X-Cf3FFZEE.js";import"./toggle-group-BqrVPEZw.js";import"./index-B11-oLok.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-D6a8kmGH.js";import"./connection-card-h503T7yE.js";import"./use-registry-connections-BaBm7Ii1.js";import"./use-organization-settings--1KNcya1.js";import"./useInfiniteQuery-BugVQNDu.js";import"./infiniteQueryObserver-DkM0VxlF.js";import"./extract-connection-data-DIDviCIp.js";import"./Container-U4v06cth.js";import"./connection-form-helpers-B5DiwUxU.js";import"./use-infinite-scroll-FZg8WuOv.js";import"./useSuspenseInfiniteQuery-CMPA3kQv.js";import"./badge-CNKFpwCQ.js";import"./ChevronRight-DDkghuaf.js";import"./use-decopilot-events-D5TlUkky.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-DNx2iDfI.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-C6J9iUe_.js";import"./index-D8ZWoKb1.js";import"./ArrowNarrowLeft-C_pLc5t-.js";import"./ArrowUpRight-Bws5ir-q.js";import"./ChevronUp-BjFGxYUb.js";import"./DotsVertical-BCK2nFhn.js";import"./Palette-CA95sDHj.js";import"./Shield01-DtWtqZJ1.js";import"./User01-C-8Fo7RS.js";import"./skeleton-B9GboYxM.js";import"./avatar-DZ7Lcia3.js";import"./index-BLqORW7O.js";import"./collection-search-DjqZM35U.js";import"./use-create-virtual-mcp-BFp1mbc9.js";import"./task-status-Df19deFg.js";import"./required-auth-layout-B0aP_BYa.js";import"./use-org-sso-Drj77Zm1.js";import"./collections-_TpL4Kbd.js";import"./settings-section-DTpTGGC-.js";import"./formatDistanceToNow-Cb2QZZJn.js";function wh(t,e){const s=Ht(e);return Ch({filters:{...t,status:"pending"}},s).length}function Rn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Ch(t={},e){const s=Ht(e).getMutationCache(),i=A.useRef(t),r=A.useRef(null);return r.current===null&&(r.current=Rn(s,t)),A.useEffect(()=>{i.current=t}),A.useSyncExternalStore(A.useCallback(n=>s.subscribe(()=>{const a=jl(r.current,Rn(s,i.current));r.current!==a&&(r.current=a,El.schedule(n))}),[s]),()=>r.current,()=>r.current)}function kh(t,e){const s=V.c(39),{org:i,locator:r}=ye();let n;s[0]!==i.id?(n={connectionId:It,orgId:i.id},s[0]=i.id,s[1]=n):n=s[1];const a=Fe(n),l=Ht();let h;s[2]!==t||s[3]!==i.id?(h=As.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=h):h=s[4];let c;s[5]!==a||s[6]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=c):c=s[7];const d=t.length>0;let u;s[8]!==h||s[9]!==c||s[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,retry:!1,refetchOnWindowFocus:!1},s[8]=h,s[9]=c,s[10]=d,s[11]=u):u=s[11];const m=Wo(u);let _;s[12]!==a||s[13]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const y=w.content,k=Array.isArray(y)&&y[0]&&typeof y[0]=="object"?y[0].text??"Create failed":"Create failed";throw new Error(k)}return w.structuredContent.item},s[12]=a,s[13]=e,s[14]=_):_=s[14];let f;s[15]!==r||s[16]!==i.id||s[17]!==m||s[18]!==l?(f=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:As.tasksPrefix(r)}),m.refetch()},s[15]=r,s[16]=i.id,s[17]=m,s[18]=l,s[19]=f):f=s[19];let p;s[20]!==_||s[21]!==f?(p={mutationFn:_,onSuccess:f},s[20]=_,s[21]=f,s[22]=p):p=s[22];const g=Uo(p);let v,b;if(s[23]!==g||s[24]!==t||s[25]!==m.data||s[26]!==m.isSuccess?(v=()=>{t&&(!m.isSuccess||m.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,m.isSuccess,m.data,g],s[23]=g,s[24]=t,s[25]=m.data,s[26]=m.isSuccess,s[27]=v,s[28]=b):(v=s[27],b=s[28]),A.useEffect(v,b),!t){let x;return s[29]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[29]=x):x=s[29],x}if(m.isLoading){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[30]=x):x=s[30],x}if(m.isError){const x=m.error;let w;return s[31]!==x?(w={status:"error",error:x},s[31]=x,s[32]=w):w=s[32],w}if(m.isSuccess&&m.data){let x;return s[33]!==m.data?(x={status:"ready",task:m.data},s[33]=m.data,s[34]=x):x=s[34],x}if(g.isPending||m.isSuccess&&!m.data){let x;return s[35]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[35]=x):x=s[35],x}if(g.isError){let x;return s[36]!==g.error?(x={status:"error",error:g.error},s[36]=g.error,s[37]=x):x=s[37],x}let S;return s[38]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[38]=S):S=s[38],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Mn(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 Nh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function jh(t){const e=V.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Eh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.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 Eh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Th(t){const e=V.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let m;e[6]!==c||e[7]!==d||e[8]!==u?(m=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let f;e[11]!==a?(f=a.toFixed(1),e[11]=a,e[12]=f):f=e[12];let p;e[13]!==f?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",f,"%"]})]}),e[13]=f,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==m?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[m,x]}),e[27]=x,e[28]=m,e[29]=w):w=e[29],w}function Dh(t){const e=V.c(19),{part:s}=t,i=s.input?.agent_id,r=gt(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let d;e[0]!==a||e[1]!==n?(d=o.jsx(ds,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=d):d=e[2];const u=h?"text-destructive":"text-foreground";let m;e[3]!==u?(m=te("shrink-0 font-medium",u),e[3]=u,e[4]=m):m=e[4];let _;e[5]!==n||e[6]!==m?(_=o.jsx("span",{className:m,children:n}),e[5]=n,e[6]=m,e[7]=_):_=e[7];let f;e[8]!==s.input?(f=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=f):f=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Me,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(Yl,{size:12,className:"text-destructive"}):c?o.jsx(as,{size:12,className:"text-warning"}):o.jsx(ql,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==d||e[15]!==_||e[16]!==f||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,_,f,p]}),e[14]=d,e[15]=_,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function Rh(t){const e=V.c(58),{onClose:s,back:i,className:r}=t,[n,a]=A.useState(null),{messages:l}=Jo(),{tasks:h,taskId:c}=lt(),{selectedModel:d,selectedVirtualMcp:u}=yi();let m,_,f,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==d||e[6]!==u?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=Q=>Q.id===c,e[17]=c,e[18]=N):N=e[18];const y=h.find(N),k=ec(l),j=[...l].reverse().find($h),M=j?.metadata?.usage,R=j?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,T=M?.contextTokens??M?.totalTokens??0,C=R&&R>0?(T/R*100).toFixed(1):null,D=l;let E;e[19]!==D?(E=D.filter(zh).reduce(Oh,0),e[19]=D,e[20]=E):E=e[20];const L=E,z=l;let B;e[21]!==z?(B=z.filter(Lh).reduce(Ph,0),e[21]=z,e[22]=B):B=e[22];const O=B,$=Math.max(0,k.totalTokens-L-O),W=l[0],I=l.at(-1),F=W?.metadata?.created_at??y?.created_at,U=I?.metadata?.created_at??y?.updated_at,K=l.filter(Ah),G=l.flatMap(Ih),P=d?.modelId?Nh(d.modelId):"—",Z=u?.title??"Decopilot",Y=[{label:"Session",value:y?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:Z},{label:"Model",value:P},{label:"Context Limit",value:R?vs(R):"—"},{label:"Session Tokens (billed)",value:k.totalTokens>0?vs(k.totalTokens):"0"},{label:"Usage",value:C!==null?`${C}%`:"—"},{label:"Input Tokens",value:k.inputTokens>0?vs(k.inputTokens):"0"},{label:"Output Tokens",value:k.outputTokens>0?vs(k.outputTokens):"0"},{label:"Reasoning Tokens",value:k.reasoningTokens>0?vs(k.reasoningTokens):"0"},{label:"Cost",value:k.cost>0?`$${k.cost<.001?k.cost.toFixed(6):k.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Mn(F)},{label:"Last Activity",value:Mn(U)}];if(!y&&K.length===0){let Q;e[23]!==r?(Q=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=Q):Q=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let de;e[26]!==i?(de=i?o.jsx(bn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=de):de=e[27];let ue;e[28]!==s||e[29]!==de?(ue=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:de})]}),e[28]=s,e[29]=de,e[30]=ue):ue=e[30];let we;e[31]===Symbol.for("react.memo_cache_sentinel")?(we=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=we):we=e[31];let Xe;e[32]!==Q||e[33]!==ue?(Xe=o.jsxs("div",{className:Q,children:[ue,we]}),e[32]=Q,e[33]=ue,e[34]=Xe):Xe=e[34],S=Xe;break e}e[35]!==r?(v=te("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=ee):ee=e[37];let ce;e[38]!==i?(ce=i?o.jsx(bn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ce):ce=e[39],e[40]!==s||e[41]!==ce?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[ee,o.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:ce})]}),e[40]=s,e[41]=ce,e[42]=b):b=e[42],m="flex flex-col gap-8 p-6",_=G.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:G.map(Mh)})]}),f=o.jsx(jh,{items:Y});let ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(ie=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ie):ie=e[43],e[44]!==O||e[45]!==$||e[46]!==L?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ie,o.jsx(Th,{userTokens:L,assistantTokens:O,otherTokens:$})]}),e[44]=O,e[45]=$,e[46]=L,e[47]=p):p=e[47],g=K.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:K.map(Q=>{const he=Q.metadata?.created_at,de=n?.id===Q.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(de?null:Q),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:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:te("shrink-0 font-medium",Q.role==="user"?"text-chart-1":"text-chart-2"),children:Q.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:Q.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),de&&o.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(Q,null,2)})]},Q.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=d,e[6]=u?.title,e[7]=c,e[8]=h,e[9]=m,e[10]=_,e[11]=f,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else m=e[9],_=e[10],f=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==m||e[49]!==_||e[50]!==f||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:m,children:[_,f,p,g]}),e[48]=m,e[49]=_,e[50]=f,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Mh(t,e){return o.jsx(Dh,{part:t},e)}function Ih(t){return(t.parts??[]).filter(Bh)}function Bh(t){return t.type==="tool-subtask"}function Ah(t){return t.role!=="system"}function Ph(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Lh(t){return t.role==="assistant"}function Oh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function zh(t){return t.role==="user"}function $h(t){return t.role==="assistant"&&t.metadata?.usage}const In=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Bn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Fh(){const t=In[Math.floor(Math.random()*In.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Hh(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Wh(t){const e=V.c(25),{orgId:s,userId:i,connectionId:r,vmMap:n,owner:a,repo:l,enabled:h}=t,c=h===void 0?!0:h,d=r??null;let u;e[0]!==s||e[1]!==d?(u={connectionId:d,orgId:s},e[0]=s,e[1]=d,e[2]=u):u=e[2];const m=Fe(u);let _;e[3]!==a||e[4]!==l?(_={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=_):_=e[5];const f=c&&!!r&&!!a&&!!l;let p;e[6]!==m||e[7]!==_||e[8]!==f?(p={client:m,toolName:"list_branches",toolArguments:_,enabled:f,staleTime:3e4,select:qh},e[6]=m,e[7]=_,e[8]=f,e[9]=p):p=e[9];const{data:g,isLoading:v,isError:b}=us(p);let S,x;e[10]!==i||e[11]!==n?(x=new Set(Object.keys(n?.[i]??{})),S=[...x].sort().map(Kh),e[10]=i,e[11]=n,e[12]=S,e[13]=x):(S=e[12],x=e[13]);const w=S;let N;if(e[14]!==g||e[15]!==x){const M=Array.isArray(g)?g:g?.branches??[];let R;e[17]!==x?(R=T=>!x.has(T.name),e[17]=x,e[18]=R):R=e[18],N=M.filter(Vh).filter(R).map(Uh),e[14]=g,e[15]=x,e[16]=N}else N=e[16];const y=N,k=Array.isArray(g)?null:g?.default_branch??null;let j;return e[19]!==k||e[20]!==b||e[21]!==v||e[22]!==y||e[23]!==w?(j={yours:w,others:y,defaultBase:k,isLoading:v,isError:b},e[19]=k,e[20]=b,e[21]=v,e[22]=y,e[23]=w,e[24]=j):j=e[24],j}function Uh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Vh(t){return typeof t.name=="string"}function Kh(t){return{name:t,source:"yours"}}function qh(t){return Hh(t)}function Gh(t){const e=V.c(41),{orgId:s,userId:i,connectionId:r,owner:n,repo:a,vmMap:l,value:h,onChange:c}=t,[d,u]=A.useState(!1);let m;e[0]!==r||e[1]!==d||e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==i||e[6]!==l?(m={orgId:s,userId:i,connectionId:r,vmMap:l,owner:n,repo:a,enabled:d},e[0]=r,e[1]=d,e[2]=s,e[3]=n,e[4]=a,e[5]=i,e[6]=l,e[7]=m):m=e[7];const{yours:_,others:f,isLoading:p,isError:g}=Wh(m);let v;e[8]!==c?(v=E=>{c(E),u(!1)},e[8]=c,e[9]=v):v=e[9];const b=v,S=h??"Select branch…";let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ds,{className:"h-3.5 w-3.5"}),e[10]=x):x=e[10];let w;e[11]!==S?(w=o.jsx(Hs,{asChild:!0,children:o.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[x,o.jsx("span",{className:"max-w-[200px] truncate",children:S})]})}),e[11]=S,e[12]=w):w=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(dc,{placeholder:"Search branches…"}),e[13]=N):N=e[13];let y;e[14]!==b?(y=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[N,o.jsx(se,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>b(Fh()),children:"New"})]}),e[14]=b,e[15]=y):y=e[15];let k;e[16]!==g?(k=g&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[16]=g,e[17]=k):k=e[17];let j;e[18]!==g||e[19]!==p||e[20]!==f.length||e[21]!==_.length?(j=!g&&!p&&_.length===0&&f.length===0&&o.jsx(cc,{children:"No branches found."}),e[18]=g,e[19]=p,e[20]=f.length,e[21]=_.length,e[22]=j):j=e[22];let M;e[23]!==b||e[24]!==_?(M=_.length>0&&o.jsx(wn,{heading:"Your branches",children:_.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Ds,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=b,e[24]=_,e[25]=M):M=e[25];let R;e[26]!==f||e[27]!==b?(R=f.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{}),o.jsx(wn,{heading:"Other branches in repo",children:f.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Ds,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=f,e[27]=b,e[28]=R):R=e[28];let T;e[29]!==R||e[30]!==k||e[31]!==j||e[32]!==M?(T=o.jsxs(uc,{children:[k,j,M,R]}),e[29]=R,e[30]=k,e[31]=j,e[32]=M,e[33]=T):T=e[33];let C;e[34]!==T||e[35]!==y?(C=o.jsx(Ws,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(fc,{children:[y,T]})}),e[34]=T,e[35]=y,e[36]=C):C=e[36];let D;return e[37]!==d||e[38]!==C||e[39]!==w?(D=o.jsxs(Us,{open:d,onOpenChange:u,children:[w,C]}),e[37]=d,e[38]=C,e[39]=w,e[40]=D):D=e[40],D}function Yh(){const t=V.c(26),{org:e}=ye(),{selectedVirtualMcp:s}=yi(),{data:i}=Si.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=lt();let a;t[0]!==e.id?(a=Yo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=gt(h.id),d=i?.user?.id??"",u=c?.metadata?.githubRepo??null,m=!!u?.connectionId&&!!d;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Vl,{size:32}),t[2]=_):_=t[2];let f;t[3]!==h.icon||t[4]!==h.title?(f=o.jsx(ds,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=f):f=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==u||t[13]!==e.id||t[14]!==n||t[15]!==m||t[16]!==d?(b=m&&o.jsx("div",{className:"mt-2",children:o.jsx(Gh,{orgId:e.id,userId:d,connectionId:u.connectionId,owner:u.owner,repo:u.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=n,t[15]=m,t[16]=d,t[17]=b):b=t[17];let S;t[18]!==f||t[19]!==p||t[20]!==v||t[21]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[f,p,v,b]}),t[18]=f,t[19]=p,t[20]=v,t[21]=b,t[22]=S):S=t[22];let x;t[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[23]=x):x=t[23];let w;return t[24]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[24]=S,t[25]=w):w=t[25],w}function Xh(){const t=V.c(26),{org:e}=ye(),s=Nc(),{isChatEmpty:i}=Jo(),[r,n]=A.useState("chat"),a=zl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!$l(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]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const d=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let u;t[10]!==d?(u=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",d),t[10]=d,t[11]=u):u=t[11];let m;t[12]!==i?(m=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(Yh,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=m):m=t[13];let _;t[14]!==u||t[15]!==m?(_=o.jsx("div",{className:u,children:m}),t[14]=u,t[15]=m,t[16]=_):_=t[16];const f=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==f?(p=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[17]=f,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Rh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Na(){const t=V.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Qt,{fallback:e,children:o.jsx(A.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(Xh,{})})}),t[1]=s):s=t[1],s}async function Jh(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const ja=["VM_START"],Zs=new Map,Zh=t=>`${t.virtualMcpId}::${t.branch??""}`;function sn(t){const e=Ht();return Uo({mutationKey:ja,mutationFn:async s=>{const i=Zh(s),r=Zs.get(i);if(r)return r;const n=(async()=>(await Jh(t,"VM_START",s)).structuredContent)();Zs.set(i,n);try{return await n}finally{Zs.get(i)===n&&Zs.delete(i)}},onSuccess:()=>{ni(e)}})}function Ea(t,e){const s=V.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:ja,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],wh(i)>0}const Qh={settings:_c,automations:mc,env:mi,preview:Xl,git:Ds};function An(t){const e=ki(t);if(e.type==="icon"){const s=Ni(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function $i(t){if(t.kind==="system")return{kind:"component",Component:Qh[t.tabId]};const e=An(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=An(s.icon);return i||{kind:"fallback"}}function ed(t){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),{data:i}=Tl({queryKey:As.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Ta(t){const e=V.c(8),s=Mt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Yr(i),n=gt(t.virtualMcpId),a=ed(t.taskId),{currentBranch:l}=lt(),h=n?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],m=a?.expanded_tools??[],_=!!(n&&Bt(n));let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f={includeVirtual:!0},e[1]=f):f=e[1];const p=ji(f),{activeTab:g,mainOpen:v}=tc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(td)}:null}),b=Zo(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const j of m){const M=Sn(j.appId,j.toolName);x.set(M,{id:M,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of u){const M=Sn(j.connectionId,j.toolName);x.set(M,{id:M,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let w;e[2]!==p?(w=j=>({id:j.id,title:j.title,kind:"agent",icon:$i({tabId:j.id,kind:"agent",appId:j.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const N=[...d.map(w),...Array.from(x.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:$i({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:p})})),...S.map(j=>({id:j.id,title:j.title,kind:"system",icon:$i({tabId:j.id,kind:"system",connections:p})}))];let y;return e[4]!==g||e[5]!==v||e[6]!==s?(y=j=>{const M=sc({clickedId:j,activeTab:g,mainOpen:v});s({to:".",search:R=>({...R,main:M}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=y):y=e[7],{activeTab:g,mainOpen:v,setActiveTab:y,systemTabs:S,layoutTabs:d,expandedTools:m,automationTabParsed:b,tabs:N}}function td(t){return{id:t.id}}function sd(t){const e=V.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:d}=t,u=a===void 0?"lg":a,m=c===void 0?!0:c,_=d===void 0?!1:d,[f,p]=A.useState(!1),[g,v]=A.useState("icons"),[b,S]=A.useState(""),[x,w]=A.useState("blue");let N;e[0]!==s?(N=ki(s),e[0]=s,e[1]=N):N=e[1];const y=N,k=y.type==="icon"||y.type==="url"&&y.color?y.color:x;let j;e[2]!==i||e[3]!==k?(j=_e=>{i(Pi(_e,k))},e[2]=i,e[3]=k,e[4]=j):j=e[4];const M=j;let R;e[5]!==i||e[6]!==r||e[7]!==y.name||e[8]!==y.type||e[9]!==y.url?(R=_e=>{w(_e),r?.(_e),y.type==="icon"?i(Pi(y.name,_e)):y.type==="url"&&i(kn(y.url,_e))},e[5]=i,e[6]=r,e[7]=y.name,e[8]=y.type,e[9]=y.url,e[10]=R):R=e[10];const T=R;let C;e[11]!==i||e[12]!==k?(C=_e=>{i(kn(_e,k)),p(!1)},e[11]=i,e[12]=k,e[13]=C):C=e[13];const D=C;let E;e[14]!==i||e[15]!==k?(E=()=>{const _e=Jr(),Vt=_e[Math.floor(Math.random()*_e.length)];i(Pi(Vt,k))},e[14]=i,e[15]=k,e[16]=E):E=e[16];const L=E;let z,B,O,$,W,I,F,U;if(e[17]!==l||e[18]!==_||e[19]!==f||e[20]!==u){const _e={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Us,I=_?!1:f,F=p,z=Hs,W=!0,U="button",O=_,$=te("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",_e[u],l),e[17]=l,e[18]=_,e[19]=f,e[20]=u,e[21]=z,e[22]=B,e[23]=O,e[24]=$,e[25]=W,e[26]=I,e[27]=F,e[28]=U}else z=e[21],B=e[22],O=e[23],$=e[24],W=e[25],I=e[26],F=e[27],U=e[28];let K;e[29]!==h||e[30]!==n||e[31]!==u||e[32]!==s?(K=o.jsx(Nn,{icon:s,name:n,size:u,className:h}),e[29]=h,e[30]=n,e[31]=u,e[32]=s,e[33]=K):K=e[33];let G;e[34]!==_||e[35]!==m?(G=m&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(ta,{size:16,className:"text-white"})}),e[34]=_,e[35]=m,e[36]=G):G=e[36];let P;e[37]!==O||e[38]!==$||e[39]!==K||e[40]!==G||e[41]!==U?(P=o.jsxs("button",{type:U,disabled:O,className:$,children:[K,G]}),e[37]=O,e[38]=$,e[39]=K,e[40]=G,e[41]=U,e[42]=P):P=e[42];let Z;e[43]!==z||e[44]!==W||e[45]!==P?(Z=o.jsx(z,{asChild:W,children:P}),e[43]=z,e[44]=W,e[45]=P,e[46]=Z):Z=e[46];let Y;e[47]!==n||e[48]!==s?(Y=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(Nn,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=Y):Y=e[49];let ee;e[50]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>v("icons"),e[50]=ee):ee=e[50];const ce=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ie;e[51]!==ce?(ie=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ce),e[51]=ce,e[52]=ie):ie=e[52];let Q;e[53]!==ie?(Q=o.jsx("button",{type:"button",onClick:ee,className:ie,children:"Icons"}),e[53]=ie,e[54]=Q):Q=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const de=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[56]!==de?(ue=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",de),e[56]=de,e[57]=ue):ue=e[57];let we;e[58]!==ue?(we=o.jsx("button",{type:"button",onClick:he,className:ue,children:"Upload"}),e[58]=ue,e[59]=we):we=e[59];let Xe;e[60]===Symbol.for("react.memo_cache_sentinel")?(Xe=o.jsx("div",{className:"flex-1"}),e[60]=Xe):Xe=e[60];let He;e[61]!==Q||e[62]!==we?(He=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[Q,we,Xe]}),e[61]=Q,e[62]=we,e[63]=He):He=e[63];let ne;e[64]!==T||e[65]!==L||e[66]!==M||e[67]!==D||e[68]!==y.name||e[69]!==y.type||e[70]!==b||e[71]!==k||e[72]!==g?(ne=g==="icons"?o.jsx(od,{search:b,onSearchChange:S,selectedColor:k,onColorChange:T,onSelectIcon:M,onRandom:L,currentIconName:y.type==="icon"?y.name:null}):o.jsx(ad,{onUpload:D}),e[64]=T,e[65]=L,e[66]=M,e[67]=D,e[68]=y.name,e[69]=y.type,e[70]=b,e[71]=k,e[72]=g,e[73]=ne):ne=e[73];let ve;e[74]!==Y||e[75]!==He||e[76]!==ne?(ve=o.jsx(Ws,{align:"start",className:"w-80 p-0",onOpenAutoFocus:id,children:o.jsxs("div",{className:"flex flex-col",children:[Y,He,ne]})}),e[74]=Y,e[75]=He,e[76]=ne,e[77]=ve):ve=e[77];let tt;return e[78]!==B||e[79]!==I||e[80]!==F||e[81]!==Z||e[82]!==ve?(tt=o.jsxs(B,{open:I,onOpenChange:F,children:[Z,ve]}),e[78]=B,e[79]=I,e[80]=F,e[81]=Z,e[82]=ve,e[83]=tt):tt=e[83],tt}function id(t){return t.preventDefault()}function rd(t){const e=V.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=A.useState(!1);let a,l,h,c,d,u,m;if(e[0]!==r||e[1]!==s){const b=ea(s);l=Us,u=r,m=n,a=Hs,d=!0,h="button",c=te("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=d,e[7]=u,e[8]=m}else a=e[2],l=e[3],h=e[4],c=e[5],d=e[6],u=e[7],m=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let f;e[12]!==a||e[13]!==d||e[14]!==_?(f=o.jsx(a,{asChild:d,children:_}),e[12]=a,e[13]=d,e[14]=_,e[15]=f):f=e[15];let p;e[16]!==i||e[17]!==s?(p=gc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:te("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Ws,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:nd,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==u||e[23]!==m||e[24]!==f||e[25]!==g?(v=o.jsxs(l,{open:u,onOpenChange:m,children:[f,g]}),e[21]=l,e[22]=u,e[23]=m,e[24]=f,e[25]=g,e[26]=v):v=e[26],v}function nd(t){return t.preventDefault()}function od(t){const e=V.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,m,_,f,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=Jr(),w=ea(r);d=s.trim()?x.filter(T=>{const C=ar(T),D=s.toLowerCase();return C.includes(D)||T.toLowerCase().includes(D)}):x,f="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ca,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=N):N=e[14];let y;e[15]!==i?(y=T=>i(T.target.value),e[15]=i,e[16]=y):y=e[16];let k;e[17]!==s||e[18]!==y?(k=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(fs,{value:s,onChange:y,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=y,e[19]=k):k=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(pc,{size:14,className:"text-muted-foreground"}),e[20]=j):j=e[20];let M;e[21]!==l?(M=o.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:j}),e[21]=l,e[22]=M):M=e[22];let R;e[23]!==n||e[24]!==r?(R=o.jsx(rd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=R):R=e[25],e[26]!==M||e[27]!==R||e[28]!==k?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[k,M,R]}),e[26]=M,e[27]=R,e[28]=k,e[29]=p):p=e[29],c=wa,_="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",m=d.map(T=>{const C=Ni(T);return C?o.jsx("button",{type:"button",onClick:()=>a(T),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===T?te(w.bg,w.text):te(w.text,"hover:bg-accent")),title:T,children:o.jsx(C,{size:18})},T):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=d,e[9]=u,e[10]=m,e[11]=_,e[12]=f,e[13]=p}else c=e[7],d=e[8],u=e[9],m=e[10],_=e[11],f=e[12],p=e[13];let g;e[30]!==u||e[31]!==m?(g=o.jsx("div",{className:u,children:m}),e[30]=u,e[31]=m,e[32]=g):g=e[32];let v;e[33]!==d.length?(v=d.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.length,e[34]=v):v=e[34];let b;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(b=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=b):b=e[39];let S;return e[40]!==f||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:f,children:[p,b]}),e[40]=f,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function ad(t){const e=V.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=N=>{const y=N.target.files?.[0];if(!y)return;if(y.size>2097152){me.error("Image must be smaller than 2MB"),N.target.value="";return}const k=new FileReader;k.onerror=()=>{me.error("Failed to read image file"),i.current&&(i.current.value="")},k.onloadend=()=>{k.readyState===FileReader.DONE&&k.result&&s(k.result),i.current&&(i.current.value="")},k.readAsDataURL(y)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=A.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const N=a.trim();N&&(s(N),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let d;e[5]!==n?(d=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=d):d=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=o.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:[o.jsx(Jl,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=m):m=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=N=>l(N.target.value),e[10]=f):f=e[10];let p;e[11]!==c?(p=N=>{N.key==="Enter"&&(N.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(fs,{value:a,onChange:f,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const b=!v;let S;e[18]!==c||e[19]!==b?(S=o.jsx(se,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let w;return e[24]!==x||e[25]!==d?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,m,_,x]}),e[24]=x,e[25]=d,e[26]=w):w=e[26],w}function ld(t){const e=V.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=ki(s);if(n.type==="icon"){const a=Ni(n.name);if(a){let l;e[2]!==a?(l=o.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=o.jsx(Bc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function cd(t){const e=V.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=ki(s),e[0]=s,e[1]=d):d=e[1];const u=d,m=u.type==="icon"?u.name:null;let _,f,p,g,v,b,S,x,w,N,y,k,j,M,R;if(e[2]!==r||e[3]!==m||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=Jr();g=h.trim()?B.filter(K=>{const G=h.toLowerCase();return ar(K).includes(G)||K.toLowerCase().includes(G)}):B,p=Us,v=n?!1:a,b=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let $;e[24]!==r||e[25]!==O?($=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=$):$=e[26];let W;e[27]!==s?(W=o.jsx(ld,{value:s}),e[27]=s,e[28]=W):W=e[28],e[29]!==n||e[30]!==$||e[31]!==W?(S=o.jsx(Hs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:$,children:W})}),e[29]=n,e[30]=$,e[31]=W,e[32]=S):S=e[32],f=Ws,j="start",M="w-64 p-0",R=hd,y="flex flex-col";let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(Ca,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=I):I=e[33];let F;e[34]===Symbol.for("react.memo_cache_sentinel")?(F=K=>c(K.target.value),e[34]=F):F=e[34],e[35]!==h?(k=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[I,o.jsx(fs,{value:h,onChange:F,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=k):k=e[36],_=wa,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let U;e[37]!==m||e[38]!==i?(U=K=>{const G=Ni(K);return G?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:ar(K),children:o.jsx(G,{size:16})},K):null},e[37]=m,e[38]=i,e[39]=U):U=e[39],w=g.map(U),e[2]=r,e[3]=m,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=f,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=w,e[18]=N,e[19]=y,e[20]=k,e[21]=j,e[22]=M,e[23]=R}else _=e[9],f=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],w=e[17],N=e[18],y=e[19],k=e[20],j=e[21],M=e[22],R=e[23];let T;e[40]!==x||e[41]!==w?(T=o.jsx("div",{className:x,children:w}),e[40]=x,e[41]=w,e[42]=T):T=e[42];let C;e[43]!==g.length?(C=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=C):C=e[44];let D;e[45]!==_||e[46]!==T||e[47]!==C||e[48]!==N?(D=o.jsxs(_,{className:N,children:[T,C]}),e[45]=_,e[46]=T,e[47]=C,e[48]=N,e[49]=D):D=e[49];let E;e[50]!==D||e[51]!==y||e[52]!==k?(E=o.jsxs("div",{className:y,children:[k,D]}),e[50]=D,e[51]=y,e[52]=k,e[53]=E):E=e[53];let L;e[54]!==f||e[55]!==E||e[56]!==j||e[57]!==M||e[58]!==R?(L=o.jsx(f,{align:j,className:M,onOpenAutoFocus:R,children:E}),e[54]=f,e[55]=E,e[56]=j,e[57]=M,e[58]=R,e[59]=L):L=e[59];let z;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==L?(z=o.jsxs(p,{open:v,onOpenChange:b,children:[S,L]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=L,e[65]=z):z=e[65],z}function hd(t){return t.preventDefault()}function ai(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Me,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Fi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(Dl,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.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 dd(t){const e=V.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=te("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.tags?(d=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];let m;e[10]!==s.description?(m=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=m):m=e[11];let _;e[12]!==u||e[13]!==m?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,m]}),e[12]=u,e[13]=m,e[14]=_):_=e[14];let f;e[15]!==n||e[16]!==i||e[17]!==r?(f=o.jsx(rh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=f):f=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==f?(p=o.jsxs("label",{className:h,children:[_,f]}),e[19]=h,e[20]=_,e[21]=f,e[22]=p):p=e[22],p}function rn(t){const e=V.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const u=s.map(ud);if(s.length===0){let m;e[8]!==n?(m=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=m):m=e[9],c=m;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(m=>o.jsx(dd,{item:m,isSelected:i===null||i?.includes(m.id),onToggle:()=>r(m.id,u),disabled:a},m.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[10]!==l||e[11]!==h?(d=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function ud(t){return t.id}function fd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=kc(c);let u;e[5]!==d.tools?(u=d.tools.map(md),e[5]=d.tools,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function md(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(Jc,{annotations:t.annotations,_meta:t._meta})}}function _d(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=Yc(c);let u;e[5]!==d.resources?(u=d.resources.map(pd),e[5]=d.resources,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function pd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function gd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=nh(c);let u;e[5]!==d.prompts?(u=d.prompts.map(vd),e[5]=d.prompts,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function vd(t){return{id:t.name,name:t.name,description:t.description}}function xd(t){const e=V.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:m}=t,_=n[r],f=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?d(r):u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=d,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(ds,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let x;e[13]!==b||e[14]!==S?(x=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=x):x=e[15];let w;e[16]!==v||e[17]!==x?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let y;e[20]!==m?(y=z=>m(z),e[20]=m,e[21]=y):y=e[21];let k;e[22]!==i||e[23]!==y?(k=o.jsx(ih,{tabs:N,activeTab:i,onTabChange:y}),e[22]=i,e[23]=y,e[24]=k):k=e[24];const j=f?"Deselect all":"Select all";let M;e[25]!==g||e[26]!==j?(M=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:j}),e[25]=g,e[26]=j,e[27]=M):M=e[27];let R;e[28]!==M||e[29]!==k?(R=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[k,M]}),e[28]=M,e[29]=k,e[30]=R):R=e[30];let T;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(T=i==="tools"&&o.jsx(Qt,{fallback:Fi("Tools not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(fd,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(z,B)=>a(r,z,B)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=T):T=e[35];let C;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(C=i==="resources"&&o.jsx(Qt,{fallback:Fi("Resources not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(_d,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(z,B)=>l(r,z,B)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=C):C=e[40];let D;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(D=i==="prompts"&&o.jsx(Qt,{fallback:Fi("Prompts not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(gd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(z,B)=>h(r,z,B)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=D):D=e[45];let E;e[46]!==T||e[47]!==C||e[48]!==D?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,C,D]}),e[46]=T,e[47]=C,e[48]=D,e[49]=E):E=e[49];let L;return e[50]!==R||e[51]!==E||e[52]!==w?(L=o.jsxs(o.Fragment,{children:[w,R,E]}),e[50]=R,e[51]=E,e[52]=w,e[53]=L):L=e[53],L}function bd(t){const e=V.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=ha(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(vc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.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]=d):d=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&o.jsx(se,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let m;return e[7]!==u?(m=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,d,u]}),e[7]=u,e[8]=m):m=e[8],m}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Sd(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 Pn(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function yd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function wd(t){const e=V.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,d]=A.useReducer(yd,h),u=Qr(r??"");let m;e[1]!==a?(m=a??[],e[1]=a,e[2]=m):m=e[2];let _;e[3]!==m?(_=Sd(m),e[3]=m,e[4]=_):_=e[4];const f=_;let p;e[5]!==n||e[6]!==f?(p=(I,F,U,K)=>{const G=f[I]?.[F];let P;G===null?P=K.filter(Y=>Y!==U):G?.includes(U)?P=G.filter(Y=>Y!==U):(P=[...G??[],U],P.length===K.length&&(P=null));const Z={...f};Z[I]?Z[I]={...Z[I]}:Z[I]={tools:null,resources:null,prompts:null},Z[I][F]=P,n.setValue("connections",Pn(Z),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=f,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==f?(v=(I,F)=>{const K=f[I]?.[F]===null?[]:null,G={...f};G[I]?G[I]={...G[I]}:G[I]={tools:null,resources:null,prompts:null},G[I][F]=K,n.setValue("connections",Pn(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=f,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(I,F,U)=>g(I,"tools",F,U),e[11]=g,e[12]=S):S=e[12];const x=S;let w;e[13]!==g?(w=(I,F,U)=>g(I,"resources",F,U),e[13]=g,e[14]=w):w=e[14];const N=w;let y;e[15]!==g?(y=(I,F,U)=>g(I,"prompts",F,U),e[15]=g,e[16]=y):y=e[16];const k=y;let j;e[17]!==b?(j=I=>b(I,"tools"),e[17]=b,e[18]=j):j=e[18];const M=j;let R;e[19]!==b?(R=I=>b(I,"resources"),e[19]=b,e[20]=R):R=e[20];const T=R;let C;e[21]!==b?(C=I=>b(I,"prompts"),e[21]=b,e[22]=C):C=e[22];const D=C;if(!r||!u)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ai,{}),e[23]=E):E=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=I=>d({type:"SET_ACTIVE_TAB",payload:I}),e[24]=L):L=e[24];let z;e[25]!==u||e[26]!==c.activeTab||e[27]!==f||e[28]!==r||e[29]!==D||e[30]!==T||e[31]!==M||e[32]!==k||e[33]!==N||e[34]!==x?(z=o.jsx(xd,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:f,toggleTool:x,toggleResource:N,togglePrompt:k,toggleAllTools:M,toggleAllResources:T,toggleAllPrompts:D,onTabChange:L},r),e[25]=u,e[26]=c.activeTab,e[27]=f,e[28]=r,e[29]=D,e[30]=T,e[31]=M,e[32]=k,e[33]=N,e[34]=x,e[35]=z):z=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==z?(B=o.jsx(A.Suspense,{fallback:E,children:o.jsx(bd,{connectionId:r,onAuthenticate:l,children:z})}),e[36]=l,e[37]=r,e[38]=z,e[39]=B):B=e[39];let O;e[40]!==i?(O=o.jsx(Qc,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(se,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let $;e[42]!==B||e[43]!==O?($=o.jsxs(en,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,O]}),e[42]=B,e[43]=O,e[44]=$):$=e[44];let W;return e[45]!==i||e[46]!==s||e[47]!==$?(W=o.jsx(tn,{open:s,onOpenChange:i,children:$}),e[45]=i,e[46]=s,e[47]=$,e[48]=W):W=e[48],W}const Hi={tools:null,resources:null,prompts:null},Cd=Rl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function kd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Nd(t){const e=V.c(11),{url:s,agentId:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Se("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),me.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Ei,{size:20,className:"text-green-600"}):o.jsx(Ci,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==h||e[9]!==d?(u=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,d]}),e[7]=l,e[8]=h,e[9]=d,e[10]=u):u=e[10],u}function jd(t){const e=V.c(9),{url:s,serverName:i,agentId:r,organizationId:n}=t;let a;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(a=()=>{Se("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=da(i),_=kd(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor","x-org-id":n}},null,2)),f=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(_)}`;window.open(f,"_blank"),me.success("Opening Cursor...")},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let h,c;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=o.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%)"}}),c=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[5]=h,e[6]=c):(h=e[5],c=e[6]);let d;return e[7]!==l?(d=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,c]}),e[7]=l,e[8]=d):d=e[8],d}function Ed(t){const e=V.c(13),{url:s,serverName:i,agentId:r,organizationId:n}=t,[a,l]=A.useState(!1);let h;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(h=async()=>{Se("agent_connect_action",{agent_id:r,action:"install_claude_code"});const f=da(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code","x-org-id":n}},null,2),v=`claude mcp add-json "${f}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),me.success("Claude Code command copied to clipboard"),setTimeout(()=>l(!1),2e3)},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=h):h=e[4];const c=h;let d;e[5]!==a?(d=a?o.jsx(Ei,{size:20,className:"text-green-600"}):o.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[5]=a,e[6]=d):d=e[6];const u=a?"Copied!":"Install on Claude Code";let m;e[7]!==u?(m=o.jsx("span",{className:"text-xs font-medium",children:u}),e[7]=u,e[8]=m):m=e[8];let _;return e[9]!==c||e[10]!==d||e[11]!==m?(_=o.jsxs(se,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,m]}),e[9]=c,e[10]=d,e[11]=m,e[12]=_):_=e[12],_}function Td({virtualMcp:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),[i,r]=A.useState(null),[n,a]=A.useState(!1),[l,h]=A.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,u=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,m=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),Se("agent_typegen_key_generated",{agent_id:c})}catch{Se("agent_typegen_key_failed",{agent_id:c}),me.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{Se("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),me.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:n,children:[n?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(sh,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.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."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Dd,{apiKey:i,agentId:c})]})}function Dd(t){const e=V.c(21),{apiKey:s,agentId:i}=t,[r,n]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
3
- ${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{Se("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=d):d=e[3];const u=d,m=!s;let _;e[4]!==m?(_=te({"opacity-50":m}),e[4]=m,e[5]=_):_=e[5];let f;e[6]!==l||e[7]!==_?(f=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=f):f=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==f?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[f,p,g]}),e[11]=f,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==u||e[16]!==b?(S=o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,e[16]=b,e[17]=S):S=e[17];let x;return e[18]!==v||e[19]!==S?(x=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=x):x=e[20],x}function Rd(t){const e=V.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(A.Suspense,{fallback:i,children:o.jsx(Td,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Md(t){const e=V.c(38),{open:s,onOpenChange:i,virtualMcp:r}=t,n=`/mcp/virtual-mcp/${r.id}`;let a;e[0]!==n?(a=new URL(n,window.location.origin),e[0]=n,e[1]=a):a=e[1];const l=a;let h;e[2]!==r.id||e[3]!==r.title?(h=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=h):h=e[4];const c=h,d=aa();let u;e[5]!==r.id||e[6]!==l.href?(u=o.jsx(Nd,{url:l.href,agentId:r.id}),e[5]=r.id,e[6]=l.href,e[7]=u):u=e[7];let m,_;e[8]!==c||e[9]!==r.id||e[10]!==r.organization_id||e[11]!==l.href?(m=o.jsx(jd,{url:l.href,serverName:c,agentId:r.id,organizationId:r.organization_id}),_=o.jsx(Ed,{url:l.href,serverName:c,agentId:r.id,organizationId:r.organization_id}),e[8]=c,e[9]=r.id,e[10]=r.organization_id,e[11]=l.href,e[12]=m,e[13]=_):(m=e[12],_=e[13]);let f;e[14]!==u||e[15]!==m||e[16]!==_?(f=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[u,m,_]})}),e[14]=u,e[15]=m,e[16]=_,e[17]=f):f=e[17];let p;e[18]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("div",{className:"border-t border-border"}),e[18]=p):p=e[18];let g;e[19]!==r?(g=o.jsx(Rd,{virtualMcp:r}),e[19]=r,e[20]=g):g=e[20];let v;e[21]!==f||e[22]!==g?(v=o.jsxs("div",{className:"flex flex-col gap-6",children:[f,p,g]}),e[21]=f,e[22]=g,e[23]=v):v=e[23];const b=v;if(d){let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(lh,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[24]=N):N=e[24];let y;e[25]!==b?(y=o.jsx(ch,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[N,b]})}),e[25]=b,e[26]=y):y=e[26];let k;return e[27]!==i||e[28]!==s||e[29]!==y?(k=o.jsx(hh,{open:s,onOpenChange:i,children:y}),e[27]=i,e[28]=s,e[29]=y,e[30]=k):k=e[30],k}let S;e[31]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ba,{children:o.jsx(Sa,{children:"Connect"})}),e[31]=S):S=e[31];let x;e[32]!==b?(x=o.jsxs(en,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,b]}),e[32]=b,e[33]=x):x=e[33];let w;return e[34]!==i||e[35]!==s||e[36]!==x?(w=o.jsx(tn,{open:s,onOpenChange:i,children:x}),e[34]=i,e[35]=s,e[36]=x,e[37]=w):w=e[37],w}function Id(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 Bd(t){const e=V.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=Qr(s),{org:d}=ye();if(!c)return null;let u;e[0]!==c?(u=Zc(c),e[0]=c,e[1]=u):u=e[1];const m=u;let _;e[2]!==s?(_=o.jsx(Od,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let f;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==d.slug||e[16]!==m||e[17]!==i?(f=o.jsx(Ld,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:m,orgSlug:d.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=d.slug,e[16]=m,e[17]=i,e[18]=f):f=e[18];let p;return e[19]!==_||e[20]!==f?(p=o.jsx(A.Suspense,{fallback:_,children:f}),e[19]=_,e[20]=f,e[21]=p):p=e[21],p}const Ln="__new_instance__";async function Ad(t,e){const s=t?.idToken??null;if(s){const r=On(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 n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return On(e)}function On(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 Pd(t){const e=V.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,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 h=ji(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Ln?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(ts,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(ss,{})}),e[6]=d):d=e[6];let u;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(Rt,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],u=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=u}else u=e[10];let m;e[14]!==a?(m=a&&o.jsx(Rt,{value:Ln,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=m):m=e[15];let _;e[16]!==u||e[17]!==m?(_=o.jsxs(is,{children:[u,m]}),e[16]=u,e[17]=m,e[18]=_):_=e[18];let f;return e[19]!==i||e[20]!==c||e[21]!==_?(f=o.jsxs(es,{value:i,onValueChange:c,children:[d,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=f):f=e[22],f}function Ld(t){const e=V.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:m,onAuthenticate:_,onSwitchInstance:f,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=ha(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==x?(w=te("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=w):w=e[3];let N;e[4]!==h||e[5]!==l?(N={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=N):N=e[6];let y;e[7]!==n||e[8]!==i?(y=o.jsx(ds,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=y):y=e[9];let k;e[10]!==i?(k=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=k):k=e[11];let j;e[12]!==r||e[13]!==S?(j=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=j):j=e[14];let M;e[15]!==k||e[16]!==j?(M=o.jsxs("div",{className:"flex-1 min-w-0",children:[k,j]}),e[15]=k,e[16]=j,e[17]=M):M=e[17];let R;e[18]!==s||e[19]!==S||e[20]!==_?(R=S?o.jsx(se,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:K=>{K.preventDefault(),K.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.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:o.jsx(th,{size:16})})}),o.jsx(qe,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=R):R=e[21];let T;e[22]!==N||e[23]!==y||e[24]!==M||e[25]!==R?(T=o.jsxs(Bl,{to:"/$org/settings/connections/$appSlug",params:N,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[y,M,R]}),e[22]=N,e[23]=y,e[24]=M,e[25]=R,e[26]=T):T=e[26];let C;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==f||e[31]!==d?(C=c&&o.jsx(Pd,{appName:c,connectionId:s,usedConnectionIds:d,onSwitchInstance:f,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=f,e[31]=d,e[32]=C):C=e[32];let D;e[33]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(bc,{size:13}),e[33]=D):D=e[33];let E;e[34]!==u?(E=o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:D})}),e[34]=u,e[35]=E):E=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsx(qe,{side:"bottom",children:"Configure resources"}),e[36]=L):L=e[36];let z;e[37]!==E?(z=o.jsxs(Ve,{delayDuration:0,children:[E,L]}),e[37]=E,e[38]=z):z=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=o.jsx(ls,{size:13}),e[39]=B):B=e[39];let O;e[40]!==m?(O=o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:m,"aria-label":"Remove connection",children:B})}),e[40]=m,e[41]=O):O=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx(qe,{side:"bottom",children:"Remove"}),e[42]=$):$=e[42];let W;e[43]!==O?(W=o.jsxs(Ve,{delayDuration:0,children:[O,$]}),e[43]=O,e[44]=W):W=e[44];let I;e[45]!==z||e[46]!==W?(I=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[z,W]}),e[45]=z,e[46]=W,e[47]=I):I=e[47];let F;e[48]!==C||e[49]!==I?(F=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[C,I]}),e[48]=C,e[49]=I,e[50]=F):F=e[50];let U;return e[51]!==T||e[52]!==F||e[53]!==w?(U=o.jsxs("div",{className:w,children:[T,F]}),e[51]=T,e[52]=F,e[53]=w,e[54]=U):U=e[54],U}function Od(t){const e=V.c(17),{connection_id:s}=t,i=Qr(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(Da,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(ds,{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 n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.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]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let d;return e[15]!==h?(d=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function Da(){const t=V.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.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=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.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=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function zd({virtualMcpId:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),i=Ht(),r=gt(t),n=(r?.connections??[]).map(O=>O.connection_id).sort(),{data:a}=Wo({queryKey:As.projectConnectionDetails(t,n),enabled:n.length>0,queryFn:async()=>await Promise.all(n.map(async $=>{try{const W=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:$}}),{item:I}=Li(W),F=(I?.tools??[]).filter(U=>!!Xc(U._meta)).map(U=>({name:U.name,description:U.description}));return{fetchOk:!0,id:$,title:I?.title??$,icon:I?.icon??null,uiTools:F}}catch{return{fetchOk:!1,id:$,title:$,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(O=>O.uiTools.length>0),h=new Set(ic),c=r?.metadata?.ui,d=c?.pinnedViews??[],u=c?.layout?.defaultMainView??null,m=c?.layout?.chatDefaultOpen??!1,_=!u||u.type==="chat"?"chat":u.type==="instructions"||u.type==="connections"||u.type==="layout"?"settings":h.has(u.type)?u.type:`${u.type}:${u.id??""}:${u.toolName??""}`,[f,p]=A.useState(d),[g,v]=A.useState(_),[b,S]=A.useState(m),[x,w]=A.useState(!1),N=O=>{const[$,W,I]=O.split(":");return $?$==="chat"?{type:$}:h.has($)?{type:$}:$==="ext-apps"&&W?{type:"ext-apps",id:W,toolName:I||void 0}:null:null},y=A.useRef(!1);if(a&&a.length>0&&!y.current){y.current=!0;const O=new Set((a??[]).filter(I=>I.fetchOk).map(I=>I.id)),$=new Set(l.flatMap(I=>I.uiTools.map(F=>`${I.id}:${F.name}`))),W=d.filter(I=>!O.has(I.connectionId)||$.has(`${I.connectionId}:${I.toolName}`));if(W.length!==d.length){p(W);let I=g;u?.type==="ext-apps"&&!W.some(F=>F.connectionId===u.id&&F.toolName===u.toolName)&&(I="chat",v(I)),s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:W,layout:{defaultMainView:N(I),chatDefaultOpen:b}}}).then(F=>{Li(F),i.invalidateQueries({predicate:U=>Array.isArray(U.queryKey)&&U.queryKey.includes("collection")&&U.queryKey.includes("VIRTUAL_MCP")})}).catch(()=>{p(d),v(_)})}}const k=(O,$,W)=>{w(!0),(async()=>{try{const F=await s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:O,layout:{defaultMainView:N($),chatDefaultOpen:W??b}}});Li(F),i.invalidateQueries({predicate:U=>Array.isArray(U.queryKey)&&U.queryKey.includes("collection")&&U.queryKey.includes("VIRTUAL_MCP")}),me.success("Layout updated")}catch(F){me.error("Failed to update layout: "+(F instanceof Error?F.message:"Unknown error"))}finally{w(!1)}})()},j=(O,$)=>{const W=f.some(U=>U.connectionId===O&&U.toolName===$);let I,F=g;if(W){I=f.filter(K=>!(K.connectionId===O&&K.toolName===$));const U=`ext-apps:${O}:${$}`;g===U&&(F="chat",v(F))}else I=[...f,{connectionId:O,toolName:$,label:yn($),icon:null}];p(I),k(I,F)},M=(O,$,W)=>{p(I=>I.map(F=>F.connectionId===O&&F.toolName===$?{...F,label:W}:F))},R=()=>{k(f,g)},T=(O,$,W)=>{p(F=>F.map(U=>U.connectionId===O&&U.toolName===$?{...U,icon:W}:U));const I=f.map(F=>F.connectionId===O&&F.toolName===$?{...F,icon:W}:F);k(I,g)},C=O=>{v(O),k(f,O)},D=n.length===0,E=a&&l.length===0,L=!!Bt(r),z=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];L&&(z.push({value:"env",label:"Terminal"}),z.push({value:"preview",label:"Preview"}));for(const O of f)z.push({value:`ext-apps:${O.connectionId}:${O.toolName}`,label:O.label||O.toolName});const B=l.length>0||D||E;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(eh,{className:"p-6 gap-5",children:[o.jsxs(Tn,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(es,{value:g,onValueChange:C,children:[o.jsx(ts,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(ss,{})}),o.jsx(is,{children:z.map(O=>o.jsx(Rt,{value:O.value,className:"capitalize",children:O.label},O.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(cr,{checked:g==="chat"?!0:b,disabled:g==="chat"||x,onCheckedChange:O=>{S(O),k(f,g,O)}})})}),g==="chat"&&o.jsx(qe,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),B&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Tn,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),D&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),E&&!D&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:l.map((O,$)=>o.jsxs("div",{children:[$>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(ds,{icon:O.icon,name:O.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:O.title})]}),o.jsx("div",{className:"space-y-1.5",children:O.uiTools.map(W=>{const I=f.some(U=>U.connectionId===O.id&&U.toolName===W.name),F=f.find(U=>U.connectionId===O.id&&U.toolName===W.name);return o.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",I?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(cd,{value:F?.icon??null,onChange:U=>T(O.id,W.name,U),disabled:!I||x}),o.jsx(fs,{value:I&&F?F.label:yn(W.name),onChange:U=>M(O.id,W.name,U.target.value),onBlur:R,className:"h-7 text-sm w-40",disabled:!I||x,readOnly:!I})]}),o.jsx(cr,{checked:I,onCheckedChange:()=>j(O.id,W.name),disabled:x})]},W.name)})})]},O.id))})]})]})]})]})}function $d({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ye(),i=Ul(),r=qc(),n=Ht(),a=Fe({connectionId:It,orgId:s.id}),l=Vo({resolver:Ml(Cd),defaultValues:t}),h=l.watch("connections"),c=!!Bt(t),[d,u]=A.useReducer(Id,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[m,_]=A.useState(!1),{createTaskWithMessage:f}=lt(),{setChatMode:p}=yi(),{createNewTask:g}=Zr(),v=()=>{const P=l.getValues("metadata.instructions");P?.trim()&&(M(),Se("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:P.length}),p("plan"),f({virtualMcpId:Xo(s.id),message:{parts:[{type:"text",text:`/writing-prompts ${t.id}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DufFnF1s.js","assets/index-DRnP8Xhy.js","assets/index-B4J1yAvl.css","assets/pair-rqe3skqp.js","assets/agent-icon-DnE1m294.js","assets/AlertCircle-CtSiN7Dh.js","assets/Tool01-73PH4njb.js","assets/XClose-BpjQA_dF.js","assets/RefreshCcw01-DV-_PfmV.js","assets/ArrowNarrowLeft-CjMD5YtT.js","assets/XCircle-BKeTm8Ww.js","assets/ArrowUpRight-VGEco3p8.js","assets/ZapSquare-BL-_ZEqM.js","assets/Users03-CtQ_adLe.js","assets/CheckCircle-BOjQcSoZ.js","assets/ChevronDown-B21GyFLP.js","assets/ChevronRight-C7fFXCXU.js","assets/ChevronUp-DLJe-Ifh.js","assets/DotsVertical-_1yE4PFi.js","assets/Container-DVwtR0PY.js","assets/Star01-DupDdRAe.js","assets/Palette-xIvgAE_U.js","assets/SearchMd-BgpZuBQH.js","assets/index-D1LVHcIe.js","assets/tooltip-CUw8WpYG.js","assets/X-DavTUkoo.js","assets/LinkExternal01-BeNjIA73.js","assets/Lock01-y9D26Lk9.js","assets/Sun-B1MYWGMj.js","assets/Play-esUCyQh5.js","assets/Plus-8zlfW9Nb.js","assets/Settings02-B2DHZxlV.js","assets/Shield01-CewVSi37.js","assets/Trash01-_-2EAUWH.js","assets/User01-DLnrd0WJ.js","assets/Zap-DT_tBFfJ.js","assets/index-COQkJrV6.js","assets/use-copy-Czy0YFNn.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BSlhJimL.js","assets/content-blocks-o63cs2vh.js","assets/types-slR7lXH6.js","assets/constants-DZ5y4NEu.js","assets/chat-context-C2vjARhO.js","assets/use-virtual-mcp-Dkco3wCF.js","assets/use-collections-CDG0ivO9.js","assets/use-ai-providers-DespFg1Y.js","assets/use-decopilot-events-DkzJQYGR.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-BMtiaufW.js","assets/use-organization-settings-C516uAxZ.js","assets/shell-layout-BK74oWLU.js","assets/required-auth-layout-CKQlCfyf.js","assets/use-org-sso-CXTYwYuw.js","assets/integration-icon-Cz-seBmA.js","assets/use-mcp-tools-nd8RTEJZ.js"])))=>i.map(i=>d[i]);
2
+ import{o as Ht,r as A,p as jl,q as El,e as V,s as ye,K as As,n as Wo,a as Uo,c as te,j as o,l as Me,B as se,E as Qt,b as Si,v as ni,f as Mt,d as Yr,w as Tl,x as me,y as Rl,V as Dl,t as Se,z as Vo,C as Ml,D as Xt,F as Il,G as vn,L as Bl,H as Ai,I as Js,J as ct,M as Ko,P as Al,_ as Pl,Q as qo,R as Go,T as Ll,g as Ol}from"./index-DRnP8Xhy.js";import{C as je,u as zl,w as $l,A as Fl,T as Hl,a as Wl}from"./index-DHKldY3y.js";import{I as ds}from"./integration-icon-Cz-seBmA.js";import{S as It,u as Fe,g as Yo,a as Xo}from"./constants-DZ5y4NEu.js";import{u as gt,a as Ul}from"./use-virtual-mcp-Dkco3wCF.js";import{a as Vl}from"./Users03-CtQ_adLe.js";import{u as Jo,a as lt,b as yi,c as wi,t as Kl,d as xn}from"./chat-context-C2vjARhO.js";import{i as as}from"./AlertCircle-CtSiN7Dh.js";import{i as ql}from"./CheckCircle-BOjQcSoZ.js";import{n as bn,a as Gl}from"./ZapSquare-BL-_ZEqM.js";import{i as Yl,a as Xl,b as Jl,c as Ci,d as Zl}from"./XCircle-BKeTm8Ww.js";import{s as ls,i as Ql}from"./XClose-BpjQA_dF.js";import{c as ec,r as tc,p as Zo,f as Sn,a as sc,F as ic,t as yn,M as Xr,G as Qo,L as rc,i as nc,b as oc,d as ac,e as lc}from"./pair-rqe3skqp.js";import{C as cc,a as wn,b as Cn,c as hc,d as dc,e as uc,f as fc}from"./command-CsVFknP_.js";import{P as Hs,a as Ws,b as Us}from"./popover-B6ijC2Zf.js";import{i as Rs,a as mi,b as mc,c as _c,p as ki,g as Ni,d as Jr,e as ea,h as ar,f as Pi,j as kn,A as Nn,k as ta,l as pc,m as gc,n as vc,t as xc,o as bc,q as sa,r as ia,s as ra,u as na,v as jn,w as Sc,x as Ds,y as yc,z as wc,B as Cc,C as oa}from"./agent-icon-DnE1m294.js";import{u as us,a as kc}from"./use-mcp-tools-nd8RTEJZ.js";import{u as Nc,a as jc}from"./use-ai-providers-DespFg1Y.js";import{g as Bt,c as En,u as Ec,b as lr,d as Tc,e as Rc,f as Dc,T as Mc}from"./index-BJz9Oj-t.js";import{u as Zr,i as Ic}from"./shell-layout-BK74oWLU.js";import{i as Bc,P as at,u as Ac,c as Pc,d as Lc,e as Oc}from"./index-D1LVHcIe.js";import{u as aa,T as Ve,a as Ke,b as qe,c as zc}from"./tooltip-CUw8WpYG.js";import{u as $c}from"./use-status-sounds-COJng9ez.js";import{E as Ps}from"./empty-state-DbgILpoj.js";import{A as Fc,a as Hc,b as Wc,c as Uc,R as la,d as Vc,e as Kc}from"./accordion-pRq2Jalt.js";import{u as ji,a as Qr,b as qc}from"./use-connection-DDedfw7l.js";import{g as Gc}from"./constants-BwurOShK.js";import{u as Yc,g as Xc}from"./types-slR7lXH6.js";import{U as ca}from"./user-BCVAIUhB.js";import{T as Jc,u as ha}from"./tools-list-CwM3RxlF.js";import{u as Li}from"./unwrap-tool-result-BYXdCQMg.js";import{s as da,g as Zc}from"./connection-slug-eyAPH6o3.js";import{A as ua,a as fa,b as ma,c as _a,d as pa,e as ga,f as va,g as xa}from"./alert-dialog-DvcLf48w.js";import{D as Qc,a as en,b as tn,c as ba,d as Sa}from"./dialog-BSlhJimL.js";import{C as eh,a as Tn}from"./card-Hve9iIpZ.js";import{I as fs}from"./input-liZY-axz.js";import{L as Ms}from"./label-CrXFAdsO.js";import{S as es,a as ts,b as ss,c as is,d as Dt}from"./select-DwQCWni4.js";import{S as cr}from"./switch-BwYbkaPM.js";import{T as Rn}from"./textarea-CkxfQbxI.js";import{i as oi}from"./Play-esUCyQh5.js";import{s as cs}from"./Plus-8zlfW9Nb.js";import{a as th}from"./Settings02-B2DHZxlV.js";import{t as ya}from"./Tool01-73PH4njb.js";import{s as hr}from"./Trash01-_-2EAUWH.js";import{S as wa}from"./scroll-area-D_0eTXQI.js";import{i as Ca,a as sh}from"./SearchMd-BgpZuBQH.js";import{C as ih}from"./collection-tabs-Bcs-_tfj.js";import{C as rh}from"./checkbox-DmWLCJJH.js";import{u as nh,T as Oi,a as oh,b as ah,c as zi}from"./tabs-CGg7lV45.js";import{D as lh,a as ch,b as hh}from"./drawer-DwurUbp0.js";import{i as Ei,t as dr}from"./ChevronDown-B21GyFLP.js";import{n as Wt}from"./LinkExternal01-BeNjIA73.js";import{S as dh}from"./index-COQkJrV6.js";import{D as rs,a as ns,b as os,c as yt,d as uh,e as fh,f as mh}from"./dropdown-menu-Dn3K1Gpo.js";import{i as ka}from"./RefreshCcw01-DV-_PfmV.js";import{V as _h}from"./view-mode-toggle-Bbj9P-zr.js";import{G as ph}from"./lean-canvas-recruit-modal-DZ6knxg9.js";import{M as gh}from"./select-model-CSzGroxj.js";import{u as Vs,a as vh,b as xh,c as bh,A as Sh,d as yh}from"./automation-list-row-DsEcFwqj.js";import{i as Ls}from"./Zap-DT_tBFfJ.js";import{S as wh}from"./search-input-CbBz2_I7.js";import"./use-navigate-to-agent-Dj0boPYr.js";import"./use-tasks-BMtiaufW.js";import"./use-collections-CDG0ivO9.js";import"./collection-search-D_mJKf_N.js";import"./form-DTt4fIHo.js";import"./Star01-DupDdRAe.js";import"./Lock01-y9D26Lk9.js";import"./X-DavTUkoo.js";import"./toggle-group-C5VhmQig.js";import"./index-BTM4S0x-.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-D6a8kmGH.js";import"./connection-card-aTu5Xl4N.js";import"./use-registry-connections-BH65PVKK.js";import"./use-organization-settings-C516uAxZ.js";import"./useInfiniteQuery-mbgOLEDd.js";import"./infiniteQueryObserver-BFZ15R1_.js";import"./extract-connection-data-Bp5NDOhQ.js";import"./Container-DVwtR0PY.js";import"./connection-form-helpers-BEHWki2e.js";import"./use-infinite-scroll-qjXoMT8U.js";import"./useSuspenseInfiniteQuery-DZGLPMRe.js";import"./badge-BnwDLyJj.js";import"./ChevronRight-C7fFXCXU.js";import"./use-decopilot-events-DkzJQYGR.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-Czy0YFNn.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-B1MYWGMj.js";import"./index-BZwRn_mX.js";import"./ArrowNarrowLeft-CjMD5YtT.js";import"./ArrowUpRight-VGEco3p8.js";import"./ChevronUp-DLJe-Ifh.js";import"./DotsVertical-_1yE4PFi.js";import"./Palette-xIvgAE_U.js";import"./Shield01-CewVSi37.js";import"./User01-DLnrd0WJ.js";import"./skeleton-DnMJGIDK.js";import"./avatar-B1YFr91G.js";import"./index-D9wcQMm5.js";import"./collection-search-DffILLk0.js";import"./use-create-virtual-mcp-Bhi93QNY.js";import"./task-status-DAgh3LfT.js";import"./required-auth-layout-CKQlCfyf.js";import"./use-org-sso-CXTYwYuw.js";import"./collections-CISD8jzc.js";import"./settings-section-CVNbjkC4.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Ch(t,e){const s=Ht(e);return kh({filters:{...t,status:"pending"}},s).length}function Dn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function kh(t={},e){const s=Ht(e).getMutationCache(),i=A.useRef(t),r=A.useRef(null);return r.current===null&&(r.current=Dn(s,t)),A.useEffect(()=>{i.current=t}),A.useSyncExternalStore(A.useCallback(n=>s.subscribe(()=>{const a=jl(r.current,Dn(s,i.current));r.current!==a&&(r.current=a,El.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Nh(t,e){const s=V.c(39),{org:i,locator:r}=ye();let n;s[0]!==i.id?(n={connectionId:It,orgId:i.id},s[0]=i.id,s[1]=n):n=s[1];const a=Fe(n),l=Ht();let h;s[2]!==t||s[3]!==i.id?(h=As.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=h):h=s[4];let c;s[5]!==a||s[6]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=c):c=s[7];const d=t.length>0;let u;s[8]!==h||s[9]!==c||s[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,retry:!1,refetchOnWindowFocus:!1},s[8]=h,s[9]=c,s[10]=d,s[11]=u):u=s[11];const m=Wo(u);let _;s[12]!==a||s[13]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const y=w.content,k=Array.isArray(y)&&y[0]&&typeof y[0]=="object"?y[0].text??"Create failed":"Create failed";throw new Error(k)}return w.structuredContent.item},s[12]=a,s[13]=e,s[14]=_):_=s[14];let f;s[15]!==r||s[16]!==i.id||s[17]!==m||s[18]!==l?(f=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:As.tasksPrefix(r)}),m.refetch()},s[15]=r,s[16]=i.id,s[17]=m,s[18]=l,s[19]=f):f=s[19];let p;s[20]!==_||s[21]!==f?(p={mutationFn:_,onSuccess:f},s[20]=_,s[21]=f,s[22]=p):p=s[22];const g=Uo(p);let v,b;if(s[23]!==g||s[24]!==t||s[25]!==m.data||s[26]!==m.isSuccess?(v=()=>{t&&(!m.isSuccess||m.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,m.isSuccess,m.data,g],s[23]=g,s[24]=t,s[25]=m.data,s[26]=m.isSuccess,s[27]=v,s[28]=b):(v=s[27],b=s[28]),A.useEffect(v,b),!t){let x;return s[29]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[29]=x):x=s[29],x}if(m.isLoading){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[30]=x):x=s[30],x}if(m.isError){const x=m.error;let w;return s[31]!==x?(w={status:"error",error:x},s[31]=x,s[32]=w):w=s[32],w}if(m.isSuccess&&m.data){let x;return s[33]!==m.data?(x={status:"ready",task:m.data},s[33]=m.data,s[34]=x):x=s[34],x}if(g.isPending||m.isSuccess&&!m.data){let x;return s[35]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[35]=x):x=s[35],x}if(g.isError){let x;return s[36]!==g.error?(x={status:"error",error:g.error},s[36]=g.error,s[37]=x):x=s[37],x}let S;return s[38]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[38]=S):S=s[38],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Mn(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 jh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Eh(t){const e=V.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Th),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.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 Th(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Rh(t){const e=V.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let m;e[6]!==c||e[7]!==d||e[8]!==u?(m=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let f;e[11]!==a?(f=a.toFixed(1),e[11]=a,e[12]=f):f=e[12];let p;e[13]!==f?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",f,"%"]})]}),e[13]=f,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==m?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[m,x]}),e[27]=x,e[28]=m,e[29]=w):w=e[29],w}function Dh(t){const e=V.c(19),{part:s}=t,i=s.input?.agent_id,r=gt(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let d;e[0]!==a||e[1]!==n?(d=o.jsx(ds,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=d):d=e[2];const u=h?"text-destructive":"text-foreground";let m;e[3]!==u?(m=te("shrink-0 font-medium",u),e[3]=u,e[4]=m):m=e[4];let _;e[5]!==n||e[6]!==m?(_=o.jsx("span",{className:m,children:n}),e[5]=n,e[6]=m,e[7]=_):_=e[7];let f;e[8]!==s.input?(f=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=f):f=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Me,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(Yl,{size:12,className:"text-destructive"}):c?o.jsx(as,{size:12,className:"text-warning"}):o.jsx(ql,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==d||e[15]!==_||e[16]!==f||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,_,f,p]}),e[14]=d,e[15]=_,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function Mh(t){const e=V.c(58),{onClose:s,back:i,className:r}=t,[n,a]=A.useState(null),{messages:l}=Jo(),{tasks:h,taskId:c}=lt(),{selectedModel:d,selectedVirtualMcp:u}=yi();let m,_,f,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==d||e[6]!==u?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=Q=>Q.id===c,e[17]=c,e[18]=N):N=e[18];const y=h.find(N),k=ec(l),j=[...l].reverse().find(Fh),M=j?.metadata?.usage,D=j?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,T=M?.contextTokens??M?.totalTokens??0,C=D&&D>0?(T/D*100).toFixed(1):null,R=l;let E;e[19]!==R?(E=R.filter($h).reduce(zh,0),e[19]=R,e[20]=E):E=e[20];const L=E,z=l;let B;e[21]!==z?(B=z.filter(Oh).reduce(Lh,0),e[21]=z,e[22]=B):B=e[22];const O=B,$=Math.max(0,k.totalTokens-L-O),W=l[0],I=l.at(-1),F=W?.metadata?.created_at??y?.created_at,U=I?.metadata?.created_at??y?.updated_at,K=l.filter(Ph),G=l.flatMap(Bh),P=d?.modelId?jh(d.modelId):"—",Z=u?.title??"Decopilot",Y=[{label:"Session",value:y?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:Z},{label:"Model",value:P},{label:"Context Limit",value:D?vs(D):"—"},{label:"Session Tokens (billed)",value:k.totalTokens>0?vs(k.totalTokens):"0"},{label:"Usage",value:C!==null?`${C}%`:"—"},{label:"Input Tokens",value:k.inputTokens>0?vs(k.inputTokens):"0"},{label:"Output Tokens",value:k.outputTokens>0?vs(k.outputTokens):"0"},{label:"Reasoning Tokens",value:k.reasoningTokens>0?vs(k.reasoningTokens):"0"},{label:"Cost",value:k.cost>0?`$${k.cost<.001?k.cost.toFixed(6):k.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Mn(F)},{label:"Last Activity",value:Mn(U)}];if(!y&&K.length===0){let Q;e[23]!==r?(Q=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=Q):Q=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let de;e[26]!==i?(de=i?o.jsx(bn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=de):de=e[27];let ue;e[28]!==s||e[29]!==de?(ue=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:de})]}),e[28]=s,e[29]=de,e[30]=ue):ue=e[30];let we;e[31]===Symbol.for("react.memo_cache_sentinel")?(we=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=we):we=e[31];let Xe;e[32]!==Q||e[33]!==ue?(Xe=o.jsxs("div",{className:Q,children:[ue,we]}),e[32]=Q,e[33]=ue,e[34]=Xe):Xe=e[34],S=Xe;break e}e[35]!==r?(v=te("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=ee):ee=e[37];let ce;e[38]!==i?(ce=i?o.jsx(bn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ce):ce=e[39],e[40]!==s||e[41]!==ce?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[ee,o.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:ce})]}),e[40]=s,e[41]=ce,e[42]=b):b=e[42],m="flex flex-col gap-8 p-6",_=G.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:G.map(Ih)})]}),f=o.jsx(Eh,{items:Y});let ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(ie=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ie):ie=e[43],e[44]!==O||e[45]!==$||e[46]!==L?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ie,o.jsx(Rh,{userTokens:L,assistantTokens:O,otherTokens:$})]}),e[44]=O,e[45]=$,e[46]=L,e[47]=p):p=e[47],g=K.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:K.map(Q=>{const he=Q.metadata?.created_at,de=n?.id===Q.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(de?null:Q),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:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:te("shrink-0 font-medium",Q.role==="user"?"text-chart-1":"text-chart-2"),children:Q.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:Q.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),de&&o.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(Q,null,2)})]},Q.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=d,e[6]=u?.title,e[7]=c,e[8]=h,e[9]=m,e[10]=_,e[11]=f,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else m=e[9],_=e[10],f=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==m||e[49]!==_||e[50]!==f||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:m,children:[_,f,p,g]}),e[48]=m,e[49]=_,e[50]=f,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Ih(t,e){return o.jsx(Dh,{part:t},e)}function Bh(t){return(t.parts??[]).filter(Ah)}function Ah(t){return t.type==="tool-subtask"}function Ph(t){return t.role!=="system"}function Lh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Oh(t){return t.role==="assistant"}function zh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function $h(t){return t.role==="user"}function Fh(t){return t.role==="assistant"&&t.metadata?.usage}const In=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Bn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Hh(){const t=In[Math.floor(Math.random()*In.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Wh(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Uh(t){const e=V.c(25),{orgId:s,userId:i,connectionId:r,vmMap:n,owner:a,repo:l,enabled:h}=t,c=h===void 0?!0:h,d=r??null;let u;e[0]!==s||e[1]!==d?(u={connectionId:d,orgId:s},e[0]=s,e[1]=d,e[2]=u):u=e[2];const m=Fe(u);let _;e[3]!==a||e[4]!==l?(_={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=_):_=e[5];const f=c&&!!r&&!!a&&!!l;let p;e[6]!==m||e[7]!==_||e[8]!==f?(p={client:m,toolName:"list_branches",toolArguments:_,enabled:f,staleTime:3e4,select:Gh},e[6]=m,e[7]=_,e[8]=f,e[9]=p):p=e[9];const{data:g,isLoading:v,isError:b}=us(p);let S,x;e[10]!==i||e[11]!==n?(x=new Set(Object.keys(n?.[i]??{})),S=[...x].sort().map(qh),e[10]=i,e[11]=n,e[12]=S,e[13]=x):(S=e[12],x=e[13]);const w=S;let N;if(e[14]!==g||e[15]!==x){const M=Array.isArray(g)?g:g?.branches??[];let D;e[17]!==x?(D=T=>!x.has(T.name),e[17]=x,e[18]=D):D=e[18],N=M.filter(Kh).filter(D).map(Vh),e[14]=g,e[15]=x,e[16]=N}else N=e[16];const y=N,k=Array.isArray(g)?null:g?.default_branch??null;let j;return e[19]!==k||e[20]!==b||e[21]!==v||e[22]!==y||e[23]!==w?(j={yours:w,others:y,defaultBase:k,isLoading:v,isError:b},e[19]=k,e[20]=b,e[21]=v,e[22]=y,e[23]=w,e[24]=j):j=e[24],j}function Vh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Kh(t){return typeof t.name=="string"}function qh(t){return{name:t,source:"yours"}}function Gh(t){return Wh(t)}function Yh(t){const e=V.c(41),{orgId:s,userId:i,connectionId:r,owner:n,repo:a,vmMap:l,value:h,onChange:c}=t,[d,u]=A.useState(!1);let m;e[0]!==r||e[1]!==d||e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==i||e[6]!==l?(m={orgId:s,userId:i,connectionId:r,vmMap:l,owner:n,repo:a,enabled:d},e[0]=r,e[1]=d,e[2]=s,e[3]=n,e[4]=a,e[5]=i,e[6]=l,e[7]=m):m=e[7];const{yours:_,others:f,isLoading:p,isError:g}=Uh(m);let v;e[8]!==c?(v=E=>{c(E),u(!1)},e[8]=c,e[9]=v):v=e[9];const b=v,S=h??"Select branch…";let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[10]=x):x=e[10];let w;e[11]!==S?(w=o.jsx(Hs,{asChild:!0,children:o.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[x,o.jsx("span",{className:"max-w-[200px] truncate",children:S})]})}),e[11]=S,e[12]=w):w=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(dc,{placeholder:"Search branches…"}),e[13]=N):N=e[13];let y;e[14]!==b?(y=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[N,o.jsx(se,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>b(Hh()),children:"New"})]}),e[14]=b,e[15]=y):y=e[15];let k;e[16]!==g?(k=g&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[16]=g,e[17]=k):k=e[17];let j;e[18]!==g||e[19]!==p||e[20]!==f.length||e[21]!==_.length?(j=!g&&!p&&_.length===0&&f.length===0&&o.jsx(cc,{children:"No branches found."}),e[18]=g,e[19]=p,e[20]=f.length,e[21]=_.length,e[22]=j):j=e[22];let M;e[23]!==b||e[24]!==_?(M=_.length>0&&o.jsx(wn,{heading:"Your branches",children:_.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=b,e[24]=_,e[25]=M):M=e[25];let D;e[26]!==f||e[27]!==b?(D=f.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{}),o.jsx(wn,{heading:"Other branches in repo",children:f.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=f,e[27]=b,e[28]=D):D=e[28];let T;e[29]!==D||e[30]!==k||e[31]!==j||e[32]!==M?(T=o.jsxs(uc,{children:[k,j,M,D]}),e[29]=D,e[30]=k,e[31]=j,e[32]=M,e[33]=T):T=e[33];let C;e[34]!==T||e[35]!==y?(C=o.jsx(Ws,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(fc,{children:[y,T]})}),e[34]=T,e[35]=y,e[36]=C):C=e[36];let R;return e[37]!==d||e[38]!==C||e[39]!==w?(R=o.jsxs(Us,{open:d,onOpenChange:u,children:[w,C]}),e[37]=d,e[38]=C,e[39]=w,e[40]=R):R=e[40],R}function Xh(){const t=V.c(26),{org:e}=ye(),{selectedVirtualMcp:s}=yi(),{data:i}=Si.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=lt();let a;t[0]!==e.id?(a=Yo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=gt(h.id),d=i?.user?.id??"",u=c?.metadata?.githubRepo??null,m=!!u?.connectionId&&!!d;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Vl,{size:32}),t[2]=_):_=t[2];let f;t[3]!==h.icon||t[4]!==h.title?(f=o.jsx(ds,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=f):f=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==u||t[13]!==e.id||t[14]!==n||t[15]!==m||t[16]!==d?(b=m&&o.jsx("div",{className:"mt-2",children:o.jsx(Yh,{orgId:e.id,userId:d,connectionId:u.connectionId,owner:u.owner,repo:u.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=n,t[15]=m,t[16]=d,t[17]=b):b=t[17];let S;t[18]!==f||t[19]!==p||t[20]!==v||t[21]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[f,p,v,b]}),t[18]=f,t[19]=p,t[20]=v,t[21]=b,t[22]=S):S=t[22];let x;t[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[23]=x):x=t[23];let w;return t[24]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[24]=S,t[25]=w):w=t[25],w}function Jh(){const t=V.c(26),{org:e}=ye(),s=Nc(),{isChatEmpty:i}=Jo(),[r,n]=A.useState("chat"),a=zl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!$l(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]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const d=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let u;t[10]!==d?(u=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",d),t[10]=d,t[11]=u):u=t[11];let m;t[12]!==i?(m=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(Xh,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=m):m=t[13];let _;t[14]!==u||t[15]!==m?(_=o.jsx("div",{className:u,children:m}),t[14]=u,t[15]=m,t[16]=_):_=t[16];const f=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==f?(p=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[17]=f,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Mh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Na(){const t=V.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Qt,{fallback:e,children:o.jsx(A.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(Jh,{})})}),t[1]=s):s=t[1],s}async function Zh(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const ja=["VM_START"],Zs=new Map,Qh=t=>`${t.virtualMcpId}::${t.branch??""}`;function sn(t){const e=Ht();return Uo({mutationKey:ja,mutationFn:async s=>{const i=Qh(s),r=Zs.get(i);if(r)return r;const n=(async()=>(await Zh(t,"VM_START",s)).structuredContent)();Zs.set(i,n);try{return await n}finally{Zs.get(i)===n&&Zs.delete(i)}},onSuccess:()=>{ni(e)}})}function Ea(t,e){const s=V.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:ja,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Ch(i)>0}const ed={settings:_c,automations:mc,env:mi,preview:Xl,git:Rs};function An(t){const e=ki(t);if(e.type==="icon"){const s=Ni(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function $i(t){if(t.kind==="system")return{kind:"component",Component:ed[t.tabId]};const e=An(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=An(s.icon);return i||{kind:"fallback"}}function td(t){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),{data:i}=Tl({queryKey:As.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Ta(t){const e=V.c(8),s=Mt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Yr(i),n=gt(t.virtualMcpId),a=td(t.taskId),{currentBranch:l}=lt(),h=n?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],m=a?.expanded_tools??[],_=!!(n&&Bt(n));let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f={includeVirtual:!0},e[1]=f):f=e[1];const p=ji(f),{activeTab:g,mainOpen:v}=tc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(sd)}:null}),b=Zo(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const j of m){const M=Sn(j.appId,j.toolName);x.set(M,{id:M,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of u){const M=Sn(j.connectionId,j.toolName);x.set(M,{id:M,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let w;e[2]!==p?(w=j=>({id:j.id,title:j.title,kind:"agent",icon:$i({tabId:j.id,kind:"agent",appId:j.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const N=[...d.map(w),...Array.from(x.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:$i({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:p})})),...S.map(j=>({id:j.id,title:j.title,kind:"system",icon:$i({tabId:j.id,kind:"system",connections:p})}))];let y;return e[4]!==g||e[5]!==v||e[6]!==s?(y=j=>{const M=sc({clickedId:j,activeTab:g,mainOpen:v});s({to:".",search:D=>({...D,main:M}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=y):y=e[7],{activeTab:g,mainOpen:v,setActiveTab:y,systemTabs:S,layoutTabs:d,expandedTools:m,automationTabParsed:b,tabs:N}}function sd(t){return{id:t.id}}function id(t){const e=V.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:d}=t,u=a===void 0?"lg":a,m=c===void 0?!0:c,_=d===void 0?!1:d,[f,p]=A.useState(!1),[g,v]=A.useState("icons"),[b,S]=A.useState(""),[x,w]=A.useState("blue");let N;e[0]!==s?(N=ki(s),e[0]=s,e[1]=N):N=e[1];const y=N,k=y.type==="icon"||y.type==="url"&&y.color?y.color:x;let j;e[2]!==i||e[3]!==k?(j=_e=>{i(Pi(_e,k))},e[2]=i,e[3]=k,e[4]=j):j=e[4];const M=j;let D;e[5]!==i||e[6]!==r||e[7]!==y.name||e[8]!==y.type||e[9]!==y.url?(D=_e=>{w(_e),r?.(_e),y.type==="icon"?i(Pi(y.name,_e)):y.type==="url"&&i(kn(y.url,_e))},e[5]=i,e[6]=r,e[7]=y.name,e[8]=y.type,e[9]=y.url,e[10]=D):D=e[10];const T=D;let C;e[11]!==i||e[12]!==k?(C=_e=>{i(kn(_e,k)),p(!1)},e[11]=i,e[12]=k,e[13]=C):C=e[13];const R=C;let E;e[14]!==i||e[15]!==k?(E=()=>{const _e=Jr(),Vt=_e[Math.floor(Math.random()*_e.length)];i(Pi(Vt,k))},e[14]=i,e[15]=k,e[16]=E):E=e[16];const L=E;let z,B,O,$,W,I,F,U;if(e[17]!==l||e[18]!==_||e[19]!==f||e[20]!==u){const _e={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Us,I=_?!1:f,F=p,z=Hs,W=!0,U="button",O=_,$=te("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",_e[u],l),e[17]=l,e[18]=_,e[19]=f,e[20]=u,e[21]=z,e[22]=B,e[23]=O,e[24]=$,e[25]=W,e[26]=I,e[27]=F,e[28]=U}else z=e[21],B=e[22],O=e[23],$=e[24],W=e[25],I=e[26],F=e[27],U=e[28];let K;e[29]!==h||e[30]!==n||e[31]!==u||e[32]!==s?(K=o.jsx(Nn,{icon:s,name:n,size:u,className:h}),e[29]=h,e[30]=n,e[31]=u,e[32]=s,e[33]=K):K=e[33];let G;e[34]!==_||e[35]!==m?(G=m&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(ta,{size:16,className:"text-white"})}),e[34]=_,e[35]=m,e[36]=G):G=e[36];let P;e[37]!==O||e[38]!==$||e[39]!==K||e[40]!==G||e[41]!==U?(P=o.jsxs("button",{type:U,disabled:O,className:$,children:[K,G]}),e[37]=O,e[38]=$,e[39]=K,e[40]=G,e[41]=U,e[42]=P):P=e[42];let Z;e[43]!==z||e[44]!==W||e[45]!==P?(Z=o.jsx(z,{asChild:W,children:P}),e[43]=z,e[44]=W,e[45]=P,e[46]=Z):Z=e[46];let Y;e[47]!==n||e[48]!==s?(Y=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(Nn,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=Y):Y=e[49];let ee;e[50]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>v("icons"),e[50]=ee):ee=e[50];const ce=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ie;e[51]!==ce?(ie=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ce),e[51]=ce,e[52]=ie):ie=e[52];let Q;e[53]!==ie?(Q=o.jsx("button",{type:"button",onClick:ee,className:ie,children:"Icons"}),e[53]=ie,e[54]=Q):Q=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const de=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[56]!==de?(ue=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",de),e[56]=de,e[57]=ue):ue=e[57];let we;e[58]!==ue?(we=o.jsx("button",{type:"button",onClick:he,className:ue,children:"Upload"}),e[58]=ue,e[59]=we):we=e[59];let Xe;e[60]===Symbol.for("react.memo_cache_sentinel")?(Xe=o.jsx("div",{className:"flex-1"}),e[60]=Xe):Xe=e[60];let He;e[61]!==Q||e[62]!==we?(He=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[Q,we,Xe]}),e[61]=Q,e[62]=we,e[63]=He):He=e[63];let ne;e[64]!==T||e[65]!==L||e[66]!==M||e[67]!==R||e[68]!==y.name||e[69]!==y.type||e[70]!==b||e[71]!==k||e[72]!==g?(ne=g==="icons"?o.jsx(ad,{search:b,onSearchChange:S,selectedColor:k,onColorChange:T,onSelectIcon:M,onRandom:L,currentIconName:y.type==="icon"?y.name:null}):o.jsx(ld,{onUpload:R}),e[64]=T,e[65]=L,e[66]=M,e[67]=R,e[68]=y.name,e[69]=y.type,e[70]=b,e[71]=k,e[72]=g,e[73]=ne):ne=e[73];let ve;e[74]!==Y||e[75]!==He||e[76]!==ne?(ve=o.jsx(Ws,{align:"start",className:"w-80 p-0",onOpenAutoFocus:rd,children:o.jsxs("div",{className:"flex flex-col",children:[Y,He,ne]})}),e[74]=Y,e[75]=He,e[76]=ne,e[77]=ve):ve=e[77];let tt;return e[78]!==B||e[79]!==I||e[80]!==F||e[81]!==Z||e[82]!==ve?(tt=o.jsxs(B,{open:I,onOpenChange:F,children:[Z,ve]}),e[78]=B,e[79]=I,e[80]=F,e[81]=Z,e[82]=ve,e[83]=tt):tt=e[83],tt}function rd(t){return t.preventDefault()}function nd(t){const e=V.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=A.useState(!1);let a,l,h,c,d,u,m;if(e[0]!==r||e[1]!==s){const b=ea(s);l=Us,u=r,m=n,a=Hs,d=!0,h="button",c=te("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=d,e[7]=u,e[8]=m}else a=e[2],l=e[3],h=e[4],c=e[5],d=e[6],u=e[7],m=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let f;e[12]!==a||e[13]!==d||e[14]!==_?(f=o.jsx(a,{asChild:d,children:_}),e[12]=a,e[13]=d,e[14]=_,e[15]=f):f=e[15];let p;e[16]!==i||e[17]!==s?(p=gc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:te("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Ws,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:od,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==u||e[23]!==m||e[24]!==f||e[25]!==g?(v=o.jsxs(l,{open:u,onOpenChange:m,children:[f,g]}),e[21]=l,e[22]=u,e[23]=m,e[24]=f,e[25]=g,e[26]=v):v=e[26],v}function od(t){return t.preventDefault()}function ad(t){const e=V.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,m,_,f,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=Jr(),w=ea(r);d=s.trim()?x.filter(T=>{const C=ar(T),R=s.toLowerCase();return C.includes(R)||T.toLowerCase().includes(R)}):x,f="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ca,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=N):N=e[14];let y;e[15]!==i?(y=T=>i(T.target.value),e[15]=i,e[16]=y):y=e[16];let k;e[17]!==s||e[18]!==y?(k=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(fs,{value:s,onChange:y,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=y,e[19]=k):k=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(pc,{size:14,className:"text-muted-foreground"}),e[20]=j):j=e[20];let M;e[21]!==l?(M=o.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:j}),e[21]=l,e[22]=M):M=e[22];let D;e[23]!==n||e[24]!==r?(D=o.jsx(nd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=D):D=e[25],e[26]!==M||e[27]!==D||e[28]!==k?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[k,M,D]}),e[26]=M,e[27]=D,e[28]=k,e[29]=p):p=e[29],c=wa,_="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",m=d.map(T=>{const C=Ni(T);return C?o.jsx("button",{type:"button",onClick:()=>a(T),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===T?te(w.bg,w.text):te(w.text,"hover:bg-accent")),title:T,children:o.jsx(C,{size:18})},T):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=d,e[9]=u,e[10]=m,e[11]=_,e[12]=f,e[13]=p}else c=e[7],d=e[8],u=e[9],m=e[10],_=e[11],f=e[12],p=e[13];let g;e[30]!==u||e[31]!==m?(g=o.jsx("div",{className:u,children:m}),e[30]=u,e[31]=m,e[32]=g):g=e[32];let v;e[33]!==d.length?(v=d.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.length,e[34]=v):v=e[34];let b;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(b=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=b):b=e[39];let S;return e[40]!==f||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:f,children:[p,b]}),e[40]=f,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function ld(t){const e=V.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=N=>{const y=N.target.files?.[0];if(!y)return;if(y.size>2097152){me.error("Image must be smaller than 2MB"),N.target.value="";return}const k=new FileReader;k.onerror=()=>{me.error("Failed to read image file"),i.current&&(i.current.value="")},k.onloadend=()=>{k.readyState===FileReader.DONE&&k.result&&s(k.result),i.current&&(i.current.value="")},k.readAsDataURL(y)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=A.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const N=a.trim();N&&(s(N),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let d;e[5]!==n?(d=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=d):d=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=o.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:[o.jsx(Jl,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=m):m=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=N=>l(N.target.value),e[10]=f):f=e[10];let p;e[11]!==c?(p=N=>{N.key==="Enter"&&(N.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(fs,{value:a,onChange:f,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const b=!v;let S;e[18]!==c||e[19]!==b?(S=o.jsx(se,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let w;return e[24]!==x||e[25]!==d?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,m,_,x]}),e[24]=x,e[25]=d,e[26]=w):w=e[26],w}function cd(t){const e=V.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=ki(s);if(n.type==="icon"){const a=Ni(n.name);if(a){let l;e[2]!==a?(l=o.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=o.jsx(Bc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function hd(t){const e=V.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=ki(s),e[0]=s,e[1]=d):d=e[1];const u=d,m=u.type==="icon"?u.name:null;let _,f,p,g,v,b,S,x,w,N,y,k,j,M,D;if(e[2]!==r||e[3]!==m||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=Jr();g=h.trim()?B.filter(K=>{const G=h.toLowerCase();return ar(K).includes(G)||K.toLowerCase().includes(G)}):B,p=Us,v=n?!1:a,b=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let $;e[24]!==r||e[25]!==O?($=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=$):$=e[26];let W;e[27]!==s?(W=o.jsx(cd,{value:s}),e[27]=s,e[28]=W):W=e[28],e[29]!==n||e[30]!==$||e[31]!==W?(S=o.jsx(Hs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:$,children:W})}),e[29]=n,e[30]=$,e[31]=W,e[32]=S):S=e[32],f=Ws,j="start",M="w-64 p-0",D=dd,y="flex flex-col";let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(Ca,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=I):I=e[33];let F;e[34]===Symbol.for("react.memo_cache_sentinel")?(F=K=>c(K.target.value),e[34]=F):F=e[34],e[35]!==h?(k=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[I,o.jsx(fs,{value:h,onChange:F,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=k):k=e[36],_=wa,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let U;e[37]!==m||e[38]!==i?(U=K=>{const G=Ni(K);return G?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:ar(K),children:o.jsx(G,{size:16})},K):null},e[37]=m,e[38]=i,e[39]=U):U=e[39],w=g.map(U),e[2]=r,e[3]=m,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=f,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=w,e[18]=N,e[19]=y,e[20]=k,e[21]=j,e[22]=M,e[23]=D}else _=e[9],f=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],w=e[17],N=e[18],y=e[19],k=e[20],j=e[21],M=e[22],D=e[23];let T;e[40]!==x||e[41]!==w?(T=o.jsx("div",{className:x,children:w}),e[40]=x,e[41]=w,e[42]=T):T=e[42];let C;e[43]!==g.length?(C=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=C):C=e[44];let R;e[45]!==_||e[46]!==T||e[47]!==C||e[48]!==N?(R=o.jsxs(_,{className:N,children:[T,C]}),e[45]=_,e[46]=T,e[47]=C,e[48]=N,e[49]=R):R=e[49];let E;e[50]!==R||e[51]!==y||e[52]!==k?(E=o.jsxs("div",{className:y,children:[k,R]}),e[50]=R,e[51]=y,e[52]=k,e[53]=E):E=e[53];let L;e[54]!==f||e[55]!==E||e[56]!==j||e[57]!==M||e[58]!==D?(L=o.jsx(f,{align:j,className:M,onOpenAutoFocus:D,children:E}),e[54]=f,e[55]=E,e[56]=j,e[57]=M,e[58]=D,e[59]=L):L=e[59];let z;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==L?(z=o.jsxs(p,{open:v,onOpenChange:b,children:[S,L]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=L,e[65]=z):z=e[65],z}function dd(t){return t.preventDefault()}function ai(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Me,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Fi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(Rl,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.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 ud(t){const e=V.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=te("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.tags?(d=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];let m;e[10]!==s.description?(m=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=m):m=e[11];let _;e[12]!==u||e[13]!==m?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,m]}),e[12]=u,e[13]=m,e[14]=_):_=e[14];let f;e[15]!==n||e[16]!==i||e[17]!==r?(f=o.jsx(rh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=f):f=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==f?(p=o.jsxs("label",{className:h,children:[_,f]}),e[19]=h,e[20]=_,e[21]=f,e[22]=p):p=e[22],p}function rn(t){const e=V.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const u=s.map(fd);if(s.length===0){let m;e[8]!==n?(m=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=m):m=e[9],c=m;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(m=>o.jsx(ud,{item:m,isSelected:i===null||i?.includes(m.id),onToggle:()=>r(m.id,u),disabled:a},m.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[10]!==l||e[11]!==h?(d=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function fd(t){return t.id}function md(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=kc(c);let u;e[5]!==d.tools?(u=d.tools.map(_d),e[5]=d.tools,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function _d(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(Jc,{annotations:t.annotations,_meta:t._meta})}}function pd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=Yc(c);let u;e[5]!==d.resources?(u=d.resources.map(gd),e[5]=d.resources,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function gd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function vd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=nh(c);let u;e[5]!==d.prompts?(u=d.prompts.map(xd),e[5]=d.prompts,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function xd(t){return{id:t.name,name:t.name,description:t.description}}function bd(t){const e=V.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:m}=t,_=n[r],f=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?d(r):u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=d,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(ds,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let x;e[13]!==b||e[14]!==S?(x=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=x):x=e[15];let w;e[16]!==v||e[17]!==x?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let y;e[20]!==m?(y=z=>m(z),e[20]=m,e[21]=y):y=e[21];let k;e[22]!==i||e[23]!==y?(k=o.jsx(ih,{tabs:N,activeTab:i,onTabChange:y}),e[22]=i,e[23]=y,e[24]=k):k=e[24];const j=f?"Deselect all":"Select all";let M;e[25]!==g||e[26]!==j?(M=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:j}),e[25]=g,e[26]=j,e[27]=M):M=e[27];let D;e[28]!==M||e[29]!==k?(D=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[k,M]}),e[28]=M,e[29]=k,e[30]=D):D=e[30];let T;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(T=i==="tools"&&o.jsx(Qt,{fallback:Fi("Tools not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(md,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(z,B)=>a(r,z,B)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=T):T=e[35];let C;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(C=i==="resources"&&o.jsx(Qt,{fallback:Fi("Resources not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(pd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(z,B)=>l(r,z,B)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=C):C=e[40];let R;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(R=i==="prompts"&&o.jsx(Qt,{fallback:Fi("Prompts not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(vd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(z,B)=>h(r,z,B)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=R):R=e[45];let E;e[46]!==T||e[47]!==C||e[48]!==R?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,C,R]}),e[46]=T,e[47]=C,e[48]=R,e[49]=E):E=e[49];let L;return e[50]!==D||e[51]!==E||e[52]!==w?(L=o.jsxs(o.Fragment,{children:[w,D,E]}),e[50]=D,e[51]=E,e[52]=w,e[53]=L):L=e[53],L}function Sd(t){const e=V.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=ha(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(vc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.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]=d):d=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&o.jsx(se,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let m;return e[7]!==u?(m=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,d,u]}),e[7]=u,e[8]=m):m=e[8],m}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function yd(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 Pn(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function wd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Cd(t){const e=V.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,d]=A.useReducer(wd,h),u=Qr(r??"");let m;e[1]!==a?(m=a??[],e[1]=a,e[2]=m):m=e[2];let _;e[3]!==m?(_=yd(m),e[3]=m,e[4]=_):_=e[4];const f=_;let p;e[5]!==n||e[6]!==f?(p=(I,F,U,K)=>{const G=f[I]?.[F];let P;G===null?P=K.filter(Y=>Y!==U):G?.includes(U)?P=G.filter(Y=>Y!==U):(P=[...G??[],U],P.length===K.length&&(P=null));const Z={...f};Z[I]?Z[I]={...Z[I]}:Z[I]={tools:null,resources:null,prompts:null},Z[I][F]=P,n.setValue("connections",Pn(Z),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=f,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==f?(v=(I,F)=>{const K=f[I]?.[F]===null?[]:null,G={...f};G[I]?G[I]={...G[I]}:G[I]={tools:null,resources:null,prompts:null},G[I][F]=K,n.setValue("connections",Pn(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=f,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(I,F,U)=>g(I,"tools",F,U),e[11]=g,e[12]=S):S=e[12];const x=S;let w;e[13]!==g?(w=(I,F,U)=>g(I,"resources",F,U),e[13]=g,e[14]=w):w=e[14];const N=w;let y;e[15]!==g?(y=(I,F,U)=>g(I,"prompts",F,U),e[15]=g,e[16]=y):y=e[16];const k=y;let j;e[17]!==b?(j=I=>b(I,"tools"),e[17]=b,e[18]=j):j=e[18];const M=j;let D;e[19]!==b?(D=I=>b(I,"resources"),e[19]=b,e[20]=D):D=e[20];const T=D;let C;e[21]!==b?(C=I=>b(I,"prompts"),e[21]=b,e[22]=C):C=e[22];const R=C;if(!r||!u)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ai,{}),e[23]=E):E=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=I=>d({type:"SET_ACTIVE_TAB",payload:I}),e[24]=L):L=e[24];let z;e[25]!==u||e[26]!==c.activeTab||e[27]!==f||e[28]!==r||e[29]!==R||e[30]!==T||e[31]!==M||e[32]!==k||e[33]!==N||e[34]!==x?(z=o.jsx(bd,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:f,toggleTool:x,toggleResource:N,togglePrompt:k,toggleAllTools:M,toggleAllResources:T,toggleAllPrompts:R,onTabChange:L},r),e[25]=u,e[26]=c.activeTab,e[27]=f,e[28]=r,e[29]=R,e[30]=T,e[31]=M,e[32]=k,e[33]=N,e[34]=x,e[35]=z):z=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==z?(B=o.jsx(A.Suspense,{fallback:E,children:o.jsx(Sd,{connectionId:r,onAuthenticate:l,children:z})}),e[36]=l,e[37]=r,e[38]=z,e[39]=B):B=e[39];let O;e[40]!==i?(O=o.jsx(Qc,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(se,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let $;e[42]!==B||e[43]!==O?($=o.jsxs(en,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,O]}),e[42]=B,e[43]=O,e[44]=$):$=e[44];let W;return e[45]!==i||e[46]!==s||e[47]!==$?(W=o.jsx(tn,{open:s,onOpenChange:i,children:$}),e[45]=i,e[46]=s,e[47]=$,e[48]=W):W=e[48],W}const Hi={tools:null,resources:null,prompts:null},kd=Dl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Nd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function jd(t){const e=V.c(11),{url:s,agentId:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Se("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),me.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Ei,{size:20,className:"text-green-600"}):o.jsx(Ci,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==h||e[9]!==d?(u=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,d]}),e[7]=l,e[8]=h,e[9]=d,e[10]=u):u=e[10],u}function Ed(t){const e=V.c(9),{url:s,serverName:i,agentId:r,organizationId:n}=t;let a;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(a=()=>{Se("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=da(i),_=Nd(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor","x-org-id":n}},null,2)),f=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(_)}`;window.open(f,"_blank"),me.success("Opening Cursor...")},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let h,c;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=o.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%)"}}),c=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[5]=h,e[6]=c):(h=e[5],c=e[6]);let d;return e[7]!==l?(d=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,c]}),e[7]=l,e[8]=d):d=e[8],d}function Td(t){const e=V.c(13),{url:s,serverName:i,agentId:r,organizationId:n}=t,[a,l]=A.useState(!1);let h;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(h=async()=>{Se("agent_connect_action",{agent_id:r,action:"install_claude_code"});const f=da(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code","x-org-id":n}},null,2),v=`claude mcp add-json "${f}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),me.success("Claude Code command copied to clipboard"),setTimeout(()=>l(!1),2e3)},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=h):h=e[4];const c=h;let d;e[5]!==a?(d=a?o.jsx(Ei,{size:20,className:"text-green-600"}):o.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[5]=a,e[6]=d):d=e[6];const u=a?"Copied!":"Install on Claude Code";let m;e[7]!==u?(m=o.jsx("span",{className:"text-xs font-medium",children:u}),e[7]=u,e[8]=m):m=e[8];let _;return e[9]!==c||e[10]!==d||e[11]!==m?(_=o.jsxs(se,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,m]}),e[9]=c,e[10]=d,e[11]=m,e[12]=_):_=e[12],_}function Rd({virtualMcp:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),[i,r]=A.useState(null),[n,a]=A.useState(!1),[l,h]=A.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,u=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,m=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),Se("agent_typegen_key_generated",{agent_id:c})}catch{Se("agent_typegen_key_failed",{agent_id:c}),me.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{Se("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),me.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:n,children:[n?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(sh,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.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."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Dd,{apiKey:i,agentId:c})]})}function Dd(t){const e=V.c(21),{apiKey:s,agentId:i}=t,[r,n]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
3
+ ${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{Se("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=d):d=e[3];const u=d,m=!s;let _;e[4]!==m?(_=te({"opacity-50":m}),e[4]=m,e[5]=_):_=e[5];let f;e[6]!==l||e[7]!==_?(f=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=f):f=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==f?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[f,p,g]}),e[11]=f,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==u||e[16]!==b?(S=o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,e[16]=b,e[17]=S):S=e[17];let x;return e[18]!==v||e[19]!==S?(x=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=x):x=e[20],x}function Md(t){const e=V.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(A.Suspense,{fallback:i,children:o.jsx(Rd,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Id(t){const e=V.c(38),{open:s,onOpenChange:i,virtualMcp:r}=t,n=`/mcp/virtual-mcp/${r.id}`;let a;e[0]!==n?(a=new URL(n,window.location.origin),e[0]=n,e[1]=a):a=e[1];const l=a;let h;e[2]!==r.id||e[3]!==r.title?(h=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=h):h=e[4];const c=h,d=aa();let u;e[5]!==r.id||e[6]!==l.href?(u=o.jsx(jd,{url:l.href,agentId:r.id}),e[5]=r.id,e[6]=l.href,e[7]=u):u=e[7];let m,_;e[8]!==c||e[9]!==r.id||e[10]!==r.organization_id||e[11]!==l.href?(m=o.jsx(Ed,{url:l.href,serverName:c,agentId:r.id,organizationId:r.organization_id}),_=o.jsx(Td,{url:l.href,serverName:c,agentId:r.id,organizationId:r.organization_id}),e[8]=c,e[9]=r.id,e[10]=r.organization_id,e[11]=l.href,e[12]=m,e[13]=_):(m=e[12],_=e[13]);let f;e[14]!==u||e[15]!==m||e[16]!==_?(f=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[u,m,_]})}),e[14]=u,e[15]=m,e[16]=_,e[17]=f):f=e[17];let p;e[18]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("div",{className:"border-t border-border"}),e[18]=p):p=e[18];let g;e[19]!==r?(g=o.jsx(Md,{virtualMcp:r}),e[19]=r,e[20]=g):g=e[20];let v;e[21]!==f||e[22]!==g?(v=o.jsxs("div",{className:"flex flex-col gap-6",children:[f,p,g]}),e[21]=f,e[22]=g,e[23]=v):v=e[23];const b=v;if(d){let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(lh,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[24]=N):N=e[24];let y;e[25]!==b?(y=o.jsx(ch,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[N,b]})}),e[25]=b,e[26]=y):y=e[26];let k;return e[27]!==i||e[28]!==s||e[29]!==y?(k=o.jsx(hh,{open:s,onOpenChange:i,children:y}),e[27]=i,e[28]=s,e[29]=y,e[30]=k):k=e[30],k}let S;e[31]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ba,{children:o.jsx(Sa,{children:"Connect"})}),e[31]=S):S=e[31];let x;e[32]!==b?(x=o.jsxs(en,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,b]}),e[32]=b,e[33]=x):x=e[33];let w;return e[34]!==i||e[35]!==s||e[36]!==x?(w=o.jsx(tn,{open:s,onOpenChange:i,children:x}),e[34]=i,e[35]=s,e[36]=x,e[37]=w):w=e[37],w}function Bd(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 Ad(t){const e=V.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=Qr(s),{org:d}=ye();if(!c)return null;let u;e[0]!==c?(u=Zc(c),e[0]=c,e[1]=u):u=e[1];const m=u;let _;e[2]!==s?(_=o.jsx(zd,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let f;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==d.slug||e[16]!==m||e[17]!==i?(f=o.jsx(Od,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:m,orgSlug:d.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=d.slug,e[16]=m,e[17]=i,e[18]=f):f=e[18];let p;return e[19]!==_||e[20]!==f?(p=o.jsx(A.Suspense,{fallback:_,children:f}),e[19]=_,e[20]=f,e[21]=p):p=e[21],p}const Ln="__new_instance__";async function Pd(t,e){const s=t?.idToken??null;if(s){const r=On(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 n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return On(e)}function On(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 Ld(t){const e=V.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,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 h=ji(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Ln?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(ts,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(ss,{})}),e[6]=d):d=e[6];let u;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(Dt,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],u=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=u}else u=e[10];let m;e[14]!==a?(m=a&&o.jsx(Dt,{value:Ln,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=m):m=e[15];let _;e[16]!==u||e[17]!==m?(_=o.jsxs(is,{children:[u,m]}),e[16]=u,e[17]=m,e[18]=_):_=e[18];let f;return e[19]!==i||e[20]!==c||e[21]!==_?(f=o.jsxs(es,{value:i,onValueChange:c,children:[d,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=f):f=e[22],f}function Od(t){const e=V.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:m,onAuthenticate:_,onSwitchInstance:f,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=ha(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==x?(w=te("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=w):w=e[3];let N;e[4]!==h||e[5]!==l?(N={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=N):N=e[6];let y;e[7]!==n||e[8]!==i?(y=o.jsx(ds,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=y):y=e[9];let k;e[10]!==i?(k=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=k):k=e[11];let j;e[12]!==r||e[13]!==S?(j=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=j):j=e[14];let M;e[15]!==k||e[16]!==j?(M=o.jsxs("div",{className:"flex-1 min-w-0",children:[k,j]}),e[15]=k,e[16]=j,e[17]=M):M=e[17];let D;e[18]!==s||e[19]!==S||e[20]!==_?(D=S?o.jsx(se,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:K=>{K.preventDefault(),K.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.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:o.jsx(th,{size:16})})}),o.jsx(qe,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=D):D=e[21];let T;e[22]!==N||e[23]!==y||e[24]!==M||e[25]!==D?(T=o.jsxs(Bl,{to:"/$org/settings/connections/$appSlug",params:N,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[y,M,D]}),e[22]=N,e[23]=y,e[24]=M,e[25]=D,e[26]=T):T=e[26];let C;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==f||e[31]!==d?(C=c&&o.jsx(Ld,{appName:c,connectionId:s,usedConnectionIds:d,onSwitchInstance:f,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=f,e[31]=d,e[32]=C):C=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(bc,{size:13}),e[33]=R):R=e[33];let E;e[34]!==u?(E=o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:R})}),e[34]=u,e[35]=E):E=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsx(qe,{side:"bottom",children:"Configure resources"}),e[36]=L):L=e[36];let z;e[37]!==E?(z=o.jsxs(Ve,{delayDuration:0,children:[E,L]}),e[37]=E,e[38]=z):z=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=o.jsx(ls,{size:13}),e[39]=B):B=e[39];let O;e[40]!==m?(O=o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:m,"aria-label":"Remove connection",children:B})}),e[40]=m,e[41]=O):O=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx(qe,{side:"bottom",children:"Remove"}),e[42]=$):$=e[42];let W;e[43]!==O?(W=o.jsxs(Ve,{delayDuration:0,children:[O,$]}),e[43]=O,e[44]=W):W=e[44];let I;e[45]!==z||e[46]!==W?(I=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[z,W]}),e[45]=z,e[46]=W,e[47]=I):I=e[47];let F;e[48]!==C||e[49]!==I?(F=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[C,I]}),e[48]=C,e[49]=I,e[50]=F):F=e[50];let U;return e[51]!==T||e[52]!==F||e[53]!==w?(U=o.jsxs("div",{className:w,children:[T,F]}),e[51]=T,e[52]=F,e[53]=w,e[54]=U):U=e[54],U}function zd(t){const e=V.c(17),{connection_id:s}=t,i=Qr(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(Ra,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(ds,{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 n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.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]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let d;return e[15]!==h?(d=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function Ra(){const t=V.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.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=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.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=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function $d({virtualMcpId:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),i=Ht(),r=gt(t),n=(r?.connections??[]).map(O=>O.connection_id).sort(),{data:a}=Wo({queryKey:As.projectConnectionDetails(t,n),enabled:n.length>0,queryFn:async()=>await Promise.all(n.map(async $=>{try{const W=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:$}}),{item:I}=Li(W),F=(I?.tools??[]).filter(U=>!!Xc(U._meta)).map(U=>({name:U.name,description:U.description}));return{fetchOk:!0,id:$,title:I?.title??$,icon:I?.icon??null,uiTools:F}}catch{return{fetchOk:!1,id:$,title:$,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(O=>O.uiTools.length>0),h=new Set(ic),c=r?.metadata?.ui,d=c?.pinnedViews??[],u=c?.layout?.defaultMainView??null,m=c?.layout?.chatDefaultOpen??!1,_=!u||u.type==="chat"?"chat":u.type==="instructions"||u.type==="connections"||u.type==="layout"?"settings":h.has(u.type)?u.type:`${u.type}:${u.id??""}:${u.toolName??""}`,[f,p]=A.useState(d),[g,v]=A.useState(_),[b,S]=A.useState(m),[x,w]=A.useState(!1),N=O=>{const[$,W,I]=O.split(":");return $?$==="chat"?{type:$}:h.has($)?{type:$}:$==="ext-apps"&&W?{type:"ext-apps",id:W,toolName:I||void 0}:null:null},y=A.useRef(!1);if(a&&a.length>0&&!y.current){y.current=!0;const O=new Set((a??[]).filter(I=>I.fetchOk).map(I=>I.id)),$=new Set(l.flatMap(I=>I.uiTools.map(F=>`${I.id}:${F.name}`))),W=d.filter(I=>!O.has(I.connectionId)||$.has(`${I.connectionId}:${I.toolName}`));if(W.length!==d.length){p(W);let I=g;u?.type==="ext-apps"&&!W.some(F=>F.connectionId===u.id&&F.toolName===u.toolName)&&(I="chat",v(I)),s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:W,layout:{defaultMainView:N(I),chatDefaultOpen:b}}}).then(F=>{Li(F),i.invalidateQueries({predicate:U=>Array.isArray(U.queryKey)&&U.queryKey.includes("collection")&&U.queryKey.includes("VIRTUAL_MCP")})}).catch(()=>{p(d),v(_)})}}const k=(O,$,W)=>{w(!0),(async()=>{try{const F=await s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:O,layout:{defaultMainView:N($),chatDefaultOpen:W??b}}});Li(F),i.invalidateQueries({predicate:U=>Array.isArray(U.queryKey)&&U.queryKey.includes("collection")&&U.queryKey.includes("VIRTUAL_MCP")}),me.success("Layout updated")}catch(F){me.error("Failed to update layout: "+(F instanceof Error?F.message:"Unknown error"))}finally{w(!1)}})()},j=(O,$)=>{const W=f.some(U=>U.connectionId===O&&U.toolName===$);let I,F=g;if(W){I=f.filter(K=>!(K.connectionId===O&&K.toolName===$));const U=`ext-apps:${O}:${$}`;g===U&&(F="chat",v(F))}else I=[...f,{connectionId:O,toolName:$,label:yn($),icon:null}];p(I),k(I,F)},M=(O,$,W)=>{p(I=>I.map(F=>F.connectionId===O&&F.toolName===$?{...F,label:W}:F))},D=()=>{k(f,g)},T=(O,$,W)=>{p(F=>F.map(U=>U.connectionId===O&&U.toolName===$?{...U,icon:W}:U));const I=f.map(F=>F.connectionId===O&&F.toolName===$?{...F,icon:W}:F);k(I,g)},C=O=>{v(O),k(f,O)},R=n.length===0,E=a&&l.length===0,L=!!Bt(r),z=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];L&&(z.push({value:"env",label:"Terminal"}),z.push({value:"preview",label:"Preview"}));for(const O of f)z.push({value:`ext-apps:${O.connectionId}:${O.toolName}`,label:O.label||O.toolName});const B=l.length>0||R||E;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(eh,{className:"p-6 gap-5",children:[o.jsxs(Tn,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(es,{value:g,onValueChange:C,children:[o.jsx(ts,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(ss,{})}),o.jsx(is,{children:z.map(O=>o.jsx(Dt,{value:O.value,className:"capitalize",children:O.label},O.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(cr,{checked:g==="chat"?!0:b,disabled:g==="chat"||x,onCheckedChange:O=>{S(O),k(f,g,O)}})})}),g==="chat"&&o.jsx(qe,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),B&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Tn,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),R&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),E&&!R&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:l.map((O,$)=>o.jsxs("div",{children:[$>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(ds,{icon:O.icon,name:O.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:O.title})]}),o.jsx("div",{className:"space-y-1.5",children:O.uiTools.map(W=>{const I=f.some(U=>U.connectionId===O.id&&U.toolName===W.name),F=f.find(U=>U.connectionId===O.id&&U.toolName===W.name);return o.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",I?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(hd,{value:F?.icon??null,onChange:U=>T(O.id,W.name,U),disabled:!I||x}),o.jsx(fs,{value:I&&F?F.label:yn(W.name),onChange:U=>M(O.id,W.name,U.target.value),onBlur:D,className:"h-7 text-sm w-40",disabled:!I||x,readOnly:!I})]}),o.jsx(cr,{checked:I,onCheckedChange:()=>j(O.id,W.name),disabled:x})]},W.name)})})]},O.id))})]})]})]})]})}function Fd({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ye(),i=Ul(),r=qc(),n=Ht(),a=Fe({connectionId:It,orgId:s.id}),l=Vo({resolver:Ml(kd),defaultValues:t}),h=l.watch("connections"),c=!!Bt(t),[d,u]=A.useReducer(Bd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[m,_]=A.useState(!1),{createTaskWithMessage:f}=lt(),{setChatMode:p}=yi(),{createNewTask:g}=Zr(),v=()=>{const P=l.getValues("metadata.instructions");P?.trim()&&(M(),Se("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:P.length}),p("plan"),f({virtualMcpId:Xo(s.id),message:{parts:[{type:"text",text:`/writing-prompts ${t.id}
4
4
 
5
5
  <instructions>
6
6
  ${P}
7
- </instructions>`}]}}))},b=()=>{M(),Se("agent_test_clicked",{agent_id:t.id}),g()},S=A.useRef(null),x=A.useRef(null),w=A.useRef(new Set),N=A.useRef(0),y=A.useRef(null),k=A.useRef(null),j=3e4,M=()=>{k.current&&(clearTimeout(k.current),k.current=null),x.current!==null&&(Se("agent_updated",{agent_id:t.id,fields:Array.from(w.current),instructions_length:y.current,save_count:N.current,edit_duration_ms:Date.now()-x.current}),x.current=null,w.current=new Set,N.current=0,y.current=null)},R=async()=>{S.current&&(clearTimeout(S.current),S.current=null);const P=Object.keys(l.formState.dirtyFields);if(P.length===0)return;const Z=P.includes("metadata"),Y=l.getValues(),ee=await i.update.mutateAsync({id:t.id,data:Y});x.current===null&&(x.current=Date.now());for(const ce of P)w.current.add(ce);N.current+=1,Z&&(y.current=Y.metadata?.instructions?.length??0),k.current&&clearTimeout(k.current),k.current=setTimeout(M,j),l.reset(ee)},T=()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{R()},1e3)},C=A.useRef(!1);C.current||(C.current=!0,l.watch(()=>{T()}));const D=()=>{Se("connections_dialog_opened",{source:"agent_settings",mode:"add"}),u({type:"SET_ADD_DIALOG_OPEN",payload:!0})},E=async P=>{const Z=l.getValues("connections");if(Z.some(ce=>ce.connection_id===P))return;l.setValue("connections",[...Z,{connection_id:P,selected_tools:Hi.tools,selected_resources:Hi.resources,selected_prompts:Hi.prompts}],{shouldDirty:!0}),u({type:"SET_ADD_DIALOG_OPEN",payload:!1});const Y=new URL(`/mcp/${P}`,window.location.origin),ee=await vn({url:Y.href,token:null,orgId:s.id});ee.supportsOAuth&&!ee.isAuthenticated&&await $(P)},L=P=>{const Y=l.getValues("connections").filter(ee=>ee.connection_id!==P);l.setValue("connections",Y,{shouldDirty:!0})},z=(P,Z)=>{const Y=l.getValues("connections");if(Y.some(ee=>ee.connection_id===Z)){me.error("This instance is already added to the agent");return}l.setValue("connections",Y.map(ee=>ee.connection_id===P?{...ee,connection_id:Z}:ee),{shouldDirty:!0})},B=async P=>{if(l.getValues("connections").find(Y=>Y.connection_id===P))try{const Y=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:P}}),{item:ee}=Y.structuredContent??{};if(!ee)return;const ce=ee.title.replace(/\s*\(.*?\)\s*$/,""),ie=Gc("conn"),Q=`${ce} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:ie,title:Q,description:ee.description??null,connection_type:ee.connection_type,connection_url:ee.connection_url??null,connection_token:null,icon:ee.icon??null,app_name:ee.app_name??null,app_id:ee.app_id??null,connection_headers:ee.connection_headers??null});const he=new URL(`/mcp/${ie}`,window.location.origin),de=await vn({url:he.href,token:null,orgId:s.id});if(de.supportsOAuth&&!de.isAuthenticated){const ue=await $(ie);if(!ue){await r.delete.mutateAsync(ie);return}await r.update.mutateAsync({id:ie,data:{title:`${ce} (${ue})`}})}z(P,ie),me.success("New instance created")}catch(Y){console.error("Failed to create instance:",Y),me.error("Failed to create instance")}},O=P=>{u({type:"OPEN_SETTINGS",payload:P})},$=async P=>{const{token:Z,tokenInfo:Y,error:ee}=await Il({connectionId:P,scope:"offline_access"});if(ee||!Z)return me.error(`Authentication failed: ${ee}`),null;if(Y)try{const ie=await fetch(`/api/connections/${P}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json","x-org-id":s.id},credentials:"include",body:JSON.stringify({accessToken:Y.accessToken,refreshToken:Y.refreshToken,expiresIn:Y.expiresIn,scope:Y.scope,clientId:Y.clientId,clientSecret:Y.clientSecret,tokenEndpoint:Y.tokenEndpoint})});if(!ie.ok)console.error("Failed to save OAuth token:",await ie.text()),await r.update.mutateAsync({id:P,data:{connection_token:Z}});else try{await r.update.mutateAsync({id:P,data:{}})}catch(Q){console.warn("Failed to refresh connection tools after OAuth:",Q)}}catch(ie){console.error("Error saving OAuth token:",ie),await r.update.mutateAsync({id:P,data:{connection_token:Z}})}else await r.update.mutateAsync({id:P,data:{connection_token:Z}});const ce=new URL(`/mcp/${P}`,window.location.origin);return await n.invalidateQueries({queryKey:As.isMCPAuthenticated(ce.href,null)}),me.success("Authentication successful"),Ad(Y,Z)},W=()=>{const P=l.getValues("metadata.instructions")??"",Z=`<role>
7
+ </instructions>`}]}}))},b=()=>{M(),Se("agent_test_clicked",{agent_id:t.id}),g()},S=A.useRef(null),x=A.useRef(null),w=A.useRef(new Set),N=A.useRef(0),y=A.useRef(null),k=A.useRef(null),j=3e4,M=()=>{k.current&&(clearTimeout(k.current),k.current=null),x.current!==null&&(Se("agent_updated",{agent_id:t.id,fields:Array.from(w.current),instructions_length:y.current,save_count:N.current,edit_duration_ms:Date.now()-x.current}),x.current=null,w.current=new Set,N.current=0,y.current=null)},D=async()=>{S.current&&(clearTimeout(S.current),S.current=null);const P=Object.keys(l.formState.dirtyFields);if(P.length===0)return;const Z=P.includes("metadata"),Y=l.getValues(),ee=await i.update.mutateAsync({id:t.id,data:Y});x.current===null&&(x.current=Date.now());for(const ce of P)w.current.add(ce);N.current+=1,Z&&(y.current=Y.metadata?.instructions?.length??0),k.current&&clearTimeout(k.current),k.current=setTimeout(M,j),l.reset(ee)},T=()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{D()},1e3)},C=A.useRef(!1);C.current||(C.current=!0,l.watch(()=>{T()}));const R=()=>{Se("connections_dialog_opened",{source:"agent_settings",mode:"add"}),u({type:"SET_ADD_DIALOG_OPEN",payload:!0})},E=async P=>{const Z=l.getValues("connections");if(Z.some(ce=>ce.connection_id===P))return;l.setValue("connections",[...Z,{connection_id:P,selected_tools:Hi.tools,selected_resources:Hi.resources,selected_prompts:Hi.prompts}],{shouldDirty:!0}),u({type:"SET_ADD_DIALOG_OPEN",payload:!1});const Y=new URL(`/mcp/${P}`,window.location.origin),ee=await vn({url:Y.href,token:null,orgId:s.id});ee.supportsOAuth&&!ee.isAuthenticated&&await $(P)},L=P=>{const Y=l.getValues("connections").filter(ee=>ee.connection_id!==P);l.setValue("connections",Y,{shouldDirty:!0})},z=(P,Z)=>{const Y=l.getValues("connections");if(Y.some(ee=>ee.connection_id===Z)){me.error("This instance is already added to the agent");return}l.setValue("connections",Y.map(ee=>ee.connection_id===P?{...ee,connection_id:Z}:ee),{shouldDirty:!0})},B=async P=>{if(l.getValues("connections").find(Y=>Y.connection_id===P))try{const Y=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:P}}),{item:ee}=Y.structuredContent??{};if(!ee)return;const ce=ee.title.replace(/\s*\(.*?\)\s*$/,""),ie=Gc("conn"),Q=`${ce} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:ie,title:Q,description:ee.description??null,connection_type:ee.connection_type,connection_url:ee.connection_url??null,connection_token:null,icon:ee.icon??null,app_name:ee.app_name??null,app_id:ee.app_id??null,connection_headers:ee.connection_headers??null});const he=new URL(`/mcp/${ie}`,window.location.origin),de=await vn({url:he.href,token:null,orgId:s.id});if(de.supportsOAuth&&!de.isAuthenticated){const ue=await $(ie);if(!ue){await r.delete.mutateAsync(ie);return}await r.update.mutateAsync({id:ie,data:{title:`${ce} (${ue})`}})}z(P,ie),me.success("New instance created")}catch(Y){console.error("Failed to create instance:",Y),me.error("Failed to create instance")}},O=P=>{u({type:"OPEN_SETTINGS",payload:P})},$=async P=>{const{token:Z,tokenInfo:Y,error:ee}=await Il({connectionId:P,scope:"offline_access"});if(ee||!Z)return me.error(`Authentication failed: ${ee}`),null;if(Y)try{const ie=await fetch(`/api/connections/${P}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json","x-org-id":s.id},credentials:"include",body:JSON.stringify({accessToken:Y.accessToken,refreshToken:Y.refreshToken,expiresIn:Y.expiresIn,scope:Y.scope,clientId:Y.clientId,clientSecret:Y.clientSecret,tokenEndpoint:Y.tokenEndpoint})});if(!ie.ok)console.error("Failed to save OAuth token:",await ie.text()),await r.update.mutateAsync({id:P,data:{connection_token:Z}});else try{await r.update.mutateAsync({id:P,data:{}})}catch(Q){console.warn("Failed to refresh connection tools after OAuth:",Q)}}catch(ie){console.error("Error saving OAuth token:",ie),await r.update.mutateAsync({id:P,data:{connection_token:Z}})}else await r.update.mutateAsync({id:P,data:{connection_token:Z}});const ce=new URL(`/mcp/${P}`,window.location.origin);return await n.invalidateQueries({queryKey:As.isMCPAuthenticated(ce.href,null)}),me.success("Authentication successful"),Pd(Y,Z)},W=()=>{const P=l.getValues("metadata.instructions")??"",Z=`<role>
8
8
  Define who this agent is and what it specializes in.
9
9
  Example: You are a support triage agent for B2B merchants.
10
10
  </role>
@@ -31,7 +31,7 @@ Define step-by-step how the agent should handle requests.
31
31
  4. Ask for confirmation before making any changes.
32
32
  </workflows>`,Y=P.trim()?`${P}
33
33
 
34
- ${Z}`:Z;l.setValue("metadata.instructions",Y,{shouldDirty:!0})},I=new Set(h.map(P=>P.connection_id)),F=Mt(),[U,K]=A.useState(!1),G=async()=>{M();try{await i.delete.mutateAsync(t.id),Se("agent_deleted",{agent_id:t.id,source:"agent_detail"}),me.success(`Deleted "${t.title}"`),F({to:"/$org",params:{org:s.slug}})}catch{}};return o.jsxs(at,{children:[o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&o.jsx(at.Title,{actions:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(se,{variant:"outline",size:"sm",onClick:b,children:[o.jsx(oi,{size:14,className:"!size-[14px]"}),"Test Agent"]}),o.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>K(!0),children:o.jsx(hr,{size:14})})]}),children:"Settings"}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Xt,{name:"icon",control:l.control,render:({field:P})=>o.jsx(sd,{value:P.value??null,onChange:Z=>{P.onChange(Z),R()},onColorChange:Z=>{l.setValue("metadata.ui.themeColor",Z,{shouldDirty:!0}),R()},name:l.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2",disabled:c})}),o.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[o.jsx(Xt,{name:"title",control:l.control,render:({field:P})=>o.jsx("input",{...P,type:"text",value:P.value??"",onBlur:()=>{P.onBlur(),R()},disabled:c,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"})}),o.jsx(Xt,{name:"description",control:l.control,render:({field:P})=>o.jsx("input",{...P,type:"text",value:P.value??"",onBlur:()=>{P.onBlur(),R()},disabled:c,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"})})]}),o.jsxs(se,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Se("agent_connect_modal_opened",{agent_id:t.id}),u({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[o.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[o.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),o.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:o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),o.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-muted-foreground",children:[o.jsx(ca,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx("span",{className:"text-sm",children:new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]}),o.jsxs("section",{className:"flex flex-col gap-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&o.jsxs(se,{variant:"outline",size:"sm",onClick:D,children:[o.jsx(cs,{size:14}),"Add connection"]})]}),o.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?o.jsxs("button",{type:"button",onClick:D,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:[o.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:o.jsx(cs,{size:16})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map(P=>o.jsx(Qt,{fallback:()=>null,children:o.jsx(A.Suspense,{fallback:o.jsx(Da,{}),children:o.jsx(Bd,{connection_id:P.connection_id,usedConnectionIds:I,onOpenSettings:()=>O(P.connection_id),onRemove:()=>L(P.connection_id),onAuthenticate:$,onSwitchInstance:z,onNewInstance:()=>B(P.connection_id)})})},P.connection_id))})]}),o.jsxs("section",{className:"flex flex-col gap-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),!c&&o.jsxs("div",{className:"flex items-center gap-2",children:[!l.watch("metadata.instructions")?.trim()&&o.jsx(se,{variant:"outline",size:"sm",onClick:W,children:"+ Prompt template"}),o.jsxs(se,{variant:"outline",size:"sm",disabled:!l.watch("metadata.instructions")?.trim(),onClick:v,children:[o.jsx(ya,{size:13}),"Improve"]})]})]}),o.jsx(Xt,{name:"metadata.instructions",control:l.control,render:({field:P})=>o.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(Dn,{...P,value:P.value??"",onBlur:()=>{P.onBlur(),R()},disabled:c,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"}}),o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>_(!0),"aria-label":"Open fullscreen editor",children:o.jsx(xc,{size:14})})}),o.jsx(qe,{side:"left",children:"Fullscreen"})]})]})})]}),o.jsx(zd,{virtualMcpId:t.id}),o.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),o.jsxs(se,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>K(!0),children:[o.jsx(hr,{size:14}),"Delete agent"]})]})]})})}),o.jsx(ua,{open:U,onOpenChange:K,children:o.jsxs(fa,{children:[o.jsxs(ma,{children:[o.jsx(_a,{children:"Delete Agent?"}),o.jsxs(pa,{children:["This action cannot be undone. This will permanently delete"," ",o.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),o.jsxs(ga,{children:[o.jsx(va,{children:"Cancel"}),o.jsx(xa,{onClick:G,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),o.jsx(Fl,{open:d.addDialogOpen,onOpenChange:P=>u({type:"SET_ADD_DIALOG_OPEN",payload:P}),agentId:t.id,addedConnectionIds:I,onAdd:E}),o.jsx(wd,{open:d.settingsDialogOpen,onOpenChange:P=>{P||u({type:"CLOSE_SETTINGS"})},selectedId:d.settingsConnectionId,form:l,connections:h,onAuthenticate:$}),o.jsx(Md,{open:d.shareDialogOpen,onOpenChange:P=>u({type:"SET_SHARE_DIALOG_OPEN",payload:P}),virtualMcp:t}),o.jsx(tn,{open:m,onOpenChange:_,children:o.jsxs(en,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[o.jsx(ba,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:o.jsx(Sa,{children:"Instructions"})}),o.jsx("div",{className:"flex-1 min-h-0 p-6",children:o.jsx(Xt,{name:"metadata.instructions",control:l.control,render:({field:P})=>o.jsx(Dn,{...P,value:P.value??"",onBlur:()=>{P.onBlur(),R()},disabled:c,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 Fd(t){const e=V.c(9),{virtualMcpId:s,hideOwnTitle:i}=t,r=Mt(),{org:n}=ye(),a=gt(s);if(!a){let c;return e[0]!==r||e[1]!==n.slug?(c=o.jsx("div",{className:"flex h-full w-full bg-background",children:o.jsx(Ps,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:o.jsx(se,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:n.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=n.slug,e[2]=c):c=e[2],c}let l;e[3]!==a?(l=Bt(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let h;return e[5]!==i||e[6]!==l||e[7]!==a?(h=o.jsx($d,{virtualMcp:a,hideOwnTitle:i},l),e[5]=i,e[6]=l,e[7]=a,e[8]=h):h=e[8],h}function zn(t){const e=V.c(2),{virtualMcpId:s}=t;let i;return e[0]!==s?(i=o.jsx(Fd,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=i):i=e[1],i}const Hd={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function Os(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 Hd[s]??e}):""}function Ks(t){if(!t||typeof t!="object")return null;const e=t;if(e.structuredContent!==void 0)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(!s)return null;try{return JSON.parse(s)}catch{return null}}const Ti=6e4,Di=3e4;function Ra(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.branch?`${t.owner}:${t.branch}`:void 0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={owner:t.owner,repo:t.repo,state:"all",head:r,perPage:1},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.branch;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Di,select:Wd},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Wd(t){const e=Ks(t);if(!e||!Array.isArray(e)||e.length===0)return null;const s=e[0],i=s.base,r=s.head,n=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:n?.login??""}}function Ma(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get_files",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Di,select:Ud},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Ud(t){const e=Ks(t);return Array.isArray(e)?e.map(Vd):[]}function Vd(t){const e=Number(t.additions??0),s=Number(t.changes??e),i=Number(t.deletions??Math.max(0,s-e));return{filename:String(t.filename??""),status:t.status??"modified",additions:e,deletions:i,blobUrl:typeof t.blob_url=="string"?t.blob_url:null}}function Ia(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Di,select:Kd},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Kd(t){const e=Ks(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(qd)}function qd(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 Gd(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Di,select:Yd},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Yd(t){const e=Ks(t);return Array.isArray(e)?e.map(Xd):[]}function Xd(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 Jd(t){const e=V.c(27),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye();let l;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(l={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=l):l=e[5];const h=Ma(l);if(h.isLoading){let b;return e[6]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading files…"}),e[6]=b):b=e[6],b}if(h.isError){let b;return e[7]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load file list."}),e[7]=b):b=e[7],b}let c;e[8]!==h.data?(c=h.data??[],e[8]=h.data,e[9]=c):c=e[9];const d=c;if(d.length===0){let b;return e[10]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"text-sm text-muted-foreground",children:"No files changed."}),e[10]=b):b=e[10],b}const u=d.length===1?"":"s",m=`${s.htmlUrl}/files`;let _;e[11]!==m?(_=o.jsx("a",{href:m,target:"_blank",rel:"noreferrer",className:"underline hover:text-foreground",children:"View diffs on GitHub"}),e[11]=m,e[12]=_):_=e[12];let f;e[13]!==d.length||e[14]!==u||e[15]!==_?(f=o.jsxs("div",{className:"pb-2 text-xs text-muted-foreground",children:[d.length," file",u," changed ·"," ",_]}),e[13]=d.length,e[14]=u,e[15]=_,e[16]=f):f=e[16];let p;if(e[17]!==d||e[18]!==s.htmlUrl){let b;e[20]!==s.htmlUrl?(b=S=>o.jsx("li",{children:o.jsxs("a",{href:S.blobUrl??`${s.htmlUrl}/files`,target:"_blank",rel:"noreferrer",className:"flex items-center justify-between rounded px-2 py-1 font-mono text-xs hover:bg-muted",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(Zd,{status:S.status}),o.jsx("span",{className:"truncate",children:S.filename})]}),o.jsxs("span",{className:"flex shrink-0 items-center gap-2 tabular-nums",children:[o.jsxs("span",{children:[o.jsxs("span",{className:"text-success",children:["+",S.additions]})," ",o.jsxs("span",{className:"text-destructive",children:["−",S.deletions]})]}),o.jsx(Wt,{className:"h-3 w-3 text-muted-foreground"})]})]})},S.filename),e[20]=s.htmlUrl,e[21]=b):b=e[21],p=d.map(b),e[17]=d,e[18]=s.htmlUrl,e[19]=p}else p=e[19];let g;e[22]!==p?(g=o.jsx("ul",{className:"space-y-0.5",children:p}),e[22]=p,e[23]=g):g=e[23];let v;return e[24]!==f||e[25]!==g?(v=o.jsxs("div",{className:"flex flex-col gap-1",children:[f,g]}),e[24]=f,e[25]=g,e[26]=v):v=e[26],v}function Zd(t){const e=V.c(2),{status:s}=t,i=s==="added"?"A":s==="removed"?"D":s==="renamed"?"R":s==="copied"?"C":"M";let r;return e[0]!==i?(r=o.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded bg-muted text-[10px] font-bold text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1],r}const vt="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 Qd(t){return`Commit every pending change in the working tree with a concise conventional-commit message summarizing the diff, then push to \`origin/${t.branch}\`. If local commits are ahead of the remote, push those in the same invocation. ${vt}`}function eu(t){return`Open a pull request for \`${t.branch}\` against its base. Write a clear title and a summary of the changes so far. ${vt}`}function tu(t){return`Reopen PR #${t.prNumber}. ${vt}`}function su(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${vt}`}function iu(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. ${vt}`}function ru(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. ${vt}`}function nu(t){return`Mark PR #${t.prNumber} ready for review. ${vt}`}function ou(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. ${vt}`}function au(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. ${vt}`}function lu(t){return`Squash-merge PR #${t.prNumber} into its base. ${vt}`}function cu(t){const e=V.c(23),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye(),l=wi();let h;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(h={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=h):h=e[5];const c=Ia(h);let d;e[6]!==l||e[7]!==s.number?(d=g=>l.sendMessage({parts:[{type:"text",text:iu({prNumber:s.number,checkName:g})}]}),e[6]=l,e[7]=s.number,e[8]=d):d=e[8];const u=d;if(c.isLoading){let g;return e[9]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[9]=g):g=e[9],g}if(c.isError){let g;return e[10]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[10]=g):g=e[10],g}let m;e[11]!==c.data?(m=c.data??[],e[11]=c.data,e[12]=m):m=e[12];const _=m;if(_.length===0){let g;return e[13]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[13]=g):g=e[13],g}let f;if(e[14]!==l||e[15]!==_||e[16]!==u){let g;e[18]!==l||e[19]!==u?(g=v=>o.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(hu,{check:v}),o.jsx("span",{className:"truncate",children:v.name}),v.durationMs!=null&&o.jsx("span",{className:"text-xs text-muted-foreground",children:du(v.durationMs)})]}),o.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[v.htmlUrl&&o.jsx("a",{href:v.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:o.jsx(Wt,{className:"h-3.5 w-3.5"})}),v.conclusion==="failure"&&o.jsx(se,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(v.name),children:"Re-run"})]})]},v.id),e[18]=l,e[19]=u,e[20]=g):g=e[20],f=_.map(g),e[14]=l,e[15]=_,e[16]=u,e[17]=f}else f=e[17];let p;return e[21]!==f?(p=o.jsx("ul",{className:"flex flex-col gap-0.5",children:f}),e[21]=f,e[22]=p):p=e[22],p}function hu(t){const e=V.c(5),{check:s}=t;if(s.status!=="completed"){let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=n):n=e[0],n}if(s.conclusion==="success"){let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=n):n=e[1],n}if(s.conclusion==="failure"){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=n):n=e[2],n}const i=s.conclusion??"—";let r;return e[3]!==i?(r=o.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[3]=i,e[4]=r):r=e[4],r}function du(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}function uu(t){const e=V.c(10),{comments:s,isLoading:i,isError:r}=t;if(i||r||!s||s.length===0)return null;const n=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==n?(a=o.jsxs(Fc,{className:"py-3 text-sm font-medium",children:[s.length," comment",n]}),e[0]=s.length,e[1]=n,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(fu),e[3]=s,e[4]=l):l=e[4];let h;e[5]!==l?(h=o.jsx(Hc,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=o.jsx(Wc,{type:"single",collapsible:!0,className:"border-t border-border",children:o.jsxs(Uc,{value:"comments",className:"border-b-0",children:[a,h]})}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}function fu(t){return o.jsxs("div",{className:"rounded-md border border-border p-3",children:[o.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",mu(t.createdAt)]}),o.jsx(Xr,{id:`pr-comment-${t.id}`,text:Os(t.body)})]},t.id)}function mu(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 n=Math.floor(s/6e4);return`${Math.max(1,n)}m ago`}function _u(t){const e=V.c(18),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye();let l;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(l={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=l):l=e[5];const h=Gd(l);let c;e[6]!==s.body||e[7]!==s.number?(c=s.body&&o.jsx("div",{className:"text-sm",children:o.jsx(Xr,{id:`pr-body-${s.number}`,text:Os(s.body)})}),e[6]=s.body,e[7]=s.number,e[8]=c):c=e[8];let d;e[9]!==h.data?(d=h.data??[],e[9]=h.data,e[10]=d):d=e[10];let u;e[11]!==h.isError||e[12]!==h.isLoading||e[13]!==d?(u=o.jsx(uu,{comments:d,isLoading:h.isLoading,isError:h.isError}),e[11]=h.isError,e[12]=h.isLoading,e[13]=d,e[14]=u):u=e[14];let m;return e[15]!==c||e[16]!==u?(m=o.jsxs("div",{className:"space-y-8",children:[c,u]}),e[15]=c,e[16]=u,e[17]=m):m=e[17],m}function pu(t){const e=V.c(26),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye();let l;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(l={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=l):l=e[5];const c=Ma(l).data?.length,[d,u]=A.useState("description"),m=A.useRef({description:null,changes:null,checks:null}),[_,f]=A.useState(null),p=k=>j=>{if(m.current[k]=j,j&&k===d){const M=j.offsetLeft,R=j.offsetWidth;(_===null||M!==_.left||R!==_.width)&&f({left:M,width:R})}},g=k=>{const j=k;u(j);const M=m.current[j];M&&f({left:M.offsetLeft,width:M.offsetWidth})},v=Oi,b=p("checks");let S;e[6]!==v||e[7]!==b?(S=o.jsx(v,{ref:b,variant:"underline",value:"checks",className:"pb-3 data-[state=active]:border-transparent",children:"Checks"}),e[6]=v,e[7]=b,e[8]=S):S=e[8];let x;e[9]!==_?(x=_&&o.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-[-1px] h-0.5 bg-primary transition-[left,width] duration-200 ease-out",style:{left:_.left,width:_.width}}),e[9]=_,e[10]=x):x=e[10];let w;e[11]!==i||e[12]!==r||e[13]!==s||e[14]!==n?(w=o.jsx(zi,{value:"description",className:"mt-6",children:o.jsx(_u,{pr:s,connectionId:i,owner:r,repo:n})}),e[11]=i,e[12]=r,e[13]=s,e[14]=n,e[15]=w):w=e[15];let N;e[16]!==i||e[17]!==r||e[18]!==s||e[19]!==n?(N=o.jsx(zi,{value:"changes",className:"mt-6",children:o.jsx(Jd,{pr:s,connectionId:i,owner:r,repo:n})}),e[16]=i,e[17]=r,e[18]=s,e[19]=n,e[20]=N):N=e[20];let y;return e[21]!==i||e[22]!==r||e[23]!==s||e[24]!==n?(y=o.jsx(zi,{value:"checks",className:"mt-6",children:o.jsx(cu,{pr:s,connectionId:i,owner:r,repo:n})}),e[21]=i,e[22]=r,e[23]=s,e[24]=n,e[25]=y):y=e[25],o.jsxs(oh,{value:d,onValueChange:g,variant:"underline",children:[o.jsxs(ah,{variant:"underline",className:"relative h-auto p-0",children:[o.jsx(Oi,{ref:p("description"),variant:"underline",value:"description",className:"pb-3 data-[state=active]:border-transparent",children:"Description"}),o.jsxs(Oi,{ref:p("changes"),variant:"underline",value:"changes",className:"pb-3 data-[state=active]:border-transparent",children:["Changes",c!==void 0?` ${c}`:""]}),S,x]}),w,N,y]})}function gu(t){const e=V.c(5),{pr:s}=t,i=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Wt,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let n;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==i?(n=o.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:o.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]=n):n=e[4],n}function vu(t){const e=V.c(23),{pr:s}=t;let i;e[0]!==s.title?(i=Os(s.title),e[0]=s.title,e[1]=i):i=e[1];let r;e[2]!==i?(r=o.jsx("h1",{className:"text-2xl font-semibold",children:i}),e[2]=i,e[3]=r):r=e[3];const n=`Open PR #${s.number} on GitHub`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(Wt,{className:"h-3.5 w-3.5"}),e[4]=a):a=e[4];let l;e[5]!==s.htmlUrl||e[6]!==s.number||e[7]!==n?(l=o.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":n,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,a]}),e[5]=s.htmlUrl,e[6]=s.number,e[7]=n,e[8]=l):l=e[8];let h;e[9]!==s.author?(h=s.author&&o.jsxs(o.Fragment,{children:["@",s.author," · "]}),e[9]=s.author,e[10]=h):h=e[10];let c;e[11]!==s.base?(c=o.jsx("span",{className:"font-mono text-xs",children:s.base}),e[11]=s.base,e[12]=c):c=e[12];let d;e[13]!==s.head?(d=o.jsx("span",{className:"font-mono text-xs",children:s.head}),e[13]=s.head,e[14]=d):d=e[14];let u;e[15]!==l||e[16]!==h||e[17]!==c||e[18]!==d?(u=o.jsxs("div",{className:"text-sm text-muted-foreground",children:[l," · ",h,c," ← ",d]}),e[15]=l,e[16]=h,e[17]=c,e[18]=d,e[19]=u):u=e[19];let m;return e[20]!==r||e[21]!==u?(m=o.jsxs("div",{className:"space-y-2",children:[r,u]}),e[20]=r,e[21]=u,e[22]=m):m=e[22],m}function xu(t){const e=V.c(8),{virtualMcpId:s}=t,{org:i}=ye(),r=gt(s),{currentBranch:n}=lt(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.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]=h):h=e[0],h}if(!n){let h;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[o.jsx(Ds,{className:"h-6 w-6 text-muted-foreground"}),o.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),o.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the dropdown in the header to see PR status."})]}),e[1]=h):h=e[1],h}let l;return e[2]!==n||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==i.id?(l=o.jsx(bu,{orgId:i.id,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:n}),e[2]=n,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=i.id,e[7]=l):l=e[7],l}function bu(t){const e=V.c(49),{orgId:s,connectionId:i,owner:r,repo:n,branch:a}=t;let l;e[0]!==a||e[1]!==i||e[2]!==s||e[3]!==r||e[4]!==n?(l={orgId:s,connectionId:i,owner:r,repo:n,branch:a},e[0]=a,e[1]=i,e[2]=s,e[3]=r,e[4]=n,e[5]=l):l=e[5];const{data:h,isLoading:c,isError:d}=Ra(l),u=Su;if(c){let v;return e[6]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[6]=v):v=e[6],v}if(d){let v;return e[7]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[7]=v):v=e[7],v}const m=`https://github.com/${r}/${n}/tree/${a}`;if(h&&h.state==="closed"){let v;e[8]!==h?(v=o.jsx(gu,{pr:h}),e[8]=h,e[9]=v):v=e[9];const b=h.merged?"✓ Merged":"✗ Closed";let S;e[10]!==h.mergedAt?(S=h.mergedAt&&o.jsxs(o.Fragment,{children:[" · ",new Date(h.mergedAt).toLocaleDateString()]}),e[10]=h.mergedAt,e[11]=S):S=e[11];let x;e[12]!==h.author?(x=h.author&&o.jsxs(o.Fragment,{children:[" · by @",h.author]}),e[12]=h.author,e[13]=x):x=e[13];let w;e[14]!==h.base||e[15]!==b||e[16]!==S||e[17]!==x?(w=o.jsxs("div",{className:"text-sm text-success",children:[b," into ",h.base,S,x]}),e[14]=h.base,e[15]=b,e[16]=S,e[17]=x,e[18]=w):w=e[18];let N;e[19]!==h.title?(N=Os(h.title),e[19]=h.title,e[20]=N):N=e[20];let y;e[21]!==N?(y=o.jsx("h1",{className:"text-lg font-semibold",children:N}),e[21]=N,e[22]=y):y=e[22];let k;e[23]!==h.body||e[24]!==h.number?(k=h.body&&o.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:o.jsx(Xr,{id:`pr-body-${h.number}`,text:Os(h.body)})}),e[23]=h.body,e[24]=h.number,e[25]=k):k=e[25];let j;e[26]!==w||e[27]!==y||e[28]!==k?(j=o.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[w,y,k]}),e[26]=w,e[27]=y,e[28]=k,e[29]=j):j=e[29];let M;return e[30]!==v||e[31]!==j?(M=o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[v,j]}),e[30]=v,e[31]=j,e[32]=M):M=e[32],M}if(h&&h.state==="open"){let v;e[33]!==h?(v=o.jsx(vu,{pr:h}),e[33]=h,e[34]=v):v=e[34];let b;e[35]!==i||e[36]!==r||e[37]!==h||e[38]!==n?(b=o.jsx("div",{className:"mt-8",children:o.jsx(pu,{pr:h,connectionId:i,owner:r,repo:n})}),e[35]=i,e[36]=r,e[37]=h,e[38]=n,e[39]=b):b=e[39];let S;return e[40]!==v||e[41]!==b?(S=o.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:o.jsx("div",{className:"flex-1 overflow-auto",children:o.jsxs("div",{className:"mx-auto w-full max-w-[1200px] px-4 pt-8 pb-6 md:px-10 md:pt-12 md:pb-10",children:[v,b]})})}),e[40]=v,e[41]=b,e[42]=S):S=e[42],S}let _;e[43]===Symbol.for("react.memo_cache_sentinel")?(_=o.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[43]=_):_=e[43];let f;e[44]!==m?(f=()=>u(m),e[44]=m,e[45]=f):f=e[45];let p;e[46]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(Wt,{className:"mr-1.5 h-4 w-4"}),e[46]=p):p=e[46];let g;return e[47]!==f?(g=o.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[_,o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs(se,{size:"sm",variant:"outline",onClick:f,children:[p,"Open branch on GitHub"]})})]}),e[47]=f,e[48]=g):g=e[48],g}function Su(t){window.open(t,"_blank","noopener,noreferrer")}const Wi="env";function yu(){const t=V.c(13),e=Mt();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=Yr(s).main===Wi;let n;t[1]!==e?(n=m=>{e({search:(_=>({..._,main:m})),replace:!0})},t[1]=e,t[2]=n):n=t[2];const a=n;let l;t[3]!==r||t[4]!==a?(l=()=>{a(r?"0":Wi)},t[3]=r,t[4]=a,t[5]=l):l=t[5];const h=l;let c;t[6]!==r||t[7]!==a?(c=()=>{r||a(Wi)},t[6]=r,t[7]=a,t[8]=c):c=t[8];const d=c;let u;return t[9]!==r||t[10]!==d||t[11]!==h?(u={envOpen:r,toggleEnv:h,openEnv:d},t[9]=r,t[10]=d,t[11]=h,t[12]=u):u=t[12],u}const wu=Ai({tag:ct(),id:ct(),classes:ct(),text:ct(),html:ct(),manifestKey:ct().nullable(),componentName:ct().nullable(),parents:ct(),url:ct(),path:ct(),viewport:Ai({width:Js(),height:Js()}),position:Ai({x:Js(),y:Js()})}),Cu=`(function() {
34
+ ${Z}`:Z;l.setValue("metadata.instructions",Y,{shouldDirty:!0})},I=new Set(h.map(P=>P.connection_id)),F=Mt(),[U,K]=A.useState(!1),G=async()=>{M();try{await i.delete.mutateAsync(t.id),Se("agent_deleted",{agent_id:t.id,source:"agent_detail"}),me.success(`Deleted "${t.title}"`),F({to:"/$org",params:{org:s.slug}})}catch{}};return o.jsxs(at,{children:[o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&o.jsx(at.Title,{actions:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(se,{variant:"outline",size:"sm",onClick:b,children:[o.jsx(oi,{size:14,className:"!size-[14px]"}),"Test Agent"]}),o.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>K(!0),children:o.jsx(hr,{size:14})})]}),children:"Settings"}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Xt,{name:"icon",control:l.control,render:({field:P})=>o.jsx(id,{value:P.value??null,onChange:Z=>{P.onChange(Z),D()},onColorChange:Z=>{l.setValue("metadata.ui.themeColor",Z,{shouldDirty:!0}),D()},name:l.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2",disabled:c})}),o.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[o.jsx(Xt,{name:"title",control:l.control,render:({field:P})=>o.jsx("input",{...P,type:"text",value:P.value??"",onBlur:()=>{P.onBlur(),D()},disabled:c,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"})}),o.jsx(Xt,{name:"description",control:l.control,render:({field:P})=>o.jsx("input",{...P,type:"text",value:P.value??"",onBlur:()=>{P.onBlur(),D()},disabled:c,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"})})]}),o.jsxs(se,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Se("agent_connect_modal_opened",{agent_id:t.id}),u({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[o.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[o.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),o.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:o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),o.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-muted-foreground",children:[o.jsx(ca,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx("span",{className:"text-sm",children:new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]}),o.jsxs("section",{className:"flex flex-col gap-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&o.jsxs(se,{variant:"outline",size:"sm",onClick:R,children:[o.jsx(cs,{size:14}),"Add connection"]})]}),o.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?o.jsxs("button",{type:"button",onClick:R,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:[o.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:o.jsx(cs,{size:16})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map(P=>o.jsx(Qt,{fallback:()=>null,children:o.jsx(A.Suspense,{fallback:o.jsx(Ra,{}),children:o.jsx(Ad,{connection_id:P.connection_id,usedConnectionIds:I,onOpenSettings:()=>O(P.connection_id),onRemove:()=>L(P.connection_id),onAuthenticate:$,onSwitchInstance:z,onNewInstance:()=>B(P.connection_id)})})},P.connection_id))})]}),o.jsxs("section",{className:"flex flex-col gap-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),!c&&o.jsxs("div",{className:"flex items-center gap-2",children:[!l.watch("metadata.instructions")?.trim()&&o.jsx(se,{variant:"outline",size:"sm",onClick:W,children:"+ Prompt template"}),o.jsxs(se,{variant:"outline",size:"sm",disabled:!l.watch("metadata.instructions")?.trim(),onClick:v,children:[o.jsx(ya,{size:13}),"Improve"]})]})]}),o.jsx(Xt,{name:"metadata.instructions",control:l.control,render:({field:P})=>o.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(Rn,{...P,value:P.value??"",onBlur:()=>{P.onBlur(),D()},disabled:c,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"}}),o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>_(!0),"aria-label":"Open fullscreen editor",children:o.jsx(xc,{size:14})})}),o.jsx(qe,{side:"left",children:"Fullscreen"})]})]})})]}),o.jsx($d,{virtualMcpId:t.id}),o.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),o.jsxs(se,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>K(!0),children:[o.jsx(hr,{size:14}),"Delete agent"]})]})]})})}),o.jsx(ua,{open:U,onOpenChange:K,children:o.jsxs(fa,{children:[o.jsxs(ma,{children:[o.jsx(_a,{children:"Delete Agent?"}),o.jsxs(pa,{children:["This action cannot be undone. This will permanently delete"," ",o.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),o.jsxs(ga,{children:[o.jsx(va,{children:"Cancel"}),o.jsx(xa,{onClick:G,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),o.jsx(Fl,{open:d.addDialogOpen,onOpenChange:P=>u({type:"SET_ADD_DIALOG_OPEN",payload:P}),agentId:t.id,addedConnectionIds:I,onAdd:E}),o.jsx(Cd,{open:d.settingsDialogOpen,onOpenChange:P=>{P||u({type:"CLOSE_SETTINGS"})},selectedId:d.settingsConnectionId,form:l,connections:h,onAuthenticate:$}),o.jsx(Id,{open:d.shareDialogOpen,onOpenChange:P=>u({type:"SET_SHARE_DIALOG_OPEN",payload:P}),virtualMcp:t}),o.jsx(tn,{open:m,onOpenChange:_,children:o.jsxs(en,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[o.jsx(ba,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:o.jsx(Sa,{children:"Instructions"})}),o.jsx("div",{className:"flex-1 min-h-0 p-6",children:o.jsx(Xt,{name:"metadata.instructions",control:l.control,render:({field:P})=>o.jsx(Rn,{...P,value:P.value??"",onBlur:()=>{P.onBlur(),D()},disabled:c,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 Hd(t){const e=V.c(9),{virtualMcpId:s,hideOwnTitle:i}=t,r=Mt(),{org:n}=ye(),a=gt(s);if(!a){let c;return e[0]!==r||e[1]!==n.slug?(c=o.jsx("div",{className:"flex h-full w-full bg-background",children:o.jsx(Ps,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:o.jsx(se,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:n.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=n.slug,e[2]=c):c=e[2],c}let l;e[3]!==a?(l=Bt(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let h;return e[5]!==i||e[6]!==l||e[7]!==a?(h=o.jsx(Fd,{virtualMcp:a,hideOwnTitle:i},l),e[5]=i,e[6]=l,e[7]=a,e[8]=h):h=e[8],h}function zn(t){const e=V.c(2),{virtualMcpId:s}=t;let i;return e[0]!==s?(i=o.jsx(Hd,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=i):i=e[1],i}const Wd={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function Os(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 Wd[s]??e}):""}function Ks(t){if(!t||typeof t!="object")return null;const e=t;if(e.structuredContent!==void 0)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(!s)return null;try{return JSON.parse(s)}catch{return null}}const Ti=6e4,Ri=3e4;function Da(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.branch?`${t.owner}:${t.branch}`:void 0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={owner:t.owner,repo:t.repo,state:"all",head:r,perPage:1},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.branch;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Ri,select:Ud},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Ud(t){const e=Ks(t);if(!e||!Array.isArray(e)||e.length===0)return null;const s=e[0],i=s.base,r=s.head,n=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:n?.login??""}}function Ma(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get_files",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Ri,select:Vd},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Vd(t){const e=Ks(t);return Array.isArray(e)?e.map(Kd):[]}function Kd(t){const e=Number(t.additions??0),s=Number(t.changes??e),i=Number(t.deletions??Math.max(0,s-e));return{filename:String(t.filename??""),status:t.status??"modified",additions:e,deletions:i,blobUrl:typeof t.blob_url=="string"?t.blob_url:null}}function Ia(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Ri,select:qd},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function qd(t){const e=Ks(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Gd)}function Gd(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 Yd(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Ti,refetchIntervalInBackground:!1,staleTime:Ri,select:Xd},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function Xd(t){const e=Ks(t);return Array.isArray(e)?e.map(Jd):[]}function Jd(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 Zd(t){const e=V.c(27),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye();let l;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(l={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=l):l=e[5];const h=Ma(l);if(h.isLoading){let b;return e[6]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading files…"}),e[6]=b):b=e[6],b}if(h.isError){let b;return e[7]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load file list."}),e[7]=b):b=e[7],b}let c;e[8]!==h.data?(c=h.data??[],e[8]=h.data,e[9]=c):c=e[9];const d=c;if(d.length===0){let b;return e[10]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"text-sm text-muted-foreground",children:"No files changed."}),e[10]=b):b=e[10],b}const u=d.length===1?"":"s",m=`${s.htmlUrl}/files`;let _;e[11]!==m?(_=o.jsx("a",{href:m,target:"_blank",rel:"noreferrer",className:"underline hover:text-foreground",children:"View diffs on GitHub"}),e[11]=m,e[12]=_):_=e[12];let f;e[13]!==d.length||e[14]!==u||e[15]!==_?(f=o.jsxs("div",{className:"pb-2 text-xs text-muted-foreground",children:[d.length," file",u," changed ·"," ",_]}),e[13]=d.length,e[14]=u,e[15]=_,e[16]=f):f=e[16];let p;if(e[17]!==d||e[18]!==s.htmlUrl){let b;e[20]!==s.htmlUrl?(b=S=>o.jsx("li",{children:o.jsxs("a",{href:S.blobUrl??`${s.htmlUrl}/files`,target:"_blank",rel:"noreferrer",className:"flex items-center justify-between rounded px-2 py-1 font-mono text-xs hover:bg-muted",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(Qd,{status:S.status}),o.jsx("span",{className:"truncate",children:S.filename})]}),o.jsxs("span",{className:"flex shrink-0 items-center gap-2 tabular-nums",children:[o.jsxs("span",{children:[o.jsxs("span",{className:"text-success",children:["+",S.additions]})," ",o.jsxs("span",{className:"text-destructive",children:["−",S.deletions]})]}),o.jsx(Wt,{className:"h-3 w-3 text-muted-foreground"})]})]})},S.filename),e[20]=s.htmlUrl,e[21]=b):b=e[21],p=d.map(b),e[17]=d,e[18]=s.htmlUrl,e[19]=p}else p=e[19];let g;e[22]!==p?(g=o.jsx("ul",{className:"space-y-0.5",children:p}),e[22]=p,e[23]=g):g=e[23];let v;return e[24]!==f||e[25]!==g?(v=o.jsxs("div",{className:"flex flex-col gap-1",children:[f,g]}),e[24]=f,e[25]=g,e[26]=v):v=e[26],v}function Qd(t){const e=V.c(2),{status:s}=t,i=s==="added"?"A":s==="removed"?"D":s==="renamed"?"R":s==="copied"?"C":"M";let r;return e[0]!==i?(r=o.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded bg-muted text-[10px] font-bold text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1],r}const vt="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 eu(t){return`Commit every pending change in the working tree with a concise conventional-commit message summarizing the diff, then push to \`origin/${t.branch}\`. If local commits are ahead of the remote, push those in the same invocation. ${vt}`}function tu(t){return`Open a pull request for \`${t.branch}\` against its base. Write a clear title and a summary of the changes so far. ${vt}`}function su(t){return`Reopen PR #${t.prNumber}. ${vt}`}function iu(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${vt}`}function ru(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. ${vt}`}function nu(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. ${vt}`}function ou(t){return`Mark PR #${t.prNumber} ready for review. ${vt}`}function au(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. ${vt}`}function lu(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. ${vt}`}function cu(t){return`Squash-merge PR #${t.prNumber} into its base. ${vt}`}function hu(t){const e=V.c(23),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye(),l=wi();let h;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(h={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=h):h=e[5];const c=Ia(h);let d;e[6]!==l||e[7]!==s.number?(d=g=>l.sendMessage({parts:[{type:"text",text:ru({prNumber:s.number,checkName:g})}]}),e[6]=l,e[7]=s.number,e[8]=d):d=e[8];const u=d;if(c.isLoading){let g;return e[9]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[9]=g):g=e[9],g}if(c.isError){let g;return e[10]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[10]=g):g=e[10],g}let m;e[11]!==c.data?(m=c.data??[],e[11]=c.data,e[12]=m):m=e[12];const _=m;if(_.length===0){let g;return e[13]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[13]=g):g=e[13],g}let f;if(e[14]!==l||e[15]!==_||e[16]!==u){let g;e[18]!==l||e[19]!==u?(g=v=>o.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(du,{check:v}),o.jsx("span",{className:"truncate",children:v.name}),v.durationMs!=null&&o.jsx("span",{className:"text-xs text-muted-foreground",children:uu(v.durationMs)})]}),o.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[v.htmlUrl&&o.jsx("a",{href:v.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:o.jsx(Wt,{className:"h-3.5 w-3.5"})}),v.conclusion==="failure"&&o.jsx(se,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(v.name),children:"Re-run"})]})]},v.id),e[18]=l,e[19]=u,e[20]=g):g=e[20],f=_.map(g),e[14]=l,e[15]=_,e[16]=u,e[17]=f}else f=e[17];let p;return e[21]!==f?(p=o.jsx("ul",{className:"flex flex-col gap-0.5",children:f}),e[21]=f,e[22]=p):p=e[22],p}function du(t){const e=V.c(5),{check:s}=t;if(s.status!=="completed"){let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=n):n=e[0],n}if(s.conclusion==="success"){let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=n):n=e[1],n}if(s.conclusion==="failure"){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=n):n=e[2],n}const i=s.conclusion??"—";let r;return e[3]!==i?(r=o.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[3]=i,e[4]=r):r=e[4],r}function uu(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}function fu(t){const e=V.c(10),{comments:s,isLoading:i,isError:r}=t;if(i||r||!s||s.length===0)return null;const n=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==n?(a=o.jsxs(Fc,{className:"py-3 text-sm font-medium",children:[s.length," comment",n]}),e[0]=s.length,e[1]=n,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(mu),e[3]=s,e[4]=l):l=e[4];let h;e[5]!==l?(h=o.jsx(Hc,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=o.jsx(Wc,{type:"single",collapsible:!0,className:"border-t border-border",children:o.jsxs(Uc,{value:"comments",className:"border-b-0",children:[a,h]})}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}function mu(t){return o.jsxs("div",{className:"rounded-md border border-border p-3",children:[o.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",_u(t.createdAt)]}),o.jsx(Xr,{id:`pr-comment-${t.id}`,text:Os(t.body)})]},t.id)}function _u(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 n=Math.floor(s/6e4);return`${Math.max(1,n)}m ago`}function pu(t){const e=V.c(18),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye();let l;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(l={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=l):l=e[5];const h=Yd(l);let c;e[6]!==s.body||e[7]!==s.number?(c=s.body&&o.jsx("div",{className:"text-sm",children:o.jsx(Xr,{id:`pr-body-${s.number}`,text:Os(s.body)})}),e[6]=s.body,e[7]=s.number,e[8]=c):c=e[8];let d;e[9]!==h.data?(d=h.data??[],e[9]=h.data,e[10]=d):d=e[10];let u;e[11]!==h.isError||e[12]!==h.isLoading||e[13]!==d?(u=o.jsx(fu,{comments:d,isLoading:h.isLoading,isError:h.isError}),e[11]=h.isError,e[12]=h.isLoading,e[13]=d,e[14]=u):u=e[14];let m;return e[15]!==c||e[16]!==u?(m=o.jsxs("div",{className:"space-y-8",children:[c,u]}),e[15]=c,e[16]=u,e[17]=m):m=e[17],m}function gu(t){const e=V.c(26),{pr:s,connectionId:i,owner:r,repo:n}=t,{org:a}=ye();let l;e[0]!==i||e[1]!==a.id||e[2]!==r||e[3]!==s.number||e[4]!==n?(l={orgId:a.id,connectionId:i,owner:r,repo:n,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=r,e[3]=s.number,e[4]=n,e[5]=l):l=e[5];const c=Ma(l).data?.length,[d,u]=A.useState("description"),m=A.useRef({description:null,changes:null,checks:null}),[_,f]=A.useState(null),p=k=>j=>{if(m.current[k]=j,j&&k===d){const M=j.offsetLeft,D=j.offsetWidth;(_===null||M!==_.left||D!==_.width)&&f({left:M,width:D})}},g=k=>{const j=k;u(j);const M=m.current[j];M&&f({left:M.offsetLeft,width:M.offsetWidth})},v=Oi,b=p("checks");let S;e[6]!==v||e[7]!==b?(S=o.jsx(v,{ref:b,variant:"underline",value:"checks",className:"pb-3 data-[state=active]:border-transparent",children:"Checks"}),e[6]=v,e[7]=b,e[8]=S):S=e[8];let x;e[9]!==_?(x=_&&o.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-[-1px] h-0.5 bg-primary transition-[left,width] duration-200 ease-out",style:{left:_.left,width:_.width}}),e[9]=_,e[10]=x):x=e[10];let w;e[11]!==i||e[12]!==r||e[13]!==s||e[14]!==n?(w=o.jsx(zi,{value:"description",className:"mt-6",children:o.jsx(pu,{pr:s,connectionId:i,owner:r,repo:n})}),e[11]=i,e[12]=r,e[13]=s,e[14]=n,e[15]=w):w=e[15];let N;e[16]!==i||e[17]!==r||e[18]!==s||e[19]!==n?(N=o.jsx(zi,{value:"changes",className:"mt-6",children:o.jsx(Zd,{pr:s,connectionId:i,owner:r,repo:n})}),e[16]=i,e[17]=r,e[18]=s,e[19]=n,e[20]=N):N=e[20];let y;return e[21]!==i||e[22]!==r||e[23]!==s||e[24]!==n?(y=o.jsx(zi,{value:"checks",className:"mt-6",children:o.jsx(hu,{pr:s,connectionId:i,owner:r,repo:n})}),e[21]=i,e[22]=r,e[23]=s,e[24]=n,e[25]=y):y=e[25],o.jsxs(oh,{value:d,onValueChange:g,variant:"underline",children:[o.jsxs(ah,{variant:"underline",className:"relative h-auto p-0",children:[o.jsx(Oi,{ref:p("description"),variant:"underline",value:"description",className:"pb-3 data-[state=active]:border-transparent",children:"Description"}),o.jsxs(Oi,{ref:p("changes"),variant:"underline",value:"changes",className:"pb-3 data-[state=active]:border-transparent",children:["Changes",c!==void 0?` ${c}`:""]}),S,x]}),w,N,y]})}function vu(t){const e=V.c(5),{pr:s}=t,i=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Wt,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let n;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==i?(n=o.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:o.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]=n):n=e[4],n}function xu(t){const e=V.c(23),{pr:s}=t;let i;e[0]!==s.title?(i=Os(s.title),e[0]=s.title,e[1]=i):i=e[1];let r;e[2]!==i?(r=o.jsx("h1",{className:"text-2xl font-semibold",children:i}),e[2]=i,e[3]=r):r=e[3];const n=`Open PR #${s.number} on GitHub`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(Wt,{className:"h-3.5 w-3.5"}),e[4]=a):a=e[4];let l;e[5]!==s.htmlUrl||e[6]!==s.number||e[7]!==n?(l=o.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":n,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,a]}),e[5]=s.htmlUrl,e[6]=s.number,e[7]=n,e[8]=l):l=e[8];let h;e[9]!==s.author?(h=s.author&&o.jsxs(o.Fragment,{children:["@",s.author," · "]}),e[9]=s.author,e[10]=h):h=e[10];let c;e[11]!==s.base?(c=o.jsx("span",{className:"font-mono text-xs",children:s.base}),e[11]=s.base,e[12]=c):c=e[12];let d;e[13]!==s.head?(d=o.jsx("span",{className:"font-mono text-xs",children:s.head}),e[13]=s.head,e[14]=d):d=e[14];let u;e[15]!==l||e[16]!==h||e[17]!==c||e[18]!==d?(u=o.jsxs("div",{className:"text-sm text-muted-foreground",children:[l," · ",h,c," ← ",d]}),e[15]=l,e[16]=h,e[17]=c,e[18]=d,e[19]=u):u=e[19];let m;return e[20]!==r||e[21]!==u?(m=o.jsxs("div",{className:"space-y-2",children:[r,u]}),e[20]=r,e[21]=u,e[22]=m):m=e[22],m}function bu(t){const e=V.c(8),{virtualMcpId:s}=t,{org:i}=ye(),r=gt(s),{currentBranch:n}=lt(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.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]=h):h=e[0],h}if(!n){let h;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[o.jsx(Rs,{className:"h-6 w-6 text-muted-foreground"}),o.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),o.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the dropdown in the header to see PR status."})]}),e[1]=h):h=e[1],h}let l;return e[2]!==n||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==i.id?(l=o.jsx(Su,{orgId:i.id,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:n}),e[2]=n,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=i.id,e[7]=l):l=e[7],l}function Su(t){const e=V.c(49),{orgId:s,connectionId:i,owner:r,repo:n,branch:a}=t;let l;e[0]!==a||e[1]!==i||e[2]!==s||e[3]!==r||e[4]!==n?(l={orgId:s,connectionId:i,owner:r,repo:n,branch:a},e[0]=a,e[1]=i,e[2]=s,e[3]=r,e[4]=n,e[5]=l):l=e[5];const{data:h,isLoading:c,isError:d}=Da(l),u=yu;if(c){let v;return e[6]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[6]=v):v=e[6],v}if(d){let v;return e[7]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[7]=v):v=e[7],v}const m=`https://github.com/${r}/${n}/tree/${a}`;if(h&&h.state==="closed"){let v;e[8]!==h?(v=o.jsx(vu,{pr:h}),e[8]=h,e[9]=v):v=e[9];const b=h.merged?"✓ Merged":"✗ Closed";let S;e[10]!==h.mergedAt?(S=h.mergedAt&&o.jsxs(o.Fragment,{children:[" · ",new Date(h.mergedAt).toLocaleDateString()]}),e[10]=h.mergedAt,e[11]=S):S=e[11];let x;e[12]!==h.author?(x=h.author&&o.jsxs(o.Fragment,{children:[" · by @",h.author]}),e[12]=h.author,e[13]=x):x=e[13];let w;e[14]!==h.base||e[15]!==b||e[16]!==S||e[17]!==x?(w=o.jsxs("div",{className:"text-sm text-success",children:[b," into ",h.base,S,x]}),e[14]=h.base,e[15]=b,e[16]=S,e[17]=x,e[18]=w):w=e[18];let N;e[19]!==h.title?(N=Os(h.title),e[19]=h.title,e[20]=N):N=e[20];let y;e[21]!==N?(y=o.jsx("h1",{className:"text-lg font-semibold",children:N}),e[21]=N,e[22]=y):y=e[22];let k;e[23]!==h.body||e[24]!==h.number?(k=h.body&&o.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:o.jsx(Xr,{id:`pr-body-${h.number}`,text:Os(h.body)})}),e[23]=h.body,e[24]=h.number,e[25]=k):k=e[25];let j;e[26]!==w||e[27]!==y||e[28]!==k?(j=o.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[w,y,k]}),e[26]=w,e[27]=y,e[28]=k,e[29]=j):j=e[29];let M;return e[30]!==v||e[31]!==j?(M=o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[v,j]}),e[30]=v,e[31]=j,e[32]=M):M=e[32],M}if(h&&h.state==="open"){let v;e[33]!==h?(v=o.jsx(xu,{pr:h}),e[33]=h,e[34]=v):v=e[34];let b;e[35]!==i||e[36]!==r||e[37]!==h||e[38]!==n?(b=o.jsx("div",{className:"mt-8",children:o.jsx(gu,{pr:h,connectionId:i,owner:r,repo:n})}),e[35]=i,e[36]=r,e[37]=h,e[38]=n,e[39]=b):b=e[39];let S;return e[40]!==v||e[41]!==b?(S=o.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:o.jsx("div",{className:"flex-1 overflow-auto",children:o.jsxs("div",{className:"mx-auto w-full max-w-[1200px] px-4 pt-8 pb-6 md:px-10 md:pt-12 md:pb-10",children:[v,b]})})}),e[40]=v,e[41]=b,e[42]=S):S=e[42],S}let _;e[43]===Symbol.for("react.memo_cache_sentinel")?(_=o.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[43]=_):_=e[43];let f;e[44]!==m?(f=()=>u(m),e[44]=m,e[45]=f):f=e[45];let p;e[46]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(Wt,{className:"mr-1.5 h-4 w-4"}),e[46]=p):p=e[46];let g;return e[47]!==f?(g=o.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[_,o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs(se,{size:"sm",variant:"outline",onClick:f,children:[p,"Open branch on GitHub"]})})]}),e[47]=f,e[48]=g):g=e[48],g}function yu(t){window.open(t,"_blank","noopener,noreferrer")}const Wi="env";function wu(){const t=V.c(13),e=Mt();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=Yr(s).main===Wi;let n;t[1]!==e?(n=m=>{e({search:(_=>({..._,main:m})),replace:!0})},t[1]=e,t[2]=n):n=t[2];const a=n;let l;t[3]!==r||t[4]!==a?(l=()=>{a(r?"0":Wi)},t[3]=r,t[4]=a,t[5]=l):l=t[5];const h=l;let c;t[6]!==r||t[7]!==a?(c=()=>{r||a(Wi)},t[6]=r,t[7]=a,t[8]=c):c=t[8];const d=c;let u;return t[9]!==r||t[10]!==d||t[11]!==h?(u={envOpen:r,toggleEnv:h,openEnv:d},t[9]=r,t[10]=d,t[11]=h,t[12]=u):u=t[12],u}const Cu=Ai({tag:ct(),id:ct(),classes:ct(),text:ct(),html:ct(),manifestKey:ct().nullable(),componentName:ct().nullable(),parents:ct(),url:ct(),path:ct(),viewport:Ai({width:Js(),height:Js()}),position:Ai({x:Js(),y:Js()})}),ku=`(function() {
35
35
  if (window.__visualEditorActive) return;
36
36
  window.__visualEditorActive = true;
37
37
 
@@ -153,9 +153,9 @@ ${Z}`:Z;l.setValue("metadata.instructions",Y,{shouldDirty:!0})},I=new Set(h.map(
153
153
  window.__visualEditorActive = false;
154
154
  }
155
155
  });
156
- })();`;function qt(t){return t.replace(/[`*_]/g,"\\$&")}function ku(t,e){const s=[`The user selected an element on the live preview and asked: **"${qt(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:** \`${qt(t.manifestKey)}\``,"");const i=`<${t.tag}${t.classes?` class="${qt(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${i}\``),t.parents&&s.push(`**DOM breadcrumb:** ${qt(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${qt(t.text)}"`),t.componentName&&s.push(`**Component name:** ${qt(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(`
157
- `)}function Nu(t,e,s=320,i=44,r=12){const{x:n,y:a}=t,{width:l,height:h}=e,c=Math.max(r,Math.min(n-s/2,l-s-r)),u=a/h>.68?Math.max(r,a-i-18):Math.min(a+18,h-i-r);return{leftPct:c/l*100,topPct:u/h*100}}function ju(t){const e=V.c(32),{element:s,onDismiss:i}=t,[r,n]=A.useState(""),a=A.useRef(null),{sendMessage:l}=wi(),{setChatOpen:h}=Zr();let c;e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==h?(c=()=>{if(!r.trim())return;const M=ku(s,r);h(!0),l({parts:[{type:"text",text:M}]}),i()},e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=h,e[5]=c):c=e[5];const d=c;let u;e[6]!==s.position||e[7]!==s.viewport?(u=Nu(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const m=u,_=`${m.leftPct}%`,f=`${m.topPct}%`;let p;e[9]!==_||e[10]!==f?(p={left:_,top:f,width:"320px"},e[9]=_,e[10]=f,e[11]=p):p=e[11];let g;e[12]!==d?(g=M=>{M.preventDefault(),d()},e[12]=d,e[13]=g):g=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=M=>n(M.target.value),e[14]=v):v=e[14];let b;e[15]!==i?(b=M=>{M.key==="Escape"&&i()},e[15]=i,e[16]=b):b=e[16];let S;e[17]!==r||e[18]!==b?(S=o.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:b,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]=b,e[19]=S):S=e[19];let x;e[20]!==r?(x=r.trim(),e[20]=r,e[21]=x):x=e[21];const w=!x;let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[o.jsx("title",{children:"Send"}),o.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=N):N=e[22];let y;e[23]!==w?(y=o.jsx("button",{type:"submit",disabled:w,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:N}),e[23]=w,e[24]=y):y=e[24];let k;e[25]!==y||e[26]!==g||e[27]!==S?(k=o.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:g,children:[S,y]}),e[25]=y,e[26]=g,e[27]=S,e[28]=k):k=e[28];let j;return e[29]!==k||e[30]!==p?(j=o.jsx("div",{className:"absolute z-30 pointer-events-none",style:p,children:k}),e[29]=k,e[30]=p,e[31]=j):j=e[31],j}const Eu={phase:null,status:{ready:!1,htmlSupport:!1},suspended:!1,notFound:!1,scripts:[],activeProcesses:[],branchStatus:null,getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},Ba=A.createContext(Eu),$n=16384;class Tu{data="";append(e){this.data+=e,this.data.length>$n&&(this.data=this.data.slice(this.data.length-$n))}get(){return this.data}clear(){this.data=""}}const Du=6e4,Ru=1e3,Mu=3e4,Iu=["log","status","scripts","processes","reload","branch-status"];function Bu({virtualMcpId:t,branch:e,children:s}){const{org:i}=ye(),[r,n]=A.useState(null),[a,l]=A.useState({ready:!1,htmlSupport:!1}),[h,c]=A.useState(!1),[d,u]=A.useState(!1),[m,_]=A.useState([]),[f,p]=A.useState([]),[g,v]=A.useState(null),[,b]=A.useState(0),S=A.useRef(new Map),x=A.useRef(new Set),w=A.useRef(new Set),N=k=>{let j=S.current.get(k);return j||(j=new Tu,S.current.set(k,j)),j};A.useEffect(()=>{if(n(null),l({ready:!1,htmlSupport:!1}),c(!1),u(!1),_([]),p([]),v(null),S.current.clear(),!t||!e)return;const k=`/api/vm-events?virtualMcpId=${encodeURIComponent(t)}&branch=${encodeURIComponent(e)}&x-org-id=${encodeURIComponent(i.id)}`;let j=!1,M=0,R=null,T=null,C=null,D=!1;const E=()=>{T||(T=setTimeout(()=>{c(!0)},Du))},L=()=>{T&&(clearTimeout(T),T=null)},z=I=>{try{const F=JSON.parse(I.data);n(F),F.kind!=="failed"&&u(!1),F.kind==="failed"&&(D=!0,C?.close())}catch(F){console.warn("[vm-events] bad phase payload",F)}},B=()=>{u(!0),n(null),l({ready:!1,htmlSupport:!1}),_([]),p([]),v(null),S.current.clear()},O=I=>{try{const F=JSON.parse(I.data);if(I.type==="log"&&typeof F.data=="string"){const U=F.source,K=F.data.replace(/\r?\n/g,`\r
158
- `);N(U).append(K);for(const G of x.current)try{G(U,K)}catch{}b(G=>G+1)}else if(I.type==="status")l({ready:!!F.ready,htmlSupport:!!F.htmlSupport});else if(I.type==="scripts")_(F.scripts??[]);else if(I.type==="processes")p(F.active??[]);else if(I.type==="reload")for(const U of w.current)try{U()}catch{}else I.type==="branch-status"&&v({branch:String(F.branch??""),base:String(F.base??"main"),workingTreeDirty:!!F.workingTreeDirty,unpushed:Number(F.unpushed??0),aheadOfBase:Number(F.aheadOfBase??0),behindBase:Number(F.behindBase??0),headSha:String(F.headSha??"")})}catch{}};function $(){if(!(j||D)){C=new EventSource(k),C.onopen=()=>{M=0,L(),c(!1)},C.onerror=()=>{C?.readyState===EventSource.CLOSED&&(D||(E(),W()))},C.addEventListener("phase",z),C.addEventListener("gone",B);for(const I of Iu)C.addEventListener(I,O)}}function W(){if(j||R||D)return;const I=Math.min(Ru*2**M,Mu);M++,R=setTimeout(()=>{R=null,!j&&(C?.close(),$())},I)}return $(),()=>{j=!0,C?.close(),R&&clearTimeout(R),L()}},[t,e,i.id]);const y={phase:r,status:a,suspended:h,notFound:d,scripts:m,activeProcesses:f,branchStatus:g,getBuffer:k=>S.current.get(k)?.get()??"",hasData:k=>(S.current.get(k)?.get().length??0)>0,subscribeChunks:k=>(x.current.add(k),()=>{x.current.delete(k)}),subscribeReload:k=>(w.current.add(k),()=>{w.current.delete(k)})};return o.jsx(Ba,{value:y,children:s})}function ms(){return A.use(Ba)}function Au(t){const{subscribeChunks:e}=ms(),s=A.useRef(t);s.current=t,A.useEffect(()=>e((n,a)=>{s.current?.(n,a)}),[e])}function Pu(t){const{subscribeReload:e}=ms(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function Aa(t){const e=V.c(5),{onResume:s,label:i}=t,r=i===void 0?"Resume Server":i;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("p",{className:"text-sm text-muted-foreground",children:"VM suspended due to inactivity."}),e[0]=n):n=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(sa,{size:14}),e[1]=a):a=e[1];let l;return e[2]!==r||e[3]!==s?(l=o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[n,o.jsxs(se,{onClick:s,children:[a,r]})]}),e[2]=r,e[3]=s,e[4]=l):l=e[4],l}const Ui=[{key:"sandbox",label:"Setting up your workspace"},{key:"setup",label:"Installing packages"},{key:"server",label:"Starting your preview"}],ft="bg-foreground/[0.05]",ot="bg-foreground/[0.09]",Lu=Array.from({length:35},()=>Math.random()*1.8),Ou=Array.from({length:35},()=>Math.random()<.4);function zu(t,e,s){return s.length>0?2:t||e.length>0?1:0}function $u(t){return t.replace(/\u001b\[[0-9;?]*[a-zA-Z]/g,"")}function Fu(t,e){const s=[...e,"setup"];for(const i of s){const r=t(i);if(!r)continue;const n=$u(r).split(/\r\n|\r|\n/);for(let a=n.length-1;a>=0;a--){const l=n[a]?.trim();if(l)return l}}return null}function Hu({hasSetupData:t,scripts:e,activeProcesses:s,onViewLogs:i,claimPhase:r,onRetry:n}){if(r!=null)return o.jsx(Yu,{phase:r,onRetry:n,onViewLogs:i});const a=zu(t,e,s),l=Ui[a]?.label??Ui[0].label,{getBuffer:h}=ms(),c=Fu(h,s);return o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none gap-8",children:[o.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:[o.jsx(Qo,{}),o.jsxs("span",{className:"text-[13px] font-medium text-foreground/85 animate-in fade-in duration-500",children:[l,"…"]},Ui[a]?.key??"sandbox")]}),o.jsxs("div",{className:"relative w-[min(78%,560px)] aspect-[4/3]",children:[o.jsx(Vi,{phase:0,current:a,children:o.jsx(Wu,{})}),o.jsx(Vi,{phase:1,current:a,children:o.jsx(Uu,{})}),o.jsx(Vi,{phase:2,current:a,children:o.jsx(Ku,{})})]}),o.jsxs("div",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 flex flex-col items-center gap-1 max-w-[80%] min-w-0",children:[c&&o.jsx("span",{className:"block w-full max-w-[440px] truncate text-center text-xs font-mono text-muted-foreground/45 animate-in fade-in duration-300",children:c},c),o.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors duration-200",children:[o.jsx(mi,{size:11}),"View logs"]})]}),o.jsx("style",{children:`
156
+ })();`;function qt(t){return t.replace(/[`*_]/g,"\\$&")}function Nu(t,e){const s=[`The user selected an element on the live preview and asked: **"${qt(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:** \`${qt(t.manifestKey)}\``,"");const i=`<${t.tag}${t.classes?` class="${qt(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${i}\``),t.parents&&s.push(`**DOM breadcrumb:** ${qt(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${qt(t.text)}"`),t.componentName&&s.push(`**Component name:** ${qt(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(`
157
+ `)}function ju(t,e,s=320,i=44,r=12){const{x:n,y:a}=t,{width:l,height:h}=e,c=Math.max(r,Math.min(n-s/2,l-s-r)),u=a/h>.68?Math.max(r,a-i-18):Math.min(a+18,h-i-r);return{leftPct:c/l*100,topPct:u/h*100}}function Eu(t){const e=V.c(32),{element:s,onDismiss:i}=t,[r,n]=A.useState(""),a=A.useRef(null),{sendMessage:l}=wi(),{setChatOpen:h}=Zr();let c;e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==h?(c=()=>{if(!r.trim())return;const M=Nu(s,r);h(!0),l({parts:[{type:"text",text:M}]}),i()},e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=h,e[5]=c):c=e[5];const d=c;let u;e[6]!==s.position||e[7]!==s.viewport?(u=ju(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const m=u,_=`${m.leftPct}%`,f=`${m.topPct}%`;let p;e[9]!==_||e[10]!==f?(p={left:_,top:f,width:"320px"},e[9]=_,e[10]=f,e[11]=p):p=e[11];let g;e[12]!==d?(g=M=>{M.preventDefault(),d()},e[12]=d,e[13]=g):g=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=M=>n(M.target.value),e[14]=v):v=e[14];let b;e[15]!==i?(b=M=>{M.key==="Escape"&&i()},e[15]=i,e[16]=b):b=e[16];let S;e[17]!==r||e[18]!==b?(S=o.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:b,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]=b,e[19]=S):S=e[19];let x;e[20]!==r?(x=r.trim(),e[20]=r,e[21]=x):x=e[21];const w=!x;let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[o.jsx("title",{children:"Send"}),o.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=N):N=e[22];let y;e[23]!==w?(y=o.jsx("button",{type:"submit",disabled:w,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:N}),e[23]=w,e[24]=y):y=e[24];let k;e[25]!==y||e[26]!==g||e[27]!==S?(k=o.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:g,children:[S,y]}),e[25]=y,e[26]=g,e[27]=S,e[28]=k):k=e[28];let j;return e[29]!==k||e[30]!==p?(j=o.jsx("div",{className:"absolute z-30 pointer-events-none",style:p,children:k}),e[29]=k,e[30]=p,e[31]=j):j=e[31],j}const Tu={phase:null,status:{ready:!1,htmlSupport:!1},suspended:!1,notFound:!1,scripts:[],activeProcesses:[],branchStatus:null,getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},Ba=A.createContext(Tu),$n=16384;class Ru{data="";append(e){this.data+=e,this.data.length>$n&&(this.data=this.data.slice(this.data.length-$n))}get(){return this.data}clear(){this.data=""}}const Du=6e4,Mu=1e3,Iu=3e4,Bu=["log","status","scripts","processes","reload","branch-status"];function Au({virtualMcpId:t,branch:e,children:s}){const{org:i}=ye(),[r,n]=A.useState(null),[a,l]=A.useState({ready:!1,htmlSupport:!1}),[h,c]=A.useState(!1),[d,u]=A.useState(!1),[m,_]=A.useState([]),[f,p]=A.useState([]),[g,v]=A.useState(null),[,b]=A.useState(0),S=A.useRef(new Map),x=A.useRef(new Set),w=A.useRef(new Set),N=k=>{let j=S.current.get(k);return j||(j=new Ru,S.current.set(k,j)),j};A.useEffect(()=>{if(n(null),l({ready:!1,htmlSupport:!1}),c(!1),u(!1),_([]),p([]),v(null),S.current.clear(),!t||!e)return;const k=`/api/vm-events?virtualMcpId=${encodeURIComponent(t)}&branch=${encodeURIComponent(e)}&x-org-id=${encodeURIComponent(i.id)}`;let j=!1,M=0,D=null,T=null,C=null,R=!1;const E=()=>{T||(T=setTimeout(()=>{c(!0)},Du))},L=()=>{T&&(clearTimeout(T),T=null)},z=I=>{try{const F=JSON.parse(I.data);n(F),F.kind!=="failed"&&u(!1),F.kind==="failed"&&(R=!0,C?.close())}catch(F){console.warn("[vm-events] bad phase payload",F)}},B=()=>{u(!0),n(null),l({ready:!1,htmlSupport:!1}),_([]),p([]),v(null),S.current.clear()},O=I=>{try{const F=JSON.parse(I.data);if(I.type==="log"&&typeof F.data=="string"){const U=F.source,K=F.data.replace(/\r?\n/g,`\r
158
+ `);N(U).append(K);for(const G of x.current)try{G(U,K)}catch{}b(G=>G+1)}else if(I.type==="status")l({ready:!!F.ready,htmlSupport:!!F.htmlSupport});else if(I.type==="scripts")_(F.scripts??[]);else if(I.type==="processes")p(F.active??[]);else if(I.type==="reload")for(const U of w.current)try{U()}catch{}else I.type==="branch-status"&&v({branch:String(F.branch??""),base:String(F.base??"main"),workingTreeDirty:!!F.workingTreeDirty,unpushed:Number(F.unpushed??0),aheadOfBase:Number(F.aheadOfBase??0),behindBase:Number(F.behindBase??0),headSha:String(F.headSha??"")})}catch{}};function $(){if(!(j||R)){C=new EventSource(k),C.onopen=()=>{M=0,L(),c(!1)},C.onerror=()=>{C?.readyState===EventSource.CLOSED&&(R||(E(),W()))},C.addEventListener("phase",z),C.addEventListener("gone",B);for(const I of Bu)C.addEventListener(I,O)}}function W(){if(j||D||R)return;const I=Math.min(Mu*2**M,Iu);M++,D=setTimeout(()=>{D=null,!j&&(C?.close(),$())},I)}return $(),()=>{j=!0,C?.close(),D&&clearTimeout(D),L()}},[t,e,i.id]);const y={phase:r,status:a,suspended:h,notFound:d,scripts:m,activeProcesses:f,branchStatus:g,getBuffer:k=>S.current.get(k)?.get()??"",hasData:k=>(S.current.get(k)?.get().length??0)>0,subscribeChunks:k=>(x.current.add(k),()=>{x.current.delete(k)}),subscribeReload:k=>(w.current.add(k),()=>{w.current.delete(k)})};return o.jsx(Ba,{value:y,children:s})}function ms(){return A.use(Ba)}function Pu(t){const{subscribeChunks:e}=ms(),s=A.useRef(t);s.current=t,A.useEffect(()=>e((n,a)=>{s.current?.(n,a)}),[e])}function Lu(t){const{subscribeReload:e}=ms(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function Aa(t){const e=V.c(5),{onResume:s,label:i}=t,r=i===void 0?"Resume Server":i;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("p",{className:"text-sm text-muted-foreground",children:"VM suspended due to inactivity."}),e[0]=n):n=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(sa,{size:14}),e[1]=a):a=e[1];let l;return e[2]!==r||e[3]!==s?(l=o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[n,o.jsxs(se,{onClick:s,children:[a,r]})]}),e[2]=r,e[3]=s,e[4]=l):l=e[4],l}const Ui=[{key:"sandbox",label:"Setting up your workspace"},{key:"setup",label:"Installing packages"},{key:"server",label:"Starting your preview"}],ft="bg-foreground/[0.05]",ot="bg-foreground/[0.09]",Ou=Array.from({length:35},()=>Math.random()*1.8),zu=Array.from({length:35},()=>Math.random()<.4);function $u(t,e,s){return s.length>0?2:t||e.length>0?1:0}function Fu(t){return t.replace(/\u001b\[[0-9;?]*[a-zA-Z]/g,"")}function Hu(t,e){const s=[...e,"setup"];for(const i of s){const r=t(i);if(!r)continue;const n=Fu(r).split(/\r\n|\r|\n/);for(let a=n.length-1;a>=0;a--){const l=n[a]?.trim();if(l)return l}}return null}function Wu({hasSetupData:t,scripts:e,activeProcesses:s,onViewLogs:i,claimPhase:r,onRetry:n}){if(r!=null)return o.jsx(Xu,{phase:r,onRetry:n,onViewLogs:i});const a=$u(t,e,s),l=Ui[a]?.label??Ui[0].label,{getBuffer:h}=ms(),c=Hu(h,s);return o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none gap-8",children:[o.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:[o.jsx(Qo,{}),o.jsxs("span",{className:"text-[13px] font-medium text-foreground/85 animate-in fade-in duration-500",children:[l,"…"]},Ui[a]?.key??"sandbox")]}),o.jsxs("div",{className:"relative w-[min(78%,560px)] aspect-[4/3]",children:[o.jsx(Vi,{phase:0,current:a,children:o.jsx(Uu,{})}),o.jsx(Vi,{phase:1,current:a,children:o.jsx(Vu,{})}),o.jsx(Vi,{phase:2,current:a,children:o.jsx(qu,{})})]}),o.jsxs("div",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 flex flex-col items-center gap-1 max-w-[80%] min-w-0",children:[c&&o.jsx("span",{className:"block w-full max-w-[440px] truncate text-center text-xs font-mono text-muted-foreground/45 animate-in fade-in duration-300",children:c},c),o.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors duration-200",children:[o.jsx(mi,{size:11}),"View logs"]})]}),o.jsx("style",{children:`
159
159
  @keyframes vm-pulse-soft {
160
160
  0%, 100% { opacity: 0.25; }
161
161
  50% { opacity: 1; }
@@ -164,26 +164,26 @@ ${Z}`:Z;l.setValue("metadata.instructions",Y,{shouldDirty:!0})},I=new Set(h.map(
164
164
  0%, 100% { opacity: 0.5; }
165
165
  50% { opacity: 1; }
166
166
  }
167
- `})]})}function Vi(t){const e=V.c(10),{phase:s,current:i,children:r}=t,n=s-i,a=n<0,l=n===0,h=a?90:n*-22,c=a?.94:1-Math.max(n,0)*.04,d=a?0:l?1:n===1?.8:.55,u=a?10:30-n,m=!l;let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=te("absolute inset-0 rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] overflow-hidden transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=_):_=e[0];const f=`translateY(${h}px) scale(${c})`,p=l?"auto":"none";let g;e[1]!==d||e[2]!==f||e[3]!==p||e[4]!==u?(g={transform:f,opacity:d,zIndex:u,transitionDuration:"1000ms",pointerEvents:p},e[1]=d,e[2]=f,e[3]=p,e[4]=u,e[5]=g):g=e[5];let v;return e[6]!==r||e[7]!==m||e[8]!==g?(v=o.jsx("div",{"aria-hidden":m,className:_,style:g,children:r}),e[6]=r,e[7]=m,e[8]=g,e[9]=v):v=e[9],v}function nn(t){const e=V.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,n,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:te("w-2.5 h-2.5 rounded-full",ot)}),n=o.jsx("div",{className:te("w-2.5 h-2.5 rounded-full",ot)}),a=o.jsx("div",{className:te("w-2.5 h-2.5 rounded-full",ot)}),e[0]=r,e[1]=n,e[2]=a):(r=e[0],n=e[1],a=e[2]);let l;e[3]!==i?(l=i&&o.jsx("div",{className:te("ml-3 h-3.5 flex-1 max-w-[220px] rounded-sm",ft)}),e[3]=i,e[4]=l):l=e[4];let h;return e[5]!==l?(h=o.jsxs("div",{className:"h-7 flex items-center gap-1.5 px-3 shrink-0",children:[r,n,a,l]}),e[5]=l,e[6]=h):h=e[6],h}function Wu(){const t=V.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(nn,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx("div",{className:te("w-[18%] rounded-md",ft),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=o.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=o.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 n;return t[4]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsxs("div",{className:"flex h-full flex-col",children:[e,o.jsxs("div",{className:"flex flex-1 min-h-0 gap-1.5 p-3",children:[s,o.jsxs("div",{className:"flex-1 flex flex-col gap-1.5 min-w-0",children:[i,o.jsxs("div",{className:"flex-1 grid grid-cols-5 gap-1.5 min-h-0",children:[r,o.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[o.jsx("div",{className:te("rounded-md",ft),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),o.jsx("div",{className:te("rounded-md",ft),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=n):n=t[4],n}function Uu(){const t=V.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(nn,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex h-full flex-col",children:[e,o.jsx("div",{className:"relative flex-1 flex items-center justify-center px-8 py-5",children:o.jsx("div",{className:"grid gap-2 w-full",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:Lu.map(Vu)})})]}),t[1]=s):s=t[1],s}function Vu(t,e){return o.jsx("div",{className:te("aspect-square rounded-md",Ou[e]?"bg-chart-2/70":ot),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function Ku(){const t=V.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(nn,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,n,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx("div",{className:"h-5 rounded-md mb-2 bg-chart-1/[0.10]"}),i=o.jsx("div",{className:te("h-1.5 rounded-sm w-[70%]",ot)}),r=o.jsx("div",{className:te("h-1.5 rounded-sm w-[55%]",ot)}),n=o.jsx("div",{className:te("h-1.5 rounded-sm w-[80%]",ot)}),a=o.jsx("div",{className:te("h-1.5 rounded-sm w-[50%]",ot)}),t[1]=s,t[2]=i,t[3]=r,t[4]=n,t[5]=a):(s=t[1],i=t[2],r=t[3],n=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsxs("div",{className:"w-[18%] p-2.5 flex flex-col gap-1.5 shrink-0 bg-chart-1/[0.05]",children:[s,i,r,n,a,o.jsx("div",{className:"mt-auto",children:o.jsx("div",{className:te("h-4 rounded-md",ot)})})]}),t[6]=l):l=t[6];let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:o.jsxs("div",{className:"absolute bottom-3 left-3 right-3 space-y-1.5",children:[o.jsx("div",{className:"h-3 rounded-sm w-[35%] bg-chart-1/[0.15]"}),o.jsx("div",{className:te("h-1.5 rounded-sm w-[55%]",ft)})]})}),t[7]=h):h=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[o.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),o.jsx("div",{className:te("h-4 w-10 rounded-full",ft)}),o.jsx("div",{className:te("h-4 w-14 rounded-full",ft)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs("div",{className:te("col-span-3 rounded-md flex flex-col justify-end p-2 gap-1",ft),children:[o.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",ot)}),o.jsx("div",{className:te("h-1 w-[75%] rounded-sm",ot)})]}),t[9]=d):d=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"flex h-full flex-col",children:[e,o.jsxs("div",{className:"flex flex-1 min-h-0",children:[l,o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h,o.jsxs("div",{className:"flex-1 p-3 flex flex-col gap-2.5 min-h-0",children:[c,o.jsxs("div",{className:"flex-1 grid grid-cols-5 gap-2 min-h-0",children:[d,o.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[o.jsx("div",{className:te("rounded-md",ft)}),o.jsx("div",{className:te("rounded-md",ft)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}const qu={claiming:{headline:"Reserving sandbox",body:"Posting your claim to the cluster…"},"waiting-for-capacity":{headline:"Waiting for cluster capacity",body:"The cluster may need to provision a new node — typically 60–90s."},"pulling-image":{headline:"Downloading sandbox image",body:"First boot on this node — subsequent runs reuse the cached image."},"starting-container":{headline:"Starting your sandbox"},"warming-daemon":{headline:"Connecting to your sandbox"}};function Gu(t){switch(t.reason){case"image-pull-backoff":return{headline:"Sandbox image failed to download",body:t.message};case"crash-loop-backoff":return{headline:"Sandbox crashed during startup",body:t.message};case"scheduling-timeout":return{headline:"Couldn't get cluster capacity in time",body:t.message};case"claim-never-created":return{headline:"Sandbox claim was never posted",body:t.message};case"reconciler-error":return{headline:"Sandbox controller reported an error",body:t.message};default:return{headline:"Sandbox failed to start",body:t.message}}}function Yu(t){const e=V.c(36),{phase:s,onRetry:i,onViewLogs:r}=t;if(s.kind==="failed"){let p;e[0]!==s?(p=Gu(s),e[0]=s,e[1]=p):p=e[1];const g=p;let v;e[2]!==g.headline?(v=o.jsx("span",{className:"text-sm font-medium text-foreground",children:g.headline}),e[2]=g.headline,e[3]=v):v=e[3];let b;e[4]!==g.body?(b=o.jsx("span",{className:"text-xs text-muted-foreground",children:g.body}),e[4]=g.body,e[5]=b):b=e[5];let S;e[6]!==v||e[7]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center gap-2 text-center max-w-[440px]",children:[v,b]}),e[6]=v,e[7]=b,e[8]=S):S=e[8];let x;e[9]!==i?(x=i&&o.jsx("button",{type:"button",onClick:i,className:"rounded-md border border-foreground/15 bg-background px-3 py-1.5 text-xs font-medium hover:bg-foreground/[0.04] transition-colors",children:"Try again"}),e[9]=i,e[10]=x):x=e[10];let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(mi,{size:11}),e[11]=w):w=e[11];let N;e[12]!==r?(N=o.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 text-xs text-muted-foreground/60 hover:text-muted-foreground transition-colors duration-200",children:[w,"View logs"]}),e[12]=r,e[13]=N):N=e[13];let y;return e[14]!==S||e[15]!==x||e[16]!==N?(y=o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none gap-6 px-6",children:[S,x,N]}),e[14]=S,e[15]=x,e[16]=N,e[17]=y):y=e[17],y}let n;e[18]!==s.kind?(n=s.kind==="ready"?{headline:"Almost ready",body:void 0}:qu[s.kind],e[18]=s.kind,e[19]=n):n=e[19];const a=n;let l;e[20]!==a.body||e[21]!==s?(l=s.kind==="ready"?void 0:Xu(s)??a.body,e[20]=a.body,e[21]=s,e[22]=l):l=e[22];const h=l;let c;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx(Qo,{}),e[23]=c):c=e[23];let d;e[24]!==a.headline||e[25]!==s.kind?(d=o.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:[c,o.jsxs("span",{className:"text-[13px] font-medium text-foreground/85 animate-in fade-in duration-500",children:[a.headline,"…"]},s.kind)]}),e[24]=a.headline,e[25]=s.kind,e[26]=d):d=e[26];let u;e[27]!==h?(u=h&&o.jsx("span",{className:"block max-w-[440px] truncate text-center text-xs text-muted-foreground/70 animate-in fade-in duration-300",children:h},h),e[27]=h,e[28]=u):u=e[28];let m;e[29]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx(mi,{size:11}),e[29]=m):m=e[29];let _;e[30]!==r?(_=o.jsxs("button",{type:"button",onClick:r,className:"absolute bottom-5 left-1/2 -translate-x-1/2 flex items-center gap-1.5 text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors duration-200",children:[m,"View logs"]}),e[30]=r,e[31]=_):_=e[31];let f;return e[32]!==d||e[33]!==u||e[34]!==_?(f=o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none gap-6",children:[d,u,_]}),e[32]=d,e[33]=u,e[34]=_,e[35]=f):f=e[35],f}function Xu(t){if(t.kind==="waiting-for-capacity"&&t.nodeClaim)return`Provisioning node ${t.nodeClaim}…`}function Pa(t){const e=V.c(21),{errorMsg:s,onRetry:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsxs("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 z-20 flex items-center gap-2 rounded-full border border-destructive/30 bg-background/80 px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)] backdrop-blur-md",children:[o.jsx(as,{size:13,className:"text-destructive/80"}),o.jsx("span",{className:"text-[13px] font-medium text-destructive/90",children:"Failed to start"})]}),e[0]=r):r=e[0];let n,a;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"absolute left-[8%] right-[8%] -top-5 h-full rounded-xl border border-foreground/[0.05] bg-foreground/[0.015]"}),a=o.jsx("div",{className:"absolute left-[4%] right-[4%] -top-2.5 h-full rounded-xl border border-foreground/[0.07] bg-foreground/[0.025]"}),e[1]=n,e[2]=a):(n=e[1],a=e[2]);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsxs("div",{className:"h-7 border-b border-foreground/[0.08] bg-foreground/[0.015] flex items-center gap-1.5 px-3",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground/10"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground/10"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground/10"}),o.jsx("div",{className:"ml-3 h-3.5 flex-1 max-w-[240px] rounded-sm bg-foreground/[0.04]"})]}),e[3]=l):l=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(as,{size:14,className:"text-destructive/80 mt-0.5 shrink-0"}),e[4]=h):h=e[4];let c;e[5]!==s?(c=o.jsxs("div",{className:"flex items-start gap-2",children:[h,o.jsx("p",{className:"text-xs text-destructive/80 line-clamp-5 break-all leading-relaxed font-mono",children:s})]}),e[5]=s,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ko,{size:12}),e[7]=d):d=e[7];let u;e[8]!==i?(u=o.jsxs(se,{variant:"outline",size:"sm",onClick:i,children:[d,"Retry"]}),e[8]=i,e[9]=u):u=e[9];let m;e[10]!==s?(m=()=>navigator.clipboard.writeText(s).then(Ju),e[10]=s,e[11]=m):m=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ci,{size:10}),e[12]=_):_=e[12];let f;e[13]!==m?(f=o.jsxs("button",{type:"button",onClick:m,className:"flex items-center gap-1 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors duration-200",children:[_,"Copy error"]}),e[13]=m,e[14]=f):f=e[14];let p;e[15]!==f||e[16]!==u?(p=o.jsxs("div",{className:"flex items-center gap-2",children:[u,f]}),e[15]=f,e[16]=u,e[17]=p):p=e[17];let g;return e[18]!==p||e[19]!==c?(g=o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none",children:[r,o.jsxs("div",{className:"relative w-[min(78%,560px)] aspect-[4/3] mt-6 opacity-60",children:[n,a,o.jsxs("div",{className:"relative w-full h-full rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] overflow-hidden",children:[l,o.jsx("div",{className:"flex items-center justify-center p-6 h-[calc(100%-1.75rem)]",children:o.jsxs("div",{className:"w-full max-w-sm rounded-lg border border-destructive/20 bg-destructive/[0.03] p-4 space-y-3",children:[c,p]})})]})]})]}),e[18]=p,e[19]=c,e[20]=g):g=e[20],g}function Ju(){me.success("Error copied to clipboard")}const Zu=[{value:"preview",icon:o.jsx(ra,{size:14}),tooltip:"Interactive"},{value:"visual",icon:o.jsx(na,{size:14}),tooltip:"Visual Editor"}];function Qu(){const t=pn(),{data:e}=Si.useSession(),{openEnv:s}=yu(),{taskId:i,currentBranch:r,setCurrentTaskBranch:n}=lt(),[a,l]=A.useState("preview"),[h,c]=A.useState(null),d=A.useRef(null),u=e?.user?.id,m=t?.entity?.metadata,_=u&&r?m?.vmMap?.[u]?.[r]:void 0,f=_?.previewUrl??null,p=ms();Pu(()=>{const P=d.current;P&&(P.src=P.src)});const g=p.status.htmlSupport,v=p.suspended,b=A.useRef({url:"",at:0,ready:!1});f&&b.current.url!==f&&(b.current={url:f,at:_?.createdAt??Date.now(),ready:!1}),f&&p.status.ready&&!b.current.ready&&(b.current.ready=!0);const S=!!f&&!b.current.ready&&!v,x=A.useRef(0),w=t?.entity?.id??null,N=Fe({connectionId:It,orgId:t?.entity?.organization_id??""}),y=sn(N),k=y.error?.message??null,j=Ea(w??void 0,r??void 0);j?x.current||(x.current=Date.now()):f&&(x.current=0);const M=j&&!f&&!v,R=A.useRef(null),T=A.useRef(null),C=p.phase,D=!f&&!!C&&C.kind!=="failed",E=P=>{if(!w)return;const Z={virtualMcpId:w};r&&(Z.branch=r),y.mutate(Z,{onSuccess:Y=>{Y?.branch&&!r&&n(Y.branch)},onError:Y=>{console.error(`[preview] ${P} VM_START failed`,Y)}})},L=A.useRef(E);L.current=E,i&&_&&R.current!==i&&(R.current=i);const z=!!i&&!!w&&!!u&&!!r&&!_&&!k&&!y.isPending&&R.current!==i;A.useEffect(()=>{!z||!i||(R.current=i,L.current("auto-start"))},[z,i]);const B=p.notFound?_?.vmId??null:null;A.useEffect(()=>{!B||!w||k||y.isPending||T.current!==B&&(T.current=B,L.current("self-heal"))},[B,w,k,y.isPending]);const O=()=>{R.current=null,T.current=null,y.reset(),L.current("auto-start")};A.useEffect(()=>{if(!f)return;let P;try{P=new URL(f,window.location.href).origin}catch{return}const Z=Y=>{if(Y.origin!==P||Y.data?.type!=="visual-editor::element-clicked")return;const ee=wu.safeParse(Y.data.payload);ee.success&&c(ee.data)};return window.addEventListener("message",Z),()=>window.removeEventListener("message",Z)},[f]);const $=()=>{const P=d.current?.contentWindow;P&&P.postMessage({type:"visual-editor::activate",script:Cu},"*")},W=()=>{const P=d.current?.contentWindow;P&&P.postMessage({type:"visual-editor::deactivate"},"*")},I=P=>{l(P),c(null),P==="visual"?$():W()},F=()=>{if(!d.current)return;const P=d.current;P.src=P.src},U=()=>{if(!d.current||!f)return;const P=f.includes("?")?"&":"?";d.current.src=`${f}${P}_r=${Date.now()}`},K=()=>{const P=d.current?.contentWindow?.location?.href??f;P&&navigator.clipboard.writeText(P)},G=(()=>{if(!f)return"No server running";try{const P=new URL(f);return`${P.host}${P.pathname==="/"?"":P.pathname}`}catch{return f}})();return o.jsxs("div",{className:"flex flex-col w-full h-full",children:[f&&o.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[g&&o.jsx(mh,{value:a,onValueChange:I,options:Zu,size:"sm",className:"shrink-0 bg-foreground/[0.045]"}),o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-0.5",children:[o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:()=>d.current?.contentWindow?.history.back(),children:o.jsx(ka,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Back"})]}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:()=>d.current?.contentWindow?.history.forward(),children:o.jsx(Zl,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Forward"})]}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:F,children:o.jsx(Ko,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Refresh"})]}),o.jsx("div",{className:"flex h-8 min-w-0 flex-1 items-center rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",children:o.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-foreground/88",children:G})})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:()=>window.open(f,"_blank","noopener"),children:o.jsx(Wt,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Open in new tab"})]}),o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",children:o.jsx(ia,{size:14})})}),o.jsxs(os,{align:"end",children:[o.jsx(yt,{onClick:U,children:"Hard Reload"}),o.jsx(yt,{onClick:K,children:"Copy Current URL"})]})]})]})]}),o.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[!f&&!M&&!k&&!D&&o.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-4 bg-background",children:[o.jsx(ra,{size:48,className:"text-muted-foreground/40"}),o.jsx("h3",{className:"text-lg font-medium",children:"Preview"}),o.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-sm",children:"Start the development server to see a live preview"}),o.jsxs(se,{onClick:s,children:[o.jsx(sa,{size:14}),"Start Server"]})]}),k&&o.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-background",children:o.jsx(Pa,{errorMsg:k,onRetry:O})}),!k&&v&&o.jsx("div",{className:"absolute inset-0 z-30 bg-background/80 backdrop-blur-sm",children:o.jsx(Aa,{onResume:s})}),!k&&(S||M||D||p.notFound)&&o.jsx("div",{className:"absolute inset-0 z-30 flex items-center justify-center bg-background",children:o.jsx(Hu,{since:S?b.current.at:x.current,hasSetupData:p.hasData("setup"),scripts:p.scripts,activeProcesses:p.activeProcesses,onViewLogs:s,claimPhase:f?null:C,onRetry:O})}),a==="visual"&&!h&&o.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:[o.jsx(na,{size:12}),"Click any element to ask the AI"]}),a==="visual"&&h&&o.jsx(ju,{element:h,onDismiss:()=>c(null)}),f&&!S&&!p.notFound&&o.jsx("iframe",{ref:d,src:f,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{Se("vm_preview_loaded",{view_mode:a,vm_id:_?.vmId??null}),a==="visual"&&$()}},f)]})]})}function ef(t){const e=V.c(2),{virtualMcpId:s}=t,i=gt(s);if(!(i?Bt(i):null)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[o.jsx(as,{size:24,className:"text-muted-foreground/60"}),o.jsx("div",{children:"No repository connected."}),o.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 n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(Qu,{}),e[1]=n):n=e[1],n}var La=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,sf=(t,e)=>{for(var s in e)La(t,s,{get:e[s],enumerable:!0})},ke=(t,e,s,i)=>{for(var r=i>1?void 0:i?tf(e,s):e,n=t.length-1,a;n>=0;n--)(a=t[n])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&La(e,s,r),r},J=(t,e)=>(s,i)=>e(s,i,t),Fn="Terminal input",ur={get:()=>Fn,set:t=>Fn=t},Hn="Too much output to announce, navigate to rows manually to read",fr={get:()=>Hn,set:t=>Hn=t};function rf(t){return t.replace(/\r?\n/g,"\r")}function nf(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function of(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function af(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Oa(r,e,s,i)}}function Oa(t,e,s,i){t=rf(t),t=nf(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function za(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,n=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function Wn(t,e,s,i,r){za(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Et(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Ri(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let n=t[r];n>65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var lf=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 n=t.charCodeAt(r++);56320<=n&&n<=57343?e[i++]=(this._interim-55296)*1024+n-56320+65536:(e[i++]=this._interim,e[i++]=n),this._interim=0}for(let n=r;n<s;++n){let a=t.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=s)return this._interim=a,i;let l=t.charCodeAt(n);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}},cf=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,n,a,l,h=0,c=0;if(this.interim[0]){let m=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)_<<=6,_|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-f;for(;c<v;){if(c>=s)return 0;if(p=t[c++],(p&192)!==128){c--,m=!0;break}else this.interim[f++]=p,_<<=6,_|=p&63}m||(g===2?_<128?c--:e[i++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(e[i++]=_):_<65536||_>1114111||(e[i++]=_)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((r=t[u])&128)&&!((n=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=n,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(n=t[u++],(n&192)!==128){u--;continue}if(h=(r&31)<<6|n&63,h<128){u--;continue}e[i++]=h}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(n=t[u++],(n&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=n,i;if(a=t[u++],(a&192)!==128){u--;continue}if(h=(r&15)<<12|(n&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(n=t[u++],(n&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=n,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(h=(r&7)<<18|(n&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},$a="",Tt=" ",qs=class Fa{constructor(){this.fg=0,this.bg=0,this.extended=new _i}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 Fa;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}},_i=class Ha{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 Ha(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},nt=class Wa extends qs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _i,this.combinedData=""}static fromCharData(e){let s=new Wa;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?Et(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()]}},Un="di$target",mr="di$dependencies",Ki=new Map;function hf(t){return t[mr]||[]}function ze(t){if(Ki.has(t))return Ki.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");df(e,s,r)};return e._id=t,Ki.set(t,e),e}function df(t,e,s){e[Un]===e?e[mr].push({id:t,index:s}):(e[mr]=[{id:t,index:s}],e[Un]=e)}var Ge=ze("BufferService"),Ua=ze("CoreMouseService"),Ut=ze("CoreService"),uf=ze("CharsetService"),on=ze("InstantiationService"),Va=ze("LogService"),Ye=ze("OptionsService"),Ka=ze("OscLinkService"),ff=ze("UnicodeService"),Gs=ze("DecorationService"),_r=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,n=new nt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=d,l=n.extended.urlId;continue}else c=n.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let m={start:{x:h+1,y:t},end:{x:d+(!c&&d===a-1?1:0),y:t}},_=!1;if(!r?.allowNonHttpProtocols)try{let f=new URL(u);["http:","https:"].includes(f.protocol)||(_=!0)}catch{_=!0}_||i.push({text:u,range:m,activate:(f,p)=>r?r.activate(f,p,m):mf(f,p),hover:(f,p)=>r?.hover?.(f,p,m),leave:(f,p)=>r?.leave?.(f,p,m)})}c=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,l=n.extended.urlId):(h=-1,l=-1)}}e(i)}};_r=ke([J(0,Ge),J(1,Ye),J(2,Ka)],_r);function mf(t,e){if(confirm(`Do you want to navigate to ${e}?
167
+ `})]})}function Vi(t){const e=V.c(10),{phase:s,current:i,children:r}=t,n=s-i,a=n<0,l=n===0,h=a?90:n*-22,c=a?.94:1-Math.max(n,0)*.04,d=a?0:l?1:n===1?.8:.55,u=a?10:30-n,m=!l;let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=te("absolute inset-0 rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] overflow-hidden transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=_):_=e[0];const f=`translateY(${h}px) scale(${c})`,p=l?"auto":"none";let g;e[1]!==d||e[2]!==f||e[3]!==p||e[4]!==u?(g={transform:f,opacity:d,zIndex:u,transitionDuration:"1000ms",pointerEvents:p},e[1]=d,e[2]=f,e[3]=p,e[4]=u,e[5]=g):g=e[5];let v;return e[6]!==r||e[7]!==m||e[8]!==g?(v=o.jsx("div",{"aria-hidden":m,className:_,style:g,children:r}),e[6]=r,e[7]=m,e[8]=g,e[9]=v):v=e[9],v}function nn(t){const e=V.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,n,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:te("w-2.5 h-2.5 rounded-full",ot)}),n=o.jsx("div",{className:te("w-2.5 h-2.5 rounded-full",ot)}),a=o.jsx("div",{className:te("w-2.5 h-2.5 rounded-full",ot)}),e[0]=r,e[1]=n,e[2]=a):(r=e[0],n=e[1],a=e[2]);let l;e[3]!==i?(l=i&&o.jsx("div",{className:te("ml-3 h-3.5 flex-1 max-w-[220px] rounded-sm",ft)}),e[3]=i,e[4]=l):l=e[4];let h;return e[5]!==l?(h=o.jsxs("div",{className:"h-7 flex items-center gap-1.5 px-3 shrink-0",children:[r,n,a,l]}),e[5]=l,e[6]=h):h=e[6],h}function Uu(){const t=V.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(nn,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx("div",{className:te("w-[18%] rounded-md",ft),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=o.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=o.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 n;return t[4]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsxs("div",{className:"flex h-full flex-col",children:[e,o.jsxs("div",{className:"flex flex-1 min-h-0 gap-1.5 p-3",children:[s,o.jsxs("div",{className:"flex-1 flex flex-col gap-1.5 min-w-0",children:[i,o.jsxs("div",{className:"flex-1 grid grid-cols-5 gap-1.5 min-h-0",children:[r,o.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[o.jsx("div",{className:te("rounded-md",ft),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),o.jsx("div",{className:te("rounded-md",ft),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=n):n=t[4],n}function Vu(){const t=V.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(nn,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex h-full flex-col",children:[e,o.jsx("div",{className:"relative flex-1 flex items-center justify-center px-8 py-5",children:o.jsx("div",{className:"grid gap-2 w-full",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:Ou.map(Ku)})})]}),t[1]=s):s=t[1],s}function Ku(t,e){return o.jsx("div",{className:te("aspect-square rounded-md",zu[e]?"bg-chart-2/70":ot),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function qu(){const t=V.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(nn,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,n,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx("div",{className:"h-5 rounded-md mb-2 bg-chart-1/[0.10]"}),i=o.jsx("div",{className:te("h-1.5 rounded-sm w-[70%]",ot)}),r=o.jsx("div",{className:te("h-1.5 rounded-sm w-[55%]",ot)}),n=o.jsx("div",{className:te("h-1.5 rounded-sm w-[80%]",ot)}),a=o.jsx("div",{className:te("h-1.5 rounded-sm w-[50%]",ot)}),t[1]=s,t[2]=i,t[3]=r,t[4]=n,t[5]=a):(s=t[1],i=t[2],r=t[3],n=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsxs("div",{className:"w-[18%] p-2.5 flex flex-col gap-1.5 shrink-0 bg-chart-1/[0.05]",children:[s,i,r,n,a,o.jsx("div",{className:"mt-auto",children:o.jsx("div",{className:te("h-4 rounded-md",ot)})})]}),t[6]=l):l=t[6];let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:o.jsxs("div",{className:"absolute bottom-3 left-3 right-3 space-y-1.5",children:[o.jsx("div",{className:"h-3 rounded-sm w-[35%] bg-chart-1/[0.15]"}),o.jsx("div",{className:te("h-1.5 rounded-sm w-[55%]",ft)})]})}),t[7]=h):h=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[o.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),o.jsx("div",{className:te("h-4 w-10 rounded-full",ft)}),o.jsx("div",{className:te("h-4 w-14 rounded-full",ft)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs("div",{className:te("col-span-3 rounded-md flex flex-col justify-end p-2 gap-1",ft),children:[o.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",ot)}),o.jsx("div",{className:te("h-1 w-[75%] rounded-sm",ot)})]}),t[9]=d):d=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"flex h-full flex-col",children:[e,o.jsxs("div",{className:"flex flex-1 min-h-0",children:[l,o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h,o.jsxs("div",{className:"flex-1 p-3 flex flex-col gap-2.5 min-h-0",children:[c,o.jsxs("div",{className:"flex-1 grid grid-cols-5 gap-2 min-h-0",children:[d,o.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[o.jsx("div",{className:te("rounded-md",ft)}),o.jsx("div",{className:te("rounded-md",ft)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}const Gu={claiming:{headline:"Reserving sandbox",body:"Posting your claim to the cluster…"},"waiting-for-capacity":{headline:"Waiting for cluster capacity",body:"The cluster may need to provision a new node — typically 60–90s."},"pulling-image":{headline:"Downloading sandbox image",body:"First boot on this node — subsequent runs reuse the cached image."},"starting-container":{headline:"Starting your sandbox"},"warming-daemon":{headline:"Connecting to your sandbox"}};function Yu(t){switch(t.reason){case"image-pull-backoff":return{headline:"Sandbox image failed to download",body:t.message};case"crash-loop-backoff":return{headline:"Sandbox crashed during startup",body:t.message};case"scheduling-timeout":return{headline:"Couldn't get cluster capacity in time",body:t.message};case"claim-never-created":return{headline:"Sandbox claim was never posted",body:t.message};case"reconciler-error":return{headline:"Sandbox controller reported an error",body:t.message};default:return{headline:"Sandbox failed to start",body:t.message}}}function Xu(t){const e=V.c(36),{phase:s,onRetry:i,onViewLogs:r}=t;if(s.kind==="failed"){let p;e[0]!==s?(p=Yu(s),e[0]=s,e[1]=p):p=e[1];const g=p;let v;e[2]!==g.headline?(v=o.jsx("span",{className:"text-sm font-medium text-foreground",children:g.headline}),e[2]=g.headline,e[3]=v):v=e[3];let b;e[4]!==g.body?(b=o.jsx("span",{className:"text-xs text-muted-foreground",children:g.body}),e[4]=g.body,e[5]=b):b=e[5];let S;e[6]!==v||e[7]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center gap-2 text-center max-w-[440px]",children:[v,b]}),e[6]=v,e[7]=b,e[8]=S):S=e[8];let x;e[9]!==i?(x=i&&o.jsx("button",{type:"button",onClick:i,className:"rounded-md border border-foreground/15 bg-background px-3 py-1.5 text-xs font-medium hover:bg-foreground/[0.04] transition-colors",children:"Try again"}),e[9]=i,e[10]=x):x=e[10];let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(mi,{size:11}),e[11]=w):w=e[11];let N;e[12]!==r?(N=o.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 text-xs text-muted-foreground/60 hover:text-muted-foreground transition-colors duration-200",children:[w,"View logs"]}),e[12]=r,e[13]=N):N=e[13];let y;return e[14]!==S||e[15]!==x||e[16]!==N?(y=o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none gap-6 px-6",children:[S,x,N]}),e[14]=S,e[15]=x,e[16]=N,e[17]=y):y=e[17],y}let n;e[18]!==s.kind?(n=s.kind==="ready"?{headline:"Almost ready",body:void 0}:Gu[s.kind],e[18]=s.kind,e[19]=n):n=e[19];const a=n;let l;e[20]!==a.body||e[21]!==s?(l=s.kind==="ready"?void 0:Ju(s)??a.body,e[20]=a.body,e[21]=s,e[22]=l):l=e[22];const h=l;let c;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx(Qo,{}),e[23]=c):c=e[23];let d;e[24]!==a.headline||e[25]!==s.kind?(d=o.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:[c,o.jsxs("span",{className:"text-[13px] font-medium text-foreground/85 animate-in fade-in duration-500",children:[a.headline,"…"]},s.kind)]}),e[24]=a.headline,e[25]=s.kind,e[26]=d):d=e[26];let u;e[27]!==h?(u=h&&o.jsx("span",{className:"block max-w-[440px] truncate text-center text-xs text-muted-foreground/70 animate-in fade-in duration-300",children:h},h),e[27]=h,e[28]=u):u=e[28];let m;e[29]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx(mi,{size:11}),e[29]=m):m=e[29];let _;e[30]!==r?(_=o.jsxs("button",{type:"button",onClick:r,className:"absolute bottom-5 left-1/2 -translate-x-1/2 flex items-center gap-1.5 text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors duration-200",children:[m,"View logs"]}),e[30]=r,e[31]=_):_=e[31];let f;return e[32]!==d||e[33]!==u||e[34]!==_?(f=o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none gap-6",children:[d,u,_]}),e[32]=d,e[33]=u,e[34]=_,e[35]=f):f=e[35],f}function Ju(t){if(t.kind==="waiting-for-capacity"&&t.nodeClaim)return`Provisioning node ${t.nodeClaim}…`}function Pa(t){const e=V.c(21),{errorMsg:s,onRetry:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsxs("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 z-20 flex items-center gap-2 rounded-full border border-destructive/30 bg-background/80 px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)] backdrop-blur-md",children:[o.jsx(as,{size:13,className:"text-destructive/80"}),o.jsx("span",{className:"text-[13px] font-medium text-destructive/90",children:"Failed to start"})]}),e[0]=r):r=e[0];let n,a;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"absolute left-[8%] right-[8%] -top-5 h-full rounded-xl border border-foreground/[0.05] bg-foreground/[0.015]"}),a=o.jsx("div",{className:"absolute left-[4%] right-[4%] -top-2.5 h-full rounded-xl border border-foreground/[0.07] bg-foreground/[0.025]"}),e[1]=n,e[2]=a):(n=e[1],a=e[2]);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsxs("div",{className:"h-7 border-b border-foreground/[0.08] bg-foreground/[0.015] flex items-center gap-1.5 px-3",children:[o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground/10"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground/10"}),o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground/10"}),o.jsx("div",{className:"ml-3 h-3.5 flex-1 max-w-[240px] rounded-sm bg-foreground/[0.04]"})]}),e[3]=l):l=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(as,{size:14,className:"text-destructive/80 mt-0.5 shrink-0"}),e[4]=h):h=e[4];let c;e[5]!==s?(c=o.jsxs("div",{className:"flex items-start gap-2",children:[h,o.jsx("p",{className:"text-xs text-destructive/80 line-clamp-5 break-all leading-relaxed font-mono",children:s})]}),e[5]=s,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ko,{size:12}),e[7]=d):d=e[7];let u;e[8]!==i?(u=o.jsxs(se,{variant:"outline",size:"sm",onClick:i,children:[d,"Retry"]}),e[8]=i,e[9]=u):u=e[9];let m;e[10]!==s?(m=()=>navigator.clipboard.writeText(s).then(Zu),e[10]=s,e[11]=m):m=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ci,{size:10}),e[12]=_):_=e[12];let f;e[13]!==m?(f=o.jsxs("button",{type:"button",onClick:m,className:"flex items-center gap-1 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors duration-200",children:[_,"Copy error"]}),e[13]=m,e[14]=f):f=e[14];let p;e[15]!==f||e[16]!==u?(p=o.jsxs("div",{className:"flex items-center gap-2",children:[u,f]}),e[15]=f,e[16]=u,e[17]=p):p=e[17];let g;return e[18]!==p||e[19]!==c?(g=o.jsxs("div",{className:"relative flex flex-col items-center justify-center w-full h-full overflow-hidden select-none",children:[r,o.jsxs("div",{className:"relative w-[min(78%,560px)] aspect-[4/3] mt-6 opacity-60",children:[n,a,o.jsxs("div",{className:"relative w-full h-full rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] overflow-hidden",children:[l,o.jsx("div",{className:"flex items-center justify-center p-6 h-[calc(100%-1.75rem)]",children:o.jsxs("div",{className:"w-full max-w-sm rounded-lg border border-destructive/20 bg-destructive/[0.03] p-4 space-y-3",children:[c,p]})})]})]})]}),e[18]=p,e[19]=c,e[20]=g):g=e[20],g}function Zu(){me.success("Error copied to clipboard")}const Qu=[{value:"preview",icon:o.jsx(ra,{size:14}),tooltip:"Interactive"},{value:"visual",icon:o.jsx(na,{size:14}),tooltip:"Visual Editor"}];function ef(){const t=pn(),{data:e}=Si.useSession(),{openEnv:s}=wu(),{taskId:i,currentBranch:r,setCurrentTaskBranch:n}=lt(),[a,l]=A.useState("preview"),[h,c]=A.useState(null),d=A.useRef(null),u=e?.user?.id,m=t?.entity?.metadata,_=u&&r?m?.vmMap?.[u]?.[r]:void 0,f=_?.previewUrl??null,p=ms();Lu(()=>{const P=d.current;P&&(P.src=P.src)});const g=p.status.htmlSupport,v=p.suspended,b=A.useRef({url:"",at:0,ready:!1});f&&b.current.url!==f&&(b.current={url:f,at:_?.createdAt??Date.now(),ready:!1}),f&&p.status.ready&&!b.current.ready&&(b.current.ready=!0);const S=!!f&&!b.current.ready&&!v,x=A.useRef(0),w=t?.entity?.id??null,N=Fe({connectionId:It,orgId:t?.entity?.organization_id??""}),y=sn(N),k=y.error?.message??null,j=Ea(w??void 0,r??void 0);j?x.current||(x.current=Date.now()):f&&(x.current=0);const M=j&&!f&&!v,D=A.useRef(null),T=A.useRef(null),C=p.phase,R=!f&&!!C&&C.kind!=="failed",E=P=>{if(!w)return;const Z={virtualMcpId:w};r&&(Z.branch=r),y.mutate(Z,{onSuccess:Y=>{Y?.branch&&!r&&n(Y.branch)},onError:Y=>{console.error(`[preview] ${P} VM_START failed`,Y)}})},L=A.useRef(E);L.current=E,i&&_&&D.current!==i&&(D.current=i);const z=!!i&&!!w&&!!u&&!!r&&!_&&!k&&!y.isPending&&D.current!==i;A.useEffect(()=>{!z||!i||(D.current=i,L.current("auto-start"))},[z,i]);const B=p.notFound?_?.vmId??null:null;A.useEffect(()=>{!B||!w||k||y.isPending||T.current!==B&&(T.current=B,L.current("self-heal"))},[B,w,k,y.isPending]);const O=()=>{D.current=null,T.current=null,y.reset(),L.current("auto-start")};A.useEffect(()=>{if(!f)return;let P;try{P=new URL(f,window.location.href).origin}catch{return}const Z=Y=>{if(Y.origin!==P||Y.data?.type!=="visual-editor::element-clicked")return;const ee=Cu.safeParse(Y.data.payload);ee.success&&c(ee.data)};return window.addEventListener("message",Z),()=>window.removeEventListener("message",Z)},[f]);const $=()=>{const P=d.current?.contentWindow;P&&P.postMessage({type:"visual-editor::activate",script:ku},"*")},W=()=>{const P=d.current?.contentWindow;P&&P.postMessage({type:"visual-editor::deactivate"},"*")},I=P=>{l(P),c(null),P==="visual"?$():W()},F=()=>{if(!d.current)return;const P=d.current;P.src=P.src},U=()=>{if(!d.current||!f)return;const P=f.includes("?")?"&":"?";d.current.src=`${f}${P}_r=${Date.now()}`},K=()=>{const P=d.current?.contentWindow?.location?.href??f;P&&navigator.clipboard.writeText(P)},G=(()=>{if(!f)return"No server running";try{const P=new URL(f);return`${P.host}${P.pathname==="/"?"":P.pathname}`}catch{return f}})();return o.jsxs("div",{className:"flex flex-col w-full h-full",children:[f&&o.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[g&&o.jsx(_h,{value:a,onValueChange:I,options:Qu,size:"sm",className:"shrink-0 bg-foreground/[0.045]"}),o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-0.5",children:[o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:()=>d.current?.contentWindow?.history.back(),children:o.jsx(ka,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Back"})]}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:()=>d.current?.contentWindow?.history.forward(),children:o.jsx(Zl,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Forward"})]}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:F,children:o.jsx(Ko,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Refresh"})]}),o.jsx("div",{className:"flex h-8 min-w-0 flex-1 items-center rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",children:o.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-foreground/88",children:G})})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",onClick:()=>window.open(f,"_blank","noopener"),children:o.jsx(Wt,{size:14})})}),o.jsx(qe,{side:"bottom",children:"Open in new tab"})]}),o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",children:o.jsx(ia,{size:14})})}),o.jsxs(os,{align:"end",children:[o.jsx(yt,{onClick:U,children:"Hard Reload"}),o.jsx(yt,{onClick:K,children:"Copy Current URL"})]})]})]})]}),o.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[!f&&!M&&!k&&!R&&o.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-4 bg-background",children:[o.jsx(ra,{size:48,className:"text-muted-foreground/40"}),o.jsx("h3",{className:"text-lg font-medium",children:"Preview"}),o.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-sm",children:"Start the development server to see a live preview"}),o.jsxs(se,{onClick:s,children:[o.jsx(sa,{size:14}),"Start Server"]})]}),k&&o.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-background",children:o.jsx(Pa,{errorMsg:k,onRetry:O})}),!k&&v&&o.jsx("div",{className:"absolute inset-0 z-30 bg-background/80 backdrop-blur-sm",children:o.jsx(Aa,{onResume:s})}),!k&&(S||M||R||p.notFound)&&o.jsx("div",{className:"absolute inset-0 z-30 flex items-center justify-center bg-background",children:o.jsx(Wu,{since:S?b.current.at:x.current,hasSetupData:p.hasData("setup"),scripts:p.scripts,activeProcesses:p.activeProcesses,onViewLogs:s,claimPhase:f?null:C,onRetry:O})}),a==="visual"&&!h&&o.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:[o.jsx(na,{size:12}),"Click any element to ask the AI"]}),a==="visual"&&h&&o.jsx(Eu,{element:h,onDismiss:()=>c(null)}),f&&!S&&!p.notFound&&o.jsx("iframe",{ref:d,src:f,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{Se("vm_preview_loaded",{view_mode:a,vm_id:_?.vmId??null}),a==="visual"&&$()}},f)]})]})}function tf(t){const e=V.c(2),{virtualMcpId:s}=t,i=gt(s);if(!(i?Bt(i):null)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[o.jsx(as,{size:24,className:"text-muted-foreground/60"}),o.jsx("div",{children:"No repository connected."}),o.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 n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(ef,{}),e[1]=n):n=e[1],n}var La=Object.defineProperty,sf=Object.getOwnPropertyDescriptor,rf=(t,e)=>{for(var s in e)La(t,s,{get:e[s],enumerable:!0})},ke=(t,e,s,i)=>{for(var r=i>1?void 0:i?sf(e,s):e,n=t.length-1,a;n>=0;n--)(a=t[n])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&La(e,s,r),r},J=(t,e)=>(s,i)=>e(s,i,t),Fn="Terminal input",ur={get:()=>Fn,set:t=>Fn=t},Hn="Too much output to announce, navigate to rows manually to read",fr={get:()=>Hn,set:t=>Hn=t};function nf(t){return t.replace(/\r?\n/g,"\r")}function of(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function af(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function lf(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Oa(r,e,s,i)}}function Oa(t,e,s,i){t=nf(t),t=of(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function za(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,n=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function Wn(t,e,s,i,r){za(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Et(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Di(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let n=t[r];n>65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var cf=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 n=t.charCodeAt(r++);56320<=n&&n<=57343?e[i++]=(this._interim-55296)*1024+n-56320+65536:(e[i++]=this._interim,e[i++]=n),this._interim=0}for(let n=r;n<s;++n){let a=t.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=s)return this._interim=a,i;let l=t.charCodeAt(n);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}},hf=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,n,a,l,h=0,c=0;if(this.interim[0]){let m=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)_<<=6,_|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-f;for(;c<v;){if(c>=s)return 0;if(p=t[c++],(p&192)!==128){c--,m=!0;break}else this.interim[f++]=p,_<<=6,_|=p&63}m||(g===2?_<128?c--:e[i++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(e[i++]=_):_<65536||_>1114111||(e[i++]=_)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((r=t[u])&128)&&!((n=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=n,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(n=t[u++],(n&192)!==128){u--;continue}if(h=(r&31)<<6|n&63,h<128){u--;continue}e[i++]=h}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(n=t[u++],(n&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=n,i;if(a=t[u++],(a&192)!==128){u--;continue}if(h=(r&15)<<12|(n&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(n=t[u++],(n&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=n,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(h=(r&7)<<18|(n&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},$a="",Tt=" ",qs=class Fa{constructor(){this.fg=0,this.bg=0,this.extended=new _i}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 Fa;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}},_i=class Ha{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 Ha(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},nt=class Wa extends qs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _i,this.combinedData=""}static fromCharData(e){let s=new Wa;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?Et(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()]}},Un="di$target",mr="di$dependencies",Ki=new Map;function df(t){return t[mr]||[]}function ze(t){if(Ki.has(t))return Ki.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");uf(e,s,r)};return e._id=t,Ki.set(t,e),e}function uf(t,e,s){e[Un]===e?e[mr].push({id:t,index:s}):(e[mr]=[{id:t,index:s}],e[Un]=e)}var Ge=ze("BufferService"),Ua=ze("CoreMouseService"),Ut=ze("CoreService"),ff=ze("CharsetService"),on=ze("InstantiationService"),Va=ze("LogService"),Ye=ze("OptionsService"),Ka=ze("OscLinkService"),mf=ze("UnicodeService"),Gs=ze("DecorationService"),_r=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,n=new nt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=d,l=n.extended.urlId;continue}else c=n.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let m={start:{x:h+1,y:t},end:{x:d+(!c&&d===a-1?1:0),y:t}},_=!1;if(!r?.allowNonHttpProtocols)try{let f=new URL(u);["http:","https:"].includes(f.protocol)||(_=!0)}catch{_=!0}_||i.push({text:u,range:m,activate:(f,p)=>r?r.activate(f,p,m):_f(f,p),hover:(f,p)=>r?.hover?.(f,p,m),leave:(f,p)=>r?.leave?.(f,p,m)})}c=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,l=n.extended.urlId):(h=-1,l=-1)}}e(i)}};_r=ke([J(0,Ge),J(1,Ye),J(2,Ka)],_r);function _f(t,e){if(confirm(`Do you want to navigate to ${e}?
168
168
 
169
- 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 Mi=ze("CharSizeService"),wt=ze("CoreBrowserService"),an=ze("MouseService"),Ct=ze("RenderService"),_f=ze("SelectionService"),qa=ze("CharacterJoinerService"),_s=ze("ThemeService"),Ga=ze("LinkProviderService"),pf=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Vn.isErrorNoTelemetry(t)?new Vn(t.message+`
169
+ 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 Mi=ze("CharSizeService"),wt=ze("CoreBrowserService"),an=ze("MouseService"),Ct=ze("RenderService"),pf=ze("SelectionService"),qa=ze("CharacterJoinerService"),_s=ze("ThemeService"),Ga=ze("LinkProviderService"),gf=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Vn.isErrorNoTelemetry(t)?new Vn(t.message+`
170
170
 
171
171
  `+t.stack):new Error(t.message+`
172
172
 
173
- `+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)}},gf=new pf;function li(t){vf(t)||gf.onUnexpectedError(t)}var pr="Canceled";function vf(t){return t instanceof xf?!0:t instanceof Error&&t.name===pr&&t.message===pr}var xf=class extends Error{constructor(){super(pr),this.name=this.message}};function bf(t){return new Error(`Illegal argument: ${t}`)}var Vn=class gr extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof gr)return e;let s=new gr;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},vr=class Ya extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ya.prototype)}};function Ze(t,e=0){return t[t.length-(1+e)]}var Sf;(t=>{function e(n){return n<0}t.isLessThan=e;function s(n){return n<=0}t.isLessThanOrEqual=s;function i(n){return n>0}t.isGreaterThan=i;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Sf||={});function yf(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var Xa;(t=>{function e(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(x){yield x}t.single=r;function n(x){return e(x)?x:r(x)}t.wrap=n;function a(x){return x||s}t.from=a;function*l(x){for(let w=x.length-1;w>=0;w--)yield x[w]}t.reverse=l;function h(x){return!x||x[Symbol.iterator]().next().done===!0}t.isEmpty=h;function c(x){return x[Symbol.iterator]().next().value}t.first=c;function d(x,w){let N=0;for(let y of x)if(w(y,N++))return!0;return!1}t.some=d;function u(x,w){for(let N of x)if(w(N))return N}t.find=u;function*m(x,w){for(let N of x)w(N)&&(yield N)}t.filter=m;function*_(x,w){let N=0;for(let y of x)yield w(y,N++)}t.map=_;function*f(x,w){let N=0;for(let y of x)yield*w(y,N++)}t.flatMap=f;function*p(...x){for(let w of x)yield*w}t.concat=p;function g(x,w,N){let y=N;for(let k of x)y=w(y,k);return y}t.reduce=g;function*v(x,w,N=x.length){for(w<0&&(w+=x.length),N<0?N+=x.length:N>x.length&&(N=x.length);w<N;w++)yield x[w]}t.slice=v;function b(x,w=Number.POSITIVE_INFINITY){let N=[];if(w===0)return[N,x];let y=x[Symbol.iterator]();for(let k=0;k<w;k++){let j=y.next();if(j.done)return[N,t.empty()];N.push(j.value)}return[N,{[Symbol.iterator](){return y}}]}t.consume=b;async function S(x){let w=[];for await(let N of x)w.push(N);return Promise.resolve(w)}t.asyncToArray=S})(Xa||={});function $t(t){if(Xa.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 wf(...t){return ge(()=>$t(t))}function ge(t){return{dispose:yf(()=>{t()})}}var Ja=class Za{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{$t(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?Za.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)}};Ja.DISABLE_DISPOSED_WARNING=!1;var Dt=Ja,le=class{constructor(){this._store=new Dt,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)}};le.None=Object.freeze({dispose(){}});var hs=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}},St=typeof window=="object"?window:globalThis,xr=class br{constructor(e){this.element=e,this.next=br.Undefined,this.prev=br.Undefined}};xr.Undefined=new xr(void 0);var xe=xr,Kn=class{constructor(){this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===xe.Undefined}clear(){let t=this._first;for(;t!==xe.Undefined;){let e=t.next;t.prev=xe.Undefined,t.next=xe.Undefined,t=e}this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new xe(t);if(this._first===xe.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!==xe.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==xe.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==xe.Undefined&&t.next!==xe.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===xe.Undefined&&t.next===xe.Undefined?(this._first=xe.Undefined,this._last=xe.Undefined):t.next===xe.Undefined?(this._last=this._last.prev,this._last.next=xe.Undefined):t.prev===xe.Undefined&&(this._first=this._first.next,this._first.prev=xe.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==xe.Undefined;)yield t.element,t=t.next}},Cf=globalThis.performance&&typeof globalThis.performance.now=="function",kf=class Qa{static create(e){return new Qa(e)}constructor(e){this._now=Cf&&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}},$e;(t=>{t.None=()=>le.None;function e(T,C){return u(T,()=>{},0,void 0,!0,void 0,C)}t.defer=e;function s(T){return(C,D=null,E)=>{let L=!1,z;return z=T(B=>{if(!L)return z?z.dispose():L=!0,C.call(D,B)},null,E),L&&z.dispose(),z}}t.once=s;function i(T,C,D){return c((E,L=null,z)=>T(B=>E.call(L,C(B)),null,z),D)}t.map=i;function r(T,C,D){return c((E,L=null,z)=>T(B=>{C(B),E.call(L,B)},null,z),D)}t.forEach=r;function n(T,C,D){return c((E,L=null,z)=>T(B=>C(B)&&E.call(L,B),null,z),D)}t.filter=n;function a(T){return T}t.signal=a;function l(...T){return(C,D=null,E)=>{let L=wf(...T.map(z=>z(B=>C.call(D,B))));return d(L,E)}}t.any=l;function h(T,C,D,E){let L=D;return i(T,z=>(L=C(L,z),L),E)}t.reduce=h;function c(T,C){let D,E={onWillAddFirstListener(){D=T(L.fire,L)},onDidRemoveLastListener(){D?.dispose()}},L=new q(E);return C?.add(L),L.event}function d(T,C){return C instanceof Array?C.push(T):C&&C.add(T),T}function u(T,C,D=100,E=!1,L=!1,z,B){let O,$,W,I=0,F,U={leakWarningThreshold:z,onWillAddFirstListener(){O=T(G=>{I++,$=C($,G),E&&!W&&(K.fire($),$=void 0),F=()=>{let P=$;$=void 0,W=void 0,(!E||I>1)&&K.fire(P),I=0},typeof D=="number"?(clearTimeout(W),W=setTimeout(F,D)):W===void 0&&(W=0,queueMicrotask(F))})},onWillRemoveListener(){L&&I>0&&F?.()},onDidRemoveLastListener(){F=void 0,O.dispose()}},K=new q(U);return B?.add(K),K.event}t.debounce=u;function m(T,C=0,D){return t.debounce(T,(E,L)=>E?(E.push(L),E):[L],C,void 0,!0,void 0,D)}t.accumulate=m;function _(T,C=(E,L)=>E===L,D){let E=!0,L;return n(T,z=>{let B=E||!C(z,L);return E=!1,L=z,B},D)}t.latch=_;function f(T,C,D){return[t.filter(T,C,D),t.filter(T,E=>!C(E),D)]}t.split=f;function p(T,C=!1,D=[],E){let L=D.slice(),z=T($=>{L?L.push($):O.fire($)});E&&E.add(z);let B=()=>{L?.forEach($=>O.fire($)),L=null},O=new q({onWillAddFirstListener(){z||(z=T($=>O.fire($)),E&&E.add(z))},onDidAddFirstListener(){L&&(C?setTimeout(B):B())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return E&&E.add(O),O.event}t.buffer=p;function g(T,C){return(D,E,L)=>{let z=C(new b);return T(function(B){let O=z.evaluate(B);O!==v&&D.call(E,O)},void 0,L)}}t.chain=g;let v=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(C){return this.steps.push(C),this}forEach(C){return this.steps.push(D=>(C(D),D)),this}filter(C){return this.steps.push(D=>C(D)?D:v),this}reduce(C,D){let E=D;return this.steps.push(L=>(E=C(E,L),E)),this}latch(C=(D,E)=>D===E){let D=!0,E;return this.steps.push(L=>{let z=D||!C(L,E);return D=!1,E=L,z?L:v}),this}evaluate(C){for(let D of this.steps)if(C=D(C),C===v)break;return C}}function S(T,C,D=E=>E){let E=(...O)=>B.fire(D(...O)),L=()=>T.on(C,E),z=()=>T.removeListener(C,E),B=new q({onWillAddFirstListener:L,onDidRemoveLastListener:z});return B.event}t.fromNodeEventEmitter=S;function x(T,C,D=E=>E){let E=(...O)=>B.fire(D(...O)),L=()=>T.addEventListener(C,E),z=()=>T.removeEventListener(C,E),B=new q({onWillAddFirstListener:L,onDidRemoveLastListener:z});return B.event}t.fromDOMEventEmitter=x;function w(T){return new Promise(C=>s(T)(C))}t.toPromise=w;function N(T){let C=new q;return T.then(D=>{C.fire(D)},()=>{C.fire(void 0)}).finally(()=>{C.dispose()}),C.event}t.fromPromise=N;function y(T,C){return T(D=>C.fire(D))}t.forward=y;function k(T,C,D){return C(D),T(E=>C(E))}t.runAndSubscribe=k;class j{constructor(C,D){this._observable=C,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{C.addObserver(this)},onDidRemoveLastListener:()=>{C.removeObserver(this)}};this.emitter=new q(E),D&&D.add(this.emitter)}beginUpdate(C){this._counter++}handlePossibleChange(C){}handleChange(C,D){this._hasChanged=!0}endUpdate(C){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function M(T,C){return new j(T,C).emitter.event}t.fromObservable=M;function R(T){return(C,D,E)=>{let L=0,z=!1,B={beginUpdate(){L++},endUpdate(){L--,L===0&&(T.reportChanges(),z&&(z=!1,C.call(D)))},handlePossibleChange(){},handleChange(){z=!0}};T.addObserver(B),T.reportChanges();let O={dispose(){T.removeObserver(B)}};return E instanceof Dt?E.add(O):Array.isArray(E)&&E.push(O),O}}t.fromObservableLight=R})($e||={});var Sr=class yr{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${yr._idPool++}`,yr.all.add(this)}start(e){this._stopWatch=new kf,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}}};Sr.all=new Set,Sr._idPool=0;var Nf=Sr,jf=-1,el=class tl{constructor(e,s,i=(tl._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[n,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(n);let h=new Df(l,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-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}};el._idPool=1;var Ef=el,Tf=class sl{constructor(e){this.value=e}static create(){let e=new Error;return new sl(e.stack??"")}print(){console.warn(this.value.split(`
173
+ `+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)}},vf=new gf;function li(t){xf(t)||vf.onUnexpectedError(t)}var pr="Canceled";function xf(t){return t instanceof bf?!0:t instanceof Error&&t.name===pr&&t.message===pr}var bf=class extends Error{constructor(){super(pr),this.name=this.message}};function Sf(t){return new Error(`Illegal argument: ${t}`)}var Vn=class gr extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof gr)return e;let s=new gr;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},vr=class Ya extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ya.prototype)}};function Ze(t,e=0){return t[t.length-(1+e)]}var yf;(t=>{function e(n){return n<0}t.isLessThan=e;function s(n){return n<=0}t.isLessThanOrEqual=s;function i(n){return n>0}t.isGreaterThan=i;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(yf||={});function wf(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var Xa;(t=>{function e(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(x){yield x}t.single=r;function n(x){return e(x)?x:r(x)}t.wrap=n;function a(x){return x||s}t.from=a;function*l(x){for(let w=x.length-1;w>=0;w--)yield x[w]}t.reverse=l;function h(x){return!x||x[Symbol.iterator]().next().done===!0}t.isEmpty=h;function c(x){return x[Symbol.iterator]().next().value}t.first=c;function d(x,w){let N=0;for(let y of x)if(w(y,N++))return!0;return!1}t.some=d;function u(x,w){for(let N of x)if(w(N))return N}t.find=u;function*m(x,w){for(let N of x)w(N)&&(yield N)}t.filter=m;function*_(x,w){let N=0;for(let y of x)yield w(y,N++)}t.map=_;function*f(x,w){let N=0;for(let y of x)yield*w(y,N++)}t.flatMap=f;function*p(...x){for(let w of x)yield*w}t.concat=p;function g(x,w,N){let y=N;for(let k of x)y=w(y,k);return y}t.reduce=g;function*v(x,w,N=x.length){for(w<0&&(w+=x.length),N<0?N+=x.length:N>x.length&&(N=x.length);w<N;w++)yield x[w]}t.slice=v;function b(x,w=Number.POSITIVE_INFINITY){let N=[];if(w===0)return[N,x];let y=x[Symbol.iterator]();for(let k=0;k<w;k++){let j=y.next();if(j.done)return[N,t.empty()];N.push(j.value)}return[N,{[Symbol.iterator](){return y}}]}t.consume=b;async function S(x){let w=[];for await(let N of x)w.push(N);return Promise.resolve(w)}t.asyncToArray=S})(Xa||={});function $t(t){if(Xa.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 Cf(...t){return ge(()=>$t(t))}function ge(t){return{dispose:wf(()=>{t()})}}var Ja=class Za{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{$t(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?Za.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)}};Ja.DISABLE_DISPOSED_WARNING=!1;var Rt=Ja,le=class{constructor(){this._store=new Rt,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)}};le.None=Object.freeze({dispose(){}});var hs=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}},St=typeof window=="object"?window:globalThis,xr=class br{constructor(e){this.element=e,this.next=br.Undefined,this.prev=br.Undefined}};xr.Undefined=new xr(void 0);var xe=xr,Kn=class{constructor(){this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===xe.Undefined}clear(){let t=this._first;for(;t!==xe.Undefined;){let e=t.next;t.prev=xe.Undefined,t.next=xe.Undefined,t=e}this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new xe(t);if(this._first===xe.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!==xe.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==xe.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==xe.Undefined&&t.next!==xe.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===xe.Undefined&&t.next===xe.Undefined?(this._first=xe.Undefined,this._last=xe.Undefined):t.next===xe.Undefined?(this._last=this._last.prev,this._last.next=xe.Undefined):t.prev===xe.Undefined&&(this._first=this._first.next,this._first.prev=xe.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==xe.Undefined;)yield t.element,t=t.next}},kf=globalThis.performance&&typeof globalThis.performance.now=="function",Nf=class Qa{static create(e){return new Qa(e)}constructor(e){this._now=kf&&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}},$e;(t=>{t.None=()=>le.None;function e(T,C){return u(T,()=>{},0,void 0,!0,void 0,C)}t.defer=e;function s(T){return(C,R=null,E)=>{let L=!1,z;return z=T(B=>{if(!L)return z?z.dispose():L=!0,C.call(R,B)},null,E),L&&z.dispose(),z}}t.once=s;function i(T,C,R){return c((E,L=null,z)=>T(B=>E.call(L,C(B)),null,z),R)}t.map=i;function r(T,C,R){return c((E,L=null,z)=>T(B=>{C(B),E.call(L,B)},null,z),R)}t.forEach=r;function n(T,C,R){return c((E,L=null,z)=>T(B=>C(B)&&E.call(L,B),null,z),R)}t.filter=n;function a(T){return T}t.signal=a;function l(...T){return(C,R=null,E)=>{let L=Cf(...T.map(z=>z(B=>C.call(R,B))));return d(L,E)}}t.any=l;function h(T,C,R,E){let L=R;return i(T,z=>(L=C(L,z),L),E)}t.reduce=h;function c(T,C){let R,E={onWillAddFirstListener(){R=T(L.fire,L)},onDidRemoveLastListener(){R?.dispose()}},L=new q(E);return C?.add(L),L.event}function d(T,C){return C instanceof Array?C.push(T):C&&C.add(T),T}function u(T,C,R=100,E=!1,L=!1,z,B){let O,$,W,I=0,F,U={leakWarningThreshold:z,onWillAddFirstListener(){O=T(G=>{I++,$=C($,G),E&&!W&&(K.fire($),$=void 0),F=()=>{let P=$;$=void 0,W=void 0,(!E||I>1)&&K.fire(P),I=0},typeof R=="number"?(clearTimeout(W),W=setTimeout(F,R)):W===void 0&&(W=0,queueMicrotask(F))})},onWillRemoveListener(){L&&I>0&&F?.()},onDidRemoveLastListener(){F=void 0,O.dispose()}},K=new q(U);return B?.add(K),K.event}t.debounce=u;function m(T,C=0,R){return t.debounce(T,(E,L)=>E?(E.push(L),E):[L],C,void 0,!0,void 0,R)}t.accumulate=m;function _(T,C=(E,L)=>E===L,R){let E=!0,L;return n(T,z=>{let B=E||!C(z,L);return E=!1,L=z,B},R)}t.latch=_;function f(T,C,R){return[t.filter(T,C,R),t.filter(T,E=>!C(E),R)]}t.split=f;function p(T,C=!1,R=[],E){let L=R.slice(),z=T($=>{L?L.push($):O.fire($)});E&&E.add(z);let B=()=>{L?.forEach($=>O.fire($)),L=null},O=new q({onWillAddFirstListener(){z||(z=T($=>O.fire($)),E&&E.add(z))},onDidAddFirstListener(){L&&(C?setTimeout(B):B())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return E&&E.add(O),O.event}t.buffer=p;function g(T,C){return(R,E,L)=>{let z=C(new b);return T(function(B){let O=z.evaluate(B);O!==v&&R.call(E,O)},void 0,L)}}t.chain=g;let v=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(C){return this.steps.push(C),this}forEach(C){return this.steps.push(R=>(C(R),R)),this}filter(C){return this.steps.push(R=>C(R)?R:v),this}reduce(C,R){let E=R;return this.steps.push(L=>(E=C(E,L),E)),this}latch(C=(R,E)=>R===E){let R=!0,E;return this.steps.push(L=>{let z=R||!C(L,E);return R=!1,E=L,z?L:v}),this}evaluate(C){for(let R of this.steps)if(C=R(C),C===v)break;return C}}function S(T,C,R=E=>E){let E=(...O)=>B.fire(R(...O)),L=()=>T.on(C,E),z=()=>T.removeListener(C,E),B=new q({onWillAddFirstListener:L,onDidRemoveLastListener:z});return B.event}t.fromNodeEventEmitter=S;function x(T,C,R=E=>E){let E=(...O)=>B.fire(R(...O)),L=()=>T.addEventListener(C,E),z=()=>T.removeEventListener(C,E),B=new q({onWillAddFirstListener:L,onDidRemoveLastListener:z});return B.event}t.fromDOMEventEmitter=x;function w(T){return new Promise(C=>s(T)(C))}t.toPromise=w;function N(T){let C=new q;return T.then(R=>{C.fire(R)},()=>{C.fire(void 0)}).finally(()=>{C.dispose()}),C.event}t.fromPromise=N;function y(T,C){return T(R=>C.fire(R))}t.forward=y;function k(T,C,R){return C(R),T(E=>C(E))}t.runAndSubscribe=k;class j{constructor(C,R){this._observable=C,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{C.addObserver(this)},onDidRemoveLastListener:()=>{C.removeObserver(this)}};this.emitter=new q(E),R&&R.add(this.emitter)}beginUpdate(C){this._counter++}handlePossibleChange(C){}handleChange(C,R){this._hasChanged=!0}endUpdate(C){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function M(T,C){return new j(T,C).emitter.event}t.fromObservable=M;function D(T){return(C,R,E)=>{let L=0,z=!1,B={beginUpdate(){L++},endUpdate(){L--,L===0&&(T.reportChanges(),z&&(z=!1,C.call(R)))},handlePossibleChange(){},handleChange(){z=!0}};T.addObserver(B),T.reportChanges();let O={dispose(){T.removeObserver(B)}};return E instanceof Rt?E.add(O):Array.isArray(E)&&E.push(O),O}}t.fromObservableLight=D})($e||={});var Sr=class yr{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${yr._idPool++}`,yr.all.add(this)}start(e){this._stopWatch=new Nf,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}}};Sr.all=new Set,Sr._idPool=0;var jf=Sr,Ef=-1,el=class tl{constructor(e,s,i=(tl._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[n,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(n);let h=new Df(l,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-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}};el._idPool=1;var Tf=el,Rf=class sl{constructor(e){this.value=e}static create(){let e=new Error;return new sl(e.stack??"")}print(){console.warn(this.value.split(`
174
174
  `).slice(2).join(`
175
- `))}},Df=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Rf=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},Mf=0,qi=class{constructor(t){this.value=t,this.id=Mf++}},If=2,Bf,q=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Ef(t?.onListenerError??li,this._options?.leakWarningThreshold??jf):void 0,this._perfMon=this._options?._profName?new Nf(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],h=new Rf(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||li)(h),le.None}if(this._disposed)return le.None;e&&(t=t.bind(e));let i=new qi(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=Tf.create(),r=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof qi?(this._deliveryQueue??=new Af,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=ge(()=>{r?.(),this._removeListener(i)});return s instanceof Dt?s.add(n):Array.isArray(s)&&s.push(n),n},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*If<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]: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||li;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 qi)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}},Af=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}},wr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new q,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}};wr.INSTANCE=new wr;var ln=wr;function Pf(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}ln.INSTANCE.onDidChangeZoomLevel;function Lf(t){return ln.INSTANCE.getZoomFactor(t)}ln.INSTANCE.onDidChangeFullscreen;var ps=typeof navigator=="object"?navigator.userAgent:"",Cr=ps.indexOf("Firefox")>=0,Of=ps.indexOf("AppleWebKit")>=0,cn=ps.indexOf("Chrome")>=0,zf=!cn&&ps.indexOf("Safari")>=0;ps.indexOf("Electron/")>=0;ps.indexOf("Android")>=0;var Gi=!1;if(typeof St.matchMedia=="function"){let t=St.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=St.matchMedia("(display-mode: fullscreen)");Gi=t.matches,Pf(St,t,({matches:s})=>{Gi&&e.matches||(Gi=s)})}var Zt="en",kr=!1,Nr=!1,ci=!1,il=!1,Qs,hi=Zt,qn=Zt,$f,bt,zt=globalThis,et;typeof zt.vscode<"u"&&typeof zt.vscode.process<"u"?et=zt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(et=process);var Ff=typeof et?.versions?.electron=="string",Hf=Ff&&et?.type==="renderer";if(typeof et=="object"){kr=et.platform==="win32",Nr=et.platform==="darwin",ci=et.platform==="linux",ci&&et.env.SNAP&&et.env.SNAP_REVISION,et.env.CI||et.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Qs=Zt,hi=Zt;let t=et.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Qs=e.userLocale,qn=e.osLocale,hi=e.resolvedLanguage||Zt,$f=e.languagePack?.translationsConfigFile}catch{}il=!0}else typeof navigator=="object"&&!Hf?(bt=navigator.userAgent,kr=bt.indexOf("Windows")>=0,Nr=bt.indexOf("Macintosh")>=0,(bt.indexOf("Macintosh")>=0||bt.indexOf("iPad")>=0||bt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ci=bt.indexOf("Linux")>=0,bt?.indexOf("Mobi")>=0,hi=globalThis._VSCODE_NLS_LANGUAGE||Zt,Qs=navigator.language.toLowerCase(),qn=Qs):console.error("Unable to resolve platform.");var rl=kr,_t=Nr,Wf=ci,Gn=il,pt=bt,kt=hi,Uf;(t=>{function e(){return kt}t.value=e;function s(){return kt.length===2?kt==="en":kt.length>=3?kt[0]==="e"&&kt[1]==="n"&&kt[2]==="-":!1}t.isDefaultVariant=s;function i(){return kt==="en"}t.isDefault=i})(Uf||={});var Vf=typeof zt.postMessage=="function"&&!zt.importScripts;(()=>{if(Vf){let t=[];zt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let n=t[i];if(n.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),n.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),zt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var Kf=!!(pt&&pt.indexOf("Chrome")>=0);pt&&pt.indexOf("Firefox")>=0;!Kf&&pt&&pt.indexOf("Safari")>=0;pt&&pt.indexOf("Edg/")>=0;pt&&pt.indexOf("Android")>=0;var Gt=typeof navigator=="object"?navigator:{};Gn||document.queryCommandSupported&&document.queryCommandSupported("copy")||Gt&&Gt.clipboard&&Gt.clipboard.writeText,Gn||Gt&&Gt.clipboard&&Gt.clipboard.readText;var hn=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}},Yi=new hn,Yn=new hn,Xn=new hn,qf=new Array(230),nl;(t=>{function e(l){return Yi.keyCodeToStr(l)}t.toString=e;function s(l){return Yi.strToKeyCode(l)}t.fromString=s;function i(l){return Yn.keyCodeToStr(l)}t.toUserSettingsUS=i;function r(l){return Xn.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function n(l){return Yn.strToKeyCode(l)||Xn.strToKeyCode(l)}t.fromUserSettings=n;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 Yi.keyCodeToStr(l)}t.toElectronAccelerator=a})(nl||={});var Gf=class ol{constructor(e,s,i,r,n){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof ol&&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 Yf([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Yf=class{constructor(t){if(t.length===0)throw bf("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 Xf(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return nl.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(Cr)switch(e){case 59:return 85;case 60:if(Wf)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_t)return 57;break}else if(Of&&(_t&&e===93||!_t&&e===92))return 57;return qf[e]||0}var Jf=_t?256:2048,Zf=512,Qf=1024,em=_t?2048:256,Jn=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=Xf(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|=Jf),this.altKey&&(e|=Zf),this.shiftKey&&(e|=Qf),this.metaKey&&(e|=em),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new Gf(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},Zn=new WeakMap;function tm(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 sm=class{static getSameOriginWindowChain(t){let e=Zn.get(t);if(!e){e=[],Zn.set(t,e);let s=t,i;do i=tm(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 n of r){let a=n.window.deref();if(s+=a?.scrollY??0,i+=a?.scrollX??0,a===e||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},ei=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=sm.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Qn=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(cn){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(t){let r=t,n=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 n.VERTICAL_AXIS<"u"&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Cr&&!_t?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")zf&&rl?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<"u"&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Cr&&!_t?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()}},al=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),im;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof rm?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:al})})(im||={});var rm=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?al:(this._emitter||(this._emitter=new q),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},dn=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 vr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new vr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},nm=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 vr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=ge(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},om;(t=>{async function e(i){let r,n=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}t.settled=e;function s(i){return new Promise(async(r,n)=>{try{await i(r,n)}catch(a){n(a)}})}t.withAsyncBody=s})(om||={});var eo=class it{static fromArray(e){return new it(s=>{s.emitMany(e)})}static fromPromise(e){return new it(async s=>{s.emitMany(await e)})}static fromPromises(e){return new it(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new it(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 q,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 $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new it(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return it.map(this,e)}static filter(e,s){return new it(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return it.filter(this,e)}static coalesce(e){return it.filter(e,s=>!!s)}coalesce(){return it.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return it.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())}};eo.EMPTY=eo.fromArray([]);var{getWindow:mt,getWindowId:am,onDidRegisterWindow:lm}=(function(){let t=new Map,e={window:St,disposables:new Dt};t.set(St.vscodeWindowId,e);let s=new q,i=new q,r=new q;function n(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 le.None;let l=new Dt,h={window:a,disposables:l.add(new Dt)};return t.set(a.vscodeWindowId,h),l.add(ge(()=>{t.delete(a.vscodeWindowId),i.fire(a)})),l.add(re(a,Ae.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(h),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:n,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h?.view?h.view.window:St},getDocument(a){return mt(a).document}}})(),cm=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 re(t,e,s,i){return new cm(t,e,s,i)}var to=function(t,e,s,i){return re(t,e,s,i)},un,hm=class extends nm{constructor(t){super(),this.defaultTarget=t&&mt(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},so=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){li(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=n=>{s.set(n,!1);let a=t.get(n)??[];for(e.set(n,a),t.set(n,[]),i.set(n,!0);a.length>0;)a.sort(so.sort),a.shift().execute();i.set(n,!1)};un=(n,a,l=0)=>{let h=am(n),c=new so(a,l),d=t.get(h);return d||(d=[],t.set(h,d)),d.push(c),s.get(h)||(s.set(h,!0),n.requestAnimationFrame(()=>r(h))),c}})();function dm(t){let e=t.getBoundingClientRect(),s=mt(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var Ae={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"},um=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=Je(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Je(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Je(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Je(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Je(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Je(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Je(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Je(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Je(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Je(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Je(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=Je(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=Je(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Je(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 Je(t){return typeof t=="number"?`${t}px`:t}function Is(t){return new um(t)}var ll=class{constructor(){this._hooks=new Dt,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 n=t;try{t.setPointerCapture(e),this._hooks.add(ge(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{n=mt(t)}this._hooks.add(re(n,Ae.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(re(n,Ae.POINTER_UP,a=>this.stopMonitoring(!0)))}};function fm(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 n=`$memoize$${e}`;s[i]=function(...a){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[n]}}var ut;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(ut||={});var ks=class We extends le{constructor(){super(),this.dispatched=!1,this.targets=new Kn,this.ignoreTargets=new Kn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(lm,({window:e,disposables:s})=>{s.add(re(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(re(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(re(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:St,disposables:this._store}))}static addTarget(e){if(!We.isTouchDevice())return le.None;We.INSTANCE||(We.INSTANCE=new We);let s=We.INSTANCE.targets.push(e);return ge(s)}static ignoreTarget(e){if(!We.isTouchDevice())return le.None;We.INSTANCE||(We.INSTANCE=new We);let s=We.INSTANCE.ignoreTargets.push(e);return ge(s)}static isTouchDevice(){return"ontouchstart"in St||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 n=e.targetTouches.item(i);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:s,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[s],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let a=this.newGestureEvent(ut.Start,n.target);a.pageX=n.pageX,a.pageY=n.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 n=0,a=s.changedTouches.length;n<a;n++){let l=s.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<We.HOLD_DELAY&&Math.abs(h.initialPageX-Ze(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ze(h.rollingPageY))<30){let d=this.newGestureEvent(ut.Tap,h.initialTarget);d.pageX=Ze(h.rollingPageX),d.pageY=Ze(h.rollingPageY),this.dispatchEvent(d)}else if(c>=We.HOLD_DELAY&&Math.abs(h.initialPageX-Ze(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ze(h.rollingPageY))<30){let d=this.newGestureEvent(ut.Contextmenu,h.initialTarget);d.pageX=Ze(h.rollingPageX),d.pageY=Ze(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Ze(h.rollingPageX),u=Ze(h.rollingPageY),m=Ze(h.rollingTimestamps)-h.rollingTimestamps[0],_=d-h.rollingPageX[0],f=u-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(e,p,i,Math.abs(_)/m,_>0?1:-1,d,Math.abs(f)/m,f>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(ut.End,h.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===ut.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>We.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===ut.Change||e.type===ut.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,n=e.initialTarget;for(;n&&n!==i;)r++,n=n.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,n,a,l,h,c){this.handle=un(e,()=>{let d=Date.now(),u=d-i,m=0,_=0,f=!0;r+=We.SCROLL_FRICTION*u,l+=We.SCROLL_FRICTION*u,r>0&&(f=!1,m=n*r*u),l>0&&(f=!1,_=h*l*u);let p=this.newGestureEvent(ut.Change);p.translationX=m,p.translationY=_,s.forEach(g=>g.dispatchEvent(p)),f||this.inertia(e,s,d,r,n,a+m,l,h,c+_)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let n=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let a=this.activeTouches[n.identifier],l=this.newGestureEvent(ut.Change,a.initialTarget);l.translationX=n.pageX-Ze(a.rollingPageX),l.translationY=n.pageY-Ze(a.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(n.pageX),a.rollingPageY.push(n.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};ks.SCROLL_FRICTION=-.005,ks.HOLD_DELAY=700,ks.CLEAR_TAP_COUNT_TIME=400,ke([fm],ks,"isTouchDevice",1);var mm=ks,fn=class extends le{onclick(t,e){this._register(re(t,Ae.CLICK,s=>e(new ei(mt(t),s))))}onmousedown(t,e){this._register(re(t,Ae.MOUSE_DOWN,s=>e(new ei(mt(t),s))))}onmouseover(t,e){this._register(re(t,Ae.MOUSE_OVER,s=>e(new ei(mt(t),s))))}onmouseleave(t,e){this._register(re(t,Ae.MOUSE_LEAVE,s=>e(new ei(mt(t),s))))}onkeydown(t,e){this._register(re(t,Ae.KEY_DOWN,s=>e(new Jn(s))))}onkeyup(t,e){this._register(re(t,Ae.KEY_UP,s=>e(new Jn(s))))}oninput(t,e){this._register(re(t,Ae.INPUT,e))}onblur(t,e){this._register(re(t,Ae.BLUR,e))}onfocus(t,e){this._register(re(t,Ae.FOCUS,e))}onchange(t,e){this._register(re(t,Ae.CHANGE,e))}ignoreGesture(t){return mm.ignoreTarget(t)}},io=11,_m=class extends fn{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=io+"px",this.domNode.style.height=io+"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 ll),this._register(to(this.bgDomNode,Ae.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(to(this.domNode,Ae.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new hm),this._pointerdownScheduleRepeatTimer=this._register(new dn)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,mt(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()}},pm=class jr{constructor(e,s,i,r,n,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,n=n|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),n<0&&(n=0),l+n>a&&(l=a-n),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=n,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 jr(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 jr(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,n=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,h=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:n,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},gm=class extends le{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new pm(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 no(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=no.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)))}},ro=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function Xi(t,e){let s=e-t;return function(i){return t+s*bm(i)}}function vm(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var no=class Er{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,n;return e<s?(r=e+.75*i,n=s-.75*i):(r=e-.75*i,n=s+.75*i),vm(Xi(e,r),Xi(n,s),.33)}return Xi(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 ro(i,r,!1)}return new ro(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return Er.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new Er(e,s,r,i)}};function xm(t){return Math.pow(t,3)}function bm(t){return 1-xm(1-t)}var Sm=class extends le{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 dn)}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":"")))}},ym=140,cl=class extends fn{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 Sm(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ll),this._shouldRender=!0,this.domNode=Is(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(re(this.domNode.domNode,Ae.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new _m(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=Is(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(re(this.slider.domNode,Ae.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=dm(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 n=this._sliderOrthogonalPointerPosition(r),a=Math.abs(n-s);if(rl&&a>ym){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()}},hl=class Tr{constructor(e,s,i,r,n,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Tr(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,n){let a=Math.max(0,i-e),l=Math.max(0,a-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/r))),d=(l-c)/(r-i),u=n*d;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=Tr._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)}},wm=class extends cl{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new hl(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}},Cm=class extends cl{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new hl(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}},km=500,oo=50,Nm=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Dr=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 n=r===this._front?e:Math.pow(2,-i);if(e-=n,s+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(cn){let s=mt(e.browserEvent),i=Lf(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,n=new Nm(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=n,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]=n),n.score=this._computeScore(n,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),n=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(r,a),1),c=Math.max(Math.min(n,l),1),d=Math.max(r,a),u=Math.max(n,l);d%h===0&&u%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Dr.INSTANCE=new Dr;var jm=Dr,Em=class extends fn{constructor(t,e,s){super(),this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new q),this.onWillScroll=this._onWillScroll.event,this._options=Dm(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 Cm(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new wm(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=Is(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Is(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Is(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 dn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=$t(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,_t&&(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 Qn(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=$t(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new Qn(s))};this._mouseWheelToDispose.push(re(this._listenOnDomNode,Ae.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=jm.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,n=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+r===0?n=r=0:Math.abs(r)>=Math.abs(n)?n=0:r=0),this._options.flipAxes&&([r,n]=[n,r]);let a=!_t&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!n&&(n=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(n=n*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),h={};if(r){let c=oo*r,d=l.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(h,d)}if(n){let c=oo*n,d=l.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(h,d)}h=this._scrollable.validateScrollPosition(h),(l.scrollLeft!==h.scrollLeft||l.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),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":"",n=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${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(),km)}},Tm=class extends Em{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 Dm(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,_t&&(e.className+=" mac"),e}var Rr=class extends le{constructor(t,e,s,i,r,n,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new gm({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>un(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Tm(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),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($e.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(ge(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(ge(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
176
- `)})),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}};Rr=ke([J(2,Ge),J(3,wt),J(4,Ua),J(5,_s),J(6,Ye),J(7,Ct)],Rr);var Mr=class extends le{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(n=>this._removeDecoration(n))),this._register(ge(()=>{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()}};Mr=ke([J(1,Ge),J(2,wt),J(3,Gs),J(4,Ct)],Mr);var Rm=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)}},ht={full:0,left:0,center:0,right:0},Nt={full:0,left:0,center:0,right:0},xs={full:0,left:0,center:0,right:0},pi=class extends le{constructor(t,e,s,i,r,n,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=n,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Rm,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(ge(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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);Nt.full=this._canvas.width,Nt.left=t,Nt.center=e,Nt.right=t,this._refreshDrawHeightConstants(),xs.full=1,xs.left=1,xs.center=1+Nt.left,xs.right=1+Nt.left+Nt.center}_refreshDrawHeightConstants(){ht.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);ht.left=e,ht.center=e,ht.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.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(xs[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-ht[t.position||"full"]/2),Nt[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+ht[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}))}};pi=ke([J(2,Ge),J(3,Gs),J(4,Ct),J(5,Ye),J(6,_s),J(7,wt)],pi);var H;(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=`
177
- `,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=""))(H||={});var di;(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="Ÿ"))(di||={});var dl;(t=>t.ST=`${H.ESC}\\`)(dl||={});var Ir=class{constructor(t,e,s,i,r,n){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=n,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(`${H.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 n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Ir=ke([J(2,Ge),J(3,Ye),J(4,Ut),J(5,Ct)],Ir);var Pe=0,Le=0,Oe=0,Ce=0,ao={css:"#00000000",rgba:0},Te;(t=>{function e(r,n,a,l){return l!==void 0?`#${At(r)}${At(n)}${At(a)}${At(l)}`:`#${At(r)}${At(n)}${At(a)}`}t.toCss=e;function s(r,n,a,l=255){return(r<<24|n<<16|a<<8|l)>>>0}t.toRgba=s;function i(r,n,a,l){return{css:t.toCss(r,n,a,l),rgba:t.toRgba(r,n,a,l)}}t.toColor=i})(Te||={});var pe;(t=>{function e(h,c){if(Ce=(c.rgba&255)/255,Ce===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,u=c.rgba>>16&255,m=c.rgba>>8&255,_=h.rgba>>24&255,f=h.rgba>>16&255,p=h.rgba>>8&255;Pe=_+Math.round((d-_)*Ce),Le=f+Math.round((u-f)*Ce),Oe=p+Math.round((m-p)*Ce);let g=Te.toCss(Pe,Le,Oe),v=Te.toRgba(Pe,Le,Oe);return{css:g,rgba:v}}t.blend=e;function s(h){return(h.rgba&255)===255}t.isOpaque=s;function i(h,c,d){let u=ui.ensureContrastRatio(h.rgba,c.rgba,d);if(u)return Te.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=i;function r(h){let c=(h.rgba|255)>>>0;return[Pe,Le,Oe]=ui.toChannels(c),{css:Te.toCss(Pe,Le,Oe),rgba:c}}t.opaque=r;function n(h,c){return Ce=Math.round(c*255),[Pe,Le,Oe]=ui.toChannels(h.rgba),{css:Te.toCss(Pe,Le,Oe,Ce),rgba:Te.toRgba(Pe,Le,Oe,Ce)}}t.opacity=n;function a(h,c){return Ce=h.rgba&255,n(h,Ce*c/255)}t.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=l})(pe||={});var be;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,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 Pe=parseInt(r.slice(1,2).repeat(2),16),Le=parseInt(r.slice(2,3).repeat(2),16),Oe=parseInt(r.slice(3,4).repeat(2),16),Te.toColor(Pe,Le,Oe);case 5:return Pe=parseInt(r.slice(1,2).repeat(2),16),Le=parseInt(r.slice(2,3).repeat(2),16),Oe=parseInt(r.slice(3,4).repeat(2),16),Ce=parseInt(r.slice(4,5).repeat(2),16),Te.toColor(Pe,Le,Oe,Ce);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 n=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(n)return Pe=parseInt(n[1]),Le=parseInt(n[2]),Oe=parseInt(n[3]),Ce=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Te.toColor(Pe,Le,Oe,Ce);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),[Pe,Le,Oe,Ce]=e.getImageData(0,0,1,1).data,Ce!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Te.toRgba(Pe,Le,Oe,Ce),css:r}}t.toColor=i})(be||={});var Ue;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,n){let a=i/255,l=r/255,h=n/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+d*.7152+u*.0722}t.relativeLuminance2=s})(Ue||={});var ui;(t=>{function e(a,l){if(Ce=(l&255)/255,Ce===1)return l;let h=l>>24&255,c=l>>16&255,d=l>>8&255,u=a>>24&255,m=a>>16&255,_=a>>8&255;return Pe=u+Math.round((h-u)*Ce),Le=m+Math.round((c-m)*Ce),Oe=_+Math.round((d-_)*Ce),Te.toRgba(Pe,Le,Oe)}t.blend=e;function s(a,l,h){let c=Ue.relativeLuminance(a>>8),d=Ue.relativeLuminance(l>>8);if(xt(c,d)<h){if(d<c){let _=i(a,l,h),f=xt(c,Ue.relativeLuminance(_>>8));if(f<h){let p=r(a,l,h),g=xt(c,Ue.relativeLuminance(p>>8));return f>g?_:p}return _}let u=r(a,l,h),m=xt(c,Ue.relativeLuminance(u>>8));if(m<h){let _=i(a,l,h),f=xt(c,Ue.relativeLuminance(_>>8));return m>f?u:_}return u}}t.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,m=l>>24&255,_=l>>16&255,f=l>>8&255,p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));for(;p<h&&(m>0||_>0||f>0);)m-=Math.max(0,Math.ceil(m*.1)),_-=Math.max(0,Math.ceil(_*.1)),f-=Math.max(0,Math.ceil(f*.1)),p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));return(m<<24|_<<16|f<<8|255)>>>0}t.reduceLuminance=i;function r(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,m=l>>24&255,_=l>>16&255,f=l>>8&255,p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));for(;p<h&&(m<255||_<255||f<255);)m=Math.min(255,m+Math.ceil((255-m)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));return(m<<24|_<<16|f<<8|255)>>>0}t.increaseLuminance=r;function n(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=n})(ui||={});function At(t){let e=t.toString(16);return e.length<2?"0"+e:e}function xt(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var Mm=class extends qs{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()]}},gi=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new nt}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,n=0,a=0,l=e.getFg(0),h=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!==h){if(c-r>1){let d=this._getJoinedRanges(i,a,n,e,r);for(let u=0;u<d.length;u++)s.push(d[u])}r=c,a=n,l=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||Tt.length}if(this._bufferService.cols-r>1){let c=this._getJoinedRanges(i,a,n,e,r);for(let d=0;d<c.length;d++)s.push(c[d])}return s}_getJoinedRanges(t,e,s,i,r){let n=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(n);for(let c=0;c<h.length;c++)gi._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,n=0,a=t[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=e.getWidth(l),c=e.getString(l).length||Tt.length;if(h!==0){if(!r&&a[0]<=n&&(a[0]=l,r=!0),a[1]<=n){if(a[1]=l,a=t[++i],!a)break;a[0]<=n?(a[0]=l,r=!0):r=!1}n+=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}};gi=ke([J(0,Ge)],gi);function Im(t){return 57508<=t&&t<=57558}function Bm(t){return 9472<=t&&t<=9631}function Am(t){return Im(t)||Bm(t)}function Pm(){return{css:{canvas:ti(),cell:ti()},device:{canvas:ti(),cell:ti(),char:{width:0,height:0,left:0,top:0}}}}function ti(){return{width:0,height:0}}var Br=class{constructor(t,e,s,i,r,n,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=n,this._themeService=a,this._workCell=new nt,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,n,a,l,h,c,d){let u=[],m=this._characterJoinerService.getJoinedCharacters(e),_=this._themeService.colors,f=t.getNoBgTrimmedLength();s&&f<n+1&&(f=n+1);let p,g=0,v="",b=0,S=0,x=0,w=0,N=!1,y=0,k=!1,j=0,M=0,R=[],T=c!==-1&&d!==-1;for(let C=0;C<f;C++){t.loadCell(C,this._workCell);let D=this._workCell.getWidth();if(D===0)continue;let E=!1,L=C>=M,z=C,B=this._workCell;if(m.length>0&&C===m[0][0]&&L){let Q=m.shift(),he=this._isCellInSelection(Q[0],e);for(b=Q[0]+1;b<Q[1];b++)L&&=he===this._isCellInSelection(b,e);L&&=!s||n<Q[0]||n>=Q[1],L?(E=!0,B=new Mm(this._workCell,t.translateToString(!0,Q[0],Q[1]),Q[1]-Q[0]),z=Q[1]-1,D=B.getWidth()):M=Q[1]}let O=this._isCellInSelection(C,e),$=s&&C===n,W=T&&C>=c&&C<=d,I=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,Q=>{I=!0});let F=B.getChars()||Tt;if(F===" "&&(B.isUnderline()||B.isOverline())&&(F=" "),j=D*l-h.get(F,B.isBold(),B.isItalic()),!p)p=this._document.createElement("span");else if(g&&(O&&k||!O&&!k&&B.bg===S)&&(O&&k&&_.selectionForeground||B.fg===x)&&B.extended.ext===w&&W===N&&j===y&&!$&&!E&&!I&&L){B.isInvisible()?v+=Tt:v+=F,g++;continue}else g&&(p.textContent=v),p=this._document.createElement("span"),g=0,v="";if(S=B.bg,x=B.fg,w=B.extended.ext,N=W,y=j,k=O,E&&n>=C&&n<=z&&(n=C),!this._coreService.isCursorHidden&&$&&this._coreService.isCursorInitialized){if(R.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&R.push("xterm-cursor-blink"),R.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":R.push("xterm-cursor-outline");break;case"block":R.push("xterm-cursor-block");break;case"bar":R.push("xterm-cursor-bar");break;case"underline":R.push("xterm-cursor-underline");break}}if(B.isBold()&&R.push("xterm-bold"),B.isItalic()&&R.push("xterm-italic"),B.isDim()&&R.push("xterm-dim"),B.isInvisible()?v=Tt:v=B.getChars()||Tt,B.isUnderline()&&(R.push(`xterm-underline-${B.extended.underlineStyle}`),v===" "&&(v=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${qs.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let Q=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&Q<8&&(Q+=8),p.style.textDecorationColor=_.ansi[Q].css}B.isOverline()&&(R.push("xterm-overline"),v===" "&&(v=" ")),B.isStrikethrough()&&R.push("xterm-strikethrough"),W&&(p.style.textDecoration="underline");let U=B.getFgColor(),K=B.getFgColorMode(),G=B.getBgColor(),P=B.getBgColorMode(),Z=!!B.isInverse();if(Z){let Q=U;U=G,G=Q;let he=K;K=P,P=he}let Y,ee,ce=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,Q=>{Q.options.layer!=="top"&&ce||(Q.backgroundColorRGB&&(P=50331648,G=Q.backgroundColorRGB.rgba>>8&16777215,Y=Q.backgroundColorRGB),Q.foregroundColorRGB&&(K=50331648,U=Q.foregroundColorRGB.rgba>>8&16777215,ee=Q.foregroundColorRGB),ce=Q.options.layer==="top")}),!ce&&O&&(Y=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,G=Y.rgba>>8&16777215,P=50331648,ce=!0,_.selectionForeground&&(K=50331648,U=_.selectionForeground.rgba>>8&16777215,ee=_.selectionForeground)),ce&&R.push("xterm-decoration-top");let ie;switch(P){case 16777216:case 33554432:ie=_.ansi[G],R.push(`xterm-bg-${G}`);break;case 50331648:ie=Te.toColor(G>>16,G>>8&255,G&255),this._addStyle(p,`background-color:#${lo((G>>>0).toString(16),"0",6)}`);break;default:Z?(ie=_.foreground,R.push("xterm-bg-257")):ie=_.background}switch(Y||B.isDim()&&(Y=pe.multiplyOpacity(ie,.5)),K){case 16777216:case 33554432:B.isBold()&&U<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(U+=8),this._applyMinimumContrast(p,ie,_.ansi[U],B,Y,void 0)||R.push(`xterm-fg-${U}`);break;case 50331648:let Q=Te.toColor(U>>16&255,U>>8&255,U&255);this._applyMinimumContrast(p,ie,Q,B,Y,ee)||this._addStyle(p,`color:#${lo(U.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,ie,_.foreground,B,Y,ee)||Z&&R.push("xterm-fg-257")}R.length&&(p.className=R.join(" "),R.length=0),!$&&!E&&!I&&L?g++:p.textContent=v,j!==this.defaultSpacing&&(p.style.letterSpacing=`${j}px`),u.push(p),C=z}return p&&g&&(p.textContent=v),u}_applyMinimumContrast(t,e,s,i,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Am(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!n&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=pe.ensureContrastRatio(r||e,n||s,h),a.setColor((r||e).rgba,(n||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]}};Br=ke([J(1,qa),J(2,Ye),J(3,wt),J(4,Ut),J(5,Gs),J(6,_s)],Br);function lo(t,e,s){for(;t.length<s;)t=e+t;return t}var Lm=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 n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[s,i,r,n],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(n),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 n=this._holey.get(r);if(n===void 0){let a=0;e&&(a|=1),s&&(a|=2),n=this._measure(t,a),n>0&&this._holey.set(r,n)}return n}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},Om=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,n=e[1]-r,a=s[1]-r,l=Math.max(n,0),h=Math.min(a,t.rows-1);if(l>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=n,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,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 zm(){return new Om}var Ji="xterm-dom-renderer-owner-",st="xterm-rows",si="xterm-fg-",co="xterm-bg-",bs="xterm-focus",ii="xterm-selection",$m=1,Ar=class extends le{constructor(t,e,s,i,r,n,a,l,h,c,d,u,m,_){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=n,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=m,this._themeService=_,this._terminalClass=$m++,this._rowElements=[],this._selectionRenderModel=zm(),this.onRequestRedraw=this._register(new q).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(st),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(ii),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Pm(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Br,document),this._element.classList.add(Ji+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(ge(()=>{this._element.classList.remove(Ji+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Lm(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} .${st} 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} .${st} { 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} .${st} .xterm-dim { color: ${pe.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} .${st}.${bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${st}.${bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${st}.${bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${ii} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ii} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ii} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[n,a]of t.ansi.entries())e+=`${this._terminalSelector} .${si}${n} { color: ${a.css}; }${this._terminalSelector} .${si}${n}.xterm-dim { color: ${pe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${co}${n} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${si}257 { color: ${pe.opaque(t.background).css}; }${this._terminalSelector} .${si}257.xterm-dim { color: ${pe.multiplyOpacity(pe.opaque(t.background),.5).css}; }${this._terminalSelector} .${co}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(bs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(bs),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,n=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=t[0]>e[0];l.appendChild(this._createSelectionElement(n,h?e[0]:t[0],h?t[0]:e[0],a-n+1))}else{let h=i===n?t[0]:0,c=n===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,h,c));let d=a-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==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"),n=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return n+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-n),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${n}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),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=t;h<=e;h++){let c=h+s.ydisp,d=this._rowElements[h],u=s.lines.get(c);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,c,c===i,a,l,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ji}${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,n){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,h=l.ybase+l.y,c=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=s;_<=i;++_){let f=_+l.ydisp,p=this._rowElements[_],g=l.lines.get(f);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,f,f===h,u,m,c,d,this.dimensions.css.cell.width,this._widthCache,n?_===s?t:0:-1,n?(_===i?e:r)-1:-1))}}};Ar=ke([J(7,on),J(8,Mi),J(9,Ye),J(10,Ge),J(11,Ut),J(12,wt),J(13,_s)],Ar);var Pr=class extends le{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Hm(this._optionsService))}catch{this._measureStrategy=this._register(new Fm(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())}};Pr=ke([J(2,Ye)],Pr);var ul=class extends le{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)}},Fm=class extends ul{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}},Hm=class extends ul{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}},Wm=class extends le{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 Um(this._window)),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(re(this._textarea,"focus",()=>this._isFocused=!0)),this._register(re(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}},Um=class extends le{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new hs),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ge(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=re(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)}},Vm=class extends le{constructor(){super(),this.linkProviders=[],this._register(ge(()=>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 mn(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),n=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-n,e.clientY-i.top-a]}function Km(t,e,s,i,r,n,a,l,h){if(!n)return;let c=mn(t,e,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),r),c}var Lr=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return Km(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=mn(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])}}};Lr=ke([J(0,Ct),J(1,Mi)],Lr);var qm=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=[]}},fl={};sf(fl,{getSafariVersion:()=>Ym,isChromeOS:()=>gl,isFirefox:()=>ml,isIpad:()=>Xm,isIphone:()=>Jm,isLegacyEdge:()=>Gm,isLinux:()=>_n,isMac:()=>vi,isNode:()=>Ii,isSafari:()=>_l,isWindows:()=>pl});var Ii=typeof process<"u"&&"title"in process,Ys=Ii?"node":navigator.userAgent,Xs=Ii?"node":navigator.platform,ml=Ys.includes("Firefox"),Gm=Ys.includes("Edge"),_l=/^((?!chrome|android).)*safari/i.test(Ys);function Ym(){if(!_l)return 0;let t=Ys.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var vi=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Xs),Xm=Xs==="iPad",Jm=Xs==="iPhone",pl=["Windows","Win16","Win32","WinCE"].includes(Xs),_n=Xs.indexOf("Linux")>=0,gl=/\bCrOS\b/.test(Ys),vl=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()}},Zm=class extends vl{_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())}}},Qm=class extends vl{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},xi=!Ii&&"requestIdleCallback"in window?Qm:Zm,e_=class{constructor(){this._queue=new xi}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Or=class extends le{constructor(t,e,s,i,r,n,a,l,h){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new hs),this._pausedResizeTask=new e_,this._observerDisposable=this._register(new hs),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 q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new qm((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new t_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ge(()=>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(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.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(h.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=ge(()=>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()}};Or=ke([J(2,Ye),J(3,Mi),J(4,Ut),J(5,Gs),J(6,Ge),J(7,wt),J(8,_s)],Or);var t_=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 s_(t,e,s,i){let r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return n_(r,n,t,e,s,i)+Bi(n,e,s,i)+o_(r,n,t,e,s,i);let a;if(n===e)return a=r>t?"D":"C",$s(Math.abs(r-t),zs(a,i));a=n>e?"D":"C";let l=Math.abs(n-e),h=r_(n>e?t:r,s)+(l-1)*s.cols+1+i_(n>e?r:t);return $s(h,zs(a,i))}function i_(t,e){return t-1}function r_(t,e){return e.cols-t}function n_(t,e,s,i,r,n){return Bi(e,i,r,n).length===0?"":$s(bl(t,e,t,e-Ft(e,r),!1,r).length,zs("D",n))}function Bi(t,e,s,i){let r=t-Ft(t,s),n=e-Ft(e,s),a=Math.abs(r-n)-a_(t,e,s);return $s(a,zs(xl(t,e),i))}function o_(t,e,s,i,r,n){let a;Bi(e,i,r,n).length>0?a=i-Ft(i,r):a=e;let l=i,h=l_(t,e,s,i,r,n);return $s(bl(t,a,s,l,h==="C",r).length,zs(h,n))}function a_(t,e,s){let i=0,r=t-Ft(t,s),n=e-Ft(e,s);for(let a=0;a<Math.abs(r-n);a++){let l=xl(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&i++}return i}function Ft(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 l_(t,e,s,i,r,n){let a;return Bi(s,i,r,n).length>0?a=i-Ft(i,r):a=e,t<s&&a<=i||t>=s&&a<i?"C":"D"}function xl(t,e){return t>e?"A":"B"}function bl(t,e,s,i,r,n){let a=t,l=e,h="";for(;(a!==s||l!==i)&&l>=0&&l<n.buffer.lines.length;)a+=r?1:-1,r&&a>n.cols-1?(h+=n.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(h+=n.buffer.translateBufferLineToString(l,!1,0,t+1),a=n.cols-1,t=a,l--);return h+n.buffer.translateBufferLineToString(l,!1,t,a)}function zs(t,e){let s=e?"O":"[";return H.ESC+s+t}function $s(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var c_=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 ho(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 Zi=50,h_=15,d_=50,u_=500,f_=" ",m_=new RegExp(f_,"g"),zr=class extends le{constructor(t,e,s,i,r,n,a,l,h){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=n,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new nt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new q),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 c_(this._bufferService),this._activeSelectionMode=0,this._register(ge(()=>{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],n=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,n);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 n=t[1]+1;n<=e[1]-1;n++){let a=s.lines.get(n),l=s.translateBufferLineToString(n,!0);a?.isWrapped?i[i.length-1]+=l:i.push(l)}if(t[1]!==e[1]){let n=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);n&&n.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(m_," ")).join(pl?`\r
175
+ `))}},Df=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Mf=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},If=0,qi=class{constructor(t){this.value=t,this.id=If++}},Bf=2,Af,q=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Tf(t?.onListenerError??li,this._options?.leakWarningThreshold??Ef):void 0,this._perfMon=this._options?._profName?new jf(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],h=new Mf(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||li)(h),le.None}if(this._disposed)return le.None;e&&(t=t.bind(e));let i=new qi(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=Rf.create(),r=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof qi?(this._deliveryQueue??=new Pf,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=ge(()=>{r?.(),this._removeListener(i)});return s instanceof Rt?s.add(n):Array.isArray(s)&&s.push(n),n},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*Bf<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]: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||li;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 qi)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}},Pf=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}},wr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new q,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}};wr.INSTANCE=new wr;var ln=wr;function Lf(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}ln.INSTANCE.onDidChangeZoomLevel;function Of(t){return ln.INSTANCE.getZoomFactor(t)}ln.INSTANCE.onDidChangeFullscreen;var ps=typeof navigator=="object"?navigator.userAgent:"",Cr=ps.indexOf("Firefox")>=0,zf=ps.indexOf("AppleWebKit")>=0,cn=ps.indexOf("Chrome")>=0,$f=!cn&&ps.indexOf("Safari")>=0;ps.indexOf("Electron/")>=0;ps.indexOf("Android")>=0;var Gi=!1;if(typeof St.matchMedia=="function"){let t=St.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=St.matchMedia("(display-mode: fullscreen)");Gi=t.matches,Lf(St,t,({matches:s})=>{Gi&&e.matches||(Gi=s)})}var Zt="en",kr=!1,Nr=!1,ci=!1,il=!1,Qs,hi=Zt,qn=Zt,Ff,bt,zt=globalThis,et;typeof zt.vscode<"u"&&typeof zt.vscode.process<"u"?et=zt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(et=process);var Hf=typeof et?.versions?.electron=="string",Wf=Hf&&et?.type==="renderer";if(typeof et=="object"){kr=et.platform==="win32",Nr=et.platform==="darwin",ci=et.platform==="linux",ci&&et.env.SNAP&&et.env.SNAP_REVISION,et.env.CI||et.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Qs=Zt,hi=Zt;let t=et.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Qs=e.userLocale,qn=e.osLocale,hi=e.resolvedLanguage||Zt,Ff=e.languagePack?.translationsConfigFile}catch{}il=!0}else typeof navigator=="object"&&!Wf?(bt=navigator.userAgent,kr=bt.indexOf("Windows")>=0,Nr=bt.indexOf("Macintosh")>=0,(bt.indexOf("Macintosh")>=0||bt.indexOf("iPad")>=0||bt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ci=bt.indexOf("Linux")>=0,bt?.indexOf("Mobi")>=0,hi=globalThis._VSCODE_NLS_LANGUAGE||Zt,Qs=navigator.language.toLowerCase(),qn=Qs):console.error("Unable to resolve platform.");var rl=kr,_t=Nr,Uf=ci,Gn=il,pt=bt,kt=hi,Vf;(t=>{function e(){return kt}t.value=e;function s(){return kt.length===2?kt==="en":kt.length>=3?kt[0]==="e"&&kt[1]==="n"&&kt[2]==="-":!1}t.isDefaultVariant=s;function i(){return kt==="en"}t.isDefault=i})(Vf||={});var Kf=typeof zt.postMessage=="function"&&!zt.importScripts;(()=>{if(Kf){let t=[];zt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let n=t[i];if(n.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),n.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),zt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var qf=!!(pt&&pt.indexOf("Chrome")>=0);pt&&pt.indexOf("Firefox")>=0;!qf&&pt&&pt.indexOf("Safari")>=0;pt&&pt.indexOf("Edg/")>=0;pt&&pt.indexOf("Android")>=0;var Gt=typeof navigator=="object"?navigator:{};Gn||document.queryCommandSupported&&document.queryCommandSupported("copy")||Gt&&Gt.clipboard&&Gt.clipboard.writeText,Gn||Gt&&Gt.clipboard&&Gt.clipboard.readText;var hn=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}},Yi=new hn,Yn=new hn,Xn=new hn,Gf=new Array(230),nl;(t=>{function e(l){return Yi.keyCodeToStr(l)}t.toString=e;function s(l){return Yi.strToKeyCode(l)}t.fromString=s;function i(l){return Yn.keyCodeToStr(l)}t.toUserSettingsUS=i;function r(l){return Xn.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function n(l){return Yn.strToKeyCode(l)||Xn.strToKeyCode(l)}t.fromUserSettings=n;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 Yi.keyCodeToStr(l)}t.toElectronAccelerator=a})(nl||={});var Yf=class ol{constructor(e,s,i,r,n){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof ol&&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 Xf([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Xf=class{constructor(t){if(t.length===0)throw Sf("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 Jf(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return nl.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(Cr)switch(e){case 59:return 85;case 60:if(Uf)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_t)return 57;break}else if(zf&&(_t&&e===93||!_t&&e===92))return 57;return Gf[e]||0}var Zf=_t?256:2048,Qf=512,em=1024,tm=_t?2048:256,Jn=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=Jf(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|=Zf),this.altKey&&(e|=Qf),this.shiftKey&&(e|=em),this.metaKey&&(e|=tm),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new Yf(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},Zn=new WeakMap;function sm(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 im=class{static getSameOriginWindowChain(t){let e=Zn.get(t);if(!e){e=[],Zn.set(t,e);let s=t,i;do i=sm(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 n of r){let a=n.window.deref();if(s+=a?.scrollY??0,i+=a?.scrollX??0,a===e||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},ei=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=im.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Qn=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(cn){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(t){let r=t,n=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 n.VERTICAL_AXIS<"u"&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Cr&&!_t?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")$f&&rl?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<"u"&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Cr&&!_t?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()}},al=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),rm;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof nm?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:al})})(rm||={});var nm=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?al:(this._emitter||(this._emitter=new q),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},dn=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 vr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new vr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},om=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 vr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=ge(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},am;(t=>{async function e(i){let r,n=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}t.settled=e;function s(i){return new Promise(async(r,n)=>{try{await i(r,n)}catch(a){n(a)}})}t.withAsyncBody=s})(am||={});var eo=class it{static fromArray(e){return new it(s=>{s.emitMany(e)})}static fromPromise(e){return new it(async s=>{s.emitMany(await e)})}static fromPromises(e){return new it(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new it(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 q,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 $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new it(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return it.map(this,e)}static filter(e,s){return new it(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return it.filter(this,e)}static coalesce(e){return it.filter(e,s=>!!s)}coalesce(){return it.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return it.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())}};eo.EMPTY=eo.fromArray([]);var{getWindow:mt,getWindowId:lm,onDidRegisterWindow:cm}=(function(){let t=new Map,e={window:St,disposables:new Rt};t.set(St.vscodeWindowId,e);let s=new q,i=new q,r=new q;function n(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 le.None;let l=new Rt,h={window:a,disposables:l.add(new Rt)};return t.set(a.vscodeWindowId,h),l.add(ge(()=>{t.delete(a.vscodeWindowId),i.fire(a)})),l.add(re(a,Ae.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(h),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:n,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h?.view?h.view.window:St},getDocument(a){return mt(a).document}}})(),hm=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 re(t,e,s,i){return new hm(t,e,s,i)}var to=function(t,e,s,i){return re(t,e,s,i)},un,dm=class extends om{constructor(t){super(),this.defaultTarget=t&&mt(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},so=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){li(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=n=>{s.set(n,!1);let a=t.get(n)??[];for(e.set(n,a),t.set(n,[]),i.set(n,!0);a.length>0;)a.sort(so.sort),a.shift().execute();i.set(n,!1)};un=(n,a,l=0)=>{let h=lm(n),c=new so(a,l),d=t.get(h);return d||(d=[],t.set(h,d)),d.push(c),s.get(h)||(s.set(h,!0),n.requestAnimationFrame(()=>r(h))),c}})();function um(t){let e=t.getBoundingClientRect(),s=mt(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var Ae={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"},fm=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=Je(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Je(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Je(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Je(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Je(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Je(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Je(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Je(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Je(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Je(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Je(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=Je(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=Je(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Je(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 Je(t){return typeof t=="number"?`${t}px`:t}function Is(t){return new fm(t)}var ll=class{constructor(){this._hooks=new Rt,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 n=t;try{t.setPointerCapture(e),this._hooks.add(ge(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{n=mt(t)}this._hooks.add(re(n,Ae.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(re(n,Ae.POINTER_UP,a=>this.stopMonitoring(!0)))}};function mm(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 n=`$memoize$${e}`;s[i]=function(...a){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[n]}}var ut;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(ut||={});var ks=class We extends le{constructor(){super(),this.dispatched=!1,this.targets=new Kn,this.ignoreTargets=new Kn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(cm,({window:e,disposables:s})=>{s.add(re(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(re(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(re(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:St,disposables:this._store}))}static addTarget(e){if(!We.isTouchDevice())return le.None;We.INSTANCE||(We.INSTANCE=new We);let s=We.INSTANCE.targets.push(e);return ge(s)}static ignoreTarget(e){if(!We.isTouchDevice())return le.None;We.INSTANCE||(We.INSTANCE=new We);let s=We.INSTANCE.ignoreTargets.push(e);return ge(s)}static isTouchDevice(){return"ontouchstart"in St||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 n=e.targetTouches.item(i);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:s,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[s],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let a=this.newGestureEvent(ut.Start,n.target);a.pageX=n.pageX,a.pageY=n.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 n=0,a=s.changedTouches.length;n<a;n++){let l=s.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<We.HOLD_DELAY&&Math.abs(h.initialPageX-Ze(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ze(h.rollingPageY))<30){let d=this.newGestureEvent(ut.Tap,h.initialTarget);d.pageX=Ze(h.rollingPageX),d.pageY=Ze(h.rollingPageY),this.dispatchEvent(d)}else if(c>=We.HOLD_DELAY&&Math.abs(h.initialPageX-Ze(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ze(h.rollingPageY))<30){let d=this.newGestureEvent(ut.Contextmenu,h.initialTarget);d.pageX=Ze(h.rollingPageX),d.pageY=Ze(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Ze(h.rollingPageX),u=Ze(h.rollingPageY),m=Ze(h.rollingTimestamps)-h.rollingTimestamps[0],_=d-h.rollingPageX[0],f=u-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(e,p,i,Math.abs(_)/m,_>0?1:-1,d,Math.abs(f)/m,f>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(ut.End,h.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===ut.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>We.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===ut.Change||e.type===ut.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,n=e.initialTarget;for(;n&&n!==i;)r++,n=n.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,n,a,l,h,c){this.handle=un(e,()=>{let d=Date.now(),u=d-i,m=0,_=0,f=!0;r+=We.SCROLL_FRICTION*u,l+=We.SCROLL_FRICTION*u,r>0&&(f=!1,m=n*r*u),l>0&&(f=!1,_=h*l*u);let p=this.newGestureEvent(ut.Change);p.translationX=m,p.translationY=_,s.forEach(g=>g.dispatchEvent(p)),f||this.inertia(e,s,d,r,n,a+m,l,h,c+_)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let n=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let a=this.activeTouches[n.identifier],l=this.newGestureEvent(ut.Change,a.initialTarget);l.translationX=n.pageX-Ze(a.rollingPageX),l.translationY=n.pageY-Ze(a.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(n.pageX),a.rollingPageY.push(n.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};ks.SCROLL_FRICTION=-.005,ks.HOLD_DELAY=700,ks.CLEAR_TAP_COUNT_TIME=400,ke([mm],ks,"isTouchDevice",1);var _m=ks,fn=class extends le{onclick(t,e){this._register(re(t,Ae.CLICK,s=>e(new ei(mt(t),s))))}onmousedown(t,e){this._register(re(t,Ae.MOUSE_DOWN,s=>e(new ei(mt(t),s))))}onmouseover(t,e){this._register(re(t,Ae.MOUSE_OVER,s=>e(new ei(mt(t),s))))}onmouseleave(t,e){this._register(re(t,Ae.MOUSE_LEAVE,s=>e(new ei(mt(t),s))))}onkeydown(t,e){this._register(re(t,Ae.KEY_DOWN,s=>e(new Jn(s))))}onkeyup(t,e){this._register(re(t,Ae.KEY_UP,s=>e(new Jn(s))))}oninput(t,e){this._register(re(t,Ae.INPUT,e))}onblur(t,e){this._register(re(t,Ae.BLUR,e))}onfocus(t,e){this._register(re(t,Ae.FOCUS,e))}onchange(t,e){this._register(re(t,Ae.CHANGE,e))}ignoreGesture(t){return _m.ignoreTarget(t)}},io=11,pm=class extends fn{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=io+"px",this.domNode.style.height=io+"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 ll),this._register(to(this.bgDomNode,Ae.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(to(this.domNode,Ae.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new dm),this._pointerdownScheduleRepeatTimer=this._register(new dn)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,mt(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()}},gm=class jr{constructor(e,s,i,r,n,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,n=n|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),n<0&&(n=0),l+n>a&&(l=a-n),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=n,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 jr(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 jr(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,n=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,h=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:n,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},vm=class extends le{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new gm(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 no(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=no.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)))}},ro=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function Xi(t,e){let s=e-t;return function(i){return t+s*Sm(i)}}function xm(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var no=class Er{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,n;return e<s?(r=e+.75*i,n=s-.75*i):(r=e-.75*i,n=s+.75*i),xm(Xi(e,r),Xi(n,s),.33)}return Xi(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 ro(i,r,!1)}return new ro(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return Er.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new Er(e,s,r,i)}};function bm(t){return Math.pow(t,3)}function Sm(t){return 1-bm(1-t)}var ym=class extends le{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 dn)}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":"")))}},wm=140,cl=class extends fn{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 ym(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ll),this._shouldRender=!0,this.domNode=Is(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(re(this.domNode.domNode,Ae.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new pm(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=Is(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(re(this.slider.domNode,Ae.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=um(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 n=this._sliderOrthogonalPointerPosition(r),a=Math.abs(n-s);if(rl&&a>wm){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()}},hl=class Tr{constructor(e,s,i,r,n,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Tr(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,n){let a=Math.max(0,i-e),l=Math.max(0,a-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/r))),d=(l-c)/(r-i),u=n*d;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=Tr._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)}},Cm=class extends cl{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new hl(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}},km=class extends cl{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new hl(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}},Nm=500,oo=50,jm=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Rr=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 n=r===this._front?e:Math.pow(2,-i);if(e-=n,s+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(cn){let s=mt(e.browserEvent),i=Of(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,n=new jm(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=n,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]=n),n.score=this._computeScore(n,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),n=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(r,a),1),c=Math.max(Math.min(n,l),1),d=Math.max(r,a),u=Math.max(n,l);d%h===0&&u%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Rr.INSTANCE=new Rr;var Em=Rr,Tm=class extends fn{constructor(t,e,s){super(),this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new q),this.onWillScroll=this._onWillScroll.event,this._options=Dm(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 km(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Cm(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=Is(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Is(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Is(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 dn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=$t(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,_t&&(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 Qn(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=$t(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new Qn(s))};this._mouseWheelToDispose.push(re(this._listenOnDomNode,Ae.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=Em.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,n=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+r===0?n=r=0:Math.abs(r)>=Math.abs(n)?n=0:r=0),this._options.flipAxes&&([r,n]=[n,r]);let a=!_t&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!n&&(n=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(n=n*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),h={};if(r){let c=oo*r,d=l.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(h,d)}if(n){let c=oo*n,d=l.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(h,d)}h=this._scrollable.validateScrollPosition(h),(l.scrollLeft!==h.scrollLeft||l.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),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":"",n=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${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(),Nm)}},Rm=class extends Tm{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 Dm(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,_t&&(e.className+=" mac"),e}var Dr=class extends le{constructor(t,e,s,i,r,n,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new vm({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>un(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Rm(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),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($e.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(ge(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(ge(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
176
+ `)})),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}};Dr=ke([J(2,Ge),J(3,wt),J(4,Ua),J(5,_s),J(6,Ye),J(7,Ct)],Dr);var Mr=class extends le{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(n=>this._removeDecoration(n))),this._register(ge(()=>{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()}};Mr=ke([J(1,Ge),J(2,wt),J(3,Gs),J(4,Ct)],Mr);var Mm=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)}},ht={full:0,left:0,center:0,right:0},Nt={full:0,left:0,center:0,right:0},xs={full:0,left:0,center:0,right:0},pi=class extends le{constructor(t,e,s,i,r,n,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=n,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Mm,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(ge(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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);Nt.full=this._canvas.width,Nt.left=t,Nt.center=e,Nt.right=t,this._refreshDrawHeightConstants(),xs.full=1,xs.left=1,xs.center=1+Nt.left,xs.right=1+Nt.left+Nt.center}_refreshDrawHeightConstants(){ht.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);ht.left=e,ht.center=e,ht.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ht.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(xs[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-ht[t.position||"full"]/2),Nt[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+ht[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}))}};pi=ke([J(2,Ge),J(3,Gs),J(4,Ct),J(5,Ye),J(6,_s),J(7,wt)],pi);var H;(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=`
177
+ `,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=""))(H||={});var di;(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="Ÿ"))(di||={});var dl;(t=>t.ST=`${H.ESC}\\`)(dl||={});var Ir=class{constructor(t,e,s,i,r,n){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=n,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(`${H.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 n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Ir=ke([J(2,Ge),J(3,Ye),J(4,Ut),J(5,Ct)],Ir);var Pe=0,Le=0,Oe=0,Ce=0,ao={css:"#00000000",rgba:0},Te;(t=>{function e(r,n,a,l){return l!==void 0?`#${At(r)}${At(n)}${At(a)}${At(l)}`:`#${At(r)}${At(n)}${At(a)}`}t.toCss=e;function s(r,n,a,l=255){return(r<<24|n<<16|a<<8|l)>>>0}t.toRgba=s;function i(r,n,a,l){return{css:t.toCss(r,n,a,l),rgba:t.toRgba(r,n,a,l)}}t.toColor=i})(Te||={});var pe;(t=>{function e(h,c){if(Ce=(c.rgba&255)/255,Ce===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,u=c.rgba>>16&255,m=c.rgba>>8&255,_=h.rgba>>24&255,f=h.rgba>>16&255,p=h.rgba>>8&255;Pe=_+Math.round((d-_)*Ce),Le=f+Math.round((u-f)*Ce),Oe=p+Math.round((m-p)*Ce);let g=Te.toCss(Pe,Le,Oe),v=Te.toRgba(Pe,Le,Oe);return{css:g,rgba:v}}t.blend=e;function s(h){return(h.rgba&255)===255}t.isOpaque=s;function i(h,c,d){let u=ui.ensureContrastRatio(h.rgba,c.rgba,d);if(u)return Te.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=i;function r(h){let c=(h.rgba|255)>>>0;return[Pe,Le,Oe]=ui.toChannels(c),{css:Te.toCss(Pe,Le,Oe),rgba:c}}t.opaque=r;function n(h,c){return Ce=Math.round(c*255),[Pe,Le,Oe]=ui.toChannels(h.rgba),{css:Te.toCss(Pe,Le,Oe,Ce),rgba:Te.toRgba(Pe,Le,Oe,Ce)}}t.opacity=n;function a(h,c){return Ce=h.rgba&255,n(h,Ce*c/255)}t.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=l})(pe||={});var be;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,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 Pe=parseInt(r.slice(1,2).repeat(2),16),Le=parseInt(r.slice(2,3).repeat(2),16),Oe=parseInt(r.slice(3,4).repeat(2),16),Te.toColor(Pe,Le,Oe);case 5:return Pe=parseInt(r.slice(1,2).repeat(2),16),Le=parseInt(r.slice(2,3).repeat(2),16),Oe=parseInt(r.slice(3,4).repeat(2),16),Ce=parseInt(r.slice(4,5).repeat(2),16),Te.toColor(Pe,Le,Oe,Ce);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 n=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(n)return Pe=parseInt(n[1]),Le=parseInt(n[2]),Oe=parseInt(n[3]),Ce=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Te.toColor(Pe,Le,Oe,Ce);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),[Pe,Le,Oe,Ce]=e.getImageData(0,0,1,1).data,Ce!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Te.toRgba(Pe,Le,Oe,Ce),css:r}}t.toColor=i})(be||={});var Ue;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,n){let a=i/255,l=r/255,h=n/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+d*.7152+u*.0722}t.relativeLuminance2=s})(Ue||={});var ui;(t=>{function e(a,l){if(Ce=(l&255)/255,Ce===1)return l;let h=l>>24&255,c=l>>16&255,d=l>>8&255,u=a>>24&255,m=a>>16&255,_=a>>8&255;return Pe=u+Math.round((h-u)*Ce),Le=m+Math.round((c-m)*Ce),Oe=_+Math.round((d-_)*Ce),Te.toRgba(Pe,Le,Oe)}t.blend=e;function s(a,l,h){let c=Ue.relativeLuminance(a>>8),d=Ue.relativeLuminance(l>>8);if(xt(c,d)<h){if(d<c){let _=i(a,l,h),f=xt(c,Ue.relativeLuminance(_>>8));if(f<h){let p=r(a,l,h),g=xt(c,Ue.relativeLuminance(p>>8));return f>g?_:p}return _}let u=r(a,l,h),m=xt(c,Ue.relativeLuminance(u>>8));if(m<h){let _=i(a,l,h),f=xt(c,Ue.relativeLuminance(_>>8));return m>f?u:_}return u}}t.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,m=l>>24&255,_=l>>16&255,f=l>>8&255,p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));for(;p<h&&(m>0||_>0||f>0);)m-=Math.max(0,Math.ceil(m*.1)),_-=Math.max(0,Math.ceil(_*.1)),f-=Math.max(0,Math.ceil(f*.1)),p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));return(m<<24|_<<16|f<<8|255)>>>0}t.reduceLuminance=i;function r(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,m=l>>24&255,_=l>>16&255,f=l>>8&255,p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));for(;p<h&&(m<255||_<255||f<255);)m=Math.min(255,m+Math.ceil((255-m)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),p=xt(Ue.relativeLuminance2(m,_,f),Ue.relativeLuminance2(c,d,u));return(m<<24|_<<16|f<<8|255)>>>0}t.increaseLuminance=r;function n(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=n})(ui||={});function At(t){let e=t.toString(16);return e.length<2?"0"+e:e}function xt(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var Im=class extends qs{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()]}},gi=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new nt}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,n=0,a=0,l=e.getFg(0),h=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!==h){if(c-r>1){let d=this._getJoinedRanges(i,a,n,e,r);for(let u=0;u<d.length;u++)s.push(d[u])}r=c,a=n,l=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||Tt.length}if(this._bufferService.cols-r>1){let c=this._getJoinedRanges(i,a,n,e,r);for(let d=0;d<c.length;d++)s.push(c[d])}return s}_getJoinedRanges(t,e,s,i,r){let n=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(n);for(let c=0;c<h.length;c++)gi._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,n=0,a=t[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=e.getWidth(l),c=e.getString(l).length||Tt.length;if(h!==0){if(!r&&a[0]<=n&&(a[0]=l,r=!0),a[1]<=n){if(a[1]=l,a=t[++i],!a)break;a[0]<=n?(a[0]=l,r=!0):r=!1}n+=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}};gi=ke([J(0,Ge)],gi);function Bm(t){return 57508<=t&&t<=57558}function Am(t){return 9472<=t&&t<=9631}function Pm(t){return Bm(t)||Am(t)}function Lm(){return{css:{canvas:ti(),cell:ti()},device:{canvas:ti(),cell:ti(),char:{width:0,height:0,left:0,top:0}}}}function ti(){return{width:0,height:0}}var Br=class{constructor(t,e,s,i,r,n,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=n,this._themeService=a,this._workCell=new nt,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,n,a,l,h,c,d){let u=[],m=this._characterJoinerService.getJoinedCharacters(e),_=this._themeService.colors,f=t.getNoBgTrimmedLength();s&&f<n+1&&(f=n+1);let p,g=0,v="",b=0,S=0,x=0,w=0,N=!1,y=0,k=!1,j=0,M=0,D=[],T=c!==-1&&d!==-1;for(let C=0;C<f;C++){t.loadCell(C,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let E=!1,L=C>=M,z=C,B=this._workCell;if(m.length>0&&C===m[0][0]&&L){let Q=m.shift(),he=this._isCellInSelection(Q[0],e);for(b=Q[0]+1;b<Q[1];b++)L&&=he===this._isCellInSelection(b,e);L&&=!s||n<Q[0]||n>=Q[1],L?(E=!0,B=new Im(this._workCell,t.translateToString(!0,Q[0],Q[1]),Q[1]-Q[0]),z=Q[1]-1,R=B.getWidth()):M=Q[1]}let O=this._isCellInSelection(C,e),$=s&&C===n,W=T&&C>=c&&C<=d,I=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,Q=>{I=!0});let F=B.getChars()||Tt;if(F===" "&&(B.isUnderline()||B.isOverline())&&(F=" "),j=R*l-h.get(F,B.isBold(),B.isItalic()),!p)p=this._document.createElement("span");else if(g&&(O&&k||!O&&!k&&B.bg===S)&&(O&&k&&_.selectionForeground||B.fg===x)&&B.extended.ext===w&&W===N&&j===y&&!$&&!E&&!I&&L){B.isInvisible()?v+=Tt:v+=F,g++;continue}else g&&(p.textContent=v),p=this._document.createElement("span"),g=0,v="";if(S=B.bg,x=B.fg,w=B.extended.ext,N=W,y=j,k=O,E&&n>=C&&n<=z&&(n=C),!this._coreService.isCursorHidden&&$&&this._coreService.isCursorInitialized){if(D.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&D.push("xterm-cursor-blink"),D.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":D.push("xterm-cursor-outline");break;case"block":D.push("xterm-cursor-block");break;case"bar":D.push("xterm-cursor-bar");break;case"underline":D.push("xterm-cursor-underline");break}}if(B.isBold()&&D.push("xterm-bold"),B.isItalic()&&D.push("xterm-italic"),B.isDim()&&D.push("xterm-dim"),B.isInvisible()?v=Tt:v=B.getChars()||Tt,B.isUnderline()&&(D.push(`xterm-underline-${B.extended.underlineStyle}`),v===" "&&(v=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${qs.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let Q=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&Q<8&&(Q+=8),p.style.textDecorationColor=_.ansi[Q].css}B.isOverline()&&(D.push("xterm-overline"),v===" "&&(v=" ")),B.isStrikethrough()&&D.push("xterm-strikethrough"),W&&(p.style.textDecoration="underline");let U=B.getFgColor(),K=B.getFgColorMode(),G=B.getBgColor(),P=B.getBgColorMode(),Z=!!B.isInverse();if(Z){let Q=U;U=G,G=Q;let he=K;K=P,P=he}let Y,ee,ce=!1;this._decorationService.forEachDecorationAtCell(C,e,void 0,Q=>{Q.options.layer!=="top"&&ce||(Q.backgroundColorRGB&&(P=50331648,G=Q.backgroundColorRGB.rgba>>8&16777215,Y=Q.backgroundColorRGB),Q.foregroundColorRGB&&(K=50331648,U=Q.foregroundColorRGB.rgba>>8&16777215,ee=Q.foregroundColorRGB),ce=Q.options.layer==="top")}),!ce&&O&&(Y=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,G=Y.rgba>>8&16777215,P=50331648,ce=!0,_.selectionForeground&&(K=50331648,U=_.selectionForeground.rgba>>8&16777215,ee=_.selectionForeground)),ce&&D.push("xterm-decoration-top");let ie;switch(P){case 16777216:case 33554432:ie=_.ansi[G],D.push(`xterm-bg-${G}`);break;case 50331648:ie=Te.toColor(G>>16,G>>8&255,G&255),this._addStyle(p,`background-color:#${lo((G>>>0).toString(16),"0",6)}`);break;default:Z?(ie=_.foreground,D.push("xterm-bg-257")):ie=_.background}switch(Y||B.isDim()&&(Y=pe.multiplyOpacity(ie,.5)),K){case 16777216:case 33554432:B.isBold()&&U<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(U+=8),this._applyMinimumContrast(p,ie,_.ansi[U],B,Y,void 0)||D.push(`xterm-fg-${U}`);break;case 50331648:let Q=Te.toColor(U>>16&255,U>>8&255,U&255);this._applyMinimumContrast(p,ie,Q,B,Y,ee)||this._addStyle(p,`color:#${lo(U.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,ie,_.foreground,B,Y,ee)||Z&&D.push("xterm-fg-257")}D.length&&(p.className=D.join(" "),D.length=0),!$&&!E&&!I&&L?g++:p.textContent=v,j!==this.defaultSpacing&&(p.style.letterSpacing=`${j}px`),u.push(p),C=z}return p&&g&&(p.textContent=v),u}_applyMinimumContrast(t,e,s,i,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Pm(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!n&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=pe.ensureContrastRatio(r||e,n||s,h),a.setColor((r||e).rgba,(n||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]}};Br=ke([J(1,qa),J(2,Ye),J(3,wt),J(4,Ut),J(5,Gs),J(6,_s)],Br);function lo(t,e,s){for(;t.length<s;)t=e+t;return t}var Om=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 n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[s,i,r,n],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(n),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 n=this._holey.get(r);if(n===void 0){let a=0;e&&(a|=1),s&&(a|=2),n=this._measure(t,a),n>0&&this._holey.set(r,n)}return n}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},zm=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,n=e[1]-r,a=s[1]-r,l=Math.max(n,0),h=Math.min(a,t.rows-1);if(l>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=n,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,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 $m(){return new zm}var Ji="xterm-dom-renderer-owner-",st="xterm-rows",si="xterm-fg-",co="xterm-bg-",bs="xterm-focus",ii="xterm-selection",Fm=1,Ar=class extends le{constructor(t,e,s,i,r,n,a,l,h,c,d,u,m,_){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=n,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=m,this._themeService=_,this._terminalClass=Fm++,this._rowElements=[],this._selectionRenderModel=$m(),this.onRequestRedraw=this._register(new q).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(st),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(ii),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Lm(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Br,document),this._element.classList.add(Ji+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(ge(()=>{this._element.classList.remove(Ji+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Om(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} .${st} 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} .${st} { 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} .${st} .xterm-dim { color: ${pe.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} .${st}.${bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${st}.${bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${st}.${bs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${st} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${ii} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ii} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ii} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[n,a]of t.ansi.entries())e+=`${this._terminalSelector} .${si}${n} { color: ${a.css}; }${this._terminalSelector} .${si}${n}.xterm-dim { color: ${pe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${co}${n} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${si}257 { color: ${pe.opaque(t.background).css}; }${this._terminalSelector} .${si}257.xterm-dim { color: ${pe.multiplyOpacity(pe.opaque(t.background),.5).css}; }${this._terminalSelector} .${co}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(bs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(bs),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,n=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=t[0]>e[0];l.appendChild(this._createSelectionElement(n,h?e[0]:t[0],h?t[0]:e[0],a-n+1))}else{let h=i===n?t[0]:0,c=n===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,h,c));let d=a-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==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"),n=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return n+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-n),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${n}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),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=t;h<=e;h++){let c=h+s.ydisp,d=this._rowElements[h],u=s.lines.get(c);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,c,c===i,a,l,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ji}${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,n){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,h=l.ybase+l.y,c=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=s;_<=i;++_){let f=_+l.ydisp,p=this._rowElements[_],g=l.lines.get(f);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,f,f===h,u,m,c,d,this.dimensions.css.cell.width,this._widthCache,n?_===s?t:0:-1,n?(_===i?e:r)-1:-1))}}};Ar=ke([J(7,on),J(8,Mi),J(9,Ye),J(10,Ge),J(11,Ut),J(12,wt),J(13,_s)],Ar);var Pr=class extends le{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Wm(this._optionsService))}catch{this._measureStrategy=this._register(new Hm(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())}};Pr=ke([J(2,Ye)],Pr);var ul=class extends le{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)}},Hm=class extends ul{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}},Wm=class extends ul{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}},Um=class extends le{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 Vm(this._window)),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(re(this._textarea,"focus",()=>this._isFocused=!0)),this._register(re(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}},Vm=class extends le{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new hs),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ge(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=re(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)}},Km=class extends le{constructor(){super(),this.linkProviders=[],this._register(ge(()=>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 mn(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),n=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-n,e.clientY-i.top-a]}function qm(t,e,s,i,r,n,a,l,h){if(!n)return;let c=mn(t,e,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),r),c}var Lr=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return qm(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=mn(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])}}};Lr=ke([J(0,Ct),J(1,Mi)],Lr);var Gm=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=[]}},fl={};rf(fl,{getSafariVersion:()=>Xm,isChromeOS:()=>gl,isFirefox:()=>ml,isIpad:()=>Jm,isIphone:()=>Zm,isLegacyEdge:()=>Ym,isLinux:()=>_n,isMac:()=>vi,isNode:()=>Ii,isSafari:()=>_l,isWindows:()=>pl});var Ii=typeof process<"u"&&"title"in process,Ys=Ii?"node":navigator.userAgent,Xs=Ii?"node":navigator.platform,ml=Ys.includes("Firefox"),Ym=Ys.includes("Edge"),_l=/^((?!chrome|android).)*safari/i.test(Ys);function Xm(){if(!_l)return 0;let t=Ys.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var vi=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Xs),Jm=Xs==="iPad",Zm=Xs==="iPhone",pl=["Windows","Win16","Win32","WinCE"].includes(Xs),_n=Xs.indexOf("Linux")>=0,gl=/\bCrOS\b/.test(Ys),vl=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()}},Qm=class extends vl{_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())}}},e_=class extends vl{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},xi=!Ii&&"requestIdleCallback"in window?e_:Qm,t_=class{constructor(){this._queue=new xi}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Or=class extends le{constructor(t,e,s,i,r,n,a,l,h){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new hs),this._pausedResizeTask=new t_,this._observerDisposable=this._register(new hs),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 q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Gm((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new s_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ge(()=>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(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.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(h.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=ge(()=>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()}};Or=ke([J(2,Ye),J(3,Mi),J(4,Ut),J(5,Gs),J(6,Ge),J(7,wt),J(8,_s)],Or);var s_=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 i_(t,e,s,i){let r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return o_(r,n,t,e,s,i)+Bi(n,e,s,i)+a_(r,n,t,e,s,i);let a;if(n===e)return a=r>t?"D":"C",$s(Math.abs(r-t),zs(a,i));a=n>e?"D":"C";let l=Math.abs(n-e),h=n_(n>e?t:r,s)+(l-1)*s.cols+1+r_(n>e?r:t);return $s(h,zs(a,i))}function r_(t,e){return t-1}function n_(t,e){return e.cols-t}function o_(t,e,s,i,r,n){return Bi(e,i,r,n).length===0?"":$s(bl(t,e,t,e-Ft(e,r),!1,r).length,zs("D",n))}function Bi(t,e,s,i){let r=t-Ft(t,s),n=e-Ft(e,s),a=Math.abs(r-n)-l_(t,e,s);return $s(a,zs(xl(t,e),i))}function a_(t,e,s,i,r,n){let a;Bi(e,i,r,n).length>0?a=i-Ft(i,r):a=e;let l=i,h=c_(t,e,s,i,r,n);return $s(bl(t,a,s,l,h==="C",r).length,zs(h,n))}function l_(t,e,s){let i=0,r=t-Ft(t,s),n=e-Ft(e,s);for(let a=0;a<Math.abs(r-n);a++){let l=xl(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&i++}return i}function Ft(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 c_(t,e,s,i,r,n){let a;return Bi(s,i,r,n).length>0?a=i-Ft(i,r):a=e,t<s&&a<=i||t>=s&&a<i?"C":"D"}function xl(t,e){return t>e?"A":"B"}function bl(t,e,s,i,r,n){let a=t,l=e,h="";for(;(a!==s||l!==i)&&l>=0&&l<n.buffer.lines.length;)a+=r?1:-1,r&&a>n.cols-1?(h+=n.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(h+=n.buffer.translateBufferLineToString(l,!1,0,t+1),a=n.cols-1,t=a,l--);return h+n.buffer.translateBufferLineToString(l,!1,t,a)}function zs(t,e){let s=e?"O":"[";return H.ESC+s+t}function $s(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var h_=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 ho(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 Zi=50,d_=15,u_=50,f_=500,m_=" ",__=new RegExp(m_,"g"),zr=class extends le{constructor(t,e,s,i,r,n,a,l,h){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=n,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new nt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new q),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 h_(this._bufferService),this._activeSelectionMode=0,this._register(ge(()=>{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],n=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,n);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 n=t[1]+1;n<=e[1]-1;n++){let a=s.lines.get(n),l=s.translateBufferLineToString(n,!0);a?.isWrapped?i[i.length-1]+=l:i.push(l)}if(t[1]!==e[1]){let n=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);n&&n.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(__," ")).join(pl?`\r
178
178
  `:`
179
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),_n&&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=ho(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=mn(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,-Zi),Zi),e/=Zi,e/Math.abs(e)+Math.round(e*(h_-1)))}shouldForceSelection(t){return vi?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(),d_)}_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&&!(vi&&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<u_&&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=s_(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,n=r.lines.get(t[1]);if(!n)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(n,t[0]),h=l,c=t[0]-l,d=0,u=0,m=0,_=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let g=t[0],v=t[0];n.getWidth(g)===0&&(d++,g--),n.getWidth(v)===2&&(u++,v++);let b=n.getString(v).length;for(b>1&&(_+=b-1,h+=b-1);g>0&&l>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):S>1&&(m+=S-1,l-=S-1),l--,g--}for(;v<n.length&&h+1<a.length&&!this._isCharWordSeparator(n.loadCell(v+1,this._workCell));){n.loadCell(v+1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):S>1&&(_+=S-1,h+=S-1),h++,v++}}h++;let f=l+c-d+m,p=Math.min(this._bufferService.cols,h-l+d+u-m-_);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&f===0&&n.getCodePoint(0)!==32){let g=r.lines.get(t[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let b=this._bufferService.cols-v.start;f-=b,p+=b}}}if(i&&f+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(t[1]+1);if(g?.isWrapped&&g.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(p+=v.length)}}return{start:f,length:p}}}_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=ho(s,this._bufferService.cols)}};zr=ke([J(3,Ge),J(4,Ut),J(5,an),J(6,Ye),J(7,Ct),J(8,wt)],zr);var uo=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={}}},fo=class{constructor(){this._color=new uo,this._css=new uo}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()}},De=Object.freeze((()=>{let t=[be.toColor("#2e3436"),be.toColor("#cc0000"),be.toColor("#4e9a06"),be.toColor("#c4a000"),be.toColor("#3465a4"),be.toColor("#75507b"),be.toColor("#06989a"),be.toColor("#d3d7cf"),be.toColor("#555753"),be.toColor("#ef2929"),be.toColor("#8ae234"),be.toColor("#fce94f"),be.toColor("#729fcf"),be.toColor("#ad7fa8"),be.toColor("#34e2e2"),be.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],n=e[s%6];t.push({css:Te.toCss(i,r,n),rgba:Te.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Te.toCss(i,i,i),rgba:Te.toRgba(i,i,i)})}return t})()),Pt=be.toColor("#ffffff"),Ns=be.toColor("#000000"),mo=be.toColor("#ffffff"),_o=Ns,Ss={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},__=Pt,$r=class extends le{constructor(t){super(),this._optionsService=t,this._contrastCache=new fo,this._halfContrastCache=new fo,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Pt,background:Ns,cursor:mo,cursorAccent:_o,selectionForeground:void 0,selectionBackgroundTransparent:Ss,selectionBackgroundOpaque:pe.blend(Ns,Ss),selectionInactiveBackgroundTransparent:Ss,selectionInactiveBackgroundOpaque:pe.blend(Ns,Ss),scrollbarSliderBackground:pe.opacity(Pt,.2),scrollbarSliderHoverBackground:pe.opacity(Pt,.4),scrollbarSliderActiveBackground:pe.opacity(Pt,.5),overviewRulerBorder:Pt,ansi:De.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=fe(t.foreground,Pt),e.background=fe(t.background,Ns),e.cursor=pe.blend(e.background,fe(t.cursor,mo)),e.cursorAccent=pe.blend(e.background,fe(t.cursorAccent,_o)),e.selectionBackgroundTransparent=fe(t.selectionBackground,Ss),e.selectionBackgroundOpaque=pe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=fe(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=pe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?fe(t.selectionForeground,ao):void 0,e.selectionForeground===ao&&(e.selectionForeground=void 0),pe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=pe.opacity(e.selectionBackgroundTransparent,.3)),pe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=pe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=fe(t.scrollbarSliderBackground,pe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=fe(t.scrollbarSliderHoverBackground,pe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=fe(t.scrollbarSliderActiveBackground,pe.opacity(e.foreground,.5)),e.overviewRulerBorder=fe(t.overviewRulerBorder,__),e.ansi=De.slice(),e.ansi[0]=fe(t.black,De[0]),e.ansi[1]=fe(t.red,De[1]),e.ansi[2]=fe(t.green,De[2]),e.ansi[3]=fe(t.yellow,De[3]),e.ansi[4]=fe(t.blue,De[4]),e.ansi[5]=fe(t.magenta,De[5]),e.ansi[6]=fe(t.cyan,De[6]),e.ansi[7]=fe(t.white,De[7]),e.ansi[8]=fe(t.brightBlack,De[8]),e.ansi[9]=fe(t.brightRed,De[9]),e.ansi[10]=fe(t.brightGreen,De[10]),e.ansi[11]=fe(t.brightYellow,De[11]),e.ansi[12]=fe(t.brightBlue,De[12]),e.ansi[13]=fe(t.brightMagenta,De[13]),e.ansi[14]=fe(t.brightCyan,De[14]),e.ansi[15]=fe(t.brightWhite,De[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]=fe(t.extendedAnsi[i],De[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()}}};$r=ke([J(0,Ye)],$r);function fe(t,e){if(t!==void 0)try{return be.toColor(t)}catch{}return e}var p_=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)}},g_=class{constructor(){this._services=new p_,this._services.set(on,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=hf(t).sort((n,a)=>n.index-a.index),i=[];for(let n of s){let a=this._services.get(n.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.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)}},v_={trace:0,debug:1,info:2,warn:3,error:4,off:5},x_="xterm.js: ",Fr=class extends le{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=v_[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?"":x_)+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)}};Fr=ke([J(0,Ye)],Fr);var po=class extends le{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new q),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,Ee=Object.freeze(new qs),ri=0,Qi=2,js=class Sl{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ae);let r=s||nt.fromCharData([0,$a,1,0]);for(let n=0;n<e;++n)this.setCell(n,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?Et(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?Et(s&2097151):""}isProtected(e){return this._data[e*ae+2]&536870912}loadCell(e,s){return ri=e*ae,s.content=this._data[ri+0],s.fg=this._data[ri+1],s.bg=this._data[ri+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]+=Et(s):r&2097151?(this._combined[e]=Et(r&2097151)+Et(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 nt;for(let n=this.length-e-s-1;n>=0;--n)this.setCell(e+s+n,this.loadCell(e+n,r));for(let n=0;n<s;++n)this.setCell(e+n,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 nt;for(let n=0;n<this.length-e-s;++n)this.setCell(e+n,this.loadCell(e+s+n,r));for(let n=this.length-s;n<this.length;++n)this.setCell(n,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*Qi<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 n=Object.keys(this._extendedAttrs);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,i*4*Qi<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Qi<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 Sl(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,n){let a=e._data;if(n)for(let h=r-1;h>=0;h--){for(let c=0;c<ae;c++)this._data[(i+h)*ae+c]=a[(s+h)*ae+c];a[(s+h)*ae+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ae;c++)this._data[(i+h)*ae+c]=a[(s+h)*ae+c];a[(s+h)*ae+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}let l=Object.keys(e._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],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 n="";for(;s<i;){let a=this._data[s*ae+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Et(l):Tt;if(n+=h,r)for(let c=0;c<h.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),n}};function b_(t,e,s,i,r,n){let a=[];for(let l=0;l<t.length-1;l++){let h=l,c=t.get(++h);if(!c.isWrapped)continue;let d=[t.get(l)];for(;h<t.length&&c.isWrapped;)d.push(c),c=t.get(++h);if(!n&&i>=l&&i<h){l+=d.length-1;continue}let u=0,m=Fs(d,u,e),_=1,f=0;for(;_<d.length;){let g=Fs(d,_,e),v=g-f,b=s-m,S=Math.min(v,b);d[u].copyCellsFrom(d[_],f,m,S,!1),m+=S,m===s&&(u++,m=0),f+=S,f===g&&(_++,f=0),m===0&&u!==0&&d[u-1].getWidth(s-1)===2&&(d[u].copyCellsFrom(d[u-1],s-1,m++,1,!1),d[u-1].setCell(s-1,r))}d[u].replaceCells(m,s,r);let p=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)p++;p>0&&(a.push(l+d.length-p),a.push(p)),l+=d.length-1}return a}function S_(t,e){let s=[],i=0,r=e[i],n=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++i];t.onDeleteEmitter.fire({index:a-n,amount:l}),a+=l-1,n+=l,r=e[++i]}else s.push(a);return{layout:s,countRemoved:n}}function y_(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 w_(t,e,s){let i=[],r=t.map((h,c)=>Fs(t,c,e)).reduce((h,c)=>h+c),n=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}n+=s;let h=Fs(t,a,e);n>h&&(n-=h,a++);let c=t[a].getWidth(n-1)===2;c&&n--;let d=c?s-1:s;i.push(d),l+=d}return i}function Fs(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 yl=class wl{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=wl._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),$t(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};yl._nextId=1;var C_=yl,Ie={},Lt=Ie.B;Ie[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ie.A={"#":"£"};Ie.B=void 0;Ie[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ie.C=Ie[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ie.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ie.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ie.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ie.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ie.E=Ie[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ie.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ie.H=Ie[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ie["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var go=4294967295,vo=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=Ee.clone(),this.savedCharset=Lt,this.markers=[],this._nullCell=nt.fromCharData([0,$a,1,0]),this._whitespaceCell=nt.fromCharData([0,Tt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new xi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new po(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 _i),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 _i),this._whitespaceCell}getBlankLine(t,e){return new js(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>go?go:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Ee);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 po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Ee),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 n=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 js(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new js(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),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)i+=+this.lines.get(n).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=b_(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Ee),s);if(i.length>0){let r=S_(this.lines,i);y_(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Ee),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new js(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(Ee),r=[],n=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 h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let S=this.ybase+this.y;if(S>=a&&S<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=w_(h,this._cols,t),u=d.length-h.length,m;this.ybase===0&&this.y!==this.lines.length-1?m=Math.max(0,this.y-this.lines.maxLength+u):m=Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let S=0;S<u;S++){let x=this.getBlankLine(Ee,!0);_.push(x)}_.length>0&&(r.push({start:a+h.length+n,newLines:_}),n+=_.length),h.push(..._);let f=d.length-1,p=d[f];p===0&&(f--,p=d[f]);let g=h.length-u-1,v=c;for(;g>=0;){let S=Math.min(v,p);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[g],v-S,p-S,S,!0),p-=S,p===0&&(f--,p=d[f]),v-=S,v===0){g--;let x=Math.max(g,0);v=Fs(h,x,this._cols)}}for(let S=0;S<h.length;S++)d[S]<t&&h[S].setCell(d[S],i);let b=u-m;for(;b-- >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+n)-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 p=0;p<this.lines.length;p++)l.push(this.lines.get(p));let h=this.lines.length,c=h-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let m=0;for(let p=Math.min(this.lines.maxLength-1,h+n-1);p>=0;p--)if(u&&u.start>c+m){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(p--,u.newLines[g]);p++,a.push({index:c+1,amount:u.newLines.length}),m+=u.newLines.length,u=r[++d]}else this.lines.set(p,l[c--]);let _=0;for(let p=a.length-1;p>=0;p--)a[p].index+=_,this.lines.onInsertEmitter.fire(a[p]),_+=a[p].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}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 C_(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)}},k_=class extends le{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new q),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 vo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new vo(!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)}},Cl=2,kl=1,Hr=class extends le{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Cl),this.rows=Math.max(t.rawOptions.rows||0,kl),this.buffers=this._register(new k_(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,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;n===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=n-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(n,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))}};Hr=ke([J(0,Ye)],Hr);var Yt={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:vi,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},N_=["normal","bold","100","200","300","400","500","600","700","800","900"],j_=class extends le{constructor(t){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let e={...Yt};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(ge(()=>{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 Yt))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Yt))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=Yt[t]),!E_(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Yt[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=N_.includes(e)?e:Yt[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 E_(t){return t==="block"||t==="underline"||t==="bar"}function Es(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]&&Es(t[i],e-1);return s}var xo=Object.freeze({insertMode:!1}),bo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Wr=class extends le{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 q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Es(xo),this.decPrivateModes=Es(bo)}reset(){this.modes=Es(xo),this.decPrivateModes=Es(bo)}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))}};Wr=ke([J(0,Ge),J(1,Va),J(2,Ye)],Wr);var So={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 er(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 tr=String.fromCharCode,yo={DEFAULT:t=>{let e=[er(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${tr(e[0])}${tr(e[1])}${tr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${er(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${er(t,!0)};${t.x};${t.y}${e}`}},Ur=class extends le{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 q),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(So))this.addProtocol(i,So[i]);for(let i of Object.keys(yo))this.addEncoding(i,yo[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)}};Ur=ke([J(0,Ge),J(1,Ut),J(2,Ye)],Ur);var sr=[[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]],T_=[[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]],Re;function D_(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 R_=class{constructor(){if(this.version="6",!Re){Re=new Uint8Array(65536),Re.fill(1),Re[0]=0,Re.fill(0,1,32),Re.fill(0,127,160),Re.fill(2,4352,4448),Re[9001]=2,Re[9002]=2,Re.fill(2,11904,42192),Re[12351]=1,Re.fill(2,44032,55204),Re.fill(2,63744,64256),Re.fill(2,65040,65050),Re.fill(2,65072,65136),Re.fill(2,65280,65377),Re.fill(2,65504,65511);for(let t=0;t<sr.length;++t)Re.fill(0,sr[t][0],sr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Re[t]:D_(t,T_)?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=Ot.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Ot.createPropertyValue(0,s,i)}},Ot=class fi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new q,this.onChange=this._onChange.event;let e=new R_;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 n=0;n<r;++n){let a=e.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=r)return s+this.wcwidth(a);let c=e.charCodeAt(n);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=fi.extractWidth(l);fi.extractShouldJoin(l)&&(h-=fi.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},M_=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 wo(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 ys=2147483647,I_=256,Nl=class Vr{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>I_)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 Vr;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 n=0;n<r.length;++n)s.addSubParam(r[n]);else s.addParam(r)}return s}clone(){let e=new Vr(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>ys?ys: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>ys?ys: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,ys):e}},ws=[],B_=class{constructor(){this._state=0,this._active=ws,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=ws}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=ws,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ws,!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",Ri(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=ws,this._id=-1,this._state=0}}},Qe=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+=Ri(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}},Cs=[],A_=class{constructor(){this._handlers=Object.create(null),this._active=Cs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Cs}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=Cs,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Cs,!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",Ri(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=Cs,this._ident=0}},Ts=new Nl;Ts.addParam(0);var Co=class{constructor(t){this._handler=t,this._data="",this._params=Ts,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Ts,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Ri(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=Ts,this._data="",this._hitLimit=!1,s));return this._params=Ts,this._data="",this._hitLimit=!1,e}},P_=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}},rt=160,L_=(function(){let t=new P_(4095),e=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>e.slice(l,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),a;t.setDefault(1,0),t.addMany(i,0,2,0);for(a in n)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(rt,0,2,0),t.add(rt,8,5,8),t.add(rt,6,0,6),t.add(rt,11,0,11),t.add(rt,13,13,13),t})(),O_=class extends le{constructor(t=L_){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 Nl,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(ge(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new B_),this._dcsParser=this._register(new A_),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 n=t.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}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,n=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=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,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,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,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<e;++l){switch(i=t[l],r=this._transitions.table[this.currentState<<8|(i<160?i:rt)],r>>4){case 2:for(let m=l+1;;++m){if(m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-1;break}if(++m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-1;break}if(++m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-1;break}if(++m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-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 h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,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 d=this._escHandlers[this._collect<<8|i],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,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 m=l+1;;++m)if(m>=e||(i=t[m])===24||i===26||i===27||i>127&&i<rt){this._dcsParser.put(t,l,m),l=m-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 m=l+1;;m++)if(m>=e||(i=t[m])<32||i>127&&i<rt){this._oscParser.put(t,l,m),l=m-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}}},z_=/^([\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})$/,$_=/^[\da-f]+$/;function ko(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=z_.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),$_.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 n=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?n<<4:s===2?n:s===3?n>>4:n>>8}return i}}function ir(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 F_(t,e=16){let[s,i,r]=t;return`rgb:${ir(s,e)}/${ir(i,e)}/${ir(r,e)}`}var H_={"(":0,")":1,"*":2,"+":3,"-":1,".":2},jt=131072,No=10;function jo(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 Eo=5e3,To=0,W_=class extends le{constructor(t,e,s,i,r,n,a,l,h=new O_){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new lf,this._utf8Decoder=new cf,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ee.clone(),this._eraseAttrDataInternal=Ee.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),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 Kr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.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,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:u})}),this._parser.setDcsHandlerFallback((c,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:u})}),this._parser.setPrintHandler((c,d,u)=>this.print(c,d,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(H.BEL,()=>this.bell()),this._parser.setExecuteHandler(H.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(H.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(H.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(H.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(H.BS,()=>this.backspace()),this._parser.setExecuteHandler(H.HT,()=>this.tab()),this._parser.setExecuteHandler(H.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(H.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(di.IND,()=>this.index()),this._parser.setExecuteHandler(di.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(di.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Qe(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Qe(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Qe(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Qe(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Qe(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Qe(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Qe(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Qe(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Qe(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Qe(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Qe(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Qe(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 Ie)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 Co((c,d)=>this.requestStatusString(c,d)))}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"),Eo))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Eo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=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>jt&&(n=this._parseStack.position+jt)}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<jt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,jt))),a||this._dirtyRowTracker.clearRange(),t.length>jt)for(let c=n;c<t.length;c+=jt){let d=c+jt<t.length?c+jt:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(t.subarray(c,d),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),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let i,r,n=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=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,d);let m=this._parser.precedingJoinState;for(let _=e;_<s;++_){if(i=t[_],i<127&&n){let v=n[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}let f=this._unicodeService.charProperties(i,m);r=Ot.extractWidth(f);let p=Ot.extractShouldJoin(f),g=p?Ot.extractWidth(m):0;if(m=f,a&&this._onA11yChar.fire(Et(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(h){let v=u,b=this._activeBuffer.x-g;for(this._activeBuffer.x=g,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),g>0&&u instanceof js&&u.copyCellsFrom(v,b,0,g,!1);b<l;)v.setCellFromCodepoint(b++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,i,r);for(let b=r-g;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(d)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=m,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,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>jo(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Co(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Qe(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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.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(Ee));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=Ot.extractWidth(e),r=this._activeBuffer.x-i,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(n.length*s),l=0;for(let c=0;c<n.length;){let d=n.codePointAt(c)||0;a[l++]=d,c+=d>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(H.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(H.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(H.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(H.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(H.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,Lt),this._charsetService.setgCharset(1,Lt),this._charsetService.setgCharset(2,Lt),this._charsetService.setgCharset(3,Lt);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;(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,m=(p,g)=>(a.triggerDataEvent(`${H.ESC}[${e?"":"?"}${p};${g}$y`),!0),_=p=>p?1:2,f=t.params[0];return e?f===2?m(f,4):f===4?m(f,_(a.modes.insertMode)):f===12?m(f,3):f===20?m(f,_(u.convertEol)):m(f,0):f===1?m(f,_(i.applicationCursorKeys)):f===3?m(f,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?m(f,_(i.origin)):f===7?m(f,_(i.wraparound)):f===8?m(f,3):f===9?m(f,_(r==="X10")):f===12?m(f,_(u.cursorBlink)):f===25?m(f,_(!a.isCursorHidden)):f===45?m(f,_(i.reverseWraparound)):f===66?m(f,_(i.applicationKeypad)):f===67?m(f,4):f===1e3?m(f,_(r==="VT200")):f===1002?m(f,_(r==="DRAG")):f===1003?m(f,_(r==="ANY")):f===1004?m(f,_(i.sendFocus)):f===1005?m(f,4):f===1006?m(f,_(n==="SGR")):f===1015?m(f,4):f===1016?m(f,_(n==="SGR_PIXELS")):f===1048?m(f,1):f===47||f===1047||f===1049?m(f,_(c===d)):f===2004?m(f,_(i.bracketedPasteMode)):f===2026?m(f,_(i.synchronizedOutput)):m(f,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=qs.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,n=0;do{if(i[n+r]=t.params[e+n],t.hasSubParams(e+n)){let a=t.getSubParams(e+n),l=0;do i[1]===5&&(r=1),i[n+l+1+r]=a[l];while(++l<a.length&&l+n+1+r<i.length);break}if(i[1]===5&&n+r>=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+e<t.length&&n+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 n}_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=Ee.fg,t.bg=Ee.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|=Ee.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ee.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|=Ee.fg&16777215,i.bg&=-67108864,i.bg|=Ee.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${H.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${H.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(`${H.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=Ee.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(!jo(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(`${H.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>No&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>No&&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 n=parseInt(i);if(Do(n))if(r==="?")e.push({type:0,index:n});else{let a=ko(r);a&&e.push({type:1,index:n,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(n=>n.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=ko(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]);Do(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,Lt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(H_[t[0]],Ie[t[1]]||Lt),!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=Ee.clone(),this._eraseAttrDataInternal=Ee.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 nt;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(`${H.ESC}${a}${H.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)}},Kr=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&&(To=t,t=e,e=To),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Kr=ke([J(0,Ge)],Kr);function Do(t){return 0<=t&&t<256}var U_=5e7,Ro=12,V_=50,K_=class extends le{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 q),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>U_)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>=Ro?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Ro)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>V_&&(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()}},qr=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),h={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.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 n=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(a,n)),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)))}};qr=ke([J(0,Ge)],qr);var Mo=!1,q_=class extends le{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new hs),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new g_,this.optionsService=this._register(new j_(t)),this._instantiationService.setService(Ye,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Hr)),this._instantiationService.setService(Ge,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Fr)),this._instantiationService.setService(Va,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Wr)),this._instantiationService.setService(Ut,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ur)),this._instantiationService.setService(Ua,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ot)),this._instantiationService.setService(ff,this.unicodeService),this._charsetService=this._instantiationService.createInstance(M_),this._instantiationService.setService(uf,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(qr),this._instantiationService.setService(Ka,this._oscLinkService),this._inputHandler=this._register(new W_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.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 K_((e,s)=>this._inputHandler.parse(e,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),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&&!Mo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Mo=!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,Cl),e=Math.max(e,kl),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(wo.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(wo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ge(()=>{for(let e of t)e.dispose()})}}},G_={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 Y_(t,e,s,i){let r={type:0,cancel:!1,key:void 0},n=(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=H.ESC+"OA":r.key=H.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=H.ESC+"OD":r.key=H.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=H.ESC+"OC":r.key=H.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=H.ESC+"OB":r.key=H.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":H.DEL,t.altKey&&(r.key=H.ESC+r.key);break;case 9:if(t.shiftKey){r.key=H.ESC+"[Z";break}r.key=H.HT,r.cancel=!0;break;case 13:r.key=t.altKey?H.ESC+H.CR:H.CR,r.cancel=!0;break;case 27:r.key=H.ESC,t.altKey&&(r.key=H.ESC+H.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"D":e?r.key=H.ESC+"OD":r.key=H.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"C":e?r.key=H.ESC+"OC":r.key=H.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"A":e?r.key=H.ESC+"OA":r.key=H.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"B":e?r.key=H.ESC+"OB":r.key=H.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=H.ESC+"[2~");break;case 46:n?r.key=H.ESC+"[3;"+(n+1)+"~":r.key=H.ESC+"[3~";break;case 36:n?r.key=H.ESC+"[1;"+(n+1)+"H":e?r.key=H.ESC+"OH":r.key=H.ESC+"[H";break;case 35:n?r.key=H.ESC+"[1;"+(n+1)+"F":e?r.key=H.ESC+"OF":r.key=H.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=H.ESC+"[5;"+(n+1)+"~":r.key=H.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=H.ESC+"[6;"+(n+1)+"~":r.key=H.ESC+"[6~";break;case 112:n?r.key=H.ESC+"[1;"+(n+1)+"P":r.key=H.ESC+"OP";break;case 113:n?r.key=H.ESC+"[1;"+(n+1)+"Q":r.key=H.ESC+"OQ";break;case 114:n?r.key=H.ESC+"[1;"+(n+1)+"R":r.key=H.ESC+"OR";break;case 115:n?r.key=H.ESC+"[1;"+(n+1)+"S":r.key=H.ESC+"OS";break;case 116:n?r.key=H.ESC+"[15;"+(n+1)+"~":r.key=H.ESC+"[15~";break;case 117:n?r.key=H.ESC+"[17;"+(n+1)+"~":r.key=H.ESC+"[17~";break;case 118:n?r.key=H.ESC+"[18;"+(n+1)+"~":r.key=H.ESC+"[18~";break;case 119:n?r.key=H.ESC+"[19;"+(n+1)+"~":r.key=H.ESC+"[19~";break;case 120:n?r.key=H.ESC+"[20;"+(n+1)+"~":r.key=H.ESC+"[20~";break;case 121:n?r.key=H.ESC+"[21;"+(n+1)+"~":r.key=H.ESC+"[21~";break;case 122:n?r.key=H.ESC+"[23;"+(n+1)+"~":r.key=H.ESC+"[23~";break;case 123:n?r.key=H.ESC+"[24;"+(n+1)+"~":r.key=H.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=H.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=H.DEL:t.keyCode===219?r.key=H.ESC:t.keyCode===220?r.key=H.FS:t.keyCode===221&&(r.key=H.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=G_[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=H.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(l);t.shiftKey&&(h=h.toUpperCase()),r.key=H.ESC+h}else if(t.keyCode===32)r.key=H.ESC+(t.ctrlKey?H.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=H.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=H.US),t.key==="@"&&(r.key=H.NUL));break}return r}var Ne=0,X_=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new xi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new xi,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,n)=>this._getKey(r)-this._getKey(n)),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||(Ne=this._search(e),Ne===-1)||this._getKey(this._array[Ne])!==e)return!1;do if(this._array[Ne]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ne),!0;while(++Ne<this._array.length&&this._getKey(this._array[Ne])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,n)=>r-n),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&&(Ne=this._search(t),!(Ne<0||Ne>=this._array.length)&&this._getKey(this._array[Ne])===t))do yield this._array[Ne];while(++Ne<this._array.length&&this._getKey(this._array[Ne])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ne=this._search(t),!(Ne<0||Ne>=this._array.length)&&this._getKey(this._array[Ne])===t))do e(this._array[Ne]);while(++Ne<this._array.length&&this._getKey(this._array[Ne])===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}},rr=0,Io=0,J_=class extends le{constructor(){super(),this._decorations=new X_(t=>t?.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ge(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Z_(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 n of this._decorations.getKeyIterator(e))i=n.options.x??0,r=i+(n.options.width??1),t>=i&&t<r&&(!s||(n.options.layer??"bottom")===s)&&(yield n)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{rr=r.options.x??0,Io=rr+(r.options.width??1),t>=rr&&t<Io&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},Z_=class extends Dt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new q),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=be.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=be.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Q_=1e3,ep=class{constructor(t,e=Q_){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,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},Bo=20,bi=class extends le{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 n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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 ep(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
179
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),_n&&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=ho(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=mn(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,-Zi),Zi),e/=Zi,e/Math.abs(e)+Math.round(e*(d_-1)))}shouldForceSelection(t){return vi?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(),u_)}_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&&!(vi&&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<f_&&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=i_(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,n=r.lines.get(t[1]);if(!n)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(n,t[0]),h=l,c=t[0]-l,d=0,u=0,m=0,_=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let g=t[0],v=t[0];n.getWidth(g)===0&&(d++,g--),n.getWidth(v)===2&&(u++,v++);let b=n.getString(v).length;for(b>1&&(_+=b-1,h+=b-1);g>0&&l>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):S>1&&(m+=S-1,l-=S-1),l--,g--}for(;v<n.length&&h+1<a.length&&!this._isCharWordSeparator(n.loadCell(v+1,this._workCell));){n.loadCell(v+1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):S>1&&(_+=S-1,h+=S-1),h++,v++}}h++;let f=l+c-d+m,p=Math.min(this._bufferService.cols,h-l+d+u-m-_);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&f===0&&n.getCodePoint(0)!==32){let g=r.lines.get(t[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let b=this._bufferService.cols-v.start;f-=b,p+=b}}}if(i&&f+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(t[1]+1);if(g?.isWrapped&&g.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(p+=v.length)}}return{start:f,length:p}}}_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=ho(s,this._bufferService.cols)}};zr=ke([J(3,Ge),J(4,Ut),J(5,an),J(6,Ye),J(7,Ct),J(8,wt)],zr);var uo=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={}}},fo=class{constructor(){this._color=new uo,this._css=new uo}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()}},Re=Object.freeze((()=>{let t=[be.toColor("#2e3436"),be.toColor("#cc0000"),be.toColor("#4e9a06"),be.toColor("#c4a000"),be.toColor("#3465a4"),be.toColor("#75507b"),be.toColor("#06989a"),be.toColor("#d3d7cf"),be.toColor("#555753"),be.toColor("#ef2929"),be.toColor("#8ae234"),be.toColor("#fce94f"),be.toColor("#729fcf"),be.toColor("#ad7fa8"),be.toColor("#34e2e2"),be.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],n=e[s%6];t.push({css:Te.toCss(i,r,n),rgba:Te.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Te.toCss(i,i,i),rgba:Te.toRgba(i,i,i)})}return t})()),Pt=be.toColor("#ffffff"),Ns=be.toColor("#000000"),mo=be.toColor("#ffffff"),_o=Ns,Ss={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},p_=Pt,$r=class extends le{constructor(t){super(),this._optionsService=t,this._contrastCache=new fo,this._halfContrastCache=new fo,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Pt,background:Ns,cursor:mo,cursorAccent:_o,selectionForeground:void 0,selectionBackgroundTransparent:Ss,selectionBackgroundOpaque:pe.blend(Ns,Ss),selectionInactiveBackgroundTransparent:Ss,selectionInactiveBackgroundOpaque:pe.blend(Ns,Ss),scrollbarSliderBackground:pe.opacity(Pt,.2),scrollbarSliderHoverBackground:pe.opacity(Pt,.4),scrollbarSliderActiveBackground:pe.opacity(Pt,.5),overviewRulerBorder:Pt,ansi:Re.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=fe(t.foreground,Pt),e.background=fe(t.background,Ns),e.cursor=pe.blend(e.background,fe(t.cursor,mo)),e.cursorAccent=pe.blend(e.background,fe(t.cursorAccent,_o)),e.selectionBackgroundTransparent=fe(t.selectionBackground,Ss),e.selectionBackgroundOpaque=pe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=fe(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=pe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?fe(t.selectionForeground,ao):void 0,e.selectionForeground===ao&&(e.selectionForeground=void 0),pe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=pe.opacity(e.selectionBackgroundTransparent,.3)),pe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=pe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=fe(t.scrollbarSliderBackground,pe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=fe(t.scrollbarSliderHoverBackground,pe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=fe(t.scrollbarSliderActiveBackground,pe.opacity(e.foreground,.5)),e.overviewRulerBorder=fe(t.overviewRulerBorder,p_),e.ansi=Re.slice(),e.ansi[0]=fe(t.black,Re[0]),e.ansi[1]=fe(t.red,Re[1]),e.ansi[2]=fe(t.green,Re[2]),e.ansi[3]=fe(t.yellow,Re[3]),e.ansi[4]=fe(t.blue,Re[4]),e.ansi[5]=fe(t.magenta,Re[5]),e.ansi[6]=fe(t.cyan,Re[6]),e.ansi[7]=fe(t.white,Re[7]),e.ansi[8]=fe(t.brightBlack,Re[8]),e.ansi[9]=fe(t.brightRed,Re[9]),e.ansi[10]=fe(t.brightGreen,Re[10]),e.ansi[11]=fe(t.brightYellow,Re[11]),e.ansi[12]=fe(t.brightBlue,Re[12]),e.ansi[13]=fe(t.brightMagenta,Re[13]),e.ansi[14]=fe(t.brightCyan,Re[14]),e.ansi[15]=fe(t.brightWhite,Re[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]=fe(t.extendedAnsi[i],Re[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()}}};$r=ke([J(0,Ye)],$r);function fe(t,e){if(t!==void 0)try{return be.toColor(t)}catch{}return e}var g_=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)}},v_=class{constructor(){this._services=new g_,this._services.set(on,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=df(t).sort((n,a)=>n.index-a.index),i=[];for(let n of s){let a=this._services.get(n.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.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)}},x_={trace:0,debug:1,info:2,warn:3,error:4,off:5},b_="xterm.js: ",Fr=class extends le{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=x_[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?"":b_)+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)}};Fr=ke([J(0,Ye)],Fr);var po=class extends le{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new q),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,Ee=Object.freeze(new qs),ri=0,Qi=2,js=class Sl{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ae);let r=s||nt.fromCharData([0,$a,1,0]);for(let n=0;n<e;++n)this.setCell(n,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?Et(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?Et(s&2097151):""}isProtected(e){return this._data[e*ae+2]&536870912}loadCell(e,s){return ri=e*ae,s.content=this._data[ri+0],s.fg=this._data[ri+1],s.bg=this._data[ri+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]+=Et(s):r&2097151?(this._combined[e]=Et(r&2097151)+Et(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 nt;for(let n=this.length-e-s-1;n>=0;--n)this.setCell(e+s+n,this.loadCell(e+n,r));for(let n=0;n<s;++n)this.setCell(e+n,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 nt;for(let n=0;n<this.length-e-s;++n)this.setCell(e+n,this.loadCell(e+s+n,r));for(let n=this.length-s;n<this.length;++n)this.setCell(n,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*Qi<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 n=Object.keys(this._extendedAttrs);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,i*4*Qi<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Qi<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 Sl(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,n){let a=e._data;if(n)for(let h=r-1;h>=0;h--){for(let c=0;c<ae;c++)this._data[(i+h)*ae+c]=a[(s+h)*ae+c];a[(s+h)*ae+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ae;c++)this._data[(i+h)*ae+c]=a[(s+h)*ae+c];a[(s+h)*ae+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}let l=Object.keys(e._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],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 n="";for(;s<i;){let a=this._data[s*ae+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Et(l):Tt;if(n+=h,r)for(let c=0;c<h.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),n}};function S_(t,e,s,i,r,n){let a=[];for(let l=0;l<t.length-1;l++){let h=l,c=t.get(++h);if(!c.isWrapped)continue;let d=[t.get(l)];for(;h<t.length&&c.isWrapped;)d.push(c),c=t.get(++h);if(!n&&i>=l&&i<h){l+=d.length-1;continue}let u=0,m=Fs(d,u,e),_=1,f=0;for(;_<d.length;){let g=Fs(d,_,e),v=g-f,b=s-m,S=Math.min(v,b);d[u].copyCellsFrom(d[_],f,m,S,!1),m+=S,m===s&&(u++,m=0),f+=S,f===g&&(_++,f=0),m===0&&u!==0&&d[u-1].getWidth(s-1)===2&&(d[u].copyCellsFrom(d[u-1],s-1,m++,1,!1),d[u-1].setCell(s-1,r))}d[u].replaceCells(m,s,r);let p=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)p++;p>0&&(a.push(l+d.length-p),a.push(p)),l+=d.length-1}return a}function y_(t,e){let s=[],i=0,r=e[i],n=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++i];t.onDeleteEmitter.fire({index:a-n,amount:l}),a+=l-1,n+=l,r=e[++i]}else s.push(a);return{layout:s,countRemoved:n}}function w_(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 C_(t,e,s){let i=[],r=t.map((h,c)=>Fs(t,c,e)).reduce((h,c)=>h+c),n=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}n+=s;let h=Fs(t,a,e);n>h&&(n-=h,a++);let c=t[a].getWidth(n-1)===2;c&&n--;let d=c?s-1:s;i.push(d),l+=d}return i}function Fs(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 yl=class wl{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=wl._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),$t(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};yl._nextId=1;var k_=yl,Ie={},Lt=Ie.B;Ie[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ie.A={"#":"£"};Ie.B=void 0;Ie[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ie.C=Ie[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ie.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ie.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ie.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ie.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ie.E=Ie[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ie.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ie.H=Ie[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ie["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var go=4294967295,vo=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=Ee.clone(),this.savedCharset=Lt,this.markers=[],this._nullCell=nt.fromCharData([0,$a,1,0]),this._whitespaceCell=nt.fromCharData([0,Tt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new xi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new po(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 _i),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 _i),this._whitespaceCell}getBlankLine(t,e){return new js(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>go?go:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Ee);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 po(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Ee),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 n=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 js(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new js(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),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)i+=+this.lines.get(n).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=S_(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Ee),s);if(i.length>0){let r=y_(this.lines,i);w_(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Ee),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new js(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(Ee),r=[],n=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 h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let S=this.ybase+this.y;if(S>=a&&S<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=C_(h,this._cols,t),u=d.length-h.length,m;this.ybase===0&&this.y!==this.lines.length-1?m=Math.max(0,this.y-this.lines.maxLength+u):m=Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let S=0;S<u;S++){let x=this.getBlankLine(Ee,!0);_.push(x)}_.length>0&&(r.push({start:a+h.length+n,newLines:_}),n+=_.length),h.push(..._);let f=d.length-1,p=d[f];p===0&&(f--,p=d[f]);let g=h.length-u-1,v=c;for(;g>=0;){let S=Math.min(v,p);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[g],v-S,p-S,S,!0),p-=S,p===0&&(f--,p=d[f]),v-=S,v===0){g--;let x=Math.max(g,0);v=Fs(h,x,this._cols)}}for(let S=0;S<h.length;S++)d[S]<t&&h[S].setCell(d[S],i);let b=u-m;for(;b-- >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+n)-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 p=0;p<this.lines.length;p++)l.push(this.lines.get(p));let h=this.lines.length,c=h-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let m=0;for(let p=Math.min(this.lines.maxLength-1,h+n-1);p>=0;p--)if(u&&u.start>c+m){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(p--,u.newLines[g]);p++,a.push({index:c+1,amount:u.newLines.length}),m+=u.newLines.length,u=r[++d]}else this.lines.set(p,l[c--]);let _=0;for(let p=a.length-1;p>=0;p--)a[p].index+=_,this.lines.onInsertEmitter.fire(a[p]),_+=a[p].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}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 k_(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)}},N_=class extends le{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new q),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 vo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new vo(!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)}},Cl=2,kl=1,Hr=class extends le{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Cl),this.rows=Math.max(t.rawOptions.rows||0,kl),this.buffers=this._register(new N_(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,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;n===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=n-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(n,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))}};Hr=ke([J(0,Ye)],Hr);var Yt={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:vi,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},j_=["normal","bold","100","200","300","400","500","600","700","800","900"],E_=class extends le{constructor(t){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let e={...Yt};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(ge(()=>{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 Yt))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Yt))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=Yt[t]),!T_(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Yt[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=j_.includes(e)?e:Yt[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 T_(t){return t==="block"||t==="underline"||t==="bar"}function Es(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]&&Es(t[i],e-1);return s}var xo=Object.freeze({insertMode:!1}),bo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Wr=class extends le{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 q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Es(xo),this.decPrivateModes=Es(bo)}reset(){this.modes=Es(xo),this.decPrivateModes=Es(bo)}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))}};Wr=ke([J(0,Ge),J(1,Va),J(2,Ye)],Wr);var So={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 er(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 tr=String.fromCharCode,yo={DEFAULT:t=>{let e=[er(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${tr(e[0])}${tr(e[1])}${tr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${er(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${er(t,!0)};${t.x};${t.y}${e}`}},Ur=class extends le{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 q),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(So))this.addProtocol(i,So[i]);for(let i of Object.keys(yo))this.addEncoding(i,yo[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)}};Ur=ke([J(0,Ge),J(1,Ut),J(2,Ye)],Ur);var sr=[[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]],R_=[[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]],De;function D_(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 M_=class{constructor(){if(this.version="6",!De){De=new Uint8Array(65536),De.fill(1),De[0]=0,De.fill(0,1,32),De.fill(0,127,160),De.fill(2,4352,4448),De[9001]=2,De[9002]=2,De.fill(2,11904,42192),De[12351]=1,De.fill(2,44032,55204),De.fill(2,63744,64256),De.fill(2,65040,65050),De.fill(2,65072,65136),De.fill(2,65280,65377),De.fill(2,65504,65511);for(let t=0;t<sr.length;++t)De.fill(0,sr[t][0],sr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?De[t]:D_(t,R_)?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=Ot.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Ot.createPropertyValue(0,s,i)}},Ot=class fi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new q,this.onChange=this._onChange.event;let e=new M_;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 n=0;n<r;++n){let a=e.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=r)return s+this.wcwidth(a);let c=e.charCodeAt(n);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=fi.extractWidth(l);fi.extractShouldJoin(l)&&(h-=fi.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},I_=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 wo(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 ys=2147483647,B_=256,Nl=class Vr{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>B_)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 Vr;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 n=0;n<r.length;++n)s.addSubParam(r[n]);else s.addParam(r)}return s}clone(){let e=new Vr(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>ys?ys: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>ys?ys: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,ys):e}},ws=[],A_=class{constructor(){this._state=0,this._active=ws,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=ws}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=ws,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ws,!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",Di(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=ws,this._id=-1,this._state=0}}},Qe=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+=Di(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}},Cs=[],P_=class{constructor(){this._handlers=Object.create(null),this._active=Cs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Cs}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=Cs,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Cs,!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",Di(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=Cs,this._ident=0}},Ts=new Nl;Ts.addParam(0);var Co=class{constructor(t){this._handler=t,this._data="",this._params=Ts,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Ts,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Di(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=Ts,this._data="",this._hitLimit=!1,s));return this._params=Ts,this._data="",this._hitLimit=!1,e}},L_=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}},rt=160,O_=(function(){let t=new L_(4095),e=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>e.slice(l,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),a;t.setDefault(1,0),t.addMany(i,0,2,0);for(a in n)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(rt,0,2,0),t.add(rt,8,5,8),t.add(rt,6,0,6),t.add(rt,11,0,11),t.add(rt,13,13,13),t})(),z_=class extends le{constructor(t=O_){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 Nl,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(ge(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new A_),this._dcsParser=this._register(new P_),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 n=t.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}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,n=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=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,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,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,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<e;++l){switch(i=t[l],r=this._transitions.table[this.currentState<<8|(i<160?i:rt)],r>>4){case 2:for(let m=l+1;;++m){if(m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-1;break}if(++m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-1;break}if(++m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-1;break}if(++m>=e||(i=t[m])<32||i>126&&i<rt){this._printHandler(t,l,m),l=m-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 h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,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 d=this._escHandlers[this._collect<<8|i],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,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 m=l+1;;++m)if(m>=e||(i=t[m])===24||i===26||i===27||i>127&&i<rt){this._dcsParser.put(t,l,m),l=m-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 m=l+1;;m++)if(m>=e||(i=t[m])<32||i>127&&i<rt){this._oscParser.put(t,l,m),l=m-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}}},$_=/^([\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})$/,F_=/^[\da-f]+$/;function ko(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=$_.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),F_.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 n=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?n<<4:s===2?n:s===3?n>>4:n>>8}return i}}function ir(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 H_(t,e=16){let[s,i,r]=t;return`rgb:${ir(s,e)}/${ir(i,e)}/${ir(r,e)}`}var W_={"(":0,")":1,"*":2,"+":3,"-":1,".":2},jt=131072,No=10;function jo(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 Eo=5e3,To=0,U_=class extends le{constructor(t,e,s,i,r,n,a,l,h=new z_){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new cf,this._utf8Decoder=new hf,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ee.clone(),this._eraseAttrDataInternal=Ee.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),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 Kr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.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,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:u})}),this._parser.setDcsHandlerFallback((c,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:u})}),this._parser.setPrintHandler((c,d,u)=>this.print(c,d,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(H.BEL,()=>this.bell()),this._parser.setExecuteHandler(H.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(H.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(H.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(H.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(H.BS,()=>this.backspace()),this._parser.setExecuteHandler(H.HT,()=>this.tab()),this._parser.setExecuteHandler(H.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(H.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(di.IND,()=>this.index()),this._parser.setExecuteHandler(di.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(di.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Qe(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Qe(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Qe(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Qe(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Qe(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Qe(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Qe(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Qe(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Qe(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Qe(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Qe(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Qe(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 Ie)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 Co((c,d)=>this.requestStatusString(c,d)))}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"),Eo))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Eo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=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>jt&&(n=this._parseStack.position+jt)}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<jt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,jt))),a||this._dirtyRowTracker.clearRange(),t.length>jt)for(let c=n;c<t.length;c+=jt){let d=c+jt<t.length?c+jt:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(t.subarray(c,d),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),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let i,r,n=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=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,d);let m=this._parser.precedingJoinState;for(let _=e;_<s;++_){if(i=t[_],i<127&&n){let v=n[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}let f=this._unicodeService.charProperties(i,m);r=Ot.extractWidth(f);let p=Ot.extractShouldJoin(f),g=p?Ot.extractWidth(m):0;if(m=f,a&&this._onA11yChar.fire(Et(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(h){let v=u,b=this._activeBuffer.x-g;for(this._activeBuffer.x=g,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),g>0&&u instanceof js&&u.copyCellsFrom(v,b,0,g,!1);b<l;)v.setCellFromCodepoint(b++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,i,r);for(let b=r-g;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(d)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=m,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,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>jo(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Co(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Qe(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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.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(Ee));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=Ot.extractWidth(e),r=this._activeBuffer.x-i,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(n.length*s),l=0;for(let c=0;c<n.length;){let d=n.codePointAt(c)||0;a[l++]=d,c+=d>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(H.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(H.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(H.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(H.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(H.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,Lt),this._charsetService.setgCharset(1,Lt),this._charsetService.setgCharset(2,Lt),this._charsetService.setgCharset(3,Lt);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;(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,m=(p,g)=>(a.triggerDataEvent(`${H.ESC}[${e?"":"?"}${p};${g}$y`),!0),_=p=>p?1:2,f=t.params[0];return e?f===2?m(f,4):f===4?m(f,_(a.modes.insertMode)):f===12?m(f,3):f===20?m(f,_(u.convertEol)):m(f,0):f===1?m(f,_(i.applicationCursorKeys)):f===3?m(f,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?m(f,_(i.origin)):f===7?m(f,_(i.wraparound)):f===8?m(f,3):f===9?m(f,_(r==="X10")):f===12?m(f,_(u.cursorBlink)):f===25?m(f,_(!a.isCursorHidden)):f===45?m(f,_(i.reverseWraparound)):f===66?m(f,_(i.applicationKeypad)):f===67?m(f,4):f===1e3?m(f,_(r==="VT200")):f===1002?m(f,_(r==="DRAG")):f===1003?m(f,_(r==="ANY")):f===1004?m(f,_(i.sendFocus)):f===1005?m(f,4):f===1006?m(f,_(n==="SGR")):f===1015?m(f,4):f===1016?m(f,_(n==="SGR_PIXELS")):f===1048?m(f,1):f===47||f===1047||f===1049?m(f,_(c===d)):f===2004?m(f,_(i.bracketedPasteMode)):f===2026?m(f,_(i.synchronizedOutput)):m(f,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=qs.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,n=0;do{if(i[n+r]=t.params[e+n],t.hasSubParams(e+n)){let a=t.getSubParams(e+n),l=0;do i[1]===5&&(r=1),i[n+l+1+r]=a[l];while(++l<a.length&&l+n+1+r<i.length);break}if(i[1]===5&&n+r>=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+e<t.length&&n+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 n}_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=Ee.fg,t.bg=Ee.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|=Ee.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ee.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|=Ee.fg&16777215,i.bg&=-67108864,i.bg|=Ee.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${H.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${H.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(`${H.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=Ee.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(!jo(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(`${H.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>No&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>No&&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 n=parseInt(i);if(Ro(n))if(r==="?")e.push({type:0,index:n});else{let a=ko(r);a&&e.push({type:1,index:n,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(n=>n.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=ko(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]);Ro(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,Lt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(W_[t[0]],Ie[t[1]]||Lt),!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=Ee.clone(),this._eraseAttrDataInternal=Ee.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 nt;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(`${H.ESC}${a}${H.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)}},Kr=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&&(To=t,t=e,e=To),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Kr=ke([J(0,Ge)],Kr);function Ro(t){return 0<=t&&t<256}var V_=5e7,Do=12,K_=50,q_=class extends le{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 q),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>V_)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>=Do?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Do)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>K_&&(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()}},qr=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),h={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.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 n=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(a,n)),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)))}};qr=ke([J(0,Ge)],qr);var Mo=!1,G_=class extends le{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new hs),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new v_,this.optionsService=this._register(new E_(t)),this._instantiationService.setService(Ye,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Hr)),this._instantiationService.setService(Ge,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Fr)),this._instantiationService.setService(Va,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Wr)),this._instantiationService.setService(Ut,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ur)),this._instantiationService.setService(Ua,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ot)),this._instantiationService.setService(mf,this.unicodeService),this._charsetService=this._instantiationService.createInstance(I_),this._instantiationService.setService(ff,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(qr),this._instantiationService.setService(Ka,this._oscLinkService),this._inputHandler=this._register(new U_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.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 q_((e,s)=>this._inputHandler.parse(e,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),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&&!Mo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Mo=!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,Cl),e=Math.max(e,kl),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(wo.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(wo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ge(()=>{for(let e of t)e.dispose()})}}},Y_={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 X_(t,e,s,i){let r={type:0,cancel:!1,key:void 0},n=(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=H.ESC+"OA":r.key=H.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=H.ESC+"OD":r.key=H.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=H.ESC+"OC":r.key=H.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=H.ESC+"OB":r.key=H.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":H.DEL,t.altKey&&(r.key=H.ESC+r.key);break;case 9:if(t.shiftKey){r.key=H.ESC+"[Z";break}r.key=H.HT,r.cancel=!0;break;case 13:r.key=t.altKey?H.ESC+H.CR:H.CR,r.cancel=!0;break;case 27:r.key=H.ESC,t.altKey&&(r.key=H.ESC+H.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"D":e?r.key=H.ESC+"OD":r.key=H.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"C":e?r.key=H.ESC+"OC":r.key=H.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"A":e?r.key=H.ESC+"OA":r.key=H.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=H.ESC+"[1;"+(n+1)+"B":e?r.key=H.ESC+"OB":r.key=H.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=H.ESC+"[2~");break;case 46:n?r.key=H.ESC+"[3;"+(n+1)+"~":r.key=H.ESC+"[3~";break;case 36:n?r.key=H.ESC+"[1;"+(n+1)+"H":e?r.key=H.ESC+"OH":r.key=H.ESC+"[H";break;case 35:n?r.key=H.ESC+"[1;"+(n+1)+"F":e?r.key=H.ESC+"OF":r.key=H.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=H.ESC+"[5;"+(n+1)+"~":r.key=H.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=H.ESC+"[6;"+(n+1)+"~":r.key=H.ESC+"[6~";break;case 112:n?r.key=H.ESC+"[1;"+(n+1)+"P":r.key=H.ESC+"OP";break;case 113:n?r.key=H.ESC+"[1;"+(n+1)+"Q":r.key=H.ESC+"OQ";break;case 114:n?r.key=H.ESC+"[1;"+(n+1)+"R":r.key=H.ESC+"OR";break;case 115:n?r.key=H.ESC+"[1;"+(n+1)+"S":r.key=H.ESC+"OS";break;case 116:n?r.key=H.ESC+"[15;"+(n+1)+"~":r.key=H.ESC+"[15~";break;case 117:n?r.key=H.ESC+"[17;"+(n+1)+"~":r.key=H.ESC+"[17~";break;case 118:n?r.key=H.ESC+"[18;"+(n+1)+"~":r.key=H.ESC+"[18~";break;case 119:n?r.key=H.ESC+"[19;"+(n+1)+"~":r.key=H.ESC+"[19~";break;case 120:n?r.key=H.ESC+"[20;"+(n+1)+"~":r.key=H.ESC+"[20~";break;case 121:n?r.key=H.ESC+"[21;"+(n+1)+"~":r.key=H.ESC+"[21~";break;case 122:n?r.key=H.ESC+"[23;"+(n+1)+"~":r.key=H.ESC+"[23~";break;case 123:n?r.key=H.ESC+"[24;"+(n+1)+"~":r.key=H.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=H.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=H.DEL:t.keyCode===219?r.key=H.ESC:t.keyCode===220?r.key=H.FS:t.keyCode===221&&(r.key=H.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=Y_[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=H.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(l);t.shiftKey&&(h=h.toUpperCase()),r.key=H.ESC+h}else if(t.keyCode===32)r.key=H.ESC+(t.ctrlKey?H.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=H.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=H.US),t.key==="@"&&(r.key=H.NUL));break}return r}var Ne=0,J_=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new xi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new xi,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,n)=>this._getKey(r)-this._getKey(n)),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||(Ne=this._search(e),Ne===-1)||this._getKey(this._array[Ne])!==e)return!1;do if(this._array[Ne]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ne),!0;while(++Ne<this._array.length&&this._getKey(this._array[Ne])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,n)=>r-n),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&&(Ne=this._search(t),!(Ne<0||Ne>=this._array.length)&&this._getKey(this._array[Ne])===t))do yield this._array[Ne];while(++Ne<this._array.length&&this._getKey(this._array[Ne])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ne=this._search(t),!(Ne<0||Ne>=this._array.length)&&this._getKey(this._array[Ne])===t))do e(this._array[Ne]);while(++Ne<this._array.length&&this._getKey(this._array[Ne])===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}},rr=0,Io=0,Z_=class extends le{constructor(){super(),this._decorations=new J_(t=>t?.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ge(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Q_(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 n of this._decorations.getKeyIterator(e))i=n.options.x??0,r=i+(n.options.width??1),t>=i&&t<r&&(!s||(n.options.layer??"bottom")===s)&&(yield n)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{rr=r.options.x??0,Io=rr+(r.options.width??1),t>=rr&&t<Io&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},Q_=class extends Rt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new q),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=be.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=be.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ep=1e3,tp=class{constructor(t,e=ep){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,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},Bo=20,bi=class extends le{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 n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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 tp(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
180
180
  `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(re(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ge(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Bo+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
181
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Bo+1&&(this._liveRegion.textContent+=fr.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 n=s.lines.get(s.ydisp+r),a=[],l=n?.translateToString(!0,void 0,void 0,a)||"",h=(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",h),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"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||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 h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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:h})=>{let c=l instanceof Text?l.parentNode:l,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))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 m=h<u.length?u[h]:u.slice(-1)[0]+1;return m>=this._terminal.cols&&(++d,m=0),{row:d,column:m}},n=r(e),a=r(s);if(!(!n||!a)){if(n.row>a.row||n.row===a.row&&n.column>=a.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(a.row-n.row)*this._terminal.cols-n.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})`}};bi=ke([J(1,on),J(2,wt),J(3,Ct)],bi);var Gr=class extends le{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 q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ge(()=>{$t(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(re(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(re(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(re(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(re(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,n=>{if(this._isMouseOut)return;let a=n?.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 n=0;n<r.length;n++){let a=r[n],l=a.link.range.start.y<t?0:a.link.range.start.x,h=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){r.splice(n--,1);break}s.add(c)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let n=0;n<t;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&i){let n=i.find(a=>this._linkAtPosition(a.link,e));n&&(s=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let n=0;n<this._activeProviderReplies.size;n++){let a=this._activeProviderReplies.get(n)?.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&&tp(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,$t(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 n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!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}}};Gr=ke([J(1,an),J(2,Ct),J(3,Ge),J(4,Ga)],Gr);function tp(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 sp=class extends q_{constructor(t={}){super(t),this._linkifier=this._register(new hs),this.browser=fl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new hs),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(J_),this._instantiationService.setService(Gs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Vm),this._instantiationService.setService(Ga,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(_r)),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($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ge(()=>{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=pe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${H.ESC}]${i};${F_(r)}${dl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=Te.toColor(...e.color));else{let n=s;this._themeService.modifyColors(a=>a[n]=Te.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(bi,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.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(H.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),n=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=n+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(re(this.element,"copy",e=>{this.hasSelection()&&of(e,this._selectionService)}));let t=e=>af(e,this.textarea,this.coreService,this.optionsService);this._register(re(this.textarea,"paste",t)),this._register(re(this.element,"paste",t)),ml?this._register(re(this.element,"mousedown",e=>{e.button===2&&Wn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(re(this.element,"contextmenu",e=>{Wn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),_n&&this._register(re(this.element,"auxclick",e=>{e.button===1&&za(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(re(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(re(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(re(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(re(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(re(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(re(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(re(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(re(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",ur.get()),gl||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(Wm,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(wt,this._coreBrowserService),this._register(re(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(re(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Pr,this._document,this._helperContainer),this._instantiationService.setService(Mi,this._charSizeService),this._themeService=this._instantiationService.createInstance($r),this._instantiationService.setService(_s,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(gi),this._instantiationService.setService(qa,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Or,this.rows,this.screenElement)),this._instantiationService.setService(Ct,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(Ir,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Lr),this._instantiationService.setService(an,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Gr,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(Rr,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(zr,this.element,this.screenElement,i)),this._instantiationService.setService(_f,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($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Mr,this.screenElement)),this._register(re(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(bi,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ar,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(n){let a=t._mouseService.getMouseReportCoords(n,t.screenElement);if(!a)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(n)===!1)return!1;let c=n.deltaY;if(c===0||t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;h=c<0?0:1,l=4;break;default:return!1}return h===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:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(re(e,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(re(e,"wheel",n=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(n,!0);let a=H.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(n,!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){Oa(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=Y_(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===H.ETX||s.key===H.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)&&(ip(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(Ee));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(H.ESC+"[I"):this.coreService.triggerDataEvent(H.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(`${H.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(`${H.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function ip(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var rp=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)}},np=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 nt)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Ao=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 np(e)}getNullCell(){return new nt}},op=class extends le{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new Ao(this._core.buffers.normal,"normal"),this._alternate=new Ao(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)}},ap=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)}},lp=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}},cp=["cols","rows"],dt=0,hp=class extends le{constructor(t){super(),this._core=this._register(new sp(t)),this._addonManager=this._register(new rp),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(cp.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 ap(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new lp(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 op(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
182
- `,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 ur.get()},set promptLabel(t){ur.set(t)},get tooMuchOutput(){return fr.get()},set tooMuchOutput(t){fr.set(t)}}}_verifyIntegers(...t){for(dt of t)if(dt===1/0||isNaN(dt)||dt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dt of t)if(dt&&(dt===1/0||isNaN(dt)||dt%1!==0||dt<0))throw new Error("This API only accepts positive integers")}};var dp=2,up=1,fp=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"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(dp,Math.floor(d/t.css.cell.width)),rows:Math.max(up,Math.floor(c/t.css.cell.height))}}};function mp({onReady:t,onSelectionChange:e,initialData:s,className:i}){const r=A.useRef(null),n=A.useRef(null),a=A.useRef(e);return a.current=e,A.useEffect(()=>{const l=r.current;if(!l)return;const h=getComputedStyle(document.documentElement),c=f=>h.getPropertyValue(f).trim()||void 0,d=new hp({allowTransparency:!1,fontFamily:c("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:c("--sidebar")||c("--card")||c("--background")||"#1e1e1e",cursor:"transparent",foreground:c("--foreground")||"#d4d4d4",selectionBackground:c("--accent"),selectionForeground:c("--accent-foreground"),black:c("--muted"),red:c("--destructive"),green:c("--success"),yellow:c("--warning"),blue:c("--chart-1"),magenta:c("--chart-3"),cyan:c("--chart-5"),white:c("--foreground"),brightBlack:c("--muted-foreground"),brightRed:c("--destructive"),brightGreen:c("--success"),brightYellow:c("--warning"),brightBlue:c("--chart-1"),brightMagenta:c("--chart-3"),brightCyan:c("--chart-5"),brightWhite:c("--foreground")}}),u=new fp;d.loadAddon(u),d.open(l),u.fit(),s&&d.write(s),n.current=d,t?.(d);const m=d.onSelectionChange(()=>{const f=!!d.getSelection();a.current?.(f,()=>d.getSelection())}),_=new ResizeObserver(()=>{u.fit()});return _.observe(l),()=>{m.dispose(),_.disconnect(),n.current=null,d.dispose()}},[]),o.jsx("div",{ref:r,className:te("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function _p(){const t=V.c(2),s=pn()?.entity;let i;return t[0]!==s?(i=Bt(s),t[0]=s,t[1]=i):i=t[1],i}const pp={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"}},gp=["dev","start"];function Po(t){return t?.previewUrl?t.previewUrl.replace(/\/$/,""):null}function vp({daemonOpen:t=!1}){const{org:e}=ye(),s=pn(),i=Ht(),{data:r}=Si.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=lt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,d=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[u,m]=A.useState(null),[_,f]=A.useState(""),[p,g]=A.useState(""),[v,b]=A.useState(!1),[S,x]=A.useState(new Set),w=A.useRef(!1),N=A.useRef(Date.now()),[y,k]=A.useState("setup"),[j,M]=A.useState([]),R=A.useRef(new Map),{sendMessage:T}=wi(),{setChatOpen:C}=Zr(),[D,E]=A.useState(!1),L=A.useRef(null),z=X=>{k(X),E(!1),L.current=null},B=(X,oe,Be)=>{X===y&&(E(oe),L.current=oe?Be:null)},O=()=>{const X=L.current?.();if(!X)return;C(!0),T({parts:[{type:"text",text:`<server-logs>
181
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Bo+1&&(this._liveRegion.textContent+=fr.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 n=s.lines.get(s.ydisp+r),a=[],l=n?.translateToString(!0,void 0,void 0,a)||"",h=(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",h),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"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||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 h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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:h})=>{let c=l instanceof Text?l.parentNode:l,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))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 m=h<u.length?u[h]:u.slice(-1)[0]+1;return m>=this._terminal.cols&&(++d,m=0),{row:d,column:m}},n=r(e),a=r(s);if(!(!n||!a)){if(n.row>a.row||n.row===a.row&&n.column>=a.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(a.row-n.row)*this._terminal.cols-n.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})`}};bi=ke([J(1,on),J(2,wt),J(3,Ct)],bi);var Gr=class extends le{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 q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ge(()=>{$t(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(re(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(re(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(re(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(re(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,n=>{if(this._isMouseOut)return;let a=n?.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 n=0;n<r.length;n++){let a=r[n],l=a.link.range.start.y<t?0:a.link.range.start.x,h=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){r.splice(n--,1);break}s.add(c)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let n=0;n<t;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&i){let n=i.find(a=>this._linkAtPosition(a.link,e));n&&(s=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let n=0;n<this._activeProviderReplies.size;n++){let a=this._activeProviderReplies.get(n)?.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&&sp(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,$t(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 n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!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}}};Gr=ke([J(1,an),J(2,Ct),J(3,Ge),J(4,Ga)],Gr);function sp(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 ip=class extends G_{constructor(t={}){super(t),this._linkifier=this._register(new hs),this.browser=fl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new hs),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(Z_),this._instantiationService.setService(Gs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Km),this._instantiationService.setService(Ga,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(_r)),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($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ge(()=>{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=pe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${H.ESC}]${i};${H_(r)}${dl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=Te.toColor(...e.color));else{let n=s;this._themeService.modifyColors(a=>a[n]=Te.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(bi,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.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(H.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),n=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=n+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(re(this.element,"copy",e=>{this.hasSelection()&&af(e,this._selectionService)}));let t=e=>lf(e,this.textarea,this.coreService,this.optionsService);this._register(re(this.textarea,"paste",t)),this._register(re(this.element,"paste",t)),ml?this._register(re(this.element,"mousedown",e=>{e.button===2&&Wn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(re(this.element,"contextmenu",e=>{Wn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),_n&&this._register(re(this.element,"auxclick",e=>{e.button===1&&za(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(re(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(re(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(re(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(re(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(re(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(re(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(re(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(re(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",ur.get()),gl||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(Um,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(wt,this._coreBrowserService),this._register(re(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(re(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Pr,this._document,this._helperContainer),this._instantiationService.setService(Mi,this._charSizeService),this._themeService=this._instantiationService.createInstance($r),this._instantiationService.setService(_s,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(gi),this._instantiationService.setService(qa,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Or,this.rows,this.screenElement)),this._instantiationService.setService(Ct,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(Ir,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Lr),this._instantiationService.setService(an,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Gr,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(Dr,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(zr,this.element,this.screenElement,i)),this._instantiationService.setService(pf,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($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Mr,this.screenElement)),this._register(re(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(bi,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ar,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(n){let a=t._mouseService.getMouseReportCoords(n,t.screenElement);if(!a)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(n)===!1)return!1;let c=n.deltaY;if(c===0||t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;h=c<0?0:1,l=4;break;default:return!1}return h===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:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(re(e,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(re(e,"wheel",n=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(n,!0);let a=H.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(n,!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){Oa(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=X_(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===H.ETX||s.key===H.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)&&(rp(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(Ee));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(H.ESC+"[I"):this.coreService.triggerDataEvent(H.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(`${H.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(`${H.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function rp(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var np=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)}},op=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 nt)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Ao=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 op(e)}getNullCell(){return new nt}},ap=class extends le{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new Ao(this._core.buffers.normal,"normal"),this._alternate=new Ao(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)}},lp=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)}},cp=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}},hp=["cols","rows"],dt=0,dp=class extends le{constructor(t){super(),this._core=this._register(new ip(t)),this._addonManager=this._register(new np),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(hp.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 lp(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new cp(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 ap(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
182
+ `,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 ur.get()},set promptLabel(t){ur.set(t)},get tooMuchOutput(){return fr.get()},set tooMuchOutput(t){fr.set(t)}}}_verifyIntegers(...t){for(dt of t)if(dt===1/0||isNaN(dt)||dt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dt of t)if(dt&&(dt===1/0||isNaN(dt)||dt%1!==0||dt<0))throw new Error("This API only accepts positive integers")}};var up=2,fp=1,mp=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"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(up,Math.floor(d/t.css.cell.width)),rows:Math.max(fp,Math.floor(c/t.css.cell.height))}}};function _p({onReady:t,onSelectionChange:e,initialData:s,className:i}){const r=A.useRef(null),n=A.useRef(null),a=A.useRef(e);return a.current=e,A.useEffect(()=>{const l=r.current;if(!l)return;const h=getComputedStyle(document.documentElement),c=f=>h.getPropertyValue(f).trim()||void 0,d=new dp({allowTransparency:!1,fontFamily:c("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:c("--sidebar")||c("--card")||c("--background")||"#1e1e1e",cursor:"transparent",foreground:c("--foreground")||"#d4d4d4",selectionBackground:c("--accent"),selectionForeground:c("--accent-foreground"),black:c("--muted"),red:c("--destructive"),green:c("--success"),yellow:c("--warning"),blue:c("--chart-1"),magenta:c("--chart-3"),cyan:c("--chart-5"),white:c("--foreground"),brightBlack:c("--muted-foreground"),brightRed:c("--destructive"),brightGreen:c("--success"),brightYellow:c("--warning"),brightBlue:c("--chart-1"),brightMagenta:c("--chart-3"),brightCyan:c("--chart-5"),brightWhite:c("--foreground")}}),u=new mp;d.loadAddon(u),d.open(l),u.fit(),s&&d.write(s),n.current=d,t?.(d);const m=d.onSelectionChange(()=>{const f=!!d.getSelection();a.current?.(f,()=>d.getSelection())}),_=new ResizeObserver(()=>{u.fit()});return _.observe(l),()=>{m.dispose(),_.disconnect(),n.current=null,d.dispose()}},[]),o.jsx("div",{ref:r,className:te("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function pp(){const t=V.c(2),s=pn()?.entity;let i;return t[0]!==s?(i=Bt(s),t[0]=s,t[1]=i):i=t[1],i}const gp={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"}},vp=["dev","start"];function Po(t){return t?.previewUrl?t.previewUrl.replace(/\/$/,""):null}function xp({daemonOpen:t=!1}){const{org:e}=ye(),s=pn(),i=Ht(),{data:r}=Si.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=lt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,d=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[u,m]=A.useState(null),[_,f]=A.useState(""),[p,g]=A.useState(""),[v,b]=A.useState(!1),[S,x]=A.useState(new Set),w=A.useRef(!1),N=A.useRef(Date.now()),[y,k]=A.useState("setup"),[j,M]=A.useState([]),D=A.useRef(new Map),{sendMessage:T}=wi(),{setChatOpen:C}=Zr(),[R,E]=A.useState(!1),L=A.useRef(null),z=X=>{k(X),E(!1),L.current=null},B=(X,oe,Be)=>{X===y&&(E(oe),L.current=oe?Be:null)},O=()=>{const X=L.current?.();if(!X)return;C(!0),T({parts:[{type:"text",text:`<server-logs>
183
183
  ${X}
184
- </server-logs>`}]}),R.current.get(y)?.clearSelection()},$=Fe({connectionId:It,orgId:e.id}),W=(X,oe)=>{const Be=R.current.get(X);Be&&Be.write(oe)},I=ms();Au(W);const F=Ea(s?.entity?.id,n??void 0),U=I.suspended?"suspended":I.notFound?"creating":d?"running":F?"creating":"idle",K=u??U;A.useEffect(()=>{u==="creating"&&U==="running"&&m(null),u==="stopping"&&U==="idle"&&m(null)},[U,u]);const G=sn($),{mutate:P,isPending:Z}=G,Y=s?.entity?.id,ee=I.notFound?c?.vmId??null:null,ce=A.useRef(null);A.useEffect(()=>{if(!ee||!Y||Z||ce.current===ee)return;ce.current=ee;const X={virtualMcpId:Y};n&&(X.branch=n),P(X,{onError:oe=>{console.error("[env] reprovision VM_START failed",oe)}})},[ee,Y,n,Z,P]);const ie=A.useRef(!1);A.useEffect(()=>{if(I.scripts.length>0&&!ie.current){ie.current=!0;for(const X of gp)if(I.scripts.includes(X)){M([X]),z(X);break}}},[I.scripts]);const Q=async(X,oe)=>{const Be=await $.callTool({name:X,arguments:oe}),Kt=Be.content;if(Kt?.[0]?.text?.startsWith("Error:"))throw new Error(Kt[0].text);return Be.structuredContent??Be},he=async X=>{if(!(v||!d)){b(!0);try{const oe=Po(c);if(!oe)throw new Error("No VM");const Be=await fetch(`${oe}/_decopilot_vm/exec/${X}`,{method:"POST"});if(!Be.ok)throw new Error(`Exec failed: ${Be.statusText}`);x(Kt=>{const gn=new Set(Kt);return gn.delete(X),gn})}finally{b(!1)}}},de=async X=>{if(!(v||!d)){b(!0);try{const oe=Po(c);if(!oe)throw new Error("No VM");const Be=await fetch(`${oe}/_decopilot_vm/kill/${X}`,{method:"POST"});if(!Be.ok)throw new Error(`Kill failed: ${Be.statusText}`);x(Kt=>new Set(Kt).add(X))}finally{b(!1)}}},ue=X=>{j.includes(X)||M(oe=>[...oe,X]),z(X),he(X)},we=async()=>{if(!w.current){w.current=!0,N.current=Date.now(),m("creating"),f("Connecting..."),g(""),ie.current=!1,M([]),z("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const X={virtualMcpId:s.entity.id};n&&(X.branch=n);const oe=await Q("VM_START",X);if(!oe.vmId||!oe.branch)throw new Error("Invalid VM response — missing fields");n||a(oe.branch),f(""),ni(i)}catch(X){m("error"),g(X instanceof Error?X.message:"Failed to start VM")}finally{w.current=!1}}},Xe=async()=>{const X=d?.branch??n;m("stopping");const oe=s?.entity?.id;if(oe&&X)try{await $.callTool({name:"VM_DELETE",arguments:{virtualMcpId:oe,branch:X}})}catch{}ni(i)},He=_p();if(!He)return null;const ne=s?.entity?.metadata?.runtime,ve="__none__",tt=Object.keys(pp),_e=async(X,oe)=>{if(s?.entity)try{await $.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...ne,[X]:oe}}}}}),ni(i)}catch{me.error("Failed to update setting")}};if(K==="idle"||K==="stopping"){const X=K==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[o.jsxs("a",{href:`https://github.com/${He.owner}/${He.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(_h,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[He.owner,"/",He.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",He.owner,"/",He.name]})]}),o.jsx(Wt,{size:14,className:"text-muted-foreground shrink-0"})]}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(es,{value:ne?.selected??ve,onValueChange:oe=>_e("selected",oe===ve?null:oe),children:[o.jsx(ts,{id:"env-runtime",className:"w-28",children:o.jsx(ss,{placeholder:"None"})}),o.jsxs(is,{children:[o.jsx(Rt,{value:ve,children:"None"}),tt.map(oe=>o.jsx(Rt,{value:oe,children:oe},oe))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(fs,{id:"env-port",placeholder:"3000",className:"w-20 h-8",defaultValue:ne?.port??"",onBlur:oe=>_e("port",oe.target.value||null)})]}),o.jsxs(se,{onClick:we,disabled:X,children:[X?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(oi,{size:14}),X?"Stopping...":"Run"]})]})]})})}if(K==="creating"){const X=I.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Me,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:X}),o.jsx(rc,{since:N.current})]})}if(K==="error")return o.jsx(Pa,{errorMsg:p,onRetry:we});if(K==="suspended")return o.jsx(Aa,{onResume:we});const Vt=["setup",...j,...t?["daemon"]:[]],gs=I.scripts.filter(X=>!j.includes(X));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[Vt.map(X=>o.jsx("button",{type:"button",onClick:()=>z(X),className:te("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",y===X?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:X},X)),gs.length>0&&o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(cs,{size:14})})}),o.jsx(os,{align:"start",children:gs.map(X=>o.jsx(yt,{onClick:()=>ue(X),children:X},X))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:d?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(d?.vmId??""),children:d.vmId})}),o.jsx(qe,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(dr,{size:10})})}),o.jsx(os,{align:"center",children:o.jsxs(yt,{onClick:Xe,children:[o.jsx(jn,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[D&&o.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Sc,{size:12}),"Add to chat"]}),y!=="setup"&&y!=="daemon"&&j.includes(y)&&(()=>{const X=I.activeProcesses.includes(y)&&!S.has(y);return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:v,onClick:()=>he(y),className:te("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",X?"rounded-l-md border-r-0":"rounded-md"),children:[v?o.jsx(Me,{size:12,className:"animate-spin"}):o.jsx(oi,{size:12}),v?"Running...":X?"Restart":"Run"]}),X&&o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",disabled:v,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(dr,{size:12})})}),o.jsx(os,{align:"end",children:o.jsxs(yt,{onClick:()=>de(y),children:[o.jsx(jn,{size:12}),"Stop Process"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:Vt.map(X=>o.jsx("div",{className:te("h-full",y===X?"block":"hidden"),children:I.hasData(X)||X==="setup"||X==="daemon"?o.jsx(mp,{onReady:oe=>{R.current.set(X,oe)},onSelectionChange:(oe,Be)=>B(X,oe,Be),initialData:I.getBuffer(X),className:"h-full"}):o.jsx(Ps,{className:"h-full",image:null,title:`Script "${X}" not running`,description:`Click Run to start "${X}".`,actions:o.jsxs(se,{variant:"outline",size:"sm",disabled:v,onClick:()=>he(X),children:[v?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(oi,{size:14}),"Run"]})})},X))})]})})}function xp(t){const e=V.c(2),{virtualMcpId:s}=t,i=gt(s);if(!(i?Bt(i):null)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[o.jsx(as,{size:24,className:"text-muted-foreground/60"}),o.jsx("div",{children:"No repository connected."}),o.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Env."})]}),e[0]=a):a=e[0],a}let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(vp,{}),e[1]=n):n=e[1],n}function Bs(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function bp(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 n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function Sp(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 yp(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 n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function wp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Cp=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function kp(t){const e=V.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Vs(),[h,c]=A.useState(!1),d=i??h;let u;e[0]!==r?(u=R=>{r?r(R):c(R)},e[0]=r,e[1]=u):u=e[1];const m=u;let _;e[2]!==l||e[3]!==s||e[4]!==m?(_=async R=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:R}),me.success("Starter added"),m(!1)}catch(T){const C=T,D=C instanceof Error?C.message:"Failed to add starter";me.error(D)}},e[2]=l,e[3]=s,e[4]=m,e[5]=_):_=e[5];const f=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(ns,{asChild:!0,children:o.jsxs(se,{variant:"outline",size:"sm",children:[o.jsx(cs,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(dh,{className:"gap-2.5",children:[o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==f?(v=Cp.map(R=>o.jsxs(yt,{className:"gap-2.5",onSelect:()=>f(R.cron),disabled:l.isPending,children:[o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",R.label]},R.cron)),e[8]=l,e[9]=f,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(uh,{children:[g,o.jsx(fh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=b):b=e[12];let S;e[13]!==m||e[14]!==n?(S=()=>{m(!1),n?.()},e[13]=m,e[14]=n,e[15]=S):S=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let w;e[17]!==S?(w=o.jsxs(yt,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=w):w=e[18];let N;e[19]!==m||e[20]!==a?(N=()=>{m(!1),a?.()},e[19]=m,e[20]=a,e[21]=N):N=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Ls,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=y):y=e[22];let k;e[23]!==N?(k=o.jsxs(yt,{className:"gap-2.5",onSelect:N,children:[y,"Event"]}),e[23]=N,e[24]=k):k=e[24];let j;e[25]!==k||e[26]!==b||e[27]!==w?(j=o.jsxs(os,{align:"end",className:"w-[200px]",children:[b,w,k]}),e[25]=k,e[26]=b,e[27]=w,e[28]=j):j=e[28];let M;return e[29]!==m||e[30]!==d||e[31]!==j?(M=o.jsxs(rs,{open:d,onOpenChange:m,children:[p,j]}),e[29]=m,e[30]=d,e[31]=j,e[32]=M):M=e[32],M}function Np(t){const e=V.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Vs(),[l,h]=A.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?yp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const d=c,[u,m]=A.useState(d?.count??1),[_,f]=A.useState(!1),[p,g]=A.useState(s.cron_expression??""),v=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),me.success("Starter removed")}catch{me.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const x=S;let w;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const W=p.trim();if(!W||!Bs(W)||W===s.cron_expression){f(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:W}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),f(!1)}catch{me.error("Failed to update starter"),g(s.cron_expression??""),f(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=w):w=e[12];const N=w;let y;e[13]!==n||e[14]!==i||e[15]!==d||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(y=async W=>{if(!d)return;const I=Math.max(1,W),F=Sp(I,d.unit);if(F!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:F}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{me.error("Failed to update starter"),m(d.count)}},e[13]=n,e[14]=i,e[15]=d,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=y):y=e[19];const k=y;let j;e[20]!==b?(j=b?o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Ls,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=j):j=e[21];let M;e[22]!==r||e[23]!==u||e[24]!==p||e[25]!==k||e[26]!==N||e[27]!==d||e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(M=d&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:u,onChange:W=>m(parseInt(W.target.value)||1),onBlur:()=>k(u),onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&m(d.count)},disabled:v,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"}),o.jsx("span",{className:"text-sm",children:wp(d.unit,u)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:W=>g(W.target.value),onBlur:N,onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&(f(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!Bs(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?bp(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(jp).join(", ")})]}),e[22]=r,e[23]=u,e[24]=p,e[25]=k,e[26]=N,e[27]=d,e[28]=b,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=M):M=e[34];let R;e[35]!==v?(R=v&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=R):R=e[36];let T;e[37]!==d||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(T=b&&!d&&!_&&o.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),f(!0)},children:o.jsx(yc,{size:13,className:"text-muted-foreground"})}),e[37]=d,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=T):T=e[41];let C;e[42]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(ls,{size:13,className:"text-muted-foreground"})}),e[42]=C):C=e[42];let D;e[43]!==R||e[44]!==T?(D=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[R,T,C]}),e[43]=R,e[44]=T,e[45]=D):D=e[45];let E;e[46]!==D||e[47]!==j||e[48]!==M?(E=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[j,M,D]}),e[46]=D,e[47]=j,e[48]=M,e[49]=E):E=e[49];let L;e[50]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsxs(ma,{children:[o.jsx(_a,{children:"Remove Starter"}),o.jsx(pa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=L):L=e[50];let z;e[51]===Symbol.for("react.memo_cache_sentinel")?(z=o.jsx(va,{children:"Cancel"}),e[51]=z):z=e[51];let B;e[52]!==x?(B=o.jsxs(fa,{children:[L,o.jsxs(ga,{children:[z,o.jsx(xa,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=B):B=e[53];let O;e[54]!==l||e[55]!==B?(O=o.jsx(ua,{open:l,onOpenChange:h,children:B}),e[54]=l,e[55]=B,e[56]=O):O=e[56];let $;return e[57]!==E||e[58]!==O?($=o.jsxs(o.Fragment,{children:[E,O]}),e[57]=E,e[58]=O,e[59]=$):$=e[59],$}function jp(t){const[e,s]=t;return`${e}: ${s}`}function Ep(t){const e=V.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 n=ji(r),[a,l]=A.useState(),[h,c]=A.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,m]=A.useState(d),{triggerAdd:_}=Vs(),{data:f,isLoading:p}=gh(a);let g,v,b,S,x,w;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==u||e[9]!==n||e[10]!==f){const k=f?.find(B=>B.type===h);let j;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(j=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),Se("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),me.success("Event trigger added"),i()}catch{me.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=j):j=e[23],g=j,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let M,R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(Ls,{size:14,className:"text-muted-foreground shrink-0"}),M=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=M,e[25]=R):(M=e[24],R=e[25]);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(ls,{size:13}),e[26]=T):T=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[R,M,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:T})]}),e[27]=i,e[28]=b):b=e[28];const C=a??"";let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=B=>{l(B),c(void 0),m({})},e[29]=D):D=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ts,{className:"w-full",children:o.jsx(ss,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let L;e[31]!==n?(L=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map(Rp),e[31]=n,e[32]=L):L=e[32];let z;e[33]!==L?(z=o.jsx(is,{children:L}),e[33]=L,e[34]=z):z=e[34],e[35]!==C||e[36]!==z?(S=o.jsxs(es,{value:C,onValueChange:D,children:[E,z]}),e[35]=C,e[36]=z,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==f?(x=a&&o.jsxs(es,{value:h??"",onValueChange:B=>{c(B),m({})},children:[o.jsx(ts,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Me,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(ss,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(is,{children:f?.map(Dp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=f,e[42]=x):x=e[42],w=k?.paramsSchema&&Object.keys(k.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(k.paramsSchema).map(B=>{const[O,$]=B;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,$.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",$.description]})]}),$.enum?o.jsxs(es,{value:u[O]??"",onValueChange:W=>m(I=>({...I,[O]:W})),children:[o.jsx(ts,{className:"w-full",children:o.jsx(ss,{placeholder:`Select ${O}...`})}),o.jsx(is,{children:$.enum.map(Tp)})]}):o.jsx("input",{type:"text",value:u[O]??"",onChange:W=>m(I=>({...I,[O]:W.target.value})),placeholder:$.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=u,e[9]=n,e[10]=f,e[11]=g,e[12]=v,e[13]=b,e[14]=S,e[15]=x,e[16]=w}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],w=e[16];let N;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(N=a&&h&&o.jsx(se,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Me,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=N):N=e[47];let y;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==w||e[53]!==N?(y=o.jsxs("div",{className:v,children:[b,S,x,w,N]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=w,e[53]=N,e[54]=y):y=e[54],y}function Tp(t){return o.jsx(Rt,{value:t,children:t},t)}function Dp(t){return o.jsx(Rt,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Rp(t){return o.jsx(Rt,{value:t.id,children:t.title},t.id)}function Mp({automationId:t,automation:e,virtualMcpId:s,onBack:i,onDelete:r}){const n=e.agent?.id??s,{org:a}=ye(),{update:l,triggerAdd:h}=Vs(),c=ji(),d=new Map(c.map(ne=>[ne.id,ne.title])),{createTaskWithMessage:u}=lt(),{setModel:m,credentialId:_,selectedModel:f,setChatMode:p}=yi(),[g,v]=Al(),b=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[S,x]=A.useState(b),[w,N]=A.useState(!1),[y,k]=A.useState(!1),[j,M]=A.useState(""),[R,T]=A.useState(!1),C=A.useRef(!1),D=A.useRef(null),E=A.useRef(!1),L=A.useRef(b),z=()=>{const ve=xn(S).filter(tt=>tt.type==="text").map(tt=>tt.text).join(`
184
+ </server-logs>`}]}),D.current.get(y)?.clearSelection()},$=Fe({connectionId:It,orgId:e.id}),W=(X,oe)=>{const Be=D.current.get(X);Be&&Be.write(oe)},I=ms();Pu(W);const F=Ea(s?.entity?.id,n??void 0),U=I.suspended?"suspended":I.notFound?"creating":d?"running":F?"creating":"idle",K=u??U;A.useEffect(()=>{u==="creating"&&U==="running"&&m(null),u==="stopping"&&U==="idle"&&m(null)},[U,u]);const G=sn($),{mutate:P,isPending:Z}=G,Y=s?.entity?.id,ee=I.notFound?c?.vmId??null:null,ce=A.useRef(null);A.useEffect(()=>{if(!ee||!Y||Z||ce.current===ee)return;ce.current=ee;const X={virtualMcpId:Y};n&&(X.branch=n),P(X,{onError:oe=>{console.error("[env] reprovision VM_START failed",oe)}})},[ee,Y,n,Z,P]);const ie=A.useRef(!1);A.useEffect(()=>{if(I.scripts.length>0&&!ie.current){ie.current=!0;for(const X of vp)if(I.scripts.includes(X)){M([X]),z(X);break}}},[I.scripts]);const Q=async(X,oe)=>{const Be=await $.callTool({name:X,arguments:oe}),Kt=Be.content;if(Kt?.[0]?.text?.startsWith("Error:"))throw new Error(Kt[0].text);return Be.structuredContent??Be},he=async X=>{if(!(v||!d)){b(!0);try{const oe=Po(c);if(!oe)throw new Error("No VM");const Be=await fetch(`${oe}/_decopilot_vm/exec/${X}`,{method:"POST"});if(!Be.ok)throw new Error(`Exec failed: ${Be.statusText}`);x(Kt=>{const gn=new Set(Kt);return gn.delete(X),gn})}finally{b(!1)}}},de=async X=>{if(!(v||!d)){b(!0);try{const oe=Po(c);if(!oe)throw new Error("No VM");const Be=await fetch(`${oe}/_decopilot_vm/kill/${X}`,{method:"POST"});if(!Be.ok)throw new Error(`Kill failed: ${Be.statusText}`);x(Kt=>new Set(Kt).add(X))}finally{b(!1)}}},ue=X=>{j.includes(X)||M(oe=>[...oe,X]),z(X),he(X)},we=async()=>{if(!w.current){w.current=!0,N.current=Date.now(),m("creating"),f("Connecting..."),g(""),ie.current=!1,M([]),z("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const X={virtualMcpId:s.entity.id};n&&(X.branch=n);const oe=await Q("VM_START",X);if(!oe.vmId||!oe.branch)throw new Error("Invalid VM response — missing fields");n||a(oe.branch),f(""),ni(i)}catch(X){m("error"),g(X instanceof Error?X.message:"Failed to start VM")}finally{w.current=!1}}},Xe=async()=>{const X=d?.branch??n;m("stopping");const oe=s?.entity?.id;if(oe&&X)try{await $.callTool({name:"VM_DELETE",arguments:{virtualMcpId:oe,branch:X}})}catch{}ni(i)},He=pp();if(!He)return null;const ne=s?.entity?.metadata?.runtime,ve="__none__",tt=Object.keys(gp),_e=async(X,oe)=>{if(s?.entity)try{await $.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...ne,[X]:oe}}}}}),ni(i)}catch{me.error("Failed to update setting")}};if(K==="idle"||K==="stopping"){const X=K==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[o.jsxs("a",{href:`https://github.com/${He.owner}/${He.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(ph,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[He.owner,"/",He.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",He.owner,"/",He.name]})]}),o.jsx(Wt,{size:14,className:"text-muted-foreground shrink-0"})]}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(es,{value:ne?.selected??ve,onValueChange:oe=>_e("selected",oe===ve?null:oe),children:[o.jsx(ts,{id:"env-runtime",className:"w-28",children:o.jsx(ss,{placeholder:"None"})}),o.jsxs(is,{children:[o.jsx(Dt,{value:ve,children:"None"}),tt.map(oe=>o.jsx(Dt,{value:oe,children:oe},oe))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(fs,{id:"env-port",placeholder:"3000",className:"w-20 h-8",defaultValue:ne?.port??"",onBlur:oe=>_e("port",oe.target.value||null)})]}),o.jsxs(se,{onClick:we,disabled:X,children:[X?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(oi,{size:14}),X?"Stopping...":"Run"]})]})]})})}if(K==="creating"){const X=I.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Me,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:X}),o.jsx(rc,{since:N.current})]})}if(K==="error")return o.jsx(Pa,{errorMsg:p,onRetry:we});if(K==="suspended")return o.jsx(Aa,{onResume:we});const Vt=["setup",...j,...t?["daemon"]:[]],gs=I.scripts.filter(X=>!j.includes(X));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[Vt.map(X=>o.jsx("button",{type:"button",onClick:()=>z(X),className:te("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",y===X?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:X},X)),gs.length>0&&o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(cs,{size:14})})}),o.jsx(os,{align:"start",children:gs.map(X=>o.jsx(yt,{onClick:()=>ue(X),children:X},X))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:d?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(d?.vmId??""),children:d.vmId})}),o.jsx(qe,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(dr,{size:10})})}),o.jsx(os,{align:"center",children:o.jsxs(yt,{onClick:Xe,children:[o.jsx(jn,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[R&&o.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Sc,{size:12}),"Add to chat"]}),y!=="setup"&&y!=="daemon"&&j.includes(y)&&(()=>{const X=I.activeProcesses.includes(y)&&!S.has(y);return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:v,onClick:()=>he(y),className:te("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",X?"rounded-l-md border-r-0":"rounded-md"),children:[v?o.jsx(Me,{size:12,className:"animate-spin"}):o.jsx(oi,{size:12}),v?"Running...":X?"Restart":"Run"]}),X&&o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",disabled:v,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(dr,{size:12})})}),o.jsx(os,{align:"end",children:o.jsxs(yt,{onClick:()=>de(y),children:[o.jsx(jn,{size:12}),"Stop Process"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:Vt.map(X=>o.jsx("div",{className:te("h-full",y===X?"block":"hidden"),children:I.hasData(X)||X==="setup"||X==="daemon"?o.jsx(_p,{onReady:oe=>{D.current.set(X,oe)},onSelectionChange:(oe,Be)=>B(X,oe,Be),initialData:I.getBuffer(X),className:"h-full"}):o.jsx(Ps,{className:"h-full",image:null,title:`Script "${X}" not running`,description:`Click Run to start "${X}".`,actions:o.jsxs(se,{variant:"outline",size:"sm",disabled:v,onClick:()=>he(X),children:[v?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(oi,{size:14}),"Run"]})})},X))})]})})}function bp(t){const e=V.c(2),{virtualMcpId:s}=t,i=gt(s);if(!(i?Bt(i):null)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[o.jsx(as,{size:24,className:"text-muted-foreground/60"}),o.jsx("div",{children:"No repository connected."}),o.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Env."})]}),e[0]=a):a=e[0],a}let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(xp,{}),e[1]=n):n=e[1],n}function Bs(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Sp(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 n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function yp(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 wp(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 n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Cp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const kp=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Np(t){const e=V.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Vs(),[h,c]=A.useState(!1),d=i??h;let u;e[0]!==r?(u=D=>{r?r(D):c(D)},e[0]=r,e[1]=u):u=e[1];const m=u;let _;e[2]!==l||e[3]!==s||e[4]!==m?(_=async D=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:D}),me.success("Starter added"),m(!1)}catch(T){const C=T,R=C instanceof Error?C.message:"Failed to add starter";me.error(R)}},e[2]=l,e[3]=s,e[4]=m,e[5]=_):_=e[5];const f=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(ns,{asChild:!0,children:o.jsxs(se,{variant:"outline",size:"sm",children:[o.jsx(cs,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(uh,{className:"gap-2.5",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==f?(v=kp.map(D=>o.jsxs(yt,{className:"gap-2.5",onSelect:()=>f(D.cron),disabled:l.isPending,children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",D.label]},D.cron)),e[8]=l,e[9]=f,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(fh,{children:[g,o.jsx(mh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=b):b=e[12];let S;e[13]!==m||e[14]!==n?(S=()=>{m(!1),n?.()},e[13]=m,e[14]=n,e[15]=S):S=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let w;e[17]!==S?(w=o.jsxs(yt,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=w):w=e[18];let N;e[19]!==m||e[20]!==a?(N=()=>{m(!1),a?.()},e[19]=m,e[20]=a,e[21]=N):N=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Ls,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=y):y=e[22];let k;e[23]!==N?(k=o.jsxs(yt,{className:"gap-2.5",onSelect:N,children:[y,"Event"]}),e[23]=N,e[24]=k):k=e[24];let j;e[25]!==k||e[26]!==b||e[27]!==w?(j=o.jsxs(os,{align:"end",className:"w-[200px]",children:[b,w,k]}),e[25]=k,e[26]=b,e[27]=w,e[28]=j):j=e[28];let M;return e[29]!==m||e[30]!==d||e[31]!==j?(M=o.jsxs(rs,{open:d,onOpenChange:m,children:[p,j]}),e[29]=m,e[30]=d,e[31]=j,e[32]=M):M=e[32],M}function jp(t){const e=V.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Vs(),[l,h]=A.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?wp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const d=c,[u,m]=A.useState(d?.count??1),[_,f]=A.useState(!1),[p,g]=A.useState(s.cron_expression??""),v=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),me.success("Starter removed")}catch{me.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const x=S;let w;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const W=p.trim();if(!W||!Bs(W)||W===s.cron_expression){f(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:W}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),f(!1)}catch{me.error("Failed to update starter"),g(s.cron_expression??""),f(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=w):w=e[12];const N=w;let y;e[13]!==n||e[14]!==i||e[15]!==d||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(y=async W=>{if(!d)return;const I=Math.max(1,W),F=yp(I,d.unit);if(F!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:F}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{me.error("Failed to update starter"),m(d.count)}},e[13]=n,e[14]=i,e[15]=d,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=y):y=e[19];const k=y;let j;e[20]!==b?(j=b?o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Ls,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=j):j=e[21];let M;e[22]!==r||e[23]!==u||e[24]!==p||e[25]!==k||e[26]!==N||e[27]!==d||e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(M=d&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:u,onChange:W=>m(parseInt(W.target.value)||1),onBlur:()=>k(u),onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&m(d.count)},disabled:v,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"}),o.jsx("span",{className:"text-sm",children:Cp(d.unit,u)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:W=>g(W.target.value),onBlur:N,onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&(f(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!Bs(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?Sp(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Ep).join(", ")})]}),e[22]=r,e[23]=u,e[24]=p,e[25]=k,e[26]=N,e[27]=d,e[28]=b,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=M):M=e[34];let D;e[35]!==v?(D=v&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=D):D=e[36];let T;e[37]!==d||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(T=b&&!d&&!_&&o.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),f(!0)},children:o.jsx(yc,{size:13,className:"text-muted-foreground"})}),e[37]=d,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=T):T=e[41];let C;e[42]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(ls,{size:13,className:"text-muted-foreground"})}),e[42]=C):C=e[42];let R;e[43]!==D||e[44]!==T?(R=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[D,T,C]}),e[43]=D,e[44]=T,e[45]=R):R=e[45];let E;e[46]!==R||e[47]!==j||e[48]!==M?(E=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[j,M,R]}),e[46]=R,e[47]=j,e[48]=M,e[49]=E):E=e[49];let L;e[50]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsxs(ma,{children:[o.jsx(_a,{children:"Remove Starter"}),o.jsx(pa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=L):L=e[50];let z;e[51]===Symbol.for("react.memo_cache_sentinel")?(z=o.jsx(va,{children:"Cancel"}),e[51]=z):z=e[51];let B;e[52]!==x?(B=o.jsxs(fa,{children:[L,o.jsxs(ga,{children:[z,o.jsx(xa,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=B):B=e[53];let O;e[54]!==l||e[55]!==B?(O=o.jsx(ua,{open:l,onOpenChange:h,children:B}),e[54]=l,e[55]=B,e[56]=O):O=e[56];let $;return e[57]!==E||e[58]!==O?($=o.jsxs(o.Fragment,{children:[E,O]}),e[57]=E,e[58]=O,e[59]=$):$=e[59],$}function Ep(t){const[e,s]=t;return`${e}: ${s}`}function Tp(t){const e=V.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 n=ji(r),[a,l]=A.useState(),[h,c]=A.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,m]=A.useState(d),{triggerAdd:_}=Vs(),{data:f,isLoading:p}=vh(a);let g,v,b,S,x,w;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==u||e[9]!==n||e[10]!==f){const k=f?.find(B=>B.type===h);let j;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(j=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),Se("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),me.success("Event trigger added"),i()}catch{me.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=j):j=e[23],g=j,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let M,D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(Ls,{size:14,className:"text-muted-foreground shrink-0"}),M=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=M,e[25]=D):(M=e[24],D=e[25]);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(ls,{size:13}),e[26]=T):T=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[D,M,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:T})]}),e[27]=i,e[28]=b):b=e[28];const C=a??"";let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=B=>{l(B),c(void 0),m({})},e[29]=R):R=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ts,{className:"w-full",children:o.jsx(ss,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let L;e[31]!==n?(L=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map(Mp),e[31]=n,e[32]=L):L=e[32];let z;e[33]!==L?(z=o.jsx(is,{children:L}),e[33]=L,e[34]=z):z=e[34],e[35]!==C||e[36]!==z?(S=o.jsxs(es,{value:C,onValueChange:R,children:[E,z]}),e[35]=C,e[36]=z,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==f?(x=a&&o.jsxs(es,{value:h??"",onValueChange:B=>{c(B),m({})},children:[o.jsx(ts,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Me,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(ss,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(is,{children:f?.map(Dp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=f,e[42]=x):x=e[42],w=k?.paramsSchema&&Object.keys(k.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(k.paramsSchema).map(B=>{const[O,$]=B;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,$.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",$.description]})]}),$.enum?o.jsxs(es,{value:u[O]??"",onValueChange:W=>m(I=>({...I,[O]:W})),children:[o.jsx(ts,{className:"w-full",children:o.jsx(ss,{placeholder:`Select ${O}...`})}),o.jsx(is,{children:$.enum.map(Rp)})]}):o.jsx("input",{type:"text",value:u[O]??"",onChange:W=>m(I=>({...I,[O]:W.target.value})),placeholder:$.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=u,e[9]=n,e[10]=f,e[11]=g,e[12]=v,e[13]=b,e[14]=S,e[15]=x,e[16]=w}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],w=e[16];let N;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(N=a&&h&&o.jsx(se,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Me,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=N):N=e[47];let y;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==w||e[53]!==N?(y=o.jsxs("div",{className:v,children:[b,S,x,w,N]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=w,e[53]=N,e[54]=y):y=e[54],y}function Rp(t){return o.jsx(Dt,{value:t,children:t},t)}function Dp(t){return o.jsx(Dt,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Mp(t){return o.jsx(Dt,{value:t.id,children:t.title},t.id)}function Ip({automationId:t,automation:e,virtualMcpId:s,onBack:i,onDelete:r}){const n=e.agent?.id??s,{org:a}=ye(),{update:l,triggerAdd:h}=Vs(),c=ji(),d=new Map(c.map(ne=>[ne.id,ne.title])),{createTaskWithMessage:u}=lt(),{setModel:m,credentialId:_,selectedModel:f,setChatMode:p}=yi(),[g,v]=Al(),b=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[S,x]=A.useState(b),[w,N]=A.useState(!1),[y,k]=A.useState(!1),[j,M]=A.useState(""),[D,T]=A.useState(!1),C=A.useRef(!1),R=A.useRef(null),E=A.useRef(!1),L=A.useRef(b),z=()=>{const ve=xn(S).filter(tt=>tt.type==="text").map(tt=>tt.text).join(`
185
185
  `);ve.trim()&&(ie(),Se("automation_improve_clicked",{automation_id:t,agent_id:n,instructions_length:ve.length}),p("plan"),u({virtualMcpId:Xo(a.id),message:{parts:[{type:"text",text:`/writing-prompts for automation with id ${t}. The current message is
186
186
 
187
187
  <message>
188
188
  ${ve}
189
- </message>`}]}}))},B=e.models?.credentialId||_||"",O=e.models?.thinking?.id||f?.modelId||"",$=Vo({defaultValues:{name:e.name,active:e.active,credential_id:B,model_id:O}}),W=$.watch("active"),I=$.watch("credential_id"),F=$.watch("model_id"),{models:U,isLoading:K}=jc(I||void 0),G=U.find(ne=>ne.modelId===F)??null,P=A.useRef(null),Z=A.useRef(new Set),Y=A.useRef(0),ee=A.useRef(null),ce=3e4,ie=()=>{ee.current&&(clearTimeout(ee.current),ee.current=null),P.current!==null&&(Se("automation_updated",{automation_id:t,agent_id:n,fields:Array.from(Z.current),save_count:Y.current,edit_duration_ms:Date.now()-P.current}),P.current=null,Z.current=new Set,Y.current=0)},Q=async()=>{if(!(Object.keys($.formState.dirtyFields).length>0)&&!E.current)return!0;const ve=Object.keys($.formState.dirtyFields),tt=E.current;E.current=!1;const _e=$.getValues(),Vt=L.current;try{const gs=_e.credential_id&&_e.model_id?_e.credential_id:"",X=_e.credential_id&&_e.model_id?_e.model_id:"",oe={id:t,name:_e.name,active:_e.active,agent:{id:n},models:{credentialId:gs,thinking:{id:X}},messages:Kl(Vt),temperature:0};await l.mutateAsync(oe),P.current===null&&(P.current=Date.now());for(const Be of ve)Z.current.add(Be);return tt&&Z.current.add("messages"),Y.current+=1,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(ie,ce),$.reset({..._e,credential_id:gs,model_id:X},{keepDirtyValues:!0}),!0}catch{return E.current=!0,!1}},he=A.useRef(Q);he.current=Q;const de=()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{D.current=null,he.current()},1e3)},ue=async()=>(D.current&&(clearTimeout(D.current),D.current=null),he.current()),we=ne=>{if(L.current=ne,x(ne),!C.current){C.current=!0;return}E.current=!0,de()},Xe=A.useRef(!1);Xe.current||(Xe.current=!0,$.watch(()=>{de()})),A.useEffect(()=>()=>{D.current&&(clearTimeout(D.current),D.current=null,he.current())},[]);const He=async()=>{Se("automation_test_clicked",{automation_id:t,agent_id:n});const ne=await ue();if(ie(),!ne)return;if(!S){me.error("No instructions configured for this automation");return}G&&I&&m({...G,keyId:I}),v({...g,toolApprovalLevel:"auto"});const ve=xn(S);u({message:{tiptapDoc:S,parts:ve},virtualMcpId:n||void 0})};return o.jsxs(o.Fragment,{children:[i&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(se,{variant:"ghost",size:"sm",onClick:i,children:[o.jsx(ka,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(fs,{...$.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),r&&o.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:o.jsx(hr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Xt,{control:$.control,name:"active",render:({field:ne})=>o.jsx(cr,{checked:ne.value,onCheckedChange:ve=>{ne.onChange(ve),setTimeout(()=>ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ca,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(kp,{automationId:t,open:w,onOpenChange:N,onCustomSelect:()=>{k(!0),T(!1),M("")},onEventSelect:()=>{T(!0),k(!1)}})]}),e.triggers.length===0&&!y?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>N(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ne=>o.jsx(Np,{trigger:ne,automationId:t,connectionName:ne.connection_id?d.get(ne.connection_id):void 0},ne.id))}),y&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:j,onChange:ne=>M(ne.target.value),onBlur:async()=>{const ne=j.trim();if(!(!ne||!Bs(ne)))try{await h.mutateAsync({automation_id:t,type:"cron",cron_expression:ne}),Se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),k(!1),M("")}catch{me.error("Failed to add starter")}},onKeyDown:async ne=>{const ve=j.trim();ne.key==="Enter"&&ve&&Bs(ve)&&ne.target.blur(),ne.key==="Escape"&&(k(!1),M(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Bs(j)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),h.isPending&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.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:()=>{k(!1),M("")},children:o.jsx(ls,{size:13})})]}),R&&o.jsx(A.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Ep,{automationId:t,onDone:()=>T(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!S,onClick:z,children:[o.jsx(ya,{size:13}),"Improve"]})]}),o.jsx(Hl,{tiptapDoc:S,setTiptapDoc:we,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Wl,{virtualMcpId:n||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(ph,{model:G,isLoading:K,credentialId:I||null,onCredentialChange:ne=>{$.setValue("credential_id",ne??"",{shouldDirty:!0}),$.setValue("model_id","",{shouldDirty:!0})},onModelChange:ne=>$.setValue("model_id",ne.modelId,{shouldDirty:!0}),placeholder:"Model"}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:He,disabled:!n,children:[o.jsx(Ql,{size:16}),"Test"]})}),o.jsx(qe,{children:"Test Automation"})]})]})]})})]})]})]})}function Ip(t){const e=V.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=Zo(s),e[0]=s,e[1]=r):r=e[1];const n=r;if(!n)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==n.id||e[4]!==i?(l=o.jsx(at,{children:o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsx(A.Suspense,{fallback:a,children:o.jsx(Bp,{id:n.id,virtualMcpId:i})})})})}),e[3]=n.id,e[4]=i,e[5]=l):l=e[5],l}function Bp(t){const e=V.c(9),{id:s,virtualMcpId:i}=t,r=Mt(),{data:n,isLoading:a}=vh(s);let l;e[0]!==r?(l=()=>r({to:".",search:Ap,replace:!0}),e[0]=r,e[1]=l):l=e[1];const h=l;if(a){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=d):d=e[2],d}if(!n){let d;return e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=d):d=e[3],d}let c;return e[4]!==n||e[5]!==s||e[6]!==h||e[7]!==i?(c=o.jsx(Mp,{automationId:s,automation:n,virtualMcpId:i,onBack:h}),e[4]=n,e[5]=s,e[6]=h,e[7]=i,e[8]=c):c=e[8],c}function Ap(t){return{...t,main:"automations"}}function Pp(t){const e=V.c(20),{virtualMcpId:s}=t,i=Mt(),{data:r}=xh(s),n=r===void 0?[]:r,{create:a}=Vs(),[l,h]=A.useState(""),c=l.toLowerCase(),d=n.filter(M=>M.name.toLowerCase().includes(c));let u;e[0]!==i?(u=M=>i({to:".",search:R=>({...R,main:"automation:"+M}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const m=u,_=async()=>{if(a.isPending)return;Se("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const M=await a.mutateAsync(Sh(s));m(M.id)},f=at,p=at,g=at;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(at.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(yh,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(se,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let w;e[7]!==b||e[8]!==x?(w=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=w):w=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{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:o.jsxs(se,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):d.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(M=>o.jsx(bh,{automation:M,onClick:()=>m(M.id)},M.id))});let y;e[10]!==N||e[11]!==g.Body||e[12]!==w?(y=o.jsxs(g.Body,{children:[w,N]}),e[10]=N,e[11]=g.Body,e[12]=w,e[13]=y):y=e[13];let k;e[14]!==y||e[15]!==p.Content?(k=o.jsx(p.Content,{children:y}),e[14]=y,e[15]=p.Content,e[16]=k):k=e[16];let j;return e[17]!==f||e[18]!==k?(j=o.jsx(f,{children:k}),e[17]=f,e[18]=k,e[19]=j):j=e[19],j}function Lp(t){const e=V.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(A.Suspense,{fallback:i,children:o.jsx(Pp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Lo=A.lazy(()=>Pl(()=>import("./project-app-view-BTqqbkYN.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])).then(t=>({default:t.AppViewContent})));function Op(t){const e=V.c(44),{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:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Ta(r);if(nc(n)){let f;return e[3]!==i?(f=o.jsx(zn,{virtualMcpId:i}),e[3]=i,e[4]=f):f=e[4],f}if(n==="git"){let f;return e[5]!==i?(f=o.jsx(xu,{virtualMcpId:i}),e[5]=i,e[6]=f):f=e[6],f}if(n==="automations"){let f;return e[7]!==i?(f=o.jsx(Lp,{virtualMcpId:i}),e[7]=i,e[8]=f):f=e[8],f}if(n==="env"){let f;return e[9]!==i?(f=o.jsx(xp,{virtualMcpId:i}),e[9]=i,e[10]=f):f=e[10],f}if(n==="preview"){let f;return e[11]!==i?(f=o.jsx(ef,{virtualMcpId:i}),e[11]=i,e[12]=f):f=e[12],f}if(h){let f;return e[13]!==n||e[14]!==i?(f=o.jsx(Ip,{tabId:n,virtualMcpId:i}),e[13]=n,e[14]=i,e[15]=f):f=e[15],f}let c;e[16]!==n?(c=oc(n),e[16]=n,e[17]=c):c=e[17];const d=c;if(d){let f;if(e[18]!==l||e[19]!==d.connectionId||e[20]!==d.toolName){let S;e[22]!==d.connectionId||e[23]!==d.toolName?(S=x=>x.appId===d.connectionId&&x.toolName===d.toolName,e[22]=d.connectionId,e[23]=d.toolName,e[24]=S):S=e[24],f=l.find(S),e[18]=l,e[19]=d.connectionId,e[20]=d.toolName,e[21]=f}else f=e[21];const p=f;let g;e[25]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[25]=g):g=e[25];const v=p?.args;let b;return e[26]!==n||e[27]!==d.connectionId||e[28]!==d.toolName||e[29]!==v?(b=o.jsx(A.Suspense,{fallback:g,children:o.jsx(Lo,{connectionId:d.connectionId,toolName:d.toolName,args:v},n)}),e[26]=n,e[27]=d.connectionId,e[28]=d.toolName,e[29]=v,e[30]=b):b=e[30],b}let u;if(e[31]!==n||e[32]!==a){let f;e[34]!==n?(f=p=>p.id===n,e[34]=n,e[35]=f):f=e[35],u=a.find(f),e[31]=n,e[32]=a,e[33]=u}else u=e[33];const m=u;if(m){let f;e[36]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[36]=f):f=e[36];let p;return e[37]!==n||e[38]!==m.id||e[39]!==m.view.appId||e[40]!==m.view.args?(p=o.jsx(A.Suspense,{fallback:f,children:o.jsx(Lo,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},n)}),e[37]=n,e[38]=m.id,e[39]=m.view.appId,e[40]=m.view.args,e[41]=p):p=e[41],p}let _;return e[42]!==i?(_=o.jsx(zn,{virtualMcpId:i}),e[42]=i,e[43]=_):_=e[43],_}function zp(t){const e=V.c(7),{children:s,defaultSize:i}=t,[,r]=A.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Go.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=qo(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=m=>r(()=>{m>0&&m<100&&l(m)}),e[1]=l,e[2]=c):c=e[2];const d=c;let u;return e[3]!==s||e[4]!==h||e[5]!==d?(u=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:d,order:1,children:s}),e[3]=s,e[4]=h,e[5]=d,e[6]=u):u=e[6],u}function $p(t){const e=V.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=En(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Go.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=qo(c,45),u=A.useRef(null);let m,_;e[4]!==r||e[5]!==n||e[6]!==d?(m=()=>{const M=u.current;if(!M)return;const R=En(r,n),T=R.chat>0&&R.chat<100?d:R.chat,C=R.chat>0&&R.chat<100?100-d:R.main;M.setLayout([T,C])},_=[r,n,d],e[4]=r,e[5]=n,e[6]=d,e[7]=m,e[8]=_):(m=e[7],_=e[8]),A.useEffect(m,_);const f=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Na,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(zp,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Vc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=te("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[19]=N):N=e[19];let y;e[20]!==i||e[21]!==s?(y=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Op,{taskId:i,virtualMcpId:s})})})}),e[20]=i,e[21]=s,e[22]=y):y=e[22];let k;e[23]!==h.main||e[24]!==y?(k=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:y}),e[23]=h.main,e[24]=y,e[25]=k):k=e[25];let j;return e[26]!==k||e[27]!==f||e[28]!==b?(j=o.jsxs(Kc,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,k]},f),e[26]=k,e[27]=f,e[28]=b,e[29]=j):j=e[29],j}const nr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Oo="bg-sidebar-accent text-sidebar-foreground",or="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Fp(t){const e=V.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Ec(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Se("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Oo:or;let d;e[3]!==c?(d=te(nr,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(wc,{size:16}),e[5]=u):u=e[5];let m;e[6]!==h||e[7]!==d||e[8]!==n?(m=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=n,e[9]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(qe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let f;e[11]!==m?(f=o.jsxs(Ve,{delayDuration:300,children:[m,_]}),e[11]=m,e[12]=f):f=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Se("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Oo:or;let v;e[16]!==g?(v=te(nr,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Cc,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(qe,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(Ve,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let y;e[26]!==N?(y=te("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=y):y=e[27];const k=!l,j=l?0:-1,M=!l,R=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==R?(T=te(nr,or,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",R),e[28]=R,e[29]=T):T=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(ta,{size:16}),e[30]=C):C=e[30];let D;e[31]!==r||e[32]!==k||e[33]!==j||e[34]!==M||e[35]!==T?(D=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:k,tabIndex:j,"aria-hidden":M,className:T,children:C})}),e[31]=r,e[32]=k,e[33]=j,e[34]=M,e[35]=T,e[36]=D):D=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(qe,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let L;e[38]!==D?(L=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ve,{delayDuration:300,children:[D,E]})}),e[38]=D,e[39]=L):L=e[39];let z;e[40]!==y||e[41]!==L?(z=o.jsx("div",{className:y,children:L}),e[40]=y,e[41]=L,e[42]=z):z=e[42];let B;return e[43]!==w||e[44]!==z||e[45]!==f?(B=o.jsxs(o.Fragment,{children:[f,w,z]}),e[43]=w,e[44]=z,e[45]=f,e[46]=B):B=e[46],B}function Hp(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],h=r[a],c=[...i.slice(0,-1),h],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function Wp(t){const e=V.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=te("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Up,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function Up(t){const e=V.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function Vp(t){const e=V.c(13),{overflow:s,onSelect:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i?(a=m=>{n(!1),i(m)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Hs,{asChild:!0,children:o.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:o.jsx(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let m;e[6]!==l?(m=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Kp,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=m):m=e[7],c=s.map(m),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=o.jsx(Ws,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=o.jsxs(Us,{open:r,onOpenChange:n,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function Kp(t){const e=V.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const qp=6;function Gp(t){const e=V.c(20),{virtualMcpId:s,taskId:i}=t,r=Mt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Ta(n);let d,u,m,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=ac({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:w}=Hp(a,S,qp);u=w,d=N=>{const y=a.find(j=>j.id===N),k=S===N&&h;if(Se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:y?.kind??null,was_active:k}),N==="automations"){const j=lc({activeTab:l,mainOpen:h});r({to:".",search:M=>({...M,main:j}),replace:!0});return}c(N)},m="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(Wp,{title:N.title,icon:N.icon,active:v(N),onClick:()=>d(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=m,e[12]=_}else d=e[9],u=e[10],m=e[11],_=e[12];let f;e[13]!==d||e[14]!==u?(f=u.length>0&&o.jsx(Vp,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=f):f=e[15];let p;return e[16]!==m||e[17]!==_||e[18]!==f?(p=o.jsxs("div",{className:m,children:[_,f]}),e[16]=m,e[17]=_,e[18]=f,e[19]=p):p=e[19],p}function Yp(t){const e=V.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=te("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Ll,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function Xp(t){const e=V.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(lu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(au({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(se,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(dr,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=o.jsx(ns,{asChild:!0,children:o.jsx(se,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:d})}),e[10]=i,e[11]=u):u=e[11];let m;e[12]!==h?(m=o.jsx(os,{align:"end",children:o.jsx(yt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=m):m=e[13];let _;e[14]!==u||e[15]!==m?(_=o.jsxs(rs,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=_):_=e[16];let f;return e[17]!==c||e[18]!==_?(f=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=f):f=e[19],f}const Jp=new Set(["failure","timed_out","cancelled","action_required"]);function Zp(t){return t.status==="completed"&&Jp.has(t.conclusion)}function Qp(t){return t.status==="queued"||t.status==="in_progress"}function eg(t){const{branchStatus:e,pr:s,checks:i,reviews:r}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(Zp).map(h=>h.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(Qp)?{label:"Running tests…",disabled:!0}:r?.draft?{label:"Mark ready",action:"mark-ready"}:(r?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function tg(){return ms().branchStatus}const sg=6e4,ig=3e4;function rg(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:sg,refetchIntervalInBackground:!1,staleTime:ig,select:ng},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function ng(t){const e=Ks(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function og(t){const e=V.c(38),{virtualMcpId:s}=t,{org:i}=ye(),r=gt(s),{currentBranch:n}=lt(),a=wi(),l=r?.metadata?.githubRepo??null,h=tg(),c=l?.connectionId??"",d=l?.owner??"",u=l?.name??"",m=n??null;let _;e[0]!==i.id||e[1]!==c||e[2]!==d||e[3]!==u||e[4]!==m?(_={orgId:i.id,connectionId:c,owner:d,repo:u,branch:m},e[0]=i.id,e[1]=c,e[2]=d,e[3]=u,e[4]=m,e[5]=_):_=e[5];const p=Ra(_).data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[6]!==i.id||e[7]!==g||e[8]!==v||e[9]!==b||e[10]!==S?(x={orgId:i.id,connectionId:g,owner:v,repo:b,prNumber:S},e[6]=i.id,e[7]=g,e[8]=v,e[9]=b,e[10]=S,e[11]=x):x=e[11];const w=Ia(x),N=l?.connectionId??"",y=l?.owner??"",k=l?.name??"",j=p&&p.state==="open"?p.number:null;let M;e[12]!==i.id||e[13]!==N||e[14]!==y||e[15]!==k||e[16]!==j?(M={orgId:i.id,connectionId:N,owner:y,repo:k,prNumber:j},e[12]=i.id,e[13]=N,e[14]=y,e[15]=k,e[16]=j,e[17]=M):M=e[17];const R=rg(M);if(!l?.connectionId||!n)return null;let T;e[18]!==h||e[19]!==w.data||e[20]!==p||e[21]!==R.data?(T=eg({branchStatus:h,pr:p,checks:w.data??[],reviews:R.data??null}),e[18]=h,e[19]=w.data,e[20]=p,e[21]=R.data,e[22]=T):T=e[22];const C=T;if(!C)return null;let D;e[23]!==a?(D=I=>a.sendMessage({parts:[{type:"text",text:I}]}),e[23]=a,e[24]=D):D=e[24];const E=D,L=a.isStreaming;let z;e[25]!==n||e[26]!==C||e[27]!==L||e[28]!==p||e[29]!==E?(z=I=>{if(!L)switch(I){case"commit-and-push":{E(Qd({branch:n}));return}case"create-pr":{E(eu({branch:n}));return}case"reopen":{p&&E(tu({prNumber:p.number}));return}case"rebase":{E(su({branch:n}));return}case"fix-checks":{p&&E(ru({prNumber:p.number,failingChecks:C.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(nu({prNumber:p.number}));return}case"resolve-comments":{p&&E(ou({prNumber:p.number}));return}case"merge-split":return}},e[25]=n,e[26]=C,e[27]=L,e[28]=p,e[29]=E,e[30]=z):z=e[30];const B=z;let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(Yp,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=O):O=e[31];const $=p?.number;let W;return e[32]!==C||e[33]!==L||e[34]!==B||e[35]!==E||e[36]!==$?(W=o.jsxs(o.Fragment,{children:[O,o.jsx(ag,{button:C,isStreaming:L,onActivate:B,prNumber:$,send:E})]}),e[32]=C,e[33]=L,e[34]=B,e[35]=E,e[36]=$,e[37]=W):W=e[37],W}function ag(t){const e=V.c(18),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let d;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(d=o.jsx(Xp,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=d):d=e[3];let u;return e[4]!==d||e[5]!==n?(u=o.jsx(zo,{label:n,children:d}),e[4]=d,e[5]=n,e[6]=u):u=e[6],u}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let h;e[10]!==s.label||e[11]!==r||e[12]!==a||e[13]!==l?(h=o.jsx(se,{size:"sm",variant:a,disabled:r,onClick:l,children:s.label}),e[10]=s.label,e[11]=r,e[12]=a,e[13]=l,e[14]=h):h=e[14];let c;return e[15]!==h||e[16]!==n?(c=o.jsx(zo,{label:n,children:h}),e[15]=h,e[16]=n,e[17]=c):c=e[17],c}function zo(t){const e=V.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ke,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(qe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(zc,{children:o.jsxs(Ve,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function lg(t){const e=V.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(lr.Right,{children:o.jsx(og,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Jt=A.createContext(null);function pn(){return A.use(Jt)}function $o(t){const e=V.c(7),{children:s}=t,{taskId:i}=lt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.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]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Na,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Qt,{fallback:r,children:o.jsx(A.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Fo(t){const e=V.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],A.useLayoutEffect(r),null}function cg(t){const e=V.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Gl,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Ho(t){const e=V.c(15),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ye(),{currentBranch:l}=lt(),{data:h}=Si.useSession(),c=h?.user?.id;let d;e[0]!==a.id?(d={connectionId:It,orgId:a.id},e[0]=a.id,e[1]=d):d=e[1];const u=Fe(d),{mutate:m}=sn(u);let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[2]=_):_=e[2];const f=A.useRef(_);let p,g;e[3]!==l||e[4]!==i||e[5]!==m||e[6]!==c||e[7]!==s||e[8]!==r?(p=()=>{i&&c&&l&&(r?.[c]?.[l]||f.current.has(l)||(f.current.add(l),m({virtualMcpId:s,branch:l},{onError:hg})))},g=[i,c,l,r,s,m],e[3]=l,e[4]=i,e[5]=m,e[6]=c,e[7]=s,e[8]=r,e[9]=p,e[10]=g):(p=e[9],g=e[10]),A.useEffect(p,g);const v=l??null;let b;return e[11]!==n||e[12]!==v||e[13]!==s?(b=o.jsx(Bu,{virtualMcpId:s,branch:v,children:n}),e[11]=n,e[12]=v,e[13]=s,e[14]=b):b=e[14],b}function hg(t){console.error("[auto-start-vm] failed:",t)}function dg(){const t=V.c(96),e=aa(),s=Mt(),{org:i}=ye(),r=Tc()?.tasksOpen??!1;$c(i.id);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Ol(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Yr(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??Yo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,m=kh(a.taskId??"",u),_=gt(u),f=_?.metadata?.ui?.layout??null;let p;t[5]!==f?(p=f?{defaultMainView:f.defaultMainView??null,chatDefaultOpen:f.chatDefaultOpen??null}:null,t[5]=f,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Bt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==u?(S={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=S):S=t[11];const x=Dc(g,S),{setOpenMobile:w,openMobile:N}=Ac(),y=w,k=A.useRef(null);let j,M;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const K=G=>{Ic(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),k.current?.())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},M=[],t[12]=j,t[13]=M):(j=t[12],M=t[13]),A.useEffect(j,M);const R=u;let T;t[14]!==_||t[15]!==u?(T={virtualMcpId:u,entity:_},t[14]=_,t[15]=u,t[16]=T):T=t[16];const C=T;if(m.status==="creating"||m.status==="loading"){let K;t[17]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=K):K=t[17];let G;return t[18]!==C?(G=o.jsx(Jt,{value:C,children:K}),t[18]=C,t[19]=G):G=t[19],G}if(m.status==="error"){let K;t[20]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=K):K=t[20];let G;t[21]!==m.error.message?(G=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[K,o.jsx("div",{className:"text-muted-foreground",children:m.error.message})]})}),t[21]=m.error.message,t[22]=G):G=t[22];let P;return t[23]!==C||t[24]!==G?(P=o.jsx(Jt,{value:C,children:G}),t[23]=C,t[24]=G,t[25]=P):P=t[25],P}if(!_){let K;t[26]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(as,{size:48,className:"text-muted-foreground"}),t[26]=K):K=t[26];const G=`The agent "${u}" does not exist in this organization.`;let P;t[27]!==s||t[28]!==l?(P=o.jsx(se,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=P):P=t[29];let Z;t[30]!==G||t[31]!==P?(Z=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Ps,{image:K,title:"Agent not found",description:G,actions:P})})}),t[30]=G,t[31]=P,t[32]=Z):Z=t[32];let Y;return t[33]!==C||t[34]!==Z?(Y=o.jsx(Jt,{value:C,children:Z}),t[33]=C,t[34]=Z,t[35]=Y):Y=t[35],Y}if(e){let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(Pc,{className:"sr-only",children:"Navigation"}),t[36]=K):K=t[36];let G;t[37]!==y?(G=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Rc,{onClose:()=>y(!1)})}),t[37]=y,t[38]=G):G=t[38];let P;t[39]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Mc,{})}),t[39]=P):P=t[39];let Z;t[40]!==G?(Z=o.jsxs(Lc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[K,o.jsxs("div",{className:"flex h-full",children:[G,P]})]}),t[40]=G,t[41]=Z):Z=t[41];let Y;t[42]!==N||t[43]!==y||t[44]!==Z?(Y=o.jsx(Oc,{open:N,onOpenChange:y,children:Z}),t[42]=N,t[43]=y,t[44]=Z,t[45]=Y):Y=t[45];const ee=Y,ce=_?.metadata?.vmMap;let ie;t[46]!==x.createNewTask?(ie=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ie):ie=t[47];let Q;t[48]!==y?(Q=o.jsx(cg,{onOpenSidebar:()=>y(!0)}),t[48]=y,t[49]=Q):Q=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx($o,{})}),t[50]=he):he=t[50];let de;t[51]!==b||t[52]!==ee||t[53]!==ce||t[54]!==ie||t[55]!==Q||t[56]!==u?(de=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:ce,children:[ie,Q,he,ee]}),t[51]=b,t[52]=ee,t[53]=ce,t[54]=ie,t[55]=Q,t[56]=u,t[57]=de):de=t[57];let ue;t[58]!==R||t[59]!==de?(ue=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:R,children:de},R)}),t[58]=R,t[59]=de,t[60]=ue):ue=t[60];let we;return t[61]!==C||t[62]!==ue?(we=o.jsx(Jt,{value:C,children:ue}),t[61]=C,t[62]=ue,t[63]=we):we=t[63],we}const D=r?void 0:x.createNewTask;let E;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==D?(E=o.jsx(lr.Toggles,{children:o.jsx(Fp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:D})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=D,t[67]=E):E=t[67];let L;t[68]!==x.taskId||t[69]!==u?(L=o.jsx(lr.Tabs,{children:o.jsx(Gp,{virtualMcpId:u,taskId:x.taskId})}),t[68]=x.taskId,t[69]=u,t[70]=L):L=t[70];const z=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(lg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let $;t[75]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx($o,{}),t[75]=$):$=t[75];let W;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==u?(W=o.jsx($p,{virtualMcpId:u,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:$}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=u,t[80]=W):W=t[80];let I;t[81]!==b||t[82]!==z||t[83]!==B||t[84]!==O||t[85]!==W||t[86]!==u?(I=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:z,children:[B,O,W]}),t[81]=b,t[82]=z,t[83]=B,t[84]=O,t[85]=W,t[86]=u,t[87]=I):I=t[87];let F;t[88]!==R||t[89]!==L||t[90]!==I?(F=o.jsxs(je.Provider,{virtualMcpId:R,children:[L,I]},R),t[88]=R,t[89]=L,t[90]=I,t[91]=F):F=t[91];let U;return t[92]!==C||t[93]!==E||t[94]!==F?(U=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Jt,{value:C,children:[E,F]})}),t[92]=C,t[93]=E,t[94]=F,t[95]=U):U=t[95],U}function g1(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(A.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(dg,{})}),t[0]=e):e=t[0],e}export{g1 as default,pn as useInsetContext};
189
+ </message>`}]}}))},B=e.models?.credentialId||_||"",O=e.models?.thinking?.id||f?.modelId||"",$=Vo({defaultValues:{name:e.name,active:e.active,credential_id:B,model_id:O}}),W=$.watch("active"),I=$.watch("credential_id"),F=$.watch("model_id"),{models:U,isLoading:K}=jc(I||void 0),G=U.find(ne=>ne.modelId===F)??null,P=A.useRef(null),Z=A.useRef(new Set),Y=A.useRef(0),ee=A.useRef(null),ce=3e4,ie=()=>{ee.current&&(clearTimeout(ee.current),ee.current=null),P.current!==null&&(Se("automation_updated",{automation_id:t,agent_id:n,fields:Array.from(Z.current),save_count:Y.current,edit_duration_ms:Date.now()-P.current}),P.current=null,Z.current=new Set,Y.current=0)},Q=async()=>{if(!(Object.keys($.formState.dirtyFields).length>0)&&!E.current)return!0;const ve=Object.keys($.formState.dirtyFields),tt=E.current;E.current=!1;const _e=$.getValues(),Vt=L.current;try{const gs=_e.credential_id&&_e.model_id?_e.credential_id:"",X=_e.credential_id&&_e.model_id?_e.model_id:"",oe={id:t,name:_e.name,active:_e.active,agent:{id:n},models:{credentialId:gs,thinking:{id:X}},messages:Kl(Vt),temperature:0};await l.mutateAsync(oe),P.current===null&&(P.current=Date.now());for(const Be of ve)Z.current.add(Be);return tt&&Z.current.add("messages"),Y.current+=1,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(ie,ce),$.reset({..._e,credential_id:gs,model_id:X},{keepDirtyValues:!0}),!0}catch{return E.current=!0,!1}},he=A.useRef(Q);he.current=Q;const de=()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=null,he.current()},1e3)},ue=async()=>(R.current&&(clearTimeout(R.current),R.current=null),he.current()),we=ne=>{if(L.current=ne,x(ne),!C.current){C.current=!0;return}E.current=!0,de()},Xe=A.useRef(!1);Xe.current||(Xe.current=!0,$.watch(()=>{de()})),A.useEffect(()=>()=>{R.current&&(clearTimeout(R.current),R.current=null,he.current())},[]);const He=async()=>{Se("automation_test_clicked",{automation_id:t,agent_id:n});const ne=await ue();if(ie(),!ne)return;if(!S){me.error("No instructions configured for this automation");return}G&&I&&m({...G,keyId:I}),v({...g,toolApprovalLevel:"auto"});const ve=xn(S);u({message:{tiptapDoc:S,parts:ve},virtualMcpId:n||void 0})};return o.jsxs(o.Fragment,{children:[i&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(se,{variant:"ghost",size:"sm",onClick:i,children:[o.jsx(ka,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(fs,{...$.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),r&&o.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:o.jsx(hr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Xt,{control:$.control,name:"active",render:({field:ne})=>o.jsx(cr,{checked:ne.value,onCheckedChange:ve=>{ne.onChange(ve),setTimeout(()=>ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ca,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Np,{automationId:t,open:w,onOpenChange:N,onCustomSelect:()=>{k(!0),T(!1),M("")},onEventSelect:()=>{T(!0),k(!1)}})]}),e.triggers.length===0&&!y?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>N(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ne=>o.jsx(jp,{trigger:ne,automationId:t,connectionName:ne.connection_id?d.get(ne.connection_id):void 0},ne.id))}),y&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:j,onChange:ne=>M(ne.target.value),onBlur:async()=>{const ne=j.trim();if(!(!ne||!Bs(ne)))try{await h.mutateAsync({automation_id:t,type:"cron",cron_expression:ne}),Se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),k(!1),M("")}catch{me.error("Failed to add starter")}},onKeyDown:async ne=>{const ve=j.trim();ne.key==="Enter"&&ve&&Bs(ve)&&ne.target.blur(),ne.key==="Escape"&&(k(!1),M(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Bs(j)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),h.isPending&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.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:()=>{k(!1),M("")},children:o.jsx(ls,{size:13})})]}),D&&o.jsx(A.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Tp,{automationId:t,onDone:()=>T(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!S,onClick:z,children:[o.jsx(ya,{size:13}),"Improve"]})]}),o.jsx(Hl,{tiptapDoc:S,setTiptapDoc:we,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Wl,{virtualMcpId:n||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(gh,{model:G,isLoading:K,credentialId:I||null,onCredentialChange:ne=>{$.setValue("credential_id",ne??"",{shouldDirty:!0}),$.setValue("model_id","",{shouldDirty:!0})},onModelChange:ne=>$.setValue("model_id",ne.modelId,{shouldDirty:!0}),placeholder:"Model"}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:He,disabled:!n,children:[o.jsx(Ql,{size:16}),"Test"]})}),o.jsx(qe,{children:"Test Automation"})]})]})]})})]})]})]})}function Bp(t){const e=V.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=Zo(s),e[0]=s,e[1]=r):r=e[1];const n=r;if(!n)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==n.id||e[4]!==i?(l=o.jsx(at,{children:o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsx(A.Suspense,{fallback:a,children:o.jsx(Ap,{id:n.id,virtualMcpId:i})})})})}),e[3]=n.id,e[4]=i,e[5]=l):l=e[5],l}function Ap(t){const e=V.c(9),{id:s,virtualMcpId:i}=t,r=Mt(),{data:n,isLoading:a}=xh(s);let l;e[0]!==r?(l=()=>r({to:".",search:Pp,replace:!0}),e[0]=r,e[1]=l):l=e[1];const h=l;if(a){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=d):d=e[2],d}if(!n){let d;return e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=d):d=e[3],d}let c;return e[4]!==n||e[5]!==s||e[6]!==h||e[7]!==i?(c=o.jsx(Ip,{automationId:s,automation:n,virtualMcpId:i,onBack:h}),e[4]=n,e[5]=s,e[6]=h,e[7]=i,e[8]=c):c=e[8],c}function Pp(t){return{...t,main:"automations"}}function Lp(t){const e=V.c(20),{virtualMcpId:s}=t,i=Mt(),{data:r}=bh(s),n=r===void 0?[]:r,{create:a}=Vs(),[l,h]=A.useState(""),c=l.toLowerCase(),d=n.filter(M=>M.name.toLowerCase().includes(c));let u;e[0]!==i?(u=M=>i({to:".",search:D=>({...D,main:"automation:"+M}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const m=u,_=async()=>{if(a.isPending)return;Se("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const M=await a.mutateAsync(yh(s));m(M.id)},f=at,p=at,g=at;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(at.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(wh,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(se,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let w;e[7]!==b||e[8]!==x?(w=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=w):w=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{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:o.jsxs(se,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):d.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(M=>o.jsx(Sh,{automation:M,onClick:()=>m(M.id)},M.id))});let y;e[10]!==N||e[11]!==g.Body||e[12]!==w?(y=o.jsxs(g.Body,{children:[w,N]}),e[10]=N,e[11]=g.Body,e[12]=w,e[13]=y):y=e[13];let k;e[14]!==y||e[15]!==p.Content?(k=o.jsx(p.Content,{children:y}),e[14]=y,e[15]=p.Content,e[16]=k):k=e[16];let j;return e[17]!==f||e[18]!==k?(j=o.jsx(f,{children:k}),e[17]=f,e[18]=k,e[19]=j):j=e[19],j}function Op(t){const e=V.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(A.Suspense,{fallback:i,children:o.jsx(Lp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Lo=A.lazy(()=>Pl(()=>import("./project-app-view-DufFnF1s.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])).then(t=>({default:t.AppViewContent})));function zp(t){const e=V.c(44),{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:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Ta(r);if(nc(n)){let f;return e[3]!==i?(f=o.jsx(zn,{virtualMcpId:i}),e[3]=i,e[4]=f):f=e[4],f}if(n==="git"){let f;return e[5]!==i?(f=o.jsx(bu,{virtualMcpId:i}),e[5]=i,e[6]=f):f=e[6],f}if(n==="automations"){let f;return e[7]!==i?(f=o.jsx(Op,{virtualMcpId:i}),e[7]=i,e[8]=f):f=e[8],f}if(n==="env"){let f;return e[9]!==i?(f=o.jsx(bp,{virtualMcpId:i}),e[9]=i,e[10]=f):f=e[10],f}if(n==="preview"){let f;return e[11]!==i?(f=o.jsx(tf,{virtualMcpId:i}),e[11]=i,e[12]=f):f=e[12],f}if(h){let f;return e[13]!==n||e[14]!==i?(f=o.jsx(Bp,{tabId:n,virtualMcpId:i}),e[13]=n,e[14]=i,e[15]=f):f=e[15],f}let c;e[16]!==n?(c=oc(n),e[16]=n,e[17]=c):c=e[17];const d=c;if(d){let f;if(e[18]!==l||e[19]!==d.connectionId||e[20]!==d.toolName){let S;e[22]!==d.connectionId||e[23]!==d.toolName?(S=x=>x.appId===d.connectionId&&x.toolName===d.toolName,e[22]=d.connectionId,e[23]=d.toolName,e[24]=S):S=e[24],f=l.find(S),e[18]=l,e[19]=d.connectionId,e[20]=d.toolName,e[21]=f}else f=e[21];const p=f;let g;e[25]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[25]=g):g=e[25];const v=p?.args;let b;return e[26]!==n||e[27]!==d.connectionId||e[28]!==d.toolName||e[29]!==v?(b=o.jsx(A.Suspense,{fallback:g,children:o.jsx(Lo,{connectionId:d.connectionId,toolName:d.toolName,args:v},n)}),e[26]=n,e[27]=d.connectionId,e[28]=d.toolName,e[29]=v,e[30]=b):b=e[30],b}let u;if(e[31]!==n||e[32]!==a){let f;e[34]!==n?(f=p=>p.id===n,e[34]=n,e[35]=f):f=e[35],u=a.find(f),e[31]=n,e[32]=a,e[33]=u}else u=e[33];const m=u;if(m){let f;e[36]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[36]=f):f=e[36];let p;return e[37]!==n||e[38]!==m.id||e[39]!==m.view.appId||e[40]!==m.view.args?(p=o.jsx(A.Suspense,{fallback:f,children:o.jsx(Lo,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},n)}),e[37]=n,e[38]=m.id,e[39]=m.view.appId,e[40]=m.view.args,e[41]=p):p=e[41],p}let _;return e[42]!==i?(_=o.jsx(zn,{virtualMcpId:i}),e[42]=i,e[43]=_):_=e[43],_}function $p(t){const e=V.c(7),{children:s,defaultSize:i}=t,[,r]=A.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Go.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=qo(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=m=>r(()=>{m>0&&m<100&&l(m)}),e[1]=l,e[2]=c):c=e[2];const d=c;let u;return e[3]!==s||e[4]!==h||e[5]!==d?(u=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:d,order:1,children:s}),e[3]=s,e[4]=h,e[5]=d,e[6]=u):u=e[6],u}function Fp(t){const e=V.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=En(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Go.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=qo(c,45),u=A.useRef(null);let m,_;e[4]!==r||e[5]!==n||e[6]!==d?(m=()=>{const M=u.current;if(!M)return;const D=En(r,n),T=D.chat>0&&D.chat<100?d:D.chat,C=D.chat>0&&D.chat<100?100-d:D.main;M.setLayout([T,C])},_=[r,n,d],e[4]=r,e[5]=n,e[6]=d,e[7]=m,e[8]=_):(m=e[7],_=e[8]),A.useEffect(m,_);const f=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Na,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx($p,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Vc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=te("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[19]=N):N=e[19];let y;e[20]!==i||e[21]!==s?(y=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(zp,{taskId:i,virtualMcpId:s})})})}),e[20]=i,e[21]=s,e[22]=y):y=e[22];let k;e[23]!==h.main||e[24]!==y?(k=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:y}),e[23]=h.main,e[24]=y,e[25]=k):k=e[25];let j;return e[26]!==k||e[27]!==f||e[28]!==b?(j=o.jsxs(Kc,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,k]},f),e[26]=k,e[27]=f,e[28]=b,e[29]=j):j=e[29],j}const nr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Oo="bg-sidebar-accent text-sidebar-foreground",or="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Hp(t){const e=V.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Ec(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Se("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Oo:or;let d;e[3]!==c?(d=te(nr,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(wc,{size:16}),e[5]=u):u=e[5];let m;e[6]!==h||e[7]!==d||e[8]!==n?(m=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=n,e[9]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(qe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let f;e[11]!==m?(f=o.jsxs(Ve,{delayDuration:300,children:[m,_]}),e[11]=m,e[12]=f):f=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Se("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Oo:or;let v;e[16]!==g?(v=te(nr,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Cc,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(qe,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(Ve,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let y;e[26]!==N?(y=te("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=y):y=e[27];const k=!l,j=l?0:-1,M=!l,D=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==D?(T=te(nr,or,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",D),e[28]=D,e[29]=T):T=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(ta,{size:16}),e[30]=C):C=e[30];let R;e[31]!==r||e[32]!==k||e[33]!==j||e[34]!==M||e[35]!==T?(R=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:k,tabIndex:j,"aria-hidden":M,className:T,children:C})}),e[31]=r,e[32]=k,e[33]=j,e[34]=M,e[35]=T,e[36]=R):R=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(qe,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let L;e[38]!==R?(L=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ve,{delayDuration:300,children:[R,E]})}),e[38]=R,e[39]=L):L=e[39];let z;e[40]!==y||e[41]!==L?(z=o.jsx("div",{className:y,children:L}),e[40]=y,e[41]=L,e[42]=z):z=e[42];let B;return e[43]!==w||e[44]!==z||e[45]!==f?(B=o.jsxs(o.Fragment,{children:[f,w,z]}),e[43]=w,e[44]=z,e[45]=f,e[46]=B):B=e[46],B}function Wp(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],h=r[a],c=[...i.slice(0,-1),h],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function Up(t){const e=V.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=te("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Vp,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function Vp(t){const e=V.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function Kp(t){const e=V.c(13),{overflow:s,onSelect:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i?(a=m=>{n(!1),i(m)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Hs,{asChild:!0,children:o.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:o.jsx(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let m;e[6]!==l?(m=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(qp,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=m):m=e[7],c=s.map(m),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=o.jsx(Ws,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=o.jsxs(Us,{open:r,onOpenChange:n,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function qp(t){const e=V.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const Gp=6;function Yp(t){const e=V.c(20),{virtualMcpId:s,taskId:i}=t,r=Mt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Ta(n);let d,u,m,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=ac({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:w}=Wp(a,S,Gp);u=w,d=N=>{const y=a.find(j=>j.id===N),k=S===N&&h;if(Se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:y?.kind??null,was_active:k}),N==="automations"){const j=lc({activeTab:l,mainOpen:h});r({to:".",search:M=>({...M,main:j}),replace:!0});return}c(N)},m="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(Up,{title:N.title,icon:N.icon,active:v(N),onClick:()=>d(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=m,e[12]=_}else d=e[9],u=e[10],m=e[11],_=e[12];let f;e[13]!==d||e[14]!==u?(f=u.length>0&&o.jsx(Kp,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=f):f=e[15];let p;return e[16]!==m||e[17]!==_||e[18]!==f?(p=o.jsxs("div",{className:m,children:[_,f]}),e[16]=m,e[17]=_,e[18]=f,e[19]=p):p=e[19],p}function Xp(t){const e=V.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=te("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Ll,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function Jp(t){const e=V.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(cu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(lu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(se,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(dr,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=o.jsx(ns,{asChild:!0,children:o.jsx(se,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:d})}),e[10]=i,e[11]=u):u=e[11];let m;e[12]!==h?(m=o.jsx(os,{align:"end",children:o.jsx(yt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=m):m=e[13];let _;e[14]!==u||e[15]!==m?(_=o.jsxs(rs,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=_):_=e[16];let f;return e[17]!==c||e[18]!==_?(f=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=f):f=e[19],f}const Zp=new Set(["failure","timed_out","cancelled","action_required"]);function Qp(t){return t.status==="completed"&&Zp.has(t.conclusion)}function eg(t){return t.status==="queued"||t.status==="in_progress"}function tg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.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 #${s.number} merged into ${s.base}`};if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${e.branch} → ${e.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const h=i.filter(Qp).map(u=>u.name);if(h.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${h.join(", ")}`,meta:{failingChecks:h}};const c=i.filter(eg);if(c.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${c.length} check${c.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${e.base}`}}function sg(){return ms().branchStatus}const ig=6e4,rg=3e4;function ng(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:ig,refetchIntervalInBackground:!1,staleTime:rg,select:og},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function og(t){const e=Ks(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function ag(t){const e=V.c(39),{virtualMcpId:s}=t,{org:i}=ye(),r=gt(s),{currentBranch:n}=lt(),a=wi(),l=r?.metadata?.githubRepo??null,h=sg(),c=l?.connectionId??"",d=l?.owner??"",u=l?.name??"",m=n??null;let _;e[0]!==i.id||e[1]!==c||e[2]!==d||e[3]!==u||e[4]!==m?(_={orgId:i.id,connectionId:c,owner:d,repo:u,branch:m},e[0]=i.id,e[1]=c,e[2]=d,e[3]=u,e[4]=m,e[5]=_):_=e[5];const f=Da(_),p=f.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[6]!==i.id||e[7]!==g||e[8]!==v||e[9]!==b||e[10]!==S?(x={orgId:i.id,connectionId:g,owner:v,repo:b,prNumber:S},e[6]=i.id,e[7]=g,e[8]=v,e[9]=b,e[10]=S,e[11]=x):x=e[11];const w=Ia(x),N=l?.connectionId??"",y=l?.owner??"",k=l?.name??"",j=p&&p.state==="open"?p.number:null;let M;e[12]!==i.id||e[13]!==N||e[14]!==y||e[15]!==k||e[16]!==j?(M={orgId:i.id,connectionId:N,owner:y,repo:k,prNumber:j},e[12]=i.id,e[13]=N,e[14]=y,e[15]=k,e[16]=j,e[17]=M):M=e[17];const D=ng(M);if(!l?.connectionId||!n)return null;let T;e[18]!==h||e[19]!==w.data||e[20]!==p||e[21]!==f.isPending||e[22]!==D.data?(T=tg({branchStatus:h,pr:p,checks:w.data??[],reviews:D.data??null,loading:f.isPending}),e[18]=h,e[19]=w.data,e[20]=p,e[21]=f.isPending,e[22]=D.data,e[23]=T):T=e[23];const C=T;let R;e[24]!==a?(R=I=>a.sendMessage({parts:[{type:"text",text:I}]}),e[24]=a,e[25]=R):R=e[25];const E=R,L=a.isStreaming;let z;e[26]!==n||e[27]!==C||e[28]!==L||e[29]!==p||e[30]!==E?(z=I=>{if(!L)switch(I){case"commit-and-push":{E(eu({branch:n}));return}case"create-pr":{E(tu({branch:n}));return}case"reopen":{p&&E(su({prNumber:p.number}));return}case"rebase":{E(iu({branch:n}));return}case"fix-checks":{p&&E(nu({prNumber:p.number,failingChecks:C.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(ou({prNumber:p.number}));return}case"resolve-comments":{p&&E(au({prNumber:p.number}));return}case"merge-split":return}},e[26]=n,e[27]=C,e[28]=L,e[29]=p,e[30]=E,e[31]=z):z=e[31];const B=z;let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(Xp,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[32]=O):O=e[32];const $=p?.number;let W;return e[33]!==C||e[34]!==L||e[35]!==B||e[36]!==E||e[37]!==$?(W=o.jsxs(o.Fragment,{children:[O,o.jsx(lg,{button:C,isStreaming:L,onActivate:B,prNumber:$,send:E})]}),e[33]=C,e[34]=L,e[35]=B,e[36]=E,e[37]=$,e[38]=W):W=e[38],W}function lg(t){const e=V.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let d;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(d=o.jsx(Jp,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=d):d=e[3];let u;return e[4]!==d||e[5]!==n?(u=o.jsx(zo,{label:n,children:d}),e[4]=d,e[5]=n,e[6]=u):u=e[6],u}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(dh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(se,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(zo,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function zo(t){const e=V.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ke,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(qe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(zc,{children:o.jsxs(Ve,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function cg(t){const e=V.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(lr.Right,{children:o.jsx(ag,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Jt=A.createContext(null);function pn(){return A.use(Jt)}function $o(t){const e=V.c(7),{children:s}=t,{taskId:i}=lt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.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]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Na,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Qt,{fallback:r,children:o.jsx(A.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Fo(t){const e=V.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],A.useLayoutEffect(r),null}function hg(t){const e=V.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Gl,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Ho(t){const e=V.c(15),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ye(),{currentBranch:l}=lt(),{data:h}=Si.useSession(),c=h?.user?.id;let d;e[0]!==a.id?(d={connectionId:It,orgId:a.id},e[0]=a.id,e[1]=d):d=e[1];const u=Fe(d),{mutate:m}=sn(u);let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[2]=_):_=e[2];const f=A.useRef(_);let p,g;e[3]!==l||e[4]!==i||e[5]!==m||e[6]!==c||e[7]!==s||e[8]!==r?(p=()=>{i&&c&&l&&(r?.[c]?.[l]||f.current.has(l)||(f.current.add(l),m({virtualMcpId:s,branch:l},{onError:dg})))},g=[i,c,l,r,s,m],e[3]=l,e[4]=i,e[5]=m,e[6]=c,e[7]=s,e[8]=r,e[9]=p,e[10]=g):(p=e[9],g=e[10]),A.useEffect(p,g);const v=l??null;let b;return e[11]!==n||e[12]!==v||e[13]!==s?(b=o.jsx(Au,{virtualMcpId:s,branch:v,children:n}),e[11]=n,e[12]=v,e[13]=s,e[14]=b):b=e[14],b}function dg(t){console.error("[auto-start-vm] failed:",t)}function ug(){const t=V.c(96),e=aa(),s=Mt(),{org:i}=ye(),r=Tc()?.tasksOpen??!1;$c(i.id);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Ol(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Yr(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??Yo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,m=Nh(a.taskId??"",u),_=gt(u),f=_?.metadata?.ui?.layout??null;let p;t[5]!==f?(p=f?{defaultMainView:f.defaultMainView??null,chatDefaultOpen:f.chatDefaultOpen??null}:null,t[5]=f,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Bt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==u?(S={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=S):S=t[11];const x=Rc(g,S),{setOpenMobile:w,openMobile:N}=Ac(),y=w,k=A.useRef(null);let j,M;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const K=G=>{Ic(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),k.current?.())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},M=[],t[12]=j,t[13]=M):(j=t[12],M=t[13]),A.useEffect(j,M);const D=u;let T;t[14]!==_||t[15]!==u?(T={virtualMcpId:u,entity:_},t[14]=_,t[15]=u,t[16]=T):T=t[16];const C=T;if(m.status==="creating"||m.status==="loading"){let K;t[17]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=K):K=t[17];let G;return t[18]!==C?(G=o.jsx(Jt,{value:C,children:K}),t[18]=C,t[19]=G):G=t[19],G}if(m.status==="error"){let K;t[20]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=K):K=t[20];let G;t[21]!==m.error.message?(G=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[K,o.jsx("div",{className:"text-muted-foreground",children:m.error.message})]})}),t[21]=m.error.message,t[22]=G):G=t[22];let P;return t[23]!==C||t[24]!==G?(P=o.jsx(Jt,{value:C,children:G}),t[23]=C,t[24]=G,t[25]=P):P=t[25],P}if(!_){let K;t[26]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(as,{size:48,className:"text-muted-foreground"}),t[26]=K):K=t[26];const G=`The agent "${u}" does not exist in this organization.`;let P;t[27]!==s||t[28]!==l?(P=o.jsx(se,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=P):P=t[29];let Z;t[30]!==G||t[31]!==P?(Z=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Ps,{image:K,title:"Agent not found",description:G,actions:P})})}),t[30]=G,t[31]=P,t[32]=Z):Z=t[32];let Y;return t[33]!==C||t[34]!==Z?(Y=o.jsx(Jt,{value:C,children:Z}),t[33]=C,t[34]=Z,t[35]=Y):Y=t[35],Y}if(e){let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(Pc,{className:"sr-only",children:"Navigation"}),t[36]=K):K=t[36];let G;t[37]!==y?(G=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Dc,{onClose:()=>y(!1)})}),t[37]=y,t[38]=G):G=t[38];let P;t[39]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Mc,{})}),t[39]=P):P=t[39];let Z;t[40]!==G?(Z=o.jsxs(Lc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[K,o.jsxs("div",{className:"flex h-full",children:[G,P]})]}),t[40]=G,t[41]=Z):Z=t[41];let Y;t[42]!==N||t[43]!==y||t[44]!==Z?(Y=o.jsx(Oc,{open:N,onOpenChange:y,children:Z}),t[42]=N,t[43]=y,t[44]=Z,t[45]=Y):Y=t[45];const ee=Y,ce=_?.metadata?.vmMap;let ie;t[46]!==x.createNewTask?(ie=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ie):ie=t[47];let Q;t[48]!==y?(Q=o.jsx(hg,{onOpenSidebar:()=>y(!0)}),t[48]=y,t[49]=Q):Q=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx($o,{})}),t[50]=he):he=t[50];let de;t[51]!==b||t[52]!==ee||t[53]!==ce||t[54]!==ie||t[55]!==Q||t[56]!==u?(de=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:ce,children:[ie,Q,he,ee]}),t[51]=b,t[52]=ee,t[53]=ce,t[54]=ie,t[55]=Q,t[56]=u,t[57]=de):de=t[57];let ue;t[58]!==D||t[59]!==de?(ue=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:D,children:de},D)}),t[58]=D,t[59]=de,t[60]=ue):ue=t[60];let we;return t[61]!==C||t[62]!==ue?(we=o.jsx(Jt,{value:C,children:ue}),t[61]=C,t[62]=ue,t[63]=we):we=t[63],we}const R=r?void 0:x.createNewTask;let E;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==R?(E=o.jsx(lr.Toggles,{children:o.jsx(Hp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:R})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=R,t[67]=E):E=t[67];let L;t[68]!==x.taskId||t[69]!==u?(L=o.jsx(lr.Tabs,{children:o.jsx(Yp,{virtualMcpId:u,taskId:x.taskId})}),t[68]=x.taskId,t[69]=u,t[70]=L):L=t[70];const z=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(cg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let $;t[75]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx($o,{}),t[75]=$):$=t[75];let W;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==u?(W=o.jsx(Fp,{virtualMcpId:u,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:$}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=u,t[80]=W):W=t[80];let I;t[81]!==b||t[82]!==z||t[83]!==B||t[84]!==O||t[85]!==W||t[86]!==u?(I=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:z,children:[B,O,W]}),t[81]=b,t[82]=z,t[83]=B,t[84]=O,t[85]=W,t[86]=u,t[87]=I):I=t[87];let F;t[88]!==D||t[89]!==L||t[90]!==I?(F=o.jsxs(je.Provider,{virtualMcpId:D,children:[L,I]},D),t[88]=D,t[89]=L,t[90]=I,t[91]=F):F=t[91];let U;return t[92]!==C||t[93]!==E||t[94]!==F?(U=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Jt,{value:C,children:[E,F]})}),t[92]=C,t[93]=E,t[94]=F,t[95]=U):U=t[95],U}function v1(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(A.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(ug,{})}),t[0]=e):e=t[0],e}export{v1 as default,pn as useInsetContext};