@p4code/cli 0.8.8 → 0.8.9
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.
- package/dist/bin.mjs +1 -1
- package/dist/{binCli-CnPGSVWN.mjs → binCli-C7u9q31G.mjs} +25 -113
- package/dist/client/.vite/manifest.json +2071 -2071
- package/dist/client/assets/{AnimatedHeight-CeIqOXkD.js → AnimatedHeight-DZPLUjm9.js} +2 -2
- package/dist/client/assets/{AuthSurfaceShell-CeFbPegZ.js → AuthSurfaceShell-CY0yRsGY.js} +2 -2
- package/dist/client/assets/{CSPContext-BLmE8rVK.js → CSPContext-D9jns38x.js} +2 -2
- package/dist/client/assets/{ChatGptUsageButton-gEF4N7W7.js → ChatGptUsageButton-jceJZ5U0.js} +2 -2
- package/dist/client/assets/{ChatMarkdown-DQ3uXQzt.js → ChatMarkdown-B2cnntMF.js} +4 -4
- package/dist/client/assets/{CodexSetupSection.logic-DobP-gmw.js → CodexSetupSection.logic-Bfp0M73n.js} +2 -2
- package/dist/client/assets/{ComboboxClear-fNH6Tj-4.js → ComboboxClear-B-WUNsj0.js} +2 -2
- package/dist/client/assets/{CommandBlock-X-DC1M4o.js → CommandBlock-BI9G-Hs9.js} +2 -2
- package/dist/client/assets/{ComposerPromptEditor-DiF8eMQV.js → ComposerPromptEditor-CYQVwHWc.js} +4 -4
- package/dist/client/assets/{CompositeRoot-Bu_9wjlN.js → CompositeRoot-CZqNlh6y.js} +2 -2
- package/dist/client/assets/{ConnectionStatusDot-0G2DkC_D.js → ConnectionStatusDot-BNGv8ojc.js} +2 -2
- package/dist/client/assets/{DevicePanel-BkS5Q-Y2.js → DevicePanel-C5V7qlX0.js} +2 -2
- package/dist/client/assets/{DeviceSetup-C0iRuaPp.js → DeviceSetup-lLd1Dxuc.js} +2 -2
- package/dist/client/assets/{DialogTitle-B7ZsIcBO.js → DialogTitle-Bti0gMwZ.js} +2 -2
- package/dist/client/assets/{DiffCommentAnnotation-UyWIyKIO.js → DiffCommentAnnotation-DpZ1jfFT.js} +2 -2
- package/dist/client/assets/{DiffFileTree-LZwmN24l.js → DiffFileTree-DW_wXLvM.js} +2 -2
- package/dist/client/assets/{DiffPanel-DfD6emFU.js → DiffPanel-DvsF1RpU.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-BCslhrpA.js → DiffWorkerPoolProvider-BGHe4Gu5.js} +2 -2
- package/dist/client/assets/{EnvironmentMachineIcon-Bn0qgNMW.js → EnvironmentMachineIcon-BzeEbEQS.js} +2 -2
- package/dist/client/assets/{ExpandableText-DPFtEjPq.js → ExpandableText-CZAoe3pn.js} +2 -2
- package/dist/client/assets/{FieldControl-Dcug7PQN.js → FieldControl-DSYkAElP.js} +2 -2
- package/dist/client/assets/{FileDiff-CztExdxl.js → FileDiff-qUCf81Vy.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-C_Q3mPlo.js → FilePreviewPanel-DgsQ3_bI.js} +2 -2
- package/dist/client/assets/{FoldedSettingsSection-MrezZXWL.js → FoldedSettingsSection-B8ucLmcM.js} +2 -2
- package/dist/client/assets/{FormContext-N50VWQHc.js → FormContext-TllbMdtd.js} +2 -2
- package/dist/client/assets/{Icons-CBnVp61L.js → Icons-CyDEOiJ2.js} +2 -2
- package/dist/client/assets/{KeybindingsSettings.logic-CCa_n5Wn.js → KeybindingsSettings.logic-Dx9jAbbW.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-sRJlYzCx.js → NoProjectsHero-Lxz19PUh.js} +2 -2
- package/dist/client/assets/{PanelLayoutControls-bgJzxuTg.js → PanelLayoutControls-jZ_kyR1v.js} +4 -4
- package/dist/client/assets/{PierreEntryIcon-Bid6ECoT.js → PierreEntryIcon-zwmwEij7.js} +2 -2
- package/dist/client/assets/{PreviewPanel-CQlsmVXf.js → PreviewPanel-Cgu0PLKZ.js} +2 -2
- package/dist/client/assets/{ProjectDefaultsSettings-BaW9gkj0.js → ProjectDefaultsSettings-DaLgF84f.js} +2 -2
- package/dist/client/assets/{ProjectFavicon-oQ8xOLai.js → ProjectFavicon-Cs-IpJFL.js} +3 -3
- package/dist/client/assets/{ProjectIconPickerDialog-D1QKDGMX.js → ProjectIconPickerDialog-CWU1aanN.js} +2 -2
- package/dist/client/assets/{ProjectMonogram-wj_aiPmM.js → ProjectMonogram-De9Vi6mM.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-BXJZPbVk.js → ProviderAuthTerminal-Dod9VT45.js} +2 -2
- package/dist/client/assets/{ProviderModelPicker-CQQUHTh0.js → ProviderModelPicker-DnPxGK8M.js} +2 -2
- package/dist/client/assets/{ProviderSettingsForm-CX9Fb8_8.js → ProviderSettingsForm-CK0XB_2n.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-DLqbGyR7.js → PullRequestCodeTab-TTmg3elC.js} +2 -2
- package/dist/client/assets/{ReadOnlySourcePreview-B7C0GGAq.js → ReadOnlySourcePreview-DS49yxPu.js} +2 -2
- package/dist/client/assets/{RenderErrorBoundary-DfL11xnF.js → RenderErrorBoundary-ChsSTLIX.js} +2 -2
- package/dist/client/assets/{ScheduledTasksSettings-Di6Z2urM.js → ScheduledTasksSettings-DK0fR_O9.js} +2 -2
- package/dist/client/assets/{ScopedSwitch-DYM42LM4.js → ScopedSwitch-zab4bpLE.js} +2 -2
- package/dist/client/assets/{SecretInput-CpQgS_zs.js → SecretInput-7_dN8OZO.js} +2 -2
- package/dist/client/assets/{SettingsPanels-D-wcH1Qk.js → SettingsPanels-CvD-BKml.js} +2 -2
- package/dist/client/assets/{SettingsPanels.logic-BQHrLt25.js → SettingsPanels.logic-BxZ7DzP5.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-BbuY3OvE.js → SettingsScopeNotice-Bq3kVMy1.js} +2 -2
- package/dist/client/assets/{T3ConnectAccountPages-Bb49yKNe.js → T3ConnectAccountPages-C37rBXr1.js} +2 -2
- package/dist/client/assets/{T3ConnectSidebarSignIn-CjmtmsbE.js → T3ConnectSidebarSignIn-Dcx0wC1Y.js} +2 -2
- package/dist/client/assets/{ThemeEditorPanel-CeucoKK-.js → ThemeEditorPanel-CDg13cbU.js} +2 -2
- package/dist/client/assets/{ThreadTerminalDrawer-Di41e66k.js → ThreadTerminalDrawer-CJZ5gJIq.js} +2 -2
- package/dist/client/assets/{Virtualizer-YMJF6Rgn.js → Virtualizer-BzpMB2EV.js} +2 -2
- package/dist/client/assets/{WorkspaceBreadcrumb-B4olYudc.js → WorkspaceBreadcrumb-BG0QcIel.js} +2 -2
- package/dist/client/assets/{WorkspacePageContainer-D_NDP2pC.js → WorkspacePageContainer-D4M31vG4.js} +2 -2
- package/dist/client/assets/{WorkspacePageHeader-CF_fkCJo.js → WorkspacePageHeader-xG2EcvME.js} +2 -2
- package/dist/client/assets/{_chat-BvSmDiLw.js → _chat-DWZuy8TH.js} +5 -5
- package/dist/client/assets/{_chat.index-B86aUAxh.js → _chat.index-CFbhMaCi.js} +2 -2
- package/dist/client/assets/{_chat.new-COnJvlNC.js → _chat.new-B9CmLitW.js} +2 -2
- package/dist/client/assets/{_chat.pull-requests-CMa0EuoS.js → _chat.pull-requests-BvS3LBJa.js} +2 -2
- package/dist/client/assets/{abnfDiagram-VCTEODGH-GKlp-wAF.js → abnfDiagram-VCTEODGH-DTgtRsRm.js} +2 -2
- package/dist/client/assets/{alert-BOSKZyDW.js → alert-BFkMrLRZ.js} +2 -2
- package/dist/client/assets/architecture-7GRP2DOG-B_WCZ15Q.js +1 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-BbKUUHgQ.js → architectureDiagram-5GKGNRK7-DoSCknS9.js} +2 -2
- package/dist/client/assets/{assets-arnK8cZJ.js → assets-CH9UWZJ9.js} +2 -2
- package/dist/client/assets/{blockDiagram-I7D4REHJ-BvV9OXgS.js → blockDiagram-I7D4REHJ-CIO7Vskr.js} +2 -2
- package/dist/client/assets/{browserHistoryStore-D3NmgwWz.js → browserHistoryStore-CUwwaVj8.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-CTDv30-a.js → browserLinkTarget-o1Hmp1Jv.js} +2 -2
- package/dist/client/assets/{c4Diagram-7LVT6UL2-BT2fKwga.js → c4Diagram-7LVT6UL2-CmnScM2q.js} +2 -2
- package/dist/client/assets/channel-Qn29FVeD.js +2 -0
- package/dist/client/assets/{checkbox-B0Q9zWdp.js → checkbox-DSb65NrE.js} +2 -2
- package/dist/client/assets/{chunk-4HAMMTFA-BPIUCP2N.js → chunk-4HAMMTFA-CuQTMYv7.js} +2 -2
- package/dist/client/assets/{chunk-75Z2AOVW-BY1XFSYe.js → chunk-75Z2AOVW-xNjAbRtQ.js} +2 -2
- package/dist/client/assets/{chunk-DU6HZSFF-BhfbeXEz.js → chunk-DU6HZSFF-B-vhPkPw.js} +2 -2
- package/dist/client/assets/{chunk-F27PBJKO-CkPC4b2I.js → chunk-F27PBJKO-HjvfKtnV.js} +2 -2
- package/dist/client/assets/{chunk-GMAD6QVW-D9bW2adv.js → chunk-GMAD6QVW-kPi65s4F.js} +2 -2
- package/dist/client/assets/{chunk-GVQU2GXP-C-gRpKGj.js → chunk-GVQU2GXP-xSVP_0Ga.js} +2 -2
- package/dist/client/assets/{chunk-IMKFNOWR-CGR_s6mQ.js → chunk-IMKFNOWR-Bo44GnXt.js} +2 -2
- package/dist/client/assets/{chunk-L3NEJ4N5-BPN8qLtR.js → chunk-L3NEJ4N5-CL_FAp25.js} +2 -2
- package/dist/client/assets/{chunk-OSK3NFVY-C83gEYhi.js → chunk-OSK3NFVY-C-UAFrKw.js} +2 -2
- package/dist/client/assets/{chunk-P2QGCYS3-DoadH0FQ.js → chunk-P2QGCYS3-Cu_kTzsg.js} +2 -2
- package/dist/client/assets/{chunk-POPQ4Y6H-OENQdCtW.js → chunk-POPQ4Y6H-DlEI3XVl.js} +2 -2
- package/dist/client/assets/{chunk-PWAF6VOD-Bm9xwnBb.js → chunk-PWAF6VOD-COj3Z6PV.js} +2 -2
- package/dist/client/assets/{chunk-SHT3W25Y-CZdeFTa3.js → chunk-SHT3W25Y-DmOdlcB6.js} +2 -2
- package/dist/client/assets/{chunk-SVP7TREG-CWjZG-1G.js → chunk-SVP7TREG-DZcmFNGC.js} +2 -2
- package/dist/client/assets/{chunk-TICWLB2K-C6_3qr0T.js → chunk-TICWLB2K-D2Au2dCv.js} +2 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-BNlFiwih.js +2 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BNlFiwih.js +2 -0
- package/dist/client/assets/{color-picker-B_vY4rCj.js → color-picker-8XrkJD1z.js} +2 -2
- package/dist/client/assets/{combobox-CZ_uig0z.js → combobox-BdHSd-gh.js} +2 -2
- package/dist/client/assets/{command-DGoFksB6.js → command-DywgXMPU.js} +2 -2
- package/dist/client/assets/{connect-CuZjH_Pw.js → connect-D6Vr-odX.js} +2 -2
- package/dist/client/assets/{connect-agent-BhcB_UCW.js → connect-agent-D6S_10vE.js} +2 -2
- package/dist/client/assets/{cynefin-OW5HDTMX-BBaHuZtP.js → cynefin-OW5HDTMX-Cl8Piv1U.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-D0TOipYC.js → cynefinDiagram-5FMLGOSQ-BlrMhOzc.js} +2 -2
- package/dist/client/assets/{dagre-GXQ25YYZ-BqIStTWM.js → dagre-GXQ25YYZ-zcnnhkbu.js} +2 -2
- package/dist/client/assets/{device-Dy_6ukvt.js → device-CVYEIUNR.js} +2 -2
- package/dist/client/assets/{diagram-S7CK7UJ4-DtlY2HLu.js → diagram-S7CK7UJ4-bDWotpej.js} +2 -2
- package/dist/client/assets/{diagram-UQ7AKVKN-AFvyPgaY.js → diagram-UQ7AKVKN-QfcGX0wU.js} +2 -2
- package/dist/client/assets/{diagram-VSXAHHWV-BX0DQrOR.js → diagram-VSXAHHWV-B6rtnGIC.js} +2 -2
- package/dist/client/assets/{diagram-VX7I27RA-RpuCJkmb.js → diagram-VX7I27RA-Bh7jDf_z.js} +2 -2
- package/dist/client/assets/{diagram-Z3DM3KII-YDywc4a-.js → diagram-Z3DM3KII-BF8BOL3s.js} +2 -2
- package/dist/client/assets/{dialog-COvCzBu5.js → dialog-B5b8j4VI.js} +2 -2
- package/dist/client/assets/{diffRendering-EBC4wPDV.js → diffRendering-CnRmUrdi.js} +2 -2
- package/dist/client/assets/{discovery-list-B1TD-soO.js → discovery-list-DLWA9rLh.js} +2 -2
- package/dist/client/assets/{dist-Cg-eOU-v.js → dist-B181ZKao.js} +3 -3
- package/dist/client/assets/{draft-input-DHW6QTyZ.js → draft-input-CidATm_k.js} +2 -2
- package/dist/client/assets/{duoViewer-B9J_QozU.js → duoViewer-gLqnN26Y.js} +2 -2
- package/dist/client/assets/{dynamic-CUevKA9_.js → dynamic-C9YFXILD.js} +2 -2
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-CAfVAMWI.js → ebnfDiagram-PWID7BFC-DbaAPr36.js} +2 -2
- package/dist/client/assets/{embeddedScripts-Cvalo74G.js → embeddedScripts-DZZY2Y12.js} +2 -2
- package/dist/client/assets/{empty-Dmvz5ya5.js → empty-BQwNj0_P.js} +2 -2
- package/dist/client/assets/{entities-DPdxOTpx.js → entities-CW57Cs5E.js} +2 -2
- package/dist/client/assets/{erDiagram-RLTQ6QDP-B8I9HNiQ.js → erDiagram-RLTQ6QDP-CkFVQs9q.js} +2 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-Bx5bcL3d.js +1 -0
- package/dist/client/assets/{fileLinks-Cfgs6wOJ.js → fileLinks-CJJSqeqK.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-BbO9lBJr.js → fileTreeExpansion-D1dm7wQj.js} +2 -2
- package/dist/client/assets/flowDiagram-HODETNUW-BOrqEpZF.js +1 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-G4XFicxk.js → ganttDiagram-EL5Y4UJY-bgGfFOUy.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-BhtRP4yl.js → getDiffFileInput-C3kf5492.js} +2 -2
- package/dist/client/assets/{gitGraph-4MIJSDKK-Dz9vbKwX.js → gitGraph-4MIJSDKK-CkcsQXce.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-BRPk5Iff.js → gitGraphDiagram-WWUBYQGX-D9-3rabr.js} +2 -2
- package/dist/client/assets/{guideRunStore-OyuNEz1_.js → guideRunStore-C7ZnghV_.js} +2 -2
- package/dist/client/assets/{htmlRender-94mfYlmv.js → htmlRender-Dwrbtk9Z.js} +2 -2
- package/dist/client/assets/{index-BGHZIIwm.js → index-CG78-Gl5.js} +3 -3
- package/dist/client/assets/{info-A6RAGUB7-C2HElvlZ.js → info-A6RAGUB7-D_d0Mq_H.js} +1 -1
- package/dist/client/assets/{infoDiagram-27XIBGKW-IOOCD2gD.js → infoDiagram-27XIBGKW-DYnd3lec.js} +2 -2
- package/dist/client/assets/{input-OK9fSGsW.js → input-CNGP9r-b.js} +2 -2
- package/dist/client/assets/{input-group-DLt_QDs-.js → input-group-CIDwGwLV.js} +2 -2
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-DVm2wQsr.js → ishikawaDiagram-5VMMS53U-Br3IhV30.js} +2 -2
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-KFjVMjGh.js → journeyDiagram-3NMN7TZE-D4gshgtr.js} +2 -2
- package/dist/client/assets/{kanban-definition-UXKFOSKX-DxT40hgP.js → kanban-definition-UXKFOSKX-DODm_gbD.js} +2 -2
- package/dist/client/assets/{kbd-LyGbiGLS.js → kbd-C3OLELe_.js} +2 -2
- package/dist/client/assets/{keybindings-BWCWrY_-.js → keybindings-Dw_FB1Sr.js} +2 -2
- package/dist/client/assets/{lazyRouteComponent-Doka-Cpt.js → lazyRouteComponent-knQbCz5Y.js} +2 -2
- package/dist/client/assets/{line-BUx_Qlcs.js → line-B2pKNKWO.js} +2 -2
- package/dist/client/assets/{link-DaswZEsz.js → link-CBNV8k75.js} +2 -2
- package/dist/client/assets/{linkedPrompt-3u_uoe6Y.js → linkedPrompt-BsxfomUU.js} +2 -2
- package/dist/client/assets/{main-DB45P6Gd.js → main-pmaKofkn.js} +7 -7
- package/dist/client/assets/{mediaReference-T3SNj1En.js → mediaReference-BLVT2VlI.js} +2 -2
- package/dist/client/assets/{mediaSource-DAJ35Twr.js → mediaSource-1xb6xNr7.js} +2 -2
- package/dist/client/assets/{mermaid-parser.core-CuUxy4fc.js → mermaid-parser.core-CT916xNb.js} +4 -4
- package/dist/client/assets/{mermaid.core-CV-2Hipl.js → mermaid.core-dZGXThQe.js} +5 -5
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-B5gC6PY9.js → mindmap-definition-YA3MSWOX-DRDe2pwU.js} +2 -2
- package/dist/client/assets/{number-field-CHOp4dMK.js → number-field-CrV4BtLe.js} +2 -2
- package/dist/client/assets/{observeResize-B7tl_Rye.js → observeResize-jQzrVN_N.js} +2 -2
- package/dist/client/assets/{onboarding-CFB4Wz5g.js → onboarding-DnxQtcwh.js} +2 -2
- package/dist/client/assets/{openFileInPreview-D80asiJZ.js → openFileInPreview-Dx_dxN9N.js} +2 -2
- package/dist/client/assets/{p4ProjectFile-BfBM2HoW.js → p4ProjectFile-BfRZT-Cd.js} +2 -2
- package/dist/client/assets/{packet-AYTQ26CC-CJ0qzIIY.js → packet-AYTQ26CC-BewZkvu0.js} +1 -1
- package/dist/client/assets/{pair-CQbNFhjc.js → pair-B5ki01nI.js} +2 -2
- package/dist/client/assets/{pegDiagram-XKGWAZYB-BzvO80-H.js → pegDiagram-XKGWAZYB-C9c_KSl7.js} +2 -2
- package/dist/client/assets/{phoneViewer-BghY79hZ.js → phoneViewer-HVXHif_1.js} +2 -2
- package/dist/client/assets/{pie-WAS4IAKB-M62byk0f.js → pie-WAS4IAKB-CzmLCGka.js} +1 -1
- package/dist/client/assets/{pieDiagram-E7YTZNPT-O5p8eSgL.js → pieDiagram-E7YTZNPT-C-Z8w4pJ.js} +2 -2
- package/dist/client/assets/{pierre-icons-BweC0Ojp.js → pierre-icons-CnfzBsKG.js} +2 -2
- package/dist/client/assets/{popover-DzOky6C0.js → popover-CCsUmLYF.js} +2 -2
- package/dist/client/assets/{preview-DLjmZv-h.js → preview-BJJOaGR2.js} +2 -2
- package/dist/client/assets/{preview-CP02VJQW.js → preview-BXxrRVX-.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore-DnzLYNg5.js → previewMiniPlayerStore-C7poB4-A.js} +2 -2
- package/dist/client/assets/{primary-z0kWcTid.js → primary-DBlVHyxT.js} +2 -2
- package/dist/client/assets/{primaryCloudLinkState-Bup2zk6b.js → primaryCloudLinkState-BfCEo8Kn.js} +2 -2
- package/dist/client/assets/{projectFilesQueryState-BKJPj8kq.js → projectFilesQueryState-CgqhXdfj.js} +2 -2
- package/dist/client/assets/{projectScriptEditor-C10v2IgV.js → projectScriptEditor-CARl6hYK.js} +2 -2
- package/dist/client/assets/{providerSkills-DPGvsbQq.js → providerSkills-B2xzNGmJ.js} +2 -2
- package/dist/client/assets/{pullRequestDetail.logic-CQ1l2jWB.js → pullRequestDetail.logic-CYwAUOQC.js} +2 -2
- package/dist/client/assets/{pullRequestIcons-Cwz6tomi.js → pullRequestIcons-SCwBWGeD.js} +2 -2
- package/dist/client/assets/{pullRequestReviewStore-DejvzSy2.js → pullRequestReviewStore-C7gfd5m3.js} +2 -2
- package/dist/client/assets/{pullRequests-DmlU8TRv.js → pullRequests-DQFba6Nz.js} +2 -2
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-DMpTBqB0.js → quadrantDiagram-AXDQQJYC-I8UtWMv_.js} +2 -2
- package/dist/client/assets/{queries-DUuhuhAL.js → queries-DfOxYbXr.js} +2 -2
- package/dist/client/assets/{query-BWYUB_iK.js → query-w0R7LhwJ.js} +2 -2
- package/dist/client/assets/{radar-RG4KPBEZ-CRHj_0uz.js → radar-RG4KPBEZ-CuVsLyvG.js} +1 -1
- package/dist/client/assets/{radio-group-8ftKbjDf.js → radio-group-DwQ0T1X6.js} +2 -2
- package/dist/client/assets/{railroad-74A4TZTK-LCbjmT_s.js → railroad-74A4TZTK-CZZIaT2B.js} +1 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-DieERyRq.js +1 -0
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-BVbP0cR7.js +1 -0
- package/dist/client/assets/railroad-peg-WCYAUIDC-BDR9vaLF.js +1 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-B1mHyPCC.js → railroadDiagram-O6MQD6OU-CogIhoTG.js} +2 -2
- package/dist/client/assets/{renderScheduler-D3-fIVU2.js → renderScheduler-wjSXDjer.js} +2 -2
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-BH8vaSWt.js → requirementDiagram-BXWQKSXE-B9wTphzK.js} +2 -2
- package/dist/client/assets/{rightPanelStore-Dfw-4Ia_.js → rightPanelStore-CRw1DWSH.js} +2 -2
- package/dist/client/assets/{runtime-ivCTGH5C.js → runtime-ZOY8Qeg_.js} +2 -2
- package/dist/client/assets/{runtime-VHJoq9so.js → runtime-qAs3Aj0U.js} +3 -3
- package/dist/client/assets/{runtimeModeConfig-JkwDqP4L.js → runtimeModeConfig-VaVDuoFW.js} +2 -2
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-DqqzdGsV.js → sankeyDiagram-P5KCCOFB-CeJuchFj.js} +2 -2
- package/dist/client/assets/{scheduledTasksSettings.logic-b-y7WIWN.js → scheduledTasksSettings.logic-BBBjz09I.js} +2 -2
- package/dist/client/assets/{scroll-area-BtAqRLpC.js → scroll-area-DyzCabMe.js} +2 -2
- package/dist/client/assets/{select-FY7psXk-.js → select-BX0YSg0P.js} +2 -2
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-D6EXXu_o.js → sequenceDiagram-WJ2MYXX4-xpNi2v3f.js} +2 -2
- package/dist/client/assets/{server-C-qtaHHG.js → server-BxsIDqAi.js} +2 -2
- package/dist/client/assets/{session-KZUTmmZy.js → session-Lp4r-IPM.js} +2 -2
- package/dist/client/assets/{session-logic-Dy9r5m2F.js → session-logic-BFdJF3Bv.js} +2 -2
- package/dist/client/assets/{settings-xVK7Yt1y.js → settings-D6fi9-XU.js} +2 -2
- package/dist/client/assets/{settings.appearance-BUsQj9AN.js → settings.appearance-BBT8xGDi.js} +2 -2
- package/dist/client/assets/settings.archived-Cg-9thGj.js +2 -0
- package/dist/client/assets/{settings.computer-use-CvtFf-rW.js → settings.computer-use-Bona3Wg6.js} +2 -2
- package/dist/client/assets/{settings.connections-C90xtGng.js → settings.connections-BqAUuYT4.js} +2 -2
- package/dist/client/assets/{settings.data-controls-DemQiCxT.js → settings.data-controls-OJqN88f4.js} +2 -2
- package/dist/client/assets/{settings.decisions-DtOP9oNq.js → settings.decisions-CZWGkeug.js} +2 -2
- package/dist/client/assets/{settings.diagnostics-DXaoukRP.js → settings.diagnostics-DELbs4ob.js} +2 -2
- package/dist/client/assets/{settings.general-DkWee1YY.js → settings.general-B-fstEU-.js} +2 -2
- package/dist/client/assets/{settings.integrations-BXlqBhz3.js → settings.integrations-B9_Yw0oa.js} +2 -2
- package/dist/client/assets/{settings.keybindings-Br0uBlw0.js → settings.keybindings-tFQjI19L.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-C7LrTwqH.js → settings.open-source-licenses-J0KhjvdX.js} +2 -2
- package/dist/client/assets/{settings.plugins-BWko147F.js → settings.plugins-BnMZc7bA.js} +2 -2
- package/dist/client/assets/{settings.projects-Hlmn9qBx.js → settings.projects-B9iYESeP.js} +3 -3
- package/dist/client/assets/{settings.providers-CUBhfBx1.js → settings.providers-D_HCdEfA.js} +3 -3
- package/dist/client/assets/{settings.scheduled-tasks-CDDYe3d2.js → settings.scheduled-tasks-DaNDwLtr.js} +2 -2
- package/dist/client/assets/{settings.snap-shot-BlVwefsY.js → settings.snap-shot-ClQxMhzg.js} +2 -2
- package/dist/client/assets/{settings.source-control-b4BRd-7w.js → settings.source-control-Bs4O94Ae.js} +2 -2
- package/dist/client/assets/{settings.storage-DHuqQ3GN.js → settings.storage-BYJ2h7qr.js} +2 -2
- package/dist/client/assets/{settingsLayout-CthFz77S.js → settingsLayout-DhPKINaL.js} +2 -2
- package/dist/client/assets/{sidebar-BvjZQtR9.js → sidebar-ZKIDHqbk.js} +2 -2
- package/dist/client/assets/{sidebarProjectGrouping-CvY13nmg.js → sidebarProjectGrouping-BFqO8E5C.js} +2 -2
- package/dist/client/assets/{skeleton-p05dxp84.js → skeleton--v3ra8uu.js} +2 -2
- package/dist/client/assets/{sortable.esm-BVaB8fBB.js → sortable.esm-UojJGtqY.js} +2 -2
- package/dist/client/assets/{sourceControl-CtDr1raw.js → sourceControl-ByZv2xxh.js} +2 -2
- package/dist/client/assets/{spinner-CTNKP1wB.js → spinner-CH-Dn9Fj.js} +2 -2
- package/dist/client/assets/{standalone-page-BmCMlz1u.js → standalone-page-BwpW1F1h.js} +2 -2
- package/dist/client/assets/{stateDiagram-D77RDMKH-CVk9L7UB.js → stateDiagram-D77RDMKH-BMh5LMip.js} +2 -2
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CK8WckkU.js +2 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-eDs6vlYW.js → swimlanes-42K2YHIH-CGCv__e7.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-D_se7el1.js +9 -0
- package/dist/client/assets/{terminal-links-MjQ9lNGX.js → terminal-links-DX86FsHj.js} +2 -2
- package/dist/client/assets/{terminalSessions-BEOZlx0H.js → terminalSessions-CUABDfio.js} +2 -2
- package/dist/client/assets/{textarea-_oDVfjxe.js → textarea-B3ib3YW-.js} +2 -2
- package/dist/client/assets/{themePalette-DtFR3xYu.js → themePalette-Bl55tW1x.js} +2 -2
- package/dist/client/assets/{threadSort-BgwLDPpx.js → threadSort-DDAHH_-8.js} +2 -2
- package/dist/client/assets/{timeline-definition-24CTP7MA-nEI4h-Tk.js → timeline-definition-24CTP7MA-C_Okwnia.js} +2 -2
- package/dist/client/assets/{toast-CyScduZI.js → toast-3I2gpMYd.js} +2 -2
- package/dist/client/assets/{toggle-BBpi92mE.js → toggle-Ce46mx2g.js} +2 -2
- package/dist/client/assets/{toggle-group--QyJ7uYY.js → toggle-group-Dt1Yldxx.js} +2 -2
- package/dist/client/assets/{tooltip-DcTdC2PH.js → tooltip-DdUPPKq4.js} +2 -2
- package/dist/client/assets/{treeView-Q6P3EWNA-BqkVgtYX.js → treeView-Q6P3EWNA-23mUAiRP.js} +1 -1
- package/dist/client/assets/{treemap-WGGIJYW6-DT4jZxe1.js → treemap-WGGIJYW6-CFr3RCz-.js} +1 -1
- package/dist/client/assets/{usage-BoakMkho.js → usage-DXTqHj0T.js} +2 -2
- package/dist/client/assets/{usageAccess-Tjotp_ad.js → usageAccess-BX6xSC4z.js} +2 -2
- package/dist/client/assets/{usageFormat-C1GJS5IW.js → usageFormat-CWi_Qt3l.js} +2 -2
- package/dist/client/assets/{usageShortcuts-BmYIhNjb.js → usageShortcuts-CGv3_tEe.js} +2 -2
- package/dist/client/assets/{use-atom-command-CYY238HA.js → use-atom-command-CVDCnNHi.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-_J6EHbv7.js → useAriaLabelledBy-BnxRm9-q.js} +2 -2
- package/dist/client/assets/{useHandleNewThread-BhaVM65m.js → useHandleNewThread-BrxevYhf.js} +2 -2
- package/dist/client/assets/{useLocation-Cfwex-wi.js → useLocation-BdZaQ50l.js} +2 -2
- package/dist/client/assets/useNavigate-Cdy4Jh5i.js +2 -0
- package/dist/client/assets/{useNavigateBack-B0NrYlh8.js → useNavigateBack-BLZDxCI_.js} +2 -2
- package/dist/client/assets/{useParams-U7vgc6nk.js → useParams-3tEZUuVD.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-Urd4cbKv.js → usePermissionStatus-DCcJZUJC.js} +2 -2
- package/dist/client/assets/{usePullRequestActions-DpAVW9io.js → usePullRequestActions-cqQ4IRFz.js} +2 -2
- package/dist/client/assets/{useRegisterFieldControl-B-o6bvd-.js → useRegisterFieldControl-Cs54XrA4.js} +2 -2
- package/dist/client/assets/{useScopedModelAvailability-CIh6LpSK.js → useScopedModelAvailability-DSe3UBFZ.js} +2 -2
- package/dist/client/assets/{useSettings-gJURpIkJ.js → useSettings-DsvnJBf2.js} +2 -2
- package/dist/client/assets/{useT3ConnectAuthPrompt-Np9NC6fS.js → useT3ConnectAuthPrompt-CBxfN-Bk.js} +2 -2
- package/dist/client/assets/{utils-BBRDx4UJ.js → utils-TSzPLNGf.js} +2 -2
- package/dist/client/assets/{vcsRefInvalidation-DwljOjdx.js → vcsRefInvalidation-iz2QneVc.js} +2 -2
- package/dist/client/assets/{vennDiagram-4TSXK5OY-kVbUFMzz.js → vennDiagram-4TSXK5OY-DsePUj7P.js} +2 -2
- package/dist/client/assets/{wardley-WFR3VGLG-B5JrY4hA.js → wardley-WFR3VGLG-DADViFrd.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-kNz0Ytm1.js → wardleyDiagram-VM6X3IG4-B7tstBZh.js} +2 -2
- package/dist/client/assets/{welcome-vYaNWLrj.js → welcome-CQKf0B5f.js} +2 -2
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-DGSU7PNa.js → xychartDiagram-S5SC5T6Z-DRAYLcYA.js} +2 -2
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/dist/client/assets/architecture-7GRP2DOG-BTjma_hq.js +0 -1
- package/dist/client/assets/channel-BbVwyPme.js +0 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-BZN2DxkM.js +0 -2
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BZN2DxkM.js +0 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-Cg0CFdkZ.js +0 -1
- package/dist/client/assets/flowDiagram-HODETNUW-RF9W51fq.js +0 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-DJLpez1j.js +0 -1
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-FSaf-eSC.js +0 -1
- package/dist/client/assets/railroad-peg-WCYAUIDC-pIcyAgnc.js +0 -1
- package/dist/client/assets/settings.archived-B-IVcn1Z.js +0 -2
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DNtAQSJX.js +0 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-CEvm2POs.js +0 -9
- package/dist/client/assets/useNavigate-B3U2CN2A.js +0 -2
package/dist/client/assets/{ThreadTerminalDrawer-Di41e66k.js → ThreadTerminalDrawer-CJZ5gJIq.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$g as n,Co as r,Dm as i,Gp as a,Jp as o,Sy as s,Vo as c,WT as l,Yp as u,ay as d,c_ as f,mE as p,nm as m,ry as h,sm as g,sr as ee,t as te,vc as _,vp as ne,vs as v,vy as y}from"./utils-BBRDx4UJ.js";import{L as re,U as ie}from"./runtime-VHJoq9so.js";import{a as b,n as x,t as S}from"./tooltip-DcTdC2PH.js";import{f as ae,i as oe,m as se}from"./toast-CyScduZI.js";import{J as ce,s as le}from"./useSettings-gJURpIkJ.js";import{f as ue}from"./server-C-qtaHHG.js";import{i as de,n as fe}from"./session-KZUTmmZy.js";import{t as C}from"./use-atom-command-CYY238HA.js";import{l as pe}from"./rightPanelStore-Dfw-4Ia_.js";import{a as me}from"./fileLinks-Cfgs6wOJ.js";import{n as he}from"./toastHelpers-Dsph6LwL.js";import{t as ge}from"./observeResize-B7tl_Rye.js";import{S as _e,c as ve,d as w,n as T,s as E,x as ye}from"./browserHistoryStore-D3NmgwWz.js";import{S as D,a as be,c as xe,d as Se,f as Ce,l as we,p as Te,u as Ee,x as O}from"./keybindings-BWCWrY_-.js";import{t as De}from"./preview-DLjmZv-h.js";import{n as k,r as A}from"./browserLinkTarget-CTDv30-a.js";import{i as Oe,o as j,t as ke}from"./popover-DzOky6C0.js";import{i as Ae,n as je,t as M}from"./terminal-links-MjQ9lNGX.js";import{a as Me,i as Ne,o as N,t as P}from"./terminalSessions-BEOZlx0H.js";import{t as Pe}from"./terminalLabels-BgLOlb2G.js";import{Da as Fe,Oa as F,Wa as Ie,wa as I,xa as Le}from"./main-DB45P6Gd.js";var L=e(t(),1),Re=p(),R=e(l(),1);function ze(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 Be({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))},ne=e=>{e.isPrimary&&e.button===0&&(o=!1)},v=e=>{e.button===0&&(o=!1,s&&(s=!1,l={x:e.clientX,y:e.clientY},ee(e.detail>=2?500:0)))},y=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`,ne),a.addEventListener(`mouseup`,v),a.addEventListener(`pointercancel`,h),i.addEventListener(`keydown`,y),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`,ne),a.removeEventListener(`mouseup`,v),a.removeEventListener(`pointercancel`,h),i.removeEventListener(`keydown`,y),i.removeEventListener(`focusin`,re),e.removeEventListener(`contextmenu`,g,!0),e.removeEventListener(`scroll`,ie,!0),a.removeEventListener(`blur`,h),a.removeEventListener(`resize`,h)}}}var z=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 B(e){return z.get(e)??0}var Ve=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),He;function Ue(){if(He)return He;let e=(globalThis.navigator?.keyboard)?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0);return He=e,e}function V(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function We(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=Ve.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,Ue().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,B(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,V(e)),this.runtime.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),this.runtime.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,We(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||!I(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=M(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 je(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`&&!_(t)?e.ctrlKey&&!e.shiftKey&&!e.metaKey:n===`c`?_(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`&&!_(t)?e.shiftKey&&!e.ctrlKey&&!e.metaKey:n===`v`?_(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=ge(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=_(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&&!_(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 a=this.core.encodeKey(e);a.length!==0&&(this.suppressedKeyCodes.delete(e.code),e.preventDefault(),e.stopPropagation(),this.options.onData(a))};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,Re.c)(14),{children:n,label:r,onClick:a,tooltip:o}=e,s;t[0]===n?s=t[1]:(s=(0,R.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]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,R.jsx)(i,{className:`hidden size-3 group-hover/tab:block group-focus-visible/close:block`}),t[2]=c):c=t[2];let l;t[3]!==r||t[4]!==a||t[5]!==s?(l=(0,R.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:a,children:[s,c]}),t[3]=r,t[4]=a,t[5]=s,t[6]=l):l=t[6];let u=l;if(!o)return u;let d;t[7]===u?d=t[8]:(d=(0,R.jsx)(b,{render:u}),t[7]=u,t[8]=d);let f;t[9]===o?f=t[10]:(f=(0,R.jsx)(x,{children:o}),t[9]=o,t[10]=f);let p;return t[11]!==d||t[12]!==f?(p=(0,R.jsxs)(S,{children:[d,f]}),t[11]=d,t[12]=f,t[13]=p):p=t[13],p}var rn=0;function an(){return rn>0}async function on(e){let t=ce();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{$g as n,Co as r,Dm as i,Gp as a,Jp as o,Sy as s,Vo as c,WT as l,Yp as u,ay as d,c_ as f,mE as p,nm as m,ry as h,sm as g,sr as ee,t as te,vc as _,vp as ne,vs as v,vy as y}from"./utils-TSzPLNGf.js";import{L as re,U as ie}from"./runtime-qAs3Aj0U.js";import{a as b,n as x,t as S}from"./tooltip-DdUPPKq4.js";import{f as ae,i as oe,m as se}from"./toast-3I2gpMYd.js";import{J as ce,s as le}from"./useSettings-DsvnJBf2.js";import{f as ue}from"./server-BxsIDqAi.js";import{i as de,n as fe}from"./session-Lp4r-IPM.js";import{t as C}from"./use-atom-command-CVDCnNHi.js";import{l as pe}from"./rightPanelStore-CRw1DWSH.js";import{a as me}from"./fileLinks-CJJSqeqK.js";import{n as he}from"./toastHelpers-Dsph6LwL.js";import{t as ge}from"./observeResize-jQzrVN_N.js";import{S as _e,c as ve,d as w,n as T,s as E,x as ye}from"./browserHistoryStore-CUwwaVj8.js";import{S as D,a as be,c as xe,d as Se,f as Ce,l as we,p as Te,u as Ee,x as O}from"./keybindings-Dw_FB1Sr.js";import{t as De}from"./preview-BJJOaGR2.js";import{n as k,r as A}from"./browserLinkTarget-o1Hmp1Jv.js";import{i as Oe,o as j,t as ke}from"./popover-CCsUmLYF.js";import{i as Ae,n as je,t as M}from"./terminal-links-DX86FsHj.js";import{a as Me,i as Ne,o as N,t as P}from"./terminalSessions-CUABDfio.js";import{t as Pe}from"./terminalLabels-BgLOlb2G.js";import{Da as Fe,Oa as F,Wa as Ie,wa as I,xa as Le}from"./main-pmaKofkn.js";var L=e(t(),1),Re=p(),R=e(l(),1);function ze(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 Be({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))},ne=e=>{e.isPrimary&&e.button===0&&(o=!1)},v=e=>{e.button===0&&(o=!1,s&&(s=!1,l={x:e.clientX,y:e.clientY},ee(e.detail>=2?500:0)))},y=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`,ne),a.addEventListener(`mouseup`,v),a.addEventListener(`pointercancel`,h),i.addEventListener(`keydown`,y),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`,ne),a.removeEventListener(`mouseup`,v),a.removeEventListener(`pointercancel`,h),i.removeEventListener(`keydown`,y),i.removeEventListener(`focusin`,re),e.removeEventListener(`contextmenu`,g,!0),e.removeEventListener(`scroll`,ie,!0),a.removeEventListener(`blur`,h),a.removeEventListener(`resize`,h)}}}var z=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 B(e){return z.get(e)??0}var Ve=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),He;function Ue(){if(He)return He;let e=(globalThis.navigator?.keyboard)?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0);return He=e,e}function V(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function We(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=Ve.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,Ue().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,B(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,V(e)),this.runtime.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),this.runtime.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,We(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||!I(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=M(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 je(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`&&!_(t)?e.ctrlKey&&!e.shiftKey&&!e.metaKey:n===`c`?_(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`&&!_(t)?e.shiftKey&&!e.ctrlKey&&!e.metaKey:n===`v`?_(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=ge(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=_(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&&!_(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 a=this.core.encodeKey(e);a.length!==0&&(this.suppressedKeyCodes.delete(e.code),e.preventDefault(),e.stopPropagation(),this.options.onData(a))};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,Re.c)(14),{children:n,label:r,onClick:a,tooltip:o}=e,s;t[0]===n?s=t[1]:(s=(0,R.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]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,R.jsx)(i,{className:`hidden size-3 group-hover/tab:block group-focus-visible/close:block`}),t[2]=c):c=t[2];let l;t[3]!==r||t[4]!==a||t[5]!==s?(l=(0,R.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:a,children:[s,c]}),t[3]=r,t[4]=a,t[5]=s,t[6]=l):l=t[6];let u=l;if(!o)return u;let d;t[7]===u?d=t[8]:(d=(0,R.jsx)(b,{render:u}),t[7]=u,t[8]=d);let f;t[9]===o?f=t[10]:(f=(0,R.jsx)(x,{children:o}),t[9]=o,t[10]=f);let p;return t[11]!==d||t[12]!==f?(p=(0,R.jsxs)(S,{children:[d,f]}),t[11]=d,t[12]=f,t[13]=p):p=t[13],p}var rn=0;function an(){return rn>0}async function on(e){let t=ce();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:y,threadId:y,targetOrigin:y,cause:d()},cn=class extends s()(`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&&k(e.url)&&ye(e.threadRef.environmentId)&&e.threadRef.threadId.length>0&&await A()===`app`)){e.fallbackToBrowser();return}let t={environmentId:e.threadRef.environmentId,threadId:e.threadRef.threadId,targetOrigin:new URL(e.url).origin},n=await w(),i=_e(e.threadRef.environmentId),a=await e.openPreview({environmentId:e.threadRef.environmentId,input:{threadId:e.threadRef.threadId,url:e.url,viewport:ve(n),profileId:E(n),...i===void 0?{}:{runtime:i}}});if(a._tag===`Failure`){if(re(a))return;console.error(new cn({...t,cause:a.cause})),e.fallbackToBrowser();return}T(e.threadRef,e.url),r(e.threadRef,a.value),pe.getState().openBrowser(e.threadRef,a.value.tabId)}function un(e){return{...e===void 0?{}:{platform:e},context:{terminalFocus:!0,terminalOpen:!0}}}function dn(e,t,n){return we(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=N(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:r,terminalId:i,terminalLabel:a,cwd:o,worktreePath:s,runtimeEnv:l,providerInstanceId:u,onSessionExited:d,onAddTerminalContext:p,focusRequestId:m,autoFocus:h,visible:g,resizeEpoch:ee,drawerHeight:te,keybindings:_}){let ne=(0,L.useRef)(null),v=(0,L.useRef)(null),y=(0,L.useRef)(g),b=t.environmentId,x=de(b,f),S=(0,L.useEffectEvent)(()=>fe(b,f)),pe=de(b,n),ge=(0,L.useEffectEvent)(e=>Ae(e)||fe(b,`orchestration:operate`)),_e=c(ue.configValueAtom(b)),ve=Ie(b,_e?.availableEditors??[]),w=(0,L.useEffectEvent)(e=>ve(e)),T=C(De.open,{reportFailure:!1}),E=C(Ne.write,{reportFailure:!1}),ye=C(Ne.resize,{reportFailure:!1}),we=(0,L.useRef)(!1),k=(0,L.useRef)(0),A=(0,L.useRef)(null),Oe=(0,L.useRef)(_),j=(0,L.useMemo)(()=>Cn(l),[l]),ke=(0,L.useEffectEvent)(()=>{S()&&d()}),je=(0,L.useEffectEvent)(e=>{p?.(e)}),M=(0,L.useEffectEvent)(()=>p!==void 0),Pe=(0,L.useEffectEvent)(()=>a),I=le(t=>Fe({advanced:e,code:t.fontFamilyCode,terminal:t.fontFamilyTerminal})),Le=le(t=>F({advanced:e,code:t.fontSizeCode,terminal:t.fontSizeTerminal})),Re=(0,L.useRef)({family:I,size:Le}),z=P({environmentId:b,terminal:{threadId:r,terminalId:i,cwd:o,...s===void 0?{}:{worktreePath:s},...l?{env:l}:{},...u?{providerInstanceId:u}:{}}}),B=x&&z.version>0&&z.status===`running`,Ve=B?z.output.generation:null,He=(0,L.useEffectEvent)(e=>E({environmentId:b,input:{threadId:r,terminalId:i,data:e}})),Ue=(0,L.useEffectEvent)((e,t)=>{if(B&&S())return ye({environmentId:b,input:{threadId:r,terminalId:i,cols:e,rows:t}})}),V=z.output,We=z.error,H=z.status,Ge=(0,L.useRef)(Me),U=(0,L.useRef)(`closed`),Ke=(0,L.useEffectEvent)((e,t,n)=>{let r=U.current;n>0&&t===`running`?we.current=!1:Mn(t,r,we.current,n)&&(we.current=!0,_n(e,t===`closed`?`Terminal closed`:`Process exited`),window.setTimeout(()=>{we.current&&ke()},0)),n>0&&(U.current=t)}),W=z.version,G=(0,L.useRef)({output:V,error:We,status:H,version:W}),K=(0,L.useRef)(G.current);return K.current={output:V,error:We,status:H,version:W},(0,L.useEffect)(()=>{Oe.current=_},[_]),(0,L.useLayoutEffect)(()=>{v.current&&(v.current.input.readOnly=!x)},[x]),(0,L.useEffect)(()=>{v.current?.refreshLinkActivation()},[pe]),(0,L.useEffect)(()=>{Ve!==null&&v.current?.resendSize()},[Ve]),(0,L.useLayoutEffect)(()=>{y.current=g,v.current?.setVisible(g)},[g]),(0,L.useEffect)(()=>{let e=Re.current;(e.family!==I||e.size!==Le)&&(Re.current={family:I,size:Le},v.current?.setFont(En(I,Le)))},[I,Le]),(0,L.useEffect)(()=>{let e=ne.current;if(!e)return;let n=ce(),r=!1,a=null,s=null,c=[],l=null;return(async()=>{let a=Re.current,u={theme:Dn(e),font:En(a.family,a.size),get visible(){return y.current},onData:e=>ve(e),onResize:(e,t)=>void Ue(e,t),onSelectionChange:()=>E(),beforeKey:e=>pe(e),onLinkActivate:(e,t)=>_e(e,t),canActivateLink:e=>ge(e),onContextMenu:e=>{v.current&&ue(e)}},d=await tn.create(e,u);if(r)return d.dispose(),null;d.setVisible(y.current),d.setTheme(Dn(e)),s=d,v.current=d,d.input.readOnly=!S();let f=Re.current;(f.family!==a.family||f.size!==a.size)&&d.setFont(En(f.family,f.size));let p=K.current;G.current=p;let m=N(p.output,Me);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()&&y.current&&e.contains(document.activeElement)&&d.focus();let h=(e=!1)=>{let t=A.current===k.current;(e||t)&&(k.current+=1),t&&n?.contextMenu.close()},g=()=>{l?.cancel(),h(!0)};c.push(g);let ee=(e=null)=>{let t=v.current,n=ne.current;if(!t||!n||!t.hasSelection())return null;let r=t.getSelection(),a=t.getSelectionPosition(),o=r.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:ze({bounds:n.getBoundingClientRect(),selectionRect:t.getSelectionEndClientRect(),pointer:e,viewport:{width:window.innerWidth,height:window.innerHeight}}),clipboardText:r,selection:{terminalId:i,terminalLabel:Pe(),lineStart:s,lineEnd:c,text:o}}},te=e=>{je(e),v.current?.clearSelection(),v.current?.focus()},_=(e,t,n)=>{if(e!==k.current)return;let r=v.current;r&&_n(r,t instanceof Error?t.message:n)},x=e=>{e===k.current&&v.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=v.current;if(t){try{await t.pasteFromClipboard(()=>ae(`terminal input`),()=>e===k.current)}catch(t){_(e,t,`Unable to read the clipboard`);return}x(e)}},ue=async e=>{if(!n||!v.current)return;e.preventDefault(),g();let t=ee(),r=k.current,i;try{i=await n.contextMenu.show(An({hasSelection:t!==null,canAddToChat:M(),readOnly:!S()}),{x:e.clientX,y:e.clientY})}catch(e){_(r,e,`Unable to open the terminal context menu`),x(r);return}if(r===k.current&&i!==null)switch(i){case`add-to-chat`:t&&M()&&te(t.selection);return;case`copy`:t&&await ce(t.clipboardText,r);return;case`paste`:await le(r);return;case`select-all`:v.current?.selectAll(),x(r);return;case`scroll-to-bottom`:v.current?.scrollToBottom(),x(r);return}},de=async e=>{if(!n){g();return}if(A.current===k.current)return;let t=ee(e);if(!t){g();return}let r=++k.current;A.current=r;let i=await n.contextMenu.show(kn({canAddToChat:M()}),t.position).finally(()=>{A.current===r&&(A.current=null)});if(r===k.current&&i!==null)switch(i){case`add-to-chat`:M()&&te(t.selection);return;case`copy`:await ce(t.clipboardText,r);return}},C=async(e,t)=>{if(!S())return;let n=v.current;if(!n)return;let r=await He(e);if(r._tag===`Failure`&&!re(r)){let e=ie(r);_n(n,e instanceof Error?e.message:t)}};function pe(e){let t=Oe.current,n={context:{terminalFocus:!0,terminalOpen:!0}};if(dn(e,t)||Te(e,t,n)||Se(e,t,n)||Ce(e,t,n)||Ee(e,t,n)||be(e,t,n))return!1;let r=D(e);if(r!==null)return e.preventDefault(),e.stopPropagation(),C(r,`Failed to move cursor`),!1;let i=O(e);return i===null?!xe(e)||(e.preventDefault(),e.stopPropagation(),C(`\f`,`Failed to clear terminal`),!1):(e.preventDefault(),e.stopPropagation(),C(i,`Failed to delete terminal input`),!1)}function _e(e,r){if(!ge(e))return;let i=v.current;if(!i)return;if(Ae(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(!fe(b,`preview:operate`)){a();return}ln({url:e,threadRef:t,openPreview:T,fallbackToBrowser:a,forceBrowser:r.metaKey||r.ctrlKey}).catch(e=>{oe.add(he({type:`error`,title:`Unable to open link`,description:e instanceof Error?e.message:`An error occurred.`}))});return}let a=me(e,o);(async()=>{let e=await w(a);if(e._tag===`Success`||re(e))return;let t=ie(e);_n(i,t instanceof Error?t.message:`Unable to open path`)})()}function ve(e){S()&&(async()=>{let t=await He(e);if(t._tag===`Success`||re(t))return;let n=ie(t);_n(d,n instanceof Error?n.message:`Terminal write failed`)})()}function E(){v.current?.hasSelection()||jn({actionPending:l?.pending??!1,openMenuRequestId:A.current,currentRequestId:k.current})&&g()}l=Be({element:e,onSelection:e=>{de(e)},onDismiss:e=>h(e===`interaction`)}),c.push(()=>l?.dispose());let ye=new MutationObserver(()=>{let e=v.current;e&&e.setTheme(Dn(ne.current))});ye.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}),c.push(()=>ye.disconnect());let we=window.setTimeout(()=>{let e=v.current;if(!e)return;let t=e.isAtBottom();e.fit(),t&&e.scrollToBottom()},30);c.push(()=>window.clearTimeout(we));let De=c;return c=[],s=null,()=>{for(let e of De.toReversed())e();v.current===d&&(v.current=null),d.dispose()}})().then(e=>{if(r){e?.();return}a=e}).catch(t=>{for(let e of c.toReversed())e();if(c=[],v.current===s&&(v.current=null),s?.dispose(),s=null,r)return;let n=t instanceof Error?t.message:`Unable to initialize libghostty-vt`;e.textContent=`${n} — close and reopen the terminal to retry.`}),()=>{r=!0;let t=e.contains(document.activeElement);a?.(),S()&&t&&e.isConnected&&e.focus({preventScroll:!0})}},[o,b,j,i,r,s]),(0,L.useEffect)(()=>{let e=v.current,t={output:V,error:We,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)},[V,We,H,W]),(0,L.useEffect)(()=>{h&&x&&g&&(v.current??ne.current)?.focus()},[h,x,m,g]),(0,L.useEffect)(()=>{let e=v.current;if(!e||!y.current)return;let t=e.isAtBottom(),n=window.requestAnimationFrame(()=>{y.current&&(e.fit(),t&&e.scrollToBottom())});return()=>{window.cancelAnimationFrame(n)}},[te,b,ee,i,r]),(0,R.jsx)(`div`,{ref:ne,tabIndex:-1,className:`relative h-full w-full overflow-hidden bg-(--terminal-background)`})}function Pn(e){let t=(0,Re.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=te(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,R.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,R.jsx)(j,{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,R.jsx)(Oe,{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,R.jsxs)(ke,{children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function Fn(e){let t=(0,Re.c)(169),{mode:n,threadRef:r,threadId:i,cwd:s,worktreePath:c,runtimeEnv:l,visible:d,height:p,terminalIds:_,activeTerminalId:y,terminalGroups:re,activeTerminalGroupId:ie,focusRequestId:b,onSplitTerminal:x,onSplitTerminalVertical:S,onNewTerminal:ae,splitShortcutLabel:oe,splitVerticalShortcutLabel:se,newShortcutLabel:ce,closeShortcutLabel:le,onActiveTerminalChange:ue,onCloseTerminal:C,onHeightChange:pe,onAddTerminalContext:me,keybindings:he,terminalLabelsById:ge,terminalLaunchLocationsById:_e}=e,ve=n===void 0?`drawer`:n,w=d===void 0||d,T=de(r.environmentId,f),E=ve===`panel`,[ye]=v(Le,!1,h),D=p,[be,xe]=(0,L.useState)(hn),Se;t[0]!==D||t[1]!==i?(Se=()=>({threadId:i,height:D}),t[0]=D,t[1]=i,t[2]=Se):Se=t[2];let[Ce,we]=(0,L.useState)(Se),Te=Ce.threadId===i?Ce.height:D,Ee;t[3]!==Te||t[4]!==be?(Ee=gn(Te,be),t[3]=Te,t[4]=be,t[5]=Ee):Ee=t[5];let O=Ee,De;t[6]!==D||t[7]!==i?(De=e=>{we(t=>{let n=t.threadId===i?t.height:D,r=typeof e==`function`?e(n):e;return r===n&&t.threadId===i?t:{threadId:i,height:r}})},t[6]=D,t[7]=i,t[8]=De):De=t[8];let k=De,[A,Oe]=(0,L.useState)(0),j=(0,L.useRef)(O),ke=(0,L.useRef)(Te),Ae=(0,L.useRef)(D),je=(0,L.useRef)(pe),M=(0,L.useRef)(null),Me=(0,L.useRef)(!1),Ne;if(t[9]!==_){Ne=[];let e=new Set;for(let t of _){let n=t.trim();n.length===0||e.has(n)||(e.add(n),Ne.push(n))}t[9]=_,t[10]=Ne}else Ne=t[10];let N=Ne,P=N.length===0?``:N.includes(y)?y:N[0]??``,Fe;bb0:{if(N.length===0){let e;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[11]=e):e=t[11],Fe=e;break bb0}let e;t[12]===N?e=t[13]:(e=new Set(N),t[12]=N,t[13]=e);let n=e,r;if(t[14]!==N||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]??N[0]??``}`;r.push({id:a(s),terminalIds:i,...t.splitDirection===`vertical`?{splitDirection:`vertical`}:{}})}for(let t of N)e.has(t)||r.push({id:a(`group-${t}`),terminalIds:[t]});let o=new Map(N.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]=N,t[15]=re,t[16]=n,t[17]=r}else r=t[17];Fe=r}let F=Fe,Ie;bb1:{let e=F.findIndex(e=>e.id===ie);if(e>=0){Ie=e;break bb1}let t=F.findIndex(e=>e.terminalIds.includes(P));Ie=t>=0?t:0}let I=Ie,ze;t[18]!==N.length||t[19]!==I||t[20]!==P||t[21]!==F?(ze=F[I]?.terminalIds??(N.length>0?[P]:[]),t[18]=N.length,t[19]=I,t[20]=P,t[21]=F,t[22]=ze):ze=t[22];let Be=ze,z=F[I]?.splitDirection??`horizontal`,B=N.length>1,Ve=Be.length>1,He;t[23]===F?He=t[24]:(He=F.length>1||F.some(zn),t[23]=F,t[24]=He);let Ue=He,V=Be.length>=4,We;if(t[25]!==N||t[26]!==ge){We=new Map;for(let e of N)We.set(e,ge?.get(e)??Pe(e));t[25]=N,t[26]=ge,t[27]=We}else We=t[27];let H=We,Ge;t[28]!==s||t[29]!==l||t[30]!==_e||t[31]!==c?(Ge=e=>_e?.get(e)??{cwd:s,...c===void 0?{}:{worktreePath:c},...l?{runtimeEnv:l}:{}},t[28]=s,t[29]=l,t[30]=_e,t[31]=c,t[32]=Ge):Ge=t[32];let U=Ge,Ke=V?`Split Terminal Horizontally (max 4 per group)`:oe?`Split Terminal Horizontally (${oe})`:`Split Terminal Horizontally`,W=V?`Split Terminal Vertically (max 4 per group)`:se?`Split Terminal Vertically (${se})`:`Split Terminal Vertically`,G=ce?`New Terminal (${ce})`:`New Terminal`,K=le?`Close Terminal (${le})`:`Close Terminal`,qe;t[33]!==T||t[34]!==V||t[35]!==x?(qe=()=>{T&&!V&&x()},t[33]=T,t[34]=V,t[35]=x,t[36]=qe):qe=t[36];let Je=qe,Ye;t[37]!==T||t[38]!==V||t[39]!==S?(Ye=()=>{T&&!V&&S()},t[37]=T,t[38]=V,t[39]=S,t[40]=Ye):Ye=t[40];let Xe=Ye,q;t[41]!==T||t[42]!==ae?(q=()=>{T&&ae()},t[41]=T,t[42]=ae,t[43]=q):q=t[43];let J=q,Y;t[44]!==T||t[45]!==C||t[46]!==H||t[47]!==r.environmentId?(Y=e=>{T&&on([H.get(e)??Pe(e)]).then(t=>{t&&fe(r.environmentId,`terminal:operate`)&&C(e)})},t[44]=T,t[45]=C,t[46]=H,t[47]=r.environmentId,t[48]=Y):Y=t[48];let X=Y,Ze,Qe;t[49]===pe?(Ze=t[50],Qe=t[51]):(Ze=()=>{je.current=pe},Qe=[pe],t[49]=pe,t[50]=Ze,t[51]=Qe),(0,L.useEffect)(Ze,Qe);let $e,et;t[52]===O?($e=t[53],et=t[54]):($e=()=>{let e=M.current;if(e){e.drawer?.style.setProperty(`height`,`${j.current}px`);return}j.current=O},et=[O],t[52]=O,t[53]=$e,t[54]=et),(0,L.useLayoutEffect)($e,et);let tt,nt;t[55]===Te?(tt=t[56],nt=t[57]):(tt=()=>{ke.current=Te},nt=[Te],t[55]=Te,t[56]=tt,t[57]=nt),(0,L.useEffect)(tt,nt);let rt;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(rt=e=>{Ae.current!==e&&(Ae.current=e,je.current(e))},t[58]=rt):rt=t[58];let it=rt,at;t[59]===D?at=t[60]:(at=()=>{Ae.current=D},t[59]=D,t[60]=at);let ot;t[61]!==D||t[62]!==i?(ot=[D,i],t[61]=D,t[62]=i,t[63]=ot):ot=t[63],(0,L.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),Me.current=!1,M.current={pointerId:e.pointerId,startY:e.clientY,startHeight:j.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=M.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault();let n=gn(t.startHeight+(t.startY-e.clientY));n!==j.current&&(Me.current=!0,j.current=n,t.drawer?.style.setProperty(`height`,`${n}px`))},t[65]=ct):ct=t[65];let lt=ct,ut;t[66]===k?ut=t[67]:(ut=e=>{let t=M.current;if(t&&t.pointerId===e.pointerId){if(M.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),!Me.current||j.current===t.startHeight){let e=gn(ke.current);j.current=e,t.drawer?.style.setProperty(`height`,`${e}px`);return}k(j.current),it(j.current),Oe(Rn)}},t[66]=k,t[67]=ut);let Q=ut,dt,ft;t[68]===w?(dt=t[69],ft=t[70]):(dt=()=>{if(!w)return;let e=()=>{let e=M.current,t=gn(j.current);e&&t!==j.current&&(j.current=t,e.drawer?.style.setProperty(`height`,`${t}px`)),xe(hn()),Oe(Ln)};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},ft=[w],t[68]=w,t[69]=dt,t[70]=ft),(0,L.useEffect)(dt,ft);let pt,mt;t[71]===w?(pt=t[72],mt=t[73]):(pt=()=>{w&&(xe(hn()),Oe(In))},mt=[w],t[71]=w,t[72]=pt,t[73]=mt),(0,L.useEffect)(pt,mt);let ht,gt;if(t[74]===Symbol.for(`react.memo_cache_sentinel`)?(ht=()=>()=>{it(ke.current)},gt=[it],t[74]=ht,t[75]=gt):(ht=t[74],gt=t[75]),(0,L.useEffect)(ht,gt),N.length===0){let e=E?`right-panel`:`drawer`,n=E?`h-full flex-1`:`shrink-0 border-t border-border/80`,r;t[76]===n?r=t[77]:(r=te(`relative flex min-w-0 flex-col overflow-hidden bg-background`,n),t[76]=n,t[77]=r);let i;t[78]!==O||t[79]!==E?(i=E?void 0:{height:`${O}px`},t[78]=O,t[79]=E,t[80]=i):i=t[80];let a;t[81]!==Q||t[82]!==E?(a=E?null:(0,R.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]=E,t[83]=a):a=t[83];let o;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,R.jsx)(`p`,{children:`No terminal sessions for this thread yet.`}),t[84]=o):o=t[84];let s=!T,c;t[85]!==G||t[86]!==J||t[87]!==s?(c=(0,R.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,R.jsx)(ee,{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,R.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]!==P?($=U(P),t[95]=U,t[96]=P,t[97]=$):$=t[97];let _t=$,vt=E?`right-panel`:`drawer`,yt=E?`h-full flex-1`:`shrink-0 border-t border-border/80`,bt;t[98]===yt?bt=t[99]:(bt=te(`relative flex min-w-0 flex-col overflow-hidden bg-background`,yt),t[98]=yt,t[99]=bt);let xt;t[100]!==O||t[101]!==E?(xt=E?void 0:{height:`${O}px`},t[100]=O,t[101]=E,t[102]=xt):xt=t[102];let St;t[103]!==Q||t[104]!==E?(St=E?null:(0,R.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]=E,t[105]=St):St=t[105];let Ct;t[106]!==T||t[107]!==K||t[108]!==X||t[109]!==V||t[110]!==B||t[111]!==G||t[112]!==J||t[113]!==Je||t[114]!==Xe||t[115]!==P||t[116]!==Ke||t[117]!==W?(Ct=!B&&(0,R.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-20`,children:(0,R.jsxs)(`div`,{className:`pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs`,children:[(0,R.jsx)(Pn,{disabled:!T,className:`p-1 text-foreground/90 transition-colors ${V?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent`}`,onClick:Je,label:Ke,children:(0,R.jsx)(o,{className:`size-3.25`})}),(0,R.jsx)(`div`,{className:`h-4 w-px bg-border/80`}),(0,R.jsx)(Pn,{disabled:!T,className:`p-1 text-foreground/90 transition-colors ${V?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent`}`,onClick:Xe,label:W,children:(0,R.jsx)(u,{className:`size-3.25`})}),(0,R.jsx)(`div`,{className:`h-4 w-px bg-border/80`}),(0,R.jsx)(Pn,{disabled:!T,className:`p-1 text-foreground/90 transition-colors hover:bg-accent`,onClick:J,label:G,children:(0,R.jsx)(ne,{className:`size-3.25`})}),(0,R.jsx)(`div`,{className:`h-4 w-px bg-border/80`}),(0,R.jsx)(Pn,{disabled:!T,className:`p-1 text-foreground/90 transition-colors hover:bg-accent`,onClick:()=>X(P),label:K,children:(0,R.jsx)(g,{className:`size-3.25`})})]})}),t[106]=T,t[107]=K,t[108]=X,t[109]=V,t[110]=B,t[111]=G,t[112]=J,t[113]=Je,t[114]=Xe,t[115]=P,t[116]=Ke,t[117]=W,t[118]=Ct):Ct=t[118];let wt=B&&`gap-1.5`,Tt;t[119]===wt?Tt=t[120]:(Tt=te(`flex h-full min-h-0 bg-(--terminal-background)`,wt),t[119]=wt,t[120]=Tt);let Et;t[121]!==_t||t[122]!==ye||t[123]!==O||t[124]!==b||t[125]!==Ve||t[126]!==he||t[127]!==ue||t[128]!==me||t[129]!==C||t[130]!==A||t[131]!==U||t[132]!==P||t[133]!==z||t[134]!==H||t[135]!==i||t[136]!==r||t[137]!==w||t[138]!==Be?(Et=(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:Ve?(0,R.jsx)(`div`,{className:`grid h-full w-full min-w-0 gap-0 overflow-hidden`,style:z===`vertical`?{gridTemplateRows:`repeat(${Be.length}, minmax(0, 1fr))`}:{gridTemplateColumns:`repeat(${Be.length}, minmax(0, 1fr))`},children:Be.map(e=>{let t=U(e);return(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 ${z===`vertical`?`border-t first:border-t-0`:`border-l first:border-l-0`} ${e===P?`border-border`:`border-border/70`}`,onPointerDown:()=>{e!==P&&ue(e)},children:(0,R.jsx)(`div`,{className:`h-full`,children:(0,R.jsx)(Nn,{advancedTypography:ye,threadRef:r,threadId:i,terminalId:e,terminalLabel:H.get(e)??`Terminal`,cwd:t.cwd,...t.worktreePath===void 0?{}:{worktreePath:t.worktreePath},...t.runtimeEnv?{runtimeEnv:t.runtimeEnv}:{},onSessionExited:()=>C(e),onAddTerminalContext:me,focusRequestId:b,autoFocus:e===P,visible:w,resizeEpoch:A,drawerHeight:O,keybindings:he})})},e)})}):(0,R.jsx)(`div`,{className:`h-full`,children:(0,R.jsx)(Nn,{advancedTypography:ye,threadRef:r,threadId:i,terminalId:P,terminalLabel:H.get(P)??`Terminal`,cwd:_t.cwd,..._t.worktreePath===void 0?{}:{worktreePath:_t.worktreePath},..._t.runtimeEnv?{runtimeEnv:_t.runtimeEnv}:{},onSessionExited:()=>C(P),onAddTerminalContext:me,focusRequestId:b,autoFocus:!0,visible:w,resizeEpoch:A,drawerHeight:O,keybindings:he},P)})}),t[121]=_t,t[122]=ye,t[123]=O,t[124]=b,t[125]=Ve,t[126]=he,t[127]=ue,t[128]=me,t[129]=C,t[130]=A,t[131]=U,t[132]=P,t[133]=z,t[134]=H,t[135]=i,t[136]=r,t[137]=w,t[138]=Be,t[139]=Et):Et=t[139];let Dt;t[140]!==T||t[141]!==le||t[142]!==K||t[143]!==X||t[144]!==V||t[145]!==B||t[146]!==G||t[147]!==ue||t[148]!==J||t[149]!==Je||t[150]!==Xe||t[151]!==P||t[152]!==F||t[153]!==Ue||t[154]!==Ke||t[155]!==W||t[156]!==H?(Dt=B&&(0,R.jsxs)(`aside`,{className:`flex w-36 min-w-36 flex-col border border-border/70 bg-muted/10`,children:[(0,R.jsx)(`div`,{className:`flex h-[22px] items-stretch justify-end border-b border-border/70`,children:(0,R.jsxs)(`div`,{className:`inline-flex h-full items-stretch`,children:[(0,R.jsx)(Pn,{disabled:!T,className:`inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${V?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent/70`}`,onClick:Je,label:Ke,children:(0,R.jsx)(o,{className:`size-3.25`})}),(0,R.jsx)(Pn,{disabled:!T,className:`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${V?`cursor-not-allowed opacity-64 hover:bg-transparent`:`hover:bg-accent/70`}`,onClick:Xe,label:W,children:(0,R.jsx)(u,{className:`size-3.25`})}),(0,R.jsx)(Pn,{disabled:!T,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,R.jsx)(ne,{className:`size-3.25`})}),(0,R.jsx)(Pn,{disabled:!T,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(P),label:K,children:(0,R.jsx)(g,{className:`size-3.25`})})]})}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 py-1`,children:F.map(e=>{let t=e.terminalIds.includes(P),n=t?P:e.terminalIds[0]??P,r=e.terminalIds.length,i=r>1,s=i?e.splitDirection===`vertical`?`Stacked`:`Side by side`:`Single`,c=i?e.splitDirection===`vertical`?u:o:a;return(0,R.jsxs)(`div`,{className:`pb-0.5`,children:[Ue&&(0,R.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:()=>ue(n),children:[(0,R.jsx)(c,{className:`size-3 shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:s}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70 text-3xs tabular-nums`,children:r})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.terminalIds.map(e=>{let t=e===P,n=H.get(e)??`Terminal`,r=`Close ${n}${t&&le?` (${le})`:``}`;return(0,R.jsxs)(`div`,{className:te(`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:[T?(0,R.jsx)(nn,{label:r,onClick:()=>X(e),tooltip:r,children:(0,R.jsx)(m,{className:`size-3 shrink-0`})}):(0,R.jsx)(m,{className:`size-3 shrink-0`}),(0,R.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 text-left`,onClick:()=>ue(e),children:(0,R.jsx)(`span`,{className:`truncate`,children:n})})]},e)})})]},e.id)})})]}),t[140]=T,t[141]=le,t[142]=K,t[143]=X,t[144]=V,t[145]=B,t[146]=G,t[147]=ue,t[148]=J,t[149]=Je,t[150]=Xe,t[151]=P,t[152]=F,t[153]=Ue,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,R.jsx)(`div`,{className:`min-h-0 w-full flex-1`,children:(0,R.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,R.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,Be as l,Fn as n,on as o,Dn as r,an as s,Nn as t,ze as u};
|
|
5
|
-
//# sourceMappingURL=ThreadTerminalDrawer-
|
|
5
|
+
//# sourceMappingURL=ThreadTerminalDrawer-CJZ5gJIq.js.map
|