import { isLinux } from '../../../../base/common/platform.js';
import { localizeWithPath } from '../../../../nls.js';
import { AccessibilityCommandId } from '../../accessibility/common/accessibilityCommands.js';
import { defaultTerminalAccessibilityCommandsToSkipShell } from '../../terminalContrib/accessibility/common/terminal.accessibility.js';
import { defaultTerminalFindCommandToSkipShell } from '../../terminalContrib/find/common/terminal.find.js';
import { defaultTerminalSuggestCommandsToSkipShell } from '../../terminalContrib/suggest/common/terminal.suggest.js';
const _moduleId = "vs/workbench/contrib/terminal/common/terminal";
const TERMINAL_VIEW_ID = 'terminal';
const TERMINAL_CREATION_COMMANDS = ['workbench.action.terminal.toggleTerminal', 'workbench.action.terminal.new', 'workbench.action.togglePanel', 'workbench.action.terminal.focus'];
const TERMINAL_CONFIG_SECTION = 'terminal.integrated';
const DEFAULT_LETTER_SPACING = 0;
const MINIMUM_LETTER_SPACING = -5;
const DEFAULT_LINE_HEIGHT = isLinux ? 1.1 : 1;
const MINIMUM_FONT_WEIGHT = 1;
const MAXIMUM_FONT_WEIGHT = 1000;
const DEFAULT_FONT_WEIGHT = 'normal';
const DEFAULT_BOLD_FONT_WEIGHT = 'bold';
const SUGGESTIONS_FONT_WEIGHT = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
const isTerminalProcessManager = (t) => typeof t.write === 'function';
var ProcessState;
( ((function(ProcessState) {
    ProcessState[ProcessState["Uninitialized"] = 1] = "Uninitialized";
    ProcessState[ProcessState["Launching"] = 2] = "Launching";
    ProcessState[ProcessState["Running"] = 3] = "Running";
    ProcessState[ProcessState["KilledDuringLaunch"] = 4] = "KilledDuringLaunch";
    ProcessState[ProcessState["KilledByUser"] = 5] = "KilledByUser";
    ProcessState[ProcessState["KilledByProcess"] = 6] = "KilledByProcess";
})(ProcessState || (ProcessState = {}))));
var TerminalCommandId;
( ((function(TerminalCommandId) {
    TerminalCommandId["Toggle"] = "workbench.action.terminal.toggleTerminal";
    TerminalCommandId["Kill"] = "workbench.action.terminal.kill";
    TerminalCommandId["KillViewOrEditor"] = "workbench.action.terminal.killViewOrEditor";
    TerminalCommandId["KillEditor"] = "workbench.action.terminal.killEditor";
    TerminalCommandId["KillActiveTab"] = "workbench.action.terminal.killActiveTab";
    TerminalCommandId["KillAll"] = "workbench.action.terminal.killAll";
    TerminalCommandId["QuickKill"] = "workbench.action.terminal.quickKill";
    TerminalCommandId["ConfigureTerminalSettings"] = "workbench.action.terminal.openSettings";
    TerminalCommandId["ShellIntegrationLearnMore"] = "workbench.action.terminal.learnMore";
    TerminalCommandId["RunRecentCommand"] = "workbench.action.terminal.runRecentCommand";
    TerminalCommandId["CopyLastCommand"] = "workbench.action.terminal.copyLastCommand";
    TerminalCommandId["CopyLastCommandOutput"] = "workbench.action.terminal.copyLastCommandOutput";
    TerminalCommandId["CopyLastCommandAndLastCommandOutput"] = "workbench.action.terminal.copyLastCommandAndLastCommandOutput";
    TerminalCommandId["GoToRecentDirectory"] = "workbench.action.terminal.goToRecentDirectory";
    TerminalCommandId["CopyAndClearSelection"] = "workbench.action.terminal.copyAndClearSelection";
    TerminalCommandId["CopySelection"] = "workbench.action.terminal.copySelection";
    TerminalCommandId["CopySelectionAsHtml"] = "workbench.action.terminal.copySelectionAsHtml";
    TerminalCommandId["SelectAll"] = "workbench.action.terminal.selectAll";
    TerminalCommandId["DeleteWordLeft"] = "workbench.action.terminal.deleteWordLeft";
    TerminalCommandId["DeleteWordRight"] = "workbench.action.terminal.deleteWordRight";
    TerminalCommandId["DeleteToLineStart"] = "workbench.action.terminal.deleteToLineStart";
    TerminalCommandId["MoveToLineStart"] = "workbench.action.terminal.moveToLineStart";
    TerminalCommandId["MoveToLineEnd"] = "workbench.action.terminal.moveToLineEnd";
    TerminalCommandId["New"] = "workbench.action.terminal.new";
    TerminalCommandId["NewWithCwd"] = "workbench.action.terminal.newWithCwd";
    TerminalCommandId["NewLocal"] = "workbench.action.terminal.newLocal";
    TerminalCommandId["NewInActiveWorkspace"] = "workbench.action.terminal.newInActiveWorkspace";
    TerminalCommandId["NewWithProfile"] = "workbench.action.terminal.newWithProfile";
    TerminalCommandId["Split"] = "workbench.action.terminal.split";
    TerminalCommandId["SplitActiveTab"] = "workbench.action.terminal.splitActiveTab";
    TerminalCommandId["SplitInActiveWorkspace"] = "workbench.action.terminal.splitInActiveWorkspace";
    TerminalCommandId["Unsplit"] = "workbench.action.terminal.unsplit";
    TerminalCommandId["JoinActiveTab"] = "workbench.action.terminal.joinActiveTab";
    TerminalCommandId["Join"] = "workbench.action.terminal.join";
    TerminalCommandId["Relaunch"] = "workbench.action.terminal.relaunch";
    TerminalCommandId["FocusPreviousPane"] = "workbench.action.terminal.focusPreviousPane";
    TerminalCommandId["CreateTerminalEditor"] = "workbench.action.createTerminalEditor";
    TerminalCommandId["CreateTerminalEditorSameGroup"] = "workbench.action.createTerminalEditorSameGroup";
    TerminalCommandId["CreateTerminalEditorSide"] = "workbench.action.createTerminalEditorSide";
    TerminalCommandId["FocusTabs"] = "workbench.action.terminal.focusTabs";
    TerminalCommandId["FocusNextPane"] = "workbench.action.terminal.focusNextPane";
    TerminalCommandId["ResizePaneLeft"] = "workbench.action.terminal.resizePaneLeft";
    TerminalCommandId["ResizePaneRight"] = "workbench.action.terminal.resizePaneRight";
    TerminalCommandId["ResizePaneUp"] = "workbench.action.terminal.resizePaneUp";
    TerminalCommandId["SizeToContentWidth"] = "workbench.action.terminal.sizeToContentWidth";
    TerminalCommandId["SizeToContentWidthActiveTab"] = "workbench.action.terminal.sizeToContentWidthActiveTab";
    TerminalCommandId["ResizePaneDown"] = "workbench.action.terminal.resizePaneDown";
    TerminalCommandId["Focus"] = "workbench.action.terminal.focus";
    TerminalCommandId["FocusNext"] = "workbench.action.terminal.focusNext";
    TerminalCommandId["FocusPrevious"] = "workbench.action.terminal.focusPrevious";
    TerminalCommandId["Paste"] = "workbench.action.terminal.paste";
    TerminalCommandId["PasteSelection"] = "workbench.action.terminal.pasteSelection";
    TerminalCommandId["SelectDefaultProfile"] = "workbench.action.terminal.selectDefaultShell";
    TerminalCommandId["RunSelectedText"] = "workbench.action.terminal.runSelectedText";
    TerminalCommandId["RunActiveFile"] = "workbench.action.terminal.runActiveFile";
    TerminalCommandId["SwitchTerminal"] = "workbench.action.terminal.switchTerminal";
    TerminalCommandId["ScrollDownLine"] = "workbench.action.terminal.scrollDown";
    TerminalCommandId["ScrollDownPage"] = "workbench.action.terminal.scrollDownPage";
    TerminalCommandId["ScrollToBottom"] = "workbench.action.terminal.scrollToBottom";
    TerminalCommandId["ScrollUpLine"] = "workbench.action.terminal.scrollUp";
    TerminalCommandId["ScrollUpPage"] = "workbench.action.terminal.scrollUpPage";
    TerminalCommandId["ScrollToTop"] = "workbench.action.terminal.scrollToTop";
    TerminalCommandId["Clear"] = "workbench.action.terminal.clear";
    TerminalCommandId["ClearSelection"] = "workbench.action.terminal.clearSelection";
    TerminalCommandId["ChangeIcon"] = "workbench.action.terminal.changeIcon";
    TerminalCommandId["ChangeIconActiveTab"] = "workbench.action.terminal.changeIconActiveTab";
    TerminalCommandId["ChangeColor"] = "workbench.action.terminal.changeColor";
    TerminalCommandId["ChangeColorActiveTab"] = "workbench.action.terminal.changeColorActiveTab";
    TerminalCommandId["Rename"] = "workbench.action.terminal.rename";
    TerminalCommandId["RenameActiveTab"] = "workbench.action.terminal.renameActiveTab";
    TerminalCommandId["RenameWithArgs"] = "workbench.action.terminal.renameWithArg";
    TerminalCommandId["QuickOpenTerm"] = "workbench.action.quickOpenTerm";
    TerminalCommandId["ScrollToPreviousCommand"] = "workbench.action.terminal.scrollToPreviousCommand";
    TerminalCommandId["ScrollToNextCommand"] = "workbench.action.terminal.scrollToNextCommand";
    TerminalCommandId["SelectToPreviousCommand"] = "workbench.action.terminal.selectToPreviousCommand";
    TerminalCommandId["SelectToNextCommand"] = "workbench.action.terminal.selectToNextCommand";
    TerminalCommandId["SelectToPreviousLine"] = "workbench.action.terminal.selectToPreviousLine";
    TerminalCommandId["SelectToNextLine"] = "workbench.action.terminal.selectToNextLine";
    TerminalCommandId["SendSequence"] = "workbench.action.terminal.sendSequence";
    TerminalCommandId["AttachToSession"] = "workbench.action.terminal.attachToSession";
    TerminalCommandId["DetachSession"] = "workbench.action.terminal.detachSession";
    TerminalCommandId["MoveToEditor"] = "workbench.action.terminal.moveToEditor";
    TerminalCommandId["MoveToTerminalPanel"] = "workbench.action.terminal.moveToTerminalPanel";
    TerminalCommandId["MoveIntoNewWindow"] = "workbench.action.terminal.moveIntoNewWindow";
    TerminalCommandId["SetDimensions"] = "workbench.action.terminal.setDimensions";
    TerminalCommandId["ClearPreviousSessionHistory"] = "workbench.action.terminal.clearPreviousSessionHistory";
    TerminalCommandId["FocusHover"] = "workbench.action.terminal.focusHover";
    TerminalCommandId["ShowEnvironmentContributions"] = "workbench.action.terminal.showEnvironmentContributions";
    TerminalCommandId["StartVoice"] = "workbench.action.terminal.startVoice";
    TerminalCommandId["StopVoice"] = "workbench.action.terminal.stopVoice";
})(TerminalCommandId || (TerminalCommandId = {}))));
const DEFAULT_COMMANDS_TO_SKIP_SHELL = [
    TerminalCommandId.ClearSelection,
    TerminalCommandId.Clear,
    TerminalCommandId.CopyAndClearSelection,
    TerminalCommandId.CopySelection,
    TerminalCommandId.CopySelectionAsHtml,
    TerminalCommandId.CopyLastCommand,
    TerminalCommandId.CopyLastCommandOutput,
    TerminalCommandId.CopyLastCommandAndLastCommandOutput,
    TerminalCommandId.DeleteToLineStart,
    TerminalCommandId.DeleteWordLeft,
    TerminalCommandId.DeleteWordRight,
    TerminalCommandId.GoToRecentDirectory,
    TerminalCommandId.FocusNextPane,
    TerminalCommandId.FocusNext,
    TerminalCommandId.FocusPreviousPane,
    TerminalCommandId.FocusPrevious,
    TerminalCommandId.Focus,
    TerminalCommandId.SizeToContentWidth,
    TerminalCommandId.Kill,
    TerminalCommandId.KillEditor,
    TerminalCommandId.MoveToEditor,
    TerminalCommandId.MoveToLineEnd,
    TerminalCommandId.MoveToLineStart,
    TerminalCommandId.MoveToTerminalPanel,
    TerminalCommandId.NewInActiveWorkspace,
    TerminalCommandId.New,
    TerminalCommandId.Paste,
    TerminalCommandId.PasteSelection,
    TerminalCommandId.ResizePaneDown,
    TerminalCommandId.ResizePaneLeft,
    TerminalCommandId.ResizePaneRight,
    TerminalCommandId.ResizePaneUp,
    TerminalCommandId.RunActiveFile,
    TerminalCommandId.RunSelectedText,
    TerminalCommandId.RunRecentCommand,
    TerminalCommandId.ScrollDownLine,
    TerminalCommandId.ScrollDownPage,
    TerminalCommandId.ScrollToBottom,
    TerminalCommandId.ScrollToNextCommand,
    TerminalCommandId.ScrollToPreviousCommand,
    TerminalCommandId.ScrollToTop,
    TerminalCommandId.ScrollUpLine,
    TerminalCommandId.ScrollUpPage,
    TerminalCommandId.SendSequence,
    TerminalCommandId.SelectAll,
    TerminalCommandId.SelectToNextCommand,
    TerminalCommandId.SelectToNextLine,
    TerminalCommandId.SelectToPreviousCommand,
    TerminalCommandId.SelectToPreviousLine,
    TerminalCommandId.SplitInActiveWorkspace,
    TerminalCommandId.Split,
    TerminalCommandId.Toggle,
    TerminalCommandId.FocusHover,
    AccessibilityCommandId.OpenAccessibilityHelp,
    'editor.action.toggleTabFocusMode',
    'notifications.hideList',
    'notifications.hideToasts',
    'workbench.action.closeQuickOpen',
    'workbench.action.quickOpen',
    'workbench.action.quickOpenPreviousEditor',
    'workbench.action.showCommands',
    'workbench.action.tasks.build',
    'workbench.action.tasks.restartTask',
    'workbench.action.tasks.runTask',
    'workbench.action.tasks.reRunTask',
    'workbench.action.tasks.showLog',
    'workbench.action.tasks.showTasks',
    'workbench.action.tasks.terminate',
    'workbench.action.tasks.test',
    'workbench.action.toggleFullScreen',
    'workbench.action.terminal.focusAtIndex1',
    'workbench.action.terminal.focusAtIndex2',
    'workbench.action.terminal.focusAtIndex3',
    'workbench.action.terminal.focusAtIndex4',
    'workbench.action.terminal.focusAtIndex5',
    'workbench.action.terminal.focusAtIndex6',
    'workbench.action.terminal.focusAtIndex7',
    'workbench.action.terminal.focusAtIndex8',
    'workbench.action.terminal.focusAtIndex9',
    'workbench.action.focusSecondEditorGroup',
    'workbench.action.focusThirdEditorGroup',
    'workbench.action.focusFourthEditorGroup',
    'workbench.action.focusFifthEditorGroup',
    'workbench.action.focusSixthEditorGroup',
    'workbench.action.focusSeventhEditorGroup',
    'workbench.action.focusEighthEditorGroup',
    'workbench.action.focusNextPart',
    'workbench.action.focusPreviousPart',
    'workbench.action.nextPanelView',
    'workbench.action.previousPanelView',
    'workbench.action.nextSideBarView',
    'workbench.action.previousSideBarView',
    'workbench.action.debug.start',
    'workbench.action.debug.stop',
    'workbench.action.debug.run',
    'workbench.action.debug.restart',
    'workbench.action.debug.continue',
    'workbench.action.debug.pause',
    'workbench.action.debug.stepInto',
    'workbench.action.debug.stepOut',
    'workbench.action.debug.stepOver',
    'workbench.action.nextEditor',
    'workbench.action.previousEditor',
    'workbench.action.nextEditorInGroup',
    'workbench.action.previousEditorInGroup',
    'workbench.action.openNextRecentlyUsedEditor',
    'workbench.action.openPreviousRecentlyUsedEditor',
    'workbench.action.openNextRecentlyUsedEditorInGroup',
    'workbench.action.openPreviousRecentlyUsedEditorInGroup',
    'workbench.action.quickOpenPreviousRecentlyUsedEditor',
    'workbench.action.quickOpenLeastRecentlyUsedEditor',
    'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup',
    'workbench.action.quickOpenLeastRecentlyUsedEditorInGroup',
    'workbench.action.focusActiveEditorGroup',
    'workbench.action.focusFirstEditorGroup',
    'workbench.action.focusLastEditorGroup',
    'workbench.action.firstEditorInGroup',
    'workbench.action.lastEditorInGroup',
    'workbench.action.navigateUp',
    'workbench.action.navigateDown',
    'workbench.action.navigateRight',
    'workbench.action.navigateLeft',
    'workbench.action.togglePanel',
    'workbench.action.quickOpenView',
    'workbench.action.toggleMaximizedPanel',
    'notification.acceptPrimaryAction',
    'runCommands',
    'workbench.action.terminal.chat.start',
    'workbench.action.terminal.chat.close',
    'workbench.action.terminal.chat.discard',
    'workbench.action.terminal.chat.makeRequest',
    'workbench.action.terminal.chat.cancel',
    'workbench.action.terminal.chat.feedbackHelpful',
    'workbench.action.terminal.chat.feedbackUnhelpful',
    'workbench.action.terminal.chat.feedbackReportIssue',
    'workbench.action.terminal.chat.runCommand',
    'workbench.action.terminal.chat.insertCommand',
    'workbench.action.terminal.chat.viewInChat',
    ...defaultTerminalAccessibilityCommandsToSkipShell,
    ...defaultTerminalFindCommandToSkipShell,
    ...defaultTerminalSuggestCommandsToSkipShell,
];
const terminalContributionsDescriptor = {
    extensionPoint: 'terminal',
    defaultExtensionKind: ['workspace'],
    activationEventsGenerator: (contribs, result) => {
        for (const contrib of contribs) {
            for (const profileContrib of (contrib.profiles ?? [])) {
                result.push(`onTerminalProfile:${profileContrib.id}`);
            }
        }
    },
    jsonSchema: {
        description: ( localizeWithPath(_moduleId, 0, 'Contributes terminal functionality.')),
        type: 'object',
        properties: {
            profiles: {
                type: 'array',
                description: ( localizeWithPath(
                    _moduleId,
                    1,
                    "Defines additional terminal profiles that the user can create."
                )),
                items: {
                    type: 'object',
                    required: ['id', 'title'],
                    defaultSnippets: [{
                            body: {
                                id: '$1',
                                title: '$2'
                            }
                        }],
                    properties: {
                        id: {
                            description: ( localizeWithPath(_moduleId, 2, "The ID of the terminal profile provider.")),
                            type: 'string',
                        },
                        title: {
                            description: ( localizeWithPath(_moduleId, 3, "Title for this terminal profile.")),
                            type: 'string',
                        },
                        icon: {
                            description: ( localizeWithPath(
                                _moduleId,
                                4,
                                "A codicon, URI, or light and dark URIs to associate with this terminal type."
                            )),
                            anyOf: [{
                                    type: 'string',
                                },
                                {
                                    type: 'object',
                                    properties: {
                                        light: {
                                            description: ( localizeWithPath(_moduleId, 5, 'Icon path when a light theme is used')),
                                            type: 'string'
                                        },
                                        dark: {
                                            description: ( localizeWithPath(_moduleId, 6, 'Icon path when a dark theme is used')),
                                            type: 'string'
                                        }
                                    }
                                }]
                        },
                    },
                },
            },
        },
    },
};
export { DEFAULT_BOLD_FONT_WEIGHT, DEFAULT_COMMANDS_TO_SKIP_SHELL, DEFAULT_FONT_WEIGHT, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MAXIMUM_FONT_WEIGHT, MINIMUM_FONT_WEIGHT, MINIMUM_LETTER_SPACING, ProcessState, SUGGESTIONS_FONT_WEIGHT, TERMINAL_CONFIG_SECTION, TERMINAL_CREATION_COMMANDS, TERMINAL_VIEW_ID, TerminalCommandId, isTerminalProcessManager, terminalContributionsDescriptor };
