import { createDecorator } from '../../instantiation/common/instantiation.js';
import '../../contextkey/common/contextkey.js';
import { Registry } from '../../registry/common/platform.js';
var TitleEventSource;
( (function(TitleEventSource) {
    TitleEventSource[TitleEventSource["Api"] = 0] = "Api";
    TitleEventSource[TitleEventSource["Process"] = 1] = "Process";
    TitleEventSource[TitleEventSource["Sequence"] = 2] = "Sequence";
    TitleEventSource[TitleEventSource["Config"] = 3] = "Config";
})(TitleEventSource || (TitleEventSource = {})));
var TerminalLocation;
( (function(TerminalLocation) {
    TerminalLocation[TerminalLocation["Panel"] = 1] = "Panel";
    TerminalLocation[TerminalLocation["Editor"] = 2] = "Editor";
})(TerminalLocation || (TerminalLocation = {})));
var TerminalExitReason;
( (function(TerminalExitReason) {
    TerminalExitReason[TerminalExitReason["Unknown"] = 0] = "Unknown";
    TerminalExitReason[TerminalExitReason["Shutdown"] = 1] = "Shutdown";
    TerminalExitReason[TerminalExitReason["Process"] = 2] = "Process";
    TerminalExitReason[TerminalExitReason["User"] = 3] = "User";
    TerminalExitReason[TerminalExitReason["Extension"] = 4] = "Extension";
})(TerminalExitReason || (TerminalExitReason = {})));
const TerminalExtensions = {
    Backend: 'workbench.contributions.terminal.processBackend'
};
class TerminalBackendRegistry {
    constructor() {
        this._backends = ( new Map());
    }
    get backends() { return this._backends; }
    registerTerminalBackend(backend) {
        const key = this._sanitizeRemoteAuthority(backend.remoteAuthority);
        if (( this._backends.has(key))) {
            throw new Error(`A terminal backend with remote authority '${key}' was already registered.`);
        }
        this._backends.set(key, backend);
    }
    getTerminalBackend(remoteAuthority) {
        return this._backends.get(this._sanitizeRemoteAuthority(remoteAuthority));
    }
    _sanitizeRemoteAuthority(remoteAuthority) {
        return remoteAuthority?.toLowerCase() ?? '';
    }
}
Registry.add(TerminalExtensions.Backend, ( new TerminalBackendRegistry()));
const ITerminalLogService = ( createDecorator('terminalLogService'));
export { ITerminalLogService, TerminalExitReason, TerminalExtensions, TerminalLocation, TitleEventSource };
