@jingyi0605/codingns 0.8.0 → 0.8.5
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/bin/codingns.mjs +180 -0
- package/dist/public/assets/{AdaptiveButlerPage-BsgVNRAa.js → AdaptiveButlerPage-CJw8Ae62.js} +3 -3
- package/dist/public/assets/App-BOHBGFOd.js +30 -0
- package/dist/public/assets/{BootstrapPage--MDOigQi.js → BootstrapPage-BxHQT4nA.js} +1 -1
- package/dist/public/assets/{ConversationPage-BBss5ED8.js → ConversationPage-DWFsF6BB.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-CB8DoqwU.js → DesktopDetachPreviewPage-DOgEjYEf.js} +1 -1
- package/dist/public/assets/DesktopModal-D_A8sgQU.js +1 -0
- package/dist/public/assets/DesktopWindowPage-DK7L7osV.js +2 -0
- package/dist/public/assets/FileContextPanel-BdCoubcJ.js +1 -0
- package/dist/public/assets/GitSidebar-BeZ0hj7A.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DfLMVu8q.js +1 -0
- package/dist/public/assets/MobileSheet-5kZ-w-gU.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-DGVOzXyg.js → MobileTopHeaderFrame-lcp2GscV.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-C6JMiOq_.js +1 -0
- package/dist/public/assets/PluginAccessOverview-DGcKAMQl.js +1 -0
- package/dist/public/assets/PluginContainerPage-BlY-xJDh.js +1 -0
- package/dist/public/assets/PluginDetailPage-CAJ7LFpD.js +1 -0
- package/dist/public/assets/PluginsListPage-BxZG1NyT.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-0MPPjxtQ.js → RelayConnectEntryPage-CfNO_TIl.js} +1 -1
- package/dist/public/assets/ServerSettingsModal-by36Z_5k.js +1 -0
- package/dist/public/assets/SessionIndexPage-DkBp9Mqz.js +1 -0
- package/dist/public/assets/SettingsPage-C-ASmJAG.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-NVZRxxmH.js +1 -0
- package/dist/public/assets/{TerminalPage-B6Rdhylx.js → TerminalPage-C4LNoPBp.js} +3 -3
- package/dist/public/assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js +1 -0
- package/dist/public/assets/ToolFilesPage-47zbdgTW.js +1 -0
- package/dist/public/assets/ToolGitPage-Fuk_b_jg.js +1 -0
- package/dist/public/assets/ToolProcessesPage-sWSMWD-9.js +1 -0
- package/dist/public/assets/ToolsHomePage-R1mZlbZi.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CqmiFH2u.js +1 -0
- package/dist/public/assets/WorkbenchLayout-OFi6CWgH.js +244 -0
- package/dist/public/assets/WorkbenchModal-C7qoQElW.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BAQe_E0O.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-DhKa6e9y.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BPsrFffw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-KAtqZOAb.js +1 -0
- package/dist/public/assets/{client-runtime-manager-DGdKvYzx.js → client-runtime-manager-wmCJZKYd.js} +1 -1
- package/dist/public/assets/file-tree-icon-Mg1DiBRX.js +590 -0
- package/dist/public/assets/{index-CcaQt50x.css → index-C4t-vvqk.css} +1 -1
- package/dist/public/assets/index-CL97fwWB.js +42 -0
- package/dist/public/assets/{login-direct-candidate-resolver-DEP_xCmR.js → login-direct-candidate-resolver-BOAgTuUf.js} +1 -1
- package/dist/public/assets/plugin-permission-copy-Cq99cnzV.js +1 -0
- package/dist/public/assets/plugins-api-BQTV5DOp.js +1 -0
- package/dist/public/assets/{preferences-service-CV6Ih0BG.js → preferences-service-DJxbEEeg.js} +1 -1
- package/dist/public/assets/realtime-client-CLafKzzJ.js +1 -0
- package/dist/public/assets/{relay-entry-C751A-Sm.js → relay-entry-D-LfvdiX.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-CRAVR-8G.js → terminal-runtime-meta-BJmy8dyK.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-DQAWVdCo.js +1 -0
- package/dist/public/assets/workbench-navigation-MEzCSmsK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +4 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -1
- package/dist/server/main.js +2 -0
- package/dist/server/main.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/browser-runtime/browser-runtime-controller.d.ts +2 -1
- package/dist/server/modules/browser-runtime/browser-runtime-controller.js +1 -0
- package/dist/server/modules/browser-runtime/browser-runtime-controller.js.map +1 -1
- package/dist/server/modules/browser-runtime/browser-runtime-service.d.ts +4 -1
- package/dist/server/modules/browser-runtime/browser-runtime-service.js +40 -0
- package/dist/server/modules/browser-runtime/browser-runtime-service.js.map +1 -1
- package/dist/server/modules/browser-runtime/browser-task-payload.d.ts +2 -0
- package/dist/server/modules/browser-runtime/browser-task-payload.js.map +1 -1
- package/dist/server/modules/file/file-access-guard.d.ts +2 -0
- package/dist/server/modules/file/file-access-guard.js +24 -2
- package/dist/server/modules/file/file-access-guard.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +153 -1
- package/dist/server/modules/file/file-controller.js +215 -1
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +2 -0
- package/dist/server/modules/file/file-preview-link-service.js +5 -1
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +911 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +126 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +471 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +42 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +304 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -0
- package/dist/server/modules/git/git-command-helper-process.js +0 -18
- package/dist/server/modules/git/git-command-helper-process.js.map +1 -1
- package/dist/server/modules/git/git-command-runner.js +0 -18
- package/dist/server/modules/git/git-command-runner.js.map +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/plugins/plugin-controller.d.ts +131 -0
- package/dist/server/modules/plugins/plugin-controller.js +277 -0
- package/dist/server/modules/plugins/plugin-controller.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +38 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +178 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-manifest.d.ts +8 -0
- package/dist/server/modules/plugins/plugin-manifest.js +420 -0
- package/dist/server/modules/plugins/plugin-manifest.js.map +1 -0
- package/dist/server/modules/plugins/plugin-permission-service.d.ts +49 -0
- package/dist/server/modules/plugins/plugin-permission-service.js +267 -0
- package/dist/server/modules/plugins/plugin-permission-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-process-runner.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-process-runner.js +127 -0
- package/dist/server/modules/plugins/plugin-process-runner.js.map +1 -0
- package/dist/server/modules/plugins/plugin-registry-service.d.ts +41 -0
- package/dist/server/modules/plugins/plugin-registry-service.js +238 -0
- package/dist/server/modules/plugins/plugin-registry-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-service.d.ts +55 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js +252 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js +83 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.d.ts +31 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js +232 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-static-service.d.ts +11 -0
- package/dist/server/modules/plugins/plugin-static-service.js +145 -0
- package/dist/server/modules/plugins/plugin-static-service.js.map +1 -0
- package/dist/server/modules/presentation/presentation-controller.d.ts +3 -0
- package/dist/server/modules/presentation/presentation-controller.js +11 -0
- package/dist/server/modules/presentation/presentation-controller.js.map +1 -1
- package/dist/server/modules/presentation/presentation-export-task-service.d.ts +6 -0
- package/dist/server/modules/presentation/presentation-export-task-service.js +52 -8
- package/dist/server/modules/presentation/presentation-export-task-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-pptx-export-service.js +200 -14
- package/dist/server/modules/presentation/presentation-pptx-export-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-renderer.d.ts +50 -0
- package/dist/server/modules/presentation/presentation-renderer.js +450 -37
- package/dist/server/modules/presentation/presentation-renderer.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.js +46 -3
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.d.ts +1 -0
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +11 -2
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skills/codingns-workspace-session/SKILL.md +2 -2
- package/dist/server/modules/tasks/task-types.d.ts +2 -0
- package/dist/server/modules/tasks/task-types.js +2 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/routes/files.js +40 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/plugins-public.d.ts +3 -0
- package/dist/server/routes/plugins-public.js +5 -0
- package/dist/server/routes/plugins-public.js.map +1 -0
- package/dist/server/routes/plugins.d.ts +3 -0
- package/dist/server/routes/plugins.js +19 -0
- package/dist/server/routes/plugins.js.map +1 -0
- package/dist/server/routes/presentation.js +1 -0
- package/dist/server/routes/presentation.js.map +1 -1
- package/dist/server/server/create-server.d.ts +20 -0
- package/dist/server/server/create-server.js +47 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +63 -25
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/shared/runtime/better-sqlite3.d.ts +5 -0
- package/dist/server/shared/runtime/better-sqlite3.js +6 -0
- package/dist/server/shared/runtime/better-sqlite3.js.map +1 -0
- package/dist/server/shared/utils/install-console-timestamp-prefix.d.ts +1 -0
- package/dist/server/shared/utils/install-console-timestamp-prefix.js +28 -0
- package/dist/server/shared/utils/install-console-timestamp-prefix.js.map +1 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.d.ts +8 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js +49 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-definition-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js +84 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.d.ts +9 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js +74 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.d.ts +12 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js +142 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-run-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-run-repository.js +111 -0
- package/dist/server/storage/repositories/plugin-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js +86 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.d.ts +2 -2
- package/dist/server/storage/sqlite/client.js +250 -1
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +140 -0
- package/dist/server/types/domain.d.ts +122 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +42 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +346 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js +80 -0
- package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/index.d.ts +18 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js +19 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.d.ts +18 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js +659 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-shared.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js +72 -0
- package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +67 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +752 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +48 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +1184 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +84 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +2436 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.d.ts +47 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +1480 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.d.ts +33 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js +684 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js +8 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +48 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +373 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +61 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +1191 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.d.ts +27 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js +415 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.d.ts +7 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.js +22 -0
- package/node_modules/@codingns/session-sync-core/dist/registry.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +24 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +329 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +30 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +939 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +70 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +2571 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.d.ts +21 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +561 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.d.ts +38 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js +911 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +15 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +38 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +970 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +21 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +168 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +152 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/services.d.ts +28 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js +148 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.d.ts +6 -0
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js +9 -0
- package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +198 -0
- package/node_modules/@codingns/session-sync-core/dist/types.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/package.json +33 -0
- package/package.json +15 -6
- package/scripts/postinstall.mjs +248 -11
- package/vendor/better-sqlite3-win32-x64-node22/LICENSE +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.upstream.md +99 -0
- package/vendor/better-sqlite3-win32-x64-node22/binding.gyp +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/build/Release/better_sqlite3.node +0 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/common.gypi +68 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/copy.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/defines.gypi +41 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/download.sh +122 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/patches/1208.patch +15 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.c +265994 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.h +13968 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3ext.h +730 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3.gyp +80 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/test_extension.c +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/database.js +90 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/index.js +3 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/aggregate.js +43 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/backup.js +67 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/function.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/inspect.js +7 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/pragma.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/serialize.js +16 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/table.js +189 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/transaction.js +78 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/wrappers.js +54 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/sqlite-error.js +20 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/util.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/package.json +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/scripts/verify-runtime.cjs +42 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/addon.cpp +47 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/better_sqlite3.cpp +74 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.cpp +120 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.hpp +36 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.cpp +417 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.hpp +103 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.cpp +113 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.hpp +50 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.cpp +383 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.hpp +58 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/bind-map.cpp +73 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/binder.cpp +193 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/constants.cpp +172 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-aggregate.cpp +121 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-function.cpp +59 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-table.cpp +409 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data-converter.cpp +17 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data.cpp +194 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/helpers.cpp +109 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/macros.cpp +83 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/query-macros.cpp +71 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/row-builder.cpp +49 -0
- package/vendor/node-pty-fork/LICENSE +69 -0
- package/vendor/node-pty-fork/README.md +92 -0
- package/vendor/node-pty-fork/binding.gyp +117 -0
- package/vendor/node-pty-fork/deps/.editorconfig +2 -0
- package/vendor/node-pty-fork/deps/winpty/.drone.yml +17 -0
- package/vendor/node-pty-fork/deps/winpty/.gitattributes +19 -0
- package/vendor/node-pty-fork/deps/winpty/LICENSE +21 -0
- package/vendor/node-pty-fork/deps/winpty/Makefile +166 -0
- package/vendor/node-pty-fork/deps/winpty/README.md +151 -0
- package/vendor/node-pty-fork/deps/winpty/RELEASES.md +280 -0
- package/vendor/node-pty-fork/deps/winpty/VERSION.txt +1 -0
- package/vendor/node-pty-fork/deps/winpty/configure +167 -0
- package/vendor/node-pty-fork/deps/winpty/misc/BufferResizeTests.cc +90 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ChangeScreenBuffer.cc +53 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ClearConsole.cc +72 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.cc +117 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.ps1 +116 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ConoutMode.cc +113 -0
- package/vendor/node-pty-fork/deps/winpty/misc/DebugClient.py +42 -0
- package/vendor/node-pty-fork/deps/winpty/misc/DebugServer.py +63 -0
- package/vendor/node-pty-fork/deps/winpty/misc/DumpLines.py +5 -0
- package/vendor/node-pty-fork/deps/winpty/misc/EnableExtendedFlags.txt +46 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +528 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +633 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP932.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP936.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP949.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP950.txt +630 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +16 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Results.txt +4 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +144 -0
- package/vendor/node-pty-fork/deps/winpty/misc/FontSurvey.cc +100 -0
- package/vendor/node-pty-fork/deps/winpty/misc/FormatChar.h +21 -0
- package/vendor/node-pty-fork/deps/winpty/misc/FreezePerfTest.cc +62 -0
- package/vendor/node-pty-fork/deps/winpty/misc/GetCh.cc +20 -0
- package/vendor/node-pty-fork/deps/winpty/misc/GetConsolePos.cc +41 -0
- package/vendor/node-pty-fork/deps/winpty/misc/GetFont.cc +261 -0
- package/vendor/node-pty-fork/deps/winpty/misc/IdentifyConsoleWindow.ps1 +51 -0
- package/vendor/node-pty-fork/deps/winpty/misc/IsNewConsole.cc +87 -0
- package/vendor/node-pty-fork/deps/winpty/misc/MouseInputNotes.txt +90 -0
- package/vendor/node-pty-fork/deps/winpty/misc/MoveConsoleWindow.cc +34 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Notes.txt +219 -0
- package/vendor/node-pty-fork/deps/winpty/misc/OSVersion.cc +27 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferFreezeInactive.cc +101 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest.cc +671 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest2.cc +151 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SelectAllTest.cc +45 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetBufferSize.cc +32 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetCursorPos.cc +10 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetFont.cc +145 -0
- package/vendor/node-pty-fork/deps/winpty/misc/SetWindowRect.cc +36 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ShowArgv.cc +12 -0
- package/vendor/node-pty-fork/deps/winpty/misc/ShowConsoleInput.cc +40 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Spew.py +5 -0
- package/vendor/node-pty-fork/deps/winpty/misc/TestUtil.cc +172 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnicodeDoubleWidthTest.cc +102 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest1.cc +246 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest2.cc +130 -0
- package/vendor/node-pty-fork/deps/winpty/misc/UnixEcho.cc +89 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Utf16Echo.cc +46 -0
- package/vendor/node-pty-fork/deps/winpty/misc/VeryLargeRead.cc +122 -0
- package/vendor/node-pty-fork/deps/winpty/misc/VkEscapeTest.cc +56 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win10ResizeWhileFrozen.cc +52 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest1.cc +57 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest2.cc +30 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo1.cc +26 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo2.cc +19 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Test1.cc +46 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Test2.cc +70 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Test3.cc +78 -0
- package/vendor/node-pty-fork/deps/winpty/misc/Win32Write1.cc +44 -0
- package/vendor/node-pty-fork/deps/winpty/misc/WindowsBugCrashReader.cc +27 -0
- package/vendor/node-pty-fork/deps/winpty/misc/WriteConsole.cc +106 -0
- package/vendor/node-pty-fork/deps/winpty/misc/build32.sh +9 -0
- package/vendor/node-pty-fork/deps/winpty/misc/build64.sh +9 -0
- package/vendor/node-pty-fork/deps/winpty/misc/color-test.sh +212 -0
- package/vendor/node-pty-fork/deps/winpty/misc/font-notes.txt +300 -0
- package/vendor/node-pty-fork/deps/winpty/misc/winbug-15048.cc +201 -0
- package/vendor/node-pty-fork/deps/winpty/ship/build-pty4j-libpty.bat +36 -0
- package/vendor/node-pty-fork/deps/winpty/ship/common_ship.py +53 -0
- package/vendor/node-pty-fork/deps/winpty/ship/make_msvc_package.py +165 -0
- package/vendor/node-pty-fork/deps/winpty/ship/ship.py +108 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.cc +605 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.h +103 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.cc +84 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.cc +632 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.cc +852 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.h +109 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.cc +121 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.h +36 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.cc +152 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.h +41 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Coord.h +87 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.cc +239 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.h +32 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.cc +422 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/DsrSender.h +30 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.cc +99 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.h +47 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.cc +246 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.h +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.cc +71 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.h +68 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.cc +378 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.h +125 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.cc +699 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.h +103 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/SimplePool.h +75 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/SmallRect.h +143 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.cc +535 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.h +69 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncoding.h +157 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncodingTest.cc +189 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.cc +107 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.h +67 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.cc +193 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.h +99 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/main.cc +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/agent/subdir.mk +61 -0
- package/vendor/node-pty-fork/deps/winpty/src/configurations.gypi +60 -0
- package/vendor/node-pty-fork/deps/winpty/src/debugserver/DebugServer.cc +117 -0
- package/vendor/node-pty-fork/deps/winpty/src/debugserver/subdir.mk +41 -0
- package/vendor/node-pty-fork/deps/winpty/src/include/winpty.h +242 -0
- package/vendor/node-pty-fork/deps/winpty/src/include/winpty_constants.h +131 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.cc +75 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.h +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/LibWinptyException.h +54 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/WinptyInternal.h +72 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/subdir.mk +46 -0
- package/vendor/node-pty-fork/deps/winpty/src/libwinpty/winpty.cc +970 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/AgentMsg.h +38 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.cc +122 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.h +73 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.cc +103 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.h +102 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.cc +187 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.h +38 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.cc +138 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.h +55 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/GetCommitHash.bat +13 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/Mutex.h +54 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/OsModule.h +63 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.cc +36 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.h +45 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/PrecompiledHeader.h +43 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilder.h +227 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilderTest.cc +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.cc +55 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.h +80 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/TimeMeasurement.h +63 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/UnixCtrlChars.h +45 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/UpdateGenVersion.bat +20 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.cc +460 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.h +104 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.cc +252 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.h +29 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.cc +55 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.h +64 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.cc +57 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.h +43 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.cc +42 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.h +27 -0
- package/vendor/node-pty-fork/deps/winpty/src/shared/winpty_snprintf.h +99 -0
- package/vendor/node-pty-fork/deps/winpty/src/subdir.mk +5 -0
- package/vendor/node-pty-fork/deps/winpty/src/tests/subdir.mk +28 -0
- package/vendor/node-pty-fork/deps/winpty/src/tests/trivial_test.cc +158 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.cc +114 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.h +56 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.cc +80 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.h +53 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.cc +86 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.h +31 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.cc +70 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.h +42 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/main.cc +729 -0
- package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/subdir.mk +41 -0
- package/vendor/node-pty-fork/deps/winpty/src/winpty.gyp +206 -0
- package/vendor/node-pty-fork/deps/winpty/vcbuild.bat +83 -0
- package/vendor/node-pty-fork/lib/conpty_console_list_agent.js +20 -0
- package/vendor/node-pty-fork/lib/conpty_console_list_agent.js.map +1 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.js +47 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.js.map +1 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.test.js +30 -0
- package/vendor/node-pty-fork/lib/eventEmitter2.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/index.js +51 -0
- package/vendor/node-pty-fork/lib/index.js.map +1 -0
- package/vendor/node-pty-fork/lib/interfaces.js +7 -0
- package/vendor/node-pty-fork/lib/interfaces.js.map +1 -0
- package/vendor/node-pty-fork/lib/shared/conout.js +11 -0
- package/vendor/node-pty-fork/lib/shared/conout.js.map +1 -0
- package/vendor/node-pty-fork/lib/terminal.js +190 -0
- package/vendor/node-pty-fork/lib/terminal.js.map +1 -0
- package/vendor/node-pty-fork/lib/terminal.test.js +139 -0
- package/vendor/node-pty-fork/lib/terminal.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/testUtils.test.js +28 -0
- package/vendor/node-pty-fork/lib/testUtils.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/types.js +7 -0
- package/vendor/node-pty-fork/lib/types.js.map +1 -0
- package/vendor/node-pty-fork/lib/unixTerminal.js +304 -0
- package/vendor/node-pty-fork/lib/unixTerminal.js.map +1 -0
- package/vendor/node-pty-fork/lib/unixTerminal.test.js +330 -0
- package/vendor/node-pty-fork/lib/unixTerminal.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/utils.js +17 -0
- package/vendor/node-pty-fork/lib/utils.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsConoutConnection.js +122 -0
- package/vendor/node-pty-fork/lib/windowsConoutConnection.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.js +324 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js +90 -0
- package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.js +201 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.js.map +1 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.test.js +203 -0
- package/vendor/node-pty-fork/lib/windowsTerminal.test.js.map +1 -0
- package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js +22 -0
- package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js.map +1 -0
- package/vendor/node-pty-fork/package.json +35 -0
- package/vendor/node-pty-fork/scripts/apply-patches.mjs +341 -0
- package/vendor/node-pty-fork/scripts/fetch-upstream.mjs +41 -0
- package/vendor/node-pty-fork/scripts/install-smoke.cjs +59 -0
- package/vendor/node-pty-fork/scripts/runtime-install-context.cjs +24 -0
- package/vendor/node-pty-fork/scripts/smoke-load.cjs +10 -0
- package/vendor/node-pty-fork/scripts/sync-upstream.mjs +29 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.cjs +62 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +52 -0
- package/vendor/node-pty-fork/scripts/verify-tarball.cjs +80 -0
- package/vendor/node-pty-fork/src/conpty_console_list_agent.ts +19 -0
- package/vendor/node-pty-fork/src/eventEmitter2.test.ts +30 -0
- package/vendor/node-pty-fork/src/eventEmitter2.ts +48 -0
- package/vendor/node-pty-fork/src/index.ts +51 -0
- package/vendor/node-pty-fork/src/interfaces.ts +129 -0
- package/vendor/node-pty-fork/src/native.d.ts +56 -0
- package/vendor/node-pty-fork/src/shared/conout.ts +15 -0
- package/vendor/node-pty-fork/src/terminal.test.ts +119 -0
- package/vendor/node-pty-fork/src/terminal.ts +211 -0
- package/vendor/node-pty-fork/src/testUtils.test.ts +23 -0
- package/vendor/node-pty-fork/src/tsconfig.json +22 -0
- package/vendor/node-pty-fork/src/types.ts +15 -0
- package/vendor/node-pty-fork/src/unix/pty.cc +826 -0
- package/vendor/node-pty-fork/src/unix/spawn-helper.cc +23 -0
- package/vendor/node-pty-fork/src/unixTerminal.test.ts +335 -0
- package/vendor/node-pty-fork/src/unixTerminal.ts +320 -0
- package/vendor/node-pty-fork/src/utils.ts +9 -0
- package/vendor/node-pty-fork/src/win/conpty.cc +500 -0
- package/vendor/node-pty-fork/src/win/conpty_console_list.cc +43 -0
- package/vendor/node-pty-fork/src/win/path_util.cc +73 -0
- package/vendor/node-pty-fork/src/win/path_util.h +22 -0
- package/vendor/node-pty-fork/src/win/winpty.cc +322 -0
- package/vendor/node-pty-fork/src/windowsConoutConnection.ts +79 -0
- package/vendor/node-pty-fork/src/windowsPtyAgent.test.ts +94 -0
- package/vendor/node-pty-fork/src/windowsPtyAgent.ts +323 -0
- package/vendor/node-pty-fork/src/windowsTerminal.test.ts +214 -0
- package/vendor/node-pty-fork/src/windowsTerminal.ts +208 -0
- package/vendor/node-pty-fork/src/worker/conoutSocketWorker.ts +22 -0
- package/vendor/node-pty-fork/typings/node-pty.d.ts +203 -0
- package/vendor-src/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/dist/public/assets/App-tPcbyRdS.js +0 -30
- package/dist/public/assets/DesktopWindowPage-GtIx5m8K.js +0 -2
- package/dist/public/assets/FileContextPanel-BcM7AIT4.js +0 -1
- package/dist/public/assets/GitSidebar-CMtkaxuI.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-CrFY41_8.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DLkACTnQ.js +0 -1
- package/dist/public/assets/ServerSettingsModal-vgOhwus4.js +0 -1
- package/dist/public/assets/SessionIndexPage-KK626Ra9.js +0 -1
- package/dist/public/assets/SettingsPage-B3edBJIo.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-BxlhZp8c.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-BVLfrpSa.js +0 -1
- package/dist/public/assets/ToolFilesPage-N_gwwUjD.js +0 -1
- package/dist/public/assets/ToolGitPage-DOcuuWM1.js +0 -1
- package/dist/public/assets/ToolProcessesPage-D-FfJ7Re.js +0 -1
- package/dist/public/assets/ToolsHomePage-CHfPxd20.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CTTnfovY.js +0 -1
- package/dist/public/assets/WorkbenchLayout-CbpJg0g1.js +0 -244
- package/dist/public/assets/WorkbenchModal-Bt_1fYmM.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-DyaMnPfS.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-s7yuDIxR.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-Cf-gVpqK.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-COf6I8sT.js +0 -1
- package/dist/public/assets/file-tree-icon-BeHqeru9.js +0 -590
- package/dist/public/assets/index-CuzMc7q2.js +0 -42
- package/dist/public/assets/model-switch-api-c6kcbBGm.js +0 -1
- package/dist/public/assets/realtime-client-CRCx5xBt.js +0 -1
- package/dist/public/assets/useRegisteredDebugTemplates-D6YtNS0r.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var zl=Object.defineProperty;var Wl=(e,t,i)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var st=(e,t,i)=>Wl(e,typeof t!="symbol"?t+"":t,i);import{m as jn,F as $l,b,t as w,G as jl,j as m}from"./index-
|
|
1
|
+
var zl=Object.defineProperty;var Wl=(e,t,i)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var st=(e,t,i)=>Wl(e,typeof t!="symbol"?t+"":t,i);import{m as jn,F as $l,b,t as w,G as jl,j as m}from"./index-CL97fwWB.js";import{M as ma}from"./MobileSheet-5kZ-w-gU.js";import{aX as Ul,r as Kl,A as ql,b as Vl,aY as Yl,w as Xl,c as Gl,aO as Zl}from"./WorkbenchLayout-OFi6CWgH.js";import{e as pa,u as Jl,c as Ql,f as eh}from"./App-BOHBGFOd.js";import{M as th}from"./MobileWorkspaceSwitcherHeader-C6JMiOq_.js";import{b as ga,c as ih,d as Un,e as pr,g as Kn,f as sh,h as rh,i as nh,j as oh}from"./terminal-runtime-meta-BJmy8dyK.js";import{T as ah,i as lh}from"./TerminalRuntimeFallbackModal-Bzum5nZ0.js";import"./workbench-navigation-MEzCSmsK.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-D_A8sgQU.js";import"./WorkbenchModal-C7qoQElW.js";import"./relay-entry-D-LfvdiX.js";import"./MobileTopHeaderFrame-lcp2GscV.js";/**
|
|
2
2
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*
|
|
@@ -47,9 +47,9 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
|
|
|
47
47
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),dn&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=go(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=un(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-rr),rr),t/=rr,t/Math.abs(t)+Math.round(t*(Eu-1)))}shouldForceSelection(e){return Rs?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Tu)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Rs&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Ru&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=vu(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,u=0,d=0,_=0,p=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let E=e[0],D=e[0];n.getWidth(E)===0&&(u++,E--),n.getWidth(D)===2&&(d++,D++);let U=n.getString(D).length;for(U>1&&(p+=U-1,h+=U-1);E>0&&a>0&&!this._isCharWordSeparator(n.loadCell(E-1,this._workCell));){n.loadCell(E-1,this._workCell);let W=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,E--):W>1&&(_+=W-1,a-=W-1),a--,E--}for(;D<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(D+1,this._workCell));){n.loadCell(D+1,this._workCell);let W=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,D++):W>1&&(p+=W-1,h+=W-1),h++,D++}}h++;let f=a+l-u+_,g=Math.min(this._bufferService.cols,h-a+u+d-_-p);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&f===0&&n.getCodePoint(0)!==32){let E=r.lines.get(e[1]-1);if(E&&n.isWrapped&&E.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let U=this._bufferService.cols-D.start;f-=U,g+=U}}}if(s&&f+g===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let E=r.lines.get(e[1]+1);if(E!=null&&E.isWrapped&&E.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(g+=D.length)}}return{start:f,length:g}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=go(i,this._bufferService.cols)}};Ur=Ee([z(3,tt),z(4,ci),z(5,rn),z(6,it),z(7,$t),z(8,Wt)],Ur);var vo=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},So=class{constructor(){this._color=new vo,this._css=new vo}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Pe=Object.freeze((()=>{let e=[we.toColor("#2e3436"),we.toColor("#cc0000"),we.toColor("#4e9a06"),we.toColor("#c4a000"),we.toColor("#3465a4"),we.toColor("#75507b"),we.toColor("#06989a"),we.toColor("#d3d7cf"),we.toColor("#555753"),we.toColor("#ef2929"),we.toColor("#8ae234"),we.toColor("#fce94f"),we.toColor("#729fcf"),we.toColor("#ad7fa8"),we.toColor("#34e2e2"),we.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:Le.toCss(s,r,n),rgba:Le.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Le.toCss(s,s,s),rgba:Le.toRgba(s,s,s)})}return e})()),si=we.toColor("#ffffff"),Fi=we.toColor("#000000"),bo=we.toColor("#ffffff"),wo=Fi,Li={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Du=si,Kr=class extends ie{constructor(e){super(),this._optionsService=e,this._contrastCache=new So,this._halfContrastCache=new So,this._onChangeColors=this._register(new A),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:si,background:Fi,cursor:bo,cursorAccent:wo,selectionForeground:void 0,selectionBackgroundTransparent:Li,selectionBackgroundOpaque:_e.blend(Fi,Li),selectionInactiveBackgroundTransparent:Li,selectionInactiveBackgroundOpaque:_e.blend(Fi,Li),scrollbarSliderBackground:_e.opacity(si,.2),scrollbarSliderHoverBackground:_e.opacity(si,.4),scrollbarSliderActiveBackground:_e.opacity(si,.5),overviewRulerBorder:si,ansi:Pe.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=he(e.foreground,si),t.background=he(e.background,Fi),t.cursor=_e.blend(t.background,he(e.cursor,bo)),t.cursorAccent=_e.blend(t.background,he(e.cursorAccent,wo)),t.selectionBackgroundTransparent=he(e.selectionBackground,Li),t.selectionBackgroundOpaque=_e.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=he(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=_e.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?he(e.selectionForeground,_o):void 0,t.selectionForeground===_o&&(t.selectionForeground=void 0),_e.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=_e.opacity(t.selectionBackgroundTransparent,.3)),_e.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=_e.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=he(e.scrollbarSliderBackground,_e.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=he(e.scrollbarSliderHoverBackground,_e.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=he(e.scrollbarSliderActiveBackground,_e.opacity(t.foreground,.5)),t.overviewRulerBorder=he(e.overviewRulerBorder,Du),t.ansi=Pe.slice(),t.ansi[0]=he(e.black,Pe[0]),t.ansi[1]=he(e.red,Pe[1]),t.ansi[2]=he(e.green,Pe[2]),t.ansi[3]=he(e.yellow,Pe[3]),t.ansi[4]=he(e.blue,Pe[4]),t.ansi[5]=he(e.magenta,Pe[5]),t.ansi[6]=he(e.cyan,Pe[6]),t.ansi[7]=he(e.white,Pe[7]),t.ansi[8]=he(e.brightBlack,Pe[8]),t.ansi[9]=he(e.brightRed,Pe[9]),t.ansi[10]=he(e.brightGreen,Pe[10]),t.ansi[11]=he(e.brightYellow,Pe[11]),t.ansi[12]=he(e.brightBlue,Pe[12]),t.ansi[13]=he(e.brightMagenta,Pe[13]),t.ansi[14]=he(e.brightCyan,Pe[14]),t.ansi[15]=he(e.brightWhite,Pe[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=he(e.extendedAnsi[s],Pe[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Kr=Ee([z(0,it)],Kr);function he(e,t){if(e!==void 0)try{return we.toColor(e)}catch{}return t}var Lu=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Pu=class{constructor(){this._services=new Lu,this._services.set(sn,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=Eh(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Au={trace:0,debug:1,info:2,warn:3,error:4,off:5},Iu="xterm.js: ",qr=class extends ie{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Au[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Iu)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};qr=Ee([z(0,it)],qr);var yo=class extends ie{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new A),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new A),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new A),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},te=3,De=Object.freeze(new Xi),ls=0,nr=2,Hi=class nl{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*te);let r=i||gt.fromCharData([0,xa,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*te+0],s=i&2097151;return[this._data[t*te+1],i&2097152?this._combined[t]:s?Gt(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*te+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*te+0]=t|2097152|i[2]<<22):this._data[t*te+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*te+0]>>22}hasWidth(t){return this._data[t*te+0]&12582912}getFg(t){return this._data[t*te+1]}getBg(t){return this._data[t*te+2]}hasContent(t){return this._data[t*te+0]&4194303}getCodePoint(t){let i=this._data[t*te+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*te+0]&2097152}getString(t){let i=this._data[t*te+0];return i&2097152?this._combined[t]:i&2097151?Gt(i&2097151):""}isProtected(t){return this._data[t*te+2]&536870912}loadCell(t,i){return ls=t*te,i.content=this._data[ls+0],i.fg=this._data[ls+1],i.bg=this._data[ls+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*te+0]=i.content,this._data[t*te+1]=i.fg,this._data[t*te+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*te+0]=i|s<<22,this._data[t*te+1]=r.fg,this._data[t*te+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*te+0];r&2097152?this._combined[t]+=Gt(i):r&2097151?(this._combined[t]=Gt(r&2097151)+Gt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*te+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new gt;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new gt;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*nr<this._data.buffer.byteLength;let s=t*te;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*nr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*nr<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new nl(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*te+0]&4194303)return t+(this._data[t*te+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*te+0]&4194303||this._data[t*te+2]&50331648)return t+(this._data[t*te+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<te;l++)this._data[(s+h)*te+l]=o[(i+h)*te+l];o[(i+h)*te+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<te;l++)this._data[(s+h)*te+l]=o[(i+h)*te+l];o[(i+h)*te+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*te+0],a=o&2097151,h=o&2097152?this._combined[i]:a?Gt(a):Zt;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function Nu(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let u=[e.get(a)];for(;h<e.length&&l.isWrapped;)u.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=u.length-1;continue}let d=0,_=qi(u,d,t),p=1,f=0;for(;p<u.length;){let E=qi(u,p,t),D=E-f,U=i-_,W=Math.min(D,U);u[d].copyCellsFrom(u[p],f,_,W,!1),_+=W,_===i&&(d++,_=0),f+=W,f===E&&(p++,f=0),_===0&&d!==0&&u[d-1].getWidth(i-1)===2&&(u[d].copyCellsFrom(u[d-1],i-1,_++,1,!1),u[d-1].setCell(i-1,r))}u[d].replaceCells(_,i,r);let g=0;for(let E=u.length-1;E>0&&(E>d||u[E].getTrimmedLength()===0);E--)g++;g>0&&(o.push(a+u.length-g),o.push(g)),a+=u.length-1}return o}function Ou(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Fu(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Hu(e,t,i){let s=[],r=e.map((h,l)=>qi(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=qi(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let u=l?i-1:i;s.push(u),a+=u}return s}function qi(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var ol=class al{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=al._nextId++,this._onDispose=this.register(new A),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),li(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ol._nextId=1;var zu=ol,Ie={},ri=Ie.B;Ie[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ie.A={"#":"£"};Ie.B=void 0;Ie[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ie.C=Ie[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ie.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ie.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ie.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ie.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ie.E=Ie[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ie.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ie.H=Ie[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ie["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Co=4294967295,xo=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=De.clone(),this.savedCharset=ri,this.markers=[],this._nullCell=gt.fromCharData([0,xa,1,0]),this._whitespaceCell=gt.fromCharData([0,Zt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Bs,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new yo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ks),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ks),this._whitespaceCell}getBlankLine(e,t){return new Hi(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Co?Co:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=De);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new yo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(De),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Hi(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Hi(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=Nu(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(De),i);if(s.length>0){let r=Ou(this.lines,s);Fu(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(De),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Hi(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(De),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let W=this.ybase+this.y;if(W>=o&&W<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=Hu(h,this._cols,e),d=u.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+d):_=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let W=0;W<d;W++){let H=this.getBlankLine(De,!0);p.push(H)}p.length>0&&(r.push({start:o+h.length+n,newLines:p}),n+=p.length),h.push(...p);let f=u.length-1,g=u[f];g===0&&(f--,g=u[f]);let E=h.length-d-1,D=l;for(;E>=0;){let W=Math.min(D,g);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[E],D-W,g-W,W,!0),g-=W,g===0&&(f--,g=u[f]),D-=W,D===0){E--;let H=Math.max(E,0);D=qi(h,H,this._cols)}}for(let W=0;W<h.length;W++)u[W]<e&&h[W].setCell(u[W],s);let U=d-_;for(;U-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let h=this.lines.length,l=h-1,u=0,d=r[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let _=0;for(let g=Math.min(this.lines.maxLength-1,h+n-1);g>=0;g--)if(d&&d.start>l+_){for(let E=d.newLines.length-1;E>=0;E--)this.lines.set(g--,d.newLines[E]);g++,o.push({index:l+1,amount:d.newLines.length}),_+=d.newLines.length,d=r[++u]}else this.lines.set(g,a[l--]);let p=0;for(let g=o.length-1;g>=0;g--)o[g].index+=p,this.lines.onInsertEmitter.fire(o[g]),p+=o[g].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new zu(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Wu=class extends ie{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new A),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new xo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new xo(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},ll=2,hl=1,Vr=class extends ie{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new A),this.onResize=this._onResize.event,this._onScroll=this._register(new A),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ll),this.rows=Math.max(e.rawOptions.rows||0,hl),this.buffers=this._register(new Wu(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Vr=Ee([z(0,it)],Vr);var Si={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Rs,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},$u=["normal","bold","100","200","300","400","500","600","700","800","900"],ju=class extends ie{constructor(e){super(),this._onOptionChange=this._register(new A),this.onOptionChange=this._onOptionChange.event;let t={...Si};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(pe(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Si))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Si))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Si[e]),!Uu(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Si[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=$u.includes(t)?t:Si[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Uu(e){return e==="block"||e==="underline"||e==="bar"}function zi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&zi(e[s],t-1);return i}var ko=Object.freeze({insertMode:!1}),Eo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Yr=class extends ie{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new A),this.onData=this._onData.event,this._onUserInput=this._register(new A),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new A),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new A),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=zi(ko),this.decPrivateModes=zi(Eo)}reset(){this.modes=zi(ko),this.decPrivateModes=zi(Eo)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Yr=Ee([z(0,tt),z(1,Ba),z(2,it)],Yr);var To={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function or(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var ar=String.fromCharCode,Ro={DEFAULT:e=>{let t=[or(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ar(t[0])}${ar(t[1])}${ar(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${or(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${or(e,!0)};${e.x};${e.y}${t}`}},Xr=class extends ie{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new A),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(To))this.addProtocol(s,To[s]);for(let s of Object.keys(Ro))this.addEncoding(s,Ro[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Xr=Ee([z(0,tt),z(1,ci),z(2,it)],Xr);var lr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Ku=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ae;function qu(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Vu=class{constructor(){if(this.version="6",!Ae){Ae=new Uint8Array(65536),Ae.fill(1),Ae[0]=0,Ae.fill(0,1,32),Ae.fill(0,127,160),Ae.fill(2,4352,4448),Ae[9001]=2,Ae[9002]=2,Ae.fill(2,11904,42192),Ae[12351]=1,Ae.fill(2,44032,55204),Ae.fill(2,63744,64256),Ae.fill(2,65040,65050),Ae.fill(2,65072,65136),Ae.fill(2,65280,65377),Ae.fill(2,65504,65511);for(let e=0;e<lr.length;++e)Ae.fill(0,lr[e][0],lr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ae[e]:qu(e,Ku)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=ni.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return ni.createPropertyValue(0,i,s)}},ni=class xs{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new A,this.onChange=this._onChange.event;let t=new Vu;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=xs.extractWidth(a);xs.extractShouldJoin(a)&&(h-=xs.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Yu=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Bo(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Pi=2147483647,Xu=256,cl=class Gr{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Xu)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Gr;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Gr(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Pi?Pi:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Pi?Pi:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,Pi):t}},Ai=[],Gu=class{constructor(){this._state=0,this._active=Ai,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ai}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Ai,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ai,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Ps(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ai,this._id=-1,this._state=0}}},ht=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ps(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Ii=[],Zu=class{constructor(){this._handlers=Object.create(null),this._active=Ii,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ii}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Ii,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ii,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Ps(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ii,this._ident=0}},Wi=new cl;Wi.addParam(0);var Mo=class{constructor(e){this._handler=e,this._data="",this._params=Wi,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Wi,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ps(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=Wi,this._data="",this._hitLimit=!1,i));return this._params=Wi,this._data="",this._hitLimit=!1,t}},Ju=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},pt=160,Qu=(function(){let e=new Ju(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(pt,0,2,0),e.add(pt,8,5,8),e.add(pt,6,0,6),e.add(pt,11,0,11),e.add(pt,13,13,13),e})(),ed=class extends ie{constructor(e=Qu){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new cl,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(pe(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Gu),this._dcsParser=this._register(new Zu),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:pt)],r>>4){case 2:for(let _=a+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<pt){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<pt){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<pt){this._printHandler(e,a,_),a=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<pt){this._printHandler(e,a,_),a=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let _=a+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<pt){this._dcsParser.put(e,a,_),a=_-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=a+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<pt){this._oscParser.put(e,a,_),a=_-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},td=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,id=/^[\da-f]+$/;function Do(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=td.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),id.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function hr(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function sd(e,t=16){let[i,s,r]=e;return`rgb:${hr(i,t)}/${hr(s,t)}/${hr(r,t)}`}var rd={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Xt=131072,Lo=10;function Po(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Ao=5e3,Io=0,nd=class extends ie{constructor(e,t,i,s,r,n,o,a,h=new ed){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new xh,this._utf8Decoder=new kh,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=De.clone(),this._eraseAttrDataInternal=De.clone(),this._onRequestBell=this._register(new A),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new A),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new A),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new A),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new A),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new A),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new A),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new A),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new A),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new A),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new A),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new A),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new A),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Zr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:u.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:u,data:d})}),this._parser.setDcsHandlerFallback((l,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:u,payload:d})}),this._parser.setPrintHandler((l,u,d)=>this.print(l,u,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(k.BEL,()=>this.bell()),this._parser.setExecuteHandler(k.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(k.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(k.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(k.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(k.BS,()=>this.backspace()),this._parser.setExecuteHandler(k.HT,()=>this.tab()),this._parser.setExecuteHandler(k.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(k.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ys.IND,()=>this.index()),this._parser.setExecuteHandler(ys.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ys.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ht(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new ht(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new ht(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new ht(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new ht(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new ht(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new ht(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new ht(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new ht(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new ht(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new ht(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new ht(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in Ie)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Mo((l,u)=>this.requestStatusString(l,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Ao))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Ao} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Xt&&(n=this._parseStack.position+Xt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Xt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Xt))),o||this._dirtyRowTracker.clearRange(),e.length>Xt)for(let l=n;l<e.length;l+=Xt){let u=l+Xt<e.length?l+Xt:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,u),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let p=t;p<i;++p){if(s=e[p],s<127&&n){let D=n[String.fromCharCode(s)];D&&(s=D.charCodeAt(0))}let f=this._unicodeService.charProperties(s,_);r=ni.extractWidth(f);let g=ni.extractShouldJoin(f),E=g?ni.extractWidth(_):0;if(_=f,o&&this._onA11yChar.fire(Gt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-E>a){if(h){let D=d,U=this._activeBuffer.x-E;for(this._activeBuffer.x=E,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),E>0&&d instanceof Hi&&d.copyCellsFrom(D,U,0,E,!1);U<a;)D.setCellFromCodepoint(U++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(g&&this._activeBuffer.x){let D=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-D,s,r);for(let U=r-E;--U>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-E,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,u),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x<a&&i-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Po(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Mo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ht(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(De));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=ni.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let u=n.codePointAt(l)||0;o[a++]=u,l+=u>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(k.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(k.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(k.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(k.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(k.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ri),this._charsetService.setgCharset(1,ri),this._charsetService.setgCharset(2,ri),this._charsetService.setgCharset(3,ri);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:u}=a,d=this._optionsService.rawOptions,_=(g,E)=>(o.triggerDataEvent(`${k.ESC}[${t?"":"?"}${g};${E}$y`),!0),p=g=>g?1:2,f=e.params[0];return t?f===2?_(f,4):f===4?_(f,p(o.modes.insertMode)):f===12?_(f,3):f===20?_(f,p(d.convertEol)):_(f,0):f===1?_(f,p(s.applicationCursorKeys)):f===3?_(f,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?_(f,p(s.origin)):f===7?_(f,p(s.wraparound)):f===8?_(f,3):f===9?_(f,p(r==="X10")):f===12?_(f,p(d.cursorBlink)):f===25?_(f,p(!o.isCursorHidden)):f===45?_(f,p(s.reverseWraparound)):f===66?_(f,p(s.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,p(r==="VT200")):f===1002?_(f,p(r==="DRAG")):f===1003?_(f,p(r==="ANY")):f===1004?_(f,p(s.sendFocus)):f===1005?_(f,4):f===1006?_(f,p(n==="SGR")):f===1015?_(f,4):f===1016?_(f,p(n==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,p(l===u)):f===2004?_(f,p(s.bracketedPasteMode)):f===2026?_(f,p(s.synchronizedOutput)):_(f,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=Xi.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=De.fg,e.bg=De.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=De.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=De.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=De.fg&16777215,s.bg&=-67108864,s.bg|=De.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${k.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${k.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${k.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=De.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Po(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${k.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Lo&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Lo&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(No(n))if(r==="?")t.push({type:0,index:n});else{let o=Do(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Do(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);No(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ri),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(rd[e[0]],Ie[e[1]]||ri),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=De.clone(),this._eraseAttrDataInternal=De.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new gt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${k.ESC}${o}${k.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Zr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Io=e,e=t,t=Io),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Zr=Ee([z(0,tt)],Zr);function No(e){return 0<=e&&e<256}var od=5e7,Oo=12,ad=50,ld=class extends ie{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new A),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>od)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Oo?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Oo)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>ad&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Jr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Jr=Ee([z(0,tt)],Jr);var Fo=!1,hd=class extends ie{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new wi),this._onBinary=this._register(new A),this.onBinary=this._onBinary.event,this._onData=this._register(new A),this.onData=this._onData.event,this._onLineFeed=this._register(new A),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new A),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new A),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new A),this._instantiationService=new Pu,this.optionsService=this._register(new ju(e)),this._instantiationService.setService(it,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vr)),this._instantiationService.setService(tt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(qr)),this._instantiationService.setService(Ba,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Yr)),this._instantiationService.setService(ci,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Xr)),this._instantiationService.setService(Ra,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ni)),this._instantiationService.setService(Bh,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Yu),this._instantiationService.setService(Rh,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jr),this._instantiationService.setService(Ma,this._oscLinkService),this._inputHandler=this._register(new nd(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ve.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ve.forward(this._bufferService.onResize,this._onResize)),this._register(Ve.forward(this.coreService.onData,this._onData)),this._register(Ve.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new ld((t,i)=>this._inputHandler.parse(t,i))),this._register(Ve.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new A),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Fo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Fo=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,ll),t=Math.max(t,hl),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Bo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Bo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=pe(()=>{for(let t of e)t.dispose()})}}},cd={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function ud(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=k.ESC+"OA":r.key=k.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=k.ESC+"OD":r.key=k.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=k.ESC+"OC":r.key=k.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=k.ESC+"OB":r.key=k.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":k.DEL,e.altKey&&(r.key=k.ESC+r.key);break;case 9:if(e.shiftKey){r.key=k.ESC+"[Z";break}r.key=k.HT,r.cancel=!0;break;case 13:r.key=e.altKey?k.ESC+k.CR:k.CR,r.cancel=!0;break;case 27:r.key=k.ESC,e.altKey&&(r.key=k.ESC+k.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=k.ESC+"[1;"+(n+1)+"D":t?r.key=k.ESC+"OD":r.key=k.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=k.ESC+"[1;"+(n+1)+"C":t?r.key=k.ESC+"OC":r.key=k.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=k.ESC+"[1;"+(n+1)+"A":t?r.key=k.ESC+"OA":r.key=k.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=k.ESC+"[1;"+(n+1)+"B":t?r.key=k.ESC+"OB":r.key=k.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=k.ESC+"[2~");break;case 46:n?r.key=k.ESC+"[3;"+(n+1)+"~":r.key=k.ESC+"[3~";break;case 36:n?r.key=k.ESC+"[1;"+(n+1)+"H":t?r.key=k.ESC+"OH":r.key=k.ESC+"[H";break;case 35:n?r.key=k.ESC+"[1;"+(n+1)+"F":t?r.key=k.ESC+"OF":r.key=k.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=k.ESC+"[5;"+(n+1)+"~":r.key=k.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=k.ESC+"[6;"+(n+1)+"~":r.key=k.ESC+"[6~";break;case 112:n?r.key=k.ESC+"[1;"+(n+1)+"P":r.key=k.ESC+"OP";break;case 113:n?r.key=k.ESC+"[1;"+(n+1)+"Q":r.key=k.ESC+"OQ";break;case 114:n?r.key=k.ESC+"[1;"+(n+1)+"R":r.key=k.ESC+"OR";break;case 115:n?r.key=k.ESC+"[1;"+(n+1)+"S":r.key=k.ESC+"OS";break;case 116:n?r.key=k.ESC+"[15;"+(n+1)+"~":r.key=k.ESC+"[15~";break;case 117:n?r.key=k.ESC+"[17;"+(n+1)+"~":r.key=k.ESC+"[17~";break;case 118:n?r.key=k.ESC+"[18;"+(n+1)+"~":r.key=k.ESC+"[18~";break;case 119:n?r.key=k.ESC+"[19;"+(n+1)+"~":r.key=k.ESC+"[19~";break;case 120:n?r.key=k.ESC+"[20;"+(n+1)+"~":r.key=k.ESC+"[20~";break;case 121:n?r.key=k.ESC+"[21;"+(n+1)+"~":r.key=k.ESC+"[21~";break;case 122:n?r.key=k.ESC+"[23;"+(n+1)+"~":r.key=k.ESC+"[23~";break;case 123:n?r.key=k.ESC+"[24;"+(n+1)+"~":r.key=k.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=k.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=k.DEL:e.keyCode===219?r.key=k.ESC:e.keyCode===220?r.key=k.FS:e.keyCode===221&&(r.key=k.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=cd[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=k.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=k.ESC+l}else if(e.keyCode===32)r.key=k.ESC+(e.ctrlKey?k.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=k.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=k.US),e.key==="@"&&(r.key=k.NUL));break}return r}var Me=0,dd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Bs,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Bs,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Me=this._search(t),Me===-1)||this._getKey(this._array[Me])!==t)return!1;do if(this._array[Me]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Me),!0;while(++Me<this._array.length&&this._getKey(this._array[Me])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Me=this._search(e),!(Me<0||Me>=this._array.length)&&this._getKey(this._array[Me])===e))do yield this._array[Me];while(++Me<this._array.length&&this._getKey(this._array[Me])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Me=this._search(e),!(Me<0||Me>=this._array.length)&&this._getKey(this._array[Me])===e))do t(this._array[Me]);while(++Me<this._array.length&&this._getKey(this._array[Me])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},cr=0,Ho=0,fd=class extends ie{constructor(){super(),this._decorations=new dd(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new A),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new A),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(pe(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new _d(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{cr=r.options.x??0,Ho=cr+(r.options.width??1),e>=cr&&e<Ho&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},_d=class extends Jt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new A),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new A),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=we.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=we.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},md=1e3,pd=class{constructor(e,t=md){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},zo=20,Ms=class extends ie{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new pd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
48
48
|
`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(J(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(pe(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<zo+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
49
49
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===zo+1&&(this._liveRegion.textContent+=vr.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(u);if(!_)return console.warn("columns is null. Race condition?"),null;let p=l<_.length?_[l]:_.slice(-1)[0]+1;return p>=this._terminal.cols&&(++d,p=0),{row:d,column:p}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Ms=Ee([z(1,sn),z(2,Wt),z(3,$t)],Ms);var Qr=class extends ie{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new A),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new A),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(pe(()=>{var n;li(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(J(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(J(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(J(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(J(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,u;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&gd(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,li(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Qr=Ee([z(1,rn),z(2,$t),z(3,tt),z(4,La)],Qr);function gd(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var vd=class extends hd{constructor(e={}){super(e),this._linkifier=this._register(new wi),this.browser=Za,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new wi),this._onCursorMove=this._register(new A),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new A),this.onKey=this._onKey.event,this._onRender=this._register(new A),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new A),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new A),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new A),this.onBell=this._onBell.event,this._onFocus=this._register(new A),this._onBlur=this._register(new A),this._onA11yCharEmitter=this._register(new A),this._onA11yTabEmitter=this._register(new A),this._onWillOpen=this._register(new A),this._setup(),this._decorationService=this._instantiationService.createInstance(fd),this._instantiationService.setService(Gi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(au),this._instantiationService.setService(La,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(br)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ve.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ve.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ve.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ve.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(pe(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=_e.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${k.ESC}]${s};${sd(r)}${Xa.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=Le.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=Le.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ms,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(k.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(k.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(J(this.element,"copy",t=>{this.hasSelection()&&yh(t,this._selectionService)}));let e=t=>Ch(t,this.textarea,this.coreService,this.optionsService);this._register(J(this.textarea,"paste",e)),this._register(J(this.element,"paste",e)),Ja?this._register(J(this.element,"mousedown",t=>{t.button===2&&Xn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(J(this.element,"contextmenu",t=>{Xn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),dn&&this._register(J(this.element,"auxclick",t=>{t.button===1&&Ca(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(J(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(J(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(J(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(J(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(J(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(J(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(J(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(J(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",gr.get()),tl||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(nu,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Wt,this._coreBrowserService),this._register(J(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(J(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wr,this._document,this._helperContainer),this._instantiationService.setService(As,this._charSizeService),this._themeService=this._instantiationService.createInstance(Kr),this._instantiationService.setService(yi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ts),this._instantiationService.setService(Da,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(jr,this.rows,this.screenElement)),this._instantiationService.setService($t,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Fr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance($r),this._instantiationService.setService(rn,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Qr,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Nr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ur,this.element,this.screenElement,s)),this._instantiationService.setService(Dh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Ve.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Or,this.screenElement)),this._register(J(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ms,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Es,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Es,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zr,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,u,d,_,p;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let f=n.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(n,(_=(d=(u=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:_.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;h=f<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(J(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(J(t,"wheel",n=>{var o,a,h,l,u;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(n,!0);let d=k.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ya(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=ud(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===k.ETX||i.key===k.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Sd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(De));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(k.ESC+"[I"):this.coreService.triggerDataEvent(k.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${k.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${k.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Sd(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bd=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},wd=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new gt)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Wo=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new wd(t)}getNullCell(){return new gt}},yd=class extends ie{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new A),this.onBufferChange=this._onBufferChange.event,this._normal=new Wo(this._core.buffers.normal,"normal"),this._alternate=new Wo(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Cd=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},xd=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},kd=["cols","rows"],Et=0,Ed=class extends ie{constructor(e){super(),this._core=this._register(new vd(e)),this._addonManager=this._register(new bd),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(kd.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Cd(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new xd(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new yd(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
50
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return gr.get()},set promptLabel(e){gr.set(e)},get tooMuchOutput(){return vr.get()},set tooMuchOutput(e){vr.set(e)}}}_verifyIntegers(...e){for(Et of e)if(Et===1/0||isNaN(Et)||Et%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Et of e)if(Et&&(Et===1/0||isNaN(Et)||Et%1!==0||Et<0))throw new Error("This API only accepts positive integers")}};const ul="codingns.user-app.terminal-page",Td=3,Rd=20,Bd=5,Md=400,Dd=200,Ld=2e5,Pd=12e4,Ad=.7,Id=2,ur={selectedWorkspaceId:null,activeTerminalIdByWorkspace:{},pinnedTerminalIdsByWorkspace:{},cursorByTerminalId:{},viewStateByTerminalId:{},zoomScale:null};function $o(){var t,i;const e=ki();return{selectedWorkspaceId:((t=e.selectedWorkspaceId)==null?void 0:t.value)??null,activeTerminalIdByWorkspace:cs(e.activeTerminalIdByWorkspace),pinnedTerminalIdsByWorkspace:cs(e.pinnedTerminalIdsByWorkspace),cursorByTerminalId:cs(e.cursorByTerminalId),viewStateByTerminalId:cs(e.viewStateByTerminalId),zoomScale:((i=e.zoomScale)==null?void 0:i.value)??null}}function Nd(e){xi((t,i)=>({...t,selectedWorkspaceId:{value:e,updatedAt:i}}))}function Od(e){var t;return((t=ki().activeTerminalIdByWorkspace[e])==null?void 0:t.value)??null}function Fd(e,t){xi((i,s)=>{const r={...i,activeTerminalIdByWorkspace:{...i.activeTerminalIdByWorkspace}};return t?r.activeTerminalIdByWorkspace[e]={value:t,updatedAt:s}:delete r.activeTerminalIdByWorkspace[e],r})}function Hd(e){var t;return((t=ki().pinnedTerminalIdsByWorkspace[e])==null?void 0:t.value)??[]}function jo(e,t){xi((i,s)=>{const r={...i,pinnedTerminalIdsByWorkspace:{...i.pinnedTerminalIdsByWorkspace}},n=fl(t);return n.length===0?(delete r.pinnedTerminalIdsByWorkspace[e],r):(r.pinnedTerminalIdsByWorkspace[e]={value:n,updatedAt:s},r)})}function zd(){var e;return((e=ki().zoomScale)==null?void 0:e.value)??null}function Wd(e){xi((t,i)=>({...t,zoomScale:{value:_l(e),updatedAt:i}}))}function $d(e,t){xi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId}};return t?(r.cursorByTerminalId[e]=dl(i.cursorByTerminalId[e],{value:t,updatedAt:s}),r):(delete r.cursorByTerminalId[e],r)})}function en(e){var r,n;const t=ki(),i=((r=t.viewStateByTerminalId[e])==null?void 0:r.value)??null,s=((n=t.cursorByTerminalId[e])==null?void 0:n.value)??null;return i?i.cursor&&s&&Vi(s,i.cursor)?{resumeCursor:s,viewState:null}:{resumeCursor:i.cursor??s,viewState:i}:{resumeCursor:s,viewState:null}}function jd(e,t){xi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId},viewStateByTerminalId:{...i.viewStateByTerminalId}};return t?(r.viewStateByTerminalId[e]=Gd(i.viewStateByTerminalId[e],{value:t,updatedAt:s}),t.cursor&&(r.cursorByTerminalId[e]=dl(i.cursorByTerminalId[e],{value:t.cursor,updatedAt:s})),r):(delete r.viewStateByTerminalId[e],r)})}function xi(e){if(typeof window>"u")return;const t=ki(),i=Date.now(),s=e(t,i);window.localStorage.setItem(ul,JSON.stringify({schemaVersion:Td,state:s}))}function ki(){if(typeof window>"u")return ur;try{const e=window.localStorage.getItem(ul);if(!e)return ur;const t=JSON.parse(e),i=t&&typeof t=="object"&&"state"in t&&t.state&&typeof t.state=="object"?t.state:t;return{selectedWorkspaceId:Kd(i.selectedWorkspaceId),activeTerminalIdByWorkspace:hs(i.activeTerminalIdByWorkspace,Uo),pinnedTerminalIdsByWorkspace:hs(i.pinnedTerminalIdsByWorkspace,Vd),cursorByTerminalId:hs(i.cursorByTerminalId,Uo),viewStateByTerminalId:hs(i.viewStateByTerminalId,Yd),zoomScale:Ud(i.zoomScale)}}catch{return ur}}function Ud(e){return e===null?null:fn(e,Xd)??null}function Kd(e){return e===null?null:fn(e,qd)??null}function hs(e,t){if(!e||typeof e!="object")return{};const i={};for(const[s,r]of Object.entries(e)){const n=fn(r,t);s&&n&&(i[s]=n)}return i}function fn(e,t){const i=t(e);if(i!==null)return{value:i,updatedAt:0};if(!e||typeof e!="object")return null;const s=e,r=t(s.value);return r===null?null:{value:r,updatedAt:Number.isFinite(s.updatedAt)?Number(s.updatedAt):0}}function Uo(e){return typeof e=="string"&&e?e:null}function qd(e){return e===null?null:typeof e=="string"?e:null}function Vd(e){return Array.isArray(e)?fl(e.filter(i=>typeof i=="string")):null}function Yd(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.content!="string"||t.content.length===0||t.content.length>Pd||t.cursor!==null&&t.cursor!==void 0&&typeof t.cursor!="string"||!Number.isInteger(t.cols)||!Number.isInteger(t.rows)||!Number.isInteger(t.viewportY)||t.historyBeforeSeq!==null&&t.historyBeforeSeq!==void 0&&!Number.isInteger(t.historyBeforeSeq)||t.historyHasOlder!==void 0&&typeof t.historyHasOlder!="boolean")return null;const i=t.cols,s=t.rows,r=t.viewportY;return i<Rd||i>Md||s<Bd||s>Dd||r<0||r>Ld?null:{content:t.content,cursor:typeof t.cursor=="string"?t.cursor:null,cols:i,rows:s,viewportY:r,historyBeforeSeq:typeof t.historyBeforeSeq=="number"?t.historyBeforeSeq:null,historyHasOlder:typeof t.historyHasOlder=="boolean"?t.historyHasOlder:!0}}function Xd(e){return typeof e!="number"||!Number.isFinite(e)?null:_l(e)}function cs(e){const t={};for(const[i,s]of Object.entries(e))t[i]=s.value;return t}function dl(e,t){return!e||Vi(t.value,e.value)?t:Vi(e.value,t.value)?e:t.updatedAt>=e.updatedAt?t:e}function Gd(e,t){if(!e)return t;const i=e.value.cursor,s=t.value.cursor;return s&&i&&Vi(s,i)?t:s&&i&&Vi(i,s)?e:t.value.content.length!==e.value.content.length?t.value.content.length>e.value.content.length?t:e:t.updatedAt>=e.updatedAt?t:e}function Vi(e,t){const i=Number(e),s=Number(t);return!Number.isInteger(i)||!Number.isInteger(s)?!1:i>s}function fl(e){return Array.from(new Set(e.map(t=>t.trim()).filter(Boolean)))}function _l(e){return Math.min(Id,Math.max(Ad,e))}function Zd({terminals:e,preferredTerminalId:t,currentActiveTerminalId:i,persistedTerminalId:s}){const r=dr(e,t),n=dr(e,i),o=dr(e,s),a=e.find(h=>h.status==="running")??null;return fr(r)??fr(n)??fr(o)??a??r??n??o??e[0]??null}function dr(e,t){return t?e.find(i=>i.id===t)??null:null}function fr(e){return!e||e.status!=="running"?null:e}const Jd="codingns.terminal.debug",Qd=ef();let Ko=0;function ai(){return Qd}function ef(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search).get("terminalDebug");if(e)return qo(e);try{const t=window.localStorage.getItem(Jd);return t?qo(t):!1}catch{return!1}}function Rt(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function tf(e){return Ko+=1,`${e}-${Date.now().toString(36)}-${Ko.toString(36)}`}function ji(e,t={}){ai()&&console.info(`[terminal-debug][client] ${e}`,t)}function qo(e){const t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}const sf=8,rf=1e4;class nf{constructor(t){st(this,"socket",null);st(this,"disposed",!1);st(this,"authRecoveryInFlight",!1);st(this,"manuallyDisconnected",!1);st(this,"lastCursor");st(this,"isSubscribed",!1);st(this,"pendingInput","");st(this,"inputFlushTimer",null);st(this,"pendingInputQueuedAtMs",null);st(this,"pendingResize",null);st(this,"lastSentResizeKey",null);st(this,"inputDebugTraces",new Map);st(this,"connectionManager");this.options=t,this.lastCursor=t.lastCursor,this.connectionManager=new Kl({onReconnect:i=>{this.connect(i)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.lastCursor=t}sendInput(t){t&&(this.pendingInputQueuedAtMs===null&&(this.pendingInputQueuedAtMs=Rt()),this.pendingInput+=t,this.logDebug("input.queued",{charCount:t.length,pendingCharCount:this.pendingInput.length,preview:us(t)}),this.canSendRealtimePayload()&&(this.pruneStaleInputDebugTraces(),this.scheduleInputFlush()))}sendCurrentDimensions(t,i){!Number.isInteger(t)||!Number.isInteger(i)||t<1||i<1||this.resize(t,i)}sendTerminalInput(t){const i=this.pendingInputQueuedAtMs??Rt(),s=Rt(),n=ai()?tf(this.options.terminalId):void 0;n&&this.inputDebugTraces.set(n,{traceId:n,queuedAtMs:i,sentAtMs:s,ackedAtMs:null,charCount:t.length,preview:us(t)}),this.logDebug("input.sent",{traceId:n??null,charCount:t.length,queuedForMs:s-i,preview:us(t)}),this.sendMessage({type:"terminal.input",terminalId:this.options.terminalId,content:t,...n?{clientTraceId:n,clientSentAtMs:s}:{}}),this.pendingInputQueuedAtMs=null}resize(t,i){this.pendingResize={cols:t,rows:i},this.isSubscribed&&this.flushPendingResize()}disconnect(){this.manuallyDisconnected=!0,this.isSubscribed=!1,this.inputDebugTraces.clear();const t=this.socket;this.socket=null,t==null||t.close(),this.options.onConnectionChange("closed")}reconnectNow(){this.manuallyDisconnected=!1,this.connectionManager.reconnectNow()}close(){var t;this.disposed=!0,this.manuallyDisconnected=!0,this.connectionManager.close(),this.clearInputFlushTimer(),this.inputDebugTraces.clear(),(t=this.socket)==null||t.close(),this.socket=null,this.isSubscribed=!1}connect(t){var n;if(this.disposed||this.manuallyDisconnected)return;t&&this.socket&&(this.socket.close(),this.socket=null);const i=(n=jn.getState().session)==null?void 0:n.accessToken;if(!i){this.options.onUnauthorized();return}const s=`${$l("/ws")}?access_token=${encodeURIComponent(i)}`,r=new WebSocket(s);this.socket=r,r.addEventListener("open",()=>{this.isSubscribed=!1,r.send(JSON.stringify({type:"terminal.subscribe",terminalId:this.options.terminalId,lastCursor:this.lastCursor}))}),r.addEventListener("message",o=>{const a=JSON.parse(o.data);if(a.type==="system.connected"){this.connectionManager.markConnected();return}if(a.type==="terminal.subscribed"){this.isSubscribed=!0,this.options.onSubscribed(),this.flushPendingResize(),this.flushPendingInput(!0);return}if(a.type==="terminal.error"){if(a.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(a);return}if(a.type!=="terminal.resize.accepted"){if(a.type==="terminal.input.accepted"){if(this.pruneStaleInputDebugTraces(),a.clientTraceId){const h=this.inputDebugTraces.get(a.clientTraceId);h&&(h.ackedAtMs=Rt(),this.logDebug("input.acknowledged",{traceId:h.traceId,charCount:h.charCount,sendToAckMs:h.ackedAtMs-h.sentAtMs,preview:h.preview}))}return}if(a.type==="terminal.backfill"){this.lastCursor=a.latestCursor??this.lastCursor,this.options.onBackfill(a);return}if(a.type==="terminal.output"){this.lastCursor=a.chunk.cursor,this.pruneStaleInputDebugTraces(),this.handleDebugOutput(a.chunk.content,a.chunk.cursor),this.options.onOutput(a);return}if(a.type==="terminal.status"){this.options.onStatus(a);return}a.type}}),r.addEventListener("close",()=>{this.disposed||this.socket!==r||(this.isSubscribed=!1,this.connectionManager.markDisconnected())}),r.addEventListener("error",()=>{this.disposed||this.socket!==r||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,this.isSubscribed=!1,t==null||t.close(),jn.refresh().then(i=>{if(this.authRecoveryInFlight=!1,!(this.disposed||this.manuallyDisconnected)){if(i.status==="refreshed"){this.connectionManager.reconnectNow();return}if(i.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendMessage(t){!this.socket||this.socket.readyState!==WebSocket.OPEN||this.socket.send(JSON.stringify(t))}canSendRealtimePayload(){return!!(this.socket&&this.socket.readyState===WebSocket.OPEN&&this.isSubscribed)}flushPendingInput(t=!1){if(!this.pendingInput||!this.canSendRealtimePayload())return;t||this.clearInputFlushTimer();const i=this.pendingInput;this.pendingInput="",this.sendTerminalInput(i)}scheduleInputFlush(){this.inputFlushTimer===null&&(this.inputFlushTimer=window.setTimeout(()=>{this.inputFlushTimer=null,this.flushPendingInput(!0)},sf))}clearInputFlushTimer(){this.inputFlushTimer!==null&&(window.clearTimeout(this.inputFlushTimer),this.inputFlushTimer=null)}flushPendingResize(){if(!this.pendingResize||!this.canSendRealtimePayload())return;const t=this.pendingResize,i=`${t.cols}x${t.rows}`;if(this.lastSentResizeKey===i){this.pendingResize=null;return}this.sendMessage({type:"terminal.resize",terminalId:this.options.terminalId,cols:t.cols,rows:t.rows}),this.lastSentResizeKey=i,this.pendingResize=null}handleDebugOutput(t,i){if(!ai())return;const s=this.inputDebugTraces.values().next().value;if(!s)return;const r=Rt();this.inputDebugTraces.delete(s.traceId),this.logDebug("output.received_after_input",{traceId:s.traceId,cursor:i,charCount:t.length,sendToOutputMs:r-s.sentAtMs,ackToOutputMs:s.ackedAtMs===null?null:r-s.ackedAtMs,preview:us(t)})}logDebug(t,i){ji(`terminal.${t}`,{terminalId:this.options.terminalId,...i})}pruneStaleInputDebugTraces(){if(!ai()||this.inputDebugTraces.size===0)return;const t=Rt();for(const[i,s]of this.inputDebugTraces.entries()){const r=t-s.sentAtMs;r<rf||(this.inputDebugTraces.delete(i),this.logDebug("input.trace_expired",{traceId:i,ageMs:r,charCount:s.charCount,preview:s.preview}))}}}function us(e){return e.replace(/\r/g,"\\r").replace(/\n/g,"\\n").slice(0,60)}const of=250,af=/\u001b\[\?(?:\d+;)*\d+c|\u001b\[>(?:\d+;)*\d+c/g;function lf(e,t=window){let i=!1,s="",r=null,n=null,o=!1;const a=()=>{r!==null&&(t.clearTimeout(r),r=null)},h=()=>{n!==null&&(t.clearTimeout(n),n=null)},l=()=>{if(!i||r!==null||n!==null||s.length===0)return;const u=o?hf(s):s;s="",o=!1,u&&e(u)};return{enqueue(u){if(u){if(i&&r===null&&n===null){e(u);return}s+=u}},suspend(){a(),h(),i=!1},resume(u=0){if(a(),h(),u<=0){i=!0,l();return}i=!1,o=!0,r=t.setTimeout(()=>{r=null,i=!0,n=t.setTimeout(()=>{n=null,l()},of)},u)},dispose(){a(),h(),i=!1,s="",o=!1}}}function hf(e){return e.replace(af,"")}const cf=120,uf=120,df=120,ff=30,_f=14,mf=160,pf=12e4,ml=20,pl=5,gf=320,vf=120,Sf=.8,bf=1.6,Vo=.1,wf=700,Yo=10,yf=300,Cf=250,Xo=196,xf=6,_r=8,_n=72,mn=48,kf=60*1e3,Ef=20,Tf=6,Rf=14,Bf=2,Go=.06,Zo=.9,Mf=.97,Df=3600,Lf=3,Pf=5,ds={primary:null,secondary:null},fs={primary:"closed",secondary:"closed"};function Jo(e){var n,o,a;const t=e.routeWorkspaceId??null;if(t)return t;const i=e.shellCurrentWorkspaceId&&e.workspaces.some(h=>h.id===e.shellCurrentWorkspaceId)?e.shellCurrentWorkspaceId:null;if(i)return i;const s=((n=e.persistedWorkspaceId)==null?void 0:n.trim())??"";return((o=e.workspaces.find(h=>h.id===s))==null?void 0:o.id)??((a=e.workspaces[0])==null?void 0:a.id)??""}function L_({externalWindowMode:e=!1,externalWindowWorkspaceId:t=null,embeddedMode:i=!1,workbenchShellOverrides:s}={}){var $n;const r=pa(),n=ql(r),o=Ul(),a=Jl(),{workspaceId:h}=Ql(),l=Vl(),{navigationGroups:u,currentWorkspaceId:d,selectWorkspace:_,subscribeTerminalManagerSnapshot:p,requestTerminalManagerRefresh:f,addTerminalManagerSnapshotListener:g}={navigationGroups:(s==null?void 0:s.navigationGroups)??l.navigationGroups,currentWorkspaceId:(s==null?void 0:s.currentWorkspaceId)??l.currentWorkspaceId,selectWorkspace:(s==null?void 0:s.selectWorkspace)??l.selectWorkspace,subscribeTerminalManagerSnapshot:(s==null?void 0:s.subscribeTerminalManagerSnapshot)??l.subscribeTerminalManagerSnapshot,requestTerminalManagerRefresh:(s==null?void 0:s.requestTerminalManagerRefresh)??l.requestTerminalManagerRefresh,addTerminalManagerSnapshotListener:(s==null?void 0:s.addTerminalManagerSnapshotListener)??l.addTerminalManagerSnapshotListener},E=b.useRef(null),D=b.useRef(null),U=b.useRef(null),W=b.useRef(null),H=b.useRef({}),O=b.useRef(null),j=b.useRef(null),se=b.useRef(null),Z=b.useRef(null),V=b.useRef(""),oe=b.useRef([]),X=b.useRef(0),x=b.useRef({primary:null,secondary:null}),S=b.useRef(ds),T=b.useRef("primary"),P=b.useRef("single"),B=b.useMemo(()=>u.map(c=>c.workspace),[u]),$=i?(t==null?void 0:t.trim())||(h==null?void 0:h.trim())||null:(h==null?void 0:h.trim())||(t==null?void 0:t.trim())||null,I=$o().selectedWorkspaceId,[N,ne]=b.useState(()=>Jo({routeWorkspaceId:$,shellCurrentWorkspaceId:d,workspaces:B,persistedWorkspaceId:I})),[ce,Te]=b.useState(""),[Q,ee]=b.useState([]),[ye,Ce]=b.useState(""),[Ne,ct]=b.useState(""),[ge,ve]=b.useState(!1),[vt,Se]=b.useState(!1),[C,R]=b.useState(!1),[K,re]=b.useState(!1),[ae,Re]=b.useState([]),[q,Y]=b.useState(null),[de,ut]=b.useState(!1),[nt,dt]=b.useState(null),[M,F]=b.useState(null),[fe,Be]=b.useState(!1),[Ye,ot]=b.useState(null),[Ct,St]=b.useState(!1),[Lt,Qi]=b.useState("single"),[Pt,yl]=b.useState("primary"),[Qt,vn]=b.useState(ds),[es,jt]=b.useState(fs),[Sn,ts]=b.useState([]),[bn,ui]=b.useState([]),[Ei,Cl]=b.useState({}),[ei,xl]=b.useState(()=>zd()??1),di=b.useMemo(()=>B.find(c=>c.id===d)??null,[d,B]),wn=b.useMemo(()=>B.find(c=>c.id===N)??null,[N,B]),At=b.useMemo(()=>wn??(N||$?null:di)??null,[$,wn,N,di]),at=b.useMemo(()=>{var c;return(At==null?void 0:At.id)??$??N??(di==null?void 0:di.id)??((c=B[0])==null?void 0:c.id)??""},[At,$,N,di,B]),kl=b.useMemo(()=>At??B[0]??{id:"__terminal-mobile-workspace-placeholder__",name:w("terminal.mobileWorkspaceSwitcherPlaceholder"),path:w("home.emptyWorkspaces")},[At,B]),{dismissToast:Fs,showToast:bt}=eh(),Ze=b.useCallback((c,v="info")=>{},[]),yn=b.useCallback((c,v)=>{x.current[c]=v},[]),Cn=b.useCallback(()=>{a("/login",{replace:!0})},[a]),Hs=b.useCallback((c,v)=>{const y=U.current,L=v??H.current[c];if(!y||!L||!L.isConnected)return null;const G=y.getBoundingClientRect(),me=L.getBoundingClientRect(),ue=Math.max(_r,G.width-Xo-_r),wt=Ds(me.right-G.left-Xo,_r,ue),ft=Math.max(0,me.bottom-G.top+xf);return{terminalId:c,top:ft,left:wt}},[]),xn=b.useCallback(c=>{const v=Hs(c);if(!v){F(null);return}F(y=>!y||y.terminalId!==c||y.top===v.top&&y.left===v.left?y:v)},[Hs]),Ti=b.useMemo(()=>new Set(Sn),[Sn]),zs=b.useMemo(()=>new Set(bn),[bn]),kn=b.useMemo(()=>Vf(ae,Ti),[Ti,ae]),En=b.useMemo(()=>ga(r.ui.osFamily),[r.ui.osFamily]),le=!r.isDesktop&&r.isMobile,El=r.isDesktop&&r.bridge.supported&&!e&&!!at,Tn=b.useMemo(()=>at?Yl(at):null,[at]),Tl=jl(c=>Tn?c.openWindowIds.includes(Tn):!1),Rn=e||!Tl,Ut=le?"single":Lt,fi=le?"primary":Pt,It=b.useMemo(()=>le?{primary:Qt[Pt]??Qt.primary,secondary:null}:Qt,[Pt,le,Qt]),Ws=b.useMemo(()=>le?{primary:es[Pt]??es.primary,secondary:"closed"}:es,[Pt,le,es]),Nt=It[fi],Je=b.useMemo(()=>ae.find(c=>c.id===Nt)??null,[Nt,ae]),$s=b.useMemo(()=>M?ae.find(c=>c.id===M.terminalId)??null:null,[M,ae]),Rl=Ut==="single"?["primary"]:["primary","secondary"],xt=b.useMemo(()=>Qf(Q,r.ui.osFamily),[r.ui.osFamily,Q]),Bl=b.useMemo(()=>xt.find(c=>c.value===Ne)??xt[0]??null,[Ne,xt]),Ml={"--terminal-mobile-list-width":le&&ge?"60vw":"0px"};b.useEffect(()=>{oe.current=ae},[ae]),Nf(D,O,le,N||at),b.useEffect(()=>{Ce(c=>ms(Q,c)??"")},[Q]),b.useEffect(()=>{ct(c=>{var v,y;return xt.length?c&&xt.some(L=>L.value===c&&L.available)?c:((v=xt.find(L=>L.available))==null?void 0:v.value)??((y=xt[0])==null?void 0:y.value)??"":""})},[xt]);function Kt(c){const v=c(S.current);S.current=v,vn(v)}function _i(c){T.current=c,yl(c)}function js(c){P.current=c,Qi(c)}const mi=b.useCallback((c,v,y={})=>{var me;if(V.current!==c)return;oe.current=v,Re(v),Y(c),ui(ue=>{const wt=new Set(v.map(ft=>ft.id));return ue.filter(ft=>wt.has(ft))}),ts(ue=>{const wt=new Set(v.map(gi=>gi.id)),ft=ue.filter(gi=>wt.has(gi));return ft.length!==ue.length&&jo(c,ft),ft});const L=Od(c),G=((me=Zd({terminals:v,preferredTerminalId:y.preferredTerminalId,currentActiveTerminalId:S.current[T.current]??S.current.primary,persistedTerminalId:L}))==null?void 0:me.id)??null;vn(ue=>{const wt=gs({terminals:v,currentBindings:ue,splitDirection:P.current,fallbackTerminalId:G,preferredPaneId:y.preferredPaneId??T.current});return S.current=wt,wt})},[]),qt=b.useCallback(async(c,v={})=>{const y=X.current+1;X.current=y;try{const L=await ih(c);if(y!==X.current||V.current!==c)return;mi(c,L.items,v)}catch(L){if(y!==X.current||V.current!==c)return;const G=L instanceof Error?L.message:w("terminal.workspaceLoadFailed");Ze(G,"error")}},[mi,Ze]),Bn=b.useCallback(()=>N?qt(N):Promise.resolve(),[qt,N]);b.useEffect(()=>{V.current=N},[N]),b.useEffect(()=>{S.current=Qt},[Qt]),b.useEffect(()=>{T.current=Pt},[Pt]),b.useEffect(()=>{P.current=Lt},[Lt]),b.useEffect(()=>{if(!le)return;const c=S.current[T.current]??S.current.primary,v=P.current!=="single",y=T.current!=="primary",L=S.current.secondary!==null||S.current.primary!==c;!v&&!y&&!L||(Kt(()=>({primary:c,secondary:null})),js("single"),_i("primary"),jt(G=>G.secondary==="closed"?G:{...G,secondary:"closed"}))},[le]),b.useEffect(()=>{const c=$o().selectedWorkspaceId;ne(v=>{const y=v.trim();return $||(y&&B.some(L=>L.id===y)?y:Jo({routeWorkspaceId:$,shellCurrentWorkspaceId:d,workspaces:B,persistedWorkspaceId:c}))})},[$,d,B]),b.useEffect(()=>{Nd(N||null)},[N]),b.useEffect(()=>{if(!N){ts([]);return}ts(Hd(N))},[N]),b.useEffect(()=>{if(Nt||ae.length===0)return;const c=wl(ae);c&&Bi(c,"primary")},[Nt,ae]),b.useEffect(()=>{Wd(ei)},[ei]),b.useEffect(()=>{F(null)},[Pt,Qt,N]),b.useEffect(()=>{le&&ve(!1)},[Nt,le,N]),b.useEffect(()=>{M&&!ae.some(c=>c.id===M.terminalId)&&F(null)},[M,ae]),b.useEffect(()=>{if(N)return g(c=>{c.workspaceId===N&&(Xl(ua(N),{revision:c.revision??null,terminals:c.terminals,templates:c.templates,templateStatuses:c.templateStatuses,shellOptions:c.shellOptions}),ee(c.shellOptions??[]),mi(c.workspaceId,c.terminals))})},[g,mi,N]),b.useEffect(()=>{if(!M)return;const c=W.current,v=()=>{xn(M.terminalId)},y=window.requestAnimationFrame(v);return window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),c==null||c.addEventListener("scroll",v,{passive:!0}),()=>{window.cancelAnimationFrame(y),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),c==null||c.removeEventListener("scroll",v)}},[M,xn]),b.useEffect(()=>{if(!M&&!fe)return;function c(y){var ue,wt,ft,gi;const L=y.target,G=(((ue=E.current)==null?void 0:ue.contains(L))??!1)||!!M&&(((wt=H.current[M.terminalId])==null?void 0:wt.contains(L))??!1),me=(((ft=j.current)==null?void 0:ft.contains(L))??!1)||(((gi=se.current)==null?void 0:gi.contains(L))??!1);M&&!G&&F(null),fe&&!me&&Be(!1)}function v(y){y.key==="Escape"&&(F(null),Be(!1))}return window.addEventListener("mousedown",c),window.addEventListener("keydown",v),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",v)}},[M,fe]),b.useEffect(()=>{if(!N){Y(null),ee([]),Ce(""),ve(!1),Se(!1),oe.current=[],Re([]),Kt(()=>ds),_i("primary"),jt(fs),dt(null);return}Y(null),_i("primary"),jt(fs),dt(null);const c=Gl(ua(N),kf);if(c?(ee(Yf(c.shellOptions)),mi(N,c.terminals)):(ee([]),oe.current=[],Re([]),Kt(()=>ds),_i("primary"),jt(fs),dt(null)),p(N,{knownRevision:(c==null?void 0:c.revision)??null}),c){const v=window.setTimeout(()=>{f(N,{knownRevision:c.revision??null})},1500);return()=>{window.clearTimeout(v)}}f(N,{knownRevision:null}),e&&(qt(N),Q.length===0&&Un().then(v=>{ee(v.items??[])}).catch(()=>{}))},[mi,e,f,qt,N,Q.length,p]),b.useEffect(()=>{N&&q===N&&(Je&&Je.workspaceId!==N||Fd(N,Nt??null))},[Je,Nt,q,N]);const Mn=b.useCallback((c,v)=>{jt(y=>({...y,[c]:v}))},[]),Dn=b.useCallback(c=>{c.status!=="running"&&ui(v=>v.filter(y=>y!==c.id)),Re(v=>{const y=v.map(L=>L.id===c.id?{...L,status:c.status,statusDetail:c.statusDetail,processId:c.processId??L.processId??null}:L);return oe.current=y,y})},[]);function Ri(c,v){Cl(y=>{if(v===null){if(!(c in y))return y;const L={...y};return delete L[c],L}return y[c]===v?y:{...y,[c]:v}})}function Us(c,v){bt({id:mr(c),title:v==="closing"?w("terminal.closing"):w("terminal.deleting"),description:v==="closing"?w("terminal.closePendingDescription"):w("terminal.deletePendingDescription"),tone:"info",durationMs:null})}async function Ln(c,v,y){for(let L=0;L<Yo;L+=1){if(V.current!==c)return"workspace_changed";await qt(c);const G=oe.current.find(ue=>ue.id===v)??null;if(y==="deleting"?G===null:G===null||G.status!=="running")return"settled";L<Yo-1&&await c_()}return"timeout"}function Pn(c){_i(c)}function Ks(c){Bi(c,T.current)}function Bi(c,v){const y=le?"primary":v,L=le?"single":P.current;Kt(G=>{const me=L==="single"?{primary:c,secondary:null}:{...G,[y]:c};if(L!=="single"){const ue=y==="primary"?"secondary":"primary";me[ue]===c&&(me[ue]=tn(ae,c))}return gs({terminals:ae,currentBindings:me,splitDirection:L,fallbackTerminalId:c,preferredPaneId:y})}),ui(G=>G.filter(me=>me!==c)),F(null)}async function qs(c,v={}){try{return await nh(c)}catch(y){if(v.allowFallbackPrompt!==!1&&c.runtimeType!=="embedded-pty"&&lh(y))return ot(c),null;throw y}}async function is(){if(Q.length>0||K)return Q;re(!0);try{const v=(await Un()).items??[];return ee(v),v}catch{return Q}finally{re(!1)}}async function An(){!le||!at||de||(await is(),Se(!0))}async function Vs(c,v,y={}){var L;ut(!0),dt(v);try{const G=await qs(c);if(!G){pi(v);return}Ys(G,v),pi(v),(L=y.onCreated)==null||L.call(y),await qt(c.workspaceId,{preferredTerminalId:G.id,preferredPaneId:v}),Ze(w("terminal.created"),"success")}catch(G){pi(v),Ze(G instanceof Error?G.message:w("terminal.createFailed"),"error")}finally{ut(!1)}}function pi(c){dt(v=>v===c?null:v)}function Ys(c,v){const y=le?"primary":v,L=le?"single":P.current,G=f_(oe.current,c);oe.current=G,Re(G),Kt(me=>gs({terminals:G,currentBindings:{...me,[y]:c.id,...L==="single"?{primary:c.id,secondary:null}:{}},splitDirection:L,fallbackTerminalId:c.id,preferredPaneId:y})),jt(me=>({...me,[y]:c.status==="running"?"reconnecting":"closed"})),ui(me=>me.filter(ue=>ue!==c.id))}async function Dl(){const c=at;if(!c||de)return;const v=le?"primary":T.current,y=await is(),L=ms(y.length>0?y:Q,ye);await Vs({workspaceId:c,shell:L??void 0,runtimeType:ce||void 0},v)}async function Ll(){if(!at||de)return;const v=await is(),y=v.length>0?v:Q,L=ms(y,ye);if(Xf(y,le,r.ui.osFamily)){Ce(L??""),R(!0);return}await Dl()}async function Pl(){const c=at;if(!c||de)return;const v=Q.length>0?Q:await is(),y=ms(v.length>0?v:Q,ye);await Vs({workspaceId:c,shell:y??void 0,runtimeType:ps(ce,r.ui.osFamily)},T.current,{onCreated:()=>{R(!1)}})}async function Al(){const c=at;if(!c||de)return;const v=Bl;!v||!v.available||await Vs({workspaceId:c,shell:v.value,runtimeType:ps(ce,r.ui.osFamily)},"primary",{onCreated:()=>{Se(!1),ve(!1)}})}async function In(c,v){return Ri(v,"deleting"),Us(v,"deleting"),await oh(v),Ln(c,v,"deleting")}async function Xs(c){if(!N||Ei[c])return;const v=N,y=mr(c);F(null),Ri(c,"closing"),Us(c,"closing"),(async()=>{try{await sh(c);const L=await Ln(v,c,"closing");if(L==="workspace_changed"){Fs(y);return}if(L==="timeout"){bt({id:y,title:w("terminal.closed"),description:w("terminal.closeSyncDelayed"),tone:"warning"});return}if(!oe.current.some(me=>me.id===c)){bt({id:y,title:w("terminal.deleted"),tone:"success"});return}const G=await In(v,c);if(G==="workspace_changed"){Fs(y);return}if(G==="timeout"){bt({id:y,title:w("terminal.deleted"),description:w("terminal.deleteSyncDelayed"),tone:"warning"});return}bt({id:y,title:w("terminal.deleted"),tone:"success"})}catch(L){bt({id:y,title:L instanceof Error?L.message:w("terminal.closeFailed"),tone:"error"})}finally{Ri(c,null)}})()}async function Nn(c){if(!N||Ei[c])return;const v=N,y=mr(c);F(null),Ri(c,"deleting"),Us(c,"deleting"),(async()=>{try{const L=await In(v,c);if(L==="workspace_changed"){Fs(y);return}if(L==="timeout"){bt({id:y,title:w("terminal.deleted"),description:w("terminal.deleteSyncDelayed"),tone:"warning"});return}bt({id:y,title:w("terminal.deleted"),tone:"success"})}catch(L){bt({id:y,title:L instanceof Error?L.message:w("terminal.deleteFailed"),tone:"error"})}finally{Ri(c,null)}})()}async function On(c){if(!N)return;const v=le?"primary":T.current;try{const y=await qs({workspaceId:N,cwd:c.cwd,shell:c.shell,runtimeType:c.runtimeType});if(!y)return;Ys(y,v),F(null),await qt(N,{preferredTerminalId:y.id,preferredPaneId:v}),Ze(w("terminal.duplicateSuccess"),"success")}catch(y){Ze(y instanceof Error?y.message:w("terminal.duplicateFailed"),"error")}}async function Il(){const c=Ye;if(!c)return;const v=le?"primary":T.current;St(!0),dt(v);try{const y=await qs({...c,runtimeType:"embedded-pty"},{allowFallbackPrompt:!1});if(!y){pi(v);return}Ys(y,v),Te("embedded-pty"),ot(null),R(!1),Se(!1),pi(v),await qt(c.workspaceId,{preferredTerminalId:y.id,preferredPaneId:v}),Ze(w("terminal.created"),"success")}catch(y){pi(v),Ze(y instanceof Error?y.message:w("terminal.createFailed"),"error")}finally{St(!1)}}function Fn(c){N&&(ts(v=>{const y=v.includes(c)?v.filter(L=>L!==c):[c,...v];return jo(N,y),y}),F(null))}function Hn(c){var y;const v=Yi(c,It,Ut,fi);v&&((y=x.current[v])==null||y.disconnect(),Kt(L=>({...L,[v]:null})),jt(L=>({...L,[v]:"closed"})),ui(L=>L.includes(c)?L:[...L,c]),F(null),Ze(w("terminal.disconnected"),"warning"))}function zn(c){var y;const v=Yi(c,It,Ut,fi);v&&(ui(L=>L.filter(G=>G!==c)),jt(L=>({...L,[v]:"reconnecting"})),(y=x.current[v])==null||y.reconnect(),F(null),Ze(w("terminal.reconnectRequested")))}function Gs(c){xl(pn(c))}function Zs(c){if(!le){if(c==="single"){Kt(v=>({primary:T.current==="secondary"?v.secondary??v.primary:v.primary,secondary:null})),js("single"),_i("primary");return}js(c),Kt(v=>gs({terminals:ae,currentBindings:v,splitDirection:c,fallbackTerminalId:v[T.current]??v.primary,preferredPaneId:T.current}))}}async function Nl(){if(Je)try{const c=s_({terminalId:Je.id,splitDirection:Ut,paneBindings:It,paneApiById:x.current});if(!c.trim()){Ze(w("terminal.logEmpty"),"warning");return}const v=new Date().toISOString().replace(/[:.]/g,"-"),L=`${d_(Je.name||"terminal")}-${v}.log`;u_(L,c),Ze(w("terminal.saveLogSuccess"),"success")}catch(c){Ze(c instanceof Error?c.message:w("terminal.saveLogFailed"),"error")}}function Wn(c){if(le){if(c==="right"){o.trigger("gesture"),ve(!0);return}o.trigger("gesture"),ve(!1)}}function Ol(c){if(!le||ge)return;const v=c.touches[0];v&&(Z.current={x:v.clientX,y:v.clientY})}function Fl(c){if(!le||ge){Z.current=null;return}const v=Z.current,y=c.changedTouches[0];if(Z.current=null,!v||!y)return;const L=y.clientX-v.x,G=y.clientY-v.y;Math.abs(L)<_n||Math.abs(G)>mn||Math.abs(L)<=Math.abs(G)||L<0||Wn("right")}const Hl=b.useCallback(async(c,v)=>{const y=await Zl(r,{workspaceId:c,workspaceName:v,focusOwner:"terminal-page"});y.ok||bt({title:y.detail??w("terminal.openExternalFailed"),tone:"error"})},[r,bt]);return m.jsxs("main",{className:`terminal-layout${i?" terminal-layout-embedded":" mobile-page-fixed-root"}`,"data-embedded":i?"true":void 0,children:[m.jsx(ah,{open:Ye!==null,busy:Ct,onClose:()=>{Ct||ot(null)},onConfirmFallback:()=>{Il()}}),m.jsx("section",{ref:D,className:"terminal-shell","data-mobile":le,"data-mobile-list-open":le?ge:void 0,style:le?Ml:void 0,children:le?m.jsxs(m.Fragment,{children:[m.jsx(th,{containerRef:O,currentWorkspace:kl,workspaces:B,onSelectWorkspace:c=>{_(c),ne(c)},trailing:m.jsx("button",{type:"button",className:"secondary-button mobile-tools-more-button","aria-label":w("terminal.mobileDrawerAction"),title:w("terminal.mobileDrawerAction"),"aria-expanded":ge,onClick:()=>{ve(c=>!c)},children:m.jsx(gl,{})})}),m.jsx(Af,{open:ge,terminals:kn,pinnedTerminalIds:Ti,activeTerminalId:(Je==null?void 0:Je.id)??null,creatingTerminal:de,paneBindings:It,splitDirection:Ut,activePaneId:fi,paneConnectionStates:Ws,terminalMutations:Ei,manuallyDisconnectedTerminalIdSet:zs,onClose:()=>{ve(!1)},onCreateTerminal:()=>{ve(!1),An()},onSelectTerminal:c=>{Bi(c,"primary"),ve(!1)},onBindToActivePane:c=>{Ks(c),ve(!1)},onBindToPane:Bi,onDuplicate:On,onDisconnect:Hn,onReconnect:zn,onCloseTerminal:Xs,onDeleteTerminal:Nn,onTogglePin:Fn}),m.jsxs("div",{className:"terminal-stage-surface terminal-stage-surface-mobile",children:[m.jsx("div",{className:"terminal-mobile-edge-swipe-zone","aria-hidden":"true",onTouchStart:Ol,onTouchEnd:Fl,onTouchCancel:()=>{Z.current=null}}),m.jsx("div",{className:"terminal-stage-grid","data-layout":"single","data-mobile":"true",children:m.jsx(ta,{paneId:"primary",paneLabel:w("terminal.panePrimary"),terminal:Je,pendingCreation:!Je&&nt==="primary",zoomScale:ei,active:!0,ownsTerminalSize:Rn,isMobileLayout:!0,onActivate:Pn,onSwipeGesture:Wn,onConnectionChange:Mn,onTerminalStatus:Dn,onRequireReload:Bn,onUnauthorized:Cn,registerApi:yn,notifyTerminal:Ze,canCreateTerminal:!!at,onRequestCreateTerminal:()=>{An()},onRequestOpenTerminalDrawer:()=>{ve(!0)}},`mobile-${(Je==null?void 0:Je.id)??"empty"}`)})]}),m.jsx(ea,{open:vt,loading:K,creating:de,shellChoices:xt,osFamily:r.ui.osFamily,selectedShell:Ne,runtimeType:ps(ce,r.ui.osFamily),title:w("terminal.mobileCreateSheetTitle"),shellLabel:w("terminal.mobileCreateShellLabel"),shellDescription:w("terminal.mobileCreateShellDescription"),runtimeLabel:w("terminal.mobileCreateRuntimeLabel"),runtimeDescription:w("terminal.mobileCreateRuntimeDescription"),confirmLabel:w("terminal.mobileCreateConfirm"),onClose:()=>{de||Se(!1)},onSelectShell:ct,onSelectRuntime:c=>{Te(c)},onConfirm:()=>{Al()}})]}):m.jsxs(m.Fragment,{children:[m.jsx("header",{className:"terminal-tabbar","data-window-drag-handle":"terminal-tabbar","data-tauri-drag-region":n,children:m.jsxs("div",{ref:U,className:"terminal-tabbar-main","data-tauri-drag-region":n,children:[m.jsxs("div",{ref:W,className:"terminal-tabbar-scroll",role:"tablist","aria-label":w("terminal.title"),"data-window-drag":"ignore",children:[kn.map(c=>{const v=c.id===Nt,y=Ti.has(c.id),L=(M==null?void 0:M.terminalId)===c.id,G=Ei[c.id]??null,me=G?"creating":gn({terminal:c,paneBindings:It,paneConnectionStates:Ws,manuallyDisconnectedTerminalIdSet:zs});return m.jsxs("div",{className:"terminal-tab-shell","data-active":v,"data-assigned":h_(c.id,It,Ut),children:[m.jsx("button",{className:"terminal-tab","data-active":v,type:"button",role:"tab","aria-selected":v,"aria-busy":G!==null,onClick:()=>{v||o.trigger("selection"),Ks(c.id)},onAuxClick:ue=>{ue.button!==1||G!==null||(ue.preventDefault(),Xs(c.id))},children:m.jsx("span",{className:"terminal-tab-name",children:m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"terminal-tab-status-dot","data-status":me,"aria-hidden":"true"}),y?m.jsx("span",{className:"terminal-tab-pin-indicator",children:"•"}):null,m.jsx("span",{className:"terminal-tab-name-text",children:c.name}),m.jsx("span",{className:"terminal-tab-runtime",title:Kn(c.runtimeType,r.ui.osFamily),children:pr(c.runtimeType,r.ui.osFamily)}),G?m.jsxs("span",{className:"terminal-tab-operation","data-operation":G,children:[m.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),G==="closing"?w("terminal.closePendingBadge"):w("terminal.deletePendingBadge")]}):null]})})}),m.jsx("button",{ref:ue=>{H.current[c.id]=ue},className:"terminal-tab-inline-action",type:"button","data-open":L,disabled:G!==null,"aria-haspopup":"menu","aria-label":w("terminal.moreActions"),"aria-expanded":L,onClick:ue=>{if(ue.stopPropagation(),L){F(null);return}F(Hs(c.id,ue.currentTarget)??{terminalId:c.id,top:0,left:0})},children:"⋯"})]},c.id)}),nt?m.jsx("div",{className:"terminal-tab-shell",role:"presentation","data-active":Nt===null&&Pt===nt,"data-assigned":"false","data-pending":"true",children:m.jsx("div",{className:"terminal-tab","aria-hidden":"true",children:m.jsxs("span",{className:"terminal-tab-name",children:[m.jsx("span",{className:"terminal-tab-status-dot","data-status":"creating","aria-hidden":"true"}),m.jsx("span",{className:"terminal-tab-name-text",children:w("terminal.creating")}),m.jsx("span",{className:"terminal-tab-runtime",title:Kn(ce||void 0,r.ui.osFamily),children:pr(ce||void 0,r.ui.osFamily)})]})})}):null,m.jsx("button",{className:"terminal-tab-control",type:"button","aria-label":w("terminal.createButton"),title:w("terminal.createButton"),disabled:!N||de,onClick:()=>{Ll()},children:m.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:m.jsx("svg",{viewBox:"0 0 16 16",focusable:"false",children:m.jsx("path",{d:"M8 3.25a.75.75 0 0 1 .75.75v3.25H12a.75.75 0 0 1 0 1.5H8.75V12a.75.75 0 0 1-1.5 0V8.75H4A.75.75 0 0 1 4 7.25h3.25V4A.75.75 0 0 1 8 3.25Z"})})})})]}),m.jsx("div",{className:"terminal-tabbar-inline-actions",children:m.jsxs("div",{className:"terminal-toolbar-anchor","data-window-drag":"ignore",children:[m.jsx("div",{ref:j,className:"terminal-toolbar-inline","data-open":fe,"aria-hidden":!fe,"data-window-drag":"ignore",children:m.jsxs("div",{className:"terminal-toolbar-cluster",children:[El?m.jsx("button",{type:"button",className:"terminal-toolbar-menu-action",onClick:()=>{at&&(Be(!1),Hl(at,(At==null?void 0:At.name)??null))},children:w("terminal.openExternalAction")}):null,m.jsxs("div",{className:"terminal-toolbar-section",children:[m.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.runtimeField")}),m.jsx("select",{className:"terminal-runtime-select",value:ce,"aria-label":w("terminal.runtimeField"),title:($n=En.find(c=>c.value===ce))==null?void 0:$n.description,onChange:c=>{Te(c.target.value)},children:En.map(c=>m.jsx("option",{value:c.value,children:c.label},c.value||"auto"))})]}),m.jsxs("div",{className:"terminal-toolbar-section",children:[m.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.zoomLabel")}),m.jsxs("div",{className:"terminal-zoom-group","aria-label":w("terminal.zoomLabel"),children:[m.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":w("terminal.zoomOutAction"),onClick:()=>{Gs(ei-Vo)},children:"-"}),m.jsx("button",{type:"button",className:"terminal-zoom-value","aria-label":w("terminal.zoomResetAction"),onClick:()=>{Gs(1)},children:i_(ei)}),m.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":w("terminal.zoomInAction"),onClick:()=>{Gs(ei+Vo)},children:"+"})]})]}),m.jsxs("div",{className:"terminal-toolbar-section",children:[m.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.layoutLabel")}),m.jsxs("div",{className:"terminal-layout-switcher",children:[m.jsx("button",{type:"button",className:"terminal-layout-button","data-active":Lt==="single","aria-label":w("terminal.layoutSingleAction"),onClick:()=>{Zs("single")},children:"1"}),m.jsx("button",{type:"button",className:"terminal-layout-button","data-active":Lt==="vertical","aria-label":w("terminal.layoutVerticalAction"),onClick:()=>{Zs("vertical")},children:"||"}),m.jsx("button",{type:"button",className:"terminal-layout-button","data-active":Lt==="horizontal","aria-label":w("terminal.layoutHorizontalAction"),onClick:()=>{Zs("horizontal")},children:"="})]})]}),m.jsx("button",{type:"button",className:"terminal-toolbar-save",disabled:!Je,onClick:()=>{Nl()},children:w("terminal.saveLogAction")})]})}),m.jsx("button",{ref:se,type:"button",className:"terminal-toolbar-toggle terminal-toolbar-toggle-tool","data-open":fe,"aria-label":w("terminal.toolbarToggleAction"),"aria-expanded":fe,onClick:()=>{F(null),Be(c=>!c)},children:m.jsx("span",{className:"terminal-toolbar-icon terminal-toolbar-icon-tool","aria-hidden":"true",children:m.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",focusable:"false",children:[m.jsx("path",{d:"M13.1 3.3a3.1 3.1 0 0 0-2.4 3.77L4.95 12.82a1.5 1.5 0 1 0 2.12 2.12l5.74-5.74a3.1 3.1 0 0 0 3.77-2.4l-1.76.5a1.06 1.06 0 0 1-1.04-.28l-1.3-1.3a1.06 1.06 0 0 1-.28-1.04l.9-1.38Z",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"m5.85 11.92 2.22 2.22",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round"})]})})})]})}),M&&$s?m.jsx(Of,{ref:E,actionMenu:M,terminal:$s,paneBindings:It,splitDirection:Ut,activePaneId:fi,paneConnectionStates:Ws,pinnedTerminalIdSet:Ti,manuallyDisconnectedTerminalIdSet:zs,pendingMutation:Ei[$s.id]??null,onBindToActivePane:Ks,onBindToPane:Bi,onDuplicate:On,onDisconnect:Hn,onReconnect:zn,onClose:Xs,onDelete:Nn,onTogglePin:Fn,onCloseMenu:()=>{F(null)}}):null]})}),m.jsx("div",{className:"terminal-stage-surface",children:m.jsx("div",{className:"terminal-stage-grid","data-layout":Ut,"data-mobile":"false",children:Rl.map(c=>{const v=It[c],y=ae.find(L=>L.id===v)??null;return m.jsx(ta,{paneId:c,paneLabel:c==="primary"?w("terminal.panePrimary"):w("terminal.paneSecondary"),terminal:y,pendingCreation:!y&&nt===c,zoomScale:ei,active:fi===c,ownsTerminalSize:Rn,onActivate:Pn,onConnectionChange:Mn,onTerminalStatus:Dn,onRequireReload:Bn,onUnauthorized:Cn,registerApi:yn,notifyTerminal:Ze},`${c}-${(y==null?void 0:y.id)??"empty"}`)})})})]})}),m.jsx(ea,{open:C,loading:K,creating:de,shellChoices:xt,osFamily:r.ui.osFamily,selectedShell:ye,runtimeType:ps(ce,r.ui.osFamily),title:w("terminal.createDialogTitle"),shellLabel:w("terminal.mobileCreateShellLabel"),shellDescription:w("terminal.createDialogShellDescription"),runtimeLabel:w("terminal.mobileCreateRuntimeLabel"),runtimeDescription:w("terminal.createDialogRuntimeDescription"),confirmLabel:w("terminal.createDialogConfirm"),onClose:()=>{de||R(!1)},onSelectShell:Ce,onSelectRuntime:c=>{Te(c)},onConfirm:()=>{Pl()}})]})}function Af({open:e,terminals:t,pinnedTerminalIds:i,activeTerminalId:s,creatingTerminal:r,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,terminalMutations:l,manuallyDisconnectedTerminalIdSet:u,onClose:d,onCreateTerminal:_,onSelectTerminal:p,onBindToActivePane:f,onBindToPane:g,onDuplicate:E,onDisconnect:D,onReconnect:U,onCloseTerminal:W,onDeleteTerminal:H,onTogglePin:O}){const j=b.useRef(null),[se,Z]=b.useState(null),V=t.filter(x=>i.has(x.id)),oe=t.filter(x=>!i.has(x.id)),X=t.find(x=>x.id===se)??null;return b.useEffect(()=>{e||Z(null)},[e]),e?m.jsxs(m.Fragment,{children:[m.jsxs("section",{className:"terminal-mobile-list-rail surface-card","aria-label":w("terminal.mobileDrawerTitle"),onTouchStart:x=>{const S=x.touches[0];S&&(j.current={x:S.clientX,y:S.clientY})},onTouchEnd:x=>{const S=j.current,T=x.changedTouches[0];if(j.current=null,!S||!T)return;const P=T.clientX-S.x,B=T.clientY-S.y;Math.abs(P)<_n||Math.abs(B)>mn||Math.abs(P)<=Math.abs(B)||P>=0||d()},onTouchCancel:()=>{j.current=null},children:[m.jsxs("div",{className:"terminal-mobile-list-heading",children:[m.jsx("strong",{children:w("terminal.mobileDrawerTitle")}),m.jsx("p",{children:w("terminal.mobileDrawerDescription")})]}),m.jsxs("div",{className:"terminal-mobile-list-body",children:[V.length>0?m.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[m.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[m.jsx("span",{children:w("terminal.mobilePinnedSectionTitle")}),m.jsx("span",{className:"workbench-section-counter",children:V.length})]}),m.jsx("div",{className:"terminal-mobile-session-list",children:V.map(x=>m.jsx(Qo,{terminal:x,active:x.id===s,pendingMutation:l[x.id]??null,onOpen:p,onOpenMenu:S=>{Z(T=>T===S?null:S)}},x.id))})]}):null,m.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[m.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[m.jsx("span",{children:w("terminal.workspaceField")}),m.jsx("span",{className:"workbench-section-counter",children:oe.length})]}),oe.length>0?m.jsx("div",{className:"terminal-mobile-session-list",children:oe.map(x=>m.jsx(Qo,{terminal:x,active:x.id===s,pendingMutation:l[x.id]??null,onOpen:p,onOpenMenu:S=>{Z(T=>T===S?null:S)}},x.id))}):m.jsx("div",{className:"workbench-session-empty",children:w("terminal.mobileDrawerEmptyDescription")})]})]}),m.jsx("div",{className:"terminal-mobile-list-footer",children:m.jsxs("button",{type:"button",className:"workbench-import-toggle terminal-mobile-list-create",disabled:r,onClick:_,children:[m.jsx("span",{className:"workbench-import-toggle-symbol",children:"+"}),m.jsx("span",{className:"workbench-import-toggle-label",children:w("terminal.createButton")})]})})]}),m.jsx(If,{terminal:X,pendingMutation:X?l[X.id]??null:null,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,pinnedTerminalIdSet:i,manuallyDisconnectedTerminalIdSet:u,onClose:()=>{Z(null)},onBindToActivePane:x=>{Z(null),f(x)},onBindToPane:(x,S)=>{Z(null),g(x,S)},onDuplicate:async x=>{Z(null),await E(x)},onDisconnect:x=>{Z(null),D(x)},onReconnect:x=>{Z(null),U(x)},onCloseTerminal:async x=>{Z(null),await W(x)},onDeleteTerminal:async x=>{Z(null),await H(x)},onTogglePin:x=>{Z(null),O(x)}})]}):null}function Qo({terminal:e,active:t,pendingMutation:i,onOpen:s,onOpenMenu:r}){return m.jsxs("article",{className:"terminal-mobile-session-card","data-active":t,children:[m.jsxs("button",{type:"button",className:"terminal-mobile-session-primary","data-active":t?"true":"false",onClick:()=>{s(e.id)},children:[m.jsxs("div",{className:"terminal-mobile-session-title-row",children:[m.jsx("span",{className:t_(e.status)}),m.jsx("span",{className:"terminal-mobile-session-title",title:e.name,children:e.name}),m.jsx("span",{className:"terminal-mobile-session-runtime-badge",children:pr(e.runtimeType)})]}),m.jsx("div",{className:"terminal-mobile-session-path",title:e.cwd,children:e.cwd}),i?m.jsxs("div",{className:"terminal-mobile-session-operation",children:[m.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),m.jsx("span",{children:i==="closing"?w("terminal.closePendingBadge"):w("terminal.deletePendingBadge")})]}):null]}),m.jsx("button",{type:"button",className:"terminal-mobile-session-action","aria-label":w("terminal.moreActions"),title:w("terminal.moreActions"),onClick:n=>{n.stopPropagation(),r(e.id)},children:m.jsx(gl,{})})]})}function If({terminal:e,pendingMutation:t,paneBindings:i,splitDirection:s,activePaneId:r,paneConnectionStates:n,pinnedTerminalIdSet:o,manuallyDisconnectedTerminalIdSet:a,onClose:h,onBindToActivePane:l,onBindToPane:u,onDuplicate:d,onDisconnect:_,onReconnect:p,onCloseTerminal:f,onDeleteTerminal:g,onTogglePin:E}){if(!e||typeof document>"u")return null;const D=o.has(e.id),U=Yi(e.id,i,s,r),W=U?n[U]:"closed",H=gn({terminal:e,paneBindings:i,paneConnectionStates:n,manuallyDisconnectedTerminalIdSet:a}),O=t===null&&e.status==="running"&&H!=="disconnected",j=t===null&&!O,se=t===null&&U!==null&&e.status==="running";return m.jsxs(ma,{open:!0,title:w("terminal.moreActions"),description:e.name,kind:"action",height:"auto",className:"terminal-mobile-action-sheet",cardClassName:"terminal-mobile-action-sheet-card",bodyClassName:"terminal-mobile-action-list",onClose:h,children:[s!=="single"?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{u(e.id,"primary")},children:w("terminal.bindToPrimaryPaneAction")}),m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.secondary===e.id,onClick:()=>{u(e.id,"secondary")},children:w("terminal.bindToSecondaryPaneAction")})]}):m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{l(e.id)},children:w("terminal.bindToPaneAction")}),m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{d(e)},children:w("terminal.duplicateAction")}),se?W==="connected"?m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{_(e.id)},children:w("terminal.disconnectAction")}):m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{p(e.id)},children:w("terminal.reconnectAction")}):null,O?m.jsx("button",{type:"button",className:"terminal-mobile-action-item",onClick:()=>{f(e.id)},children:w("terminal.closeButton")}):null,j?m.jsx("button",{type:"button",className:"terminal-mobile-action-item danger",onClick:()=>{g(e.id)},children:w("terminal.deleteAction")}):null,m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{E(e.id)},children:D?w("terminal.unpinAction"):w("terminal.pinAction")})]})}function Nf(e,t,i,s){b.useEffect(()=>{const r=e.current,n=t.current;if(!i||!r){r&&r.style.removeProperty("--terminal-mobile-header-height");return}if(!n){r.style.removeProperty("--terminal-mobile-header-height");return}const o=r,a=n;function h(){!e.current||!a.isConnected||o.style.setProperty("--terminal-mobile-header-height",`${a.offsetHeight}px`)}h();const l=typeof ResizeObserver<"u"?new ResizeObserver(h):null;return l==null||l.observe(a),window.addEventListener("resize",h),()=>{l==null||l.disconnect(),window.removeEventListener("resize",h),r.style.removeProperty("--terminal-mobile-header-height")}},[i,t,s,e])}function ea({open:e,loading:t,creating:i,shellChoices:s,osFamily:r,selectedShell:n,runtimeType:o,title:a,shellLabel:h,shellDescription:l,runtimeLabel:u,runtimeDescription:d,confirmLabel:_,onClose:p,onSelectShell:f,onSelectRuntime:g,onConfirm:E}){if(!e||typeof document>"u")return null;const D=s.find(O=>O.value===n)??s[0]??null,U=ga(r).find(O=>O.value==="tmux")??null,W=[{value:"tmux",title:(U==null?void 0:U.label)??w("terminal.mobileRuntimePersistentTitle"),description:(U==null?void 0:U.description)??w("terminal.mobileRuntimePersistentDescription")},{value:"embedded-pty",title:w("terminal.mobileRuntimeSessionTitle"),description:w("terminal.mobileRuntimeSessionDescription")}],H=i||t||!D||!D.available;return m.jsxs(ma,{open:!0,title:a,kind:"form",height:"three-quarter",className:"terminal-mobile-create-sheet",cardClassName:"terminal-mobile-create-sheet-card",bodyClassName:"terminal-mobile-create-sheet-body",dismissible:!i,onClose:p,children:[m.jsxs("section",{className:"terminal-mobile-create-section",children:[m.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[m.jsx("strong",{children:h}),m.jsx("p",{children:l})]}),t&&s.length===0?m.jsxs("div",{className:"terminal-mobile-create-loading",children:[m.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),m.jsx("span",{children:w("terminal.mobileCreateLoadingShells")})]}):m.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:s.map(O=>{const j=O.value===n;return m.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":j?"true":"false",disabled:!O.available||i,onClick:()=>{f(O.value)},children:[m.jsxs("span",{className:"terminal-mobile-choice-copy",children:[m.jsx("strong",{children:O.label}),m.jsx("span",{children:O.description})]}),!O.available&&O.unavailableReason?m.jsx("span",{className:"terminal-mobile-choice-badge terminal-mobile-choice-badge-muted",children:O.unavailableReason}):j?m.jsx("span",{className:"terminal-mobile-choice-badge",children:w("settings.enabled")}):null]},O.id)})})]}),m.jsxs("section",{className:"terminal-mobile-create-section",children:[m.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[m.jsx("strong",{children:u}),m.jsx("p",{children:d})]}),m.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:W.map(O=>{const j=O.value===o;return m.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":j?"true":"false",disabled:i,onClick:()=>{g(O.value)},children:[m.jsxs("span",{className:"terminal-mobile-choice-copy",children:[m.jsx("strong",{children:O.title}),m.jsx("span",{children:O.description})]}),j?m.jsx("span",{className:"terminal-mobile-choice-badge",children:w("settings.enabled")}):null]},O.value)})})]}),m.jsx("button",{type:"button",className:"terminal-mobile-primary-action terminal-mobile-create-confirm",disabled:H,onClick:E,children:i?w("terminal.creating"):_})]})}function gl(){return m.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[m.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),m.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),m.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}const Of=b.forwardRef(function({actionMenu:t,terminal:i,pendingMutation:s,paneBindings:r,splitDirection:n,activePaneId:o,paneConnectionStates:a,pinnedTerminalIdSet:h,manuallyDisconnectedTerminalIdSet:l,onBindToActivePane:u,onBindToPane:d,onDuplicate:_,onDisconnect:p,onReconnect:f,onClose:g,onDelete:E,onTogglePin:D,onCloseMenu:U},W){const H=h.has(i.id),O=Yi(i.id,r,n,o),j=O?a[O]:"closed",se=gn({terminal:i,paneBindings:r,paneConnectionStates:a,manuallyDisconnectedTerminalIdSet:l}),Z=s===null&&i.status==="running"&&se!=="disconnected",V=s===null&&!Z,oe=s===null&&O!==null&&i.status==="running",X=n!=="single";return m.jsxs("div",{ref:W,className:"terminal-tab-menu",role:"menu",style:{top:`${t.top}px`,left:`${t.left}px`},onClick:x=>{x.stopPropagation()},children:[X?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{d(i.id,"primary")},children:w("terminal.bindToPrimaryPaneAction")}),m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.secondary===i.id,onClick:()=>{d(i.id,"secondary")},children:w("terminal.bindToSecondaryPaneAction")})]}):m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{u(i.id)},children:w("terminal.bindToPaneAction")}),m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{U(),_(i)},children:w("terminal.duplicateAction")}),oe?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),j==="connected"?m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{p(i.id)},children:w("terminal.disconnectAction")}):m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{f(i.id)},children:w("terminal.reconnectAction")})]}):null,m.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),Z?m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{U(),g(i.id)},children:w("terminal.closeButton")}):null,V?m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{E(i.id)},children:w("terminal.deleteAction")}):null,m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{D(i.id)},children:H?w("terminal.unpinAction"):w("terminal.pinAction")})]})});function ta({paneId:e,paneLabel:t,terminal:i,pendingCreation:s,zoomScale:r,active:n,ownsTerminalSize:o,isMobileLayout:a=!1,canCreateTerminal:h=!0,onActivate:l,onSwipeGesture:u,onConnectionChange:d,onTerminalStatus:_,onRequireReload:p,onUnauthorized:f,registerApi:g,notifyTerminal:E,onRequestCreateTerminal:D,onRequestOpenTerminalDrawer:U}){const W=pa(),H=b.useRef(null),O=b.useRef(null),j=b.useRef(null),se=b.useRef(null),Z=b.useRef(null),V=b.useRef(null),oe=b.useRef(null),X=b.useRef(null),x=b.useRef(null),S=b.useRef(!0),T=b.useRef(!1),P=b.useRef(null),B=b.useRef((i==null?void 0:i.status)??null),$=b.useRef(!1),I=b.useRef([]),N=b.useRef(n),[ne,ce]=b.useState(null),Te=!a,Q=b.useCallback(C=>{var R;C&&((R=Z.current)==null||R.sendInput(C))},[]),ee=b.useCallback(()=>{ce(null)},[]),ye=b.useCallback(()=>{const C=V.current,R=typeof(C==null?void 0:C.terminal.getSelection)=="function"?C.terminal.getSelection():"";if(R.trim())return R.trim();const K=typeof document>"u"?null:document.getSelection();return(K==null?void 0:K.toString().trim())??""},[]),Ce=b.useCallback(async()=>{var K;const C=(ne==null?void 0:ne.text)??ye();if(!C){ee();return}const R=await W.bridge.writeClipboardText(C);if(!R.ok){E(R.detail||w("common.copyFailed"),"error");return}ee(),(K=V.current)==null||K.focus()},[ee,E,W.bridge,ye,ne==null?void 0:ne.text]),Ne=b.useCallback(C=>{const R=Number(C);!Number.isInteger(R)||R<=0||(X.current=X.current===null?R:Math.min(X.current,R),x.current=X.current)},[]),ct=b.useCallback(async C=>{const R=V.current;if(!R)return;if(!C.content){S.current=C.hasMore,x.current=C.nextBeforeSeq;return}const K=bl(R.readPlainText()),re=C.replaceContent?Math.max(0,C.lineCount-K):C.anchorLine;await R.prependHistory(C.content,re,{replaceContent:C.replaceContent===!0}),X.current=C.nextBeforeSeq??X.current,x.current=C.nextBeforeSeq,S.current=C.hasMore,R.schedulePersist()},[]),ge=b.useCallback(()=>{const C=V.current;return C?C.terminal.buffer.active.baseY===0:!1},[]),ve=b.useCallback(async()=>{if(!(i!=null&&i.id)||T.current||!S.current)return;const C=x.current;if(C!==null){T.current=!0;try{let R=C,K=Tf;for(;R!==null&&K>0;){const re=await rh(i.id,{beforeSeq:R,limit:Ef});if(await ct(re),K-=1,!re.hasMore||!ge())break;R=re.nextBeforeSeq}}catch(R){E(R instanceof Error?R.message:w("conversation.historyLoadFailed"),"error")}finally{T.current=!1}}},[ct,E,ge,i==null?void 0:i.id]);b.useEffect(()=>{B.current=(i==null?void 0:i.status)??null},[i==null?void 0:i.status]),b.useEffect(()=>{ee()},[ee,i==null?void 0:i.id]),b.useEffect(()=>{N.current=n},[n]),b.useEffect(()=>{var C;n&&((C=V.current)==null||C.focus())},[n,i==null?void 0:i.id]),b.useEffect(()=>{if(!ne)return;function C(K){var ae;const re=K.target;re&&(((ae=j.current)==null?void 0:ae.contains(re))??!1)||ee()}function R(K){K.key==="Escape"&&ee()}return window.addEventListener("mousedown",C),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),window.addEventListener("keydown",R),()=>{window.removeEventListener("mousedown",C),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),window.removeEventListener("keydown",R)}},[ee,ne]),b.useEffect(()=>{var C,R;(C=V.current)==null||C.setFontSize(ha(r)),(R=V.current)==null||R.reflow()},[r]),b.useEffect(()=>{var R;const C=V.current;C&&(C.reflow(),o&&((R=Z.current)==null||R.sendCurrentDimensions(C.terminal.cols,C.terminal.rows)))},[o,i==null?void 0:i.id]),b.useEffect(()=>{if(typeof document>"u")return;const C=()=>{var K;(K=V.current)==null||K.applyTheme()};C();const R=new MutationObserver(K=>{K.some(re=>re.attributeName==="data-theme")&&C()});return R.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{R.disconnect()}},[i==null?void 0:i.id]),b.useEffect(()=>{var K;if((K=V.current)==null||K.dispose(),V.current=null,g(e,null),!(i!=null&&i.id)||!H.current)return;const C=en(i.id).viewState,R=Ff({container:H.current,restoredViewState:C,fontSize:ha(r),enableTouchMomentum:a,getCursor:()=>oe.current,getHistoryPaging:()=>({beforeSeq:x.current,hasOlder:S.current}),canResize:()=>B.current==="running"&&o,onInput:Q,onResize:({cols:re,rows:ae})=>{var Re;o&&((Re=Z.current)==null||Re.resize(re,ae))},onViewportTop:()=>{ve()},onCursorChange:re=>{$d(i.id,re)},onViewStateChange:re=>{jd(i.id,re)}});return V.current=R,g(e,{focus:()=>{R.focus()},readPlainText:()=>R.readPlainText(),disconnect:()=>{var re;(re=Z.current)==null||re.disconnect()},reconnect:()=>{var re;(re=Z.current)==null||re.reconnectNow()}}),()=>{R.persistNow(),R.dispose(),V.current===R&&(V.current=null),g(e,null)}},[Q,ve,o,e,g,i==null?void 0:i.id,r]),b.useEffect(()=>{var ae,Re;if((ae=Z.current)==null||ae.close(),Z.current=null,P.current=null,(Re=V.current)==null||Re.suspendInputForwarding(),d(e,"closed"),!(i!=null&&i.id)){oe.current=null,X.current=null,x.current=null,S.current=!0,T.current=!1,$.current=!1,I.current=[];return}const C=en(i.id),R=C.viewState,K=C.resumeCursor;oe.current=K,X.current=(R==null?void 0:R.historyBeforeSeq)??null,x.current=(R==null?void 0:R.historyBeforeSeq)??null,S.current=(R==null?void 0:R.historyHasOlder)===!1&&i.runtimeType==="tmux"?!0:(R==null?void 0:R.historyHasOlder)??!0,T.current=!1,$.current=!1,I.current=[];const re=new nf({terminalId:i.id,lastCursor:K,onConnectionChange:q=>{var Y;q!=="connected"&&((Y=V.current)==null||Y.suspendInputForwarding()),d(e,q)},onSubscribed:()=>{var Y;const q=V.current;q&&(q.suspendInputForwarding(),q.reflow(),o&&re.sendCurrentDimensions(q.terminal.cols,q.terminal.rows),q.resumeInputForwarding(i.runtimeType==="tmux"?cf:0)),N.current&&((Y=V.current)==null||Y.focus())},onBackfill:q=>{var dt,M;const Y=V.current,de=Os(q.chunks),ut=Y==null?void 0:Y.shouldAutoRevealLatest();Y&&(q.cursorReset?(ra(Y.terminal,de,()=>{ut&&Y.revealLatest()}),X.current=null):Y.restoredFromSnapshot?sa(Y.terminal,de,()=>{ut&&Y.revealLatest()}):(ra(Y.terminal,de,()=>{ut&&Y.revealLatest()}),X.current=null)),$.current=!0,de.length>0&&Ne((dt=de[0])==null?void 0:dt.cursor);const nt=q.latestCursor??oe.current;if(oe.current=nt,Y==null||Y.scheduleCursorPersist(nt),Y&&I.current.length>0){const F=zf(I.current,q.latestCursor);if(I.current=[],F.length>0){sa(Y.terminal,F);const fe=((M=F.at(-1))==null?void 0:M.cursor)??nt;oe.current=fe,Y.scheduleCursorPersist(fe)}}if(P.current==="idle_closed"){E(w("terminal.recoveryIdleClosed"),"warning");return}if(K){E(q.truncated?w("terminal.recoveryTruncated"):w("terminal.recoveryComplete"),q.truncated?"warning":"success");return}R!=null&&R.content||E(w("terminal.connectedHint"))},onOutput:q=>{const Y=V.current,de=!$.current,ut=Y==null?void 0:Y.shouldAutoRevealLatest();if(de){I.current=[...I.current,q.chunk],oe.current=q.chunk.cursor,Y==null||Y.scheduleCursorPersist(q.chunk.cursor);return}if(Y&&ai()){const nt=Rt();Y.terminal.write(q.chunk.content,()=>{ji("terminal.output.rendered",{terminalId:i.id,cursor:q.chunk.cursor,charCount:q.chunk.content.length,renderMs:Rt()-nt}),ut&&Y.revealLatest()})}else Y==null||Y.terminal.write(q.chunk.content,()=>{ut&&(Y==null||Y.revealLatest())});oe.current=q.chunk.cursor,Ne(q.chunk.cursor),Y==null||Y.scheduleCursorPersist(q.chunk.cursor)},onStatus:q=>{if(_({id:q.terminal.id,status:q.terminal.status,statusDetail:q.terminal.statusDetail,processId:q.terminal.processId??null}),q.terminal.id===i.id){if(B.current=q.terminal.status,q.terminal.status!=="running"&&d(e,"closed"),q.terminal.status==="closed"&&q.terminal.statusDetail==="TERMINAL_IDLE_TIMEOUT"){P.current="idle_closed",E(w("terminal.recoveryIdleClosed"),"warning");return}q.terminal.status==="error"&&q.terminal.statusDetail&&E(q.terminal.statusDetail,"error")}},onError:q=>{if(q.terminalId===i.id){if(q.error_code==="TERMINAL_NOT_RUNNING"){p();return}q.error_code!=="INVALID_TERMINAL_SIZE"&&E(q.detail,"error")}},onUnauthorized:f});return Z.current=re,re.start(),()=>{re.close(),$.current=!1,I.current=[],d(e,"closed")}},[ve,E,d,p,_,f,e,i==null?void 0:i.id,i==null?void 0:i.runtimeType,o,Ne]);const vt=b.useCallback(C=>{var K;if(!Te||!n||!(i!=null&&i.id)||Gf(C))return;const R=Zf(C.nativeEvent);R&&(C.preventDefault(),C.stopPropagation(),Q(R),(K=V.current)==null||K.focus())},[n,Q,i==null?void 0:i.id,Te]),Se=b.useCallback(C=>{var K;if(!Te||!n||!(i!=null&&i.id)||Sl(C.target))return;const R=C.clipboardData.getData("text");R&&(C.preventDefault(),Q(R),(K=V.current)==null||K.focus())},[n,Q,i==null?void 0:i.id,Te]);return m.jsx("article",{ref:O,className:"terminal-pane-card","data-active":n,"data-empty":!i,tabIndex:i?0:-1,onMouseDown:C=>{ee(),l(e),C.currentTarget.focus({preventScroll:!0})},onClick:()=>{var C;ee(),(C=V.current)==null||C.focus()},onKeyDown:vt,onPaste:Se,onContextMenu:C=>{var de;if(a||!i)return;const R=ye();if(!R){ee();return}const K=(de=O.current)==null?void 0:de.getBoundingClientRect();if(!K)return;C.preventDefault(),l(e);const re=164,ae=52,Re=8,q=Math.max(Re,K.width-re-Re),Y=Math.max(Re,K.height-ae-Re);ce({text:R,left:Ds(C.clientX-K.left,Re,q),top:Ds(C.clientY-K.top,Re,Y)})},onTouchStart:C=>{if(!a)return;const R=C.touches[0];R&&(se.current={x:R.clientX,y:R.clientY})},onTouchEnd:C=>{if(!a||!u){se.current=null;return}const R=se.current,K=C.changedTouches[0];if(se.current=null,!R||!K)return;const re=K.clientX-R.x,ae=K.clientY-R.y;Math.abs(re)<_n||Math.abs(ae)>mn||Math.abs(re)<=Math.abs(ae)||u(re<0?"left":"right")},onTouchCancel:()=>{se.current=null},children:i?m.jsxs("div",{className:"terminal-canvas",children:[m.jsx("div",{ref:H,className:"terminal-xterm"}),ne?m.jsx("div",{ref:j,className:"terminal-selection-menu",style:{top:ne.top,left:ne.left},role:"menu","aria-label":w("common.copy"),onMouseDown:C=>{C.stopPropagation()},onClick:C=>{C.stopPropagation()},onContextMenu:C=>{C.preventDefault(),C.stopPropagation()},children:m.jsx("button",{type:"button",className:"terminal-selection-menu-action",role:"menuitem",onClick:()=>{Ce()},children:w("common.copy")})}):null]}):s?m.jsxs("div",{className:"terminal-empty-state terminal-empty-state-inline terminal-pending-state",children:[m.jsx("span",{className:"terminal-pane-label",children:t}),m.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),m.jsx("h1",{children:w("terminal.creating")}),m.jsx("p",{children:w("terminal.creationPendingDescription")})]}):m.jsxs("div",{className:a?"terminal-empty-state terminal-empty-state-inline terminal-mobile-empty-state":"terminal-empty-state terminal-empty-state-inline",children:[m.jsx("span",{className:"terminal-pane-label",children:t}),m.jsx("h1",{children:a?w("terminal.mobileEmptyTitle"):w("terminal.stageEmptyTitle")}),m.jsx("p",{children:a?w("terminal.mobileEmptyDescription"):w("terminal.splitEmptySubtitle")}),a?m.jsxs("div",{className:"terminal-mobile-empty-actions",children:[m.jsx("button",{type:"button",className:"terminal-mobile-primary-action",disabled:!h,onClick:()=>{D==null||D()},children:w("terminal.createButton")}),m.jsx("button",{type:"button",className:"terminal-mobile-secondary-action",onClick:()=>{U==null||U()},children:w("terminal.mobileDrawerAction")})]}):null]})})}function Ff(e){var de,ut,nt,dt;const t=la(),i=new Ed({cols:((de=e.restoredViewState)==null?void 0:de.cols)??df,rows:((ut=e.restoredViewState)==null?void 0:ut.rows)??ff,cursorBlink:!0,scrollback:2e3,allowTransparency:!1,fontFamily:'"Cascadia Mono", "Cascadia Code", "Consolas", monospace',fontSize:e.fontSize,theme:t}),s=new uh,r=new ph,n=lf(M=>{e.onInput(M)});let o=null,a=null,h=null,l=!1,u=!1,d=!1,_=i.cols,p=i.rows,f=null,g=null;const E=new Set;let D=null,U=0,W=0,H=0,O=null,j=0,se=!1;const Z=()=>{i.focus()};i.loadAddon(s),i.loadAddon(r),i.onData(M=>{n.enqueue(M)});const V=typeof i.onScroll=="function"?i.onScroll(M=>{var F;M===0&&((F=e.onViewportTop)==null||F.call(e)),Se()}):null;i.onResize(({cols:M,rows:F})=>{_=M,p=F,e.canResize()&&e.onResize({cols:M,rows:F}),Se()}),e.container.replaceChildren(),i.open(e.container),aa(e.container,t);const oe=e.container.querySelector(".xterm"),X=e.container.querySelector(".xterm-viewport"),x=X instanceof HTMLElement?X:oe instanceof HTMLElement?oe:e.container,S=oe instanceof HTMLElement?oe:e.container;S.addEventListener("mousedown",Z,{passive:!0}),S.addEventListener("pointerdown",Z,{passive:!0}),x.style.touchAction="pan-y",x.style.overscrollBehavior="contain","webkitOverflowScrolling"in x.style&&(x.style.webkitOverflowScrolling="touch");const T=M=>{var Be;if(u||M.deltaY===0)return!1;const F=i.buffer.active.viewportY===0;return i.buffer.active.baseY>0?!0:(M.deltaY<0&&F&&((Be=e.onViewportTop)==null||Be.call(e)),!1)},P=()=>i.buffer.active.baseY>0||i.buffer.active.viewportY>0,B=()=>{O!==null&&(window.cancelAnimationFrame(O),O=null),j=0},$=M=>{var Ye;if(u||M===0)return!1;const F=i.buffer.active.viewportY===0,fe=i.buffer.active.viewportY;if(P()){i.scrollLines(M);const ot=i.buffer.active.viewportY!==fe;return Se(),ot}return M<0&&F&&((Ye=e.onViewportTop)==null||Ye.call(e)),!1},I=()=>{if(!e.enableTouchMomentum){W=0;return}if(B(),!se||!P()||Math.abs(W)<Go){W=0;return}let M=performance.now(),F=0,fe=0;const Be=Ye=>{if(u){B();return}const ot=Math.max(1,Ye-M);M=Ye,F+=ot,j+=W*ot;const Ct=ia(j);if(Ct!==0){if(fe=0,j-=Ct,!$(Ct)){W=0,B();return}}else fe+=1;if(W*=Math.pow(Mf,ot/16),fe>=Lf||F>=Df||Math.abs(W)<Go){W=0,B();return}O=window.requestAnimationFrame(Be)};O=window.requestAnimationFrame(Be)},N=M=>{const F=M.touches[0];if(B(),W=0,se=!1,H=performance.now(),!F){D=null;return}D={x:F.clientX,y:F.clientY}},ne=M=>{if(!D)return;const F=M.touches[0];if(!F)return;const fe=F.clientX-D.x,Be=F.clientY-D.y;if(Math.abs(Be)<=Math.abs(fe)){D={x:F.clientX,y:F.clientY};return}M.preventDefault();const Ye=performance.now(),ot=Math.max(1,Ye-H);H=Ye;const Ct=-Be/Rf;U+=Ct;const St=ia(U);if(St!==0){U-=St;const Lt=$(St);if(e.enableTouchMomentum&&Lt){const Qi=Ds(St/ot*Bf,-Zo,Zo);W=W===0?Qi:W*.35+Qi*.65,se=!0}else Lt||(W=0,se=!1)}D={x:F.clientX,y:F.clientY}},ce=()=>{D=null,U=0,I()},Te=()=>{D=null,U=0,W=0,se=!1,B()};typeof i.attachCustomWheelEventHandler=="function"&&i.attachCustomWheelEventHandler(T),S.addEventListener("touchstart",N,{passive:!0}),S.addEventListener("touchmove",ne,{passive:!1}),S.addEventListener("touchend",ce,{passive:!0}),S.addEventListener("touchcancel",Te,{passive:!0}),(nt=e.restoredViewState)!=null&&nt.content?i.write(e.restoredViewState.content,()=>{const M=e.restoredViewState;M&&M.viewportY>0&&i.scrollToLine(M.viewportY),ct().then(()=>{K()})}):ct().then(()=>{K()});const Q=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{window.requestAnimationFrame(()=>{C()})});Q==null||Q.observe(e.container),typeof document<"u"&&"fonts"in document&&document.fonts.ready.then(()=>{K()});const ee=()=>{R()},ye=()=>{K()};typeof window<"u"&&(window.addEventListener("resize",ee),window.addEventListener("pageshow",ye),(dt=window.visualViewport)==null||dt.addEventListener("resize",ee));const Ce=()=>{ji("terminal.persist.pagehide",{cursor:e.getCursor()}),ge()},Ne=()=>{document.visibilityState==="hidden"&&(ji("terminal.persist.visibility_hidden",{cursor:e.getCursor()}),ge())};typeof window<"u"&&window.addEventListener("pagehide",Ce),typeof document<"u"&&document.addEventListener("visibilitychange",Ne);async function ct(){for(let M=0;M<10;M+=1){if(oa(e.container))return;await new Promise(F=>{window.requestAnimationFrame(()=>F())})}}function ge(){if(u)return;const M=ai()?Rt():0;o!==null&&(window.clearTimeout(o),o=null);const F=Hf(i,r,e.getCursor(),e.getHistoryPaging());F?(a!==null&&(window.clearTimeout(a),a=null),l=!1):ve(e.getCursor()),e.onViewStateChange(F),ai()&&ji("terminal.persist.completed",{cursor:e.getCursor(),hasViewState:!!F,contentLength:(F==null?void 0:F.content.length)??0,historyBeforeSeq:(F==null?void 0:F.historyBeforeSeq)??null,durationMs:Rt()-M})}function ve(M){u||(a!==null&&(window.clearTimeout(a),a=null),M!==void 0&&(h=M,l=!0),l&&(e.onCursorChange(h),l=!1))}function vt(M){u||(h=M,l=!0,a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{ve()},yf))}function Se(){u||(o!==null&&window.clearTimeout(o),o=window.setTimeout(()=>{ge()},Cf))}function C(){var Be,Ye;if(u)return;const M=Re();if(re(),!oa(e.container))return;const F=Uf(e.container,i,s);if(!F||F.cols<ml||F.rows<pl||d&&F.cols===_&&F.rows===p)return;const fe=vl(i);(i.cols!==F.cols||i.rows!==F.rows)&&((Ye=(Be=fe==null?void 0:fe._renderService)==null?void 0:Be.clear)==null||Ye.call(Be),i.resize(F.cols,F.rows)),d=!0,_=i.cols,p=i.rows,M&&ae()}function R(){if(u)return;const M=window.requestAnimationFrame(()=>{E.delete(M),C()});E.add(M)}function K(){R();const M=window.requestAnimationFrame(()=>{E.delete(M),R()});E.add(M),f!==null&&window.clearTimeout(f),f=window.setTimeout(()=>{f=null,R()},uf)}function re(){const M=$f(e.container.clientHeight);e.container.style.setProperty("--terminal-bottom-gap",`${M}px`)}function ae(){na(e.container,i),Y()}function Re(){return jf(e.container,i)}function q(){const M=la();i.options.theme=M,aa(e.container,M)}function Y(){if(u||typeof window>"u")return;g!==null&&window.cancelAnimationFrame(g);const M=F=>{g=window.requestAnimationFrame(()=>{if(u){g=null;return}if(na(e.container,i),F<=1){g=null;return}M(F-1)})};M(2)}return{terminal:i,restoredFromSnapshot:!!e.restoredViewState,focus:()=>{i.focus()},reflow:()=>{C()},revealLatest:ae,shouldAutoRevealLatest:Re,prependHistory:async(M,F=bl(M),fe={})=>{if(!M)return;const Be=i.buffer.active.viewportY,Ye=ca(i),ot=fe.replaceContent?Ls(M):o_(M,Ye);await new Promise(Ct=>{i.reset(),i.write(a_(ot),()=>{const St=Math.max(0,Be+Math.max(F,0));St>0&&i.scrollToLine(St),Ct()})}),Se()},readPlainText:()=>ca(i),setFontSize:M=>{i.options.fontSize!==M&&(i.options.fontSize=M,C(),Se())},applyTheme:q,persistNow:ge,scheduleCursorPersist:vt,schedulePersist:Se,suspendInputForwarding:()=>{n.suspend()},resumeInputForwarding:(M=0)=>{n.resume(M)},dispose:()=>{var M;u=!0,f!==null&&(window.clearTimeout(f),f=null),g!==null&&(window.cancelAnimationFrame(g),g=null),E.forEach(F=>{window.cancelAnimationFrame(F)}),E.clear(),n.dispose(),o!==null&&window.clearTimeout(o),a!==null&&window.clearTimeout(a),S.removeEventListener("mousedown",Z),S.removeEventListener("pointerdown",Z),S.removeEventListener("touchstart",N),S.removeEventListener("touchmove",ne),S.removeEventListener("touchend",ce),S.removeEventListener("touchcancel",Te),B(),V==null||V.dispose(),Q==null||Q.disconnect(),typeof window<"u"&&(window.removeEventListener("pagehide",Ce),window.removeEventListener("resize",ee),window.removeEventListener("pageshow",ye),(M=window.visualViewport)==null||M.removeEventListener("resize",ee)),typeof document<"u"&&document.removeEventListener("visibilitychange",Ne),i.dispose(),e.container.replaceChildren()}}}function ia(e){return e<0?Math.ceil(e):Math.floor(e)}function Hf(e,t,i,s){const r=t.serialize({scrollback:mf});return!r||r.length>pf?null:{content:r,cursor:i,cols:e.cols,rows:e.rows,viewportY:e.buffer.active.viewportY,historyBeforeSeq:s.beforeSeq,historyHasOlder:s.hasOlder}}function sa(e,t,i){const s=Os(t);if(s.length===0){i==null||i();return}e.write(s.map(r=>r.content).join(""),()=>{i==null||i()})}function ra(e,t,i){e.reset();const s=Os(t);if(s.length===0){i==null||i();return}e.write(s.map(r=>r.content).join(""),()=>{i==null||i()})}function Os(e){if(e.length<2)return e;const t=e.map((i,s)=>({chunk:i,index:s,cursor:Number(i.cursor)}));return t.some(i=>!Number.isFinite(i.cursor))?e:[...t].sort((i,s)=>i.cursor===s.cursor?i.index-s.index:i.cursor-s.cursor).map(i=>i.chunk)}function zf(e,t){const i=Os(e);if(!t)return i;const s=Number(t);return Number.isFinite(s)?i.filter(r=>{const n=Number(r.cursor);return!Number.isFinite(n)||n>s}):i}function Wf(e,t=1){return e.buffer.active.baseY-e.buffer.active.viewportY<=t}function $f(e){return Pf}function jf(e,t){return Wf(t,1)}function na(e,t){t.scrollToBottom()}function oa(e){return e.clientWidth>=gf&&e.clientHeight>=vf}function Uf(e,t,i){const s=i.proposeDimensions(),r=qf(t),n=Kf(e);if(!n||!r)return s??null;const o=n.width,a=n.height;if(!Number.isFinite(o)||!Number.isFinite(a)||o<=0||a<=0||r.width<=0||r.height<=0)return s??null;const h=Math.floor(o/r.width),l=Math.floor(a/r.height);return!Number.isFinite(h)||!Number.isFinite(l)?s??null:{cols:Math.max(ml,h),rows:Math.max(pl,l)}}function Kf(e){var l;const t=e.querySelector(".xterm");if(!(t instanceof HTMLElement))return null;const i=(l=t.ownerDocument.defaultView)==null?void 0:l.getComputedStyle(t),s=_s(i==null?void 0:i.paddingLeft),r=_s(i==null?void 0:i.paddingRight),n=_s(i==null?void 0:i.paddingTop),o=_s(i==null?void 0:i.paddingBottom),a=t.clientWidth-s-r,h=t.clientHeight-n-o;return!Number.isFinite(a)||!Number.isFinite(h)||a<=0||h<=0?null:{width:a,height:h}}function _s(e){if(!e)return 0;const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function qf(e){var r,n,o,a,h;const t=(o=(n=(r=vl(e))==null?void 0:r._renderService)==null?void 0:n.dimensions)==null?void 0:o.css,i=((a=t==null?void 0:t.cell)==null?void 0:a.width)??0,s=((h=t==null?void 0:t.cell)==null?void 0:h.height)??0;return!Number.isFinite(i)||!Number.isFinite(s)||i<=0||s<=0?null:{width:i,height:s}}function vl(e){return e._core??null}function aa(e,t){const i=t.background??"",s=t.foreground??"",r=t.cursor??s,n=t.cursorAccent??i,o=t.selectionBackground??"";e.style.background=i,e.style.setProperty("--terminal-theme-background",i),e.style.setProperty("--terminal-theme-foreground",s),e.style.setProperty("--terminal-theme-cursor",r),e.style.setProperty("--terminal-theme-cursor-accent",n),e.style.setProperty("--terminal-theme-selection",o)}function la(){if(typeof window>"u")return{background:"#ffffff",foreground:"#1a1a1a",cursor:"#1a1a1a",cursorAccent:"#ffffff",selectionBackground:"rgba(0, 122, 255, 0.18)"};const e=window.getComputedStyle(document.documentElement),t=Ni(e,"--terminal-theme-background","#ffffff"),i=Ni(e,"--terminal-theme-foreground","#1a1a1a"),s=Ni(e,"--terminal-theme-cursor",i),r=Ni(e,"--terminal-theme-cursor-accent",t),n=Ni(e,"--terminal-theme-selection","rgba(0, 122, 255, 0.18)");return{background:t,foreground:i,cursor:s,cursorAccent:r,selectionBackground:n}}function Ni(e,t,i){return e.getPropertyValue(t).trim()||i}function Vf(e,t){return[...e].sort((i,s)=>{const r=t.has(i.id),n=t.has(s.id);return r!==n?r?-1:1:i.createdAt!==s.createdAt?i.createdAt.localeCompare(s.createdAt):i.name!==s.name?i.name.localeCompare(s.name,"zh-CN-u-kn-true"):i.id.localeCompare(s.id)})}function Yf(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;const i=t;return typeof i.id=="string"&&typeof i.label=="string"&&typeof i.shell=="string"&&typeof i.available=="boolean"}):[]}function ms(e,t){var s;const i=t.trim();if(i){const r=e.find(n=>n.available&&n.shell===i);if(r)return r.shell}return((s=e.find(r=>r.available))==null?void 0:s.shell)??null}function ps(e,t){return e||(t==="windows"?"embedded-pty":"tmux")}function Xf(e,t,i){return t||i!=="windows"?!1:e.filter(s=>s.available).length>1}function Gf(e){if(e.nativeEvent.isComposing||Sl(e.target)||e.metaKey||e.altKey)return!0;const t=e.currentTarget;return t instanceof HTMLElement&&t.dataset.empty==="true"}function Sl(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:e.isContentEditable}function Zf(e){const t=e.key;if(!t||t==="Process"||t==="Dead"||t==="Unidentified")return null;if(e.ctrlKey)return Jf(t);if(t.length===1)return t;switch(t){case"Enter":return"\r";case"Backspace":return"";case"Tab":return" ";case"Escape":return"\x1B";case"ArrowUp":return"\x1B[A";case"ArrowDown":return"\x1B[B";case"ArrowRight":return"\x1B[C";case"ArrowLeft":return"\x1B[D";case"Home":return"\x1B[H";case"End":return"\x1B[F";case"Delete":return"\x1B[3~";case"Insert":return"\x1B[2~";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";default:return null}}function Jf(e){if(e.length===1){const t=e.toUpperCase();if(t>="A"&&t<="Z")return String.fromCharCode(t.charCodeAt(0)-64);switch(t){case"@":case" ":return"\0";case"[":return"\x1B";case"\\":return"";case"]":return"";case"^":return"";case"_":return"";default:return null}}switch(e){case"Enter":return`
|
|
50
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return gr.get()},set promptLabel(e){gr.set(e)},get tooMuchOutput(){return vr.get()},set tooMuchOutput(e){vr.set(e)}}}_verifyIntegers(...e){for(Et of e)if(Et===1/0||isNaN(Et)||Et%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Et of e)if(Et&&(Et===1/0||isNaN(Et)||Et%1!==0||Et<0))throw new Error("This API only accepts positive integers")}};const ul="codingns.user-app.terminal-page",Td=3,Rd=20,Bd=5,Md=400,Dd=200,Ld=2e5,Pd=12e4,Ad=.7,Id=2,ur={selectedWorkspaceId:null,activeTerminalIdByWorkspace:{},pinnedTerminalIdsByWorkspace:{},cursorByTerminalId:{},viewStateByTerminalId:{},zoomScale:null};function $o(){var t,i;const e=ki();return{selectedWorkspaceId:((t=e.selectedWorkspaceId)==null?void 0:t.value)??null,activeTerminalIdByWorkspace:cs(e.activeTerminalIdByWorkspace),pinnedTerminalIdsByWorkspace:cs(e.pinnedTerminalIdsByWorkspace),cursorByTerminalId:cs(e.cursorByTerminalId),viewStateByTerminalId:cs(e.viewStateByTerminalId),zoomScale:((i=e.zoomScale)==null?void 0:i.value)??null}}function Nd(e){xi((t,i)=>({...t,selectedWorkspaceId:{value:e,updatedAt:i}}))}function Od(e){var t;return((t=ki().activeTerminalIdByWorkspace[e])==null?void 0:t.value)??null}function Fd(e,t){xi((i,s)=>{const r={...i,activeTerminalIdByWorkspace:{...i.activeTerminalIdByWorkspace}};return t?r.activeTerminalIdByWorkspace[e]={value:t,updatedAt:s}:delete r.activeTerminalIdByWorkspace[e],r})}function Hd(e){var t;return((t=ki().pinnedTerminalIdsByWorkspace[e])==null?void 0:t.value)??[]}function jo(e,t){xi((i,s)=>{const r={...i,pinnedTerminalIdsByWorkspace:{...i.pinnedTerminalIdsByWorkspace}},n=fl(t);return n.length===0?(delete r.pinnedTerminalIdsByWorkspace[e],r):(r.pinnedTerminalIdsByWorkspace[e]={value:n,updatedAt:s},r)})}function zd(){var e;return((e=ki().zoomScale)==null?void 0:e.value)??null}function Wd(e){xi((t,i)=>({...t,zoomScale:{value:_l(e),updatedAt:i}}))}function $d(e,t){xi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId}};return t?(r.cursorByTerminalId[e]=dl(i.cursorByTerminalId[e],{value:t,updatedAt:s}),r):(delete r.cursorByTerminalId[e],r)})}function en(e){var r,n;const t=ki(),i=((r=t.viewStateByTerminalId[e])==null?void 0:r.value)??null,s=((n=t.cursorByTerminalId[e])==null?void 0:n.value)??null;return i?i.cursor&&s&&Vi(s,i.cursor)?{resumeCursor:s,viewState:null}:{resumeCursor:i.cursor??s,viewState:i}:{resumeCursor:s,viewState:null}}function jd(e,t){xi((i,s)=>{const r={...i,cursorByTerminalId:{...i.cursorByTerminalId},viewStateByTerminalId:{...i.viewStateByTerminalId}};return t?(r.viewStateByTerminalId[e]=Gd(i.viewStateByTerminalId[e],{value:t,updatedAt:s}),t.cursor&&(r.cursorByTerminalId[e]=dl(i.cursorByTerminalId[e],{value:t.cursor,updatedAt:s})),r):(delete r.viewStateByTerminalId[e],r)})}function xi(e){if(typeof window>"u")return;const t=ki(),i=Date.now(),s=e(t,i);window.localStorage.setItem(ul,JSON.stringify({schemaVersion:Td,state:s}))}function ki(){if(typeof window>"u")return ur;try{const e=window.localStorage.getItem(ul);if(!e)return ur;const t=JSON.parse(e),i=t&&typeof t=="object"&&"state"in t&&t.state&&typeof t.state=="object"?t.state:t;return{selectedWorkspaceId:Kd(i.selectedWorkspaceId),activeTerminalIdByWorkspace:hs(i.activeTerminalIdByWorkspace,Uo),pinnedTerminalIdsByWorkspace:hs(i.pinnedTerminalIdsByWorkspace,Vd),cursorByTerminalId:hs(i.cursorByTerminalId,Uo),viewStateByTerminalId:hs(i.viewStateByTerminalId,Yd),zoomScale:Ud(i.zoomScale)}}catch{return ur}}function Ud(e){return e===null?null:fn(e,Xd)??null}function Kd(e){return e===null?null:fn(e,qd)??null}function hs(e,t){if(!e||typeof e!="object")return{};const i={};for(const[s,r]of Object.entries(e)){const n=fn(r,t);s&&n&&(i[s]=n)}return i}function fn(e,t){const i=t(e);if(i!==null)return{value:i,updatedAt:0};if(!e||typeof e!="object")return null;const s=e,r=t(s.value);return r===null?null:{value:r,updatedAt:Number.isFinite(s.updatedAt)?Number(s.updatedAt):0}}function Uo(e){return typeof e=="string"&&e?e:null}function qd(e){return e===null?null:typeof e=="string"?e:null}function Vd(e){return Array.isArray(e)?fl(e.filter(i=>typeof i=="string")):null}function Yd(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.content!="string"||t.content.length===0||t.content.length>Pd||t.cursor!==null&&t.cursor!==void 0&&typeof t.cursor!="string"||!Number.isInteger(t.cols)||!Number.isInteger(t.rows)||!Number.isInteger(t.viewportY)||t.historyBeforeSeq!==null&&t.historyBeforeSeq!==void 0&&!Number.isInteger(t.historyBeforeSeq)||t.historyHasOlder!==void 0&&typeof t.historyHasOlder!="boolean")return null;const i=t.cols,s=t.rows,r=t.viewportY;return i<Rd||i>Md||s<Bd||s>Dd||r<0||r>Ld?null:{content:t.content,cursor:typeof t.cursor=="string"?t.cursor:null,cols:i,rows:s,viewportY:r,historyBeforeSeq:typeof t.historyBeforeSeq=="number"?t.historyBeforeSeq:null,historyHasOlder:typeof t.historyHasOlder=="boolean"?t.historyHasOlder:!0}}function Xd(e){return typeof e!="number"||!Number.isFinite(e)?null:_l(e)}function cs(e){const t={};for(const[i,s]of Object.entries(e))t[i]=s.value;return t}function dl(e,t){return!e||Vi(t.value,e.value)?t:Vi(e.value,t.value)?e:t.updatedAt>=e.updatedAt?t:e}function Gd(e,t){if(!e)return t;const i=e.value.cursor,s=t.value.cursor;return s&&i&&Vi(s,i)?t:s&&i&&Vi(i,s)?e:t.value.content.length!==e.value.content.length?t.value.content.length>e.value.content.length?t:e:t.updatedAt>=e.updatedAt?t:e}function Vi(e,t){const i=Number(e),s=Number(t);return!Number.isInteger(i)||!Number.isInteger(s)?!1:i>s}function fl(e){return Array.from(new Set(e.map(t=>t.trim()).filter(Boolean)))}function _l(e){return Math.min(Id,Math.max(Ad,e))}function Zd({terminals:e,preferredTerminalId:t,currentActiveTerminalId:i,persistedTerminalId:s}){const r=dr(e,t),n=dr(e,i),o=dr(e,s),a=e.find(h=>h.status==="running")??null;return fr(r)??fr(n)??fr(o)??a??r??n??o??e[0]??null}function dr(e,t){return t?e.find(i=>i.id===t)??null:null}function fr(e){return!e||e.status!=="running"?null:e}const Jd="codingns.terminal.debug",Qd=ef();let Ko=0;function ai(){return Qd}function ef(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search).get("terminalDebug");if(e)return qo(e);try{const t=window.localStorage.getItem(Jd);return t?qo(t):!1}catch{return!1}}function Rt(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function tf(e){return Ko+=1,`${e}-${Date.now().toString(36)}-${Ko.toString(36)}`}function ji(e,t={}){ai()&&console.info(`[terminal-debug][client] ${e}`,t)}function qo(e){const t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}const sf=8,rf=1e4;class nf{constructor(t){st(this,"socket",null);st(this,"disposed",!1);st(this,"authRecoveryInFlight",!1);st(this,"manuallyDisconnected",!1);st(this,"lastCursor");st(this,"isSubscribed",!1);st(this,"pendingInput","");st(this,"inputFlushTimer",null);st(this,"pendingInputQueuedAtMs",null);st(this,"pendingResize",null);st(this,"lastSentResizeKey",null);st(this,"inputDebugTraces",new Map);st(this,"connectionManager");this.options=t,this.lastCursor=t.lastCursor,this.connectionManager=new Ul({onReconnect:i=>{this.connect(i)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.lastCursor=t}sendInput(t){t&&(this.pendingInputQueuedAtMs===null&&(this.pendingInputQueuedAtMs=Rt()),this.pendingInput+=t,this.logDebug("input.queued",{charCount:t.length,pendingCharCount:this.pendingInput.length,preview:us(t)}),this.canSendRealtimePayload()&&(this.pruneStaleInputDebugTraces(),this.scheduleInputFlush()))}sendCurrentDimensions(t,i){!Number.isInteger(t)||!Number.isInteger(i)||t<1||i<1||this.resize(t,i)}sendTerminalInput(t){const i=this.pendingInputQueuedAtMs??Rt(),s=Rt(),n=ai()?tf(this.options.terminalId):void 0;n&&this.inputDebugTraces.set(n,{traceId:n,queuedAtMs:i,sentAtMs:s,ackedAtMs:null,charCount:t.length,preview:us(t)}),this.logDebug("input.sent",{traceId:n??null,charCount:t.length,queuedForMs:s-i,preview:us(t)}),this.sendMessage({type:"terminal.input",terminalId:this.options.terminalId,content:t,...n?{clientTraceId:n,clientSentAtMs:s}:{}}),this.pendingInputQueuedAtMs=null}resize(t,i){this.pendingResize={cols:t,rows:i},this.isSubscribed&&this.flushPendingResize()}disconnect(){this.manuallyDisconnected=!0,this.isSubscribed=!1,this.inputDebugTraces.clear();const t=this.socket;this.socket=null,t==null||t.close(),this.options.onConnectionChange("closed")}reconnectNow(){this.manuallyDisconnected=!1,this.connectionManager.reconnectNow()}close(){var t;this.disposed=!0,this.manuallyDisconnected=!0,this.connectionManager.close(),this.clearInputFlushTimer(),this.inputDebugTraces.clear(),(t=this.socket)==null||t.close(),this.socket=null,this.isSubscribed=!1}connect(t){var n;if(this.disposed||this.manuallyDisconnected)return;t&&this.socket&&(this.socket.close(),this.socket=null);const i=(n=jn.getState().session)==null?void 0:n.accessToken;if(!i){this.options.onUnauthorized();return}const s=`${$l("/ws")}?access_token=${encodeURIComponent(i)}`,r=new WebSocket(s);this.socket=r,r.addEventListener("open",()=>{this.isSubscribed=!1,r.send(JSON.stringify({type:"terminal.subscribe",terminalId:this.options.terminalId,lastCursor:this.lastCursor}))}),r.addEventListener("message",o=>{const a=JSON.parse(o.data);if(a.type==="system.connected"){this.connectionManager.markConnected();return}if(a.type==="terminal.subscribed"){this.isSubscribed=!0,this.options.onSubscribed(),this.flushPendingResize(),this.flushPendingInput(!0);return}if(a.type==="terminal.error"){if(a.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(a);return}if(a.type!=="terminal.resize.accepted"){if(a.type==="terminal.input.accepted"){if(this.pruneStaleInputDebugTraces(),a.clientTraceId){const h=this.inputDebugTraces.get(a.clientTraceId);h&&(h.ackedAtMs=Rt(),this.logDebug("input.acknowledged",{traceId:h.traceId,charCount:h.charCount,sendToAckMs:h.ackedAtMs-h.sentAtMs,preview:h.preview}))}return}if(a.type==="terminal.backfill"){this.lastCursor=a.latestCursor??this.lastCursor,this.options.onBackfill(a);return}if(a.type==="terminal.output"){this.lastCursor=a.chunk.cursor,this.pruneStaleInputDebugTraces(),this.handleDebugOutput(a.chunk.content,a.chunk.cursor),this.options.onOutput(a);return}if(a.type==="terminal.status"){this.options.onStatus(a);return}a.type}}),r.addEventListener("close",()=>{this.disposed||this.socket!==r||(this.isSubscribed=!1,this.connectionManager.markDisconnected())}),r.addEventListener("error",()=>{this.disposed||this.socket!==r||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,this.isSubscribed=!1,t==null||t.close(),jn.refresh().then(i=>{if(this.authRecoveryInFlight=!1,!(this.disposed||this.manuallyDisconnected)){if(i.status==="refreshed"){this.connectionManager.reconnectNow();return}if(i.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendMessage(t){!this.socket||this.socket.readyState!==WebSocket.OPEN||this.socket.send(JSON.stringify(t))}canSendRealtimePayload(){return!!(this.socket&&this.socket.readyState===WebSocket.OPEN&&this.isSubscribed)}flushPendingInput(t=!1){if(!this.pendingInput||!this.canSendRealtimePayload())return;t||this.clearInputFlushTimer();const i=this.pendingInput;this.pendingInput="",this.sendTerminalInput(i)}scheduleInputFlush(){this.inputFlushTimer===null&&(this.inputFlushTimer=window.setTimeout(()=>{this.inputFlushTimer=null,this.flushPendingInput(!0)},sf))}clearInputFlushTimer(){this.inputFlushTimer!==null&&(window.clearTimeout(this.inputFlushTimer),this.inputFlushTimer=null)}flushPendingResize(){if(!this.pendingResize||!this.canSendRealtimePayload())return;const t=this.pendingResize,i=`${t.cols}x${t.rows}`;if(this.lastSentResizeKey===i){this.pendingResize=null;return}this.sendMessage({type:"terminal.resize",terminalId:this.options.terminalId,cols:t.cols,rows:t.rows}),this.lastSentResizeKey=i,this.pendingResize=null}handleDebugOutput(t,i){if(!ai())return;const s=this.inputDebugTraces.values().next().value;if(!s)return;const r=Rt();this.inputDebugTraces.delete(s.traceId),this.logDebug("output.received_after_input",{traceId:s.traceId,cursor:i,charCount:t.length,sendToOutputMs:r-s.sentAtMs,ackToOutputMs:s.ackedAtMs===null?null:r-s.ackedAtMs,preview:us(t)})}logDebug(t,i){ji(`terminal.${t}`,{terminalId:this.options.terminalId,...i})}pruneStaleInputDebugTraces(){if(!ai()||this.inputDebugTraces.size===0)return;const t=Rt();for(const[i,s]of this.inputDebugTraces.entries()){const r=t-s.sentAtMs;r<rf||(this.inputDebugTraces.delete(i),this.logDebug("input.trace_expired",{traceId:i,ageMs:r,charCount:s.charCount,preview:s.preview}))}}}function us(e){return e.replace(/\r/g,"\\r").replace(/\n/g,"\\n").slice(0,60)}const of=250,af=/\u001b\[\?(?:\d+;)*\d+c|\u001b\[>(?:\d+;)*\d+c/g;function lf(e,t=window){let i=!1,s="",r=null,n=null,o=!1;const a=()=>{r!==null&&(t.clearTimeout(r),r=null)},h=()=>{n!==null&&(t.clearTimeout(n),n=null)},l=()=>{if(!i||r!==null||n!==null||s.length===0)return;const u=o?hf(s):s;s="",o=!1,u&&e(u)};return{enqueue(u){if(u){if(i&&r===null&&n===null){e(u);return}s+=u}},suspend(){a(),h(),i=!1},resume(u=0){if(a(),h(),u<=0){i=!0,l();return}i=!1,o=!0,r=t.setTimeout(()=>{r=null,i=!0,n=t.setTimeout(()=>{n=null,l()},of)},u)},dispose(){a(),h(),i=!1,s="",o=!1}}}function hf(e){return e.replace(af,"")}const cf=120,uf=120,df=120,ff=30,_f=14,mf=160,pf=12e4,ml=20,pl=5,gf=320,vf=120,Sf=.8,bf=1.6,Vo=.1,wf=700,Yo=10,yf=300,Cf=250,Xo=196,xf=6,_r=8,_n=72,mn=48,kf=60*1e3,Ef=20,Tf=6,Rf=14,Bf=2,Go=.06,Zo=.9,Mf=.97,Df=3600,Lf=3,Pf=5,ds={primary:null,secondary:null},fs={primary:"closed",secondary:"closed"};function Jo(e){var n,o,a;const t=e.routeWorkspaceId??null;if(t)return t;const i=e.shellCurrentWorkspaceId&&e.workspaces.some(h=>h.id===e.shellCurrentWorkspaceId)?e.shellCurrentWorkspaceId:null;if(i)return i;const s=((n=e.persistedWorkspaceId)==null?void 0:n.trim())??"";return((o=e.workspaces.find(h=>h.id===s))==null?void 0:o.id)??((a=e.workspaces[0])==null?void 0:a.id)??""}function A_({externalWindowMode:e=!1,externalWindowWorkspaceId:t=null,embeddedMode:i=!1,workbenchShellOverrides:s}={}){var $n;const r=pa(),n=Kl(r),o=ql(),a=Jl(),{workspaceId:h}=Ql(),l=Vl(),{navigationGroups:u,currentWorkspaceId:d,selectWorkspace:_,subscribeTerminalManagerSnapshot:p,requestTerminalManagerRefresh:f,addTerminalManagerSnapshotListener:g}={navigationGroups:(s==null?void 0:s.navigationGroups)??l.navigationGroups,currentWorkspaceId:(s==null?void 0:s.currentWorkspaceId)??l.currentWorkspaceId,selectWorkspace:(s==null?void 0:s.selectWorkspace)??l.selectWorkspace,subscribeTerminalManagerSnapshot:(s==null?void 0:s.subscribeTerminalManagerSnapshot)??l.subscribeTerminalManagerSnapshot,requestTerminalManagerRefresh:(s==null?void 0:s.requestTerminalManagerRefresh)??l.requestTerminalManagerRefresh,addTerminalManagerSnapshotListener:(s==null?void 0:s.addTerminalManagerSnapshotListener)??l.addTerminalManagerSnapshotListener},E=b.useRef(null),D=b.useRef(null),U=b.useRef(null),W=b.useRef(null),H=b.useRef({}),O=b.useRef(null),j=b.useRef(null),se=b.useRef(null),Z=b.useRef(null),V=b.useRef(""),oe=b.useRef([]),X=b.useRef(0),x=b.useRef({primary:null,secondary:null}),S=b.useRef(ds),T=b.useRef("primary"),P=b.useRef("single"),B=b.useMemo(()=>u.map(c=>c.workspace),[u]),$=i?(t==null?void 0:t.trim())||(h==null?void 0:h.trim())||null:(h==null?void 0:h.trim())||(t==null?void 0:t.trim())||null,I=$o().selectedWorkspaceId,[N,ne]=b.useState(()=>Jo({routeWorkspaceId:$,shellCurrentWorkspaceId:d,workspaces:B,persistedWorkspaceId:I})),[ce,Te]=b.useState(""),[Q,ee]=b.useState([]),[ye,Ce]=b.useState(""),[Ne,ct]=b.useState(""),[ge,ve]=b.useState(!1),[vt,Se]=b.useState(!1),[C,R]=b.useState(!1),[K,re]=b.useState(!1),[ae,Re]=b.useState([]),[q,Y]=b.useState(null),[de,ut]=b.useState(!1),[nt,dt]=b.useState(null),[M,F]=b.useState(null),[fe,Be]=b.useState(!1),[Ye,ot]=b.useState(null),[Ct,St]=b.useState(!1),[Lt,Qi]=b.useState("single"),[Pt,yl]=b.useState("primary"),[Qt,vn]=b.useState(ds),[es,jt]=b.useState(fs),[Sn,ts]=b.useState([]),[bn,ui]=b.useState([]),[Ei,Cl]=b.useState({}),[ei,xl]=b.useState(()=>zd()??1),di=b.useMemo(()=>B.find(c=>c.id===d)??null,[d,B]),wn=b.useMemo(()=>B.find(c=>c.id===N)??null,[N,B]),At=b.useMemo(()=>wn??(N||$?null:di)??null,[$,wn,N,di]),at=b.useMemo(()=>{var c;return(At==null?void 0:At.id)??$??N??(di==null?void 0:di.id)??((c=B[0])==null?void 0:c.id)??""},[At,$,N,di,B]),kl=b.useMemo(()=>At??B[0]??{id:"__terminal-mobile-workspace-placeholder__",name:w("terminal.mobileWorkspaceSwitcherPlaceholder"),path:w("home.emptyWorkspaces")},[At,B]),{dismissToast:Fs,showToast:bt}=eh(),Ze=b.useCallback((c,v="info")=>{},[]),yn=b.useCallback((c,v)=>{x.current[c]=v},[]),Cn=b.useCallback(()=>{a("/login",{replace:!0})},[a]),Hs=b.useCallback((c,v)=>{const y=U.current,L=v??H.current[c];if(!y||!L||!L.isConnected)return null;const G=y.getBoundingClientRect(),me=L.getBoundingClientRect(),ue=Math.max(_r,G.width-Xo-_r),wt=Ds(me.right-G.left-Xo,_r,ue),ft=Math.max(0,me.bottom-G.top+xf);return{terminalId:c,top:ft,left:wt}},[]),xn=b.useCallback(c=>{const v=Hs(c);if(!v){F(null);return}F(y=>!y||y.terminalId!==c||y.top===v.top&&y.left===v.left?y:v)},[Hs]),Ti=b.useMemo(()=>new Set(Sn),[Sn]),zs=b.useMemo(()=>new Set(bn),[bn]),kn=b.useMemo(()=>Vf(ae,Ti),[Ti,ae]),En=b.useMemo(()=>ga(r.ui.osFamily),[r.ui.osFamily]),le=!r.isDesktop&&r.isMobile,El=r.isDesktop&&r.bridge.supported&&!e&&!!at,Tn=b.useMemo(()=>at?Yl(at):null,[at]),Tl=jl(c=>Tn?c.openWindowIds.includes(Tn):!1),Rn=e||!Tl,Ut=le?"single":Lt,fi=le?"primary":Pt,It=b.useMemo(()=>le?{primary:Qt[Pt]??Qt.primary,secondary:null}:Qt,[Pt,le,Qt]),Ws=b.useMemo(()=>le?{primary:es[Pt]??es.primary,secondary:"closed"}:es,[Pt,le,es]),Nt=It[fi],Je=b.useMemo(()=>ae.find(c=>c.id===Nt)??null,[Nt,ae]),$s=b.useMemo(()=>M?ae.find(c=>c.id===M.terminalId)??null:null,[M,ae]),Rl=Ut==="single"?["primary"]:["primary","secondary"],xt=b.useMemo(()=>Qf(Q,r.ui.osFamily),[r.ui.osFamily,Q]),Bl=b.useMemo(()=>xt.find(c=>c.value===Ne)??xt[0]??null,[Ne,xt]),Ml={"--terminal-mobile-list-width":le&&ge?"60vw":"0px"};b.useEffect(()=>{oe.current=ae},[ae]),Nf(D,O,le,N||at),b.useEffect(()=>{Ce(c=>ms(Q,c)??"")},[Q]),b.useEffect(()=>{ct(c=>{var v,y;return xt.length?c&&xt.some(L=>L.value===c&&L.available)?c:((v=xt.find(L=>L.available))==null?void 0:v.value)??((y=xt[0])==null?void 0:y.value)??"":""})},[xt]);function Kt(c){const v=c(S.current);S.current=v,vn(v)}function _i(c){T.current=c,yl(c)}function js(c){P.current=c,Qi(c)}const mi=b.useCallback((c,v,y={})=>{var me;if(V.current!==c)return;oe.current=v,Re(v),Y(c),ui(ue=>{const wt=new Set(v.map(ft=>ft.id));return ue.filter(ft=>wt.has(ft))}),ts(ue=>{const wt=new Set(v.map(gi=>gi.id)),ft=ue.filter(gi=>wt.has(gi));return ft.length!==ue.length&&jo(c,ft),ft});const L=Od(c),G=((me=Zd({terminals:v,preferredTerminalId:y.preferredTerminalId,currentActiveTerminalId:S.current[T.current]??S.current.primary,persistedTerminalId:L}))==null?void 0:me.id)??null;vn(ue=>{const wt=gs({terminals:v,currentBindings:ue,splitDirection:P.current,fallbackTerminalId:G,preferredPaneId:y.preferredPaneId??T.current});return S.current=wt,wt})},[]),qt=b.useCallback(async(c,v={})=>{const y=X.current+1;X.current=y;try{const L=await ih(c);if(y!==X.current||V.current!==c)return;mi(c,L.items,v)}catch(L){if(y!==X.current||V.current!==c)return;const G=L instanceof Error?L.message:w("terminal.workspaceLoadFailed");Ze(G,"error")}},[mi,Ze]),Bn=b.useCallback(()=>N?qt(N):Promise.resolve(),[qt,N]);b.useEffect(()=>{V.current=N},[N]),b.useEffect(()=>{S.current=Qt},[Qt]),b.useEffect(()=>{T.current=Pt},[Pt]),b.useEffect(()=>{P.current=Lt},[Lt]),b.useEffect(()=>{if(!le)return;const c=S.current[T.current]??S.current.primary,v=P.current!=="single",y=T.current!=="primary",L=S.current.secondary!==null||S.current.primary!==c;!v&&!y&&!L||(Kt(()=>({primary:c,secondary:null})),js("single"),_i("primary"),jt(G=>G.secondary==="closed"?G:{...G,secondary:"closed"}))},[le]),b.useEffect(()=>{const c=$o().selectedWorkspaceId;ne(v=>{const y=v.trim();return $||(y&&B.some(L=>L.id===y)?y:Jo({routeWorkspaceId:$,shellCurrentWorkspaceId:d,workspaces:B,persistedWorkspaceId:c}))})},[$,d,B]),b.useEffect(()=>{Nd(N||null)},[N]),b.useEffect(()=>{if(!N){ts([]);return}ts(Hd(N))},[N]),b.useEffect(()=>{if(Nt||ae.length===0)return;const c=wl(ae);c&&Bi(c,"primary")},[Nt,ae]),b.useEffect(()=>{Wd(ei)},[ei]),b.useEffect(()=>{F(null)},[Pt,Qt,N]),b.useEffect(()=>{le&&ve(!1)},[Nt,le,N]),b.useEffect(()=>{M&&!ae.some(c=>c.id===M.terminalId)&&F(null)},[M,ae]),b.useEffect(()=>{if(N)return g(c=>{c.workspaceId===N&&(Xl(ua(N),{revision:c.revision??null,terminals:c.terminals,templates:c.templates,templateStatuses:c.templateStatuses,shellOptions:c.shellOptions}),ee(c.shellOptions??[]),mi(c.workspaceId,c.terminals))})},[g,mi,N]),b.useEffect(()=>{if(!M)return;const c=W.current,v=()=>{xn(M.terminalId)},y=window.requestAnimationFrame(v);return window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),c==null||c.addEventListener("scroll",v,{passive:!0}),()=>{window.cancelAnimationFrame(y),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),c==null||c.removeEventListener("scroll",v)}},[M,xn]),b.useEffect(()=>{if(!M&&!fe)return;function c(y){var ue,wt,ft,gi;const L=y.target,G=(((ue=E.current)==null?void 0:ue.contains(L))??!1)||!!M&&(((wt=H.current[M.terminalId])==null?void 0:wt.contains(L))??!1),me=(((ft=j.current)==null?void 0:ft.contains(L))??!1)||(((gi=se.current)==null?void 0:gi.contains(L))??!1);M&&!G&&F(null),fe&&!me&&Be(!1)}function v(y){y.key==="Escape"&&(F(null),Be(!1))}return window.addEventListener("mousedown",c),window.addEventListener("keydown",v),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",v)}},[M,fe]),b.useEffect(()=>{if(!N){Y(null),ee([]),Ce(""),ve(!1),Se(!1),oe.current=[],Re([]),Kt(()=>ds),_i("primary"),jt(fs),dt(null);return}Y(null),_i("primary"),jt(fs),dt(null);const c=Gl(ua(N),kf);if(c?(ee(Yf(c.shellOptions)),mi(N,c.terminals)):(ee([]),oe.current=[],Re([]),Kt(()=>ds),_i("primary"),jt(fs),dt(null)),p(N,{knownRevision:(c==null?void 0:c.revision)??null}),c){const v=window.setTimeout(()=>{f(N,{knownRevision:c.revision??null})},1500);return()=>{window.clearTimeout(v)}}f(N,{knownRevision:null}),e&&(qt(N),Q.length===0&&Un().then(v=>{ee(v.items??[])}).catch(()=>{}))},[mi,e,f,qt,N,Q.length,p]),b.useEffect(()=>{N&&q===N&&(Je&&Je.workspaceId!==N||Fd(N,Nt??null))},[Je,Nt,q,N]);const Mn=b.useCallback((c,v)=>{jt(y=>({...y,[c]:v}))},[]),Dn=b.useCallback(c=>{c.status!=="running"&&ui(v=>v.filter(y=>y!==c.id)),Re(v=>{const y=v.map(L=>L.id===c.id?{...L,status:c.status,statusDetail:c.statusDetail,processId:c.processId??L.processId??null}:L);return oe.current=y,y})},[]);function Ri(c,v){Cl(y=>{if(v===null){if(!(c in y))return y;const L={...y};return delete L[c],L}return y[c]===v?y:{...y,[c]:v}})}function Us(c,v){bt({id:mr(c),title:v==="closing"?w("terminal.closing"):w("terminal.deleting"),description:v==="closing"?w("terminal.closePendingDescription"):w("terminal.deletePendingDescription"),tone:"info",durationMs:null})}async function Ln(c,v,y){for(let L=0;L<Yo;L+=1){if(V.current!==c)return"workspace_changed";await qt(c);const G=oe.current.find(ue=>ue.id===v)??null;if(y==="deleting"?G===null:G===null||G.status!=="running")return"settled";L<Yo-1&&await c_()}return"timeout"}function Pn(c){_i(c)}function Ks(c){Bi(c,T.current)}function Bi(c,v){const y=le?"primary":v,L=le?"single":P.current;Kt(G=>{const me=L==="single"?{primary:c,secondary:null}:{...G,[y]:c};if(L!=="single"){const ue=y==="primary"?"secondary":"primary";me[ue]===c&&(me[ue]=tn(ae,c))}return gs({terminals:ae,currentBindings:me,splitDirection:L,fallbackTerminalId:c,preferredPaneId:y})}),ui(G=>G.filter(me=>me!==c)),F(null)}async function qs(c,v={}){try{return await nh(c)}catch(y){if(v.allowFallbackPrompt!==!1&&c.runtimeType!=="embedded-pty"&&lh(y))return ot(c),null;throw y}}async function is(){if(Q.length>0||K)return Q;re(!0);try{const v=(await Un()).items??[];return ee(v),v}catch{return Q}finally{re(!1)}}async function An(){!le||!at||de||(await is(),Se(!0))}async function Vs(c,v,y={}){var L;ut(!0),dt(v);try{const G=await qs(c);if(!G){pi(v);return}Ys(G,v),pi(v),(L=y.onCreated)==null||L.call(y),await qt(c.workspaceId,{preferredTerminalId:G.id,preferredPaneId:v}),Ze(w("terminal.created"),"success")}catch(G){pi(v),Ze(G instanceof Error?G.message:w("terminal.createFailed"),"error")}finally{ut(!1)}}function pi(c){dt(v=>v===c?null:v)}function Ys(c,v){const y=le?"primary":v,L=le?"single":P.current,G=f_(oe.current,c);oe.current=G,Re(G),Kt(me=>gs({terminals:G,currentBindings:{...me,[y]:c.id,...L==="single"?{primary:c.id,secondary:null}:{}},splitDirection:L,fallbackTerminalId:c.id,preferredPaneId:y})),jt(me=>({...me,[y]:c.status==="running"?"reconnecting":"closed"})),ui(me=>me.filter(ue=>ue!==c.id))}async function Dl(){const c=at;if(!c||de)return;const v=le?"primary":T.current,y=await is(),L=ms(y.length>0?y:Q,ye);await Vs({workspaceId:c,shell:L??void 0,runtimeType:ce||void 0},v)}async function Ll(){if(!at||de)return;const v=await is(),y=v.length>0?v:Q,L=ms(y,ye);if(Xf(y,le,r.ui.osFamily)){Ce(L??""),R(!0);return}await Dl()}async function Pl(){const c=at;if(!c||de)return;const v=Q.length>0?Q:await is(),y=ms(v.length>0?v:Q,ye);await Vs({workspaceId:c,shell:y??void 0,runtimeType:ps(ce,r.ui.osFamily)},T.current,{onCreated:()=>{R(!1)}})}async function Al(){const c=at;if(!c||de)return;const v=Bl;!v||!v.available||await Vs({workspaceId:c,shell:v.value,runtimeType:ps(ce,r.ui.osFamily)},"primary",{onCreated:()=>{Se(!1),ve(!1)}})}async function In(c,v){return Ri(v,"deleting"),Us(v,"deleting"),await oh(v),Ln(c,v,"deleting")}async function Xs(c){if(!N||Ei[c])return;const v=N,y=mr(c);F(null),Ri(c,"closing"),Us(c,"closing"),(async()=>{try{await sh(c);const L=await Ln(v,c,"closing");if(L==="workspace_changed"){Fs(y);return}if(L==="timeout"){bt({id:y,title:w("terminal.closed"),description:w("terminal.closeSyncDelayed"),tone:"warning"});return}if(!oe.current.some(me=>me.id===c)){bt({id:y,title:w("terminal.deleted"),tone:"success"});return}const G=await In(v,c);if(G==="workspace_changed"){Fs(y);return}if(G==="timeout"){bt({id:y,title:w("terminal.deleted"),description:w("terminal.deleteSyncDelayed"),tone:"warning"});return}bt({id:y,title:w("terminal.deleted"),tone:"success"})}catch(L){bt({id:y,title:L instanceof Error?L.message:w("terminal.closeFailed"),tone:"error"})}finally{Ri(c,null)}})()}async function Nn(c){if(!N||Ei[c])return;const v=N,y=mr(c);F(null),Ri(c,"deleting"),Us(c,"deleting"),(async()=>{try{const L=await In(v,c);if(L==="workspace_changed"){Fs(y);return}if(L==="timeout"){bt({id:y,title:w("terminal.deleted"),description:w("terminal.deleteSyncDelayed"),tone:"warning"});return}bt({id:y,title:w("terminal.deleted"),tone:"success"})}catch(L){bt({id:y,title:L instanceof Error?L.message:w("terminal.deleteFailed"),tone:"error"})}finally{Ri(c,null)}})()}async function On(c){if(!N)return;const v=le?"primary":T.current;try{const y=await qs({workspaceId:N,cwd:c.cwd,shell:c.shell,runtimeType:c.runtimeType});if(!y)return;Ys(y,v),F(null),await qt(N,{preferredTerminalId:y.id,preferredPaneId:v}),Ze(w("terminal.duplicateSuccess"),"success")}catch(y){Ze(y instanceof Error?y.message:w("terminal.duplicateFailed"),"error")}}async function Il(){const c=Ye;if(!c)return;const v=le?"primary":T.current;St(!0),dt(v);try{const y=await qs({...c,runtimeType:"embedded-pty"},{allowFallbackPrompt:!1});if(!y){pi(v);return}Ys(y,v),Te("embedded-pty"),ot(null),R(!1),Se(!1),pi(v),await qt(c.workspaceId,{preferredTerminalId:y.id,preferredPaneId:v}),Ze(w("terminal.created"),"success")}catch(y){pi(v),Ze(y instanceof Error?y.message:w("terminal.createFailed"),"error")}finally{St(!1)}}function Fn(c){N&&(ts(v=>{const y=v.includes(c)?v.filter(L=>L!==c):[c,...v];return jo(N,y),y}),F(null))}function Hn(c){var y;const v=Yi(c,It,Ut,fi);v&&((y=x.current[v])==null||y.disconnect(),Kt(L=>({...L,[v]:null})),jt(L=>({...L,[v]:"closed"})),ui(L=>L.includes(c)?L:[...L,c]),F(null),Ze(w("terminal.disconnected"),"warning"))}function zn(c){var y;const v=Yi(c,It,Ut,fi);v&&(ui(L=>L.filter(G=>G!==c)),jt(L=>({...L,[v]:"reconnecting"})),(y=x.current[v])==null||y.reconnect(),F(null),Ze(w("terminal.reconnectRequested")))}function Gs(c){xl(pn(c))}function Zs(c){if(!le){if(c==="single"){Kt(v=>({primary:T.current==="secondary"?v.secondary??v.primary:v.primary,secondary:null})),js("single"),_i("primary");return}js(c),Kt(v=>gs({terminals:ae,currentBindings:v,splitDirection:c,fallbackTerminalId:v[T.current]??v.primary,preferredPaneId:T.current}))}}async function Nl(){if(Je)try{const c=s_({terminalId:Je.id,splitDirection:Ut,paneBindings:It,paneApiById:x.current});if(!c.trim()){Ze(w("terminal.logEmpty"),"warning");return}const v=new Date().toISOString().replace(/[:.]/g,"-"),L=`${d_(Je.name||"terminal")}-${v}.log`;u_(L,c),Ze(w("terminal.saveLogSuccess"),"success")}catch(c){Ze(c instanceof Error?c.message:w("terminal.saveLogFailed"),"error")}}function Wn(c){if(le){if(c==="right"){o.trigger("gesture"),ve(!0);return}o.trigger("gesture"),ve(!1)}}function Ol(c){if(!le||ge)return;const v=c.touches[0];v&&(Z.current={x:v.clientX,y:v.clientY})}function Fl(c){if(!le||ge){Z.current=null;return}const v=Z.current,y=c.changedTouches[0];if(Z.current=null,!v||!y)return;const L=y.clientX-v.x,G=y.clientY-v.y;Math.abs(L)<_n||Math.abs(G)>mn||Math.abs(L)<=Math.abs(G)||L<0||Wn("right")}const Hl=b.useCallback(async(c,v)=>{const y=await Zl(r,{workspaceId:c,workspaceName:v,focusOwner:"terminal-page"});y.ok||bt({title:y.detail??w("terminal.openExternalFailed"),tone:"error"})},[r,bt]);return m.jsxs("main",{className:`terminal-layout${i?" terminal-layout-embedded":" mobile-page-fixed-root"}`,"data-embedded":i?"true":void 0,children:[m.jsx(ah,{open:Ye!==null,busy:Ct,onClose:()=>{Ct||ot(null)},onConfirmFallback:()=>{Il()}}),m.jsx("section",{ref:D,className:"terminal-shell","data-mobile":le,"data-mobile-list-open":le?ge:void 0,style:le?Ml:void 0,children:le?m.jsxs(m.Fragment,{children:[m.jsx(th,{containerRef:O,currentWorkspace:kl,workspaces:B,onSelectWorkspace:c=>{_(c),ne(c)},trailing:m.jsx("button",{type:"button",className:"secondary-button mobile-tools-more-button","aria-label":w("terminal.mobileDrawerAction"),title:w("terminal.mobileDrawerAction"),"aria-expanded":ge,onClick:()=>{ve(c=>!c)},children:m.jsx(gl,{})})}),m.jsx(Af,{open:ge,terminals:kn,pinnedTerminalIds:Ti,activeTerminalId:(Je==null?void 0:Je.id)??null,creatingTerminal:de,paneBindings:It,splitDirection:Ut,activePaneId:fi,paneConnectionStates:Ws,terminalMutations:Ei,manuallyDisconnectedTerminalIdSet:zs,onClose:()=>{ve(!1)},onCreateTerminal:()=>{ve(!1),An()},onSelectTerminal:c=>{Bi(c,"primary"),ve(!1)},onBindToActivePane:c=>{Ks(c),ve(!1)},onBindToPane:Bi,onDuplicate:On,onDisconnect:Hn,onReconnect:zn,onCloseTerminal:Xs,onDeleteTerminal:Nn,onTogglePin:Fn}),m.jsxs("div",{className:"terminal-stage-surface terminal-stage-surface-mobile",children:[m.jsx("div",{className:"terminal-mobile-edge-swipe-zone","aria-hidden":"true",onTouchStart:Ol,onTouchEnd:Fl,onTouchCancel:()=>{Z.current=null}}),m.jsx("div",{className:"terminal-stage-grid","data-layout":"single","data-mobile":"true",children:m.jsx(ta,{paneId:"primary",paneLabel:w("terminal.panePrimary"),terminal:Je,pendingCreation:!Je&&nt==="primary",zoomScale:ei,active:!0,ownsTerminalSize:Rn,isMobileLayout:!0,onActivate:Pn,onSwipeGesture:Wn,onConnectionChange:Mn,onTerminalStatus:Dn,onRequireReload:Bn,onUnauthorized:Cn,registerApi:yn,notifyTerminal:Ze,canCreateTerminal:!!at,onRequestCreateTerminal:()=>{An()},onRequestOpenTerminalDrawer:()=>{ve(!0)}},`mobile-${(Je==null?void 0:Je.id)??"empty"}`)})]}),m.jsx(ea,{open:vt,loading:K,creating:de,shellChoices:xt,osFamily:r.ui.osFamily,selectedShell:Ne,runtimeType:ps(ce,r.ui.osFamily),title:w("terminal.mobileCreateSheetTitle"),shellLabel:w("terminal.mobileCreateShellLabel"),shellDescription:w("terminal.mobileCreateShellDescription"),runtimeLabel:w("terminal.mobileCreateRuntimeLabel"),runtimeDescription:w("terminal.mobileCreateRuntimeDescription"),confirmLabel:w("terminal.mobileCreateConfirm"),onClose:()=>{de||Se(!1)},onSelectShell:ct,onSelectRuntime:c=>{Te(c)},onConfirm:()=>{Al()}})]}):m.jsxs(m.Fragment,{children:[m.jsx("header",{className:"terminal-tabbar","data-window-drag-handle":"terminal-tabbar","data-tauri-drag-region":n,children:m.jsxs("div",{ref:U,className:"terminal-tabbar-main","data-tauri-drag-region":n,children:[m.jsxs("div",{ref:W,className:"terminal-tabbar-scroll",role:"tablist","aria-label":w("terminal.title"),"data-window-drag":"ignore",children:[kn.map(c=>{const v=c.id===Nt,y=Ti.has(c.id),L=(M==null?void 0:M.terminalId)===c.id,G=Ei[c.id]??null,me=G?"creating":gn({terminal:c,paneBindings:It,paneConnectionStates:Ws,manuallyDisconnectedTerminalIdSet:zs});return m.jsxs("div",{className:"terminal-tab-shell","data-active":v,"data-assigned":h_(c.id,It,Ut),children:[m.jsx("button",{className:"terminal-tab","data-active":v,type:"button",role:"tab","aria-selected":v,"aria-busy":G!==null,onClick:()=>{v||o.trigger("selection"),Ks(c.id)},onAuxClick:ue=>{ue.button!==1||G!==null||(ue.preventDefault(),Xs(c.id))},children:m.jsx("span",{className:"terminal-tab-name",children:m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"terminal-tab-status-dot","data-status":me,"aria-hidden":"true"}),y?m.jsx("span",{className:"terminal-tab-pin-indicator",children:"•"}):null,m.jsx("span",{className:"terminal-tab-name-text",children:c.name}),m.jsx("span",{className:"terminal-tab-runtime",title:Kn(c.runtimeType,r.ui.osFamily),children:pr(c.runtimeType,r.ui.osFamily)}),G?m.jsxs("span",{className:"terminal-tab-operation","data-operation":G,children:[m.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),G==="closing"?w("terminal.closePendingBadge"):w("terminal.deletePendingBadge")]}):null]})})}),m.jsx("button",{ref:ue=>{H.current[c.id]=ue},className:"terminal-tab-inline-action",type:"button","data-open":L,disabled:G!==null,"aria-haspopup":"menu","aria-label":w("terminal.moreActions"),"aria-expanded":L,onClick:ue=>{if(ue.stopPropagation(),L){F(null);return}F(Hs(c.id,ue.currentTarget)??{terminalId:c.id,top:0,left:0})},children:"⋯"})]},c.id)}),nt?m.jsx("div",{className:"terminal-tab-shell",role:"presentation","data-active":Nt===null&&Pt===nt,"data-assigned":"false","data-pending":"true",children:m.jsx("div",{className:"terminal-tab","aria-hidden":"true",children:m.jsxs("span",{className:"terminal-tab-name",children:[m.jsx("span",{className:"terminal-tab-status-dot","data-status":"creating","aria-hidden":"true"}),m.jsx("span",{className:"terminal-tab-name-text",children:w("terminal.creating")}),m.jsx("span",{className:"terminal-tab-runtime",title:Kn(ce||void 0,r.ui.osFamily),children:pr(ce||void 0,r.ui.osFamily)})]})})}):null,m.jsx("button",{className:"terminal-tab-control",type:"button","aria-label":w("terminal.createButton"),title:w("terminal.createButton"),disabled:!N||de,onClick:()=>{Ll()},children:m.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:m.jsx("svg",{viewBox:"0 0 16 16",focusable:"false",children:m.jsx("path",{d:"M8 3.25a.75.75 0 0 1 .75.75v3.25H12a.75.75 0 0 1 0 1.5H8.75V12a.75.75 0 0 1-1.5 0V8.75H4A.75.75 0 0 1 4 7.25h3.25V4A.75.75 0 0 1 8 3.25Z"})})})})]}),m.jsx("div",{className:"terminal-tabbar-inline-actions",children:m.jsxs("div",{className:"terminal-toolbar-anchor","data-window-drag":"ignore",children:[m.jsx("div",{ref:j,className:"terminal-toolbar-inline","data-open":fe,"aria-hidden":!fe,"data-window-drag":"ignore",children:m.jsxs("div",{className:"terminal-toolbar-cluster",children:[El?m.jsx("button",{type:"button",className:"terminal-toolbar-menu-action",onClick:()=>{at&&(Be(!1),Hl(at,(At==null?void 0:At.name)??null))},children:w("terminal.openExternalAction")}):null,m.jsxs("div",{className:"terminal-toolbar-section",children:[m.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.runtimeField")}),m.jsx("select",{className:"terminal-runtime-select",value:ce,"aria-label":w("terminal.runtimeField"),title:($n=En.find(c=>c.value===ce))==null?void 0:$n.description,onChange:c=>{Te(c.target.value)},children:En.map(c=>m.jsx("option",{value:c.value,children:c.label},c.value||"auto"))})]}),m.jsxs("div",{className:"terminal-toolbar-section",children:[m.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.zoomLabel")}),m.jsxs("div",{className:"terminal-zoom-group","aria-label":w("terminal.zoomLabel"),children:[m.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":w("terminal.zoomOutAction"),onClick:()=>{Gs(ei-Vo)},children:"-"}),m.jsx("button",{type:"button",className:"terminal-zoom-value","aria-label":w("terminal.zoomResetAction"),onClick:()=>{Gs(1)},children:i_(ei)}),m.jsx("button",{type:"button",className:"terminal-zoom-button","aria-label":w("terminal.zoomInAction"),onClick:()=>{Gs(ei+Vo)},children:"+"})]})]}),m.jsxs("div",{className:"terminal-toolbar-section",children:[m.jsx("span",{className:"terminal-toolbar-label",children:w("terminal.layoutLabel")}),m.jsxs("div",{className:"terminal-layout-switcher",children:[m.jsx("button",{type:"button",className:"terminal-layout-button","data-active":Lt==="single","aria-label":w("terminal.layoutSingleAction"),onClick:()=>{Zs("single")},children:"1"}),m.jsx("button",{type:"button",className:"terminal-layout-button","data-active":Lt==="vertical","aria-label":w("terminal.layoutVerticalAction"),onClick:()=>{Zs("vertical")},children:"||"}),m.jsx("button",{type:"button",className:"terminal-layout-button","data-active":Lt==="horizontal","aria-label":w("terminal.layoutHorizontalAction"),onClick:()=>{Zs("horizontal")},children:"="})]})]}),m.jsx("button",{type:"button",className:"terminal-toolbar-save",disabled:!Je,onClick:()=>{Nl()},children:w("terminal.saveLogAction")})]})}),m.jsx("button",{ref:se,type:"button",className:"terminal-toolbar-toggle terminal-toolbar-toggle-tool","data-open":fe,"aria-label":w("terminal.toolbarToggleAction"),"aria-expanded":fe,onClick:()=>{F(null),Be(c=>!c)},children:m.jsx("span",{className:"terminal-toolbar-icon terminal-toolbar-icon-tool","aria-hidden":"true",children:m.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",focusable:"false",children:[m.jsx("path",{d:"M13.1 3.3a3.1 3.1 0 0 0-2.4 3.77L4.95 12.82a1.5 1.5 0 1 0 2.12 2.12l5.74-5.74a3.1 3.1 0 0 0 3.77-2.4l-1.76.5a1.06 1.06 0 0 1-1.04-.28l-1.3-1.3a1.06 1.06 0 0 1-.28-1.04l.9-1.38Z",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"m5.85 11.92 2.22 2.22",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round"})]})})})]})}),M&&$s?m.jsx(Of,{ref:E,actionMenu:M,terminal:$s,paneBindings:It,splitDirection:Ut,activePaneId:fi,paneConnectionStates:Ws,pinnedTerminalIdSet:Ti,manuallyDisconnectedTerminalIdSet:zs,pendingMutation:Ei[$s.id]??null,onBindToActivePane:Ks,onBindToPane:Bi,onDuplicate:On,onDisconnect:Hn,onReconnect:zn,onClose:Xs,onDelete:Nn,onTogglePin:Fn,onCloseMenu:()=>{F(null)}}):null]})}),m.jsx("div",{className:"terminal-stage-surface",children:m.jsx("div",{className:"terminal-stage-grid","data-layout":Ut,"data-mobile":"false",children:Rl.map(c=>{const v=It[c],y=ae.find(L=>L.id===v)??null;return m.jsx(ta,{paneId:c,paneLabel:c==="primary"?w("terminal.panePrimary"):w("terminal.paneSecondary"),terminal:y,pendingCreation:!y&&nt===c,zoomScale:ei,active:fi===c,ownsTerminalSize:Rn,onActivate:Pn,onConnectionChange:Mn,onTerminalStatus:Dn,onRequireReload:Bn,onUnauthorized:Cn,registerApi:yn,notifyTerminal:Ze},`${c}-${(y==null?void 0:y.id)??"empty"}`)})})})]})}),m.jsx(ea,{open:C,loading:K,creating:de,shellChoices:xt,osFamily:r.ui.osFamily,selectedShell:ye,runtimeType:ps(ce,r.ui.osFamily),title:w("terminal.createDialogTitle"),shellLabel:w("terminal.mobileCreateShellLabel"),shellDescription:w("terminal.createDialogShellDescription"),runtimeLabel:w("terminal.mobileCreateRuntimeLabel"),runtimeDescription:w("terminal.createDialogRuntimeDescription"),confirmLabel:w("terminal.createDialogConfirm"),onClose:()=>{de||R(!1)},onSelectShell:Ce,onSelectRuntime:c=>{Te(c)},onConfirm:()=>{Pl()}})]})}function Af({open:e,terminals:t,pinnedTerminalIds:i,activeTerminalId:s,creatingTerminal:r,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,terminalMutations:l,manuallyDisconnectedTerminalIdSet:u,onClose:d,onCreateTerminal:_,onSelectTerminal:p,onBindToActivePane:f,onBindToPane:g,onDuplicate:E,onDisconnect:D,onReconnect:U,onCloseTerminal:W,onDeleteTerminal:H,onTogglePin:O}){const j=b.useRef(null),[se,Z]=b.useState(null),V=t.filter(x=>i.has(x.id)),oe=t.filter(x=>!i.has(x.id)),X=t.find(x=>x.id===se)??null;return b.useEffect(()=>{e||Z(null)},[e]),e?m.jsxs(m.Fragment,{children:[m.jsxs("section",{className:"terminal-mobile-list-rail surface-card","aria-label":w("terminal.mobileDrawerTitle"),onTouchStart:x=>{const S=x.touches[0];S&&(j.current={x:S.clientX,y:S.clientY})},onTouchEnd:x=>{const S=j.current,T=x.changedTouches[0];if(j.current=null,!S||!T)return;const P=T.clientX-S.x,B=T.clientY-S.y;Math.abs(P)<_n||Math.abs(B)>mn||Math.abs(P)<=Math.abs(B)||P>=0||d()},onTouchCancel:()=>{j.current=null},children:[m.jsxs("div",{className:"terminal-mobile-list-heading",children:[m.jsx("strong",{children:w("terminal.mobileDrawerTitle")}),m.jsx("p",{children:w("terminal.mobileDrawerDescription")})]}),m.jsxs("div",{className:"terminal-mobile-list-body",children:[V.length>0?m.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[m.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[m.jsx("span",{children:w("terminal.mobilePinnedSectionTitle")}),m.jsx("span",{className:"workbench-section-counter",children:V.length})]}),m.jsx("div",{className:"terminal-mobile-session-list",children:V.map(x=>m.jsx(Qo,{terminal:x,active:x.id===s,pendingMutation:l[x.id]??null,onOpen:p,onOpenMenu:S=>{Z(T=>T===S?null:S)}},x.id))})]}):null,m.jsxs("section",{className:"terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[m.jsxs("div",{className:"terminal-mobile-list-group-heading",children:[m.jsx("span",{children:w("terminal.workspaceField")}),m.jsx("span",{className:"workbench-section-counter",children:oe.length})]}),oe.length>0?m.jsx("div",{className:"terminal-mobile-session-list",children:oe.map(x=>m.jsx(Qo,{terminal:x,active:x.id===s,pendingMutation:l[x.id]??null,onOpen:p,onOpenMenu:S=>{Z(T=>T===S?null:S)}},x.id))}):m.jsx("div",{className:"workbench-session-empty",children:w("terminal.mobileDrawerEmptyDescription")})]})]}),m.jsx("div",{className:"terminal-mobile-list-footer",children:m.jsxs("button",{type:"button",className:"workbench-import-toggle terminal-mobile-list-create",disabled:r,onClick:_,children:[m.jsx("span",{className:"workbench-import-toggle-symbol",children:"+"}),m.jsx("span",{className:"workbench-import-toggle-label",children:w("terminal.createButton")})]})})]}),m.jsx(If,{terminal:X,pendingMutation:X?l[X.id]??null:null,paneBindings:n,splitDirection:o,activePaneId:a,paneConnectionStates:h,pinnedTerminalIdSet:i,manuallyDisconnectedTerminalIdSet:u,onClose:()=>{Z(null)},onBindToActivePane:x=>{Z(null),f(x)},onBindToPane:(x,S)=>{Z(null),g(x,S)},onDuplicate:async x=>{Z(null),await E(x)},onDisconnect:x=>{Z(null),D(x)},onReconnect:x=>{Z(null),U(x)},onCloseTerminal:async x=>{Z(null),await W(x)},onDeleteTerminal:async x=>{Z(null),await H(x)},onTogglePin:x=>{Z(null),O(x)}})]}):null}function Qo({terminal:e,active:t,pendingMutation:i,onOpen:s,onOpenMenu:r}){return m.jsxs("article",{className:"terminal-mobile-session-card","data-active":t,children:[m.jsxs("button",{type:"button",className:"terminal-mobile-session-primary","data-active":t?"true":"false",onClick:()=>{s(e.id)},children:[m.jsxs("div",{className:"terminal-mobile-session-title-row",children:[m.jsx("span",{className:t_(e.status)}),m.jsx("span",{className:"terminal-mobile-session-title",title:e.name,children:e.name}),m.jsx("span",{className:"terminal-mobile-session-runtime-badge",children:pr(e.runtimeType)})]}),m.jsx("div",{className:"terminal-mobile-session-path",title:e.cwd,children:e.cwd}),i?m.jsxs("div",{className:"terminal-mobile-session-operation",children:[m.jsx("span",{className:"terminal-tab-operation-spinner","aria-hidden":"true"}),m.jsx("span",{children:i==="closing"?w("terminal.closePendingBadge"):w("terminal.deletePendingBadge")})]}):null]}),m.jsx("button",{type:"button",className:"terminal-mobile-session-action","aria-label":w("terminal.moreActions"),title:w("terminal.moreActions"),onClick:n=>{n.stopPropagation(),r(e.id)},children:m.jsx(gl,{})})]})}function If({terminal:e,pendingMutation:t,paneBindings:i,splitDirection:s,activePaneId:r,paneConnectionStates:n,pinnedTerminalIdSet:o,manuallyDisconnectedTerminalIdSet:a,onClose:h,onBindToActivePane:l,onBindToPane:u,onDuplicate:d,onDisconnect:_,onReconnect:p,onCloseTerminal:f,onDeleteTerminal:g,onTogglePin:E}){if(!e||typeof document>"u")return null;const D=o.has(e.id),U=Yi(e.id,i,s,r),W=U?n[U]:"closed",H=gn({terminal:e,paneBindings:i,paneConnectionStates:n,manuallyDisconnectedTerminalIdSet:a}),O=t===null&&e.status==="running"&&H!=="disconnected",j=t===null&&!O,se=t===null&&U!==null&&e.status==="running";return m.jsxs(ma,{open:!0,title:w("terminal.moreActions"),description:e.name,kind:"action",height:"auto",className:"terminal-mobile-action-sheet",cardClassName:"terminal-mobile-action-sheet-card",bodyClassName:"terminal-mobile-action-list",onClose:h,children:[s!=="single"?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{u(e.id,"primary")},children:w("terminal.bindToPrimaryPaneAction")}),m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.secondary===e.id,onClick:()=>{u(e.id,"secondary")},children:w("terminal.bindToSecondaryPaneAction")})]}):m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null||i.primary===e.id,onClick:()=>{l(e.id)},children:w("terminal.bindToPaneAction")}),m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{d(e)},children:w("terminal.duplicateAction")}),se?W==="connected"?m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{_(e.id)},children:w("terminal.disconnectAction")}):m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{p(e.id)},children:w("terminal.reconnectAction")}):null,O?m.jsx("button",{type:"button",className:"terminal-mobile-action-item",onClick:()=>{f(e.id)},children:w("terminal.closeButton")}):null,j?m.jsx("button",{type:"button",className:"terminal-mobile-action-item danger",onClick:()=>{g(e.id)},children:w("terminal.deleteAction")}):null,m.jsx("button",{type:"button",className:"terminal-mobile-action-item",disabled:t!==null,onClick:()=>{E(e.id)},children:D?w("terminal.unpinAction"):w("terminal.pinAction")})]})}function Nf(e,t,i,s){b.useEffect(()=>{const r=e.current,n=t.current;if(!i||!r){r&&r.style.removeProperty("--terminal-mobile-header-height");return}if(!n){r.style.removeProperty("--terminal-mobile-header-height");return}const o=r,a=n;function h(){!e.current||!a.isConnected||o.style.setProperty("--terminal-mobile-header-height",`${a.offsetHeight}px`)}h();const l=typeof ResizeObserver<"u"?new ResizeObserver(h):null;return l==null||l.observe(a),window.addEventListener("resize",h),()=>{l==null||l.disconnect(),window.removeEventListener("resize",h),r.style.removeProperty("--terminal-mobile-header-height")}},[i,t,s,e])}function ea({open:e,loading:t,creating:i,shellChoices:s,osFamily:r,selectedShell:n,runtimeType:o,title:a,shellLabel:h,shellDescription:l,runtimeLabel:u,runtimeDescription:d,confirmLabel:_,onClose:p,onSelectShell:f,onSelectRuntime:g,onConfirm:E}){if(!e||typeof document>"u")return null;const D=s.find(O=>O.value===n)??s[0]??null,U=ga(r).find(O=>O.value==="tmux")??null,W=[{value:"tmux",title:(U==null?void 0:U.label)??w("terminal.mobileRuntimePersistentTitle"),description:(U==null?void 0:U.description)??w("terminal.mobileRuntimePersistentDescription")},{value:"embedded-pty",title:w("terminal.mobileRuntimeSessionTitle"),description:w("terminal.mobileRuntimeSessionDescription")}],H=i||t||!D||!D.available;return m.jsxs(ma,{open:!0,title:a,kind:"form",height:"three-quarter",className:"terminal-mobile-create-sheet",cardClassName:"terminal-mobile-create-sheet-card",bodyClassName:"terminal-mobile-create-sheet-body",dismissible:!i,onClose:p,children:[m.jsxs("section",{className:"terminal-mobile-create-section",children:[m.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[m.jsx("strong",{children:h}),m.jsx("p",{children:l})]}),t&&s.length===0?m.jsxs("div",{className:"terminal-mobile-create-loading",children:[m.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),m.jsx("span",{children:w("terminal.mobileCreateLoadingShells")})]}):m.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:s.map(O=>{const j=O.value===n;return m.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":j?"true":"false",disabled:!O.available||i,onClick:()=>{f(O.value)},children:[m.jsxs("span",{className:"terminal-mobile-choice-copy",children:[m.jsx("strong",{children:O.label}),m.jsx("span",{children:O.description})]}),!O.available&&O.unavailableReason?m.jsx("span",{className:"terminal-mobile-choice-badge terminal-mobile-choice-badge-muted",children:O.unavailableReason}):j?m.jsx("span",{className:"terminal-mobile-choice-badge",children:w("settings.enabled")}):null]},O.id)})})]}),m.jsxs("section",{className:"terminal-mobile-create-section",children:[m.jsxs("div",{className:"terminal-mobile-create-section-copy",children:[m.jsx("strong",{children:u}),m.jsx("p",{children:d})]}),m.jsx("div",{className:"terminal-mobile-choice-grid",role:"list",children:W.map(O=>{const j=O.value===o;return m.jsxs("button",{type:"button",className:"terminal-mobile-choice-card","data-selected":j?"true":"false",disabled:i,onClick:()=>{g(O.value)},children:[m.jsxs("span",{className:"terminal-mobile-choice-copy",children:[m.jsx("strong",{children:O.title}),m.jsx("span",{children:O.description})]}),j?m.jsx("span",{className:"terminal-mobile-choice-badge",children:w("settings.enabled")}):null]},O.value)})})]}),m.jsx("button",{type:"button",className:"terminal-mobile-primary-action terminal-mobile-create-confirm",disabled:H,onClick:E,children:i?w("terminal.creating"):_})]})}function gl(){return m.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[m.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),m.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),m.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}const Of=b.forwardRef(function({actionMenu:t,terminal:i,pendingMutation:s,paneBindings:r,splitDirection:n,activePaneId:o,paneConnectionStates:a,pinnedTerminalIdSet:h,manuallyDisconnectedTerminalIdSet:l,onBindToActivePane:u,onBindToPane:d,onDuplicate:_,onDisconnect:p,onReconnect:f,onClose:g,onDelete:E,onTogglePin:D,onCloseMenu:U},W){const H=h.has(i.id),O=Yi(i.id,r,n,o),j=O?a[O]:"closed",se=gn({terminal:i,paneBindings:r,paneConnectionStates:a,manuallyDisconnectedTerminalIdSet:l}),Z=s===null&&i.status==="running"&&se!=="disconnected",V=s===null&&!Z,oe=s===null&&O!==null&&i.status==="running",X=n!=="single";return m.jsxs("div",{ref:W,className:"terminal-tab-menu",role:"menu",style:{top:`${t.top}px`,left:`${t.left}px`},onClick:x=>{x.stopPropagation()},children:[X?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{d(i.id,"primary")},children:w("terminal.bindToPrimaryPaneAction")}),m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.secondary===i.id,onClick:()=>{d(i.id,"secondary")},children:w("terminal.bindToSecondaryPaneAction")})]}):m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null||r.primary===i.id,onClick:()=>{u(i.id)},children:w("terminal.bindToPaneAction")}),m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{U(),_(i)},children:w("terminal.duplicateAction")}),oe?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),j==="connected"?m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{p(i.id)},children:w("terminal.disconnectAction")}):m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{f(i.id)},children:w("terminal.reconnectAction")})]}):null,m.jsx("div",{className:"terminal-tab-menu-divider",role:"separator"}),Z?m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{U(),g(i.id)},children:w("terminal.closeButton")}):null,V?m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",onClick:()=>{E(i.id)},children:w("terminal.deleteAction")}):null,m.jsx("button",{type:"button",className:"terminal-tab-menu-item",role:"menuitem",disabled:s!==null,onClick:()=>{D(i.id)},children:H?w("terminal.unpinAction"):w("terminal.pinAction")})]})});function ta({paneId:e,paneLabel:t,terminal:i,pendingCreation:s,zoomScale:r,active:n,ownsTerminalSize:o,isMobileLayout:a=!1,canCreateTerminal:h=!0,onActivate:l,onSwipeGesture:u,onConnectionChange:d,onTerminalStatus:_,onRequireReload:p,onUnauthorized:f,registerApi:g,notifyTerminal:E,onRequestCreateTerminal:D,onRequestOpenTerminalDrawer:U}){const W=pa(),H=b.useRef(null),O=b.useRef(null),j=b.useRef(null),se=b.useRef(null),Z=b.useRef(null),V=b.useRef(null),oe=b.useRef(null),X=b.useRef(null),x=b.useRef(null),S=b.useRef(!0),T=b.useRef(!1),P=b.useRef(null),B=b.useRef((i==null?void 0:i.status)??null),$=b.useRef(!1),I=b.useRef([]),N=b.useRef(n),[ne,ce]=b.useState(null),Te=!a,Q=b.useCallback(C=>{var R;C&&((R=Z.current)==null||R.sendInput(C))},[]),ee=b.useCallback(()=>{ce(null)},[]),ye=b.useCallback(()=>{const C=V.current,R=typeof(C==null?void 0:C.terminal.getSelection)=="function"?C.terminal.getSelection():"";if(R.trim())return R.trim();const K=typeof document>"u"?null:document.getSelection();return(K==null?void 0:K.toString().trim())??""},[]),Ce=b.useCallback(async()=>{var K;const C=(ne==null?void 0:ne.text)??ye();if(!C){ee();return}const R=await W.bridge.writeClipboardText(C);if(!R.ok){E(R.detail||w("common.copyFailed"),"error");return}ee(),(K=V.current)==null||K.focus()},[ee,E,W.bridge,ye,ne==null?void 0:ne.text]),Ne=b.useCallback(C=>{const R=Number(C);!Number.isInteger(R)||R<=0||(X.current=X.current===null?R:Math.min(X.current,R),x.current=X.current)},[]),ct=b.useCallback(async C=>{const R=V.current;if(!R)return;if(!C.content){S.current=C.hasMore,x.current=C.nextBeforeSeq;return}const K=bl(R.readPlainText()),re=C.replaceContent?Math.max(0,C.lineCount-K):C.anchorLine;await R.prependHistory(C.content,re,{replaceContent:C.replaceContent===!0}),X.current=C.nextBeforeSeq??X.current,x.current=C.nextBeforeSeq,S.current=C.hasMore,R.schedulePersist()},[]),ge=b.useCallback(()=>{const C=V.current;return C?C.terminal.buffer.active.baseY===0:!1},[]),ve=b.useCallback(async()=>{if(!(i!=null&&i.id)||T.current||!S.current)return;const C=x.current;if(C!==null){T.current=!0;try{let R=C,K=Tf;for(;R!==null&&K>0;){const re=await rh(i.id,{beforeSeq:R,limit:Ef});if(await ct(re),K-=1,!re.hasMore||!ge())break;R=re.nextBeforeSeq}}catch(R){E(R instanceof Error?R.message:w("conversation.historyLoadFailed"),"error")}finally{T.current=!1}}},[ct,E,ge,i==null?void 0:i.id]);b.useEffect(()=>{B.current=(i==null?void 0:i.status)??null},[i==null?void 0:i.status]),b.useEffect(()=>{ee()},[ee,i==null?void 0:i.id]),b.useEffect(()=>{N.current=n},[n]),b.useEffect(()=>{var C;n&&((C=V.current)==null||C.focus())},[n,i==null?void 0:i.id]),b.useEffect(()=>{if(!ne)return;function C(K){var ae;const re=K.target;re&&(((ae=j.current)==null?void 0:ae.contains(re))??!1)||ee()}function R(K){K.key==="Escape"&&ee()}return window.addEventListener("mousedown",C),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),window.addEventListener("keydown",R),()=>{window.removeEventListener("mousedown",C),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),window.removeEventListener("keydown",R)}},[ee,ne]),b.useEffect(()=>{var C,R;(C=V.current)==null||C.setFontSize(ha(r)),(R=V.current)==null||R.reflow()},[r]),b.useEffect(()=>{var R;const C=V.current;C&&(C.reflow(),o&&((R=Z.current)==null||R.sendCurrentDimensions(C.terminal.cols,C.terminal.rows)))},[o,i==null?void 0:i.id]),b.useEffect(()=>{if(typeof document>"u")return;const C=()=>{var K;(K=V.current)==null||K.applyTheme()};C();const R=new MutationObserver(K=>{K.some(re=>re.attributeName==="data-theme")&&C()});return R.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{R.disconnect()}},[i==null?void 0:i.id]),b.useEffect(()=>{var K;if((K=V.current)==null||K.dispose(),V.current=null,g(e,null),!(i!=null&&i.id)||!H.current)return;const C=en(i.id).viewState,R=Ff({container:H.current,restoredViewState:C,fontSize:ha(r),enableTouchMomentum:a,getCursor:()=>oe.current,getHistoryPaging:()=>({beforeSeq:x.current,hasOlder:S.current}),canResize:()=>B.current==="running"&&o,onInput:Q,onResize:({cols:re,rows:ae})=>{var Re;o&&((Re=Z.current)==null||Re.resize(re,ae))},onViewportTop:()=>{ve()},onCursorChange:re=>{$d(i.id,re)},onViewStateChange:re=>{jd(i.id,re)}});return V.current=R,g(e,{focus:()=>{R.focus()},readPlainText:()=>R.readPlainText(),disconnect:()=>{var re;(re=Z.current)==null||re.disconnect()},reconnect:()=>{var re;(re=Z.current)==null||re.reconnectNow()}}),()=>{R.persistNow(),R.dispose(),V.current===R&&(V.current=null),g(e,null)}},[Q,ve,o,e,g,i==null?void 0:i.id,r]),b.useEffect(()=>{var ae,Re;if((ae=Z.current)==null||ae.close(),Z.current=null,P.current=null,(Re=V.current)==null||Re.suspendInputForwarding(),d(e,"closed"),!(i!=null&&i.id)){oe.current=null,X.current=null,x.current=null,S.current=!0,T.current=!1,$.current=!1,I.current=[];return}const C=en(i.id),R=C.viewState,K=C.resumeCursor;oe.current=K,X.current=(R==null?void 0:R.historyBeforeSeq)??null,x.current=(R==null?void 0:R.historyBeforeSeq)??null,S.current=(R==null?void 0:R.historyHasOlder)===!1&&i.runtimeType==="tmux"?!0:(R==null?void 0:R.historyHasOlder)??!0,T.current=!1,$.current=!1,I.current=[];const re=new nf({terminalId:i.id,lastCursor:K,onConnectionChange:q=>{var Y;q!=="connected"&&((Y=V.current)==null||Y.suspendInputForwarding()),d(e,q)},onSubscribed:()=>{var Y;const q=V.current;q&&(q.suspendInputForwarding(),q.reflow(),o&&re.sendCurrentDimensions(q.terminal.cols,q.terminal.rows),q.resumeInputForwarding(i.runtimeType==="tmux"?cf:0)),N.current&&((Y=V.current)==null||Y.focus())},onBackfill:q=>{var dt,M;const Y=V.current,de=Os(q.chunks),ut=Y==null?void 0:Y.shouldAutoRevealLatest();Y&&(q.cursorReset?(ra(Y.terminal,de,()=>{ut&&Y.revealLatest()}),X.current=null):Y.restoredFromSnapshot?sa(Y.terminal,de,()=>{ut&&Y.revealLatest()}):(ra(Y.terminal,de,()=>{ut&&Y.revealLatest()}),X.current=null)),$.current=!0,de.length>0&&Ne((dt=de[0])==null?void 0:dt.cursor);const nt=q.latestCursor??oe.current;if(oe.current=nt,Y==null||Y.scheduleCursorPersist(nt),Y&&I.current.length>0){const F=zf(I.current,q.latestCursor);if(I.current=[],F.length>0){sa(Y.terminal,F);const fe=((M=F.at(-1))==null?void 0:M.cursor)??nt;oe.current=fe,Y.scheduleCursorPersist(fe)}}if(P.current==="idle_closed"){E(w("terminal.recoveryIdleClosed"),"warning");return}if(K){E(q.truncated?w("terminal.recoveryTruncated"):w("terminal.recoveryComplete"),q.truncated?"warning":"success");return}R!=null&&R.content||E(w("terminal.connectedHint"))},onOutput:q=>{const Y=V.current,de=!$.current,ut=Y==null?void 0:Y.shouldAutoRevealLatest();if(de){I.current=[...I.current,q.chunk],oe.current=q.chunk.cursor,Y==null||Y.scheduleCursorPersist(q.chunk.cursor);return}if(Y&&ai()){const nt=Rt();Y.terminal.write(q.chunk.content,()=>{ji("terminal.output.rendered",{terminalId:i.id,cursor:q.chunk.cursor,charCount:q.chunk.content.length,renderMs:Rt()-nt}),ut&&Y.revealLatest()})}else Y==null||Y.terminal.write(q.chunk.content,()=>{ut&&(Y==null||Y.revealLatest())});oe.current=q.chunk.cursor,Ne(q.chunk.cursor),Y==null||Y.scheduleCursorPersist(q.chunk.cursor)},onStatus:q=>{if(_({id:q.terminal.id,status:q.terminal.status,statusDetail:q.terminal.statusDetail,processId:q.terminal.processId??null}),q.terminal.id===i.id){if(B.current=q.terminal.status,q.terminal.status!=="running"&&d(e,"closed"),q.terminal.status==="closed"&&q.terminal.statusDetail==="TERMINAL_IDLE_TIMEOUT"){P.current="idle_closed",E(w("terminal.recoveryIdleClosed"),"warning");return}q.terminal.status==="error"&&q.terminal.statusDetail&&E(q.terminal.statusDetail,"error")}},onError:q=>{if(q.terminalId===i.id){if(q.error_code==="TERMINAL_NOT_RUNNING"){p();return}q.error_code!=="INVALID_TERMINAL_SIZE"&&E(q.detail,"error")}},onUnauthorized:f});return Z.current=re,re.start(),()=>{re.close(),$.current=!1,I.current=[],d(e,"closed")}},[ve,E,d,p,_,f,e,i==null?void 0:i.id,i==null?void 0:i.runtimeType,o,Ne]);const vt=b.useCallback(C=>{var K;if(!Te||!n||!(i!=null&&i.id)||Gf(C))return;const R=Zf(C.nativeEvent);R&&(C.preventDefault(),C.stopPropagation(),Q(R),(K=V.current)==null||K.focus())},[n,Q,i==null?void 0:i.id,Te]),Se=b.useCallback(C=>{var K;if(!Te||!n||!(i!=null&&i.id)||Sl(C.target))return;const R=C.clipboardData.getData("text");R&&(C.preventDefault(),Q(R),(K=V.current)==null||K.focus())},[n,Q,i==null?void 0:i.id,Te]);return m.jsx("article",{ref:O,className:"terminal-pane-card","data-active":n,"data-empty":!i,tabIndex:i?0:-1,onMouseDown:C=>{ee(),l(e),C.currentTarget.focus({preventScroll:!0})},onClick:()=>{var C;ee(),(C=V.current)==null||C.focus()},onKeyDown:vt,onPaste:Se,onContextMenu:C=>{var de;if(a||!i)return;const R=ye();if(!R){ee();return}const K=(de=O.current)==null?void 0:de.getBoundingClientRect();if(!K)return;C.preventDefault(),l(e);const re=164,ae=52,Re=8,q=Math.max(Re,K.width-re-Re),Y=Math.max(Re,K.height-ae-Re);ce({text:R,left:Ds(C.clientX-K.left,Re,q),top:Ds(C.clientY-K.top,Re,Y)})},onTouchStart:C=>{if(!a)return;const R=C.touches[0];R&&(se.current={x:R.clientX,y:R.clientY})},onTouchEnd:C=>{if(!a||!u){se.current=null;return}const R=se.current,K=C.changedTouches[0];if(se.current=null,!R||!K)return;const re=K.clientX-R.x,ae=K.clientY-R.y;Math.abs(re)<_n||Math.abs(ae)>mn||Math.abs(re)<=Math.abs(ae)||u(re<0?"left":"right")},onTouchCancel:()=>{se.current=null},children:i?m.jsxs("div",{className:"terminal-canvas",children:[m.jsx("div",{ref:H,className:"terminal-xterm"}),ne?m.jsx("div",{ref:j,className:"terminal-selection-menu",style:{top:ne.top,left:ne.left},role:"menu","aria-label":w("common.copy"),onMouseDown:C=>{C.stopPropagation()},onClick:C=>{C.stopPropagation()},onContextMenu:C=>{C.preventDefault(),C.stopPropagation()},children:m.jsx("button",{type:"button",className:"terminal-selection-menu-action",role:"menuitem",onClick:()=>{Ce()},children:w("common.copy")})}):null]}):s?m.jsxs("div",{className:"terminal-empty-state terminal-empty-state-inline terminal-pending-state",children:[m.jsx("span",{className:"terminal-pane-label",children:t}),m.jsx("span",{className:"terminal-pending-indicator","aria-hidden":"true"}),m.jsx("h1",{children:w("terminal.creating")}),m.jsx("p",{children:w("terminal.creationPendingDescription")})]}):m.jsxs("div",{className:a?"terminal-empty-state terminal-empty-state-inline terminal-mobile-empty-state":"terminal-empty-state terminal-empty-state-inline",children:[m.jsx("span",{className:"terminal-pane-label",children:t}),m.jsx("h1",{children:a?w("terminal.mobileEmptyTitle"):w("terminal.stageEmptyTitle")}),m.jsx("p",{children:a?w("terminal.mobileEmptyDescription"):w("terminal.splitEmptySubtitle")}),a?m.jsxs("div",{className:"terminal-mobile-empty-actions",children:[m.jsx("button",{type:"button",className:"terminal-mobile-primary-action",disabled:!h,onClick:()=>{D==null||D()},children:w("terminal.createButton")}),m.jsx("button",{type:"button",className:"terminal-mobile-secondary-action",onClick:()=>{U==null||U()},children:w("terminal.mobileDrawerAction")})]}):null]})})}function Ff(e){var de,ut,nt,dt;const t=la(),i=new Ed({cols:((de=e.restoredViewState)==null?void 0:de.cols)??df,rows:((ut=e.restoredViewState)==null?void 0:ut.rows)??ff,cursorBlink:!0,scrollback:2e3,allowTransparency:!1,fontFamily:'"Cascadia Mono", "Cascadia Code", "Consolas", monospace',fontSize:e.fontSize,theme:t}),s=new uh,r=new ph,n=lf(M=>{e.onInput(M)});let o=null,a=null,h=null,l=!1,u=!1,d=!1,_=i.cols,p=i.rows,f=null,g=null;const E=new Set;let D=null,U=0,W=0,H=0,O=null,j=0,se=!1;const Z=()=>{i.focus()};i.loadAddon(s),i.loadAddon(r),i.onData(M=>{n.enqueue(M)});const V=typeof i.onScroll=="function"?i.onScroll(M=>{var F;M===0&&((F=e.onViewportTop)==null||F.call(e)),Se()}):null;i.onResize(({cols:M,rows:F})=>{_=M,p=F,e.canResize()&&e.onResize({cols:M,rows:F}),Se()}),e.container.replaceChildren(),i.open(e.container),aa(e.container,t);const oe=e.container.querySelector(".xterm"),X=e.container.querySelector(".xterm-viewport"),x=X instanceof HTMLElement?X:oe instanceof HTMLElement?oe:e.container,S=oe instanceof HTMLElement?oe:e.container;S.addEventListener("mousedown",Z,{passive:!0}),S.addEventListener("pointerdown",Z,{passive:!0}),x.style.touchAction="pan-y",x.style.overscrollBehavior="contain","webkitOverflowScrolling"in x.style&&(x.style.webkitOverflowScrolling="touch");const T=M=>{var Be;if(u||M.deltaY===0)return!1;const F=i.buffer.active.viewportY===0;return i.buffer.active.baseY>0?!0:(M.deltaY<0&&F&&((Be=e.onViewportTop)==null||Be.call(e)),!1)},P=()=>i.buffer.active.baseY>0||i.buffer.active.viewportY>0,B=()=>{O!==null&&(window.cancelAnimationFrame(O),O=null),j=0},$=M=>{var Ye;if(u||M===0)return!1;const F=i.buffer.active.viewportY===0,fe=i.buffer.active.viewportY;if(P()){i.scrollLines(M);const ot=i.buffer.active.viewportY!==fe;return Se(),ot}return M<0&&F&&((Ye=e.onViewportTop)==null||Ye.call(e)),!1},I=()=>{if(!e.enableTouchMomentum){W=0;return}if(B(),!se||!P()||Math.abs(W)<Go){W=0;return}let M=performance.now(),F=0,fe=0;const Be=Ye=>{if(u){B();return}const ot=Math.max(1,Ye-M);M=Ye,F+=ot,j+=W*ot;const Ct=ia(j);if(Ct!==0){if(fe=0,j-=Ct,!$(Ct)){W=0,B();return}}else fe+=1;if(W*=Math.pow(Mf,ot/16),fe>=Lf||F>=Df||Math.abs(W)<Go){W=0,B();return}O=window.requestAnimationFrame(Be)};O=window.requestAnimationFrame(Be)},N=M=>{const F=M.touches[0];if(B(),W=0,se=!1,H=performance.now(),!F){D=null;return}D={x:F.clientX,y:F.clientY}},ne=M=>{if(!D)return;const F=M.touches[0];if(!F)return;const fe=F.clientX-D.x,Be=F.clientY-D.y;if(Math.abs(Be)<=Math.abs(fe)){D={x:F.clientX,y:F.clientY};return}M.preventDefault();const Ye=performance.now(),ot=Math.max(1,Ye-H);H=Ye;const Ct=-Be/Rf;U+=Ct;const St=ia(U);if(St!==0){U-=St;const Lt=$(St);if(e.enableTouchMomentum&&Lt){const Qi=Ds(St/ot*Bf,-Zo,Zo);W=W===0?Qi:W*.35+Qi*.65,se=!0}else Lt||(W=0,se=!1)}D={x:F.clientX,y:F.clientY}},ce=()=>{D=null,U=0,I()},Te=()=>{D=null,U=0,W=0,se=!1,B()};typeof i.attachCustomWheelEventHandler=="function"&&i.attachCustomWheelEventHandler(T),S.addEventListener("touchstart",N,{passive:!0}),S.addEventListener("touchmove",ne,{passive:!1}),S.addEventListener("touchend",ce,{passive:!0}),S.addEventListener("touchcancel",Te,{passive:!0}),(nt=e.restoredViewState)!=null&&nt.content?i.write(e.restoredViewState.content,()=>{const M=e.restoredViewState;M&&M.viewportY>0&&i.scrollToLine(M.viewportY),ct().then(()=>{K()})}):ct().then(()=>{K()});const Q=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{window.requestAnimationFrame(()=>{C()})});Q==null||Q.observe(e.container),typeof document<"u"&&"fonts"in document&&document.fonts.ready.then(()=>{K()});const ee=()=>{R()},ye=()=>{K()};typeof window<"u"&&(window.addEventListener("resize",ee),window.addEventListener("pageshow",ye),(dt=window.visualViewport)==null||dt.addEventListener("resize",ee));const Ce=()=>{ji("terminal.persist.pagehide",{cursor:e.getCursor()}),ge()},Ne=()=>{document.visibilityState==="hidden"&&(ji("terminal.persist.visibility_hidden",{cursor:e.getCursor()}),ge())};typeof window<"u"&&window.addEventListener("pagehide",Ce),typeof document<"u"&&document.addEventListener("visibilitychange",Ne);async function ct(){for(let M=0;M<10;M+=1){if(oa(e.container))return;await new Promise(F=>{window.requestAnimationFrame(()=>F())})}}function ge(){if(u)return;const M=ai()?Rt():0;o!==null&&(window.clearTimeout(o),o=null);const F=Hf(i,r,e.getCursor(),e.getHistoryPaging());F?(a!==null&&(window.clearTimeout(a),a=null),l=!1):ve(e.getCursor()),e.onViewStateChange(F),ai()&&ji("terminal.persist.completed",{cursor:e.getCursor(),hasViewState:!!F,contentLength:(F==null?void 0:F.content.length)??0,historyBeforeSeq:(F==null?void 0:F.historyBeforeSeq)??null,durationMs:Rt()-M})}function ve(M){u||(a!==null&&(window.clearTimeout(a),a=null),M!==void 0&&(h=M,l=!0),l&&(e.onCursorChange(h),l=!1))}function vt(M){u||(h=M,l=!0,a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{ve()},yf))}function Se(){u||(o!==null&&window.clearTimeout(o),o=window.setTimeout(()=>{ge()},Cf))}function C(){var Be,Ye;if(u)return;const M=Re();if(re(),!oa(e.container))return;const F=Uf(e.container,i,s);if(!F||F.cols<ml||F.rows<pl||d&&F.cols===_&&F.rows===p)return;const fe=vl(i);(i.cols!==F.cols||i.rows!==F.rows)&&((Ye=(Be=fe==null?void 0:fe._renderService)==null?void 0:Be.clear)==null||Ye.call(Be),i.resize(F.cols,F.rows)),d=!0,_=i.cols,p=i.rows,M&&ae()}function R(){if(u)return;const M=window.requestAnimationFrame(()=>{E.delete(M),C()});E.add(M)}function K(){R();const M=window.requestAnimationFrame(()=>{E.delete(M),R()});E.add(M),f!==null&&window.clearTimeout(f),f=window.setTimeout(()=>{f=null,R()},uf)}function re(){const M=$f(e.container.clientHeight);e.container.style.setProperty("--terminal-bottom-gap",`${M}px`)}function ae(){na(e.container,i),Y()}function Re(){return jf(e.container,i)}function q(){const M=la();i.options.theme=M,aa(e.container,M)}function Y(){if(u||typeof window>"u")return;g!==null&&window.cancelAnimationFrame(g);const M=F=>{g=window.requestAnimationFrame(()=>{if(u){g=null;return}if(na(e.container,i),F<=1){g=null;return}M(F-1)})};M(2)}return{terminal:i,restoredFromSnapshot:!!e.restoredViewState,focus:()=>{i.focus()},reflow:()=>{C()},revealLatest:ae,shouldAutoRevealLatest:Re,prependHistory:async(M,F=bl(M),fe={})=>{if(!M)return;const Be=i.buffer.active.viewportY,Ye=ca(i),ot=fe.replaceContent?Ls(M):o_(M,Ye);await new Promise(Ct=>{i.reset(),i.write(a_(ot),()=>{const St=Math.max(0,Be+Math.max(F,0));St>0&&i.scrollToLine(St),Ct()})}),Se()},readPlainText:()=>ca(i),setFontSize:M=>{i.options.fontSize!==M&&(i.options.fontSize=M,C(),Se())},applyTheme:q,persistNow:ge,scheduleCursorPersist:vt,schedulePersist:Se,suspendInputForwarding:()=>{n.suspend()},resumeInputForwarding:(M=0)=>{n.resume(M)},dispose:()=>{var M;u=!0,f!==null&&(window.clearTimeout(f),f=null),g!==null&&(window.cancelAnimationFrame(g),g=null),E.forEach(F=>{window.cancelAnimationFrame(F)}),E.clear(),n.dispose(),o!==null&&window.clearTimeout(o),a!==null&&window.clearTimeout(a),S.removeEventListener("mousedown",Z),S.removeEventListener("pointerdown",Z),S.removeEventListener("touchstart",N),S.removeEventListener("touchmove",ne),S.removeEventListener("touchend",ce),S.removeEventListener("touchcancel",Te),B(),V==null||V.dispose(),Q==null||Q.disconnect(),typeof window<"u"&&(window.removeEventListener("pagehide",Ce),window.removeEventListener("resize",ee),window.removeEventListener("pageshow",ye),(M=window.visualViewport)==null||M.removeEventListener("resize",ee)),typeof document<"u"&&document.removeEventListener("visibilitychange",Ne),i.dispose(),e.container.replaceChildren()}}}function ia(e){return e<0?Math.ceil(e):Math.floor(e)}function Hf(e,t,i,s){const r=t.serialize({scrollback:mf});return!r||r.length>pf?null:{content:r,cursor:i,cols:e.cols,rows:e.rows,viewportY:e.buffer.active.viewportY,historyBeforeSeq:s.beforeSeq,historyHasOlder:s.hasOlder}}function sa(e,t,i){const s=Os(t);if(s.length===0){i==null||i();return}e.write(s.map(r=>r.content).join(""),()=>{i==null||i()})}function ra(e,t,i){e.reset();const s=Os(t);if(s.length===0){i==null||i();return}e.write(s.map(r=>r.content).join(""),()=>{i==null||i()})}function Os(e){if(e.length<2)return e;const t=e.map((i,s)=>({chunk:i,index:s,cursor:Number(i.cursor)}));return t.some(i=>!Number.isFinite(i.cursor))?e:[...t].sort((i,s)=>i.cursor===s.cursor?i.index-s.index:i.cursor-s.cursor).map(i=>i.chunk)}function zf(e,t){const i=Os(e);if(!t)return i;const s=Number(t);return Number.isFinite(s)?i.filter(r=>{const n=Number(r.cursor);return!Number.isFinite(n)||n>s}):i}function Wf(e,t=1){return e.buffer.active.baseY-e.buffer.active.viewportY<=t}function $f(e){return Pf}function jf(e,t){return Wf(t,1)}function na(e,t){t.scrollToBottom()}function oa(e){return e.clientWidth>=gf&&e.clientHeight>=vf}function Uf(e,t,i){const s=i.proposeDimensions(),r=qf(t),n=Kf(e);if(!n||!r)return s??null;const o=n.width,a=n.height;if(!Number.isFinite(o)||!Number.isFinite(a)||o<=0||a<=0||r.width<=0||r.height<=0)return s??null;const h=Math.floor(o/r.width),l=Math.floor(a/r.height);return!Number.isFinite(h)||!Number.isFinite(l)?s??null:{cols:Math.max(ml,h),rows:Math.max(pl,l)}}function Kf(e){var l;const t=e.querySelector(".xterm");if(!(t instanceof HTMLElement))return null;const i=(l=t.ownerDocument.defaultView)==null?void 0:l.getComputedStyle(t),s=_s(i==null?void 0:i.paddingLeft),r=_s(i==null?void 0:i.paddingRight),n=_s(i==null?void 0:i.paddingTop),o=_s(i==null?void 0:i.paddingBottom),a=t.clientWidth-s-r,h=t.clientHeight-n-o;return!Number.isFinite(a)||!Number.isFinite(h)||a<=0||h<=0?null:{width:a,height:h}}function _s(e){if(!e)return 0;const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function qf(e){var r,n,o,a,h;const t=(o=(n=(r=vl(e))==null?void 0:r._renderService)==null?void 0:n.dimensions)==null?void 0:o.css,i=((a=t==null?void 0:t.cell)==null?void 0:a.width)??0,s=((h=t==null?void 0:t.cell)==null?void 0:h.height)??0;return!Number.isFinite(i)||!Number.isFinite(s)||i<=0||s<=0?null:{width:i,height:s}}function vl(e){return e._core??null}function aa(e,t){const i=t.background??"",s=t.foreground??"",r=t.cursor??s,n=t.cursorAccent??i,o=t.selectionBackground??"";e.style.background=i,e.style.setProperty("--terminal-theme-background",i),e.style.setProperty("--terminal-theme-foreground",s),e.style.setProperty("--terminal-theme-cursor",r),e.style.setProperty("--terminal-theme-cursor-accent",n),e.style.setProperty("--terminal-theme-selection",o)}function la(){if(typeof window>"u")return{background:"#ffffff",foreground:"#1a1a1a",cursor:"#1a1a1a",cursorAccent:"#ffffff",selectionBackground:"rgba(0, 122, 255, 0.18)"};const e=window.getComputedStyle(document.documentElement),t=Ni(e,"--terminal-theme-background","#ffffff"),i=Ni(e,"--terminal-theme-foreground","#1a1a1a"),s=Ni(e,"--terminal-theme-cursor",i),r=Ni(e,"--terminal-theme-cursor-accent",t),n=Ni(e,"--terminal-theme-selection","rgba(0, 122, 255, 0.18)");return{background:t,foreground:i,cursor:s,cursorAccent:r,selectionBackground:n}}function Ni(e,t,i){return e.getPropertyValue(t).trim()||i}function Vf(e,t){return[...e].sort((i,s)=>{const r=t.has(i.id),n=t.has(s.id);return r!==n?r?-1:1:i.createdAt!==s.createdAt?i.createdAt.localeCompare(s.createdAt):i.name!==s.name?i.name.localeCompare(s.name,"zh-CN-u-kn-true"):i.id.localeCompare(s.id)})}function Yf(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;const i=t;return typeof i.id=="string"&&typeof i.label=="string"&&typeof i.shell=="string"&&typeof i.available=="boolean"}):[]}function ms(e,t){var s;const i=t.trim();if(i){const r=e.find(n=>n.available&&n.shell===i);if(r)return r.shell}return((s=e.find(r=>r.available))==null?void 0:s.shell)??null}function ps(e,t){return e||(t==="windows"?"embedded-pty":"tmux")}function Xf(e,t,i){return t||i!=="windows"?!1:e.filter(s=>s.available).length>1}function Gf(e){if(e.nativeEvent.isComposing||Sl(e.target)||e.metaKey||e.altKey)return!0;const t=e.currentTarget;return t instanceof HTMLElement&&t.dataset.empty==="true"}function Sl(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:e.isContentEditable}function Zf(e){const t=e.key;if(!t||t==="Process"||t==="Dead"||t==="Unidentified")return null;if(e.ctrlKey)return Jf(t);if(t.length===1)return t;switch(t){case"Enter":return"\r";case"Backspace":return"";case"Tab":return" ";case"Escape":return"\x1B";case"ArrowUp":return"\x1B[A";case"ArrowDown":return"\x1B[B";case"ArrowRight":return"\x1B[C";case"ArrowLeft":return"\x1B[D";case"Home":return"\x1B[H";case"End":return"\x1B[F";case"Delete":return"\x1B[3~";case"Insert":return"\x1B[2~";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";default:return null}}function Jf(e){if(e.length===1){const t=e.toUpperCase();if(t>="A"&&t<="Z")return String.fromCharCode(t.charCodeAt(0)-64);switch(t){case"@":case" ":return"\0";case"[":return"\x1B";case"\\":return"";case"]":return"";case"^":return"";case"_":return"";default:return null}}switch(e){case"Enter":return`
|
|
51
51
|
`;case"Backspace":return"\b";case"Tab":return" ";default:return null}}function Qf(e,t){return e.length>0?e.map(i=>({id:i.id,label:e_(i),value:i.shell,description:i.shell,available:i.available,unavailableReason:i.unavailableReason})):t==="windows"?[{id:"cmd",label:"CMD",value:"cmd",description:"经典命令行",available:!0,unavailableReason:null},{id:"powershell",label:"PowerShell",value:"powershell",description:"适合脚本与系统管理",available:!0,unavailableReason:null},{id:"git-bash",label:"Git Bash",value:"git-bash",description:"更接近 Unix 命令体验",available:!0,unavailableReason:null}]:[{id:t==="linux"?"bash":"zsh",label:t==="linux"?"bash":"zsh",value:t==="linux"?"bash":"zsh",description:t==="linux"?"常见 Linux Shell":"macOS 常见默认 Shell",available:!0,unavailableReason:null}]}function e_(e){if(e.id==="cmd")return"CMD";if(e.id==="powershell")return"PowerShell";if(e.id==="git-bash")return"Git Bash";if(e.id==="default"){const t=e.shell.split(/[\\/]/);return(t[t.length-1]??e.shell).replace(/\.exe$/i,"")||e.label}return e.label}function t_(e){return e==="running"?"session-state-indicator is-running":e==="creating"?"session-state-indicator is-running-inferred":e==="error"?"session-state-indicator is-subagent-running":"session-state-indicator is-idle"}function pn(e){return Math.min(bf,Math.max(Sf,e))}function Ds(e,t,i){return Math.min(i,Math.max(t,e))}function ha(e){return Math.round(_f*pn(e)*10)/10}function i_(e){return`${Math.round(pn(e)*100)}%`}function s_(e){var i;const t=Yi(e.terminalId,e.paneBindings,e.splitDirection,"primary");if(t){const s=((i=e.paneApiById[t])==null?void 0:i.readPlainText())??"";if(s.trim())return s}return r_(e.terminalId)}function r_(e){const t=en(e).viewState;return t?n_(t.content):""}function n_(e){return e.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g,"").replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/g,"").replace(/\u001bP[\s\S]*?\u001b\\/g,"").replace(/\r/g,"")}function ca(e){const t=[];for(let i=0;i<e.buffer.active.length;i+=1){const s=e.buffer.active.getLine(i);s&&t.push(s.translateToString(!0))}return t.join(`
|
|
52
52
|
`).trimEnd()}function o_(e,t){const i=Ls(e),s=Ls(t);return i?s?`${i}
|
|
53
53
|
${s}`:i:s}function Ls(e){return e.replace(/\r/g,"").replace(/\n+$/g,"").trimEnd()}function a_(e){return e.replace(/\r?\n/g,`\r
|
|
54
54
|
`)}function bl(e){const t=Ls(e);return t?t.split(`
|
|
55
|
-
`).length:0}function gs(e){const t=new Set(e.terminals.map(r=>r.id));let i=e.currentBindings.primary&&t.has(e.currentBindings.primary)?e.currentBindings.primary:null,s=e.splitDirection!=="single"&&e.currentBindings.secondary&&t.has(e.currentBindings.secondary)?e.currentBindings.secondary:null;return e.fallbackTerminalId&&t.has(e.fallbackTerminalId)&&(e.preferredPaneId==="secondary"&&e.splitDirection!=="single"?(s=e.fallbackTerminalId,i=i??tn(e.terminals,s)??s):i=e.fallbackTerminalId),i=i??wl(e.terminals),e.splitDirection==="single"?{primary:i,secondary:null}:(s=s??tn(e.terminals,i),{primary:i,secondary:s})}function gn(e){if(e.terminal.status!=="running")return e.terminal.status;const t=l_(e.terminal.id,e.paneBindings,e.paneConnectionStates);return t.includes("connected")?"running":t.includes("reconnecting")?"creating":t.length>0||e.manuallyDisconnectedTerminalIdSet.has(e.terminal.id)?"disconnected":"running"}function l_(e,t,i){const s=[];return t.primary===e&&s.push(i.primary),t.secondary===e&&s.push(i.secondary),s}function wl(e){var t,i;return((t=e.find(s=>s.status==="running"))==null?void 0:t.id)??((i=e[0])==null?void 0:i.id)??null}function tn(e,t){var i;return((i=e.find(s=>s.id!==t))==null?void 0:i.id)??null}function h_(e,t,i){return t.primary===e?!0:i!=="single"&&t.secondary===e}function Yi(e,t,i,s){return t[s]===e?s:t.primary===e?"primary":i!=="single"&&t.secondary===e?"secondary":null}function mr(e){return`terminal-mutation-${e}`}function ua(e){return`terminal-manager.snapshot.${e}`}function c_(){return new Promise(e=>{window.setTimeout(e,wf)})}function u_(e,t){if(typeof document>"u")throw new Error(w("terminal.saveLogFailed"));const i=new Blob([t],{type:"text/plain;charset=utf-8"}),s=window.URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=e,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(s)}function d_(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-")||"terminal"}function f_(e,t){const i=e.findIndex(r=>r.id===t.id);if(i===-1)return[...e,t];const s=[...e];return s[i]=t,s}export{
|
|
55
|
+
`).length:0}function gs(e){const t=new Set(e.terminals.map(r=>r.id));let i=e.currentBindings.primary&&t.has(e.currentBindings.primary)?e.currentBindings.primary:null,s=e.splitDirection!=="single"&&e.currentBindings.secondary&&t.has(e.currentBindings.secondary)?e.currentBindings.secondary:null;return e.fallbackTerminalId&&t.has(e.fallbackTerminalId)&&(e.preferredPaneId==="secondary"&&e.splitDirection!=="single"?(s=e.fallbackTerminalId,i=i??tn(e.terminals,s)??s):i=e.fallbackTerminalId),i=i??wl(e.terminals),e.splitDirection==="single"?{primary:i,secondary:null}:(s=s??tn(e.terminals,i),{primary:i,secondary:s})}function gn(e){if(e.terminal.status!=="running")return e.terminal.status;const t=l_(e.terminal.id,e.paneBindings,e.paneConnectionStates);return t.includes("connected")?"running":t.includes("reconnecting")?"creating":t.length>0||e.manuallyDisconnectedTerminalIdSet.has(e.terminal.id)?"disconnected":"running"}function l_(e,t,i){const s=[];return t.primary===e&&s.push(i.primary),t.secondary===e&&s.push(i.secondary),s}function wl(e){var t,i;return((t=e.find(s=>s.status==="running"))==null?void 0:t.id)??((i=e[0])==null?void 0:i.id)??null}function tn(e,t){var i;return((i=e.find(s=>s.id!==t))==null?void 0:i.id)??null}function h_(e,t,i){return t.primary===e?!0:i!=="single"&&t.secondary===e}function Yi(e,t,i,s){return t[s]===e?s:t.primary===e?"primary":i!=="single"&&t.secondary===e?"secondary":null}function mr(e){return`terminal-mutation-${e}`}function ua(e){return`terminal-manager.snapshot.${e}`}function c_(){return new Promise(e=>{window.setTimeout(e,wf)})}function u_(e,t){if(typeof document>"u")throw new Error(w("terminal.saveLogFailed"));const i=new Blob([t],{type:"text/plain;charset=utf-8"}),s=window.URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=e,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(s)}function d_(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-")||"terminal"}function f_(e,t){const i=e.findIndex(r=>r.id===t.id);if(i===-1)return[...e,t];const s=[...e];return s[i]=t,s}export{A_ as TerminalPage,Zf as translateKeyboardEventToTerminalInput};
|