@p4code/cli 0.8.13 → 0.8.15

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 (294) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/{binCli-B9aQxlIK.mjs → binCli-IAUzRF0Y.mjs} +283 -105
  3. package/dist/client/.vite/manifest.json +2143 -2143
  4. package/dist/client/assets/AlertDialogRoot-DYtW2IF3.js +2 -0
  5. package/dist/client/assets/{AnimatedHeight-CH-N3JTc.js → AnimatedHeight-CzFc8xri.js} +2 -2
  6. package/dist/client/assets/{AuthSurfaceShell-CJdXkxyH.js → AuthSurfaceShell-ByOYQAV0.js} +2 -2
  7. package/dist/client/assets/{CSPContext-4VAD2_gc.js → CSPContext-DcW0os5z.js} +2 -2
  8. package/dist/client/assets/{ChatGptUsageButton-7u9uPgbK.js → ChatGptUsageButton-KFBZLDN7.js} +2 -2
  9. package/dist/client/assets/{ChatMarkdown-C22JFyYa.js → ChatMarkdown-BoxySKsC.js} +4 -4
  10. package/dist/client/assets/{CheckboxIndicator-ClY0P0ol.js → CheckboxIndicator-DRAilQdq.js} +2 -2
  11. package/dist/client/assets/{CodexSetupSection.logic-CEAT7YdZ.js → CodexSetupSection.logic-d-rT4H0o.js} +2 -2
  12. package/dist/client/assets/{CollapsiblePanel-Cubscn-a.js → CollapsiblePanel-DMH4QH0_.js} +2 -2
  13. package/dist/client/assets/{ComboboxClear-qTthzuJh.js → ComboboxClear-DV4ygCOL.js} +2 -2
  14. package/dist/client/assets/{CommandBlock-CWt29kmi.js → CommandBlock-_boutMAe.js} +2 -2
  15. package/dist/client/assets/{ComposerPromptEditor-Bt_L4smq.js → ComposerPromptEditor-BTCrYVhm.js} +4 -4
  16. package/dist/client/assets/{CompositeRoot-DUqf78yV.js → CompositeRoot-CsrLt1o5.js} +2 -2
  17. package/dist/client/assets/{ConnectionStatusDot-cdpNRZhA.js → ConnectionStatusDot-uWbIqk3l.js} +2 -2
  18. package/dist/client/assets/{DevicePanel-CZm-f5TC.js → DevicePanel-DwMrOlt0.js} +2 -2
  19. package/dist/client/assets/{DeviceSetup-BdrkGme6.js → DeviceSetup-CbOHLIaV.js} +2 -2
  20. package/dist/client/assets/{DialogTitle-CQU6s1Wy.js → DialogTitle-BgclXafx.js} +2 -2
  21. package/dist/client/assets/{DiffCommentAnnotation-B-XoYYxb.js → DiffCommentAnnotation-Aq3V-yP1.js} +2 -2
  22. package/dist/client/assets/{DiffFileTree-CwTkSU3R.js → DiffFileTree-CKQPTUag.js} +2 -2
  23. package/dist/client/assets/{DiffPanel-BCI9XXpF.js → DiffPanel-BXML30Ty.js} +2 -2
  24. package/dist/client/assets/{DiffWorkerPoolProvider-OPZsOibX.js → DiffWorkerPoolProvider-CibTihO7.js} +2 -2
  25. package/dist/client/assets/{EmbeddedDesign-DwRAPHYl.js → EmbeddedDesign-722JShay.js} +2 -2
  26. package/dist/client/assets/{EnvironmentMachineIcon-DCdlTSYU.js → EnvironmentMachineIcon-Czk_PJpp.js} +2 -2
  27. package/dist/client/assets/{ExpandableText-BtdwzlFy.js → ExpandableText-Ggw0uVXl.js} +2 -2
  28. package/dist/client/assets/{FieldControl-BI2gK4Z0.js → FieldControl-Bw2_eFMa.js} +2 -2
  29. package/dist/client/assets/{FileDiff-BkJG5QAe.js → FileDiff-Cen-Dayi.js} +2 -2
  30. package/dist/client/assets/{FilePreviewPanel-CURtQAD1.js → FilePreviewPanel-BMK5AG_P.js} +2 -2
  31. package/dist/client/assets/{FoldedSettingsSection-B9B8i8Gg.js → FoldedSettingsSection-G9y7luve.js} +2 -2
  32. package/dist/client/assets/{FormContext-Bgwez2tv.js → FormContext-7fCTOXXA.js} +2 -2
  33. package/dist/client/assets/{Icons-B5JVkp3z.js → Icons-CSAp87pJ.js} +2 -2
  34. package/dist/client/assets/Input-Cr3X6dPy.js +2 -0
  35. package/dist/client/assets/{KeybindingsSettings.logic-6lVDnd1N.js → KeybindingsSettings.logic-CsSjvH9c.js} +2 -2
  36. package/dist/client/assets/{NoProjectsHero-CkhVaJk9.js → NoProjectsHero-iGEFavkK.js} +2 -2
  37. package/dist/client/assets/{PanelLayoutControls-CxuV0JO3.js → PanelLayoutControls-C4Gm81F_.js} +4 -4
  38. package/dist/client/assets/{PierreEntryIcon-CPG-jnaN.js → PierreEntryIcon-CnGUKKOC.js} +2 -2
  39. package/dist/client/assets/{PopoverHandle-CBT8hFut.js → PopoverHandle-BkhR-kKK.js} +2 -2
  40. package/dist/client/assets/{PreviewPanel-Doh1peEu.js → PreviewPanel-BZNqorNM.js} +2 -2
  41. package/dist/client/assets/{ProjectDefaultsSettings-DfhAk0_Y.js → ProjectDefaultsSettings-DzMIpb2U.js} +2 -2
  42. package/dist/client/assets/{ProjectFavicon-DUW6Bo66.js → ProjectFavicon-Dk18tk1C.js} +3 -3
  43. package/dist/client/assets/{ProjectIconPickerDialog-C613hnVY.js → ProjectIconPickerDialog-DnmG78V1.js} +2 -2
  44. package/dist/client/assets/{ProjectMonogram-B9iJhcVp.js → ProjectMonogram-CWdfC9NP.js} +2 -2
  45. package/dist/client/assets/{ProviderAuthTerminal-eq346NX_.js → ProviderAuthTerminal-nDUEuuwR.js} +2 -2
  46. package/dist/client/assets/{ProviderModelPicker-DPb-88ui.js → ProviderModelPicker-DhOV_BIX.js} +2 -2
  47. package/dist/client/assets/{ProviderSettingsForm-DTYqzs8W.js → ProviderSettingsForm-Cyw48DUr.js} +2 -2
  48. package/dist/client/assets/{PullRequestCodeTab-BBz0FfLD.js → PullRequestCodeTab-BpjwcQvb.js} +2 -2
  49. package/dist/client/assets/{ReadOnlySourcePreview-CkeeLVAm.js → ReadOnlySourcePreview-DMF3eLls.js} +2 -2
  50. package/dist/client/assets/{RenderErrorBoundary-mfAvIiFU.js → RenderErrorBoundary-DQC7sq87.js} +2 -2
  51. package/dist/client/assets/{ScheduledTasksSettings-BMUE9M9Z.js → ScheduledTasksSettings-CZK46eKO.js} +2 -2
  52. package/dist/client/assets/{ScopedSwitch-BKOdsllO.js → ScopedSwitch-BECzQob0.js} +2 -2
  53. package/dist/client/assets/{ScrollAreaCorner-CoeXGFSL.js → ScrollAreaCorner-DXYr9Xbu.js} +2 -2
  54. package/dist/client/assets/{SecretInput-CROqj1gF.js → SecretInput-WUih9JDs.js} +2 -2
  55. package/dist/client/assets/{SelectScrollUpArrow-SDOpV3nj.js → SelectScrollUpArrow-BIdW5z3c.js} +2 -2
  56. package/dist/client/assets/{SettingsPanels-BHhMJaVc.js → SettingsPanels-B3TcgEEZ.js} +2 -2
  57. package/dist/client/assets/{SettingsPanels.logic-BwmY39Sq.js → SettingsPanels.logic-DpJJdWIn.js} +2 -2
  58. package/dist/client/assets/{SettingsScopeNotice-DAPsshab.js → SettingsScopeNotice-CcgRSc9E.js} +2 -2
  59. package/dist/client/assets/{T3ConnectAccountPages-CDuVbE2z.js → T3ConnectAccountPages-8GTdhVAB.js} +2 -2
  60. package/dist/client/assets/{T3ConnectSidebarSignIn-BSQHp-Xq.js → T3ConnectSidebarSignIn-CY6WtOps.js} +2 -2
  61. package/dist/client/assets/{ThemeEditorPanel-BiuI7Uiy.js → ThemeEditorPanel-i2RAKM6Z.js} +2 -2
  62. package/dist/client/assets/{ThreadTerminalDrawer-B8n6TAqv.js → ThreadTerminalDrawer-D7lW_0Ez.js} +2 -2
  63. package/dist/client/assets/{TooltipViewport-BKD6QABG.js → TooltipViewport-Daddx30c.js} +2 -2
  64. package/dist/client/assets/{Virtualizer-CTnacEby.js → Virtualizer-CTxMd1UV.js} +2 -2
  65. package/dist/client/assets/{WorkspaceBreadcrumb-BmVcurpi.js → WorkspaceBreadcrumb-B3WecLwo.js} +2 -2
  66. package/dist/client/assets/{WorkspacePageContainer-BSjVd7h4.js → WorkspacePageContainer-rn16R8Ps.js} +2 -2
  67. package/dist/client/assets/{WorkspacePageHeader-BLYOcS9Z.js → WorkspacePageHeader-B2wsiKGJ.js} +2 -2
  68. package/dist/client/assets/{_chat-z348gvgF.js → _chat-DCAacYa_.js} +6 -6
  69. package/dist/client/assets/{_chat.index-CBbUzaK7.js → _chat.index-CqT22uaz.js} +2 -2
  70. package/dist/client/assets/{_chat.new-7TTfcDf1.js → _chat.new-CTRPd-7l.js} +2 -2
  71. package/dist/client/assets/{_chat.pull-requests-BE7Q2lUu.js → _chat.pull-requests-DZwiHPhH.js} +2 -2
  72. package/dist/client/assets/{abnfDiagram-VCTEODGH-HaXM7twL.js → abnfDiagram-VCTEODGH-0sYdmV4a.js} +2 -2
  73. package/dist/client/assets/{alert-5swcxUBm.js → alert-CvIEaZOb.js} +2 -2
  74. package/dist/client/assets/architecture-7GRP2DOG-Cre3v_DI.js +1 -0
  75. package/dist/client/assets/{architectureDiagram-5GKGNRK7-BhWXFsXS.js → architectureDiagram-5GKGNRK7-CyILOixS.js} +2 -2
  76. package/dist/client/assets/{assets-DXnV2oRj.js → assets-CqHuBXjp.js} +2 -2
  77. package/dist/client/assets/{blockDiagram-I7D4REHJ-D213N9iF.js → blockDiagram-I7D4REHJ-x-VvNLUl.js} +2 -2
  78. package/dist/client/assets/{browserHistoryStore-DURO3U2L.js → browserHistoryStore-BpqZwrsk.js} +2 -2
  79. package/dist/client/assets/{browserLinkTarget-DcGx3A8F.js → browserLinkTarget-EXHYn6yB.js} +2 -2
  80. package/dist/client/assets/{c4Diagram-7LVT6UL2-58POuQV-.js → c4Diagram-7LVT6UL2-B0k0wHF6.js} +2 -2
  81. package/dist/client/assets/channel-DQC0VAAf.js +2 -0
  82. package/dist/client/assets/{checkbox-1tz9neVf.js → checkbox-EHQPSidC.js} +2 -2
  83. package/dist/client/assets/{chunk-4HAMMTFA-Bcwcw8Wz.js → chunk-4HAMMTFA-Uul0p-TJ.js} +2 -2
  84. package/dist/client/assets/{chunk-75Z2AOVW-BaYdZ0Fq.js → chunk-75Z2AOVW-SUa_8bmt.js} +2 -2
  85. package/dist/client/assets/{chunk-DU6HZSFF-B6TRgw4-.js → chunk-DU6HZSFF-DZ_qPx6g.js} +2 -2
  86. package/dist/client/assets/{chunk-F27PBJKO-B5arSwg6.js → chunk-F27PBJKO-DNArajpV.js} +2 -2
  87. package/dist/client/assets/{chunk-GMAD6QVW-XeNCd3gb.js → chunk-GMAD6QVW-DCcQWsDo.js} +2 -2
  88. package/dist/client/assets/{chunk-GVQU2GXP-CWVbbWh7.js → chunk-GVQU2GXP-CUeM0ruH.js} +2 -2
  89. package/dist/client/assets/{chunk-IMKFNOWR-Cb-yxIAE.js → chunk-IMKFNOWR-Dz48fQ1q.js} +2 -2
  90. package/dist/client/assets/{chunk-L3NEJ4N5-Di7nZhzu.js → chunk-L3NEJ4N5-Css7u6Lh.js} +2 -2
  91. package/dist/client/assets/{chunk-OSK3NFVY-DcqBXKUK.js → chunk-OSK3NFVY-CDaAT2I-.js} +2 -2
  92. package/dist/client/assets/{chunk-P2QGCYS3-DJ1kMiTY.js → chunk-P2QGCYS3-CrKr6f8Y.js} +2 -2
  93. package/dist/client/assets/{chunk-POPQ4Y6H-Ba9RYr-b.js → chunk-POPQ4Y6H-BqMK6oaX.js} +2 -2
  94. package/dist/client/assets/{chunk-PWAF6VOD-D4Ch07S8.js → chunk-PWAF6VOD-CyuqbEJS.js} +2 -2
  95. package/dist/client/assets/{chunk-SHT3W25Y-BafMUZgc.js → chunk-SHT3W25Y-BrH-w9EI.js} +2 -2
  96. package/dist/client/assets/{chunk-SVP7TREG-CsEVe0s3.js → chunk-SVP7TREG-DC8LP4Dl.js} +2 -2
  97. package/dist/client/assets/{chunk-TICWLB2K-D3tgdZlp.js → chunk-TICWLB2K-D9Rk3v5O.js} +2 -2
  98. package/dist/client/assets/classDiagram-ZZMXUADV-BnsjDrR7.js +2 -0
  99. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BnsjDrR7.js +2 -0
  100. package/dist/client/assets/{color-picker-N6f_Hu7P.js → color-picker-Dd1K-QRk.js} +2 -2
  101. package/dist/client/assets/{combobox-B07cVaQY.js → combobox-BqpUmoio.js} +2 -2
  102. package/dist/client/assets/{command-B70eQIps.js → command-D1peviZr.js} +2 -2
  103. package/dist/client/assets/{connect-Vt7wlrih.js → connect-_R8iiudK.js} +2 -2
  104. package/dist/client/assets/{connect-agent-CX70rAkF.js → connect-agent-hovmaVDF.js} +2 -2
  105. package/dist/client/assets/{cynefin-OW5HDTMX-CU8HnD4F.js → cynefin-OW5HDTMX-EgbU-rQt.js} +1 -1
  106. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Cvc6_oYZ.js → cynefinDiagram-5FMLGOSQ-D1_um-xk.js} +2 -2
  107. package/dist/client/assets/{dagre-GXQ25YYZ-Bx5buWLS.js → dagre-GXQ25YYZ-BUeriIID.js} +2 -2
  108. package/dist/client/assets/{device-BgvBRE7C.js → device-DIh4Fmq_.js} +2 -2
  109. package/dist/client/assets/{diagram-S7CK7UJ4-CPZrAy0P.js → diagram-S7CK7UJ4-Du3htb_X.js} +2 -2
  110. package/dist/client/assets/{diagram-UQ7AKVKN-kBtSnHpL.js → diagram-UQ7AKVKN-B02FTV2h.js} +2 -2
  111. package/dist/client/assets/{diagram-VSXAHHWV-DQP2q1tS.js → diagram-VSXAHHWV-C-GXxjgO.js} +2 -2
  112. package/dist/client/assets/{diagram-VX7I27RA-DRUN0yEk.js → diagram-VX7I27RA-C9x6jBO2.js} +2 -2
  113. package/dist/client/assets/{diagram-Z3DM3KII-D4WMsQZZ.js → diagram-Z3DM3KII-BOzwpZ6f.js} +2 -2
  114. package/dist/client/assets/{dialog-DmneyTGi.js → dialog-BfenC7sz.js} +2 -2
  115. package/dist/client/assets/{diffRendering-iR2meoVj.js → diffRendering-EPxtkQvT.js} +2 -2
  116. package/dist/client/assets/{discovery-list-ZGkddsst.js → discovery-list-NHMaJPrr.js} +2 -2
  117. package/dist/client/assets/{dist-vr51zfzA.js → dist-BgOJfdC2.js} +3 -3
  118. package/dist/client/assets/{draft-input-DHZ1J7B_.js → draft-input-rVkOduh_.js} +2 -2
  119. package/dist/client/assets/{duoViewer-DTVry3xd.js → duoViewer-CbfTiSKj.js} +2 -2
  120. package/dist/client/assets/{dynamic-CuoX2JEO.js → dynamic-7n-O1eEM.js} +2 -2
  121. package/dist/client/assets/{ebnfDiagram-PWID7BFC-BNUtunQw.js → ebnfDiagram-PWID7BFC-B-aK7ztf.js} +2 -2
  122. package/dist/client/assets/{embeddedScripts-BMvBWRz_.js → embeddedScripts-D-v7UxHT.js} +2 -2
  123. package/dist/client/assets/{empty-hFNkAHps.js → empty-xf3NEL4p.js} +2 -2
  124. package/dist/client/assets/{entities-7B8nzlQw.js → entities-CyQRuOur.js} +2 -2
  125. package/dist/client/assets/{environments-DYIXXf7q.js → environments-CjU9SGCA.js} +2 -2
  126. package/dist/client/assets/{erDiagram-RLTQ6QDP-DHjjowZq.js → erDiagram-RLTQ6QDP-BUkP1ax_.js} +2 -2
  127. package/dist/client/assets/eventmodeling-NTZA5JFV-an9DCCTW.js +1 -0
  128. package/dist/client/assets/{fileLinks-BYi-XNUG.js → fileLinks-sFAkJkUp.js} +2 -2
  129. package/dist/client/assets/{fileTreeExpansion-DIOxQqDo.js → fileTreeExpansion-BoG00fm4.js} +2 -2
  130. package/dist/client/assets/flowDiagram-HODETNUW-pchK5tHw.js +1 -0
  131. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DEPOqoj0.js → ganttDiagram-EL5Y4UJY-C9-_e4R8.js} +2 -2
  132. package/dist/client/assets/{getDiffFileInput-DMj15wpy.js → getDiffFileInput-Eacwf1x6.js} +2 -2
  133. package/dist/client/assets/{gitGraph-4MIJSDKK-BGKW_zhb.js → gitGraph-4MIJSDKK-DpJxnpww.js} +1 -1
  134. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-7UhsI5zi.js → gitGraphDiagram-WWUBYQGX-D1kbQfjj.js} +2 -2
  135. package/dist/client/assets/{guideRunStore-BEkwZ9H7.js → guideRunStore-pssxpidL.js} +2 -2
  136. package/dist/client/assets/{htmlRender-BxVc1PlI.js → htmlRender-CDbYs9Mi.js} +2 -2
  137. package/dist/client/assets/{index-C_MVyH59.js → index-BcfzEf8A.js} +3 -3
  138. package/dist/client/assets/{info-A6RAGUB7-jvyzx_4e.js → info-A6RAGUB7-NwzA9LEB.js} +1 -1
  139. package/dist/client/assets/{infoDiagram-27XIBGKW-lTTpu3as.js → infoDiagram-27XIBGKW--zzuhsyp.js} +2 -2
  140. package/dist/client/assets/{input-RqvQJ9gh.js → input-CF-egQtG.js} +2 -2
  141. package/dist/client/assets/{input-group-BFtrsedw.js → input-group-CifPZlNg.js} +2 -2
  142. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-DlrQNGG9.js → ishikawaDiagram-5VMMS53U-BtNAzuJP.js} +2 -2
  143. package/dist/client/assets/{journeyDiagram-3NMN7TZE-Buy9e-fU.js → journeyDiagram-3NMN7TZE-CkOdxsrK.js} +2 -2
  144. package/dist/client/assets/{kanban-definition-UXKFOSKX-1KgAXH0g.js → kanban-definition-UXKFOSKX-L-Zve5xm.js} +2 -2
  145. package/dist/client/assets/{kbd-BnsXAHsc.js → kbd-DN9MXWor.js} +2 -2
  146. package/dist/client/assets/{keybindings-BtHOXkP-.js → keybindings-BlEA4Dlt.js} +2 -2
  147. package/dist/client/assets/{lazyRouteComponent-T0YE6Rn9.js → lazyRouteComponent-b9hpLjZB.js} +2 -2
  148. package/dist/client/assets/{line-DUV1hs6X.js → line-CUIFqVat.js} +2 -2
  149. package/dist/client/assets/{link-gKYnbTYT.js → link-BIudTto8.js} +2 -2
  150. package/dist/client/assets/{linkedPrompt-Da8rJho3.js → linkedPrompt-DQkjE7kc.js} +2 -2
  151. package/dist/client/assets/{main-Bh6Hj0_-.js → main-C58_iQqs.js} +7 -7
  152. package/dist/client/assets/{mediaReference-CLlAiRVc.js → mediaReference-D5Qxnp2d.js} +2 -2
  153. package/dist/client/assets/{mediaSource-BTCWn94E.js → mediaSource-DRXKCFCg.js} +2 -2
  154. package/dist/client/assets/{mermaid-parser.core-CsBuWV4-.js → mermaid-parser.core-Dy9NqIcU.js} +4 -4
  155. package/dist/client/assets/{mermaid.core-BcICv5EB.js → mermaid.core-C1Tbkxei.js} +5 -5
  156. package/dist/client/assets/{mindmap-definition-YA3MSWOX-BqCqe4io.js → mindmap-definition-YA3MSWOX-CNHVmlJ4.js} +2 -2
  157. package/dist/client/assets/{number-field-DIYUxout.js → number-field-CydqGM9B.js} +2 -2
  158. package/dist/client/assets/{observeResize-D9ECzP-D.js → observeResize-BxVCxCXG.js} +2 -2
  159. package/dist/client/assets/{onboarding-COQ6KgRG.js → onboarding-DQxSrthd.js} +2 -2
  160. package/dist/client/assets/{openFileInPreview-BhRAqg63.js → openFileInPreview-tPdJXpV4.js} +2 -2
  161. package/dist/client/assets/{p4ProjectFile-z5Hlq99W.js → p4ProjectFile-Dqppy-Sd.js} +2 -2
  162. package/dist/client/assets/{packet-AYTQ26CC-BYCaPqFA.js → packet-AYTQ26CC-D66WQAPv.js} +1 -1
  163. package/dist/client/assets/{pair-BDKjGij-.js → pair-BgezPXaC.js} +2 -2
  164. package/dist/client/assets/{pegDiagram-XKGWAZYB-CqCw5Z-L.js → pegDiagram-XKGWAZYB-D4RZHNwH.js} +2 -2
  165. package/dist/client/assets/{phoneViewer-DLSM0QXE.js → phoneViewer-DKIr7vIR.js} +2 -2
  166. package/dist/client/assets/{pie-WAS4IAKB-BfOlqQx1.js → pie-WAS4IAKB-ChXk3493.js} +1 -1
  167. package/dist/client/assets/{pieDiagram-E7YTZNPT-DZpCrUQF.js → pieDiagram-E7YTZNPT-BYlPIaAz.js} +2 -2
  168. package/dist/client/assets/{pierre-icons-BG7vd34x.js → pierre-icons-ByQ4P7uM.js} +2 -2
  169. package/dist/client/assets/{popover-DE9WCm99.js → popover-BunL7s_L.js} +2 -2
  170. package/dist/client/assets/{preview-Cl-7ojv-.js → preview-B_wcdd8X.js} +2 -2
  171. package/dist/client/assets/{preview-bd-MGMMz.js → preview-DDUAtKQn.js} +2 -2
  172. package/dist/client/assets/{previewMiniPlayerStore-Bz1T9oVV.js → previewMiniPlayerStore-gZV-IkW-.js} +2 -2
  173. package/dist/client/assets/{primary-BwHoAoya.js → primary-BI3yNRjI.js} +2 -2
  174. package/dist/client/assets/{primaryCloudLinkState-DtOYGRkF.js → primaryCloudLinkState-Dn_lMN_C.js} +2 -2
  175. package/dist/client/assets/{projectFilesQueryState-BP_JvI7-.js → projectFilesQueryState-DfToGDLi.js} +2 -2
  176. package/dist/client/assets/{projectScriptEditor-BGLshibY.js → projectScriptEditor-De4HeOtY.js} +2 -2
  177. package/dist/client/assets/{providerSkills-DxYtwoxJ.js → providerSkills-DrIXn_7R.js} +2 -2
  178. package/dist/client/assets/{pullRequestDetail.logic-C_aVDAY_.js → pullRequestDetail.logic-CGUKFcHo.js} +2 -2
  179. package/dist/client/assets/{pullRequestIcons-D5Yo5Zsn.js → pullRequestIcons-BZCS4C5B.js} +2 -2
  180. package/dist/client/assets/{pullRequestReviewStore-DaEzt1m1.js → pullRequestReviewStore-BqvYYzmT.js} +2 -2
  181. package/dist/client/assets/{pullRequests-D0no1PZS.js → pullRequests-tIwkUcK2.js} +2 -2
  182. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BTtuOXlL.js → quadrantDiagram-AXDQQJYC-kMIaUDbV.js} +2 -2
  183. package/dist/client/assets/{queries-DkmaXOL-.js → queries-DMjiMwzO.js} +2 -2
  184. package/dist/client/assets/{query-Bd5_Y_Vy.js → query-CRswjQ7f.js} +2 -2
  185. package/dist/client/assets/{radar-RG4KPBEZ-BiJgnIUY.js → radar-RG4KPBEZ-_vEYfKqV.js} +1 -1
  186. package/dist/client/assets/{radio-group-CBunNtTU.js → radio-group-DzD2uI5x.js} +2 -2
  187. package/dist/client/assets/{railroad-74A4TZTK-C0CA0mcr.js → railroad-74A4TZTK-BiD9GwPs.js} +1 -1
  188. package/dist/client/assets/railroad-abnf-HS5TGJTU-Dx3SBIg8.js +1 -0
  189. package/dist/client/assets/railroad-ebnf-LZEXJU2U-DqrIX1EX.js +1 -0
  190. package/dist/client/assets/railroad-peg-WCYAUIDC-zKUem5fh.js +1 -0
  191. package/dist/client/assets/{railroadDiagram-O6MQD6OU-WczOSoF4.js → railroadDiagram-O6MQD6OU-VThEbY2-.js} +2 -2
  192. package/dist/client/assets/{renderScheduler-BLjFSKnt.js → renderScheduler-ZbiToRGe.js} +2 -2
  193. package/dist/client/assets/{requirementDiagram-BXWQKSXE-B3qCIQP5.js → requirementDiagram-BXWQKSXE-CYlc8xoq.js} +2 -2
  194. package/dist/client/assets/{rightPanelStore-6-YhsfkE.js → rightPanelStore-CcmIdfDA.js} +2 -2
  195. package/dist/client/assets/{runtime-Bni_zt6P.js → runtime-BjJBBHTp.js} +2 -2
  196. package/dist/client/assets/{runtime-D8mKjOP-.js → runtime-D102A-Bu.js} +3 -3
  197. package/dist/client/assets/{runtimeModeConfig-C3q8YqVA.js → runtimeModeConfig-CGosfJJ5.js} +2 -2
  198. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-e2-j7ERe.js → sankeyDiagram-P5KCCOFB-CHYSv9pX.js} +2 -2
  199. package/dist/client/assets/{scheduledTasksSettings.logic-BNC897-_.js → scheduledTasksSettings.logic-DhrwaClP.js} +2 -2
  200. package/dist/client/assets/{scroll-area-Davaj52_.js → scroll-area-OkcD8f0Y.js} +2 -2
  201. package/dist/client/assets/{select-B47XfaxQ.js → select-BUFUt6O3.js} +2 -2
  202. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DG7-8UJk.js → sequenceDiagram-WJ2MYXX4-D1y7ChUn.js} +2 -2
  203. package/dist/client/assets/{server-CaLEm3Wt.js → server-DTGT8WWf.js} +2 -2
  204. package/dist/client/assets/{session-2CRBJwS7.js → session-Dh8maTO3.js} +2 -2
  205. package/dist/client/assets/session-logic-CJeISKsG.js +26 -0
  206. package/dist/client/assets/{settings-BIwaDm1N.js → settings-CrZbdtKO.js} +2 -2
  207. package/dist/client/assets/{settings.appearance-ToUM8fHh.js → settings.appearance-BNB57wVJ.js} +2 -2
  208. package/dist/client/assets/settings.archived-C3Vs8tIa.js +2 -0
  209. package/dist/client/assets/{settings.computer-use-BEghs16L.js → settings.computer-use-CNLnfXe7.js} +2 -2
  210. package/dist/client/assets/{settings.connections-C_LVk0gJ.js → settings.connections-CKn7dmOC.js} +2 -2
  211. package/dist/client/assets/{settings.data-controls-BaTil8NB.js → settings.data-controls-B8uFJ36x.js} +2 -2
  212. package/dist/client/assets/{settings.decisions-JTbMt08J.js → settings.decisions-Cy46-IzS.js} +2 -2
  213. package/dist/client/assets/{settings.diagnostics-ByG62ZGs.js → settings.diagnostics-BeATxGLt.js} +2 -2
  214. package/dist/client/assets/{settings.general-BT78z_Cn.js → settings.general-BAL2BKm_.js} +2 -2
  215. package/dist/client/assets/{settings.integrations-C3jj2T1d.js → settings.integrations-Bg8Ve2zj.js} +2 -2
  216. package/dist/client/assets/{settings.keybindings-CeqZWQEi.js → settings.keybindings-B3Yph4YE.js} +2 -2
  217. package/dist/client/assets/{settings.open-source-licenses-BAFwkfI8.js → settings.open-source-licenses-Dx_Hoxhs.js} +2 -2
  218. package/dist/client/assets/settings.plugins-TfmhiHSr.js +5 -0
  219. package/dist/client/assets/{settings.projects-Cqx1zAvs.js → settings.projects-DyqRcoD5.js} +3 -3
  220. package/dist/client/assets/{settings.providers-CS55UrI1.js → settings.providers-CqMvOZmv.js} +3 -3
  221. package/dist/client/assets/{settings.scheduled-tasks-CFJTEOb1.js → settings.scheduled-tasks-gzepleP4.js} +2 -2
  222. package/dist/client/assets/{settings.snap-shot-E3AITJyC.js → settings.snap-shot-DPIz29B9.js} +2 -2
  223. package/dist/client/assets/{settings.source-control-CWWy9E3b.js → settings.source-control-BMPVT8GA.js} +2 -2
  224. package/dist/client/assets/{settings.storage-BnUI1rFT.js → settings.storage-Cd4Vn9s1.js} +2 -2
  225. package/dist/client/assets/{settingsLayout-DHc6oKfL.js → settingsLayout-BRcW18Dy.js} +2 -2
  226. package/dist/client/assets/{sidebar-BkujXU9U.js → sidebar-CNP67lTi.js} +2 -2
  227. package/dist/client/assets/{sidebarProjectGrouping-DD4nu9RX.js → sidebarProjectGrouping-BRC9yCnW.js} +2 -2
  228. package/dist/client/assets/{skeleton-C6_D5JUu.js → skeleton-DDh76jpd.js} +2 -2
  229. package/dist/client/assets/{sortable.esm-BAEGChD3.js → sortable.esm-KZlxUbRj.js} +2 -2
  230. package/dist/client/assets/{sourceControl-BAghu6LN.js → sourceControl-DXwrIEUZ.js} +2 -2
  231. package/dist/client/assets/{spinner-CpLstN6u.js → spinner-DYnZ-Bpa.js} +2 -2
  232. package/dist/client/assets/{standalone-page-7vaVYOp-.js → standalone-page-DUgQaNPq.js} +2 -2
  233. package/dist/client/assets/{stateDiagram-D77RDMKH-CpZF58eW.js → stateDiagram-D77RDMKH-DhHX_ym0.js} +2 -2
  234. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-Dy0yVJgc.js +2 -0
  235. package/dist/client/assets/{swimlanes-42K2YHIH-D1b49puG.js → swimlanes-42K2YHIH-gr_Fo6MW.js} +2 -2
  236. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-CPHF5kgn.js +9 -0
  237. package/dist/client/assets/{terminal-links-CjmSI9gV.js → terminal-links-CV_3r1U3.js} +2 -2
  238. package/dist/client/assets/{terminalSessions-Q2t1JYPS.js → terminalSessions-aS2PVMmc.js} +2 -2
  239. package/dist/client/assets/{textarea-DKdxwZZC.js → textarea-Dt0w6mtc.js} +2 -2
  240. package/dist/client/assets/{themePalette-7p_LOU3J.js → themePalette-9CODTNe7.js} +2 -2
  241. package/dist/client/assets/{threadSort-C5oCCRfj.js → threadSort-BGtAZpdL.js} +2 -2
  242. package/dist/client/assets/{timeline-definition-24CTP7MA-89AJY6KO.js → timeline-definition-24CTP7MA-DOSB4Ras.js} +2 -2
  243. package/dist/client/assets/{toast-DhMYg_gN.js → toast-SPJYfh08.js} +2 -2
  244. package/dist/client/assets/{toggle-BshAsXT6.js → toggle-C3pF5hng.js} +2 -2
  245. package/dist/client/assets/{toggle-group-ZNzhUvHt.js → toggle-group-C4V_4iet.js} +2 -2
  246. package/dist/client/assets/{tooltip-Cq9yz15d.js → tooltip-Cco13jKX.js} +2 -2
  247. package/dist/client/assets/{treeView-Q6P3EWNA-CqNF2YcW.js → treeView-Q6P3EWNA-DTI4SxFY.js} +1 -1
  248. package/dist/client/assets/{treemap-WGGIJYW6-LJa3ZEYA.js → treemap-WGGIJYW6-CVnkW1D0.js} +1 -1
  249. package/dist/client/assets/{usage-CJVyABbK.js → usage-539lpsjW.js} +2 -2
  250. package/dist/client/assets/{usageAccess-CieOJbVm.js → usageAccess-CeCsk7TS.js} +2 -2
  251. package/dist/client/assets/{usageFormat-BEGhDYfU.js → usageFormat-CQXspPhL.js} +2 -2
  252. package/dist/client/assets/{usageShortcuts-DxuByyhD.js → usageShortcuts-DaMuOxo1.js} +2 -2
  253. package/dist/client/assets/{use-atom-command-x4GQBtio.js → use-atom-command-BHmF32aL.js} +2 -2
  254. package/dist/client/assets/{useAriaLabelledBy-u5efXUxw.js → useAriaLabelledBy-BinWYOc0.js} +2 -2
  255. package/dist/client/assets/{useHandleNewThread-CReGBX6y.js → useHandleNewThread-Tv2D0mTw.js} +2 -2
  256. package/dist/client/assets/{useLocation-B3ir4ben.js → useLocation-BQwksr61.js} +2 -2
  257. package/dist/client/assets/useNavigate-LjcLtV_e.js +2 -0
  258. package/dist/client/assets/{useNavigateBack-XQd0WINI.js → useNavigateBack-D2S1CDHR.js} +2 -2
  259. package/dist/client/assets/{useParams-Cil-ZIwd.js → useParams-D_8gJiai.js} +2 -2
  260. package/dist/client/assets/{usePermissionStatus-C4aMrLLP.js → usePermissionStatus-Bl_cAihc.js} +2 -2
  261. package/dist/client/assets/{usePullRequestActions-BL4mjngC.js → usePullRequestActions-DscMhi-m.js} +2 -2
  262. package/dist/client/assets/{useRegisterFieldControl-75QESVfk.js → useRegisterFieldControl-Bp078Il-.js} +2 -2
  263. package/dist/client/assets/{useScopedModelAvailability-CBOIiaXC.js → useScopedModelAvailability-BP4GoHk-.js} +2 -2
  264. package/dist/client/assets/{useSettings-Dx076NWT.js → useSettings-DUgjfqYw.js} +2 -2
  265. package/dist/client/assets/{useT3ConnectAuthPrompt-1zTdZLsH.js → useT3ConnectAuthPrompt-D0cW1Kb6.js} +2 -2
  266. package/dist/client/assets/utils-Dx_TSvdC.js +37 -0
  267. package/dist/client/assets/{vcsRefInvalidation-46AnO9mr.js → vcsRefInvalidation-CRBfa6Wz.js} +2 -2
  268. package/dist/client/assets/{vennDiagram-4TSXK5OY-CvvE7gMp.js → vennDiagram-4TSXK5OY-BVgFdMgp.js} +2 -2
  269. package/dist/client/assets/{wardley-WFR3VGLG-Ca8Qzkpo.js → wardley-WFR3VGLG-Dmh19KFW.js} +1 -1
  270. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-BBSNgSMI.js → wardleyDiagram-VM6X3IG4-CLjnvp-z.js} +2 -2
  271. package/dist/client/assets/{welcome-B3wsq5wK.js → welcome-BcEvYhrg.js} +2 -2
  272. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-D8OhWe48.js → xychartDiagram-S5SC5T6Z-CmyAZ93b.js} +2 -2
  273. package/dist/client/index.html +1 -1
  274. package/dist/{renderer-C4CdFj__.mjs → renderer-B8qsc7RL.mjs} +2 -2
  275. package/dist/{runtime-CCVFqL3Y.mjs → runtime-CEdmfdaF.mjs} +20 -6
  276. package/package.json +1 -1
  277. package/dist/client/assets/AlertDialogRoot-DvQNG7Nt.js +0 -2
  278. package/dist/client/assets/Input-BQRZG5rU.js +0 -2
  279. package/dist/client/assets/architecture-7GRP2DOG-CiMEl2LX.js +0 -1
  280. package/dist/client/assets/channel-CDbYAV2D.js +0 -2
  281. package/dist/client/assets/classDiagram-ZZMXUADV-Cdtwlmxc.js +0 -2
  282. package/dist/client/assets/classDiagram-v2-VYDZK3BY-Cdtwlmxc.js +0 -2
  283. package/dist/client/assets/eventmodeling-NTZA5JFV-DNKqiuCf.js +0 -1
  284. package/dist/client/assets/flowDiagram-HODETNUW-CbOoDtR7.js +0 -1
  285. package/dist/client/assets/railroad-abnf-HS5TGJTU-BtC_0p6z.js +0 -1
  286. package/dist/client/assets/railroad-ebnf-LZEXJU2U-IeTBC6cs.js +0 -1
  287. package/dist/client/assets/railroad-peg-WCYAUIDC-DLoLKYq3.js +0 -1
  288. package/dist/client/assets/session-logic-BLOBsHEA.js +0 -26
  289. package/dist/client/assets/settings.archived-Cq_qclay.js +0 -2
  290. package/dist/client/assets/settings.plugins-D5l1ZPSB.js +0 -5
  291. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DewOo-MV.js +0 -2
  292. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-d9EGwk-5.js +0 -9
  293. package/dist/client/assets/useNavigate-DRqH9NhA.js +0 -2
  294. package/dist/client/assets/utils-BEVyjoxo.js +0 -37
