import { Event } from '../../../../base/common/event.js';
import { IDisposable } from '../../../../base/common/lifecycle.js';
import { OperatingSystem } from '../../../../base/common/platform.js';
import Severity from '../../../../base/common/severity.js';
import { ThemeIcon } from '../../../../base/common/themables.js';
import { URI } from '../../../../base/common/uri.js';
import { ITerminalCapabilityStore } from '../../../../platform/terminal/common/capabilities/capabilities.js';
import { IMergedEnvironmentVariableCollection } from '../../../../platform/terminal/common/environmentVariable.js';
import { TitleEventSource, IFixedTerminalDimensions, IProcessProperty, IProcessReadyWindowsPty, ITerminalLaunchError, ITerminalBackend, TerminalLocationString, ITerminalProfileObject } from '../../../../platform/terminal/common/terminal.js';
import { IEnvironmentVariableInfo } from './environmentVariable.js';

type FontWeight = 'normal' | 'bold' | number;
interface ITerminalProfiles {
    linux: {
        [key: string]: ITerminalProfileObject;
    };
    osx: {
        [key: string]: ITerminalProfileObject;
    };
    windows: {
        [key: string]: ITerminalProfileObject;
    };
}
type ConfirmOnKill = 'never' | 'always' | 'editor' | 'panel';
type ConfirmOnExit = 'never' | 'always' | 'hasChildProcesses';
interface ITerminalConfiguration {
    shell: {
        linux: string | null;
        osx: string | null;
        windows: string | null;
    };
    automationShell: {
        linux: string | null;
        osx: string | null;
        windows: string | null;
    };
    shellArgs: {
        linux: string[];
        osx: string[];
        windows: string[];
    };
    profiles: ITerminalProfiles;
    defaultProfile: {
        linux: string | null;
        osx: string | null;
        windows: string | null;
    };
    useWslProfiles: boolean;
    altClickMovesCursor: boolean;
    macOptionIsMeta: boolean;
    macOptionClickForcesSelection: boolean;
    gpuAcceleration: 'auto' | 'on' | 'off';
    rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord' | 'nothing';
    middleClickBehavior: 'default' | 'paste';
    cursorBlinking: boolean;
    cursorStyle: 'block' | 'underline' | 'line';
    cursorStyleInactive: 'outline' | 'block' | 'underline' | 'line' | 'none';
    cursorWidth: number;
    drawBoldTextInBrightColors: boolean;
    fastScrollSensitivity: number;
    fontFamily: string;
    fontWeight: FontWeight;
    fontWeightBold: FontWeight;
    minimumContrastRatio: number;
    mouseWheelScrollSensitivity: number;
    tabStopWidth: number;
    sendKeybindingsToShell: boolean;
    fontSize: number;
    letterSpacing: number;
    lineHeight: number;
    detectLocale: 'auto' | 'off' | 'on';
    scrollback: number;
    commandsToSkipShell: string[];
    allowChords: boolean;
    allowMnemonics: boolean;
    cwd: string;
    confirmOnExit: ConfirmOnExit;
    confirmOnKill: ConfirmOnKill;
    enableBell: boolean;
    env: {
        linux: {
            [key: string]: string;
        };
        osx: {
            [key: string]: string;
        };
        windows: {
            [key: string]: string;
        };
    };
    environmentChangesIndicator: 'off' | 'on' | 'warnonly';
    environmentChangesRelaunch: boolean;
    showExitAlert: boolean;
    splitCwd: 'workspaceRoot' | 'initial' | 'inherited';
    windowsEnableConpty: boolean;
    wordSeparators: string;
    enableFileLinks: 'off' | 'on' | 'notRemote';
    allowedLinkSchemes: string[];
    unicodeVersion: '6' | '11';
    enablePersistentSessions: boolean;
    tabs: {
        enabled: boolean;
        hideCondition: 'never' | 'singleTerminal' | 'singleGroup';
        showActiveTerminal: 'always' | 'singleTerminal' | 'singleTerminalOrNarrow' | 'singleGroup' | 'never';
        location: 'left' | 'right';
        focusMode: 'singleClick' | 'doubleClick';
        title: string;
        description: string;
        separator: string;
    };
    bellDuration: number;
    defaultLocation: TerminalLocationString;
    customGlyphs: boolean;
    persistentSessionReviveProcess: 'onExit' | 'onExitAndWindowClose' | 'never';
    ignoreProcessNames: string[];
    autoReplies: {
        [key: string]: string;
    };
    shellIntegration?: {
        enabled: boolean;
        decorationsEnabled: boolean;
    };
    enableImages: boolean;
    smoothScrolling: boolean;
    ignoreBracketedPasteMode: boolean;
    rescaleOverlappingGlyphs: boolean;
}
interface ITerminalFont {
    fontFamily: string;
    fontSize: number;
    letterSpacing: number;
    lineHeight: number;
    charWidth?: number;
    charHeight?: number;
}
interface IRemoteTerminalAttachTarget {
    id: number;
    pid: number;
    title: string;
    titleSource: TitleEventSource;
    cwd: string;
    workspaceId: string;
    workspaceName: string;
    isOrphan: boolean;
    icon: URI | {
        light: URI;
        dark: URI;
    } | {
        id: string;
        color?: {
            id: string;
        };
    } | undefined;
    color: string | undefined;
    fixedDimensions: IFixedTerminalDimensions | undefined;
    shellIntegrationNonce: string;
}
/** Read-only process information that can apply to detached terminals. */
interface ITerminalProcessInfo {
    readonly processState: ProcessState;
    readonly ptyProcessReady: Promise<void>;
    readonly shellProcessId: number | undefined;
    readonly remoteAuthority: string | undefined;
    readonly os: OperatingSystem | undefined;
    readonly userHome: string | undefined;
    readonly initialCwd: string;
    readonly environmentVariableInfo: IEnvironmentVariableInfo | undefined;
    readonly persistentProcessId: number | undefined;
    readonly shouldPersist: boolean;
    readonly hasWrittenData: boolean;
    readonly hasChildProcesses: boolean;
    readonly backend: ITerminalBackend | undefined;
    readonly capabilities: ITerminalCapabilityStore;
    readonly shellIntegrationNonce: string;
    readonly extEnvironmentVariableCollection: IMergedEnvironmentVariableCollection | undefined;
}
declare const enum ProcessState {
    Uninitialized = 1,
    Launching = 2,
    Running = 3,
    KilledDuringLaunch = 4,
    KilledByUser = 5,
    KilledByProcess = 6
}
interface ITerminalProcessExtHostProxy extends IDisposable {
    readonly instanceId: number;
    emitData(data: string): void;
    emitProcessProperty(property: IProcessProperty<any>): void;
    emitReady(pid: number, cwd: string, windowsPty: IProcessReadyWindowsPty | undefined): void;
    emitExit(exitCode: number | undefined): void;
    onInput: Event<string>;
    onBinary: Event<string>;
    onResize: Event<{
        cols: number;
        rows: number;
    }>;
    onAcknowledgeDataEvent: Event<number>;
    onShutdown: Event<boolean>;
    onRequestInitialCwd: Event<void>;
    onRequestCwd: Event<void>;
}
interface IStartExtensionTerminalRequest {
    proxy: ITerminalProcessExtHostProxy;
    cols: number;
    rows: number;
    callback: (error: ITerminalLaunchError | undefined) => void;
}
interface ITerminalStatus {
    /** An internal string ID used to identify the status. */
    id: string;
    /**
     * The severity of the status, this defines both the color and how likely the status is to be
     * the "primary status".
     */
    severity: Severity;
    /**
     * An icon representing the status, if this is not specified it will not show up on the terminal
     * tab and will use the generic `info` icon when hovering.
     */
    icon?: ThemeIcon;
    /**
     * What to show for this status in the terminal's hover.
     */
    tooltip?: string | undefined;
    /**
     * Actions to expose on hover.
     */
    hoverActions?: ITerminalStatusHoverAction[];
}
interface ITerminalStatusHoverAction {
    label: string;
    commandId: string;
    run: () => void;
}

export { type ConfirmOnExit, type ConfirmOnKill, type FontWeight, type IRemoteTerminalAttachTarget, type IStartExtensionTerminalRequest, type ITerminalConfiguration, type ITerminalFont, type ITerminalProcessExtHostProxy, type ITerminalProcessInfo, type ITerminalProfiles, type ITerminalStatus, type ITerminalStatusHoverAction, ProcessState };
