import { refineServiceDecorator } from '../../../../platform/instantiation/common/instantiation.js';
import { ILayoutService } from '../../../../platform/layout/browser/layoutService.js';
import { isMacintosh, isNative, isWeb } from '../../../../base/common/platform.js';
import { isAuxiliaryWindow } from '../../../../base/browser/window.js';
import { hasNativeTitlebar, getMenuBarVisibility } from '../../../../platform/window/common/window.js';
import { isFullscreen, isWCOEnabled } from '../../../../base/browser/browser.js';
const IWorkbenchLayoutService = refineServiceDecorator(ILayoutService);
var Parts;
( (function(Parts) {
    Parts["TITLEBAR_PART"] = "workbench.parts.titlebar";
    Parts["BANNER_PART"] = "workbench.parts.banner";
    Parts["ACTIVITYBAR_PART"] = "workbench.parts.activitybar";
    Parts["SIDEBAR_PART"] = "workbench.parts.sidebar";
    Parts["PANEL_PART"] = "workbench.parts.panel";
    Parts["AUXILIARYBAR_PART"] = "workbench.parts.auxiliarybar";
    Parts["EDITOR_PART"] = "workbench.parts.editor";
    Parts["STATUSBAR_PART"] = "workbench.parts.statusbar";
})(Parts || (Parts = {})));
var Position;
( (function(Position) {
    Position[Position["LEFT"] = 0] = "LEFT";
    Position[Position["RIGHT"] = 1] = "RIGHT";
    Position[Position["BOTTOM"] = 2] = "BOTTOM";
})(Position || (Position = {})));
function positionToString(position) {
    switch (position) {
        case 0 : return 'left';
        case 1 : return 'right';
        case 2 : return 'bottom';
        default: return 'bottom';
    }
}
const positionsByString = {
    [positionToString(0 )]: 0 ,
    [positionToString(1 )]: 1 ,
    [positionToString(2 )]: 2
};
function positionFromString(str) {
    return positionsByString[str];
}
function panelOpensMaximizedSettingToString(setting) {
    switch (setting) {
        case 0 : return 'always';
        case 1 : return 'never';
        case 2 : return 'preserve';
        default: return 'preserve';
    }
}
const panelOpensMaximizedByString = {
    [panelOpensMaximizedSettingToString(0 )]: 0 ,
    [panelOpensMaximizedSettingToString(1 )]: 1 ,
    [panelOpensMaximizedSettingToString(2 )]: 2
};
function panelOpensMaximizedFromString(str) {
    return panelOpensMaximizedByString[str];
}
function shouldShowCustomTitleBar(configurationService, window, menuBarToggled) {
    const inFullscreen = isFullscreen(window);
    const nativeTitleBarEnabled = hasNativeTitlebar(configurationService);
    const showCustomTitleBar = configurationService.getValue("window.customTitleBarVisibility" );
    if (showCustomTitleBar === "never"  && nativeTitleBarEnabled || showCustomTitleBar === "windowed"  && inFullscreen) {
        return false;
    }
    if (!isTitleBarEmpty(configurationService)) {
        return true;
    }
    if (nativeTitleBarEnabled) {
        return false;
    }
    if (isMacintosh && isNative) {
        return !inFullscreen;
    }
    if (isNative && !inFullscreen) {
        return true;
    }
    if (isWCOEnabled() && !inFullscreen) {
        return true;
    }
    const menuBarVisibility = !isAuxiliaryWindow(window) ? getMenuBarVisibility(configurationService) : 'hidden';
    switch (menuBarVisibility) {
        case 'classic':
            return !inFullscreen || !!menuBarToggled;
        case 'compact':
        case 'hidden':
            return false;
        case 'toggle':
            return !!menuBarToggled;
        case 'visible':
            return true;
        default:
            return isWeb ? false : !inFullscreen || !!menuBarToggled;
    }
}
function isTitleBarEmpty(configurationService) {
    if (configurationService.getValue("window.commandCenter" )) {
        return false;
    }
    const activityBarPosition = configurationService.getValue("workbench.activityBar.location" );
    if (activityBarPosition === "top"  || activityBarPosition === "bottom" ) {
        return false;
    }
    const editorActionsLocation = configurationService.getValue("workbench.editor.editorActionsLocation" );
    const editorTabsMode = configurationService.getValue("workbench.editor.showTabs" );
    if (editorActionsLocation === "titleBar"  || editorActionsLocation === "default"  && editorTabsMode === "none" ) {
        return false;
    }
    if (configurationService.getValue("workbench.layoutControl.enabled" )) {
        return false;
    }
    return true;
}
export { IWorkbenchLayoutService, Parts, Position, panelOpensMaximizedFromString, positionFromString, positionToString, shouldShowCustomTitleBar };