@@ -1,5 +1,5 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{NE as n,Pp as r,Um as i,fp as a,lE as o,sr as s,t as c,vp as l}from"./utils-BEVyjoxo.js";import{a as u,c as d,f,n as p,t as m,u as h}from"./tooltip-Cq9yz15d.js";import{A as g,E as _,G as ee,H as v,O as y,S as b,U as te,W as x,_ as S,d as ne,et as C,g as w,m as T,s as re,u as E,y as D}from"./themePalette-7p_LOU3J.js";import{n as O,t as k}from"./toggle-group-ZNzhUvHt.js";import{t as ie}from"./input-RqvQJ9gh.js";import{i as A,o as j,t as M}from"./popover-DE9WCm99.js";import{i as N,n as P,r as F,t as I}from"./color-picker-N6f_Hu7P.js";import{La as L}from"./main-Bh6Hj0_-.js";var ae=n(),R=e(t(),1),z=e(o(),1);function B(e){return{canvas:`Background`,toolbar:`Toolbar background`,toolbarForeground:`Toolbar text`,toolbarBorder:`Toolbar border`,toolbarControl:`Toolbar control`,toolbarControlForeground:`Toolbar control text`,toolbarControlHover:`Toolbar control hover`,accent:`Accent color`,errorForeground:`Error text`,errorSurface:`Error background`,warningForeground:`Warning text`,warningSurface:`Warning background`,updateForeground:`Update text`,updateSurface:`Update background`}[e]||e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function V(e){let t=v(e)??``,n=t.length===9?t.slice(7):``;return n===`ff`?``:n}function oe(e){return(v(e)??`#000000`).slice(0,7)}function se(e){let t=Number.parseInt(oe(e).slice(1),16);return[t>>16,t>>8&255,t&255]}function ce(e){let t=e.trim().replace(/^rgb\(\s*/i,``).replace(/\s*\)$/,``).split(/[,\s]+/).filter(Boolean).map(Number);return t.length!==3||t.some(e=>!Number.isInteger(e)||e<0||e>255)?null:`#${t.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function H(e){return se(e).join(`, `)}function U({label:e,value:t,onChange:n}){let r=oe(t),i=V(t),[a,o]=(0,R.useState)(()=>F(r)),[s,c]=(0,R.useState)(r),[l,u]=(0,R.useState)(()=>H(r)),d=(0,R.useRef)(!1),f=N(a.h,a.s,a.v),p=H(f);(0,R.useEffect)(()=>{d.current||(c(r),u(H(r))),o(e=>N(e.h,e.s,e.v)===r?e:F(r))},[r]);let m=(0,R.useRef)(n);m.current=n;let h=(0,R.useRef)(null),g=(0,R.useRef)(null),_=(0,R.useCallback)(()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null);let e=h.current;h.current=null,e!==null&&m.current(e)},[]);(0,R.useEffect)(()=>()=>_(),[_]);let ee=(0,R.useCallback)(e=>{h.current=e,g.current??=requestAnimationFrame(()=>{g.current=null;let e=h.current;h.current=null,e!==null&&m.current(e)})},[]),v=(0,R.useCallback)(e=>{o(e);let t=N(e.h,e.s,e.v);c(t),u(H(t)),ee(t+i)},[i,ee]),y=e=>{if(c(e),!/^#[0-9a-f]{6}$/i.test(e))return;let t=F(e);o(t),u(H(e)),n(e.toLowerCase())},b=e=>{u(e);let t=ce(e);t&&(o(F(t)),c(t),n(t+i))};return(0,z.jsxs)(`div`,{className:`w-72 bg-popover`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`truncate text-xs font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:`Choose a color`})]}),(0,z.jsx)(`span`,{className:`size-7 shrink-0 rounded-full shadow-sm`,style:{backgroundColor:f}})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 px-3 pb-3 pt-3`,children:[(0,z.jsx)(P,{label:e,value:a,onChange:v,onInteractionEnd:_}),(0,z.jsx)(I,{label:`${e} hue`,value:a.h,onChange:e=>v({...a,h:e}),onInteractionEnd:_}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_1.2fr] gap-2`,children:[(0,z.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,z.jsx)(`span`,{className:`px-1 text-3xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`HEX`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 rounded-lg border border-input bg-background px-2 focus-within:border-ring`,children:[(0,z.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-full`,style:{backgroundColor:f}}),(0,z.jsx)(`input`,{"aria-label":`${e} picker hex value`,className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none`,onBlur:()=>{d.current=!1,c(f),u(p)},onChange:e=>y(e.currentTarget.value),onFocus:()=>{d.current=!0},spellCheck:!1,value:s})]})]}),(0,z.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,z.jsx)(`span`,{className:`px-1 text-3xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`RGB`}),(0,z.jsx)(`span`,{className:`flex min-w-0 items-center rounded-lg border border-input bg-background px-2 focus-within:border-ring`,children:(0,z.jsx)(`input`,{"aria-label":`${e} picker RGB value`,className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none`,onBlur:()=>{d.current=!1,c(f),u(p)},onChange:e=>b(e.currentTarget.value),onFocus:()=>{d.current=!0},spellCheck:!1,value:l})})]})]})]})]})}function W(e){let t=(0,ae.c)(13),{label:n,value:r,onChange:i,onInteract:a}=e,o=`Choose ${n} color`,s;t[0]===r?s=t[1]:(s=(0,z.jsx)(`span`,{className:`absolute inset-0 rounded-full shadow-sm`,style:{backgroundColor:r}}),t[0]=r,t[1]=s);let c;t[2]!==a||t[3]!==o||t[4]!==s?(c=(0,z.jsx)(j,{render:(0,z.jsx)(`button`,{"aria-label":o,className:`relative flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border border-foreground/30 transition-transform hover:scale-105 focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring`,onFocus:a,onPointerDown:a,type:`button`,children:s})}),t[2]=a,t[3]=o,t[4]=s,t[5]=c):c=t[5];let l;t[6]!==n||t[7]!==i||t[8]!==r?(l=(0,z.jsx)(A,{align:`end`,padding:`none`,"data-theme-editor-panel":``,side:`bottom`,sideOffset:10,children:(0,z.jsx)(U,{label:n,onChange:i,value:r})}),t[6]=n,t[7]=i,t[8]=r,t[9]=l):l=t[9];let u;return t[10]!==c||t[11]!==l?(u=(0,z.jsxs)(M,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u}var le=(0,R.memo)(function(e){let t=(0,ae.c)(58),{role:n,value:r,onChange:i,onSelect:a,onToggleSelected:o,selected:s,label:l}=e,d=s!==void 0&&s,f;t[0]!==l||t[1]!==n?(f=l??B(n),t[0]=l,t[1]=n,t[2]=f):f=t[2];let h=f,g;t[3]===r?g=t[4]:(g=_(r),t[3]=r,t[4]=g);let ee=g,y=ee?r:`#000000`,b;t[5]===r?b=t[6]:(b=r.trim().toLowerCase().startsWith(`oklch(`)?v(r)??r:r,t[5]=r,t[6]=b);let te=b,x=d&&`bg-accent/60 inset-ring inset-ring-ring`,S;t[7]===x?S=t[8]:(S=c(`flex min-h-11 min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 transition-[background-color,box-shadow]`,x),t[7]=x,t[8]=S);let ne=`${d?`Hide`:`Show`} ${h} usage`,C;t[9]!==o||t[10]!==n?(C=()=>o?.(n),t[9]=o,t[10]=n,t[11]=C):C=t[11];let w;t[12]===h?w=t[13]:(w=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:h}),t[12]=h,t[13]=w);let T;t[14]!==d||t[15]!==ne||t[16]!==C||t[17]!==w?(T=(0,z.jsx)(u,{render:(0,z.jsx)(`button`,{"aria-label":ne,"aria-pressed":d,className:`flex min-w-0 flex-1 cursor-pointer items-center rounded-md text-left text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,onClick:C,type:`button`,children:w})}),t[14]=d,t[15]=ne,t[16]=C,t[17]=w,t[18]=T):T=t[18];let re=`${d?`Hide`:`Show`} where ${h} is used`,E;t[19]===re?E=t[20]:(E=(0,z.jsx)(p,{side:`top`,children:re}),t[19]=re,t[20]=E);let D;t[21]!==T||t[22]!==E?(D=(0,z.jsxs)(m,{children:[T,E]}),t[21]=T,t[22]=E,t[23]=D):D=t[23];let O;t[24]!==i||t[25]!==n?(O=e=>i(n,e),t[24]=i,t[25]=n,t[26]=O):O=t[26];let k;t[27]!==a||t[28]!==n?(k=()=>a?.(n),t[27]=a,t[28]=n,t[29]=k):k=t[29];let A;t[30]!==h||t[31]!==y||t[32]!==O||t[33]!==k?(A=(0,z.jsx)(W,{label:h,onChange:O,onInteract:k,value:y}),t[30]=h,t[31]=y,t[32]=O,t[33]=k,t[34]=A):A=t[34];let j=!ee,M=`${h} hex value`,N=`${n}-hex`,P;t[35]!==i||t[36]!==n?(P=e=>i(n,e.currentTarget.value),t[35]=i,t[36]=n,t[37]=P):P=t[37];let F,I;t[38]!==a||t[39]!==n?(F=()=>a?.(n),I=()=>a?.(n),t[38]=a,t[39]=n,t[40]=F,t[41]=I):(F=t[40],I=t[41]);let L;t[42]!==te||t[43]!==j||t[44]!==M||t[45]!==N||t[46]!==P||t[47]!==F||t[48]!==I?(L=(0,z.jsx)(ie,{"aria-invalid":j,"aria-label":M,className:`w-28 shrink-0`,font:`mono`,id:N,nativeInput:!0,onChange:P,onFocus:F,onPointerDown:I,size:`compact`,value:te}),t[42]=te,t[43]=j,t[44]=M,t[45]=N,t[46]=P,t[47]=F,t[48]=I,t[49]=L):L=t[49];let R;t[50]!==A||t[51]!==L?(R=(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[A,L]}),t[50]=A,t[51]=L,t[52]=R):R=t[52];let V;return t[53]!==n||t[54]!==D||t[55]!==R||t[56]!==S?(V=(0,z.jsxs)(`div`,{className:S,"data-theme-color-role":n,children:[D,R]}),t[53]=n,t[54]=D,t[55]=R,t[56]=S,t[57]=V):V=t[57],V}),ue=[`background`,`border`,`foreground`],G=`data-theme-inspector-match`,de=`data-theme-token-probe`,K=`#01fea7`,fe=`#fe01a7`,q=`theme-inspector-spotlight`,J=`theme-inspector-spotlight-mask`,pe=`theme-inspector-spotlight-glow`,Y=`theme-inspector-hover`,X=`http://www.w3.org/2000/svg`,me={background:`canvas`,foreground:`text`,card:`surface`,"card-foreground":`text`,popover:`surfaceOverlay`,"popover-foreground":`text`,"surface-raised":`surfaceRaised`,primary:`messageAction`,"primary-foreground":`messageActionForeground`,secondary:`secondary`,"secondary-foreground":`secondaryForeground`,muted:`muted`,"muted-foreground":`mutedForeground`,placeholder:`placeholder`,"secondary-label":`secondaryLabel`,"icon-muted":`iconMuted`,accent:`accentSurface`,"accent-foreground":`accentSurfaceForeground`,destructive:`error`,"destructive-foreground":`errorForeground`,error:`error`,"error-foreground":`errorForeground`,"error-surface":`errorSurface`,warning:`warning`,"warning-foreground":`warningForeground`,"warning-surface":`warningSurface`,update:`update`,"update-foreground":`updateForeground`,"update-surface":`updateSurface`,message:`messageSurface`,"message-foreground":`messageForeground`,"message-action":`messageAction`,"message-action-foreground":`messageActionForeground`,"message-action-hover":`messageActionHover`,sidebar:`sidebar`,"sidebar-foreground":`sidebarForeground`,"sidebar-muted-foreground":`sidebarMutedForeground`,"sidebar-control-surface":`sidebarControlSurface`,"sidebar-row-hover":`sidebarRowHover`,"sidebar-row-active":`sidebarRowActive`,"sidebar-row-selected":`sidebarRowSelected`,"sidebar-border":`sidebarBorder`,border:`border`,input:`input`,ring:`focus`},he={background:[`bg-`],border:[`border-`,`outline-`,`ring-`],foreground:[`text-`,`caret-`,`fill-`,`stroke-`]};function ge(e){document.querySelectorAll(`[${e}]`).forEach(t=>t.removeAttribute(e))}function _e(){ge(G),document.getElementById(q)?.remove()}function ve(){document.getElementById(Y)?.remove()}function Z(e){return document.createElementNS(X,e)}function ye(e){let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0||t.right<0||t.bottom<0||t.left>window.innerWidth||t.top>window.innerHeight)return null;let n=t.left-5,r=t.top-5,i=Number.parseFloat(window.getComputedStyle(e).borderTopLeftRadius)||0;return{x:n,y:r,width:t.width+10,height:t.height+10,radius:Math.min(18,Math.max(7,i+5))}}function be(e,t){let n=ye(e.element);if(!n){ve();return}let r=document.getElementById(Y);if(!r){r=document.createElement(`div`),r.id=Y,r.setAttribute(`aria-hidden`,`true`);let e=document.createElement(`span`);e.dataset.themeInspectorHoverLabel=``,r.append(e),document.body.append(r)}r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`,r.style.borderRadius=`${n.radius}px`,r.dataset.placement=n.y<32?`below`:`above`;let i=r.querySelector(`[data-theme-inspector-hover-label]`);i&&(i.textContent=t)}function xe(e){let t=new Map;for(let n of e){let e=ye(n);if(!e)continue;let r=[e.x,e.y,e.width,e.height].map(e=>Math.round(e)).join(`:`);t.set(r,e)}if(t.size===0){document.getElementById(q)?.remove();return}let n=document.getElementById(q);n||(n=Z(`svg`),n.id=q,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),document.body.append(n)),n.setAttribute(`viewBox`,`0 0 ${window.innerWidth} ${window.innerHeight}`);let r=Z(`defs`),i=Z(`mask`);i.id=J,i.setAttribute(`maskUnits`,`userSpaceOnUse`);let a=Z(`rect`);a.setAttribute(`width`,String(window.innerWidth)),a.setAttribute(`height`,String(window.innerHeight)),a.setAttribute(`fill`,`white`),i.append(a);let o=Z(`filter`);o.id=pe,o.setAttribute(`x`,`-50%`),o.setAttribute(`y`,`-50%`),o.setAttribute(`width`,`200%`),o.setAttribute(`height`,`200%`);let s=Z(`feGaussianBlur`);s.setAttribute(`stdDeviation`,`5`),s.setAttribute(`result`,`blur`);let c=Z(`feMerge`),l=Z(`feMergeNode`);l.setAttribute(`in`,`blur`);let u=Z(`feMergeNode`);u.setAttribute(`in`,`SourceGraphic`),c.append(l,u),o.append(s,c),r.append(i,o);let d=Z(`g`);for(let e of t.values()){let t=Z(`rect`);t.setAttribute(`x`,String(e.x)),t.setAttribute(`y`,String(e.y)),t.setAttribute(`width`,String(e.width)),t.setAttribute(`height`,String(e.height)),t.setAttribute(`rx`,String(e.radius)),t.setAttribute(`fill`,`black`),i.append(t);let n=t.cloneNode(!1);n.removeAttribute(`fill`),n.setAttribute(`class`,`theme-inspector-spotlight-glow`),n.setAttribute(`filter`,`url(#${pe})`),d.append(n)}let f=Z(`rect`);f.setAttribute(`class`,`theme-inspector-spotlight-dimmer`),f.setAttribute(`width`,String(window.innerWidth)),f.setAttribute(`height`,String(window.innerHeight)),f.setAttribute(`mask`,`url(#${J})`),n.replaceChildren(r,f,d)}function Se(){xe([...document.querySelectorAll(`[${G}]`)])}function Ce(e){return e.matches(`input, textarea, select, option`)?!0:Array.from(e.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!e.textContent?.trim())}function Q(e,{forHitTest:t=!1}={}){let n=window.getComputedStyle(e);if(n.display===`none`||n.visibility===`hidden`||Number(n.opacity)===0)return null;let r=[];for(let[e,t,i]of[[n.borderTopColor,n.borderTopStyle,n.borderTopWidth],[n.borderRightColor,n.borderRightStyle,n.borderRightWidth],[n.borderBottomColor,n.borderBottomStyle,n.borderBottomWidth],[n.borderLeftColor,n.borderLeftStyle,n.borderLeftWidth]])t!==`none`&&Number.parseFloat(i)>0&&r.push(e);n.outlineStyle!==`none`&&Number.parseFloat(n.outlineWidth)>0&&r.push(n.outlineColor),n.borderImageSource!==`none`&&r.push(n.borderImageSource),n.boxShadow!==`none`&&r.push(n.boxShadow);let i=[];return(t||Ce(e))&&i.push(n.color),e instanceof SVGElement&&i.push(n.fill,n.stroke),e.matches(`input, textarea`)&&i.push(n.caretColor),n.textDecorationLine!==`none`&&i.push(n.textDecorationColor),n.textShadow!==`none`&&i.push(n.textShadow),{background:[n.backgroundColor,n.backgroundImage].join(`
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{NE as n,Pp as r,Um as i,fp as a,lE as o,sr as s,t as c,vp as l}from"./utils-Dx_TSvdC.js";import{a as u,c as d,f,n as p,t as m,u as h}from"./tooltip-Cco13jKX.js";import{A as g,E as _,G as ee,H as v,O as y,S as b,U as te,W as x,_ as S,d as ne,et as C,g as w,m as T,s as re,u as E,y as D}from"./themePalette-9CODTNe7.js";import{n as O,t as k}from"./toggle-group-C4V_4iet.js";import{t as ie}from"./input-CF-egQtG.js";import{i as A,o as j,t as M}from"./popover-BunL7s_L.js";import{i as N,n as P,r as F,t as I}from"./color-picker-Dd1K-QRk.js";import{La as L}from"./main-C58_iQqs.js";var ae=n(),R=e(t(),1),z=e(o(),1);function B(e){return{canvas:`Background`,toolbar:`Toolbar background`,toolbarForeground:`Toolbar text`,toolbarBorder:`Toolbar border`,toolbarControl:`Toolbar control`,toolbarControlForeground:`Toolbar control text`,toolbarControlHover:`Toolbar control hover`,accent:`Accent color`,errorForeground:`Error text`,errorSurface:`Error background`,warningForeground:`Warning text`,warningSurface:`Warning background`,updateForeground:`Update text`,updateSurface:`Update background`}[e]||e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function V(e){let t=v(e)??``,n=t.length===9?t.slice(7):``;return n===`ff`?``:n}function oe(e){return(v(e)??`#000000`).slice(0,7)}function se(e){let t=Number.parseInt(oe(e).slice(1),16);return[t>>16,t>>8&255,t&255]}function ce(e){let t=e.trim().replace(/^rgb\(\s*/i,``).replace(/\s*\)$/,``).split(/[,\s]+/).filter(Boolean).map(Number);return t.length!==3||t.some(e=>!Number.isInteger(e)||e<0||e>255)?null:`#${t.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function H(e){return se(e).join(`, `)}function U({label:e,value:t,onChange:n}){let r=oe(t),i=V(t),[a,o]=(0,R.useState)(()=>F(r)),[s,c]=(0,R.useState)(r),[l,u]=(0,R.useState)(()=>H(r)),d=(0,R.useRef)(!1),f=N(a.h,a.s,a.v),p=H(f);(0,R.useEffect)(()=>{d.current||(c(r),u(H(r))),o(e=>N(e.h,e.s,e.v)===r?e:F(r))},[r]);let m=(0,R.useRef)(n);m.current=n;let h=(0,R.useRef)(null),g=(0,R.useRef)(null),_=(0,R.useCallback)(()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null);let e=h.current;h.current=null,e!==null&&m.current(e)},[]);(0,R.useEffect)(()=>()=>_(),[_]);let ee=(0,R.useCallback)(e=>{h.current=e,g.current??=requestAnimationFrame(()=>{g.current=null;let e=h.current;h.current=null,e!==null&&m.current(e)})},[]),v=(0,R.useCallback)(e=>{o(e);let t=N(e.h,e.s,e.v);c(t),u(H(t)),ee(t+i)},[i,ee]),y=e=>{if(c(e),!/^#[0-9a-f]{6}$/i.test(e))return;let t=F(e);o(t),u(H(e)),n(e.toLowerCase())},b=e=>{u(e);let t=ce(e);t&&(o(F(t)),c(t),n(t+i))};return(0,z.jsxs)(`div`,{className:`w-72 bg-popover`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`truncate text-xs font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:`Choose a color`})]}),(0,z.jsx)(`span`,{className:`size-7 shrink-0 rounded-full shadow-sm`,style:{backgroundColor:f}})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 px-3 pb-3 pt-3`,children:[(0,z.jsx)(P,{label:e,value:a,onChange:v,onInteractionEnd:_}),(0,z.jsx)(I,{label:`${e} hue`,value:a.h,onChange:e=>v({...a,h:e}),onInteractionEnd:_}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_1.2fr] gap-2`,children:[(0,z.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,z.jsx)(`span`,{className:`px-1 text-3xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`HEX`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 rounded-lg border border-input bg-background px-2 focus-within:border-ring`,children:[(0,z.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-full`,style:{backgroundColor:f}}),(0,z.jsx)(`input`,{"aria-label":`${e} picker hex value`,className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none`,onBlur:()=>{d.current=!1,c(f),u(p)},onChange:e=>y(e.currentTarget.value),onFocus:()=>{d.current=!0},spellCheck:!1,value:s})]})]}),(0,z.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,z.jsx)(`span`,{className:`px-1 text-3xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`RGB`}),(0,z.jsx)(`span`,{className:`flex min-w-0 items-center rounded-lg border border-input bg-background px-2 focus-within:border-ring`,children:(0,z.jsx)(`input`,{"aria-label":`${e} picker RGB value`,className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none`,onBlur:()=>{d.current=!1,c(f),u(p)},onChange:e=>b(e.currentTarget.value),onFocus:()=>{d.current=!0},spellCheck:!1,value:l})})]})]})]})]})}function W(e){let t=(0,ae.c)(13),{label:n,value:r,onChange:i,onInteract:a}=e,o=`Choose ${n} color`,s;t[0]===r?s=t[1]:(s=(0,z.jsx)(`span`,{className:`absolute inset-0 rounded-full shadow-sm`,style:{backgroundColor:r}}),t[0]=r,t[1]=s);let c;t[2]!==a||t[3]!==o||t[4]!==s?(c=(0,z.jsx)(j,{render:(0,z.jsx)(`button`,{"aria-label":o,className:`relative flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border border-foreground/30 transition-transform hover:scale-105 focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring`,onFocus:a,onPointerDown:a,type:`button`,children:s})}),t[2]=a,t[3]=o,t[4]=s,t[5]=c):c=t[5];let l;t[6]!==n||t[7]!==i||t[8]!==r?(l=(0,z.jsx)(A,{align:`end`,padding:`none`,"data-theme-editor-panel":``,side:`bottom`,sideOffset:10,children:(0,z.jsx)(U,{label:n,onChange:i,value:r})}),t[6]=n,t[7]=i,t[8]=r,t[9]=l):l=t[9];let u;return t[10]!==c||t[11]!==l?(u=(0,z.jsxs)(M,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u}var le=(0,R.memo)(function(e){let t=(0,ae.c)(58),{role:n,value:r,onChange:i,onSelect:a,onToggleSelected:o,selected:s,label:l}=e,d=s!==void 0&&s,f;t[0]!==l||t[1]!==n?(f=l??B(n),t[0]=l,t[1]=n,t[2]=f):f=t[2];let h=f,g;t[3]===r?g=t[4]:(g=_(r),t[3]=r,t[4]=g);let ee=g,y=ee?r:`#000000`,b;t[5]===r?b=t[6]:(b=r.trim().toLowerCase().startsWith(`oklch(`)?v(r)??r:r,t[5]=r,t[6]=b);let te=b,x=d&&`bg-accent/60 inset-ring inset-ring-ring`,S;t[7]===x?S=t[8]:(S=c(`flex min-h-11 min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 transition-[background-color,box-shadow]`,x),t[7]=x,t[8]=S);let ne=`${d?`Hide`:`Show`} ${h} usage`,C;t[9]!==o||t[10]!==n?(C=()=>o?.(n),t[9]=o,t[10]=n,t[11]=C):C=t[11];let w;t[12]===h?w=t[13]:(w=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:h}),t[12]=h,t[13]=w);let T;t[14]!==d||t[15]!==ne||t[16]!==C||t[17]!==w?(T=(0,z.jsx)(u,{render:(0,z.jsx)(`button`,{"aria-label":ne,"aria-pressed":d,className:`flex min-w-0 flex-1 cursor-pointer items-center rounded-md text-left text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,onClick:C,type:`button`,children:w})}),t[14]=d,t[15]=ne,t[16]=C,t[17]=w,t[18]=T):T=t[18];let re=`${d?`Hide`:`Show`} where ${h} is used`,E;t[19]===re?E=t[20]:(E=(0,z.jsx)(p,{side:`top`,children:re}),t[19]=re,t[20]=E);let D;t[21]!==T||t[22]!==E?(D=(0,z.jsxs)(m,{children:[T,E]}),t[21]=T,t[22]=E,t[23]=D):D=t[23];let O;t[24]!==i||t[25]!==n?(O=e=>i(n,e),t[24]=i,t[25]=n,t[26]=O):O=t[26];let k;t[27]!==a||t[28]!==n?(k=()=>a?.(n),t[27]=a,t[28]=n,t[29]=k):k=t[29];let A;t[30]!==h||t[31]!==y||t[32]!==O||t[33]!==k?(A=(0,z.jsx)(W,{label:h,onChange:O,onInteract:k,value:y}),t[30]=h,t[31]=y,t[32]=O,t[33]=k,t[34]=A):A=t[34];let j=!ee,M=`${h} hex value`,N=`${n}-hex`,P;t[35]!==i||t[36]!==n?(P=e=>i(n,e.currentTarget.value),t[35]=i,t[36]=n,t[37]=P):P=t[37];let F,I;t[38]!==a||t[39]!==n?(F=()=>a?.(n),I=()=>a?.(n),t[38]=a,t[39]=n,t[40]=F,t[41]=I):(F=t[40],I=t[41]);let L;t[42]!==te||t[43]!==j||t[44]!==M||t[45]!==N||t[46]!==P||t[47]!==F||t[48]!==I?(L=(0,z.jsx)(ie,{"aria-invalid":j,"aria-label":M,className:`w-28 shrink-0`,font:`mono`,id:N,nativeInput:!0,onChange:P,onFocus:F,onPointerDown:I,size:`compact`,value:te}),t[42]=te,t[43]=j,t[44]=M,t[45]=N,t[46]=P,t[47]=F,t[48]=I,t[49]=L):L=t[49];let R;t[50]!==A||t[51]!==L?(R=(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[A,L]}),t[50]=A,t[51]=L,t[52]=R):R=t[52];let V;return t[53]!==n||t[54]!==D||t[55]!==R||t[56]!==S?(V=(0,z.jsxs)(`div`,{className:S,"data-theme-color-role":n,children:[D,R]}),t[53]=n,t[54]=D,t[55]=R,t[56]=S,t[57]=V):V=t[57],V}),ue=[`background`,`border`,`foreground`],G=`data-theme-inspector-match`,de=`data-theme-token-probe`,K=`#01fea7`,fe=`#fe01a7`,q=`theme-inspector-spotlight`,J=`theme-inspector-spotlight-mask`,pe=`theme-inspector-spotlight-glow`,Y=`theme-inspector-hover`,X=`http://www.w3.org/2000/svg`,me={background:`canvas`,foreground:`text`,card:`surface`,"card-foreground":`text`,popover:`surfaceOverlay`,"popover-foreground":`text`,"surface-raised":`surfaceRaised`,primary:`messageAction`,"primary-foreground":`messageActionForeground`,secondary:`secondary`,"secondary-foreground":`secondaryForeground`,muted:`muted`,"muted-foreground":`mutedForeground`,placeholder:`placeholder`,"secondary-label":`secondaryLabel`,"icon-muted":`iconMuted`,accent:`accentSurface`,"accent-foreground":`accentSurfaceForeground`,destructive:`error`,"destructive-foreground":`errorForeground`,error:`error`,"error-foreground":`errorForeground`,"error-surface":`errorSurface`,warning:`warning`,"warning-foreground":`warningForeground`,"warning-surface":`warningSurface`,update:`update`,"update-foreground":`updateForeground`,"update-surface":`updateSurface`,message:`messageSurface`,"message-foreground":`messageForeground`,"message-action":`messageAction`,"message-action-foreground":`messageActionForeground`,"message-action-hover":`messageActionHover`,sidebar:`sidebar`,"sidebar-foreground":`sidebarForeground`,"sidebar-muted-foreground":`sidebarMutedForeground`,"sidebar-control-surface":`sidebarControlSurface`,"sidebar-row-hover":`sidebarRowHover`,"sidebar-row-active":`sidebarRowActive`,"sidebar-row-selected":`sidebarRowSelected`,"sidebar-border":`sidebarBorder`,border:`border`,input:`input`,ring:`focus`},he={background:[`bg-`],border:[`border-`,`outline-`,`ring-`],foreground:[`text-`,`caret-`,`fill-`,`stroke-`]};function ge(e){document.querySelectorAll(`[${e}]`).forEach(t=>t.removeAttribute(e))}function _e(){ge(G),document.getElementById(q)?.remove()}function ve(){document.getElementById(Y)?.remove()}function Z(e){return document.createElementNS(X,e)}function ye(e){let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0||t.right<0||t.bottom<0||t.left>window.innerWidth||t.top>window.innerHeight)return null;let n=t.left-5,r=t.top-5,i=Number.parseFloat(window.getComputedStyle(e).borderTopLeftRadius)||0;return{x:n,y:r,width:t.width+10,height:t.height+10,radius:Math.min(18,Math.max(7,i+5))}}function be(e,t){let n=ye(e.element);if(!n){ve();return}let r=document.getElementById(Y);if(!r){r=document.createElement(`div`),r.id=Y,r.setAttribute(`aria-hidden`,`true`);let e=document.createElement(`span`);e.dataset.themeInspectorHoverLabel=``,r.append(e),document.body.append(r)}r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`,r.style.borderRadius=`${n.radius}px`,r.dataset.placement=n.y<32?`below`:`above`;let i=r.querySelector(`[data-theme-inspector-hover-label]`);i&&(i.textContent=t)}function xe(e){let t=new Map;for(let n of e){let e=ye(n);if(!e)continue;let r=[e.x,e.y,e.width,e.height].map(e=>Math.round(e)).join(`:`);t.set(r,e)}if(t.size===0){document.getElementById(q)?.remove();return}let n=document.getElementById(q);n||(n=Z(`svg`),n.id=q,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),document.body.append(n)),n.setAttribute(`viewBox`,`0 0 ${window.innerWidth} ${window.innerHeight}`);let r=Z(`defs`),i=Z(`mask`);i.id=J,i.setAttribute(`maskUnits`,`userSpaceOnUse`);let a=Z(`rect`);a.setAttribute(`width`,String(window.innerWidth)),a.setAttribute(`height`,String(window.innerHeight)),a.setAttribute(`fill`,`white`),i.append(a);let o=Z(`filter`);o.id=pe,o.setAttribute(`x`,`-50%`),o.setAttribute(`y`,`-50%`),o.setAttribute(`width`,`200%`),o.setAttribute(`height`,`200%`);let s=Z(`feGaussianBlur`);s.setAttribute(`stdDeviation`,`5`),s.setAttribute(`result`,`blur`);let c=Z(`feMerge`),l=Z(`feMergeNode`);l.setAttribute(`in`,`blur`);let u=Z(`feMergeNode`);u.setAttribute(`in`,`SourceGraphic`),c.append(l,u),o.append(s,c),r.append(i,o);let d=Z(`g`);for(let e of t.values()){let t=Z(`rect`);t.setAttribute(`x`,String(e.x)),t.setAttribute(`y`,String(e.y)),t.setAttribute(`width`,String(e.width)),t.setAttribute(`height`,String(e.height)),t.setAttribute(`rx`,String(e.radius)),t.setAttribute(`fill`,`black`),i.append(t);let n=t.cloneNode(!1);n.removeAttribute(`fill`),n.setAttribute(`class`,`theme-inspector-spotlight-glow`),n.setAttribute(`filter`,`url(#${pe})`),d.append(n)}let f=Z(`rect`);f.setAttribute(`class`,`theme-inspector-spotlight-dimmer`),f.setAttribute(`width`,String(window.innerWidth)),f.setAttribute(`height`,String(window.innerHeight)),f.setAttribute(`mask`,`url(#${J})`),n.replaceChildren(r,f,d)}function Se(){xe([...document.querySelectorAll(`[${G}]`)])}function Ce(e){return e.matches(`input, textarea, select, option`)?!0:Array.from(e.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!e.textContent?.trim())}function Q(e,{forHitTest:t=!1}={}){let n=window.getComputedStyle(e);if(n.display===`none`||n.visibility===`hidden`||Number(n.opacity)===0)return null;let r=[];for(let[e,t,i]of[[n.borderTopColor,n.borderTopStyle,n.borderTopWidth],[n.borderRightColor,n.borderRightStyle,n.borderRightWidth],[n.borderBottomColor,n.borderBottomStyle,n.borderBottomWidth],[n.borderLeftColor,n.borderLeftStyle,n.borderLeftWidth]])t!==`none`&&Number.parseFloat(i)>0&&r.push(e);n.outlineStyle!==`none`&&Number.parseFloat(n.outlineWidth)>0&&r.push(n.outlineColor),n.borderImageSource!==`none`&&r.push(n.borderImageSource),n.boxShadow!==`none`&&r.push(n.boxShadow);let i=[];return(t||Ce(e))&&i.push(n.color),e instanceof SVGElement&&i.push(n.fill,n.stroke),e.matches(`input, textarea`)&&i.push(n.caretColor),n.textDecorationLine!==`none`&&i.push(n.textDecorationColor),n.textShadow!==`none`&&i.push(n.textShadow),{background:[n.backgroundColor,n.backgroundImage].join(`
2
2
  `),border:r.join(`
3
3
  `),foreground:i.join(`
4
4
  `)}}function we(e,t){return ue.filter(n=>e[n]!==t[n])}function Te(e){let t=document.documentElement,n=t.hasAttribute(de);n||t.setAttribute(de,``);try{return e()}finally{window.getComputedStyle(t).color,n||t.removeAttribute(de)}}function Ee(e){let t=document.documentElement,n=w(e),r=t.style.getPropertyValue(n),i=t.style.getPropertyPriority(n),a=r.trim().toLowerCase()===K?fe:K;return t.style.setProperty(n,a,`important`),()=>{r?t.style.setProperty(n,r,i):t.style.removeProperty(n)}}function $(e){let t=e.map(Ee);return()=>{for(let e of t.toReversed())e()}}function De(){return[document.body,...document.body.querySelectorAll(`*`)].filter(e=>!e.closest(`[data-theme-editor-panel]`)&&!e.closest(`#${q}, #${Y}`))}function Oe(e,t){if(e.includes(`:`))return null;for(let n of he[t])if(e.startsWith(n))return me[e.slice(n.length).split(`/`,1)[0]??``]??null;return null}function ke(e){for(let t of ue)for(let n of e.classList){let e=Oe(n,t);if(e)return e}return null}function Ae(e){let t=[],n=e;for(;n&&n!==document.documentElement;)n.closest(`[data-theme-editor-panel]`)||t.push(n),n=n.parentElement;return t}function je(e){if(e.closest(`[data-theme-editor-panel]`))return null;for(let t of Ae(e)){let e=ke(t);if(e)return{element:t,role:e}}return null}function Me(e){performance.now(),ge(G);let t=De(),n=performance.now(),r=Te(()=>{let n=new Map;for(let e of t){let t=Q(e);t&&n.set(e,t)}let r=$(e),i=new Set;try{for(let[e,t]of n){let n=Q(e);n&&we(t,n).length>0&&i.add(e)}}finally{r()}return i});performance.now()-n;let i=new Set;for(let e of r)i.add(e instanceof SVGElement?e.closest(`svg`)??e:e);for(let e of i)e.setAttribute(G,``);return xe([...i]),i.size}function Ne(e){if(e.closest(`[data-theme-editor-panel]`))return null;let t=Ae(e),n=je(e);if(n)return n;let r=Te(()=>{let e=new Map,n=new Map;for(let n of t){let t=Q(n,{forHitTest:!0});t&&e.set(n,t)}for(let t of C){let r=Ee(t);try{for(let[r,i]of e){let e=Q(r,{forHitTest:!0});if(!e)continue;let a=n.get(r)??{};for(let n of we(i,e))a[n]??=t;n.set(r,a)}}finally{r()}}return n});for(let e of t){let t=r.get(e);if(t)for(let n of ue){let r=t[n];if(r)return{element:e,role:r}}}return null}var Pe=[`canvas`,`accent`],Fe=[{id:`foundation`,title:`Foundation`,families:[{id:`background`,label:`Background`,role:`canvas`,roles:[`canvas`,`chrome`,`toolbar`]},{id:`surface`,label:`Surface`,role:`surface`,roles:[`surface`]},{id:`raised-surface`,label:`Raised surface`,role:`surfaceRaised`,roles:[`surfaceRaised`]},{id:`overlay`,label:`Overlay`,role:`surfaceOverlay`,roles:[`surfaceOverlay`]},{id:`text`,label:`Text`,role:`text`,roles:[`text`,`toolbarForeground`,`toolbarControlForeground`]},{id:`muted-text`,label:`Muted text`,role:`mutedForeground`,roles:[`textMuted`,`mutedForeground`,`placeholder`,`secondaryLabel`,`iconMuted`,`sidebarMutedForeground`]},{id:`border`,label:`Border`,role:`border`,roles:[`border`,`toolbarBorder`,`sidebarBorder`]},{id:`input`,label:`Input`,role:`input`,roles:[`input`]}]},{id:`brand-content`,title:`Brand & content`,families:[{id:`subtle-surface`,label:`Subtle surface`,role:`secondary`,roles:[`secondary`,`secondaryForeground`,`muted`,`toolbarControl`]},{id:`highlight-surface`,label:`Highlight surface`,role:`accentSurface`,roles:[`accentSurface`,`accentSurfaceForeground`,`toolbarControlHover`]},{id:`accent`,label:`Accent`,role:`accent`,roles:[`accent`,`accentForeground`,`focus`,`update`,`updateForeground`,`updateSurface`,`terminalCursor`]},{id:`action`,label:`Action`,role:`messageAction`,roles:[`messageAction`,`messageActionForeground`,`messageActionHover`]},{id:`message-surface`,label:`Message surface`,role:`messageSurface`,roles:[`messageSurface`,`messageForeground`]},{id:`code-surface`,label:`Code surface`,role:`codeBackground`,roles:[`codeBackground`,`codeForeground`]}]},{id:`search`,title:`Search`,families:[{id:`search-matches`,label:`Search matches`,role:`searchMatchBackground`,roles:[`searchMatchBackground`,`searchMatchForeground`]},{id:`current-match`,label:`Current match`,role:`searchMatchActiveBackground`,roles:[`searchMatchActiveBackground`,`searchMatchActiveForeground`]}]},{id:`context`,title:`Context`,families:[{id:`sidebar-background`,label:`Sidebar background`,role:`sidebar`,roles:[`sidebar`,`sidebarForeground`]},{id:`sidebar-controls`,label:`Sidebar controls`,role:`sidebarControlSurface`,roles:[`sidebarControlSurface`]},{id:`sidebar-selection`,label:`Sidebar selection`,role:`sidebarRowSelected`,roles:[`sidebarRowHover`,`sidebarRowActive`,`sidebarRowSelected`]},{id:`terminal-background`,label:`Terminal background`,role:`terminalBackground`,roles:[`terminalBackground`,`terminalForeground`,`terminalSelection`,`terminalScrollbar`,`terminalScrollbarHover`]}]},{id:`status`,title:`Status`,families:[{id:`error`,label:`Error`,role:`error`,roles:[`error`,`errorForeground`,`errorSurface`]},{id:`warning`,label:`Warning`,role:`warning`,roles:[`warning`,`warningForeground`,`warningSurface`]}]}],Ie=Fe.flatMap(e=>e.families),Le=new Map(Ie.flatMap(e=>e.roles.map(t=>[t,e])));function Re(e){return Le.get(e)??null}function ze(e){return{...T(e)}}function Be(){return{light:ze(`light`),dark:ze(`dark`)}}function Ve(e){return _(e.trim())}function He(e,t){let n=T(e);return E(e,Ve(t.canvas)?t.canvas:n.canvas,Ve(t.accent)?t.accent:n.accent)}function Ue({open:e,onOpenChange:t,onSaved:n,editingTheme:o,initialAppearance:_,seedTheme:v,seedName:w,restoreTheme:T}){let E=o!==null,[A,j]=(0,R.useState)(``),[M,N]=(0,R.useState)(_),[P,F]=(0,R.useState)(!1),[I,ae]=(0,R.useState)(()=>Be()),[V,oe]=(0,R.useState)({light:!1,dark:!1}),[se,ce]=(0,R.useState)(!1),[H,U]=(0,R.useState)(null),[W,ue]=(0,R.useState)(!1),[G,de]=(0,R.useState)(``),[K,fe]=(0,R.useState)(!1),[q,J]=(0,R.useState)(null),[pe,Y]=(0,R.useState)(null),[X,me]=(0,R.useState)(null),[he,ge]=(0,R.useState)(null),Z=(0,R.useRef)(null),ye=(0,R.useRef)(null),xe=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!e)return;let t=()=>{let e,t;ge(n=>n&&(e=Math.max(280,Math.min(n.width,window.innerWidth-16)),t=Math.max(220,Math.min(n.height,window.innerHeight-16)),{width:e,height:t})),me(n=>{if(!n)return n;let r=et(n.x,n.y,e),i=W?Z.current?.offsetHeight??0:t??Z.current?.offsetHeight??0,a=Math.max(8,window.innerHeight-i-8);return{x:r.x,y:Math.min(r.y,a)}})};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[W,e]);let[Ce,Q]=(0,R.useState)(!1),we=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(e&&!we.current){let e=o??v??null,t=Be(),n=e?S(e,_)?_:e.appearance:_;if(e){t[e.appearance]={...e.colors};for(let n of[`light`,`dark`]){let r=e.variants?.[n];r&&(t[n]={...r})}}j(o?.label??w??``),N(n),F(e!==null&&e.managed!==!0),oe({light:!1,dark:!1}),ce(e!==null&&e.managed!==!0),ae(t),J(null),Y(null),fe(!1),U(null),Q(!0)}!e&&Ce&&Q(!1),we.current=e},[o,_,Ce,e,w,v]);let Te=te(A),Ee=A.trim().toLowerCase(),$=Ee===``?null:ne().find(e=>e.id!==o?.id&&(e.id===Te||e.label.trim().toLowerCase()===Ee))??null,De=$?D($):[],Oe=o?D(o):null,ke=e=>Oe&&!Oe.includes(e)?`“${o?.label}” has no ${e} palette. Create a theme with the same name to add one.`:!E&&De.includes(e)?`“${$?.label}” already has a ${e} palette.`:null,Ae=$?.id??null,Ie=De.join(`,`);(0,R.useEffect)(()=>{if(E||Ae===null)return;let e=Ie.split(`,`).filter(Boolean);e.length===1&&N(t=>e.includes(t)?e[0]===`light`?`dark`:`light`:t)},[E,Ae,Ie]),(0,R.useEffect)(()=>{e&&Ce&&re(I[M],M)},[M,I,Ce,e]),(0,R.useEffect)(()=>{if(e)return()=>{T()}},[e,T]);let Le=(0,R.useCallback)((e,t)=>{ae(n=>{let r={...n[M],[e]:t},i=!P&&Pe.includes(e)&&Ve(t);return{...n,[M]:P?ee(M,n[M],e,t):i?He(M,r):r}}),!P&&Pe.includes(e)&&Ve(t)&&oe(e=>({...e,[M]:!0})),P&&ce(!0)},[M,P]),ze=(0,R.useCallback)((e,t=!1)=>{let n=Re(e)?.role??e;J(n),Pe.includes(n)||(F(!0),de(``)),t&&requestAnimationFrame(()=>{Z.current?.querySelector(`[data-theme-color-role="${n}"]`)?.scrollIntoView({behavior:`smooth`,block:`nearest`})})},[]),Ue=(0,R.useCallback)(e=>{J(t=>t===e?null:e)},[]),We=(0,R.useCallback)(()=>{J(null),Y(null),fe(!1)},[]),Ge=(q?P?Re(q)?.roles??[q]:Pe.includes(q)?C.filter(e=>I[M][e].trim().toLowerCase()===I[M][q].trim().toLowerCase()):[q]:[]).join(`,`);(0,R.useEffect)(()=>{if(_e(),!e||q===null){Y(null);return}if(K)return;let t=Ge.split(`,`),n=()=>Y(Me(t));n();let r=null,i=null,a=performance.now(),o=()=>{if(r!==null||i!==null)return;let e=Math.max(0,500-(performance.now()-a)),t=()=>{r=null,i=null,a=performance.now(),n()};e===0?r=requestAnimationFrame(t):i=setTimeout(t,e)},s=new MutationObserver(e=>{e.every(e=>e.target instanceof Element&&(e.target.closest(`#theme-inspector-spotlight`)||e.target.closest(`[data-theme-editor-panel]`)))||o()});s.observe(document.body,{childList:!0,subtree:!0});let c=null,l=()=>{c??=requestAnimationFrame(()=>{c=null,Se()})};return window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0),()=>{s.disconnect(),r!==null&&cancelAnimationFrame(r),i!==null&&clearTimeout(i),c!==null&&cancelAnimationFrame(c),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),_e()}},[K,e,Ge,q]),(0,R.useEffect)(()=>{if(!e||!K){ve();return}let t=!1,n=null,r=null,i=null,a=null,o=()=>{i!==null&&(window.clearTimeout(i),i=null)},s=()=>{o(),n=null,r=null,ve()},c=e=>{r=e,be(e,Re(e.role)?.label??B(e.role))},l=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`[data-theme-editor-panel]`)){s();return}o(),n=t,r=null;let a=je(t);if(a){c(a);return}ve(),i=window.setTimeout(()=>{if(i=null,n!==t||!t.isConnected)return;let e=Ne(t);e&&c(e)},140)},u=e=>{e.relatedTarget===null&&s()},d=e=>{let i=e.target;if(!(i instanceof Element)||i.closest(`[data-theme-editor-panel]`))return;e.preventDefault(),e.stopPropagation(),o();let a=n===i&&r?r:Ne(i);a&&(s(),ze(a.role,!0),t=!0)},f=e=>{let n=e.target;n instanceof Element&&!n.closest(`[data-theme-editor-panel]`)&&(e.preventDefault(),e.stopPropagation(),t&&fe(!1),t=!1)},p=e=>{e.key===`Escape`&&(e.preventDefault(),s(),We())},m=()=>{r&&(a??=requestAnimationFrame(()=>{a=null,r&&be(r,Re(r.role)?.label??B(r.role))}))},h=()=>s();return document.addEventListener(`pointerover`,l,!0),document.addEventListener(`pointerout`,u,!0),document.addEventListener(`pointerdown`,d,!0),document.addEventListener(`click`,f,!0),document.addEventListener(`keydown`,p,!0),window.addEventListener(`resize`,m),window.addEventListener(`scroll`,h,!0),()=>{document.removeEventListener(`pointerover`,l,!0),document.removeEventListener(`pointerout`,u,!0),document.removeEventListener(`pointerdown`,d,!0),document.removeEventListener(`click`,f,!0),document.removeEventListener(`keydown`,p,!0),window.removeEventListener(`resize`,m),window.removeEventListener(`scroll`,h,!0),o(),a!==null&&cancelAnimationFrame(a),ve()}},[We,K,e,ze]);let Ke=(0,R.useCallback)(e=>{if(F(e),e||(q&&!Pe.includes(q)&&J(null),!se))return;let t=o&&D(o).length>1?[`light`,`dark`]:[M];oe(e=>{let n={...e};for(let e of t)n[e]=!0;return n}),ae(e=>{let n={...e};for(let r of t)n[r]=He(r,e[r]);return n}),ce(!1)},[M,o,q,se]),qe=()=>{if(!A.trim()){U(`Name your theme first.`);return}try{let e=P?I:{light:V.light?He(`light`,I.light):I.light,dark:V.dark?He(`dark`,I.dark):I.dark},r,i=null,a=null;if(o&&$){let t=D(o),n=t.find(e=>De.includes(e));if(n){U(`“${$.label}” already has a ${n} palette. Pick another name.`);return}i=t[0]??null,r=x({...y({version:1,id:$.id,name:$.label,appearance:$.appearance,colors:$.colors,variants:{...$.variants,...Object.fromEntries(t.map(t=>[t,e[t]]))},...$.managed===!0&&!P?{managed:!0}:{}}),...$.collection?{collection:$.collection}:{}}),a=o;try{g(o.id)}catch(e){try{x($)}catch{}throw e}}else if(o){let t=o.appearance,n=t===`light`?`dark`:`light`;r=x({...y({version:1,id:o.id,name:A,appearance:t,colors:e[t],...D(o).length>1?{variants:{[n]:e[n]}}:{},...P?{}:{managed:!0}}),...o.collection?{collection:o.collection}:{}})}else if($){if(De.includes(M)){U(`“${$.label}” already has light and dark palettes. Pick another name.`);return}i=M,r=x({...y({version:1,id:$.id,name:$.label,appearance:$.appearance,colors:$.colors,variants:{...$.variants,[M]:e[M]},...$.managed===!0&&!P?{managed:!0}:{}}),...$.collection?{collection:$.collection}:{}})}else r=b(y({version:1,name:A,appearance:M,colors:e[M],...P?{}:{managed:!0}}));if(!n(r,{created:o===null&&i===null,...i?{mergedAppearance:i}:{}})){if(!o&&i===null)try{g(r.id)}catch{}else if($&&i!==null)try{x($),a&&b(a)}catch{}U(`Theme saved, but it could not be made active. Try again.`);return}t(!1)}catch(e){U(e instanceof Error?e.message:E?`Could not save the theme.`:`Could not create the theme.`)}},Je=()=>(0,z.jsxs)(`label`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:`Theme name`}),(0,z.jsx)(ie,{autoFocus:!0,size:`sm`,onChange:e=>{j(e.currentTarget.value),U(null)},placeholder:E?`Theme name`:`e.g. Aurora`,value:A})]}),Ye=e=>{let t=ke(e),n=(0,z.jsx)(k,{"aria-disabled":t!==null,value:e,children:e===`light`?`Light`:`Dark`});return t===null?n:(0,z.jsxs)(m,{children:[(0,z.jsx)(u,{render:n}),(0,z.jsx)(p,{children:t})]})},Xe=()=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:`Appearance`}),(0,z.jsxs)(O,{"aria-label":`Theme appearance`,variant:`segmented`,value:[M],onValueChange:e=>{let t=e[0];(t===`light`||t===`dark`)&&ke(t)===null&&N(t)},children:[Ye(`light`),Ye(`dark`)]})]}),Ze=()=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-start gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Colors`}),P?null:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Two colors, rest derived`})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[P?(0,z.jsx)(ie,{"aria-label":`Filter colors`,className:`min-w-0 flex-1`,onChange:e=>de(e.currentTarget.value),placeholder:`Filter colors`,size:`sm`,value:G}):null,(0,z.jsxs)(`label`,{className:`ml-auto flex shrink-0 cursor-pointer items-center gap-2 pt-0.5 text-sm font-medium`,children:[(0,z.jsx)(`span`,{children:`Advanced`}),(0,z.jsx)(L,{"aria-label":`Use advanced theme colors`,checked:P,onCheckedChange:e=>Ke(!!e)})]})]})]}),Qe=(e,t=`grid gap-2 sm:grid-cols-2`)=>(0,z.jsx)(`div`,{className:t,children:e.map(e=>(0,z.jsx)(le,{label:e.label,onChange:Le,onSelect:ze,onToggleSelected:Ue,role:e.role,selected:q===e.role,value:I[M][e.role]},e.id))}),$e=()=>{let e=G.trim().toLowerCase(),t=Fe.map(t=>({...t,families:t.families.filter(t=>!e||[t.label,...t.roles.map(e=>B(e))].join(` `).toLowerCase().includes(e))})).filter(e=>e.families.length>0);return P?(0,z.jsxs)(`div`,{className:`space-y-5`,children:[t.map(e=>(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:e.title}),Qe(e.families,`grid gap-1`)]},e.id)),t.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No matches.`}):null]}):(0,z.jsx)(`div`,{className:`grid gap-1`,children:Pe.map(e=>(0,z.jsx)(le,{onChange:Le,onSelect:ze,onToggleSelected:Ue,role:e,label:e===`canvas`?`Background`:`Accent`,selected:q===e,value:I[M][e]},e))})},et=(e,t,n)=>{let r=Z.current,i=n??r?.offsetWidth??0;return{x:Math.min(Math.max(e,8),Math.max(8,window.innerWidth-i-8)),y:Math.min(Math.max(t,8),Math.max(8,window.innerHeight-48))}},tt=e=>{if(e.target.closest(`button, input, a`))return;let t=Z.current?.getBoundingClientRect();t&&(ye.current={dx:e.clientX-t.x,dy:e.clientY-t.y},e.currentTarget.setPointerCapture(e.pointerId))},nt=e=>{let t=ye.current;t&&me(et(e.clientX-t.dx,e.clientY-t.dy))},rt=()=>{ye.current=null},it=e=>{let t=Z.current?.getBoundingClientRect();t&&(e.preventDefault(),X===null&&me(et(t.x,t.y)),xe.current={pointerX:e.clientX,pointerY:e.clientY,left:t.x,top:t.y,width:t.width,height:t.height},e.currentTarget.setPointerCapture(e.pointerId))},at=e=>{let t=xe.current;if(!t)return;let n=Math.max(280,window.innerWidth-8-t.left),r=Math.max(220,window.innerHeight-8-t.top);ge({width:Math.min(Math.max(t.width+e.clientX-t.pointerX,280),n),height:Math.min(Math.max(t.height+e.clientY-t.pointerY,220),r)})},ot=()=>{xe.current=null};return(0,z.jsxs)(`div`,{"aria-label":E?`Edit theme`:`Create theme`,className:c(`dialog-glass fixed z-[110] flex max-h-[min(42rem,calc(100dvh-6rem))] w-[min(26rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-xl border text-popover-foreground`,X===null&&`bottom-4 right-4`,W&&`max-h-none`),"data-theme-editor-panel":!0,ref:Z,role:`dialog`,style:{...X?{left:X.x,top:X.y}:{},...he?{width:he.width}:{},...he&&!W?{height:he.height,maxHeight:`calc(100dvh - 1rem)`}:{}},children:[(0,z.jsxs)(`div`,{className:`flex cursor-grab touch-none select-none items-center gap-1 border-b border-border/70 px-3 py-2 active:cursor-grabbing`,onPointerCancel:rt,onPointerDown:tt,onPointerMove:nt,onPointerUp:rt,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,z.jsx)(`h2`,{className:`shrink-0 truncate text-sm font-medium`,children:E?`Edit theme`:`Create theme`}),W?null:(0,z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:K?`Select an element · Esc to cancel`:q?`${P?Re(q)?.label??B(q):B(q)} · ${pe??0} ${pe===1?`use`:`uses`}`:`Select a color below`})]}),(0,z.jsxs)(m,{children:[(0,z.jsx)(u,{render:(0,z.jsxs)(s,{"aria-label":K?`Cancel inspecting app colors`:`Inspect app colors`,"aria-pressed":K,size:`xs`,variant:K?`secondary`:`ghost`,onClick:()=>{if(K){We();return}fe(!0)},children:[(0,z.jsx)(a,{}),K?`Cancel`:`Inspect`]})}),(0,z.jsx)(p,{"data-theme-editor-panel":``,children:K?`Cancel and clear the selection`:`Pick a color from the app`})]}),(0,z.jsx)(s,{"aria-label":W?`Expand the theme editor`:`Minimize the theme editor`,size:`icon-xs`,variant:`ghost`,onClick:()=>ue(!W),children:(0,z.jsx)(d,{icon:W?f:h})}),(0,z.jsx)(s,{"aria-label":`Close the theme editor`,size:`icon-xs`,variant:`ghost`,onClick:()=>t(!1),children:(0,z.jsx)(i,{})})]}),W?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-3 pl-3 pr-1.5`,children:[Je(),H?(0,z.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-destructive`,children:H}):null,Xe(),(0,z.jsxs)(`div`,{className:`space-y-3`,children:[Ze(),$e()]})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/70 px-3 py-2`,children:[(0,z.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,z.jsx)(s,{disabled:!A.trim(),size:`sm`,onClick:qe,children:E?$?`Merge into “${$.label}”`:`Save changes`:$?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(r,{}),`Add ${M} palette`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(l,{}),`Create theme`]})})]}),(0,z.jsx)(`div`,{"aria-hidden":!0,className:`absolute bottom-0 right-0 z-10 flex size-5 cursor-se-resize touch-none select-none items-end justify-end p-1 text-muted-foreground/70`,onPointerCancel:ot,onPointerDown:it,onPointerMove:at,onPointerUp:ot,children:(0,z.jsx)(`svg`,{className:`size-2.5`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.2`,viewBox:`0 0 8 8`,children:(0,z.jsx)(`path`,{d:`M7 1 1 7M7 4.5 4.5 7`})})})]})]})}export{Ue as ThemeEditorPanel};
5
- //# sourceMappingURL=ThemeEditorPanel-BiuI7Uiy.js.map
5
+ //# sourceMappingURL=ThemeEditorPanel-i2RAKM6Z.js.map
@@ -1,5 +1,5 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{By as n,Cm as r,Cy as i,Dc as a,E_ as o,Es as s,Iy as c,NE as l,Pp as u,Um as d,Yo as f,__ as p,dm as m,jo as h,lE as g,sm as ee,sr as te,t as _,um as v,vm as y,xy as ne}from"./utils-BEVyjoxo.js";import{R as re,W as ie}from"./runtime-D8mKjOP-.js";import{f as ae,i as oe,m as se}from"./toast-DhMYg_gN.js";import{a as b,n as x,t as S}from"./tooltip-Cq9yz15d.js";import{f as ce}from"./server-CaLEm3Wt.js";import{i as le,n as ue}from"./session-2CRBJwS7.js";import{t as de}from"./use-atom-command-x4GQBtio.js";import{l as fe}from"./rightPanelStore-6-YhsfkE.js";import{a as pe}from"./fileLinks-BYi-XNUG.js";import{R as me,s as he}from"./useSettings-Dx076NWT.js";import{n as ge}from"./toastHelpers-Dsph6LwL.js";import{t as _e}from"./observeResize-D9ECzP-D.js";import{S as ve,c as ye,d as C,n as w,s as T,x as be}from"./browserHistoryStore-DURO3U2L.js";import{S as E,a as xe,c as Se,d as Ce,f as we,l as Te,p as Ee,u as De,x as D}from"./keybindings-BtHOXkP-.js";import{t as Oe}from"./preview-bd-MGMMz.js";import{n as O,r as k}from"./browserLinkTarget-DcGx3A8F.js";import{i as ke,o as A,t as Ae}from"./popover-DE9WCm99.js";import{i as je,n as Me,t as j}from"./terminal-links-CjmSI9gV.js";import{a as Ne,i as Pe,o as M,t as N}from"./terminalSessions-Q2t1JYPS.js";import{t as Fe}from"./terminalLabels-BgLOlb2G.js";import{Da as Ie,Oa as P,Wa as Le,wa as F,xa as Re}from"./main-Bh6Hj0_-.js";var I=e(t(),1),ze=l(),L=e(g(),1);function Be(e){let{bounds:t,selectionRect:n,pointer:r,viewport:i}=e,a=r??{x:n?.right??t.left+t.width-140,y:n?n.bottom+4:t.top+12};return{x:Math.max(8,Math.min(Math.max(t.left,a.x),t.left+t.width,i.width-8)),y:Math.max(8,Math.min(Math.max(t.top,a.y),t.top+t.height,i.height-8))}}function Ve({element:e,getActionElement:t,onSelection:n,onDismiss:r}){let i=e.ownerDocument,a=i.defaultView,o=!1,s=!1,c=!1,l=null,u=null,d=null,f=e=>e!==null&&(t?.()?.contains(e)??!1),p=()=>{u!==null&&a.clearTimeout(u),d!==null&&a.cancelAnimationFrame(d),u=d=null},m=()=>{p(),o=s=!1,l=null,c=!0},h=()=>{m(),r(`cancel`)},g=()=>{m(),r(`interaction`)},ee=e=>{p(),u=a.setTimeout(()=>{u=null,d=a.requestAnimationFrame(()=>{d=null,n(l)})},e)},te=n=>{if(!n.isPrimary)return;if(f(n.target)){m();return}p(),o=n.button===0;let i=e.contains(n.target);s=!1,c=!0,l=null,i?r(`interaction`):t?.()&&r(`cancel`)},_=e=>{e.isPrimary&&(e.target?.closest(`button, [role=button]`)||(s=e.button===0&&!e.defaultPrevented,c=!s))},v=e=>{e.isPrimary&&e.button===0&&(o=!1)},y=e=>{e.button===0&&(o=!1,s&&(s=!1,l={x:e.clientX,y:e.clientY},ee(e.detail>=2?500:0)))},ne=e=>{f(e.target)&&e.key!==`Escape`||(e.key===`Escape`?h():o||(p(),s=!1,l=null,c=!1))},re=e=>{f(e.target)?m():!o&&t?.()&&h()},ie=()=>{p(),o||(l=null,c=!0),r(`cancel`)};return i.addEventListener(`pointerdown`,te,!0),e.addEventListener(`pointerdown`,_),a.addEventListener(`pointerup`,v),a.addEventListener(`mouseup`,y),a.addEventListener(`pointercancel`,h),i.addEventListener(`keydown`,ne),i.addEventListener(`focusin`,re),e.addEventListener(`contextmenu`,g,!0),e.addEventListener(`scroll`,ie,!0),a.addEventListener(`blur`,h),a.addEventListener(`resize`,h),{get pending(){return u!==null||d!==null},cancel:m,selectionChanged(){f(i.activeElement)||(o||s?r(`cancel`):!c&&u===null&&d===null&&ee(0))},dispose(){m(),i.removeEventListener(`pointerdown`,te,!0),e.removeEventListener(`pointerdown`,_),a.removeEventListener(`pointerup`,v),a.removeEventListener(`mouseup`,y),a.removeEventListener(`pointercancel`,h),i.removeEventListener(`keydown`,ne),i.removeEventListener(`focusin`,re),e.removeEventListener(`contextmenu`,g,!0),e.removeEventListener(`scroll`,ie,!0),a.removeEventListener(`blur`,h),a.removeEventListener(`resize`,h)}}}var R=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function z(e){return R.get(e)??0}var He=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),Ue;function We(){if(Ue)return Ue;let e=(globalThis.navigator?.keyboard)?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0);return Ue=e,e}function B(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function V(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=He.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var H=`/assets/ghostty-vt-DdA0Zryv.wasm`,Ge=`/assets/ghostty-write-pty-hgyAvVbe.wasm`,U=new TextDecoder,Ke=class e{memory;layouts;exports;memoryView;ptyWriters=new Map;nextPtyWriterId=1;writePtyFunctionIndex=0;constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export WebAssembly memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(U.decode(r.subarray(n,i)))}static async load(){let t=await fetch(H);if(!t.ok)throw Error(`Unable to load libghostty-vt (${t.status})`);let n,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{if(!n)return;let r=n.exports.memory;if(!(r instanceof WebAssembly.Memory))return;let i=U.decode(new Uint8Array(r.buffer,e,t));console.debug(`[libghostty-vt]`,i)}}});n=r.instance;let i=new e(r.instance);return await i.installWritePtyTrampoline(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is unavailable: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt type layout is unavailable: ${e}`);return t}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt failed to allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt failed to allocate an opaque pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.memoryDataView().getUint32(e,!0)}attachPtyWriter(e,t){if(this.writePtyFunctionIndex===0)throw Error(`libghostty-vt PTY callback trampoline is unavailable`);let n=this.nextPtyWriterId++;return this.ptyWriters.set(n,t),this.call(`ghostty_terminal_set`,e,0,n),this.call(`ghostty_terminal_set`,e,1,this.writePtyFunctionIndex),n}detachPtyWriter(e,t){this.call(`ghostty_terminal_set`,e,1,0),this.call(`ghostty_terminal_set`,e,0,0),this.ptyWriters.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}memoryDataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.layout(t).fields[n];if(!i)throw Error(`libghostty-vt field is unavailable: ${t}.${n}`);let a=this.memoryDataView(),o=e+i.offset;switch(i.type){case`bool`:case`u8`:a.setUint8(o,r);return;case`u16`:a.setUint16(o,r,!0);return;case`i32`:a.setInt32(o,r,!0);return;case`u32`:case`enum`:a.setUint32(o,r,!0);return;case`u64`:a.setBigUint64(o,BigInt(r),!0);return;default:throw Error(`Unsupported libghostty-vt field type: ${i.type}`)}}readField(e,t,n){let r=this.layout(t).fields[n];if(!r)throw Error(`libghostty-vt field is unavailable: ${t}.${n}`);let i=this.memoryDataView(),a=e+r.offset;switch(r.type){case`bool`:case`u8`:return i.getUint8(a);case`u16`:return i.getUint16(a,!0);case`i32`:return i.getInt32(a,!0);case`u32`:case`enum`:return i.getUint32(a,!0);case`u64`:return Number(i.getBigUint64(a,!0));default:throw Error(`Unsupported libghostty-vt field type: ${r.type}`)}}async installWritePtyTrampoline(){let e=await fetch(Ge);if(!e.ok)throw Error(`Unable to load the libghostty-vt PTY trampoline (${e.status})`);let t=(await WebAssembly.instantiate(await e.arrayBuffer(),{env:{t3_write_pty:(e,t,n,r)=>{let i=this.ptyWriters.get(t);i&&r!==0&&i(U.decode(new Uint8Array(this.memory.buffer,n,r)))}}})).instance.exports.ghostty_write_pty,n=this.exports.__indirect_function_table;if(typeof t!=`function`||!(n instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let r=n.length;n.grow(1),n.set(r,t),this.writePtyFunctionIndex=r}},W=null;function G(){return W??=Ke.load().catch(e=>{throw W=null,e}),W}var K=0,qe=-3,Je=1e4,Ye=16,Xe=768,q={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},J={dirty:1,raw:2,cells:3},Y={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},X={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},Ze={wide:3},Qe={narrow:0,wide:1,spacerTail:2,spacerHead:3},$e=new TextDecoder,et=new TextEncoder;function tt(e,t){let n=(e,t)=>Math.floor((e*155+t*100)/255);return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b)}}function nt(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b}function rt(e,t){if(t===1)return String.fromCodePoint(e.getUint32(0,!0));let n=4096,r=``;for(let i=0;i<t;i+=n){let a=Math.min(n,t-i),o=Array(a);for(let t=0;t<a;t+=1)o[t]=e.getUint32((i+t)*4,!0);r+=String.fromCodePoint(...o)}return r}var it=class e{runtime;terminalSlot=0;terminal=0;renderStateSlot=0;renderState=0;rowIteratorSlot=0;rowCellsSlot=0;keyEncoderSlot=0;keyEncoder=0;keyEventSlot=0;keyEvent=0;mouseEncoderSlot=0;mouseEncoder=0;mouseEventSlot=0;mouseEvent=0;ptyWriterId=0;ptyWriter=null;scratch=0;graphemes=0;graphemeCapacity=0;style=0;cellQuery=0;scrollbar=0;rows=[];disposed=!1;keyboardLayoutMap;constructor(e){this.runtime=e,We().then(e=>{this.disposed||(this.keyboardLayoutMap=e)})}static async create(t,n,r,i,a,o){let s=new e(await G());try{return s.initialize(t,n,r,i,a,o),s}catch(e){throw s.dispose(),e}}initialize(e,t,n,r,i,a){let o=this.runtime.layout(`GhosttyTerminalOptions`).size,s=this.runtime.alloc(o);this.runtime.setField(s,`GhosttyTerminalOptions`,`cols`,e),this.runtime.setField(s,`GhosttyTerminalOptions`,`rows`,t),this.runtime.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,Je),this.terminalSlot=this.runtime.allocOpaque();let c=this.runtime.call(`ghostty_terminal_new`,0,this.terminalSlot,s);this.runtime.free(s,o),this.assertSuccess(`ghostty_terminal_new`,c),this.terminal=this.runtime.readPointer(this.terminalSlot),this.applyDefaultCursorBlink(),this.ptyWriter=a,this.ptyWriterId=this.runtime.attachPtyWriter(this.terminal,a),this.renderStateSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_render_state_new`,this.runtime.call(`ghostty_render_state_new`,0,this.renderStateSlot)),this.renderState=this.runtime.readPointer(this.renderStateSlot),this.rowIteratorSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_render_state_row_iterator_new`,this.runtime.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_render_state_row_cells_new`,this.runtime.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.keyEncoderSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_key_encoder_new`,this.runtime.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=this.runtime.readPointer(this.keyEncoderSlot),this.keyEventSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_key_event_new`,this.runtime.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=this.runtime.readPointer(this.keyEventSlot),this.mouseEncoderSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_mouse_encoder_new`,this.runtime.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=this.runtime.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_mouse_event_new`,this.runtime.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=this.runtime.readPointer(this.mouseEventSlot),this.scratch=this.runtime.alloc(16);let l=this.runtime.layout(`GhosttyStyle`).size;this.style=this.runtime.alloc(l),this.runtime.setField(this.style,`GhosttyStyle`,`size`,l),this.cellQuery=this.runtime.alloc(X.size);let u=this.runtime.memoryDataView(),d=[[Y.style,this.style],[Y.graphemesLength,this.cellQuery+X.graphemesLength],[Y.selected,this.cellQuery+X.selected],[Y.background,this.cellQuery+X.background],[Y.foreground,this.cellQuery+X.foreground]];for(let[e,[t,n]]of d.entries())u.setUint32(this.cellQuery+X.keys+e*4,t,!0),u.setUint32(this.cellQuery+X.values+e*4,n,!0);this.scrollbar=this.runtime.alloc(this.runtime.layout(`GhosttyTerminalScrollbar`).size),this.setTheme(i),this.resize(e,t,n,r)}write(e){this.ensureActive();let t=typeof e==`string`?et.encode(e):e;if(t.length===0)return;let n=this.runtime.alloc(t.length);this.runtime.bytes(n,t.length).set(t),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,n,t.length),this.runtime.free(n,t.length)}resetAndWrite(e){if(this.ensureActive(),this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.applyDefaultCursorBlink(),this.rows=[],e.length===0)return;let t=this.ptyWriter;this.ptyWriterId!==0&&(this.runtime.detachPtyWriter(this.terminal,this.ptyWriterId),this.ptyWriterId=0);try{this.write(e)}finally{t!==null&&!this.disposed&&(this.ptyWriterId=this.runtime.attachPtyWriter(this.terminal,t))}}resize(e,t,n,r){this.ensureActive(),this.assertSuccess(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),Math.max(1,Math.round(n)),Math.max(1,Math.round(r))))}applyDefaultCursorBlink(){let e=this.runtime.alloc(1);this.runtime.bytes(e,1)[0]=1,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,e),this.runtime.free(e,1)}setTheme(e){this.ensureActive();let t=this.runtime.alloc(3);for(let[n,r]of[[11,e.foreground],[12,e.background],[13,e.cursor]])this.runtime.bytes(t,3).set([r.r,r.g,r.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n,t);this.runtime.free(t,3),e.palette&&this.setPalette(e.palette)}setPalette(e){let t=this.runtime.alloc(Xe);this.runtime.call(`ghostty_terminal_get`,this.terminal,25,t);let n=this.runtime.bytes(t,Xe);e.slice(0,16).forEach((e,t)=>{n.set([e.r,e.g,e.b],t*3)}),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,t),this.runtime.free(t,Xe)}scroll(e){this.ensureActive();let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=t.fields.value;this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){this.ensureActive();let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}isViewportActive(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_get`,this.terminal,32,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}scrollbarState(){this.ensureActive();let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===K?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_get`,this.terminal,11,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}isMouseAnyEventTracking(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_mode_get`,this.terminal,1003,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}isAlternateScreen(){return this.ensureActive(),this.runtime.bytes(this.scratch,4).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===K&&this.runtime.view(this.scratch,4).getUint32(0,!0)===1}isApplicationCursorKeys(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_mode_get`,this.terminal,1,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}encodeKey(e,t=`press`){this.ensureActive(),this.runtime.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),this.runtime.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),this.runtime.call(`ghostty_key_event_set_key`,this.keyEvent,z(e.code));let n=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);this.runtime.call(`ghostty_key_event_set_mods`,this.keyEvent,n),this.runtime.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,B(e)),this.runtime.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),this.runtime.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,V(e,this.keyboardLayoutMap));let r=e.key.length===1?e.key:``,i=et.encode(r),a=i.length===0?0:this.runtime.alloc(i.length);a!==0&&this.runtime.bytes(a,i.length).set(i),this.runtime.call(`ghostty_key_event_set_utf8`,this.keyEvent,a,i.length);let o=this.runtime.call(`ghostty_wasm_alloc_usize`),s=this.encodeOutput(o,(e,t)=>this.runtime.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,o));return this.runtime.call(`ghostty_wasm_free_usize`,o),a!==0&&this.runtime.free(a,i.length),s}encodePaste(e){this.ensureActive();let t=et.encode(e);if(t.length===0)return``;let n=this.runtime.alloc(t.length);this.runtime.bytes(n,t.length).set(t),this.runtime.bytes(this.scratch,1)[0]=0;let r=this.runtime.call(`ghostty_terminal_mode_get`,this.terminal,2004,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0,i=this.runtime.call(`ghostty_wasm_alloc_usize`),a=``,o=this.runtime.call(`ghostty_paste_encode`,n,t.length,+!!r,0,0,i),s=this.runtime.view(i,4).getUint32(0,!0);if(o===qe&&s>0){let e=this.runtime.alloc(s),o=this.runtime.call(`ghostty_paste_encode`,n,t.length,+!!r,e,s,i),c=this.runtime.view(i,4).getUint32(0,!0);a=o===K?$e.decode(this.runtime.bytes(e,c)):``,this.runtime.free(e,s)}return this.runtime.call(`ghostty_wasm_free_usize`,i),this.runtime.free(n,t.length),a}encodeMouse(e){this.ensureActive(),this.runtime.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let t=this.runtime.layout(`GhosttyMouseEncoderSize`),n=this.runtime.alloc(t.size);for(let[r,i]of[[`size`,t.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,e.paddingTop],[`padding_bottom`,e.paddingBottom],[`padding_right`,e.paddingRight],[`padding_left`,e.paddingLeft]])this.runtime.setField(n,`GhosttyMouseEncoderSize`,r,Math.max(0,Math.round(i)));this.runtime.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,n),this.runtime.free(n,t.size),this.runtime.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,this.runtime.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),this.runtime.bytes(this.scratch,1)[0]=1,this.runtime.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),this.runtime.call(`ghostty_mouse_event_set_action`,this.mouseEvent,e.action===`press`?0:e.action===`release`?1:2),e.button===null?this.runtime.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):this.runtime.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),this.runtime.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let r=this.runtime.layout(`GhosttyMousePosition`),i=this.runtime.alloc(r.size),a=this.runtime.view(i,r.size);a.setFloat32(r.fields.x.offset,e.x,!0),a.setFloat32(r.fields.y.offset,e.y,!0),this.runtime.call(`ghostty_mouse_event_set_position`,this.mouseEvent,i),this.runtime.free(i,r.size);let o=this.runtime.call(`ghostty_wasm_alloc_usize`),s=this.encodeOutput(o,(e,t)=>this.runtime.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,t,o));return this.runtime.call(`ghostty_wasm_free_usize`,o),s}setSelection(e,t){this.ensureActive();let n=this.runtime.layout(`GhosttySelection`),r=this.runtime.layout(`GhosttyGridRef`).size,i=this.runtime.alloc(n.size),a=0,o=0;try{this.runtime.setField(i,`GhosttySelection`,`size`,n.size),a=this.gridRef(e.x,e.y,e.tag??1),o=this.gridRef(t.x,t.y,t.tag??1);let r=n.fields.start,s=n.fields.end;this.runtime.bytes(i+r.offset,r.size).set(this.runtime.bytes(a,r.size)),this.runtime.bytes(i+s.offset,s.size).set(this.runtime.bytes(o,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,i)}finally{this.runtime.free(a,r),this.runtime.free(o,r),this.runtime.free(i,n.size)}}selectAll(){this.ensureActive();let e=this.runtime.layout(`GhosttySelection`),t=this.runtime.alloc(e.size);try{if(this.runtime.setField(t,`GhosttySelection`,`size`,e.size),this.runtime.call(`ghostty_terminal_select_all`,this.terminal,t)!==K)return null;let n=this.pointFromGridRef(t+e.fields.start.offset,2),r=this.pointFromGridRef(t+e.fields.end.offset,2);return!n||!r?null:(this.runtime.call(`ghostty_terminal_set`,this.terminal,21,t),{start:n,end:r})}finally{this.runtime.free(t,e.size)}}selectWord(e,t){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e,t)}selectLine(e,t){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e,t)}hyperlinkAt(e,t){this.ensureActive();let n=this.gridRef(e,t),r=this.runtime.call(`ghostty_wasm_alloc_usize`),i=this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,n,0,0,r),a=this.runtime.view(r,4).getUint32(0,!0),o=null;if(i===qe&&a>0){let e=this.runtime.alloc(a),t=this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,n,e,a,r),i=this.runtime.view(r,4).getUint32(0,!0);t===K&&i>0&&(o=$e.decode(this.runtime.bytes(e,i))),this.runtime.free(e,a)}return this.runtime.call(`ghostty_wasm_free_usize`,r),this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),o}clearSelection(){this.ensureActive(),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}snapshot(){this.ensureActive(),this.assertSuccess(`ghostty_render_state_update`,this.runtime.call(`ghostty_render_state_update`,this.renderState,this.terminal));let e=this.getU16(q.cols),t=this.getU16(q.rows),n=this.getU32(q.dirty),r=this.getColor(q.foreground,{r:229,g:231,b:235}),i=this.getColor(q.background,{r:0,g:0,b:0}),a=this.getBool(q.cursorHasValue)?this.getColor(q.cursor,r):r,o=this.getBool(q.cursorInViewport),s=this.getBool(q.cursorVisible)&&o,c=o?this.getU16(q.cursorX):-1,l=o?this.getU16(q.cursorY):-1;(this.rows.length!==t||this.rows.some(t=>t.cells.length!==e))&&(this.rows=Array.from({length:t},()=>({cells:Array.from({length:e},()=>this.emptyCell(r,i)),text:``,isWrapContinuation:!1,wrapsToNext:!1})));let u=new Set;if(n!==0){this.assertSuccess(`ghostty_render_state_get(row iterator)`,this.runtime.call(`ghostty_render_state_get`,this.renderState,q.rowIterator,this.rowIteratorSlot));let a=this.runtime.readPointer(this.rowIteratorSlot),o=0;for(;o<t&&this.runtime.call(`ghostty_render_state_row_iterator_next`,a)!==0;)(n===2||this.getRowBool(a,J.dirty))&&(this.rows[o]=this.readRow(a,e,r,i),u.add(o),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_set`,a,0,this.scratch)),o+=1;this.runtime.view(this.scratch,4).setUint32(0,0,!0),this.runtime.call(`ghostty_render_state_set`,this.renderState,0,this.scratch)}return{cols:e,rows:t,foreground:r,background:i,cursor:a,cursorX:c,cursorY:l,cursorVisible:s,cursorBlinking:this.getBool(q.cursorBlinking),cursorStyle:this.getU32(q.cursorStyle),dirtyRows:u,rowData:this.rows}}selectionText(){this.ensureActive();let e=this.runtime.alloc(Ye),t=this.runtime.view(e,Ye);t.setUint32(0,Ye,!0),t.setUint32(4,0,!0),t.setUint8(8,1),t.setUint8(9,1),t.setUint32(12,0,!0);let n=this.runtime.call(`ghostty_wasm_alloc_usize`),r=this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,0,0,n),i=this.runtime.view(n,4).getUint32(0,!0),a=``;if(r===qe&&i>0){let t=this.runtime.alloc(i),r=this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,i,n),o=this.runtime.view(n,4).getUint32(0,!0);r===K&&(a=$e.decode(this.runtime.bytes(t,o))),this.runtime.free(t,i)}return this.runtime.call(`ghostty_wasm_free_usize`,n),this.runtime.free(e,Ye),a}viewportPointToScreen(e,t){return this.convertPoint(e,t,1,2)}screenPointToViewport(e,t){return this.convertPoint(e,t,2,1)}convertPoint(e,t,n,r){this.ensureActive();let i=this.gridRef(e,t,n),a=this.pointFromGridRef(i,r);return this.runtime.free(i,this.runtime.layout(`GhosttyGridRef`).size),a}dispose(){if(!this.disposed){if(this.disposed=!0,this.mouseEvent&&this.runtime.call(`ghostty_mouse_event_free`,this.mouseEvent),this.mouseEncoder&&this.runtime.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),this.keyEvent&&this.runtime.call(`ghostty_key_event_free`,this.keyEvent),this.keyEncoder&&this.runtime.call(`ghostty_key_encoder_free`,this.keyEncoder),this.rowCellsSlot){let e=this.runtime.readPointer(this.rowCellsSlot);e&&this.runtime.call(`ghostty_render_state_row_cells_free`,e)}if(this.rowIteratorSlot){let e=this.runtime.readPointer(this.rowIteratorSlot);e&&this.runtime.call(`ghostty_render_state_row_iterator_free`,e)}this.renderState&&this.runtime.call(`ghostty_render_state_free`,this.renderState),this.terminal&&(this.ptyWriterId&&this.runtime.detachPtyWriter(this.terminal,this.ptyWriterId),this.runtime.call(`ghostty_terminal_free`,this.terminal)),this.style&&this.runtime.free(this.style,this.runtime.layout(`GhosttyStyle`).size),this.cellQuery&&this.runtime.free(this.cellQuery,X.size),this.scrollbar&&this.runtime.free(this.scrollbar,this.runtime.layout(`GhosttyTerminalScrollbar`).size),this.scratch&&this.runtime.free(this.scratch,16),this.graphemes&&this.runtime.free(this.graphemes,this.graphemeCapacity);for(let e of[this.mouseEventSlot,this.mouseEncoderSlot,this.keyEventSlot,this.keyEncoderSlot,this.rowCellsSlot,this.rowIteratorSlot,this.renderStateSlot,this.terminalSlot])this.runtime.freeOpaque(e)}}encodeOutput(e,t){let n=t(0,0),r=this.runtime.view(e,4).getUint32(0,!0);if(n===K&&r===0||n!==qe||r===0)return``;let i=this.runtime.alloc(r),a=t(i,r),o=this.runtime.view(e,4).getUint32(0,!0),s=a===K?$e.decode(this.runtime.bytes(i,o)):``;return this.runtime.free(i,r),s}readRow(e,t,n,r){this.assertSuccess(`ghostty_render_state_row_get(raw)`,this.runtime.call(`ghostty_render_state_row_get`,e,J.raw,this.scratch));let i=this.runtime.view(this.scratch,8).getBigUint64(0,!0);this.runtime.bytes(this.scratch+8,1)[0]=0,this.assertSuccess(`ghostty_row_get(wrap continuation)`,this.runtime.call(`ghostty_row_get`,i,2,this.scratch+8));let a=this.runtime.bytes(this.scratch+8,1)[0]!==0;this.runtime.bytes(this.scratch+8,1)[0]=0,this.assertSuccess(`ghostty_row_get(wrap)`,this.runtime.call(`ghostty_row_get`,i,1,this.scratch+8));let o=this.runtime.bytes(this.scratch+8,1)[0]!==0;this.assertSuccess(`ghostty_render_state_row_get(cells)`,this.runtime.call(`ghostty_render_state_row_get`,e,J.cells,this.rowCellsSlot));let s=this.runtime.readPointer(this.rowCellsSlot),{size:c,fields:l}=this.runtime.layout(`GhosttyStyle`),u=[];for(;u.length<t&&this.runtime.call(`ghostty_render_state_row_cells_next`,s)!==0;){this.runtime.bytes(this.style,c).fill(0),this.runtime.setField(this.style,`GhosttyStyle`,`size`,c);let e=this.runtime.call(`ghostty_render_state_row_cells_get_multi`,s,5,this.cellQuery+X.keys,this.cellQuery+X.values,this.cellQuery+X.written),t=this.runtime.memoryDataView(),i=t.getUint32(this.cellQuery+X.written,!0);i<3&&this.assertSuccess(`ghostty_render_state_row_cells_get_multi`,e);let a=t.getUint32(this.cellQuery+X.graphemesLength,!0),o=t.getUint8(this.cellQuery+X.selected)!==0,d=i>=4?this.readColor(this.cellQuery+X.background):r,f=i===5?this.readColor(this.cellQuery+X.foreground):i===3?this.getCellColor(s,Y.foreground,n):n,p=``;if(a>0){let e=a*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=this.runtime.alloc(t);this.runtime.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}this.runtime.call(`ghostty_render_state_row_cells_get`,s,Y.graphemes,this.graphemes)===K&&(p=rt(this.runtime.view(this.graphemes,e),a))}let m=0;if(p.length===0&&u.at(-1)?.text.length){this.assertSuccess(`ghostty_render_state_row_cells_get(raw)`,this.runtime.call(`ghostty_render_state_row_cells_get`,s,Y.raw,this.scratch));let e=this.runtime.view(this.scratch,8).getBigUint64(0,!0);this.runtime.view(this.scratch+8,4).setUint32(0,0,!0),this.assertSuccess(`ghostty_cell_get(wide)`,this.runtime.call(`ghostty_cell_get`,e,Ze.wide,this.scratch+8)),m=this.runtime.view(this.scratch+8,4).getUint32(0,!0)}let h=this.runtime.memoryDataView();h.getUint8(this.style+l.inverse.offset)!==0&&([f,d]=[d,f]),h.getUint8(this.style+l.faint.offset)!==0&&(f=tt(f,d)),u.push({text:p,wide:m,foreground:f,background:d,bold:h.getUint8(this.style+l.bold.offset)!==0,italic:h.getUint8(this.style+l.italic.offset)!==0,invisible:h.getUint8(this.style+l.invisible.offset)!==0,strikethrough:h.getUint8(this.style+l.strikethrough.offset)!==0,overline:h.getUint8(this.style+l.overline.offset)!==0,underline:h.getInt32(this.style+l.underline.offset,!0)!==0,selected:o})}for(;u.length<t;)u.push(this.emptyCell(n,r));return{cells:u,text:u.map(e=>e.text||` `).join(``).trimEnd(),isWrapContinuation:a,wrapsToNext:o}}gridRef(e,t,n=1){let r=this.runtime.layout(`GhosttyPoint`),i=this.runtime.alloc(r.size);this.runtime.setField(i,`GhosttyPoint`,`tag`,n);let a=r.fields.value,o=a.offset,s=this.runtime.view(i+o,a.size);s.setUint16(0,Math.max(0,e),!0),s.setUint32(4,Math.max(0,t),!0);let c=this.runtime.layout(`GhosttyGridRef`).size,l=this.runtime.alloc(c);this.runtime.setField(l,`GhosttyGridRef`,`size`,c);let u=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,i,l);return this.runtime.free(i,r.size),u!==K&&(this.runtime.free(l,c),this.assertSuccess(`ghostty_terminal_grid_ref`,u)),l}selectAt(e,t,n,r){this.ensureActive();let i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=0,c=0,l=null;try{this.runtime.setField(o,e,`size`,i.size),s=this.gridRef(n,r);let u=i.fields.ref;if(this.runtime.bytes(o+u.offset,u.size).set(this.runtime.bytes(s,u.size)),c=this.runtime.alloc(a.size),this.runtime.setField(c,`GhosttySelection`,`size`,a.size),this.runtime.call(t,this.terminal,o,c)===K){let e=c+a.fields.start.offset,t=c+a.fields.end.offset,n=this.pointFromGridRef(e,1),r=this.pointFromGridRef(t,1),i=this.pointFromGridRef(e,2),o=this.pointFromGridRef(t,2);n&&r&&i&&o&&(l={viewport:{start:n,end:r},screen:{start:i,end:o}}),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,c)}}finally{this.runtime.free(c,a.size),this.runtime.free(s,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size)}return l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===K?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}getU16(e){return this.runtime.bytes(this.scratch,2).fill(0),this.assertSuccess(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)),this.runtime.view(this.scratch,2).getUint16(0,!0)}getU32(e){return this.runtime.bytes(this.scratch,4).fill(0),this.assertSuccess(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}getBool(e){return this.runtime.bytes(this.scratch,1)[0]=0,this.assertSuccess(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)),this.runtime.bytes(this.scratch,1)[0]!==0}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)===K?this.readColor(this.scratch):t}getRowBool(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t,n){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,t,this.scratch)===K?this.readColor(this.scratch):n}readColor(e){let t=this.runtime.memoryDataView();return{r:t.getUint8(e),g:t.getUint8(e+1),b:t.getUint8(e+2)}}emptyCell(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:!1,selected:!1}}assertSuccess(e,t){if(t!==K)throw Error(`${e} failed with result ${t}`)}ensureActive(){if(this.disposed)throw Error(`libghostty-vt terminal has been disposed`)}};function at(e,t){return nt(e,t)}var ot=`rgba(72, 122, 191, 0.35)`;function Z(e){return`rgb(${e.r}, ${e.g}, ${e.b})`}function st(e,t){return at(e.foreground,t.foreground)&&e.bold===t.bold&&e.italic===t.italic&&e.invisible===t.invisible}function ct(e,t,n){let r=t+1;for(;r<e.length;){let t=e[r];if(!t)break;if(t.wide===Qe.spacerTail){r+=1;continue}if(t.text.length===0||!n(t))break;r+=1}return r}function lt(e,t,n){return`${e.italic?`italic`:`normal`} ${e.bold?`700`:`400`} ${t}px ${n}`}function ut(e,t,n){e.font=`normal 400 ${t}px ${n}`;let r=e.measureText(`M`),i=e.measureText(`Mg`),a=i.actualBoundingBoxAscent||t,o=a+i.actualBoundingBoxDescent,s=Math.max(1,Math.round(t*1.35),Math.ceil(o));return{width:Math.max(1,r.width),height:s,baseline:Math.round((s-o)/2+a)}}function Q(e,t,n,r){return{cols:Math.max(1,Math.floor((e-r*2)/n.width)),rows:Math.max(1,Math.floor((t-r*2)/n.height))}}function dt(e){let{context:t,snapshot:n,metrics:r,fontSize:i,fontFamily:a,padding:o,forceFull:s,cursorOn:c,previousCursorY:l}=e,u=e.focused??!0,d=e.selectionBackground??ot,f=e.hoveredLinkRange??null,p=e.originY??o,m=s?Array.from({length:n.rows},(e,t)=>t):[...n.dirtyRows];l!=null&&l>=0&&!m.includes(l)&&m.push(l),n.cursorVisible&&n.cursorY>=0&&!m.includes(n.cursorY)&&m.push(n.cursorY),s&&(t.save(),t.resetTransform(),t.fillStyle=Z(n.background),t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore()),t.textBaseline=`alphabetic`;for(let e of m){let s=n.rowData[e];if(!s)continue;let c=p+e*r.height;t.fillStyle=Z(n.background),t.fillRect(o,c,n.cols*r.width,r.height);let l=0;for(;l<s.cells.length;){let e=s.cells[l];if(!e)break;let i=l+1;for(;i<s.cells.length;){let t=s.cells[i];if(!t||t.selected!==e.selected||!at(t.background,e.background))break;i+=1}if(e.selected||!at(e.background,n.background)){let a=o+l*r.width,s=(i-l)*r.width;at(e.background,n.background)||(t.fillStyle=Z(e.background),t.fillRect(a,c,s,r.height)),e.selected&&(t.fillStyle=d,t.fillRect(a,c,s,r.height))}l=i}let u=0;for(;u<s.cells.length;){let e=s.cells[u];if(!e)break;if(e.text.length===0){u+=1;continue}let n=ct(s.cells,u,t=>st(t,e)),l=s.cells.slice(u,n).map(e=>e.text).join(``);!e.invisible&&l.trim().length>0&&(t.save(),t.beginPath(),t.rect(o+u*r.width,c,(n-u)*r.width,r.height),t.clip(),t.font=lt(e,i,a),t.fillStyle=Z(e.foreground),t.fillText(l,o+u*r.width,c+r.baseline,(n-u)*r.width),t.restore()),u=n}for(let n=0;n<s.cells.length;n+=1){let i=s.cells[n],a=f!==null&&e>=f.start.y&&e<=f.end.y&&(e>f.start.y||n>=f.start.x)&&(e<f.end.y||n<=f.end.x);if(!i||!i.underline&&!i.strikethrough&&!i.overline&&!a)continue;t.fillStyle=Z(i.foreground);let l=o+n*r.width;(i.underline||a)&&t.fillRect(l,c+r.height-2,r.width,1),i.strikethrough&&t.fillRect(l,c+Math.floor(r.height*.55),r.width,1),i.overline&&t.fillRect(l,c+1,r.width,1)}}if(c&&n.cursorVisible&&n.cursorX>=0&&n.cursorY>=0){let e=o+n.cursorX*r.width,s=p+n.cursorY*r.height;if(t.fillStyle=Z(n.cursor),!u)t.strokeStyle=Z(n.cursor),t.strokeRect(e+.5,s+.5,r.width-1,r.height-1);else if(n.cursorStyle===0)t.fillRect(e,s,2,r.height);else if(n.cursorStyle===2)t.fillRect(e,s+r.height-2,r.width,2);else if(n.cursorStyle===3)t.strokeStyle=Z(n.cursor),t.strokeRect(e+.5,s+.5,r.width-1,r.height-1);else{t.fillRect(e,s,r.width,r.height);let o=n.rowData[n.cursorY]?.cells[n.cursorX];o?.text&&(t.font=lt(o,i,a),t.fillStyle=Z(n.background),t.fillText(o.text,e,s+r.baseline,r.width))}}}var ft=`/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2`,pt=6,mt=32,ht=`"Symbols Nerd Font Mono", "Symbols Nerd Font", "JetBrainsMono Nerd Font", "JetBrainsMono NF", "FiraCode Nerd Font", "Hack Nerd Font", "MesloLGS NF", "CaskaydiaCove Nerd Font", "PowerlineSymbols", monospace`,gt=`"SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", `+ht,$=4,_t=18,vt=500,yt=`iMW0@# .`,bt=[`normal 400`,`normal 700`,`italic 400`,`italic 700`],xt=null;function St(){return xt===null&&(xt=(async()=>{try{let e=new FontFace(`Symbols Nerd Font Mono`,`url(${ft})`);document.fonts.add(await e.load())}catch{}})()),xt}function Ct(e){return e.split(`,`).map(e=>{let t=e.trim();return t.length===0?``:/^(['"]).*\1$/.test(t)||/^[a-zA-Z][a-zA-Z0-9-]*$/.test(t)?t:`"${t.replaceAll(`"`,``)}"`}).filter(e=>e.length>0).join(`, `)}function wt(e){let t=e===void 0?``:Ct(e);return t.length===0?gt:`${t}, ${ht}`}function Tt(e){let t=e===void 0?``:Ct(e);return t.length===0||!F(t)?gt:wt(t)}async function Et(e,t,n){let r=wt(e),i=n?.load??((e,t)=>document.fonts.load(e,t));try{await Promise.all(bt.map(e=>i(`${e} ${t}px ${r}`,yt)))}catch{}return(n?.resolve??Tt)(e)}function Dt(e){return e===void 0||!Number.isFinite(e)?12:Math.max(pt,Math.min(mt,Math.round(e)))}function Ot(e){return e.focused&&e.cursorBlinking&&e.cursorVisible&&!e.reducedMotion}function kt(e,t,n,r,i){if(!i)return t;let a=e-t*2-n*r;return t+Math.max(0,a)}function At(e,t){let n=Math.max(0,e.total),r=Math.max(0,Math.min(e.len,n)),i=Math.max(0,n-r);if(t<=0||r<=0||i===0)return null;let a=Math.min(t,Math.max(_t,t*r/n));return{thumbHeight:a,thumbTop:Math.max(0,t-a)*(Math.max(0,Math.min(e.offset,i))/i),maxOffset:i}}function jt(e,t,n,r){let i=At(e,t);if(i===null)return 0;let a=Math.max(0,t-i.thumbHeight);if(a===0)return 0;let o=Math.max(0,Math.min(n-r,a));return Math.round(o/a*i.maxOffset)}function Mt(e){let{bounds:t,clientX:n,clientY:r,cols:i,rows:a,metrics:o,padding:s,originY:c}=e,l=n-t.left-s,u=r-t.top-c;return l<0||u<0||l>=i*o.width||u>=a*o.height?null:{x:Math.floor(l/o.width),y:Math.floor(u/o.height)}}function Nt(e,t){let n=e.cells.map(e=>e.text||` `).join(``);return t?n.trimEnd():n}function Pt(e,t){let n=0;for(let r=0;r<t;r+=1)n+=e.cells[r]?.text.length||1;return n}function Ft(e,t){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}function It(e,t){for(let n=0;n<e.cells.length;n+=1)if(t<Pt(e,n+1))return n;return Math.max(0,e.cells.length-1)}function Lt(e,t,n){let r=j(t+1,t=>{let n=e[t];return n?{isWrapped:n.isWrapContinuation,translateToString:(e=!1)=>Nt(n,e)}:null});if(!r)return null;let i=r.segments[0];if(i&&e[i.bufferLineNumber-1]?.isWrapContinuation)return null;let a=r.segments.find(e=>e.bufferLineNumber===t+1),o=e[t];if(!a||!o)return null;let s=r.segments.at(-1),c=s?e[s.bufferLineNumber-1]:void 0,l=c!==void 0&&c.wrapsToNext,u=a.startIndex+Pt(o,n);for(let t of Me(r.text))if(u>=t.start&&u<t.end){if(t.end===r.text.length&&l)return null;let n=r.segments.find(e=>t.start>=e.startIndex&&t.start<e.endIndex),i=r.segments.find(e=>t.end-1>=e.startIndex&&t.end-1<e.endIndex),a=n?e[n.bufferLineNumber-1]:void 0,o=i?e[i.bufferLineNumber-1]:void 0;return!n||!i||!a||!o?null:{text:t.text,range:{start:{x:It(a,t.start-n.startIndex),y:n.bufferLineNumber-1},end:{x:It(o,t.end-1-i.startIndex),y:i.bufferLineNumber-1}}}}return null}function Rt(e,t=navigator.platform){let n=e.key.toLowerCase();return n===`insert`&&!a(t)?e.ctrlKey&&!e.shiftKey&&!e.metaKey:n===`c`?a(t)?e.metaKey:e.ctrlKey:!1}function zt(e,t){e.value=t,t.length!==0&&e.select()}function Bt(e,t){t.length!==0&&e.value===t&&(e.value=``)}function Vt(e,t){return e.length===0||!t?{preventDefault:!1,claimWriteFallback:!1}:(t.setData(`text/plain`,e),{preventDefault:!0,claimWriteFallback:!0})}function Ht(e,t=navigator.platform){let n=e.key.toLowerCase();return n===`insert`&&!a(t)?e.shiftKey&&!e.ctrlKey&&!e.metaKey:n===`v`?a(t)?e.metaKey:e.ctrlKey&&e.shiftKey:!1}function Ut(){return/linux|bsd/i.test(navigator.platform)}function Wt(e){return e.inputType===``||e.inputType===`insertCompositionText`||e.inputType===`insertFromComposition`}function Gt(e,t){return e.isComposing||t||e.key===`Process`||e.keyCode===229}function Kt(e){return e.getModifierState(`AltGraph`)&&[...e.key].length===1}function qt(e,t){return e&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey}function Jt(e,t,n){let r=e===`motion`?t:``;return{send:t.length>0&&(e!==`motion`||t!==n),nextMotionData:r}}function Yt(e,t,n){return{tracking:t,motionData:e===t?n:``}}function Xt(e,t,n,r){let i=r+(e.deltaMode===1?e.deltaY*t:e.deltaMode===2?e.deltaY*n*t:e.deltaY)/t,a=Math.trunc(i);return{rows:a,remainder:i-a}}function Zt(e,t){return e===0?``:(e<0?t?`\x1BOA`:`\x1B[A`:t?`\x1BOB`:`\x1B[B`).repeat(Math.abs(e))}function Qt(e){switch(e){case 0:return 1;case 1:return 3;case 2:return 2;case 3:return 4;case 4:return 5;default:return null}}var $t=4;function en(e,t){return{count:e!==null&&t.timeStamp-e.time<=500&&Math.hypot(t.clientX-e.x,t.clientY-e.y)<=$t?e.count>=3?1:e.count+1:1,time:t.timeStamp,x:t.clientX,y:t.clientY}}var tn=class e{canvas;input;scrollbar;cols=1;rows=1;mount;context;core;options;visible;hasSize=!1;metrics;fontFamily;requestedFontFamily;fontSize;fontEpoch=0;pendingFontEpoch=null;stopObservingResize;scrollbarThumb;snapshot=null;frame=0;cursorTimer=null;compositionInputToSuppress=null;compositionSuppressionTimer=null;cursorOn=!0;renderedCursorY=null;forceFullRender=!0;scrollbarDirty=!0;scrollbarState=null;scrollbarPointerId=null;scrollbarPointerOffset=0;disposed=!1;resizeNotifyTimer=null;originY=$;mountHeight=0;selectionEnd=null;selectionAnchorScreen=null;selectionEndScreen=null;selectionMode=`cell`;selectionBase=null;selectionScrollTimer=null;selectionScrollDelta=0;selectionPointer=null;mouseReportingPointerId=null;mouseReportingButton=null;linkActivationPointerId=null;linkActivationLink=null;linkActivationOrigin=null;hoveredLink=null;hoverPointer=null;selectionClickSequence=null;selectionMoved=!1;composing=!1;focused=!1;resizeNotified=!1;canvasConfigured=!1;theme;suppressedKeyCodes=new Set;pasteShortcutToken=0;copyShortcutToken=0;clearSelectionAfterCopy=!1;primedCopySelection=``;wheelRemainder=0;touchScroll=null;lastMouseMotionData=``;mouseAnyEventTracking=!1;dprMedia=null;reducedMotionMedia=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);inputLeft=-1;inputTop=-1;constructor(e,t,n,r,i,a,o,s,c,l){this.mount=e,this.canvas=t,this.input=n,this.scrollbar=r,this.scrollbarThumb=i,this.context=a,this.core=o,this.mouseAnyEventTracking=o.isMouseAnyEventTracking(),this.metrics=s,this.options=l,this.visible=l.visible??!0,this.theme=l.theme,this.fontFamily=c,this.requestedFontFamily=l.font?.family,this.fontSize=Dt(l.font?.size),this.installEvents(),this.watchDevicePixelRatio(),this.reducedMotionMedia?.addEventListener(`change`,this.onReducedMotionChange),document.fonts.addEventListener(`loadingdone`,this.onFontsLoaded),this.stopObservingResize=_e(e,()=>this.fit())}static async create(t,n){let r=document.createElement(`canvas`);r.className=`block size-full cursor-text`,r.style.touchAction=`pan-x pinch-zoom`,r.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`textarea`);i.className=`t3-ghostty-input`,i.setAttribute(`aria-label`,`Terminal input`),i.autocapitalize=`off`,i.autocomplete=`off`,i.spellcheck=!1,i.style.cssText=`position:absolute;left:4px;top:4px;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;`;let a=document.createElement(`div`);a.className=`group absolute top-1 right-px bottom-1 z-1 w-[var(--app-scrollbar-width)] cursor-default touch-none`,a.setAttribute(`role`,`scrollbar`),a.setAttribute(`aria-label`,`Terminal scrollback`),a.setAttribute(`aria-orientation`,`vertical`),a.tabIndex=0,a.hidden=!0;let o=document.createElement(`div`);o.className=`absolute inset-x-px top-0 rounded-[3px] bg-[var(--app-scrollbar-thumb)] transition-[background-color] duration-[120ms] ease-[ease-out] group-hover:bg-[var(--app-scrollbar-thumb-hover)] group-focus-visible:bg-[var(--app-scrollbar-thumb-hover)]`,a.append(o),t.replaceChildren(r,i,a);let s=r.getContext(`2d`,{alpha:!1});if(!s)throw Error(`Canvas 2D is unavailable`);s.fillStyle=`rgb(${n.theme.background.r}, ${n.theme.background.g}, ${n.theme.background.b})`,s.fillRect(0,0,r.width,r.height);let c=Dt(n.font?.size);try{await St()}catch{}let l=await Et(n.font?.family,c),u=ut(s,c,l),d=Q(t.clientWidth,t.clientHeight,u,$),f=await it.create(d.cols,d.rows,u.width,u.height,n.theme,n.onData),p=new e(t,r,i,a,o,s,f,u,l,n);return p.fit(),p}setVisible(e){if(!(this.disposed||this.visible===e)){if(this.visible=e,this.cursorOn=!0,this.forceFullRender=!0,this.scrollbarDirty=!0,!e){this.cancelRender(),this.setSelectionAutoscroll(0);return}this.fit()}}write(e){this.disposed||(this.core.write(e),this.synchronizeMouseTrackingState(),this.cursorOn=!0,this.scrollbarDirty=!0,this.requestRender())}resetAndWrite(e){this.disposed||(this.lastMouseMotionData=``,this.core.resetAndWrite(e),this.synchronizeMouseTrackingState(),this.cursorOn=!0,this.forceFullRender=!0,this.scrollbarDirty=!0,this.requestRender())}setTheme(e){this.disposed||(this.theme=e,this.core.setTheme(e),this.forceFullRender=!0,this.requestRender())}refreshLinkActivation(){this.disposed||this.refreshHoveredLink()}async setFont(e){if(this.disposed)return;let t=Dt(e.size),n=++this.fontEpoch;this.pendingFontEpoch=n;let r=await Et(e.family,t);this.disposed||n!==this.fontEpoch||(this.pendingFontEpoch=null,this.fontFamily=r,this.requestedFontFamily=e.family,this.fontSize=t,this.applyFontMetrics())}applyFontMetrics(){this.metrics=ut(this.context,this.fontSize,this.fontFamily),this.core.resize(this.cols,this.rows,this.metrics.width,this.metrics.height),this.inputLeft=-1,this.inputTop=-1,this.forceFullRender=!0,this.scrollbarDirty=!0,this.fit(),this.requestRender()}onReducedMotionChange=()=>{this.disposed||(this.cursorOn=!0,this.requestRender())};onFontsLoaded=()=>{if(this.disposed||this.pendingFontEpoch!==null)return;let e=Tt(this.requestedFontFamily);if(e!==this.fontFamily){this.fontFamily=e,this.applyFontMetrics();return}let t=ut(this.context,this.fontSize,this.fontFamily);(t.width!==this.metrics.width||t.height!==this.metrics.height||t.baseline!==this.metrics.baseline)&&this.applyFontMetrics()};resendSize(){this.resizeNotified=!1,this.fit()}fit(){if(this.disposed||!this.visible)return!1;let e=this.mount.clientWidth,t=this.mount.clientHeight;if(e<=0||t<=0)return this.hasSize=!1,this.forceFullRender=!0,this.cancelRender(),!1;this.hasSize=!0;let n=window.devicePixelRatio||1,r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n)),a=!1;(this.canvas.width!==r||this.canvas.height!==i||!this.canvasConfigured)&&(this.canvas.width=r,this.canvas.height=i,this.context.setTransform(n,0,0,n,0,0),this.canvasConfigured=!0,this.forceFullRender=!0,this.scrollbarDirty=!0,a=!0);let o=Q(e,t,this.metrics,$);return this.mountHeight=t,(o.cols!==this.cols||o.rows!==this.rows||!this.resizeNotified)&&(this.cols=o.cols,this.rows=o.rows,this.core.resize(o.cols,o.rows,this.metrics.width,this.metrics.height),this.notifyResize(),this.forceFullRender=!0,this.scrollbarDirty=!0,a=!0),(a||this.forceFullRender)&&this.renderFrame(),!0}notifyResize(){this.resizeNotified=!0,this.resizeNotifyTimer!==null&&window.clearTimeout(this.resizeNotifyTimer),this.resizeNotifyTimer=window.setTimeout(()=>{this.resizeNotifyTimer=null,this.disposed||this.options.onResize(this.cols,this.rows)},150)}onWindowPointerRelease=()=>{this.disposed||this.resizeNotifyTimer===null||(this.fit(),this.resizeNotifyTimer!==null&&(window.clearTimeout(this.resizeNotifyTimer),this.resizeNotifyTimer=null,this.options.onResize(this.cols,this.rows)))};focus(){!this.disposed&&this.visible&&this.input.focus({preventScroll:!0})}async pasteFromClipboard(e,t=()=>!0){let n=++this.pasteShortcutToken,r=await e();if(this.disposed||this.pasteShortcutToken!==n||!t()||(this.pasteShortcutToken+=1,r.length===0))return;let i=this.core.encodePaste(r);i.length>0&&this.options.onData(i)}pasteTerminalSelection(){let e=this.getSelection();e.length!==0&&this.pasteFromClipboard(()=>Promise.resolve(e))}hasSelection(){return this.core.selectionText().length>0}getSelection(){return this.core.selectionText()}selectAll(){this.clearPrimedCopy();let e=this.core.selectAll();this.selectionAnchorScreen=e?.start??null,this.selectionEndScreen=e?.end??null,this.selectionEnd=e?this.core.screenPointToViewport(e.end.x,e.end.y):null,this.selectionMode=`cell`,this.selectionBase=null,this.setSelectionAutoscroll(0),this.options.onSelectionChange(),this.forceFullRender=!0,this.requestRender()}getSelectionPosition(){return!this.selectionAnchorScreen||!this.selectionEndScreen||!this.hasSelection()?null:this.selectionAnchorScreen.y<this.selectionEndScreen.y||this.selectionAnchorScreen.y===this.selectionEndScreen.y&&this.selectionAnchorScreen.x<=this.selectionEndScreen.x?{start:this.selectionAnchorScreen,end:this.selectionEndScreen}:{start:this.selectionEndScreen,end:this.selectionAnchorScreen}}getSelectionEndClientRect(){let e=this.getSelectionPosition();if(!e)return null;let t=this.core.screenPointToViewport(e.end.x,e.end.y);if(!t||t.x<0||t.x>=this.cols||t.y<0||t.y>=this.rows)return null;let n=this.canvas.getBoundingClientRect();return{right:n.left+$+(t.x+1)*this.metrics.width,bottom:n.top+this.originY+(t.y+1)*this.metrics.height}}clearSelection(){this.clearPrimedCopy(),this.core.clearSelection(),this.selectionEnd=null,this.selectionAnchorScreen=null,this.selectionEndScreen=null,this.selectionMode=`cell`,this.selectionBase=null,this.setSelectionAutoscroll(0),this.options.onSelectionChange(),this.forceFullRender=!0,this.requestRender()}scrollToBottom(){this.core.scrollToBottom(),this.forceFullRender=!0,this.scrollbarDirty=!0,this.requestRender()}isAtBottom(){return this.core.isViewportActive()}dispose(){this.disposed||(this.disposed=!0,this.stopObservingResize(),document.fonts.removeEventListener(`loadingdone`,this.onFontsLoaded),this.dprMedia?.removeEventListener(`change`,this.onDevicePixelRatioChange),this.dprMedia=null,this.reducedMotionMedia?.removeEventListener(`change`,this.onReducedMotionChange),this.selectionScrollTimer!==null&&window.clearInterval(this.selectionScrollTimer),this.resizeNotifyTimer!==null&&(window.clearTimeout(this.resizeNotifyTimer),this.resizeNotifyTimer=null,this.options.onResize(this.cols,this.rows)),this.cancelRender(),this.compositionSuppressionTimer!==null&&window.clearTimeout(this.compositionSuppressionTimer),this.removeEvents(),this.core.dispose(),(this.canvas.parentElement===this.mount||this.input.parentElement===this.mount||this.scrollbar.parentElement===this.mount)&&(this.canvas.remove(),this.input.remove(),this.scrollbar.remove()))}onKeyDown=e=>{if(Kt(e)||!this.options.beforeKey(e)){this.suppressedKeyCodes.add(e.code);return}if(Gt(e,this.composing)){this.suppressedKeyCodes.add(e.code);return}let t=a(navigator.platform),n=t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey;if(e.key.toLowerCase()===`a`&&n&&!e.altKey&&(t?!e.shiftKey:e.shiftKey)){e.preventDefault(),e.stopPropagation(),this.suppressedKeyCodes.add(e.code),this.selectAll();return}let r=e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&(e.key===`PageUp`||e.key===`PageDown`),i=e.shiftKey&&!e.altKey&&n&&(e.key===`Home`||e.key===`End`);if((r||i)&&!this.core.isAlternateScreen()){let t=this.readScrollbarState();if(t!==null){e.preventDefault(),e.stopPropagation(),this.suppressedKeyCodes.add(e.code);let n=e.key===`Home`?-t.offset:e.key===`End`?t.total-t.len-t.offset:Math.max(1,t.len)*(e.key===`PageUp`?-1:1);this.scrollViewport(n);return}}if(Rt(e)&&this.hasSelection()){let t=this.getSelection();if(this.primeCopy(t),e.shiftKey||e.key.toLowerCase()===`insert`)e.preventDefault(),document.execCommand(`copy`);else{this.clearSelectionAfterCopy=!e.shiftKey&&!a(navigator.platform);let n=navigator.clipboard;if(typeof n?.writeText==`function`){let e=++this.copyShortcutToken;Promise.resolve().then(()=>{this.disposed||this.copyShortcutToken!==e||n.writeText(t).then(()=>{this.disposed||this.copyShortcutToken!==e||this.clearSelectionAfterCopy&&(this.clearSelectionAfterCopy=!1,this.clearSelection())},()=>{this.copyShortcutToken===e&&(this.clearSelectionAfterCopy=!1)})})}}this.suppressedKeyCodes.add(e.code);return}if(Ht(e)){this.suppressedKeyCodes.add(e.code);let t=navigator.clipboard;if(typeof t?.readText==`function`){let e=++this.pasteShortcutToken;t.readText().then(t=>{this.disposed||this.pasteShortcutToken!==e||(this.pasteShortcutToken+=1,t.length>0&&this.options.onData(this.core.encodePaste(t)))},()=>{})}return}this.clearPrimedCopy();let o=this.core.encodeKey(e);o.length!==0&&(this.suppressedKeyCodes.delete(e.code),e.preventDefault(),e.stopPropagation(),this.options.onData(o))};onKeyUp=e=>{if(this.suppressedKeyCodes.delete(e.code)||Gt(e,this.composing))return;let t=this.core.encodeKey(e,`release`);t.length!==0&&(e.preventDefault(),e.stopPropagation(),this.options.onData(t))};onFocus=()=>{this.focused=!0,this.cursorOn=!0,this.requestRender()};onBlur=()=>{this.focused=!1,this.refreshHoveredLink(),this.cursorOn=!0,this.requestRender()};onDevicePixelRatioChange=()=>{this.watchDevicePixelRatio(),this.fit()};watchDevicePixelRatio(){this.dprMedia?.removeEventListener(`change`,this.onDevicePixelRatioChange),this.dprMedia=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.dprMedia.addEventListener(`change`,this.onDevicePixelRatioChange)}primeCopy(e){this.primedCopySelection=e,zt(this.input,e)}clearPrimedCopy(){Bt(this.input,this.primedCopySelection),this.primedCopySelection=``}onCopyEvent=e=>{let t=this.hasSelection()?this.getSelection():this.input.value;this.primeCopy(t);let n=Vt(t,e.clipboardData);n.preventDefault&&e.preventDefault(),n.claimWriteFallback&&(this.copyShortcutToken+=1,this.clearSelectionAfterCopy&&(this.clearSelectionAfterCopy=!1,this.clearSelection()))};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;t.length!==0&&(this.pasteShortcutToken+=1,this.options.onData(this.core.encodePaste(t)))};onCompositionStart=()=>{this.clearPrimedCopy(),this.clearCompositionInputSuppression(),this.composing=!0};onCompositionEnd=e=>{this.composing=!1;let t=this.input.value||e.data;t.length>0&&this.options.onData(t),this.input.value=``,this.compositionInputToSuppress=t,this.compositionSuppressionTimer=window.setTimeout(()=>{this.compositionInputToSuppress=null,this.compositionSuppressionTimer=null},100)};onInput=e=>{let t=e;if(this.composing||t.isComposing)return;let n=this.input.value||t.data||``;if(n===this.compositionInputToSuppress&&Wt(t)){this.clearCompositionInputSuppression(),this.input.value=``;return}this.clearCompositionInputSuppression(),n.length>0&&this.options.onData(n),this.input.value=``};clearCompositionInputSuppression(){this.compositionSuppressionTimer!==null&&(window.clearTimeout(this.compositionSuppressionTimer),this.compositionSuppressionTimer=null),this.compositionInputToSuppress=null}onPointerDown=e=>{if(e.pointerType===`touch`){if(e.preventDefault(),!e.isPrimary||this.touchScroll!==null)return;this.touchScroll={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,lastY:e.clientY,remainder:0,moved:!1},this.clearHoveredLink(),this.canvas.setPointerCapture(e.pointerId);return}if(this.focus(),qt(this.core.isMouseTracking(),e)){let t=Qt(e.button);if(t===null)return;e.preventDefault(),e.stopPropagation(),this.clearHoveredLink(`default`),this.mouseReportingPointerId=e.pointerId,this.mouseReportingButton=t,this.sendMouse(`press`,t,e),this.canvas.setPointerCapture(e.pointerId);return}if(e.button===1&&Ut()){this.pasteTerminalSelection();return}if(e.button!==0)return;let t=this.recordSelectionClick(e),n=this.linkAt(e.clientX,e.clientY);if(n&&!e.shiftKey&&t===1){e.preventDefault(),e.stopPropagation(),this.linkActivationPointerId=e.pointerId,this.linkActivationLink=n,this.linkActivationOrigin={x:e.clientX,y:e.clientY,clickCount:t},this.canvas.setPointerCapture(e.pointerId);return}this.clearHoveredLink(),this.beginSelection(e,t),this.canvas.setPointerCapture(e.pointerId)};recordSelectionClick(e){return this.selectionClickSequence=en(this.selectionClickSequence,e),this.selectionClickSequence.count}beginSelection(e,t){let n=this.cellAt(e.clientX,e.clientY);this.selectionMoved=!1,this.selectionMode=t>=3?`line`:t===2?`word`:`cell`;let r=this.selectionMode===`line`?this.core.selectLine(n.x,n.y):this.selectionMode===`word`?this.core.selectWord(n.x,n.y):null;if(r)this.selectionBase=r.screen,this.selectionEnd=r.viewport.end,this.selectionAnchorScreen=r.screen.start,this.selectionEndScreen=r.screen.end,this.options.onSelectionChange();else{this.selectionMode=`cell`,this.selectionBase=null,this.selectionEnd=n;let e=this.core.viewportPointToScreen(n.x,n.y);this.selectionAnchorScreen=e,this.selectionEndScreen=e,e?this.core.setSelection({...e,tag:2},{...e,tag:2}):this.core.setSelection(n,n)}this.forceFullRender=!0,this.requestRender()}onPointerMove=e=>{if(e.pointerType===`touch`){let t=this.touchScroll;if(t?.pointerId!==e.pointerId||(e.preventDefault(),t.moved||=Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>$t,!t.moved))return;let n=Xt({deltaY:t.lastY-e.clientY,deltaMode:0},this.metrics.height,this.rows,t.remainder);t.lastY=e.clientY,t.remainder=n.remainder,this.scrollRows(n.rows,e);return}if(this.linkActivationPointerId===e.pointerId){let t=this.linkActivationOrigin;if(t===null||Math.hypot(e.clientX-t.x,e.clientY-t.y)<=$t)return;this.linkActivationPointerId=null,this.linkActivationLink=null,this.linkActivationOrigin=null,this.clearHoveredLink(),this.beginSelection({clientX:t.x,clientY:t.y},t.clickCount)}let t=this.synchronizeMouseTrackingState();if(this.mouseReportingPointerId===e.pointerId||qt(t,e)){e.preventDefault(),this.hoverPointer={x:e.clientX,y:e.clientY},this.setHoveredLink(null),this.canvas.style.cursor=`default`,this.sendMouse(`motion`,this.buttonFromButtons(e.buttons),e);return}if(this.lastMouseMotionData=``,!this.selectionAnchorScreen||!this.canvas.hasPointerCapture(e.pointerId)){this.updateHoverCursor(e);return}this.clearHoveredLink(),this.selectionPointer={x:e.clientX,y:e.clientY};let n=this.canvas.getBoundingClientRect(),r=Math.max(n.top,0)+$,i=Math.min(n.bottom,window.innerHeight)-$;this.setSelectionAutoscroll(e.clientY<r?-1:+(e.clientY>i));let a=this.cellAt(e.clientX,e.clientY);(a.x!==this.selectionEnd?.x||a.y!==this.selectionEnd.y)&&this.extendSelectionTo(e.clientX,e.clientY)};extendSelectionTo(e,t){let n=this.selectionAnchorScreen;if(n===null)return;let r=this.cellAt(e,t);this.selectionMoved=!0,this.selectionEnd=r;let i=this.selectionMode===`line`?this.core.selectLine(r.x,r.y):this.selectionMode===`word`?this.core.selectWord(r.x,r.y):null,a=this.core.viewportPointToScreen(r.x,r.y);if(a===null)return;let o=this.selectionBase,s=o!==null&&(a.y<o.start.y||a.y===o.start.y&&a.x<o.start.x),c=o===null?n:s?o.end:o.start,l=i===null?a:s?i.screen.start:i.screen.end;this.selectionAnchorScreen=c,this.selectionEndScreen=l,this.core.setSelection({...c,tag:2},{...l,tag:2}),this.options.onSelectionChange(),this.forceFullRender=!0,this.requestRender()}setSelectionAutoscroll(e){if(this.selectionScrollDelta=e,e===0){this.selectionScrollTimer!==null&&(window.clearInterval(this.selectionScrollTimer),this.selectionScrollTimer=null);return}this.selectionScrollTimer===null&&(this.selectionScrollTimer=window.setInterval(()=>{if(this.disposed||this.selectionScrollDelta===0)return;this.scrollViewport(this.selectionScrollDelta);let e=this.selectionPointer;e&&this.extendSelectionTo(e.x,e.y)},80))}updateHoverCursor(e){this.hoverPointer={x:e.clientX,y:e.clientY},this.refreshHoveredLink()}onPointerLeave=()=>{this.lastMouseMotionData=``,this.clearHoveredLink()};clearHoveredLink(e=``){this.hoverPointer=null,this.setHoveredLink(null),this.canvas.style.cursor=e}refreshHoveredLink(){let e=this.hoverPointer,t=e?this.linkAt(e.x,e.y):null;this.setHoveredLink(t)}setHoveredLink(e){let t=this.hoveredLink,n=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;this.canvas.style.cursor=e?`pointer`:``,!n&&(this.hoveredLink=e,this.forceFullRender=!0,this.requestRender())}onPointerUp=e=>{if(e.pointerType===`touch`){let t=this.touchScroll;if(t?.pointerId!==e.pointerId||(this.touchScroll=null,e.preventDefault(),this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.type===`pointercancel`||t.moved))return;if(this.focus(),qt(this.core.isMouseTracking(),e))this.sendMouse(`press`,Qt(0),e),this.sendMouse(`release`,Qt(0),e);else{let t=this.linkAt(e.clientX,e.clientY);t?this.options.onLinkActivate(t.text,e):this.clearSelection()}return}if(this.setSelectionAutoscroll(0),this.linkActivationPointerId===e.pointerId){e.preventDefault(),e.stopPropagation();let t=this.linkActivationLink;this.linkActivationPointerId=null,this.linkActivationLink=null,this.linkActivationOrigin=null,this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.type!==`pointercancel`&&t&&Ft(t,this.linkAt(e.clientX,e.clientY))&&this.options.onLinkActivate(t.text,e);return}if(this.mouseReportingPointerId===e.pointerId){e.preventDefault(),e.stopPropagation(),this.sendMouse(`release`,this.mouseReportingButton,e),this.mouseReportingPointerId=null,this.mouseReportingButton=null,this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.type===`pointercancel`?this.clearHoveredLink():(this.hoverPointer={x:e.clientX,y:e.clientY},this.refreshHoveredLink());return}if(this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.button===1&&Ut()){e.preventDefault();return}e.button===0&&(!this.selectionMoved&&this.selectionMode===`cell`&&this.clearSelection(),this.options.onSelectionChange())};onWheel=e=>{if(e.deltaY===0)return;e.preventDefault();let t=Xt(e,this.metrics.height,this.rows,this.wheelRemainder);this.wheelRemainder=t.remainder,this.scrollRows(t.rows,e)};scrollRows(e,t){if(e===0)return;let n=Math.abs(e);if(qt(this.core.isMouseTracking(),t)){let r=e<0?4:5;for(let e=0;e<n;e+=1)this.sendMouse(`press`,r,t);return}if(this.core.isAlternateScreen()){this.options.onData(Zt(e,this.core.isApplicationCursorKeys()));return}this.scrollViewport(e)}onMouseDown=e=>{(e.button===0||e.button===1&&Ut())&&e.preventDefault(),this.focus()};onMouseUp=e=>{e.button===1&&Ut()&&e.preventDefault()};onContextMenu=e=>{if(qt(this.core.isMouseTracking(),e)){e.preventDefault();return}this.options.onContextMenu?.(e)};onScrollbarPointerDown=e=>{if(e.button!==0)return;let t=this.readScrollbarState();if(t===null)return;let n=this.scrollbar.getBoundingClientRect(),r=At(t,n.height);r!==null&&(e.preventDefault(),e.stopPropagation(),this.scrollbarPointerId=e.pointerId,this.scrollbarPointerOffset=e.target===this.scrollbarThumb?e.clientY-n.top-r.thumbTop:r.thumbHeight/2,this.scrollbar.setPointerCapture(e.pointerId),this.scrollbarToPointer(e.clientY,n))};onScrollbarPointerMove=e=>{e.pointerId===this.scrollbarPointerId&&this.scrollbarState!==null&&(e.preventDefault(),this.scrollbarToPointer(e.clientY,this.scrollbar.getBoundingClientRect()))};onScrollbarPointerUp=e=>{e.pointerId===this.scrollbarPointerId&&(e.preventDefault(),this.scrollbarPointerId=null,this.scrollbar.hasPointerCapture(e.pointerId)&&this.scrollbar.releasePointerCapture(e.pointerId))};onScrollbarKeyDown=e=>{let t=this.readScrollbarState();if(t===null)return;let n=0;switch(e.key){case`ArrowUp`:n=-1;break;case`ArrowDown`:n=1;break;case`PageUp`:n=-Math.max(1,t.len);break;case`PageDown`:n=Math.max(1,t.len);break;case`Home`:n=-t.offset;break;case`End`:n=t.total-t.len-t.offset;break;default:return}e.preventDefault(),e.stopPropagation(),this.scrollViewport(n)};installEvents(){this.input.addEventListener(`keydown`,this.onKeyDown),this.input.addEventListener(`keyup`,this.onKeyUp),this.input.addEventListener(`focus`,this.onFocus),this.input.addEventListener(`blur`,this.onBlur),this.input.addEventListener(`input`,this.onInput),this.input.addEventListener(`paste`,this.onPaste),this.input.addEventListener(`copy`,this.onCopyEvent),this.input.addEventListener(`compositionstart`,this.onCompositionStart),this.input.addEventListener(`compositionend`,this.onCompositionEnd),this.canvas.addEventListener(`pointerdown`,this.onPointerDown),this.canvas.addEventListener(`pointermove`,this.onPointerMove),this.canvas.addEventListener(`pointerleave`,this.onPointerLeave),this.canvas.addEventListener(`pointerup`,this.onPointerUp),this.canvas.addEventListener(`pointercancel`,this.onPointerUp),this.canvas.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.canvas.addEventListener(`mousedown`,this.onMouseDown),this.canvas.addEventListener(`mouseup`,this.onMouseUp),this.canvas.addEventListener(`contextmenu`,this.onContextMenu),this.scrollbar.addEventListener(`pointerdown`,this.onScrollbarPointerDown),this.scrollbar.addEventListener(`pointermove`,this.onScrollbarPointerMove),this.scrollbar.addEventListener(`pointerup`,this.onScrollbarPointerUp),this.scrollbar.addEventListener(`pointercancel`,this.onScrollbarPointerUp),this.scrollbar.addEventListener(`keydown`,this.onScrollbarKeyDown),window.addEventListener(`pointerup`,this.onWindowPointerRelease),window.addEventListener(`pointercancel`,this.onWindowPointerRelease)}removeEvents(){this.input.removeEventListener(`keydown`,this.onKeyDown),this.input.removeEventListener(`keyup`,this.onKeyUp),this.input.removeEventListener(`focus`,this.onFocus),this.input.removeEventListener(`blur`,this.onBlur),this.input.removeEventListener(`input`,this.onInput),this.input.removeEventListener(`paste`,this.onPaste),this.input.removeEventListener(`copy`,this.onCopyEvent),this.input.removeEventListener(`compositionstart`,this.onCompositionStart),this.input.removeEventListener(`compositionend`,this.onCompositionEnd),this.canvas.removeEventListener(`pointerdown`,this.onPointerDown),this.canvas.removeEventListener(`pointermove`,this.onPointerMove),this.canvas.removeEventListener(`pointerleave`,this.onPointerLeave),this.canvas.removeEventListener(`pointerup`,this.onPointerUp),this.canvas.removeEventListener(`pointercancel`,this.onPointerUp),this.canvas.removeEventListener(`wheel`,this.onWheel),this.canvas.removeEventListener(`mousedown`,this.onMouseDown),this.canvas.removeEventListener(`mouseup`,this.onMouseUp),this.canvas.removeEventListener(`contextmenu`,this.onContextMenu),this.scrollbar.removeEventListener(`pointerdown`,this.onScrollbarPointerDown),this.scrollbar.removeEventListener(`pointermove`,this.onScrollbarPointerMove),this.scrollbar.removeEventListener(`pointerup`,this.onScrollbarPointerUp),this.scrollbar.removeEventListener(`pointercancel`,this.onScrollbarPointerUp),this.scrollbar.removeEventListener(`keydown`,this.onScrollbarKeyDown),window.removeEventListener(`pointerup`,this.onWindowPointerRelease),window.removeEventListener(`pointercancel`,this.onWindowPointerRelease)}scrollViewport(e){let t=Math.trunc(e),n=this.readScrollbarState();if(n!==null){let e=Math.max(0,n.total-n.len),r=Math.max(0,Math.min(n.offset+t,e));t=r-n.offset,this.scrollbarState={...n,offset:r}}t!==0&&(this.core.scroll(t),this.forceFullRender=!0,this.scrollbarDirty=!0,this.requestRender())}scrollbarToPointer(e,t){let n=this.scrollbarState;if(n===null)return;let r=jt(n,t.height,e-t.top,this.scrollbarPointerOffset);this.scrollViewport(r-n.offset)}updateScrollbar(){let e=this.readScrollbarState(),t=e===null?null:At(e,Math.max(0,this.mount.clientHeight-8));this.scrollbar.hidden=t===null,e!==null&&t!==null&&(this.scrollbar.setAttribute(`aria-valuemin`,`0`),this.scrollbar.setAttribute(`aria-valuemax`,String(t.maxOffset)),this.scrollbar.setAttribute(`aria-valuenow`,String(Math.max(0,Math.min(e.offset,t.maxOffset)))),this.scrollbarThumb.style.height=`${t.thumbHeight}px`,this.scrollbarThumb.style.transform=`translateY(${t.thumbTop}px)`)}readScrollbarState(){let e=this.core.scrollbarState();return this.scrollbarState=e,e}requestRender(){!this.disposed&&this.visible&&this.hasSize&&this.frame===0&&(this.frame=window.requestAnimationFrame(()=>{this.frame=0,this.renderFrame()}))}cancelRender(){this.frame!==0&&(window.cancelAnimationFrame(this.frame),this.frame=0),this.cursorTimer!==null&&(window.clearTimeout(this.cursorTimer),this.cursorTimer=null)}renderFrame(){if(this.disposed||!this.visible)return;if(this.frame!==0&&(window.cancelAnimationFrame(this.frame),this.frame=0),this.mount.clientWidth===0||this.mount.clientHeight===0){this.hasSize=!1,this.forceFullRender=!0,this.cancelRender();return}this.snapshot=this.core.snapshot(),this.blinkEnabled()||(this.cursorOn=!0);let e=this.readScrollbarState(),t=e!==null&&e.total>e.len,n=kt(this.mountHeight,$,this.rows,this.metrics.height,t);n!==this.originY&&(this.originY=n,this.forceFullRender=!0),this.refreshHoveredLink(),dt({context:this.context,snapshot:this.snapshot,metrics:this.metrics,fontSize:this.fontSize,fontFamily:this.fontFamily,padding:$,originY:this.originY,forceFull:this.forceFullRender,cursorOn:this.cursorOn,previousCursorY:this.renderedCursorY,focused:this.focused,hoveredLinkRange:this.hoveredLink?.range??null,...this.theme.selectionBackground===void 0?{}:{selectionBackground:this.theme.selectionBackground}}),this.positionInput(),this.renderedCursorY=this.cursorOn&&this.snapshot.cursorVisible&&this.snapshot.cursorY>=0?this.snapshot.cursorY:null,this.scrollbarDirty&&(this.scrollbarDirty=!1,this.updateScrollbar()),this.forceFullRender=!1,this.scheduleCursorBlink()}scheduleCursorBlink(){this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,this.blinkEnabled()&&(this.cursorTimer=window.setTimeout(()=>{this.cursorTimer=null,this.cursorOn=!this.cursorOn,this.requestRender()},vt))}blinkEnabled(){let e=this.snapshot;return!e||!this.visible||!this.hasSize?!1:Ot({focused:this.focused,cursorBlinking:e.cursorBlinking,cursorVisible:e.cursorVisible,reducedMotion:this.reducedMotionMedia?.matches??!1})}positionInput(){let e=this.snapshot;if(!e||!e.cursorVisible||e.cursorX<0||e.cursorY<0)return;let t=$+e.cursorX*this.metrics.width,n=this.originY+e.cursorY*this.metrics.height;(t!==this.inputLeft||n!==this.inputTop)&&(this.inputLeft=t,this.inputTop=n,this.input.style.left=`${t}px`,this.input.style.top=`${n}px`,this.input.style.height=`${this.metrics.height}px`)}cellAt(e,t){let n=this.canvas.getBoundingClientRect();return{x:Math.max(0,Math.min(this.cols-1,Math.floor((e-n.left-$)/this.metrics.width))),y:Math.max(0,Math.min(this.rows-1,Math.floor((t-n.top-this.originY)/this.metrics.height)))}}linkAt(e,t){let n=this.findLinkAt(e,t);return n&&this.options.canActivateLink?.(n.text)!==!1?n:null}findLinkAt(e,t){if(!this.snapshot)return null;let n=Mt({bounds:this.canvas.getBoundingClientRect(),clientX:e,clientY:t,cols:this.cols,rows:this.rows,metrics:this.metrics,padding:$,originY:this.originY});if(!n)return null;let r=this.core.hyperlinkAt(n.x,n.y);if(r){let e={...n},t={...n};for(;;){let t=e.x>0?{x:e.x-1,y:e.y}:e.y>0&&this.snapshot.rowData[e.y]?.isWrapContinuation?{x:this.cols-1,y:e.y-1}:null;if(!t||this.core.hyperlinkAt(t.x,t.y)!==r)break;e.x=t.x,e.y=t.y}for(;;){let e=t.x+1<this.cols?{x:t.x+1,y:t.y}:t.y+1<this.rows&&this.snapshot.rowData[t.y]?.wrapsToNext?{x:0,y:t.y+1}:null;if(!e||this.core.hyperlinkAt(e.x,e.y)!==r)break;t.x=e.x,t.y=e.y}return{text:r,range:{start:e,end:t}}}return Lt(this.snapshot.rowData,n.y,n.x)}sendMouse(e,t,n){let r=this.canvas.getBoundingClientRect(),i=this.core.encodeMouse({action:e,button:t,mods:+!!n.shiftKey|(n.ctrlKey?2:0)|(n.altKey?4:0)|(n.metaKey?8:0),x:Math.max(0,n.clientX-r.left),y:Math.max(0,n.clientY-r.top),screenWidth:r.width,screenHeight:r.height,cellWidth:this.metrics.width,cellHeight:this.metrics.height,paddingLeft:$,paddingRight:$,paddingTop:this.originY,paddingBottom:Math.max(0,r.height-this.originY-this.rows*this.metrics.height),anyButtonPressed:n.buttons!==0}),a=Jt(e,i,this.lastMouseMotionData);this.lastMouseMotionData=a.nextMotionData,a.send&&this.options.onData(i)}synchronizeMouseTrackingState(){let e=this.core.isMouseAnyEventTracking(),t=Yt(this.mouseAnyEventTracking,e,this.lastMouseMotionData);return this.mouseAnyEventTracking=t.tracking,this.lastMouseMotionData=t.motionData,e}buttonFromButtons(e){return e&1?1:e&4?3:e&2?2:e&8?4:e&16?5:null}};function nn(e){let t=(0,ze.c)(14),{children:n,label:r,onClick:i,tooltip:a}=e,o;t[0]===n?o=t[1]:(o=(0,L.jsx)(`span`,{className:`relative flex size-3 items-center justify-center group-hover/tab:hidden group-focus-visible/close:hidden`,children:n}),t[0]=n,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(d,{className:`hidden size-3 group-hover/tab:block group-focus-visible/close:block`}),t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==i||t[5]!==o?(c=(0,L.jsxs)(`button`,{type:`button`,className:`cursor-pointer group/close relative flex size-4 shrink-0 items-center justify-center rounded-sm hover:bg-muted`,"aria-label":r,onClick:i,children:[o,s]}),t[3]=r,t[4]=i,t[5]=o,t[6]=c):c=t[6];let l=c;if(!a)return l;let u;t[7]===l?u=t[8]:(u=(0,L.jsx)(b,{render:l}),t[7]=l,t[8]=u);let f;t[9]===a?f=t[10]:(f=(0,L.jsx)(x,{children:a}),t[9]=a,t[10]=f);let p;return t[11]!==u||t[12]!==f?(p=(0,L.jsxs)(S,{children:[u,f]}),t[11]=u,t[12]=f,t[13]=p):p=t[13],p}var rn=0;function an(){return rn>0}async function on(e){let t=me();if(!t)return!0;rn+=1;try{return await t.dialogs.confirm(e.length===1?[`Close terminal "${e[0]}"?`,`This stops the running process and clears its history.`].join(`
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{By as n,Cm as r,Cy as i,Dc as a,E_ as o,Es as s,Iy as c,NE as l,Pp as u,Um as d,Yo as f,__ as p,dm as m,jo as h,lE as g,sm as ee,sr as te,t as _,um as v,vm as y,xy as ne}from"./utils-Dx_TSvdC.js";import{R as re,W as ie}from"./runtime-D102A-Bu.js";import{f as ae,i as oe,m as se}from"./toast-SPJYfh08.js";import{a as b,n as x,t as S}from"./tooltip-Cco13jKX.js";import{f as ce}from"./server-DTGT8WWf.js";import{i as le,n as ue}from"./session-Dh8maTO3.js";import{t as de}from"./use-atom-command-BHmF32aL.js";import{l as fe}from"./rightPanelStore-CcmIdfDA.js";import{a as pe}from"./fileLinks-sFAkJkUp.js";import{R as me,s as he}from"./useSettings-DUgjfqYw.js";import{n as ge}from"./toastHelpers-Dsph6LwL.js";import{t as _e}from"./observeResize-BxVCxCXG.js";import{S as ve,c as ye,d as C,n as w,s as T,x as be}from"./browserHistoryStore-BpqZwrsk.js";import{S as E,a as xe,c as Se,d as Ce,f as we,l as Te,p as Ee,u as De,x as D}from"./keybindings-BlEA4Dlt.js";import{t as Oe}from"./preview-DDUAtKQn.js";import{n as O,r as k}from"./browserLinkTarget-EXHYn6yB.js";import{i as ke,o as A,t as Ae}from"./popover-BunL7s_L.js";import{i as je,n as Me,t as j}from"./terminal-links-CV_3r1U3.js";import{a as Ne,i as Pe,o as M,t as N}from"./terminalSessions-aS2PVMmc.js";import{t as Fe}from"./terminalLabels-BgLOlb2G.js";import{Da as Ie,Oa as P,Wa as Le,wa as F,xa as Re}from"./main-C58_iQqs.js";var I=e(t(),1),ze=l(),L=e(g(),1);function Be(e){let{bounds:t,selectionRect:n,pointer:r,viewport:i}=e,a=r??{x:n?.right??t.left+t.width-140,y:n?n.bottom+4:t.top+12};return{x:Math.max(8,Math.min(Math.max(t.left,a.x),t.left+t.width,i.width-8)),y:Math.max(8,Math.min(Math.max(t.top,a.y),t.top+t.height,i.height-8))}}function Ve({element:e,getActionElement:t,onSelection:n,onDismiss:r}){let i=e.ownerDocument,a=i.defaultView,o=!1,s=!1,c=!1,l=null,u=null,d=null,f=e=>e!==null&&(t?.()?.contains(e)??!1),p=()=>{u!==null&&a.clearTimeout(u),d!==null&&a.cancelAnimationFrame(d),u=d=null},m=()=>{p(),o=s=!1,l=null,c=!0},h=()=>{m(),r(`cancel`)},g=()=>{m(),r(`interaction`)},ee=e=>{p(),u=a.setTimeout(()=>{u=null,d=a.requestAnimationFrame(()=>{d=null,n(l)})},e)},te=n=>{if(!n.isPrimary)return;if(f(n.target)){m();return}p(),o=n.button===0;let i=e.contains(n.target);s=!1,c=!0,l=null,i?r(`interaction`):t?.()&&r(`cancel`)},_=e=>{e.isPrimary&&(e.target?.closest(`button, [role=button]`)||(s=e.button===0&&!e.defaultPrevented,c=!s))},v=e=>{e.isPrimary&&e.button===0&&(o=!1)},y=e=>{e.button===0&&(o=!1,s&&(s=!1,l={x:e.clientX,y:e.clientY},ee(e.detail>=2?500:0)))},ne=e=>{f(e.target)&&e.key!==`Escape`||(e.key===`Escape`?h():o||(p(),s=!1,l=null,c=!1))},re=e=>{f(e.target)?m():!o&&t?.()&&h()},ie=()=>{p(),o||(l=null,c=!0),r(`cancel`)};return i.addEventListener(`pointerdown`,te,!0),e.addEventListener(`pointerdown`,_),a.addEventListener(`pointerup`,v),a.addEventListener(`mouseup`,y),a.addEventListener(`pointercancel`,h),i.addEventListener(`keydown`,ne),i.addEventListener(`focusin`,re),e.addEventListener(`contextmenu`,g,!0),e.addEventListener(`scroll`,ie,!0),a.addEventListener(`blur`,h),a.addEventListener(`resize`,h),{get pending(){return u!==null||d!==null},cancel:m,selectionChanged(){f(i.activeElement)||(o||s?r(`cancel`):!c&&u===null&&d===null&&ee(0))},dispose(){m(),i.removeEventListener(`pointerdown`,te,!0),e.removeEventListener(`pointerdown`,_),a.removeEventListener(`pointerup`,v),a.removeEventListener(`mouseup`,y),a.removeEventListener(`pointercancel`,h),i.removeEventListener(`keydown`,ne),i.removeEventListener(`focusin`,re),e.removeEventListener(`contextmenu`,g,!0),e.removeEventListener(`scroll`,ie,!0),a.removeEventListener(`blur`,h),a.removeEventListener(`resize`,h)}}}var R=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function z(e){return R.get(e)??0}var He=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),Ue;function We(){if(Ue)return Ue;let e=(globalThis.navigator?.keyboard)?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0);return Ue=e,e}function B(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function V(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=He.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var H=`/assets/ghostty-vt-DdA0Zryv.wasm`,Ge=`/assets/ghostty-write-pty-hgyAvVbe.wasm`,U=new TextDecoder,Ke=class e{memory;layouts;exports;memoryView;ptyWriters=new Map;nextPtyWriterId=1;writePtyFunctionIndex=0;constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export WebAssembly memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(U.decode(r.subarray(n,i)))}static async load(){let t=await fetch(H);if(!t.ok)throw Error(`Unable to load libghostty-vt (${t.status})`);let n,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{if(!n)return;let r=n.exports.memory;if(!(r instanceof WebAssembly.Memory))return;let i=U.decode(new Uint8Array(r.buffer,e,t));console.debug(`[libghostty-vt]`,i)}}});n=r.instance;let i=new e(r.instance);return await i.installWritePtyTrampoline(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is unavailable: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt type layout is unavailable: ${e}`);return t}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt failed to allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt failed to allocate an opaque pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.memoryDataView().getUint32(e,!0)}attachPtyWriter(e,t){if(this.writePtyFunctionIndex===0)throw Error(`libghostty-vt PTY callback trampoline is unavailable`);let n=this.nextPtyWriterId++;return this.ptyWriters.set(n,t),this.call(`ghostty_terminal_set`,e,0,n),this.call(`ghostty_terminal_set`,e,1,this.writePtyFunctionIndex),n}detachPtyWriter(e,t){this.call(`ghostty_terminal_set`,e,1,0),this.call(`ghostty_terminal_set`,e,0,0),this.ptyWriters.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}memoryDataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.layout(t).fields[n];if(!i)throw Error(`libghostty-vt field is unavailable: ${t}.${n}`);let a=this.memoryDataView(),o=e+i.offset;switch(i.type){case`bool`:case`u8`:a.setUint8(o,r);return;case`u16`:a.setUint16(o,r,!0);return;case`i32`:a.setInt32(o,r,!0);return;case`u32`:case`enum`:a.setUint32(o,r,!0);return;case`u64`:a.setBigUint64(o,BigInt(r),!0);return;default:throw Error(`Unsupported libghostty-vt field type: ${i.type}`)}}readField(e,t,n){let r=this.layout(t).fields[n];if(!r)throw Error(`libghostty-vt field is unavailable: ${t}.${n}`);let i=this.memoryDataView(),a=e+r.offset;switch(r.type){case`bool`:case`u8`:return i.getUint8(a);case`u16`:return i.getUint16(a,!0);case`i32`:return i.getInt32(a,!0);case`u32`:case`enum`:return i.getUint32(a,!0);case`u64`:return Number(i.getBigUint64(a,!0));default:throw Error(`Unsupported libghostty-vt field type: ${r.type}`)}}async installWritePtyTrampoline(){let e=await fetch(Ge);if(!e.ok)throw Error(`Unable to load the libghostty-vt PTY trampoline (${e.status})`);let t=(await WebAssembly.instantiate(await e.arrayBuffer(),{env:{t3_write_pty:(e,t,n,r)=>{let i=this.ptyWriters.get(t);i&&r!==0&&i(U.decode(new Uint8Array(this.memory.buffer,n,r)))}}})).instance.exports.ghostty_write_pty,n=this.exports.__indirect_function_table;if(typeof t!=`function`||!(n instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let r=n.length;n.grow(1),n.set(r,t),this.writePtyFunctionIndex=r}},W=null;function G(){return W??=Ke.load().catch(e=>{throw W=null,e}),W}var K=0,qe=-3,Je=1e4,Ye=16,Xe=768,q={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},J={dirty:1,raw:2,cells:3},Y={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},X={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},Ze={wide:3},Qe={narrow:0,wide:1,spacerTail:2,spacerHead:3},$e=new TextDecoder,et=new TextEncoder;function tt(e,t){let n=(e,t)=>Math.floor((e*155+t*100)/255);return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b)}}function nt(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b}function rt(e,t){if(t===1)return String.fromCodePoint(e.getUint32(0,!0));let n=4096,r=``;for(let i=0;i<t;i+=n){let a=Math.min(n,t-i),o=Array(a);for(let t=0;t<a;t+=1)o[t]=e.getUint32((i+t)*4,!0);r+=String.fromCodePoint(...o)}return r}var it=class e{runtime;terminalSlot=0;terminal=0;renderStateSlot=0;renderState=0;rowIteratorSlot=0;rowCellsSlot=0;keyEncoderSlot=0;keyEncoder=0;keyEventSlot=0;keyEvent=0;mouseEncoderSlot=0;mouseEncoder=0;mouseEventSlot=0;mouseEvent=0;ptyWriterId=0;ptyWriter=null;scratch=0;graphemes=0;graphemeCapacity=0;style=0;cellQuery=0;scrollbar=0;rows=[];disposed=!1;keyboardLayoutMap;constructor(e){this.runtime=e,We().then(e=>{this.disposed||(this.keyboardLayoutMap=e)})}static async create(t,n,r,i,a,o){let s=new e(await G());try{return s.initialize(t,n,r,i,a,o),s}catch(e){throw s.dispose(),e}}initialize(e,t,n,r,i,a){let o=this.runtime.layout(`GhosttyTerminalOptions`).size,s=this.runtime.alloc(o);this.runtime.setField(s,`GhosttyTerminalOptions`,`cols`,e),this.runtime.setField(s,`GhosttyTerminalOptions`,`rows`,t),this.runtime.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,Je),this.terminalSlot=this.runtime.allocOpaque();let c=this.runtime.call(`ghostty_terminal_new`,0,this.terminalSlot,s);this.runtime.free(s,o),this.assertSuccess(`ghostty_terminal_new`,c),this.terminal=this.runtime.readPointer(this.terminalSlot),this.applyDefaultCursorBlink(),this.ptyWriter=a,this.ptyWriterId=this.runtime.attachPtyWriter(this.terminal,a),this.renderStateSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_render_state_new`,this.runtime.call(`ghostty_render_state_new`,0,this.renderStateSlot)),this.renderState=this.runtime.readPointer(this.renderStateSlot),this.rowIteratorSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_render_state_row_iterator_new`,this.runtime.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_render_state_row_cells_new`,this.runtime.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.keyEncoderSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_key_encoder_new`,this.runtime.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=this.runtime.readPointer(this.keyEncoderSlot),this.keyEventSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_key_event_new`,this.runtime.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=this.runtime.readPointer(this.keyEventSlot),this.mouseEncoderSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_mouse_encoder_new`,this.runtime.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=this.runtime.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=this.runtime.allocOpaque(),this.assertSuccess(`ghostty_mouse_event_new`,this.runtime.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=this.runtime.readPointer(this.mouseEventSlot),this.scratch=this.runtime.alloc(16);let l=this.runtime.layout(`GhosttyStyle`).size;this.style=this.runtime.alloc(l),this.runtime.setField(this.style,`GhosttyStyle`,`size`,l),this.cellQuery=this.runtime.alloc(X.size);let u=this.runtime.memoryDataView(),d=[[Y.style,this.style],[Y.graphemesLength,this.cellQuery+X.graphemesLength],[Y.selected,this.cellQuery+X.selected],[Y.background,this.cellQuery+X.background],[Y.foreground,this.cellQuery+X.foreground]];for(let[e,[t,n]]of d.entries())u.setUint32(this.cellQuery+X.keys+e*4,t,!0),u.setUint32(this.cellQuery+X.values+e*4,n,!0);this.scrollbar=this.runtime.alloc(this.runtime.layout(`GhosttyTerminalScrollbar`).size),this.setTheme(i),this.resize(e,t,n,r)}write(e){this.ensureActive();let t=typeof e==`string`?et.encode(e):e;if(t.length===0)return;let n=this.runtime.alloc(t.length);this.runtime.bytes(n,t.length).set(t),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,n,t.length),this.runtime.free(n,t.length)}resetAndWrite(e){if(this.ensureActive(),this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.applyDefaultCursorBlink(),this.rows=[],e.length===0)return;let t=this.ptyWriter;this.ptyWriterId!==0&&(this.runtime.detachPtyWriter(this.terminal,this.ptyWriterId),this.ptyWriterId=0);try{this.write(e)}finally{t!==null&&!this.disposed&&(this.ptyWriterId=this.runtime.attachPtyWriter(this.terminal,t))}}resize(e,t,n,r){this.ensureActive(),this.assertSuccess(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),Math.max(1,Math.round(n)),Math.max(1,Math.round(r))))}applyDefaultCursorBlink(){let e=this.runtime.alloc(1);this.runtime.bytes(e,1)[0]=1,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,e),this.runtime.free(e,1)}setTheme(e){this.ensureActive();let t=this.runtime.alloc(3);for(let[n,r]of[[11,e.foreground],[12,e.background],[13,e.cursor]])this.runtime.bytes(t,3).set([r.r,r.g,r.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n,t);this.runtime.free(t,3),e.palette&&this.setPalette(e.palette)}setPalette(e){let t=this.runtime.alloc(Xe);this.runtime.call(`ghostty_terminal_get`,this.terminal,25,t);let n=this.runtime.bytes(t,Xe);e.slice(0,16).forEach((e,t)=>{n.set([e.r,e.g,e.b],t*3)}),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,t),this.runtime.free(t,Xe)}scroll(e){this.ensureActive();let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=t.fields.value;this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){this.ensureActive();let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}isViewportActive(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_get`,this.terminal,32,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}scrollbarState(){this.ensureActive();let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===K?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_get`,this.terminal,11,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}isMouseAnyEventTracking(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_mode_get`,this.terminal,1003,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}isAlternateScreen(){return this.ensureActive(),this.runtime.bytes(this.scratch,4).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===K&&this.runtime.view(this.scratch,4).getUint32(0,!0)===1}isApplicationCursorKeys(){return this.ensureActive(),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_terminal_mode_get`,this.terminal,1,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}encodeKey(e,t=`press`){this.ensureActive(),this.runtime.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),this.runtime.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),this.runtime.call(`ghostty_key_event_set_key`,this.keyEvent,z(e.code));let n=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);this.runtime.call(`ghostty_key_event_set_mods`,this.keyEvent,n),this.runtime.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,B(e)),this.runtime.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),this.runtime.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,V(e,this.keyboardLayoutMap));let r=e.key.length===1?e.key:``,i=et.encode(r),a=i.length===0?0:this.runtime.alloc(i.length);a!==0&&this.runtime.bytes(a,i.length).set(i),this.runtime.call(`ghostty_key_event_set_utf8`,this.keyEvent,a,i.length);let o=this.runtime.call(`ghostty_wasm_alloc_usize`),s=this.encodeOutput(o,(e,t)=>this.runtime.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,o));return this.runtime.call(`ghostty_wasm_free_usize`,o),a!==0&&this.runtime.free(a,i.length),s}encodePaste(e){this.ensureActive();let t=et.encode(e);if(t.length===0)return``;let n=this.runtime.alloc(t.length);this.runtime.bytes(n,t.length).set(t),this.runtime.bytes(this.scratch,1)[0]=0;let r=this.runtime.call(`ghostty_terminal_mode_get`,this.terminal,2004,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0,i=this.runtime.call(`ghostty_wasm_alloc_usize`),a=``,o=this.runtime.call(`ghostty_paste_encode`,n,t.length,+!!r,0,0,i),s=this.runtime.view(i,4).getUint32(0,!0);if(o===qe&&s>0){let e=this.runtime.alloc(s),o=this.runtime.call(`ghostty_paste_encode`,n,t.length,+!!r,e,s,i),c=this.runtime.view(i,4).getUint32(0,!0);a=o===K?$e.decode(this.runtime.bytes(e,c)):``,this.runtime.free(e,s)}return this.runtime.call(`ghostty_wasm_free_usize`,i),this.runtime.free(n,t.length),a}encodeMouse(e){this.ensureActive(),this.runtime.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let t=this.runtime.layout(`GhosttyMouseEncoderSize`),n=this.runtime.alloc(t.size);for(let[r,i]of[[`size`,t.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,e.paddingTop],[`padding_bottom`,e.paddingBottom],[`padding_right`,e.paddingRight],[`padding_left`,e.paddingLeft]])this.runtime.setField(n,`GhosttyMouseEncoderSize`,r,Math.max(0,Math.round(i)));this.runtime.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,n),this.runtime.free(n,t.size),this.runtime.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,this.runtime.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),this.runtime.bytes(this.scratch,1)[0]=1,this.runtime.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),this.runtime.call(`ghostty_mouse_event_set_action`,this.mouseEvent,e.action===`press`?0:e.action===`release`?1:2),e.button===null?this.runtime.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):this.runtime.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),this.runtime.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let r=this.runtime.layout(`GhosttyMousePosition`),i=this.runtime.alloc(r.size),a=this.runtime.view(i,r.size);a.setFloat32(r.fields.x.offset,e.x,!0),a.setFloat32(r.fields.y.offset,e.y,!0),this.runtime.call(`ghostty_mouse_event_set_position`,this.mouseEvent,i),this.runtime.free(i,r.size);let o=this.runtime.call(`ghostty_wasm_alloc_usize`),s=this.encodeOutput(o,(e,t)=>this.runtime.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,t,o));return this.runtime.call(`ghostty_wasm_free_usize`,o),s}setSelection(e,t){this.ensureActive();let n=this.runtime.layout(`GhosttySelection`),r=this.runtime.layout(`GhosttyGridRef`).size,i=this.runtime.alloc(n.size),a=0,o=0;try{this.runtime.setField(i,`GhosttySelection`,`size`,n.size),a=this.gridRef(e.x,e.y,e.tag??1),o=this.gridRef(t.x,t.y,t.tag??1);let r=n.fields.start,s=n.fields.end;this.runtime.bytes(i+r.offset,r.size).set(this.runtime.bytes(a,r.size)),this.runtime.bytes(i+s.offset,s.size).set(this.runtime.bytes(o,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,i)}finally{this.runtime.free(a,r),this.runtime.free(o,r),this.runtime.free(i,n.size)}}selectAll(){this.ensureActive();let e=this.runtime.layout(`GhosttySelection`),t=this.runtime.alloc(e.size);try{if(this.runtime.setField(t,`GhosttySelection`,`size`,e.size),this.runtime.call(`ghostty_terminal_select_all`,this.terminal,t)!==K)return null;let n=this.pointFromGridRef(t+e.fields.start.offset,2),r=this.pointFromGridRef(t+e.fields.end.offset,2);return!n||!r?null:(this.runtime.call(`ghostty_terminal_set`,this.terminal,21,t),{start:n,end:r})}finally{this.runtime.free(t,e.size)}}selectWord(e,t){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e,t)}selectLine(e,t){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e,t)}hyperlinkAt(e,t){this.ensureActive();let n=this.gridRef(e,t),r=this.runtime.call(`ghostty_wasm_alloc_usize`),i=this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,n,0,0,r),a=this.runtime.view(r,4).getUint32(0,!0),o=null;if(i===qe&&a>0){let e=this.runtime.alloc(a),t=this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,n,e,a,r),i=this.runtime.view(r,4).getUint32(0,!0);t===K&&i>0&&(o=$e.decode(this.runtime.bytes(e,i))),this.runtime.free(e,a)}return this.runtime.call(`ghostty_wasm_free_usize`,r),this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),o}clearSelection(){this.ensureActive(),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}snapshot(){this.ensureActive(),this.assertSuccess(`ghostty_render_state_update`,this.runtime.call(`ghostty_render_state_update`,this.renderState,this.terminal));let e=this.getU16(q.cols),t=this.getU16(q.rows),n=this.getU32(q.dirty),r=this.getColor(q.foreground,{r:229,g:231,b:235}),i=this.getColor(q.background,{r:0,g:0,b:0}),a=this.getBool(q.cursorHasValue)?this.getColor(q.cursor,r):r,o=this.getBool(q.cursorInViewport),s=this.getBool(q.cursorVisible)&&o,c=o?this.getU16(q.cursorX):-1,l=o?this.getU16(q.cursorY):-1;(this.rows.length!==t||this.rows.some(t=>t.cells.length!==e))&&(this.rows=Array.from({length:t},()=>({cells:Array.from({length:e},()=>this.emptyCell(r,i)),text:``,isWrapContinuation:!1,wrapsToNext:!1})));let u=new Set;if(n!==0){this.assertSuccess(`ghostty_render_state_get(row iterator)`,this.runtime.call(`ghostty_render_state_get`,this.renderState,q.rowIterator,this.rowIteratorSlot));let a=this.runtime.readPointer(this.rowIteratorSlot),o=0;for(;o<t&&this.runtime.call(`ghostty_render_state_row_iterator_next`,a)!==0;)(n===2||this.getRowBool(a,J.dirty))&&(this.rows[o]=this.readRow(a,e,r,i),u.add(o),this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_set`,a,0,this.scratch)),o+=1;this.runtime.view(this.scratch,4).setUint32(0,0,!0),this.runtime.call(`ghostty_render_state_set`,this.renderState,0,this.scratch)}return{cols:e,rows:t,foreground:r,background:i,cursor:a,cursorX:c,cursorY:l,cursorVisible:s,cursorBlinking:this.getBool(q.cursorBlinking),cursorStyle:this.getU32(q.cursorStyle),dirtyRows:u,rowData:this.rows}}selectionText(){this.ensureActive();let e=this.runtime.alloc(Ye),t=this.runtime.view(e,Ye);t.setUint32(0,Ye,!0),t.setUint32(4,0,!0),t.setUint8(8,1),t.setUint8(9,1),t.setUint32(12,0,!0);let n=this.runtime.call(`ghostty_wasm_alloc_usize`),r=this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,0,0,n),i=this.runtime.view(n,4).getUint32(0,!0),a=``;if(r===qe&&i>0){let t=this.runtime.alloc(i),r=this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,i,n),o=this.runtime.view(n,4).getUint32(0,!0);r===K&&(a=$e.decode(this.runtime.bytes(t,o))),this.runtime.free(t,i)}return this.runtime.call(`ghostty_wasm_free_usize`,n),this.runtime.free(e,Ye),a}viewportPointToScreen(e,t){return this.convertPoint(e,t,1,2)}screenPointToViewport(e,t){return this.convertPoint(e,t,2,1)}convertPoint(e,t,n,r){this.ensureActive();let i=this.gridRef(e,t,n),a=this.pointFromGridRef(i,r);return this.runtime.free(i,this.runtime.layout(`GhosttyGridRef`).size),a}dispose(){if(!this.disposed){if(this.disposed=!0,this.mouseEvent&&this.runtime.call(`ghostty_mouse_event_free`,this.mouseEvent),this.mouseEncoder&&this.runtime.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),this.keyEvent&&this.runtime.call(`ghostty_key_event_free`,this.keyEvent),this.keyEncoder&&this.runtime.call(`ghostty_key_encoder_free`,this.keyEncoder),this.rowCellsSlot){let e=this.runtime.readPointer(this.rowCellsSlot);e&&this.runtime.call(`ghostty_render_state_row_cells_free`,e)}if(this.rowIteratorSlot){let e=this.runtime.readPointer(this.rowIteratorSlot);e&&this.runtime.call(`ghostty_render_state_row_iterator_free`,e)}this.renderState&&this.runtime.call(`ghostty_render_state_free`,this.renderState),this.terminal&&(this.ptyWriterId&&this.runtime.detachPtyWriter(this.terminal,this.ptyWriterId),this.runtime.call(`ghostty_terminal_free`,this.terminal)),this.style&&this.runtime.free(this.style,this.runtime.layout(`GhosttyStyle`).size),this.cellQuery&&this.runtime.free(this.cellQuery,X.size),this.scrollbar&&this.runtime.free(this.scrollbar,this.runtime.layout(`GhosttyTerminalScrollbar`).size),this.scratch&&this.runtime.free(this.scratch,16),this.graphemes&&this.runtime.free(this.graphemes,this.graphemeCapacity);for(let e of[this.mouseEventSlot,this.mouseEncoderSlot,this.keyEventSlot,this.keyEncoderSlot,this.rowCellsSlot,this.rowIteratorSlot,this.renderStateSlot,this.terminalSlot])this.runtime.freeOpaque(e)}}encodeOutput(e,t){let n=t(0,0),r=this.runtime.view(e,4).getUint32(0,!0);if(n===K&&r===0||n!==qe||r===0)return``;let i=this.runtime.alloc(r),a=t(i,r),o=this.runtime.view(e,4).getUint32(0,!0),s=a===K?$e.decode(this.runtime.bytes(i,o)):``;return this.runtime.free(i,r),s}readRow(e,t,n,r){this.assertSuccess(`ghostty_render_state_row_get(raw)`,this.runtime.call(`ghostty_render_state_row_get`,e,J.raw,this.scratch));let i=this.runtime.view(this.scratch,8).getBigUint64(0,!0);this.runtime.bytes(this.scratch+8,1)[0]=0,this.assertSuccess(`ghostty_row_get(wrap continuation)`,this.runtime.call(`ghostty_row_get`,i,2,this.scratch+8));let a=this.runtime.bytes(this.scratch+8,1)[0]!==0;this.runtime.bytes(this.scratch+8,1)[0]=0,this.assertSuccess(`ghostty_row_get(wrap)`,this.runtime.call(`ghostty_row_get`,i,1,this.scratch+8));let o=this.runtime.bytes(this.scratch+8,1)[0]!==0;this.assertSuccess(`ghostty_render_state_row_get(cells)`,this.runtime.call(`ghostty_render_state_row_get`,e,J.cells,this.rowCellsSlot));let s=this.runtime.readPointer(this.rowCellsSlot),{size:c,fields:l}=this.runtime.layout(`GhosttyStyle`),u=[];for(;u.length<t&&this.runtime.call(`ghostty_render_state_row_cells_next`,s)!==0;){this.runtime.bytes(this.style,c).fill(0),this.runtime.setField(this.style,`GhosttyStyle`,`size`,c);let e=this.runtime.call(`ghostty_render_state_row_cells_get_multi`,s,5,this.cellQuery+X.keys,this.cellQuery+X.values,this.cellQuery+X.written),t=this.runtime.memoryDataView(),i=t.getUint32(this.cellQuery+X.written,!0);i<3&&this.assertSuccess(`ghostty_render_state_row_cells_get_multi`,e);let a=t.getUint32(this.cellQuery+X.graphemesLength,!0),o=t.getUint8(this.cellQuery+X.selected)!==0,d=i>=4?this.readColor(this.cellQuery+X.background):r,f=i===5?this.readColor(this.cellQuery+X.foreground):i===3?this.getCellColor(s,Y.foreground,n):n,p=``;if(a>0){let e=a*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=this.runtime.alloc(t);this.runtime.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}this.runtime.call(`ghostty_render_state_row_cells_get`,s,Y.graphemes,this.graphemes)===K&&(p=rt(this.runtime.view(this.graphemes,e),a))}let m=0;if(p.length===0&&u.at(-1)?.text.length){this.assertSuccess(`ghostty_render_state_row_cells_get(raw)`,this.runtime.call(`ghostty_render_state_row_cells_get`,s,Y.raw,this.scratch));let e=this.runtime.view(this.scratch,8).getBigUint64(0,!0);this.runtime.view(this.scratch+8,4).setUint32(0,0,!0),this.assertSuccess(`ghostty_cell_get(wide)`,this.runtime.call(`ghostty_cell_get`,e,Ze.wide,this.scratch+8)),m=this.runtime.view(this.scratch+8,4).getUint32(0,!0)}let h=this.runtime.memoryDataView();h.getUint8(this.style+l.inverse.offset)!==0&&([f,d]=[d,f]),h.getUint8(this.style+l.faint.offset)!==0&&(f=tt(f,d)),u.push({text:p,wide:m,foreground:f,background:d,bold:h.getUint8(this.style+l.bold.offset)!==0,italic:h.getUint8(this.style+l.italic.offset)!==0,invisible:h.getUint8(this.style+l.invisible.offset)!==0,strikethrough:h.getUint8(this.style+l.strikethrough.offset)!==0,overline:h.getUint8(this.style+l.overline.offset)!==0,underline:h.getInt32(this.style+l.underline.offset,!0)!==0,selected:o})}for(;u.length<t;)u.push(this.emptyCell(n,r));return{cells:u,text:u.map(e=>e.text||` `).join(``).trimEnd(),isWrapContinuation:a,wrapsToNext:o}}gridRef(e,t,n=1){let r=this.runtime.layout(`GhosttyPoint`),i=this.runtime.alloc(r.size);this.runtime.setField(i,`GhosttyPoint`,`tag`,n);let a=r.fields.value,o=a.offset,s=this.runtime.view(i+o,a.size);s.setUint16(0,Math.max(0,e),!0),s.setUint32(4,Math.max(0,t),!0);let c=this.runtime.layout(`GhosttyGridRef`).size,l=this.runtime.alloc(c);this.runtime.setField(l,`GhosttyGridRef`,`size`,c);let u=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,i,l);return this.runtime.free(i,r.size),u!==K&&(this.runtime.free(l,c),this.assertSuccess(`ghostty_terminal_grid_ref`,u)),l}selectAt(e,t,n,r){this.ensureActive();let i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=0,c=0,l=null;try{this.runtime.setField(o,e,`size`,i.size),s=this.gridRef(n,r);let u=i.fields.ref;if(this.runtime.bytes(o+u.offset,u.size).set(this.runtime.bytes(s,u.size)),c=this.runtime.alloc(a.size),this.runtime.setField(c,`GhosttySelection`,`size`,a.size),this.runtime.call(t,this.terminal,o,c)===K){let e=c+a.fields.start.offset,t=c+a.fields.end.offset,n=this.pointFromGridRef(e,1),r=this.pointFromGridRef(t,1),i=this.pointFromGridRef(e,2),o=this.pointFromGridRef(t,2);n&&r&&i&&o&&(l={viewport:{start:n,end:r},screen:{start:i,end:o}}),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,c)}}finally{this.runtime.free(c,a.size),this.runtime.free(s,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size)}return l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===K?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}getU16(e){return this.runtime.bytes(this.scratch,2).fill(0),this.assertSuccess(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)),this.runtime.view(this.scratch,2).getUint16(0,!0)}getU32(e){return this.runtime.bytes(this.scratch,4).fill(0),this.assertSuccess(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}getBool(e){return this.runtime.bytes(this.scratch,1)[0]=0,this.assertSuccess(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)),this.runtime.bytes(this.scratch,1)[0]!==0}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.renderState,e,this.scratch)===K?this.readColor(this.scratch):t}getRowBool(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===K&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t,n){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,t,this.scratch)===K?this.readColor(this.scratch):n}readColor(e){let t=this.runtime.memoryDataView();return{r:t.getUint8(e),g:t.getUint8(e+1),b:t.getUint8(e+2)}}emptyCell(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:!1,selected:!1}}assertSuccess(e,t){if(t!==K)throw Error(`${e} failed with result ${t}`)}ensureActive(){if(this.disposed)throw Error(`libghostty-vt terminal has been disposed`)}};function at(e,t){return nt(e,t)}var ot=`rgba(72, 122, 191, 0.35)`;function Z(e){return`rgb(${e.r}, ${e.g}, ${e.b})`}function st(e,t){return at(e.foreground,t.foreground)&&e.bold===t.bold&&e.italic===t.italic&&e.invisible===t.invisible}function ct(e,t,n){let r=t+1;for(;r<e.length;){let t=e[r];if(!t)break;if(t.wide===Qe.spacerTail){r+=1;continue}if(t.text.length===0||!n(t))break;r+=1}return r}function lt(e,t,n){return`${e.italic?`italic`:`normal`} ${e.bold?`700`:`400`} ${t}px ${n}`}function ut(e,t,n){e.font=`normal 400 ${t}px ${n}`;let r=e.measureText(`M`),i=e.measureText(`Mg`),a=i.actualBoundingBoxAscent||t,o=a+i.actualBoundingBoxDescent,s=Math.max(1,Math.round(t*1.35),Math.ceil(o));return{width:Math.max(1,r.width),height:s,baseline:Math.round((s-o)/2+a)}}function Q(e,t,n,r){return{cols:Math.max(1,Math.floor((e-r*2)/n.width)),rows:Math.max(1,Math.floor((t-r*2)/n.height))}}function dt(e){let{context:t,snapshot:n,metrics:r,fontSize:i,fontFamily:a,padding:o,forceFull:s,cursorOn:c,previousCursorY:l}=e,u=e.focused??!0,d=e.selectionBackground??ot,f=e.hoveredLinkRange??null,p=e.originY??o,m=s?Array.from({length:n.rows},(e,t)=>t):[...n.dirtyRows];l!=null&&l>=0&&!m.includes(l)&&m.push(l),n.cursorVisible&&n.cursorY>=0&&!m.includes(n.cursorY)&&m.push(n.cursorY),s&&(t.save(),t.resetTransform(),t.fillStyle=Z(n.background),t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore()),t.textBaseline=`alphabetic`;for(let e of m){let s=n.rowData[e];if(!s)continue;let c=p+e*r.height;t.fillStyle=Z(n.background),t.fillRect(o,c,n.cols*r.width,r.height);let l=0;for(;l<s.cells.length;){let e=s.cells[l];if(!e)break;let i=l+1;for(;i<s.cells.length;){let t=s.cells[i];if(!t||t.selected!==e.selected||!at(t.background,e.background))break;i+=1}if(e.selected||!at(e.background,n.background)){let a=o+l*r.width,s=(i-l)*r.width;at(e.background,n.background)||(t.fillStyle=Z(e.background),t.fillRect(a,c,s,r.height)),e.selected&&(t.fillStyle=d,t.fillRect(a,c,s,r.height))}l=i}let u=0;for(;u<s.cells.length;){let e=s.cells[u];if(!e)break;if(e.text.length===0){u+=1;continue}let n=ct(s.cells,u,t=>st(t,e)),l=s.cells.slice(u,n).map(e=>e.text).join(``);!e.invisible&&l.trim().length>0&&(t.save(),t.beginPath(),t.rect(o+u*r.width,c,(n-u)*r.width,r.height),t.clip(),t.font=lt(e,i,a),t.fillStyle=Z(e.foreground),t.fillText(l,o+u*r.width,c+r.baseline,(n-u)*r.width),t.restore()),u=n}for(let n=0;n<s.cells.length;n+=1){let i=s.cells[n],a=f!==null&&e>=f.start.y&&e<=f.end.y&&(e>f.start.y||n>=f.start.x)&&(e<f.end.y||n<=f.end.x);if(!i||!i.underline&&!i.strikethrough&&!i.overline&&!a)continue;t.fillStyle=Z(i.foreground);let l=o+n*r.width;(i.underline||a)&&t.fillRect(l,c+r.height-2,r.width,1),i.strikethrough&&t.fillRect(l,c+Math.floor(r.height*.55),r.width,1),i.overline&&t.fillRect(l,c+1,r.width,1)}}if(c&&n.cursorVisible&&n.cursorX>=0&&n.cursorY>=0){let e=o+n.cursorX*r.width,s=p+n.cursorY*r.height;if(t.fillStyle=Z(n.cursor),!u)t.strokeStyle=Z(n.cursor),t.strokeRect(e+.5,s+.5,r.width-1,r.height-1);else if(n.cursorStyle===0)t.fillRect(e,s,2,r.height);else if(n.cursorStyle===2)t.fillRect(e,s+r.height-2,r.width,2);else if(n.cursorStyle===3)t.strokeStyle=Z(n.cursor),t.strokeRect(e+.5,s+.5,r.width-1,r.height-1);else{t.fillRect(e,s,r.width,r.height);let o=n.rowData[n.cursorY]?.cells[n.cursorX];o?.text&&(t.font=lt(o,i,a),t.fillStyle=Z(n.background),t.fillText(o.text,e,s+r.baseline,r.width))}}}var ft=`/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2`,pt=6,mt=32,ht=`"Symbols Nerd Font Mono", "Symbols Nerd Font", "JetBrainsMono Nerd Font", "JetBrainsMono NF", "FiraCode Nerd Font", "Hack Nerd Font", "MesloLGS NF", "CaskaydiaCove Nerd Font", "PowerlineSymbols", monospace`,gt=`"SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", `+ht,$=4,_t=18,vt=500,yt=`iMW0@# .`,bt=[`normal 400`,`normal 700`,`italic 400`,`italic 700`],xt=null;function St(){return xt===null&&(xt=(async()=>{try{let e=new FontFace(`Symbols Nerd Font Mono`,`url(${ft})`);document.fonts.add(await e.load())}catch{}})()),xt}function Ct(e){return e.split(`,`).map(e=>{let t=e.trim();return t.length===0?``:/^(['"]).*\1$/.test(t)||/^[a-zA-Z][a-zA-Z0-9-]*$/.test(t)?t:`"${t.replaceAll(`"`,``)}"`}).filter(e=>e.length>0).join(`, `)}function wt(e){let t=e===void 0?``:Ct(e);return t.length===0?gt:`${t}, ${ht}`}function Tt(e){let t=e===void 0?``:Ct(e);return t.length===0||!F(t)?gt:wt(t)}async function Et(e,t,n){let r=wt(e),i=n?.load??((e,t)=>document.fonts.load(e,t));try{await Promise.all(bt.map(e=>i(`${e} ${t}px ${r}`,yt)))}catch{}return(n?.resolve??Tt)(e)}function Dt(e){return e===void 0||!Number.isFinite(e)?12:Math.max(pt,Math.min(mt,Math.round(e)))}function Ot(e){return e.focused&&e.cursorBlinking&&e.cursorVisible&&!e.reducedMotion}function kt(e,t,n,r,i){if(!i)return t;let a=e-t*2-n*r;return t+Math.max(0,a)}function At(e,t){let n=Math.max(0,e.total),r=Math.max(0,Math.min(e.len,n)),i=Math.max(0,n-r);if(t<=0||r<=0||i===0)return null;let a=Math.min(t,Math.max(_t,t*r/n));return{thumbHeight:a,thumbTop:Math.max(0,t-a)*(Math.max(0,Math.min(e.offset,i))/i),maxOffset:i}}function jt(e,t,n,r){let i=At(e,t);if(i===null)return 0;let a=Math.max(0,t-i.thumbHeight);if(a===0)return 0;let o=Math.max(0,Math.min(n-r,a));return Math.round(o/a*i.maxOffset)}function Mt(e){let{bounds:t,clientX:n,clientY:r,cols:i,rows:a,metrics:o,padding:s,originY:c}=e,l=n-t.left-s,u=r-t.top-c;return l<0||u<0||l>=i*o.width||u>=a*o.height?null:{x:Math.floor(l/o.width),y:Math.floor(u/o.height)}}function Nt(e,t){let n=e.cells.map(e=>e.text||` `).join(``);return t?n.trimEnd():n}function Pt(e,t){let n=0;for(let r=0;r<t;r+=1)n+=e.cells[r]?.text.length||1;return n}function Ft(e,t){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}function It(e,t){for(let n=0;n<e.cells.length;n+=1)if(t<Pt(e,n+1))return n;return Math.max(0,e.cells.length-1)}function Lt(e,t,n){let r=j(t+1,t=>{let n=e[t];return n?{isWrapped:n.isWrapContinuation,translateToString:(e=!1)=>Nt(n,e)}:null});if(!r)return null;let i=r.segments[0];if(i&&e[i.bufferLineNumber-1]?.isWrapContinuation)return null;let a=r.segments.find(e=>e.bufferLineNumber===t+1),o=e[t];if(!a||!o)return null;let s=r.segments.at(-1),c=s?e[s.bufferLineNumber-1]:void 0,l=c!==void 0&&c.wrapsToNext,u=a.startIndex+Pt(o,n);for(let t of Me(r.text))if(u>=t.start&&u<t.end){if(t.end===r.text.length&&l)return null;let n=r.segments.find(e=>t.start>=e.startIndex&&t.start<e.endIndex),i=r.segments.find(e=>t.end-1>=e.startIndex&&t.end-1<e.endIndex),a=n?e[n.bufferLineNumber-1]:void 0,o=i?e[i.bufferLineNumber-1]:void 0;return!n||!i||!a||!o?null:{text:t.text,range:{start:{x:It(a,t.start-n.startIndex),y:n.bufferLineNumber-1},end:{x:It(o,t.end-1-i.startIndex),y:i.bufferLineNumber-1}}}}return null}function Rt(e,t=navigator.platform){let n=e.key.toLowerCase();return n===`insert`&&!a(t)?e.ctrlKey&&!e.shiftKey&&!e.metaKey:n===`c`?a(t)?e.metaKey:e.ctrlKey:!1}function zt(e,t){e.value=t,t.length!==0&&e.select()}function Bt(e,t){t.length!==0&&e.value===t&&(e.value=``)}function Vt(e,t){return e.length===0||!t?{preventDefault:!1,claimWriteFallback:!1}:(t.setData(`text/plain`,e),{preventDefault:!0,claimWriteFallback:!0})}function Ht(e,t=navigator.platform){let n=e.key.toLowerCase();return n===`insert`&&!a(t)?e.shiftKey&&!e.ctrlKey&&!e.metaKey:n===`v`?a(t)?e.metaKey:e.ctrlKey&&e.shiftKey:!1}function Ut(){return/linux|bsd/i.test(navigator.platform)}function Wt(e){return e.inputType===``||e.inputType===`insertCompositionText`||e.inputType===`insertFromComposition`}function Gt(e,t){return e.isComposing||t||e.key===`Process`||e.keyCode===229}function Kt(e){return e.getModifierState(`AltGraph`)&&[...e.key].length===1}function qt(e,t){return e&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey}function Jt(e,t,n){let r=e===`motion`?t:``;return{send:t.length>0&&(e!==`motion`||t!==n),nextMotionData:r}}function Yt(e,t,n){return{tracking:t,motionData:e===t?n:``}}function Xt(e,t,n,r){let i=r+(e.deltaMode===1?e.deltaY*t:e.deltaMode===2?e.deltaY*n*t:e.deltaY)/t,a=Math.trunc(i);return{rows:a,remainder:i-a}}function Zt(e,t){return e===0?``:(e<0?t?`\x1BOA`:`\x1B[A`:t?`\x1BOB`:`\x1B[B`).repeat(Math.abs(e))}function Qt(e){switch(e){case 0:return 1;case 1:return 3;case 2:return 2;case 3:return 4;case 4:return 5;default:return null}}var $t=4;function en(e,t){return{count:e!==null&&t.timeStamp-e.time<=500&&Math.hypot(t.clientX-e.x,t.clientY-e.y)<=$t?e.count>=3?1:e.count+1:1,time:t.timeStamp,x:t.clientX,y:t.clientY}}var tn=class e{canvas;input;scrollbar;cols=1;rows=1;mount;context;core;options;visible;hasSize=!1;metrics;fontFamily;requestedFontFamily;fontSize;fontEpoch=0;pendingFontEpoch=null;stopObservingResize;scrollbarThumb;snapshot=null;frame=0;cursorTimer=null;compositionInputToSuppress=null;compositionSuppressionTimer=null;cursorOn=!0;renderedCursorY=null;forceFullRender=!0;scrollbarDirty=!0;scrollbarState=null;scrollbarPointerId=null;scrollbarPointerOffset=0;disposed=!1;resizeNotifyTimer=null;originY=$;mountHeight=0;selectionEnd=null;selectionAnchorScreen=null;selectionEndScreen=null;selectionMode=`cell`;selectionBase=null;selectionScrollTimer=null;selectionScrollDelta=0;selectionPointer=null;mouseReportingPointerId=null;mouseReportingButton=null;linkActivationPointerId=null;linkActivationLink=null;linkActivationOrigin=null;hoveredLink=null;hoverPointer=null;selectionClickSequence=null;selectionMoved=!1;composing=!1;focused=!1;resizeNotified=!1;canvasConfigured=!1;theme;suppressedKeyCodes=new Set;pasteShortcutToken=0;copyShortcutToken=0;clearSelectionAfterCopy=!1;primedCopySelection=``;wheelRemainder=0;touchScroll=null;lastMouseMotionData=``;mouseAnyEventTracking=!1;dprMedia=null;reducedMotionMedia=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);inputLeft=-1;inputTop=-1;constructor(e,t,n,r,i,a,o,s,c,l){this.mount=e,this.canvas=t,this.input=n,this.scrollbar=r,this.scrollbarThumb=i,this.context=a,this.core=o,this.mouseAnyEventTracking=o.isMouseAnyEventTracking(),this.metrics=s,this.options=l,this.visible=l.visible??!0,this.theme=l.theme,this.fontFamily=c,this.requestedFontFamily=l.font?.family,this.fontSize=Dt(l.font?.size),this.installEvents(),this.watchDevicePixelRatio(),this.reducedMotionMedia?.addEventListener(`change`,this.onReducedMotionChange),document.fonts.addEventListener(`loadingdone`,this.onFontsLoaded),this.stopObservingResize=_e(e,()=>this.fit())}static async create(t,n){let r=document.createElement(`canvas`);r.className=`block size-full cursor-text`,r.style.touchAction=`pan-x pinch-zoom`,r.setAttribute(`aria-hidden`,`true`);let i=document.createElement(`textarea`);i.className=`t3-ghostty-input`,i.setAttribute(`aria-label`,`Terminal input`),i.autocapitalize=`off`,i.autocomplete=`off`,i.spellcheck=!1,i.style.cssText=`position:absolute;left:4px;top:4px;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;`;let a=document.createElement(`div`);a.className=`group absolute top-1 right-px bottom-1 z-1 w-[var(--app-scrollbar-width)] cursor-default touch-none`,a.setAttribute(`role`,`scrollbar`),a.setAttribute(`aria-label`,`Terminal scrollback`),a.setAttribute(`aria-orientation`,`vertical`),a.tabIndex=0,a.hidden=!0;let o=document.createElement(`div`);o.className=`absolute inset-x-px top-0 rounded-[3px] bg-[var(--app-scrollbar-thumb)] transition-[background-color] duration-[120ms] ease-[ease-out] group-hover:bg-[var(--app-scrollbar-thumb-hover)] group-focus-visible:bg-[var(--app-scrollbar-thumb-hover)]`,a.append(o),t.replaceChildren(r,i,a);let s=r.getContext(`2d`,{alpha:!1});if(!s)throw Error(`Canvas 2D is unavailable`);s.fillStyle=`rgb(${n.theme.background.r}, ${n.theme.background.g}, ${n.theme.background.b})`,s.fillRect(0,0,r.width,r.height);let c=Dt(n.font?.size);try{await St()}catch{}let l=await Et(n.font?.family,c),u=ut(s,c,l),d=Q(t.clientWidth,t.clientHeight,u,$),f=await it.create(d.cols,d.rows,u.width,u.height,n.theme,n.onData),p=new e(t,r,i,a,o,s,f,u,l,n);return p.fit(),p}setVisible(e){if(!(this.disposed||this.visible===e)){if(this.visible=e,this.cursorOn=!0,this.forceFullRender=!0,this.scrollbarDirty=!0,!e){this.cancelRender(),this.setSelectionAutoscroll(0);return}this.fit()}}write(e){this.disposed||(this.core.write(e),this.synchronizeMouseTrackingState(),this.cursorOn=!0,this.scrollbarDirty=!0,this.requestRender())}resetAndWrite(e){this.disposed||(this.lastMouseMotionData=``,this.core.resetAndWrite(e),this.synchronizeMouseTrackingState(),this.cursorOn=!0,this.forceFullRender=!0,this.scrollbarDirty=!0,this.requestRender())}setTheme(e){this.disposed||(this.theme=e,this.core.setTheme(e),this.forceFullRender=!0,this.requestRender())}refreshLinkActivation(){this.disposed||this.refreshHoveredLink()}async setFont(e){if(this.disposed)return;let t=Dt(e.size),n=++this.fontEpoch;this.pendingFontEpoch=n;let r=await Et(e.family,t);this.disposed||n!==this.fontEpoch||(this.pendingFontEpoch=null,this.fontFamily=r,this.requestedFontFamily=e.family,this.fontSize=t,this.applyFontMetrics())}applyFontMetrics(){this.metrics=ut(this.context,this.fontSize,this.fontFamily),this.core.resize(this.cols,this.rows,this.metrics.width,this.metrics.height),this.inputLeft=-1,this.inputTop=-1,this.forceFullRender=!0,this.scrollbarDirty=!0,this.fit(),this.requestRender()}onReducedMotionChange=()=>{this.disposed||(this.cursorOn=!0,this.requestRender())};onFontsLoaded=()=>{if(this.disposed||this.pendingFontEpoch!==null)return;let e=Tt(this.requestedFontFamily);if(e!==this.fontFamily){this.fontFamily=e,this.applyFontMetrics();return}let t=ut(this.context,this.fontSize,this.fontFamily);(t.width!==this.metrics.width||t.height!==this.metrics.height||t.baseline!==this.metrics.baseline)&&this.applyFontMetrics()};resendSize(){this.resizeNotified=!1,this.fit()}fit(){if(this.disposed||!this.visible)return!1;let e=this.mount.clientWidth,t=this.mount.clientHeight;if(e<=0||t<=0)return this.hasSize=!1,this.forceFullRender=!0,this.cancelRender(),!1;this.hasSize=!0;let n=window.devicePixelRatio||1,r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n)),a=!1;(this.canvas.width!==r||this.canvas.height!==i||!this.canvasConfigured)&&(this.canvas.width=r,this.canvas.height=i,this.context.setTransform(n,0,0,n,0,0),this.canvasConfigured=!0,this.forceFullRender=!0,this.scrollbarDirty=!0,a=!0);let o=Q(e,t,this.metrics,$);return this.mountHeight=t,(o.cols!==this.cols||o.rows!==this.rows||!this.resizeNotified)&&(this.cols=o.cols,this.rows=o.rows,this.core.resize(o.cols,o.rows,this.metrics.width,this.metrics.height),this.notifyResize(),this.forceFullRender=!0,this.scrollbarDirty=!0,a=!0),(a||this.forceFullRender)&&this.renderFrame(),!0}notifyResize(){this.resizeNotified=!0,this.resizeNotifyTimer!==null&&window.clearTimeout(this.resizeNotifyTimer),this.resizeNotifyTimer=window.setTimeout(()=>{this.resizeNotifyTimer=null,this.disposed||this.options.onResize(this.cols,this.rows)},150)}onWindowPointerRelease=()=>{this.disposed||this.resizeNotifyTimer===null||(this.fit(),this.resizeNotifyTimer!==null&&(window.clearTimeout(this.resizeNotifyTimer),this.resizeNotifyTimer=null,this.options.onResize(this.cols,this.rows)))};focus(){!this.disposed&&this.visible&&this.input.focus({preventScroll:!0})}async pasteFromClipboard(e,t=()=>!0){let n=++this.pasteShortcutToken,r=await e();if(this.disposed||this.pasteShortcutToken!==n||!t()||(this.pasteShortcutToken+=1,r.length===0))return;let i=this.core.encodePaste(r);i.length>0&&this.options.onData(i)}pasteTerminalSelection(){let e=this.getSelection();e.length!==0&&this.pasteFromClipboard(()=>Promise.resolve(e))}hasSelection(){return this.core.selectionText().length>0}getSelection(){return this.core.selectionText()}selectAll(){this.clearPrimedCopy();let e=this.core.selectAll();this.selectionAnchorScreen=e?.start??null,this.selectionEndScreen=e?.end??null,this.selectionEnd=e?this.core.screenPointToViewport(e.end.x,e.end.y):null,this.selectionMode=`cell`,this.selectionBase=null,this.setSelectionAutoscroll(0),this.options.onSelectionChange(),this.forceFullRender=!0,this.requestRender()}getSelectionPosition(){return!this.selectionAnchorScreen||!this.selectionEndScreen||!this.hasSelection()?null:this.selectionAnchorScreen.y<this.selectionEndScreen.y||this.selectionAnchorScreen.y===this.selectionEndScreen.y&&this.selectionAnchorScreen.x<=this.selectionEndScreen.x?{start:this.selectionAnchorScreen,end:this.selectionEndScreen}:{start:this.selectionEndScreen,end:this.selectionAnchorScreen}}getSelectionEndClientRect(){let e=this.getSelectionPosition();if(!e)return null;let t=this.core.screenPointToViewport(e.end.x,e.end.y);if(!t||t.x<0||t.x>=this.cols||t.y<0||t.y>=this.rows)return null;let n=this.canvas.getBoundingClientRect();return{right:n.left+$+(t.x+1)*this.metrics.width,bottom:n.top+this.originY+(t.y+1)*this.metrics.height}}clearSelection(){this.clearPrimedCopy(),this.core.clearSelection(),this.selectionEnd=null,this.selectionAnchorScreen=null,this.selectionEndScreen=null,this.selectionMode=`cell`,this.selectionBase=null,this.setSelectionAutoscroll(0),this.options.onSelectionChange(),this.forceFullRender=!0,this.requestRender()}scrollToBottom(){this.core.scrollToBottom(),this.forceFullRender=!0,this.scrollbarDirty=!0,this.requestRender()}isAtBottom(){return this.core.isViewportActive()}dispose(){this.disposed||(this.disposed=!0,this.stopObservingResize(),document.fonts.removeEventListener(`loadingdone`,this.onFontsLoaded),this.dprMedia?.removeEventListener(`change`,this.onDevicePixelRatioChange),this.dprMedia=null,this.reducedMotionMedia?.removeEventListener(`change`,this.onReducedMotionChange),this.selectionScrollTimer!==null&&window.clearInterval(this.selectionScrollTimer),this.resizeNotifyTimer!==null&&(window.clearTimeout(this.resizeNotifyTimer),this.resizeNotifyTimer=null,this.options.onResize(this.cols,this.rows)),this.cancelRender(),this.compositionSuppressionTimer!==null&&window.clearTimeout(this.compositionSuppressionTimer),this.removeEvents(),this.core.dispose(),(this.canvas.parentElement===this.mount||this.input.parentElement===this.mount||this.scrollbar.parentElement===this.mount)&&(this.canvas.remove(),this.input.remove(),this.scrollbar.remove()))}onKeyDown=e=>{if(Kt(e)||!this.options.beforeKey(e)){this.suppressedKeyCodes.add(e.code);return}if(Gt(e,this.composing)){this.suppressedKeyCodes.add(e.code);return}let t=a(navigator.platform),n=t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey;if(e.key.toLowerCase()===`a`&&n&&!e.altKey&&(t?!e.shiftKey:e.shiftKey)){e.preventDefault(),e.stopPropagation(),this.suppressedKeyCodes.add(e.code),this.selectAll();return}let r=e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&(e.key===`PageUp`||e.key===`PageDown`),i=e.shiftKey&&!e.altKey&&n&&(e.key===`Home`||e.key===`End`);if((r||i)&&!this.core.isAlternateScreen()){let t=this.readScrollbarState();if(t!==null){e.preventDefault(),e.stopPropagation(),this.suppressedKeyCodes.add(e.code);let n=e.key===`Home`?-t.offset:e.key===`End`?t.total-t.len-t.offset:Math.max(1,t.len)*(e.key===`PageUp`?-1:1);this.scrollViewport(n);return}}if(Rt(e)&&this.hasSelection()){let t=this.getSelection();if(this.primeCopy(t),e.shiftKey||e.key.toLowerCase()===`insert`)e.preventDefault(),document.execCommand(`copy`);else{this.clearSelectionAfterCopy=!e.shiftKey&&!a(navigator.platform);let n=navigator.clipboard;if(typeof n?.writeText==`function`){let e=++this.copyShortcutToken;Promise.resolve().then(()=>{this.disposed||this.copyShortcutToken!==e||n.writeText(t).then(()=>{this.disposed||this.copyShortcutToken!==e||this.clearSelectionAfterCopy&&(this.clearSelectionAfterCopy=!1,this.clearSelection())},()=>{this.copyShortcutToken===e&&(this.clearSelectionAfterCopy=!1)})})}}this.suppressedKeyCodes.add(e.code);return}if(Ht(e)){this.suppressedKeyCodes.add(e.code);let t=navigator.clipboard;if(typeof t?.readText==`function`){let e=++this.pasteShortcutToken;t.readText().then(t=>{this.disposed||this.pasteShortcutToken!==e||(this.pasteShortcutToken+=1,t.length>0&&this.options.onData(this.core.encodePaste(t)))},()=>{})}return}this.clearPrimedCopy();let o=this.core.encodeKey(e);o.length!==0&&(this.suppressedKeyCodes.delete(e.code),e.preventDefault(),e.stopPropagation(),this.options.onData(o))};onKeyUp=e=>{if(this.suppressedKeyCodes.delete(e.code)||Gt(e,this.composing))return;let t=this.core.encodeKey(e,`release`);t.length!==0&&(e.preventDefault(),e.stopPropagation(),this.options.onData(t))};onFocus=()=>{this.focused=!0,this.cursorOn=!0,this.requestRender()};onBlur=()=>{this.focused=!1,this.refreshHoveredLink(),this.cursorOn=!0,this.requestRender()};onDevicePixelRatioChange=()=>{this.watchDevicePixelRatio(),this.fit()};watchDevicePixelRatio(){this.dprMedia?.removeEventListener(`change`,this.onDevicePixelRatioChange),this.dprMedia=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.dprMedia.addEventListener(`change`,this.onDevicePixelRatioChange)}primeCopy(e){this.primedCopySelection=e,zt(this.input,e)}clearPrimedCopy(){Bt(this.input,this.primedCopySelection),this.primedCopySelection=``}onCopyEvent=e=>{let t=this.hasSelection()?this.getSelection():this.input.value;this.primeCopy(t);let n=Vt(t,e.clipboardData);n.preventDefault&&e.preventDefault(),n.claimWriteFallback&&(this.copyShortcutToken+=1,this.clearSelectionAfterCopy&&(this.clearSelectionAfterCopy=!1,this.clearSelection()))};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;t.length!==0&&(this.pasteShortcutToken+=1,this.options.onData(this.core.encodePaste(t)))};onCompositionStart=()=>{this.clearPrimedCopy(),this.clearCompositionInputSuppression(),this.composing=!0};onCompositionEnd=e=>{this.composing=!1;let t=this.input.value||e.data;t.length>0&&this.options.onData(t),this.input.value=``,this.compositionInputToSuppress=t,this.compositionSuppressionTimer=window.setTimeout(()=>{this.compositionInputToSuppress=null,this.compositionSuppressionTimer=null},100)};onInput=e=>{let t=e;if(this.composing||t.isComposing)return;let n=this.input.value||t.data||``;if(n===this.compositionInputToSuppress&&Wt(t)){this.clearCompositionInputSuppression(),this.input.value=``;return}this.clearCompositionInputSuppression(),n.length>0&&this.options.onData(n),this.input.value=``};clearCompositionInputSuppression(){this.compositionSuppressionTimer!==null&&(window.clearTimeout(this.compositionSuppressionTimer),this.compositionSuppressionTimer=null),this.compositionInputToSuppress=null}onPointerDown=e=>{if(e.pointerType===`touch`){if(e.preventDefault(),!e.isPrimary||this.touchScroll!==null)return;this.touchScroll={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,lastY:e.clientY,remainder:0,moved:!1},this.clearHoveredLink(),this.canvas.setPointerCapture(e.pointerId);return}if(this.focus(),qt(this.core.isMouseTracking(),e)){let t=Qt(e.button);if(t===null)return;e.preventDefault(),e.stopPropagation(),this.clearHoveredLink(`default`),this.mouseReportingPointerId=e.pointerId,this.mouseReportingButton=t,this.sendMouse(`press`,t,e),this.canvas.setPointerCapture(e.pointerId);return}if(e.button===1&&Ut()){this.pasteTerminalSelection();return}if(e.button!==0)return;let t=this.recordSelectionClick(e),n=this.linkAt(e.clientX,e.clientY);if(n&&!e.shiftKey&&t===1){e.preventDefault(),e.stopPropagation(),this.linkActivationPointerId=e.pointerId,this.linkActivationLink=n,this.linkActivationOrigin={x:e.clientX,y:e.clientY,clickCount:t},this.canvas.setPointerCapture(e.pointerId);return}this.clearHoveredLink(),this.beginSelection(e,t),this.canvas.setPointerCapture(e.pointerId)};recordSelectionClick(e){return this.selectionClickSequence=en(this.selectionClickSequence,e),this.selectionClickSequence.count}beginSelection(e,t){let n=this.cellAt(e.clientX,e.clientY);this.selectionMoved=!1,this.selectionMode=t>=3?`line`:t===2?`word`:`cell`;let r=this.selectionMode===`line`?this.core.selectLine(n.x,n.y):this.selectionMode===`word`?this.core.selectWord(n.x,n.y):null;if(r)this.selectionBase=r.screen,this.selectionEnd=r.viewport.end,this.selectionAnchorScreen=r.screen.start,this.selectionEndScreen=r.screen.end,this.options.onSelectionChange();else{this.selectionMode=`cell`,this.selectionBase=null,this.selectionEnd=n;let e=this.core.viewportPointToScreen(n.x,n.y);this.selectionAnchorScreen=e,this.selectionEndScreen=e,e?this.core.setSelection({...e,tag:2},{...e,tag:2}):this.core.setSelection(n,n)}this.forceFullRender=!0,this.requestRender()}onPointerMove=e=>{if(e.pointerType===`touch`){let t=this.touchScroll;if(t?.pointerId!==e.pointerId||(e.preventDefault(),t.moved||=Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>$t,!t.moved))return;let n=Xt({deltaY:t.lastY-e.clientY,deltaMode:0},this.metrics.height,this.rows,t.remainder);t.lastY=e.clientY,t.remainder=n.remainder,this.scrollRows(n.rows,e);return}if(this.linkActivationPointerId===e.pointerId){let t=this.linkActivationOrigin;if(t===null||Math.hypot(e.clientX-t.x,e.clientY-t.y)<=$t)return;this.linkActivationPointerId=null,this.linkActivationLink=null,this.linkActivationOrigin=null,this.clearHoveredLink(),this.beginSelection({clientX:t.x,clientY:t.y},t.clickCount)}let t=this.synchronizeMouseTrackingState();if(this.mouseReportingPointerId===e.pointerId||qt(t,e)){e.preventDefault(),this.hoverPointer={x:e.clientX,y:e.clientY},this.setHoveredLink(null),this.canvas.style.cursor=`default`,this.sendMouse(`motion`,this.buttonFromButtons(e.buttons),e);return}if(this.lastMouseMotionData=``,!this.selectionAnchorScreen||!this.canvas.hasPointerCapture(e.pointerId)){this.updateHoverCursor(e);return}this.clearHoveredLink(),this.selectionPointer={x:e.clientX,y:e.clientY};let n=this.canvas.getBoundingClientRect(),r=Math.max(n.top,0)+$,i=Math.min(n.bottom,window.innerHeight)-$;this.setSelectionAutoscroll(e.clientY<r?-1:+(e.clientY>i));let a=this.cellAt(e.clientX,e.clientY);(a.x!==this.selectionEnd?.x||a.y!==this.selectionEnd.y)&&this.extendSelectionTo(e.clientX,e.clientY)};extendSelectionTo(e,t){let n=this.selectionAnchorScreen;if(n===null)return;let r=this.cellAt(e,t);this.selectionMoved=!0,this.selectionEnd=r;let i=this.selectionMode===`line`?this.core.selectLine(r.x,r.y):this.selectionMode===`word`?this.core.selectWord(r.x,r.y):null,a=this.core.viewportPointToScreen(r.x,r.y);if(a===null)return;let o=this.selectionBase,s=o!==null&&(a.y<o.start.y||a.y===o.start.y&&a.x<o.start.x),c=o===null?n:s?o.end:o.start,l=i===null?a:s?i.screen.start:i.screen.end;this.selectionAnchorScreen=c,this.selectionEndScreen=l,this.core.setSelection({...c,tag:2},{...l,tag:2}),this.options.onSelectionChange(),this.forceFullRender=!0,this.requestRender()}setSelectionAutoscroll(e){if(this.selectionScrollDelta=e,e===0){this.selectionScrollTimer!==null&&(window.clearInterval(this.selectionScrollTimer),this.selectionScrollTimer=null);return}this.selectionScrollTimer===null&&(this.selectionScrollTimer=window.setInterval(()=>{if(this.disposed||this.selectionScrollDelta===0)return;this.scrollViewport(this.selectionScrollDelta);let e=this.selectionPointer;e&&this.extendSelectionTo(e.x,e.y)},80))}updateHoverCursor(e){this.hoverPointer={x:e.clientX,y:e.clientY},this.refreshHoveredLink()}onPointerLeave=()=>{this.lastMouseMotionData=``,this.clearHoveredLink()};clearHoveredLink(e=``){this.hoverPointer=null,this.setHoveredLink(null),this.canvas.style.cursor=e}refreshHoveredLink(){let e=this.hoverPointer,t=e?this.linkAt(e.x,e.y):null;this.setHoveredLink(t)}setHoveredLink(e){let t=this.hoveredLink,n=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;this.canvas.style.cursor=e?`pointer`:``,!n&&(this.hoveredLink=e,this.forceFullRender=!0,this.requestRender())}onPointerUp=e=>{if(e.pointerType===`touch`){let t=this.touchScroll;if(t?.pointerId!==e.pointerId||(this.touchScroll=null,e.preventDefault(),this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.type===`pointercancel`||t.moved))return;if(this.focus(),qt(this.core.isMouseTracking(),e))this.sendMouse(`press`,Qt(0),e),this.sendMouse(`release`,Qt(0),e);else{let t=this.linkAt(e.clientX,e.clientY);t?this.options.onLinkActivate(t.text,e):this.clearSelection()}return}if(this.setSelectionAutoscroll(0),this.linkActivationPointerId===e.pointerId){e.preventDefault(),e.stopPropagation();let t=this.linkActivationLink;this.linkActivationPointerId=null,this.linkActivationLink=null,this.linkActivationOrigin=null,this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.type!==`pointercancel`&&t&&Ft(t,this.linkAt(e.clientX,e.clientY))&&this.options.onLinkActivate(t.text,e);return}if(this.mouseReportingPointerId===e.pointerId){e.preventDefault(),e.stopPropagation(),this.sendMouse(`release`,this.mouseReportingButton,e),this.mouseReportingPointerId=null,this.mouseReportingButton=null,this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.type===`pointercancel`?this.clearHoveredLink():(this.hoverPointer={x:e.clientX,y:e.clientY},this.refreshHoveredLink());return}if(this.canvas.hasPointerCapture(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId),e.button===1&&Ut()){e.preventDefault();return}e.button===0&&(!this.selectionMoved&&this.selectionMode===`cell`&&this.clearSelection(),this.options.onSelectionChange())};onWheel=e=>{if(e.deltaY===0)return;e.preventDefault();let t=Xt(e,this.metrics.height,this.rows,this.wheelRemainder);this.wheelRemainder=t.remainder,this.scrollRows(t.rows,e)};scrollRows(e,t){if(e===0)return;let n=Math.abs(e);if(qt(this.core.isMouseTracking(),t)){let r=e<0?4:5;for(let e=0;e<n;e+=1)this.sendMouse(`press`,r,t);return}if(this.core.isAlternateScreen()){this.options.onData(Zt(e,this.core.isApplicationCursorKeys()));return}this.scrollViewport(e)}onMouseDown=e=>{(e.button===0||e.button===1&&Ut())&&e.preventDefault(),this.focus()};onMouseUp=e=>{e.button===1&&Ut()&&e.preventDefault()};onContextMenu=e=>{if(qt(this.core.isMouseTracking(),e)){e.preventDefault();return}this.options.onContextMenu?.(e)};onScrollbarPointerDown=e=>{if(e.button!==0)return;let t=this.readScrollbarState();if(t===null)return;let n=this.scrollbar.getBoundingClientRect(),r=At(t,n.height);r!==null&&(e.preventDefault(),e.stopPropagation(),this.scrollbarPointerId=e.pointerId,this.scrollbarPointerOffset=e.target===this.scrollbarThumb?e.clientY-n.top-r.thumbTop:r.thumbHeight/2,this.scrollbar.setPointerCapture(e.pointerId),this.scrollbarToPointer(e.clientY,n))};onScrollbarPointerMove=e=>{e.pointerId===this.scrollbarPointerId&&this.scrollbarState!==null&&(e.preventDefault(),this.scrollbarToPointer(e.clientY,this.scrollbar.getBoundingClientRect()))};onScrollbarPointerUp=e=>{e.pointerId===this.scrollbarPointerId&&(e.preventDefault(),this.scrollbarPointerId=null,this.scrollbar.hasPointerCapture(e.pointerId)&&this.scrollbar.releasePointerCapture(e.pointerId))};onScrollbarKeyDown=e=>{let t=this.readScrollbarState();if(t===null)return;let n=0;switch(e.key){case`ArrowUp`:n=-1;break;case`ArrowDown`:n=1;break;case`PageUp`:n=-Math.max(1,t.len);break;case`PageDown`:n=Math.max(1,t.len);break;case`Home`:n=-t.offset;break;case`End`:n=t.total-t.len-t.offset;break;default:return}e.preventDefault(),e.stopPropagation(),this.scrollViewport(n)};installEvents(){this.input.addEventListener(`keydown`,this.onKeyDown),this.input.addEventListener(`keyup`,this.onKeyUp),this.input.addEventListener(`focus`,this.onFocus),this.input.addEventListener(`blur`,this.onBlur),this.input.addEventListener(`input`,this.onInput),this.input.addEventListener(`paste`,this.onPaste),this.input.addEventListener(`copy`,this.onCopyEvent),this.input.addEventListener(`compositionstart`,this.onCompositionStart),this.input.addEventListener(`compositionend`,this.onCompositionEnd),this.canvas.addEventListener(`pointerdown`,this.onPointerDown),this.canvas.addEventListener(`pointermove`,this.onPointerMove),this.canvas.addEventListener(`pointerleave`,this.onPointerLeave),this.canvas.addEventListener(`pointerup`,this.onPointerUp),this.canvas.addEventListener(`pointercancel`,this.onPointerUp),this.canvas.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.canvas.addEventListener(`mousedown`,this.onMouseDown),this.canvas.addEventListener(`mouseup`,this.onMouseUp),this.canvas.addEventListener(`contextmenu`,this.onContextMenu),this.scrollbar.addEventListener(`pointerdown`,this.onScrollbarPointerDown),this.scrollbar.addEventListener(`pointermove`,this.onScrollbarPointerMove),this.scrollbar.addEventListener(`pointerup`,this.onScrollbarPointerUp),this.scrollbar.addEventListener(`pointercancel`,this.onScrollbarPointerUp),this.scrollbar.addEventListener(`keydown`,this.onScrollbarKeyDown),window.addEventListener(`pointerup`,this.onWindowPointerRelease),window.addEventListener(`pointercancel`,this.onWindowPointerRelease)}removeEvents(){this.input.removeEventListener(`keydown`,this.onKeyDown),this.input.removeEventListener(`keyup`,this.onKeyUp),this.input.removeEventListener(`focus`,this.onFocus),this.input.removeEventListener(`blur`,this.onBlur),this.input.removeEventListener(`input`,this.onInput),this.input.removeEventListener(`paste`,this.onPaste),this.input.removeEventListener(`copy`,this.onCopyEvent),this.input.removeEventListener(`compositionstart`,this.onCompositionStart),this.input.removeEventListener(`compositionend`,this.onCompositionEnd),this.canvas.removeEventListener(`pointerdown`,this.onPointerDown),this.canvas.removeEventListener(`pointermove`,this.onPointerMove),this.canvas.removeEventListener(`pointerleave`,this.onPointerLeave),this.canvas.removeEventListener(`pointerup`,this.onPointerUp),this.canvas.removeEventListener(`pointercancel`,this.onPointerUp),this.canvas.removeEventListener(`wheel`,this.onWheel),this.canvas.removeEventListener(`mousedown`,this.onMouseDown),this.canvas.removeEventListener(`mouseup`,this.onMouseUp),this.canvas.removeEventListener(`contextmenu`,this.onContextMenu),this.scrollbar.removeEventListener(`pointerdown`,this.onScrollbarPointerDown),this.scrollbar.removeEventListener(`pointermove`,this.onScrollbarPointerMove),this.scrollbar.removeEventListener(`pointerup`,this.onScrollbarPointerUp),this.scrollbar.removeEventListener(`pointercancel`,this.onScrollbarPointerUp),this.scrollbar.removeEventListener(`keydown`,this.onScrollbarKeyDown),window.removeEventListener(`pointerup`,this.onWindowPointerRelease),window.removeEventListener(`pointercancel`,this.onWindowPointerRelease)}scrollViewport(e){let t=Math.trunc(e),n=this.readScrollbarState();if(n!==null){let e=Math.max(0,n.total-n.len),r=Math.max(0,Math.min(n.offset+t,e));t=r-n.offset,this.scrollbarState={...n,offset:r}}t!==0&&(this.core.scroll(t),this.forceFullRender=!0,this.scrollbarDirty=!0,this.requestRender())}scrollbarToPointer(e,t){let n=this.scrollbarState;if(n===null)return;let r=jt(n,t.height,e-t.top,this.scrollbarPointerOffset);this.scrollViewport(r-n.offset)}updateScrollbar(){let e=this.readScrollbarState(),t=e===null?null:At(e,Math.max(0,this.mount.clientHeight-8));this.scrollbar.hidden=t===null,e!==null&&t!==null&&(this.scrollbar.setAttribute(`aria-valuemin`,`0`),this.scrollbar.setAttribute(`aria-valuemax`,String(t.maxOffset)),this.scrollbar.setAttribute(`aria-valuenow`,String(Math.max(0,Math.min(e.offset,t.maxOffset)))),this.scrollbarThumb.style.height=`${t.thumbHeight}px`,this.scrollbarThumb.style.transform=`translateY(${t.thumbTop}px)`)}readScrollbarState(){let e=this.core.scrollbarState();return this.scrollbarState=e,e}requestRender(){!this.disposed&&this.visible&&this.hasSize&&this.frame===0&&(this.frame=window.requestAnimationFrame(()=>{this.frame=0,this.renderFrame()}))}cancelRender(){this.frame!==0&&(window.cancelAnimationFrame(this.frame),this.frame=0),this.cursorTimer!==null&&(window.clearTimeout(this.cursorTimer),this.cursorTimer=null)}renderFrame(){if(this.disposed||!this.visible)return;if(this.frame!==0&&(window.cancelAnimationFrame(this.frame),this.frame=0),this.mount.clientWidth===0||this.mount.clientHeight===0){this.hasSize=!1,this.forceFullRender=!0,this.cancelRender();return}this.snapshot=this.core.snapshot(),this.blinkEnabled()||(this.cursorOn=!0);let e=this.readScrollbarState(),t=e!==null&&e.total>e.len,n=kt(this.mountHeight,$,this.rows,this.metrics.height,t);n!==this.originY&&(this.originY=n,this.forceFullRender=!0),this.refreshHoveredLink(),dt({context:this.context,snapshot:this.snapshot,metrics:this.metrics,fontSize:this.fontSize,fontFamily:this.fontFamily,padding:$,originY:this.originY,forceFull:this.forceFullRender,cursorOn:this.cursorOn,previousCursorY:this.renderedCursorY,focused:this.focused,hoveredLinkRange:this.hoveredLink?.range??null,...this.theme.selectionBackground===void 0?{}:{selectionBackground:this.theme.selectionBackground}}),this.positionInput(),this.renderedCursorY=this.cursorOn&&this.snapshot.cursorVisible&&this.snapshot.cursorY>=0?this.snapshot.cursorY:null,this.scrollbarDirty&&(this.scrollbarDirty=!1,this.updateScrollbar()),this.forceFullRender=!1,this.scheduleCursorBlink()}scheduleCursorBlink(){this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,this.blinkEnabled()&&(this.cursorTimer=window.setTimeout(()=>{this.cursorTimer=null,this.cursorOn=!this.cursorOn,this.requestRender()},vt))}blinkEnabled(){let e=this.snapshot;return!e||!this.visible||!this.hasSize?!1:Ot({focused:this.focused,cursorBlinking:e.cursorBlinking,cursorVisible:e.cursorVisible,reducedMotion:this.reducedMotionMedia?.matches??!1})}positionInput(){let e=this.snapshot;if(!e||!e.cursorVisible||e.cursorX<0||e.cursorY<0)return;let t=$+e.cursorX*this.metrics.width,n=this.originY+e.cursorY*this.metrics.height;(t!==this.inputLeft||n!==this.inputTop)&&(this.inputLeft=t,this.inputTop=n,this.input.style.left=`${t}px`,this.input.style.top=`${n}px`,this.input.style.height=`${this.metrics.height}px`)}cellAt(e,t){let n=this.canvas.getBoundingClientRect();return{x:Math.max(0,Math.min(this.cols-1,Math.floor((e-n.left-$)/this.metrics.width))),y:Math.max(0,Math.min(this.rows-1,Math.floor((t-n.top-this.originY)/this.metrics.height)))}}linkAt(e,t){let n=this.findLinkAt(e,t);return n&&this.options.canActivateLink?.(n.text)!==!1?n:null}findLinkAt(e,t){if(!this.snapshot)return null;let n=Mt({bounds:this.canvas.getBoundingClientRect(),clientX:e,clientY:t,cols:this.cols,rows:this.rows,metrics:this.metrics,padding:$,originY:this.originY});if(!n)return null;let r=this.core.hyperlinkAt(n.x,n.y);if(r){let e={...n},t={...n};for(;;){let t=e.x>0?{x:e.x-1,y:e.y}:e.y>0&&this.snapshot.rowData[e.y]?.isWrapContinuation?{x:this.cols-1,y:e.y-1}:null;if(!t||this.core.hyperlinkAt(t.x,t.y)!==r)break;e.x=t.x,e.y=t.y}for(;;){let e=t.x+1<this.cols?{x:t.x+1,y:t.y}:t.y+1<this.rows&&this.snapshot.rowData[t.y]?.wrapsToNext?{x:0,y:t.y+1}:null;if(!e||this.core.hyperlinkAt(e.x,e.y)!==r)break;t.x=e.x,t.y=e.y}return{text:r,range:{start:e,end:t}}}return Lt(this.snapshot.rowData,n.y,n.x)}sendMouse(e,t,n){let r=this.canvas.getBoundingClientRect(),i=this.core.encodeMouse({action:e,button:t,mods:+!!n.shiftKey|(n.ctrlKey?2:0)|(n.altKey?4:0)|(n.metaKey?8:0),x:Math.max(0,n.clientX-r.left),y:Math.max(0,n.clientY-r.top),screenWidth:r.width,screenHeight:r.height,cellWidth:this.metrics.width,cellHeight:this.metrics.height,paddingLeft:$,paddingRight:$,paddingTop:this.originY,paddingBottom:Math.max(0,r.height-this.originY-this.rows*this.metrics.height),anyButtonPressed:n.buttons!==0}),a=Jt(e,i,this.lastMouseMotionData);this.lastMouseMotionData=a.nextMotionData,a.send&&this.options.onData(i)}synchronizeMouseTrackingState(){let e=this.core.isMouseAnyEventTracking(),t=Yt(this.mouseAnyEventTracking,e,this.lastMouseMotionData);return this.mouseAnyEventTracking=t.tracking,this.lastMouseMotionData=t.motionData,e}buttonFromButtons(e){return e&1?1:e&4?3:e&2?2:e&8?4:e&16?5:null}};function nn(e){let t=(0,ze.c)(14),{children:n,label:r,onClick:i,tooltip:a}=e,o;t[0]===n?o=t[1]:(o=(0,L.jsx)(`span`,{className:`relative flex size-3 items-center justify-center group-hover/tab:hidden group-focus-visible/close:hidden`,children:n}),t[0]=n,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(d,{className:`hidden size-3 group-hover/tab:block group-focus-visible/close:block`}),t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==i||t[5]!==o?(c=(0,L.jsxs)(`button`,{type:`button`,className:`cursor-pointer group/close relative flex size-4 shrink-0 items-center justify-center rounded-sm hover:bg-muted`,"aria-label":r,onClick:i,children:[o,s]}),t[3]=r,t[4]=i,t[5]=o,t[6]=c):c=t[6];let l=c;if(!a)return l;let u;t[7]===l?u=t[8]:(u=(0,L.jsx)(b,{render:l}),t[7]=l,t[8]=u);let f;t[9]===a?f=t[10]:(f=(0,L.jsx)(x,{children:a}),t[9]=a,t[10]=f);let p;return t[11]!==u||t[12]!==f?(p=(0,L.jsxs)(S,{children:[u,f]}),t[11]=u,t[12]=f,t[13]=p):p=t[13],p}var rn=0;function an(){return rn>0}async function on(e){let t=me();if(!t)return!0;rn+=1;try{return await t.dialogs.confirm(e.length===1?[`Close terminal "${e[0]}"?`,`This stops the running process and clears its history.`].join(`
2
2
  `):[`Close ${e.length} terminals?`,`This stops their running processes and clears their histories: ${e.map(e=>`"${e}"`).join(`, `)}.`].join(`
3
3
  `),{variant:`destructive`})}catch{return!1}finally{--rn}}var sn={environmentId:c,threadId:c,targetOrigin:c,cause:i()},cn=class extends n()(`TerminalLinkPreviewOpenError`,sn){get message(){return`Failed to open terminal link ${this.targetOrigin} in preview for thread ${this.threadId}.`}};async function ln(e){if(!(!e.forceBrowser&&O(e.url)&&be(e.threadRef.environmentId)&&e.threadRef.threadId.length>0&&await k()===`app`)){e.fallbackToBrowser();return}let t={environmentId:e.threadRef.environmentId,threadId:e.threadRef.threadId,targetOrigin:new URL(e.url).origin},n=await C(),r=ve(e.threadRef.environmentId),i=await e.openPreview({environmentId:e.threadRef.environmentId,input:{threadId:e.threadRef.threadId,url:e.url,viewport:ye(n),profileId:T(n),...r===void 0?{}:{runtime:r}}});if(i._tag===`Failure`){if(re(i))return;console.error(new cn({...t,cause:i.cause})),e.fallbackToBrowser();return}w(e.threadRef,e.url),h(e.threadRef,i.value),fe.getState().openBrowser(e.threadRef,i.value.tabId)}function un(e){return{...e===void 0?{}:{platform:e},context:{terminalFocus:!0,terminalOpen:!0}}}function dn(e,t,n){return Te(e,t,un(n))?(e.preventDefault(),!0):!1}function fn(e,t,n){return e.repeat?dn(e,t,n):!1}var pn=180,mn=.75;function hn(){return typeof window>`u`?280:Math.max(pn,Math.floor(window.innerHeight*mn))}function gn(e,t=hn()){return Math.min(Math.max(Math.round(Number.isFinite(e)?e:280),pn),t)}function _n(e,t){e.write(`\r\n[terminal] ${t}\r\n`)}function vn(e,t){t.type===`reset`?e.resetAndWrite(t.data):t.type===`append`&&e.write(t.data)}function yn(e,t,n){if(t.version===0)return n;let r=M(t.output,n);return vn(e,r),e.clearSelection(),r.cursor}function bn(e,t){if(typeof document>`u`)return t;let n=document.createElement(`canvas`);n.width=1,n.height=1;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return t;r.clearRect(0,0,1,1),r.fillStyle=e,r.fillRect(0,0,1,1);let[i,a,o,s]=r.getImageData(0,0,1,1).data;return s===0?t:{r:i??t.r,g:a??t.g,b:o??t.b}}function xn(e){let t=Number.parseInt(e.slice(1),16);return{r:t>>16&255,g:t>>8&255,b:t&255}}var Sn={light:[`#000000`,`#cd3131`,`#107c10`,`#949800`,`#0451a5`,`#bc05bc`,`#0598bc`,`#555555`,`#666666`,`#cd3131`,`#14ce14`,`#b5ba00`,`#0451a5`,`#bc05bc`,`#0598bc`,`#a5a5a5`].map(xn),dark:[`#000000`,`#cd3131`,`#0dbc79`,`#e5e510`,`#2472c8`,`#bc3fbc`,`#11a8cd`,`#e5e5e5`,`#666666`,`#f14c4c`,`#23d18b`,`#f5f543`,`#3b8eea`,`#d670d6`,`#29b8db`,`#e5e5e5`].map(xn)};function Cn(e){return e?JSON.stringify(Object.entries(e).filter(([e,t])=>e.length>0&&typeof t==`string`).sort(([e],[t])=>e.localeCompare(t))):``}function wn(e,t){let n=e?.trim().toLowerCase();return!n||n===`transparent`||n===`rgba(0, 0, 0, 0)`||n===`rgba(0 0 0 / 0)`?t:e??t}function Tn(e,t,n){return wn(e.getPropertyValue(t),n)}function En(e,t){let n=e.trim();return n.length>0?{family:n,size:t}:{size:t}}function Dn(e){let t=e?.closest(`[data-thread-terminal-drawer]`)??document.querySelector(`[data-thread-terminal-drawer]`)??document.body,n=getComputedStyle(t),r=e?getComputedStyle(e):n,i=r.colorScheme,a=i===`dark`||i!==`light`&&document.documentElement.classList.contains(`dark`),o=a?`rgb(14, 18, 24)`:`rgb(255, 255, 255)`,s=a?`rgb(237, 241, 247)`:`rgb(28, 33, 41)`,c=getComputedStyle(document.body),l=getComputedStyle(document.documentElement),u=wn(n.backgroundColor,wn(c.backgroundColor,o)),d=wn(n.color,wn(c.color,s)),f=Tn(r,`--terminal-background`,Tn(l,`--terminal-background`,u)),p=Tn(r,`--terminal-foreground`,Tn(l,`--terminal-foreground`,d)),m=Tn(r,`--terminal-cursor`,a?`rgb(180, 203, 255)`:`rgb(38, 56, 78)`),h=Tn(r,`--terminal-selection-background`,a?`rgba(180, 203, 255, 0.25)`:`rgba(37, 63, 99, 0.2)`);return{background:bn(f,a?{r:14,g:18,b:24}:{r:255,g:255,b:255}),foreground:bn(p,a?{r:237,g:241,b:247}:{r:28,g:33,b:41}),cursor:bn(m,a?{r:180,g:203,b:255}:{r:38,g:56,b:78}),palette:Sn[a?`dark`:`light`],selectionBackground:h}}function On(e){let t=e.start.y+1;return{lineStart:t,lineEnd:Math.max(t,e.end.y+1)}}function kn(e){return[...e?.canAddToChat===!1?[]:[{id:`add-to-chat`,label:`Add to chat`}],{id:`copy`,label:`Copy`}]}function An(e){let{hasSelection:t,canAddToChat:n=!0}=e;return[...kn({canAddToChat:n}).map(e=>({...e,disabled:!t})),{id:`paste`,label:`Paste`,...e.readOnly?{disabled:!0}:{}},{id:`select-all`,label:`Select all`},{id:`scroll-to-bottom`,label:`Jump to latest`}]}function jn(e){return e.actionPending||e.openMenuRequestId===e.currentRequestId}function Mn(e,t,n,r){return r>0&&(e===`closed`||e===`exited`)&&e!==t&&!n}function Nn({advancedTypography:e,threadRef:t,threadId:n,terminalId:r,terminalLabel:i,cwd:a,worktreePath:s,runtimeEnv:c,providerInstanceId:l,onSessionExited:u,onAddTerminalContext:d,focusRequestId:m,autoFocus:h,visible:g,resizeEpoch:ee,drawerHeight:te,keybindings:_}){let v=(0,I.useRef)(null),y=(0,I.useRef)(null),ne=(0,I.useRef)(g),b=t.environmentId,x=le(b,o),S=(0,I.useEffectEvent)(()=>ue(b,o)),fe=le(b,p),_e=(0,I.useEffectEvent)(e=>je(e)||ue(b,`orchestration:operate`)),ve=f(ce.configValueAtom(b)),ye=Le(b,ve?.availableEditors??[]),C=(0,I.useEffectEvent)(e=>ye(e)),w=de(Oe.open,{reportFailure:!1}),T=de(Pe.write,{reportFailure:!1}),be=de(Pe.resize,{reportFailure:!1}),Te=(0,I.useRef)(!1),O=(0,I.useRef)(0),k=(0,I.useRef)(null),ke=(0,I.useRef)(_),A=(0,I.useMemo)(()=>Cn(c),[c]),Ae=(0,I.useEffectEvent)(()=>{S()&&u()}),Me=(0,I.useEffectEvent)(e=>{d?.(e)}),j=(0,I.useEffectEvent)(()=>d!==void 0),Fe=(0,I.useEffectEvent)(()=>i),F=he(t=>Ie({advanced:e,code:t.fontFamilyCode,terminal:t.fontFamilyTerminal})),Re=he(t=>P({advanced:e,code:t.fontSizeCode,terminal:t.fontSizeTerminal})),ze=(0,I.useRef)({family:F,size:Re}),R=N({environmentId:b,terminal:{threadId:n,terminalId:r,cwd:a,...s===void 0?{}:{worktreePath:s},...c?{env:c}:{},...l?{providerInstanceId:l}:{}}}),z=x&&R.version>0&&R.status===`running`,He=z?R.output.generation:null,Ue=(0,I.useEffectEvent)(e=>T({environmentId:b,input:{threadId:n,terminalId:r,data:e}})),We=(0,I.useEffectEvent)((e,t)=>{if(z&&S())return be({environmentId:b,input:{threadId:n,terminalId:r,cols:e,rows:t}})}),B=R.output,V=R.error,H=R.status,Ge=(0,I.useRef)(Ne),U=(0,I.useRef)(`closed`),Ke=(0,I.useEffectEvent)((e,t,n)=>{let r=U.current;n>0&&t===`running`?Te.current=!1:Mn(t,r,Te.current,n)&&(Te.current=!0,_n(e,t===`closed`?`Terminal closed`:`Process exited`),window.setTimeout(()=>{Te.current&&Ae()},0)),n>0&&(U.current=t)}),W=R.version,G=(0,I.useRef)({output:B,error:V,status:H,version:W}),K=(0,I.useRef)(G.current);return K.current={output:B,error:V,status:H,version:W},(0,I.useEffect)(()=>{ke.current=_},[_]),(0,I.useLayoutEffect)(()=>{y.current&&(y.current.input.readOnly=!x)},[x]),(0,I.useEffect)(()=>{y.current?.refreshLinkActivation()},[fe]),(0,I.useEffect)(()=>{He!==null&&y.current?.resendSize()},[He]),(0,I.useLayoutEffect)(()=>{ne.current=g,y.current?.setVisible(g)},[g]),(0,I.useEffect)(()=>{let e=ze.current;(e.family!==F||e.size!==Re)&&(ze.current={family:F,size:Re},y.current?.setFont(En(F,Re)))},[F,Re]),(0,I.useEffect)(()=>{let e=v.current;if(!e)return;let n=me(),i=!1,o=null,s=null,c=[],l=null;return(async()=>{let o=ze.current,u={theme:Dn(e),font:En(o.family,o.size),get visible(){return ne.current},onData:e=>ye(e),onResize:(e,t)=>void We(e,t),onSelectionChange:()=>T(),beforeKey:e=>he(e),onLinkActivate:(e,t)=>ve(e,t),canActivateLink:e=>_e(e),onContextMenu:e=>{y.current&&de(e)}},d=await tn.create(e,u);if(i)return d.dispose(),null;d.setVisible(ne.current),d.setTheme(Dn(e)),s=d,y.current=d,d.input.readOnly=!S();let f=ze.current;(f.family!==o.family||f.size!==o.size)&&d.setFont(En(f.family,f.size));let p=K.current;G.current=p;let m=M(p.output,Ne);m.type===`reset`&&m.data.length>0&&vn(d,m),Ge.current=m.cursor,p.error!==null&&_n(d,p.error),U.current=`closed`,Ke(d,p.status,p.version),S()&&ne.current&&e.contains(document.activeElement)&&d.focus();let h=(e=!1)=>{let t=k.current===O.current;(e||t)&&(O.current+=1),t&&n?.contextMenu.close()},g=()=>{l?.cancel(),h(!0)};c.push(g);let ee=(e=null)=>{let t=y.current,n=v.current;if(!t||!n||!t.hasSelection())return null;let i=t.getSelection(),a=t.getSelectionPosition(),o=i.replace(/\r\n/g,`
4
4
  `).replace(/^\n+|\n+$/g,``);if(!a||o.length===0)return null;let{lineStart:s,lineEnd:c}=On(a);return{position:Be({bounds:n.getBoundingClientRect(),selectionRect:t.getSelectionEndClientRect(),pointer:e,viewport:{width:window.innerWidth,height:window.innerHeight}}),clipboardText:i,selection:{terminalId:r,terminalLabel:Fe(),lineStart:s,lineEnd:c,text:o}}},te=e=>{Me(e),y.current?.clearSelection(),y.current?.focus()},_=(e,t,n)=>{if(e!==O.current)return;let r=y.current;r&&_n(r,t instanceof Error?t.message:n)},x=e=>{e===O.current&&y.current?.focus()},ce=async(e,t)=>{try{await se(e,`terminal selection`)}catch(e){_(t,e,`Unable to copy terminal selection`)}x(t)},le=async e=>{if(!S())return;let t=y.current;if(t){try{await t.pasteFromClipboard(()=>ae(`terminal input`),()=>e===O.current)}catch(t){_(e,t,`Unable to read the clipboard`);return}x(e)}},de=async e=>{if(!n||!y.current)return;e.preventDefault(),g();let t=ee(),r=O.current,i;try{i=await n.contextMenu.show(An({hasSelection:t!==null,canAddToChat:j(),readOnly:!S()}),{x:e.clientX,y:e.clientY})}catch(e){_(r,e,`Unable to open the terminal context menu`),x(r);return}if(r===O.current&&i!==null)switch(i){case`add-to-chat`:t&&j()&&te(t.selection);return;case`copy`:t&&await ce(t.clipboardText,r);return;case`paste`:await le(r);return;case`select-all`:y.current?.selectAll(),x(r);return;case`scroll-to-bottom`:y.current?.scrollToBottom(),x(r);return}},fe=async e=>{if(!n){g();return}if(k.current===O.current)return;let t=ee(e);if(!t){g();return}let r=++O.current;k.current=r;let i=await n.contextMenu.show(kn({canAddToChat:j()}),t.position).finally(()=>{k.current===r&&(k.current=null)});if(r===O.current&&i!==null)switch(i){case`add-to-chat`:j()&&te(t.selection);return;case`copy`:await ce(t.clipboardText,r);return}},me=async(e,t)=>{if(!S())return;let n=y.current;if(!n)return;let r=await Ue(e);if(r._tag===`Failure`&&!re(r)){let e=ie(r);_n(n,e instanceof Error?e.message:t)}};function he(e){let t=ke.current,n={context:{terminalFocus:!0,terminalOpen:!0}};if(dn(e,t)||Ee(e,t,n)||Ce(e,t,n)||we(e,t,n)||De(e,t,n)||xe(e,t,n))return!1;let r=E(e);if(r!==null)return e.preventDefault(),e.stopPropagation(),me(r,`Failed to move cursor`),!1;let i=D(e);return i===null?!Se(e)||(e.preventDefault(),e.stopPropagation(),me(`\f`,`Failed to clear terminal`),!1):(e.preventDefault(),e.stopPropagation(),me(i,`Failed to delete terminal input`),!1)}function ve(e,r){if(!_e(e))return;let i=y.current;if(!i)return;if(je(e)){if(!n){_n(i,`Opening links is unavailable in this browser.`);return}let a=()=>{n.shell.openExternal(e).catch(e=>{_n(i,e instanceof Error?e.message:`Unable to open link`)})};if(!ue(b,`preview:operate`)){a();return}ln({url:e,threadRef:t,openPreview:w,fallbackToBrowser:a,forceBrowser:r.metaKey||r.ctrlKey}).catch(e=>{oe.add(ge({type:`error`,title:`Unable to open link`,description:e instanceof Error?e.message:`An error occurred.`}))});return}let o=pe(e,a);(async()=>{let e=await C(o);if(e._tag===`Success`||re(e))return;let t=ie(e);_n(i,t instanceof Error?t.message:`Unable to open path`)})()}function ye(e){S()&&(async()=>{let t=await Ue(e);if(t._tag===`Success`||re(t))return;let n=ie(t);_n(d,n instanceof Error?n.message:`Terminal write failed`)})()}function T(){y.current?.hasSelection()||jn({actionPending:l?.pending??!1,openMenuRequestId:k.current,currentRequestId:O.current})&&g()}l=Ve({element:e,onSelection:e=>{fe(e)},onDismiss:e=>h(e===`interaction`)}),c.push(()=>l?.dispose());let be=new MutationObserver(()=>{let e=y.current;e&&e.setTheme(Dn(v.current))});be.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}),c.push(()=>be.disconnect());let Te=window.setTimeout(()=>{let e=y.current;if(!e)return;let t=e.isAtBottom();e.fit(),t&&e.scrollToBottom()},30);c.push(()=>window.clearTimeout(Te));let Oe=c;return c=[],s=null,()=>{for(let e of Oe.toReversed())e();y.current===d&&(y.current=null),d.dispose()}})().then(e=>{if(i){e?.();return}o=e}).catch(t=>{for(let e of c.toReversed())e();if(c=[],y.current===s&&(y.current=null),s?.dispose(),s=null,i)return;let n=t instanceof Error?t.message:`Unable to initialize libghostty-vt`;e.textContent=`${n} — close and reopen the terminal to retry.`}),()=>{i=!0;let t=e.contains(document.activeElement);o?.(),S()&&t&&e.isConnected&&e.focus({preventScroll:!0})}},[a,b,A,r,n,s]),(0,I.useEffect)(()=>{let e=y.current,t={output:B,error:V,status:H,version:W};if(!e){G.current=t;return}let n=G.current;Ke(e,t.status,t.version),(t.version!==n.version||t.output!==n.output)&&(Ge.current=yn(e,t,Ge.current),t.error!==null&&t.error!==n.error&&_n(e,t.error),G.current=t)},[B,V,H,W]),(0,I.useEffect)(()=>{h&&x&&g&&(y.current??v.current)?.focus()},[h,x,m,g]),(0,I.useEffect)(()=>{let e=y.current;if(!e||!ne.current)return;let t=e.isAtBottom(),n=window.requestAnimationFrame(()=>{ne.current&&(e.fit(),t&&e.scrollToBottom())});return()=>{window.cancelAnimationFrame(n)}},[te,b,ee,r,n]),(0,L.jsx)(`div`,{ref:v,tabIndex:-1,className:`relative h-full w-full overflow-hidden bg-(--terminal-background)`})}function Pn(e){let t=(0,ze.c)(16),{label:n,className:r,onClick:i,children:a,disabled:o}=e,s=o&&`opacity-45 cursor-not-allowed`,c;t[0]!==r||t[1]!==s?(c=_(r,s),t[0]=r,t[1]=s,t[2]=c):c=t[2];let l=o?void 0:i,u;t[3]!==o||t[4]!==n||t[5]!==c||t[6]!==l?(u=(0,L.jsx)(`button`,{type:`button`,className:c,onClick:l,"aria-label":n,"aria-disabled":o}),t[3]=o,t[4]=n,t[5]=c,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==a||t[9]!==u?(d=(0,L.jsx)(A,{openOnHover:!0,render:u,children:a}),t[8]=a,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n?f=t[12]:(f=(0,L.jsx)(ke,{tooltipStyle:!0,side:`bottom`,sideOffset:6,align:`center`,className:`pointer-events-none select-none`,children:n}),t[11]=n,t[12]=f);let p;return t[13]!==d||t[14]!==f?(p=(0,L.jsxs)(Ae,{children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function Fn(e){let t=(0,ze.c)(169),{mode:n,threadRef:i,threadId:a,cwd:c,worktreePath:l,runtimeEnv:d,visible:f,height:p,terminalIds:h,activeTerminalId:g,terminalGroups:re,activeTerminalGroupId:ie,focusRequestId:ae,onSplitTerminal:oe,onSplitTerminalVertical:se,onNewTerminal:b,splitShortcutLabel:x,splitVerticalShortcutLabel:S,newShortcutLabel:ce,closeShortcutLabel:de,onActiveTerminalChange:fe,onCloseTerminal:pe,onHeightChange:me,onAddTerminalContext:he,keybindings:ge,terminalLabelsById:_e,terminalLaunchLocationsById:ve}=e,ye=n===void 0?`drawer`:n,C=f===void 0||f,w=le(i.environmentId,o),T=ye===`panel`,[be]=s(Re,!1,ne),E=p,[xe,Se]=(0,I.useState)(hn),Ce;t[0]!==E||t[1]!==a?(Ce=()=>({threadId:a,height:E}),t[0]=E,t[1]=a,t[2]=Ce):Ce=t[2];let[we,Te]=(0,I.useState)(Ce),Ee=we.threadId===a?we.height:E,De;t[3]!==Ee||t[4]!==xe?(De=gn(Ee,xe),t[3]=Ee,t[4]=xe,t[5]=De):De=t[5];let D=De,Oe;t[6]!==E||t[7]!==a?(Oe=e=>{Te(t=>{let n=t.threadId===a?t.height:E,r=typeof e==`function`?e(n):e;return r===n&&t.threadId===a?t:{threadId:a,height:r}})},t[6]=E,t[7]=a,t[8]=Oe):Oe=t[8];let O=Oe,[k,ke]=(0,I.useState)(0),A=(0,I.useRef)(D),Ae=(0,I.useRef)(Ee),je=(0,I.useRef)(E),Me=(0,I.useRef)(me),j=(0,I.useRef)(null),Ne=(0,I.useRef)(!1),Pe;if(t[9]!==h){Pe=[];let e=new Set;for(let t of h){let n=t.trim();n.length===0||e.has(n)||(e.add(n),Pe.push(n))}t[9]=h,t[10]=Pe}else Pe=t[10];let M=Pe,N=M.length===0?``:M.includes(g)?g:M[0]??``,Ie;bb0:{if(M.length===0){let e;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[11]=e):e=t[11],Ie=e;break bb0}let e;t[12]===M?e=t[13]:(e=new Set(M),t[12]=M,t[13]=e);let n=e,r;if(t[14]!==M||t[15]!==re||t[16]!==n){let e=new Set,i=new Set;r=[];let a=e=>{if(!i.has(e))return i.add(e),e;let t=2;for(;i.has(`${e}-${t}`);)t+=1;let n=`${e}-${t}`;return i.add(n),n};for(let t of re){let i=[],o=new Set;for(let r of t.terminalIds){let t=r.trim();t.length!==0&&(o.has(t)||(o.add(t),n.has(t)&&(e.has(t)||i.push(t))))}if(i.length===0)continue;for(let t of i)e.add(t);let s=t.id.trim().length>0?t.id.trim():`group-${i[0]??M[0]??``}`;r.push({id:a(s),terminalIds:i,...t.splitDirection===`vertical`?{splitDirection:`vertical`}:{}})}for(let t of M)e.has(t)||r.push({id:a(`group-${t}`),terminalIds:[t]});let o=new Map(M.map(Bn));r.sort((e,t)=>{let n=e=>Math.min(...e.map(e=>o.get(e)??1/0));return n(e.terminalIds)-n(t.terminalIds)}),t[14]=M,t[15]=re,t[16]=n,t[17]=r}else r=t[17];Ie=r}let P=Ie,Le;bb1:{let e=P.findIndex(e=>e.id===ie);if(e>=0){Le=e;break bb1}let t=P.findIndex(e=>e.terminalIds.includes(N));Le=t>=0?t:0}let F=Le,Be;t[18]!==M.length||t[19]!==F||t[20]!==N||t[21]!==P?(Be=P[F]?.terminalIds??(M.length>0?[N]:[]),t[18]=M.length,t[19]=F,t[20]=N,t[21]=P,t[22]=Be):Be=t[22];let Ve=Be,R=P[F]?.splitDirection??`horizontal`,z=M.length>1,He=Ve.length>1,Ue;t[23]===P?Ue=t[24]:(Ue=P.length>1||P.some(zn),t[23]=P,t[24]=Ue);let We=Ue,B=Ve.length>=4,V;if(t[25]!==M||t[26]!==_e){V=new Map;for(let e of M)V.set(e,_e?.get(e)??Fe(e));t[25]=M,t[26]=_e,t[27]=V}else V=t[27];let H=V,Ge;t[28]!==c||t[29]!==d||t[30]!==ve||t[31]!==l?(Ge=e=>ve?.get(e)??{cwd:c,...l===void 0?{}:{worktreePath:l},...d?{runtimeEnv:d}:{}},t[28]=c,t[29]=d,t[30]=ve,t[31]=l,t[32]=Ge):Ge=t[32];let U=Ge,Ke=B?`Split Terminal Horizontally (max 4 per group)`:x?`Split Terminal Horizontally (${x})`:`Split Terminal Horizontally`,W=B?`Split Terminal Vertically (max 4 per group)`:S?`Split Terminal Vertically (${S})`:`Split Terminal Vertically`,G=ce?`New Terminal (${ce})`:`New Terminal`,K=de?`Close Terminal (${de})`:`Close Terminal`,qe;t[33]!==w||t[34]!==B||t[35]!==oe?(qe=()=>{w&&!B&&oe()},t[33]=w,t[34]=B,t[35]=oe,t[36]=qe):qe=t[36];let Je=qe,Ye;t[37]!==w||t[38]!==B||t[39]!==se?(Ye=()=>{w&&!B&&se()},t[37]=w,t[38]=B,t[39]=se,t[40]=Ye):Ye=t[40];let Xe=Ye,q;t[41]!==w||t[42]!==b?(q=()=>{w&&b()},t[41]=w,t[42]=b,t[43]=q):q=t[43];let J=q,Y;t[44]!==w||t[45]!==pe||t[46]!==H||t[47]!==i.environmentId?(Y=e=>{w&&on([H.get(e)??Fe(e)]).then(t=>{t&&ue(i.environmentId,`terminal:operate`)&&pe(e)})},t[44]=w,t[45]=pe,t[46]=H,t[47]=i.environmentId,t[48]=Y):Y=t[48];let X=Y,Ze,Qe;t[49]===me?(Ze=t[50],Qe=t[51]):(Ze=()=>{Me.current=me},Qe=[me],t[49]=me,t[50]=Ze,t[51]=Qe),(0,I.useEffect)(Ze,Qe);let $e,et;t[52]===D?($e=t[53],et=t[54]):($e=()=>{let e=j.current;if(e){e.drawer?.style.setProperty(`height`,`${A.current}px`);return}A.current=D},et=[D],t[52]=D,t[53]=$e,t[54]=et),(0,I.useLayoutEffect)($e,et);let tt,nt;t[55]===Ee?(tt=t[56],nt=t[57]):(tt=()=>{Ae.current=Ee},nt=[Ee],t[55]=Ee,t[56]=tt,t[57]=nt),(0,I.useEffect)(tt,nt);let rt;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(rt=e=>{je.current!==e&&(je.current=e,Me.current(e))},t[58]=rt):rt=t[58];let it=rt,at;t[59]===E?at=t[60]:(at=()=>{je.current=E},t[59]=E,t[60]=at);let ot;t[61]!==E||t[62]!==a?(ot=[E,a],t[61]=E,t[62]=a,t[63]=ot):ot=t[63],(0,I.useEffect)(at,ot);let Z;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Z=e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),Ne.current=!1,j.current={pointerId:e.pointerId,startY:e.clientY,startHeight:A.current,drawer:e.currentTarget.parentElement})},t[64]=Z):Z=t[64];let st=Z,ct;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ct=e=>{let t=j.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault();let n=gn(t.startHeight+(t.startY-e.clientY));n!==A.current&&(Ne.current=!0,A.current=n,t.drawer?.style.setProperty(`height`,`${n}px`))},t[65]=ct):ct=t[65];let lt=ct,ut;t[66]===O?ut=t[67]:(ut=e=>{let t=j.current;if(t&&t.pointerId===e.pointerId){if(j.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),!Ne.current||A.current===t.startHeight){let e=gn(Ae.current);A.current=e,t.drawer?.style.setProperty(`height`,`${e}px`);return}O(A.current),it(A.current),ke(Rn)}},t[66]=O,t[67]=ut);let Q=ut,dt,ft;t[68]===C?(dt=t[69],ft=t[70]):(dt=()=>{if(!C)return;let e=()=>{let e=j.current,t=gn(A.current);e&&t!==A.current&&(A.current=t,e.drawer?.style.setProperty(`height`,`${t}px`)),Se(hn()),ke(Ln)};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},ft=[C],t[68]=C,t[69]=dt,t[70]=ft),(0,I.useEffect)(dt,ft);let pt,mt;t[71]===C?(pt=t[72],mt=t[73]):(pt=()=>{C&&(Se(hn()),ke(In))},mt=[C],t[71]=C,t[72]=pt,t[73]=mt),(0,I.useEffect)(pt,mt);let ht,gt;if(t[74]===Symbol.for(`react.memo_cache_sentinel`)?(ht=()=>()=>{it(Ae.current)},gt=[it],t[74]=ht,t[75]=gt):(ht=t[74],gt=t[75]),(0,I.useEffect)(ht,gt),M.length===0){let e=T?`right-panel`:`drawer`,n=T?`h-full flex-1`:`shrink-0 border-t border-border/80`,r;t[76]===n?r=t[77]:(r=_(`relative flex min-w-0 flex-col overflow-hidden bg-background`,n),t[76]=n,t[77]=r);let i;t[78]!==D||t[79]!==T?(i=T?void 0:{height:`${D}px`},t[78]=D,t[79]=T,t[80]=i):i=t[80];let a;t[81]!==Q||t[82]!==T?(a=T?null:(0,L.jsx)(`div`,{className:`absolute inset-x-0 top-0 z-20 h-1.5 cursor-row-resize`,onPointerDown:st,onPointerMove:lt,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q}),t[81]=Q,t[82]=T,t[83]=a):a=t[83];let o;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,L.jsx)(`p`,{children:`No terminal sessions for this thread yet.`}),t[84]=o):o=t[84];let s=!w,c;t[85]!==G||t[86]!==J||t[87]!==s?(c=(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-4 py-6 text-center text-sm text-muted-foreground`,children:[o,(0,L.jsx)(te,{size:`xs`,variant:`outline`,onClick:J,disabled:s,children:G})]}),t[85]=G,t[86]=J,t[87]=s,t[88]=c):c=t[88];let l;return t[89]!==e||t[90]!==r||t[91]!==i||t[92]!==a||t[93]!==c?(l=(0,L.jsxs)(`aside`,{"data-thread-terminal-drawer":!0,"data-terminal-owner":e,className:r,style:i,children:[a,c]}),t[89]=e,t[90]=r,t[91]=i,t[92]=a,t[93]=c,t[94]=l):l=t[94],l}let $;t[95]!==U||t[96]!==N?($=U(N),t[95]=U,t[96]=N,t[97]=$):$=t[97];let _t=$,vt=T?`right-panel`:`drawer`,yt=T?`h-full flex-1`:`shrink-0 border-t border-border/80`,bt;t[98]===yt?bt=t[99]:(bt=_(`relative flex min-w-0 flex-col overflow-hidden bg-background`,yt),t[98]=yt,t[99]=bt);let xt;t[100]!==D||t[101]!==T?(xt=T?void 0:{height:`${D}px`},t[100]=D,t[101]=T,t[102]=xt):xt=t[102];let St;t[103]!==Q||t[104]!==T?(St=T?null:(0,L.jsx)(`div`,{className:`absolute inset-x-0 top-0 z-20 h-1.5 cursor-row-resize`,onPointerDown:st,onPointerMove:lt,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q}),t[103]=Q,t[104]=T,t[105]=St):St=t[105];let Ct;t[106]!==w||t[107]!==K||t[108]!==X||t[109]!==B||t[110]!==z||t[111]!==G||t[112]!==J||t[113]!==Je||t[114]!==Xe||t[115]!==N||t[116]!==Ke||t[117]!==W?(Ct=!z&&(0,L.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-20`,children:(0,L.jsxs)(`div`,{className:`pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,L.jsx)(Pn,{disabled:!w,className:`p-1 text-foreground/90 transition-colors ${B?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent`}`,onClick:Je,label:Ke,children:(0,L.jsx)(v,{className:`size-3.25`})}),(0,L.jsx)(`div`,{className:`h-4 w-px bg-border/80`}),(0,L.jsx)(Pn,{disabled:!w,className:`p-1 text-foreground/90 transition-colors ${B?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent`}`,onClick:Xe,label:W,children:(0,L.jsx)(m,{className:`size-3.25`})}),(0,L.jsx)(`div`,{className:`h-4 w-px bg-border/80`}),(0,L.jsx)(Pn,{disabled:!w,className:`p-1 text-foreground/90 transition-colors hover:bg-accent`,onClick:J,label:G,children:(0,L.jsx)(u,{className:`size-3.25`})}),(0,L.jsx)(`div`,{className:`h-4 w-px bg-border/80`}),(0,L.jsx)(Pn,{disabled:!w,className:`p-1 text-foreground/90 transition-colors hover:bg-accent`,onClick:()=>X(N),label:K,children:(0,L.jsx)(r,{className:`size-3.25`})})]})}),t[106]=w,t[107]=K,t[108]=X,t[109]=B,t[110]=z,t[111]=G,t[112]=J,t[113]=Je,t[114]=Xe,t[115]=N,t[116]=Ke,t[117]=W,t[118]=Ct):Ct=t[118];let wt=z&&`gap-1.5`,Tt;t[119]===wt?Tt=t[120]:(Tt=_(`flex h-full min-h-0 bg-(--terminal-background)`,wt),t[119]=wt,t[120]=Tt);let Et;t[121]!==_t||t[122]!==be||t[123]!==D||t[124]!==ae||t[125]!==He||t[126]!==ge||t[127]!==fe||t[128]!==he||t[129]!==pe||t[130]!==k||t[131]!==U||t[132]!==N||t[133]!==R||t[134]!==H||t[135]!==a||t[136]!==i||t[137]!==C||t[138]!==Ve?(Et=(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:He?(0,L.jsx)(`div`,{className:`grid h-full w-full min-w-0 gap-0 overflow-hidden`,style:R===`vertical`?{gridTemplateRows:`repeat(${Ve.length}, minmax(0, 1fr))`}:{gridTemplateColumns:`repeat(${Ve.length}, minmax(0, 1fr))`},children:Ve.map(e=>{let t=U(e);return(0,L.jsx)(`div`,{className:`min-h-0 min-w-0 ${R===`vertical`?`border-t first:border-t-0`:`border-l first:border-l-0`} ${e===N?`border-border`:`border-border/70`}`,onPointerDown:()=>{e!==N&&fe(e)},children:(0,L.jsx)(`div`,{className:`h-full`,children:(0,L.jsx)(Nn,{advancedTypography:be,threadRef:i,threadId:a,terminalId:e,terminalLabel:H.get(e)??`Terminal`,cwd:t.cwd,...t.worktreePath===void 0?{}:{worktreePath:t.worktreePath},...t.runtimeEnv?{runtimeEnv:t.runtimeEnv}:{},onSessionExited:()=>pe(e),onAddTerminalContext:he,focusRequestId:ae,autoFocus:e===N,visible:C,resizeEpoch:k,drawerHeight:D,keybindings:ge})})},e)})}):(0,L.jsx)(`div`,{className:`h-full`,children:(0,L.jsx)(Nn,{advancedTypography:be,threadRef:i,threadId:a,terminalId:N,terminalLabel:H.get(N)??`Terminal`,cwd:_t.cwd,..._t.worktreePath===void 0?{}:{worktreePath:_t.worktreePath},..._t.runtimeEnv?{runtimeEnv:_t.runtimeEnv}:{},onSessionExited:()=>pe(N),onAddTerminalContext:he,focusRequestId:ae,autoFocus:!0,visible:C,resizeEpoch:k,drawerHeight:D,keybindings:ge},N)})}),t[121]=_t,t[122]=be,t[123]=D,t[124]=ae,t[125]=He,t[126]=ge,t[127]=fe,t[128]=he,t[129]=pe,t[130]=k,t[131]=U,t[132]=N,t[133]=R,t[134]=H,t[135]=a,t[136]=i,t[137]=C,t[138]=Ve,t[139]=Et):Et=t[139];let Dt;t[140]!==w||t[141]!==de||t[142]!==K||t[143]!==X||t[144]!==B||t[145]!==z||t[146]!==G||t[147]!==fe||t[148]!==J||t[149]!==Je||t[150]!==Xe||t[151]!==N||t[152]!==P||t[153]!==We||t[154]!==Ke||t[155]!==W||t[156]!==H?(Dt=z&&(0,L.jsxs)(`aside`,{className:`flex w-36 min-w-36 flex-col border border-border/70 bg-muted/10`,children:[(0,L.jsx)(`div`,{className:`flex h-[22px] items-stretch justify-end border-b border-border/70`,children:(0,L.jsxs)(`div`,{className:`inline-flex h-full items-stretch`,children:[(0,L.jsx)(Pn,{disabled:!w,className:`inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${B?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent/70`}`,onClick:Je,label:Ke,children:(0,L.jsx)(v,{className:`size-3.25`})}),(0,L.jsx)(Pn,{disabled:!w,className:`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${B?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent/70`}`,onClick:Xe,label:W,children:(0,L.jsx)(m,{className:`size-3.25`})}),(0,L.jsx)(Pn,{disabled:!w,className:`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70`,onClick:J,label:G,children:(0,L.jsx)(u,{className:`size-3.25`})}),(0,L.jsx)(Pn,{disabled:!w,className:`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70`,onClick:()=>X(N),label:K,children:(0,L.jsx)(r,{className:`size-3.25`})})]})}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 py-1`,children:P.map(e=>{let t=e.terminalIds.includes(N),n=t?N:e.terminalIds[0]??N,r=e.terminalIds.length,i=r>1,a=i?e.splitDirection===`vertical`?`Stacked`:`Side by side`:`Single`,o=i?e.splitDirection===`vertical`?m:v:ee;return(0,L.jsxs)(`div`,{className:`pb-0.5`,children:[We&&(0,L.jsxs)(`button`,{type:`button`,className:`flex h-[22px] w-full cursor-pointer items-center gap-1 rounded px-1.5 text-2xs ${t?`bg-accent/50 text-foreground`:`text-muted-foreground hover:bg-accent/40 hover:text-foreground`}`,onClick:()=>fe(n),children:[(0,L.jsx)(o,{className:`size-3 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:a}),(0,L.jsx)(`span`,{className:`text-muted-foreground/70 text-3xs tabular-nums`,children:r})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.terminalIds.map(e=>{let t=e===N,n=H.get(e)??`Terminal`,r=`Close ${n}${t&&de?` (${de})`:``}`;return(0,L.jsxs)(`div`,{className:_(`group/tab flex h-6 w-full items-center gap-0.5 rounded-md pr-2 pl-1.5 text-xs`,t?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/60 hover:text-foreground`),children:[w?(0,L.jsx)(nn,{label:r,onClick:()=>X(e),tooltip:r,children:(0,L.jsx)(y,{className:`size-3 shrink-0`})}):(0,L.jsx)(y,{className:`size-3 shrink-0`}),(0,L.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 text-left`,onClick:()=>fe(e),children:(0,L.jsx)(`span`,{className:`truncate`,children:n})})]},e)})})]},e.id)})})]}),t[140]=w,t[141]=de,t[142]=K,t[143]=X,t[144]=B,t[145]=z,t[146]=G,t[147]=fe,t[148]=J,t[149]=Je,t[150]=Xe,t[151]=N,t[152]=P,t[153]=We,t[154]=Ke,t[155]=W,t[156]=H,t[157]=Dt):Dt=t[157];let Ot;t[158]!==Tt||t[159]!==Et||t[160]!==Dt?(Ot=(0,L.jsx)(`div`,{className:`min-h-0 w-full flex-1`,children:(0,L.jsxs)(`div`,{className:Tt,children:[Et,Dt]})}),t[158]=Tt,t[159]=Et,t[160]=Dt,t[161]=Ot):Ot=t[161];let kt;return t[162]!==vt||t[163]!==bt||t[164]!==xt||t[165]!==St||t[166]!==Ct||t[167]!==Ot?(kt=(0,L.jsxs)(`aside`,{"data-thread-terminal-drawer":!0,"data-terminal-owner":vt,className:bt,style:xt,children:[St,Ct,Ot]}),t[162]=vt,t[163]=bt,t[164]=xt,t[165]=St,t[166]=Ct,t[167]=Ot,t[168]=kt):kt=t[168],kt}function In(e){return e+1}function Ln(e){return e+1}function Rn(e){return e+1}function zn(e){return e.terminalIds.length>1}function Bn(e,t){return[e,t]}export{dn as a,tn as c,fn as i,Ve as l,Fn as n,on as o,Dn as r,an as s,Nn as t,Be as u};
5
- //# sourceMappingURL=ThreadTerminalDrawer-B8n6TAqv.js.map
5
+ //# sourceMappingURL=ThreadTerminalDrawer-D7lW_0Ez.js.map