
import { localize, localize2 } from '../../../nls.js';
import { registerAction2, Action2, MenuId, MenuRegistry } from '../../../platform/actions/common/actions.js';
import { Categories } from '../../../platform/action/common/actionCommonCategories.js';
import { IConfigurationService } from '../../../platform/configuration/common/configuration.service.js';
import { alert } from '../../../base/browser/ui/aria/aria.js';
import { positionToString, Position, Parts, LayoutSettings, EditorTabsMode, ZenModeSettings, EditorActionsLocation } from '../../services/layout/browser/layoutService.js';
import { IWorkbenchLayoutService } from '../../services/layout/browser/layoutService.service.js';
import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';
import { KeyMod as KeyMod$1, KeyCode, KeyChord } from '../../../base/common/keyCodes.js';
import { isWindows, isLinux, isWeb, isMacintosh, isNative } from '../../../base/common/platform.js';
import { IsMacNativeContext } from '../../../platform/contextkey/common/contextkeys.js';
import { KeybindingWeight, KeybindingsRegistry } from '../../../platform/keybinding/common/keybindingsRegistry.js';
import { ContextKeyExpr } from '../../../platform/contextkey/common/contextkey.js';
import { IContextKeyService } from '../../../platform/contextkey/common/contextkey.service.js';
import { ViewContainerLocationToString, ViewContainerLocation } from '../../common/views.js';
import { IViewDescriptorService } from '../../common/views.service.js';
import { IViewsService } from '../../services/views/common/viewsService.service.js';
import { IQuickInputService } from '../../../platform/quickinput/common/quickInput.service.js';
import { IDialogService } from '../../../platform/dialogs/common/dialogs.service.js';
import { IPaneCompositePartService } from '../../services/panecomposite/browser/panecomposite.service.js';
import { ToggleAuxiliaryBarAction } from '../parts/auxiliarybar/auxiliaryBarActions.js';
import { TogglePanelAction } from '../parts/panel/panelActions.js';
import { ICommandService } from '../../../platform/commands/common/commands.service.js';
import { IsMainEditorCenteredLayoutContext, IsAuxiliaryWindowFocusedContext, IsAuxiliaryWindowContext, PanelAlignmentContext, PanelPositionContext, MainEditorAreaVisibleContext, SideBarVisibleContext, InEditorZenModeContext, TitleBarStyleContext, IsMainWindowFullscreenContext, FocusedViewContext, AuxiliaryBarVisibleContext, PanelVisibleContext } from '../../common/contextkeys.js';
import { Codicon } from '../../../base/common/codicons.js';
import { ThemeIcon } from '../../../base/common/themables.js';
import { DisposableStore } from '../../../base/common/lifecycle.js';
import { registerIcon } from '../../../platform/theme/common/iconRegistry.js';
import { mainWindow } from '../../../base/browser/window.js';
import { IKeybindingService } from '../../../platform/keybinding/common/keybinding.service.js';
import { MenuSettings, TitlebarStyle } from '../../../platform/window/common/window.js';
import { IPreferencesService } from '../../services/preferences/common/preferences.service.js';
import { QuickInputAlignmentContextKey } from '../../../platform/quickinput/browser/quickInput.js';
import { IEditorGroupsService } from '../../services/editor/common/editorGroupsService.service.js';

const menubarIcon = registerIcon("menuBar", Codicon.layoutMenubar, ( localize(2830, "Represents the menu bar")));
const activityBarLeftIcon = registerIcon("activity-bar-left", Codicon.layoutActivitybarLeft, ( localize(2831, "Represents the activity bar in the left position")));
const activityBarRightIcon = registerIcon("activity-bar-right", Codicon.layoutActivitybarRight, ( localize(2832, "Represents the activity bar in the right position")));
const panelLeftIcon = registerIcon("panel-left", Codicon.layoutSidebarLeft, ( localize(2833, "Represents a side bar in the left position")));
const panelLeftOffIcon = registerIcon("panel-left-off", Codicon.layoutSidebarLeftOff, ( localize(2834, "Represents a side bar in the left position toggled off")));
const panelRightIcon = registerIcon("panel-right", Codicon.layoutSidebarRight, ( localize(2835, "Represents side bar in the right position")));
const panelRightOffIcon = registerIcon("panel-right-off", Codicon.layoutSidebarRightOff, ( localize(2836, "Represents side bar in the right position toggled off")));
const panelIcon = registerIcon("panel-bottom", Codicon.layoutPanel, ( localize(2837, "Represents the bottom panel")));
const statusBarIcon = registerIcon("statusBar", Codicon.layoutStatusbar, ( localize(2838, "Represents the status bar")));
const panelAlignmentLeftIcon = registerIcon("panel-align-left", Codicon.layoutPanelLeft, ( localize(2839, "Represents the bottom panel alignment set to the left")));
const panelAlignmentRightIcon = registerIcon("panel-align-right", Codicon.layoutPanelRight, ( localize(2840, "Represents the bottom panel alignment set to the right")));
const panelAlignmentCenterIcon = registerIcon("panel-align-center", Codicon.layoutPanelCenter, ( localize(2841, "Represents the bottom panel alignment set to the center")));
const panelAlignmentJustifyIcon = registerIcon("panel-align-justify", Codicon.layoutPanelJustify, ( localize(2842, "Represents the bottom panel alignment set to justified")));
const quickInputAlignmentTopIcon = registerIcon("quickInputAlignmentTop", Codicon.arrowUp, ( localize(2843, "Represents quick input alignment set to the top")));
const quickInputAlignmentCenterIcon = registerIcon("quickInputAlignmentCenter", Codicon.circle, ( localize(2844, "Represents quick input alignment set to the center")));
const fullscreenIcon = registerIcon("fullscreen", Codicon.screenFull, ( localize(2845, "Represents full screen")));
const centerLayoutIcon = registerIcon("centerLayoutIcon", Codicon.layoutCentered, ( localize(2846, "Represents centered layout mode")));
const zenModeIcon = registerIcon("zenMode", Codicon.target, ( localize(2847, "Represents zen mode")));
const ToggleActivityBarVisibilityActionId = "workbench.action.toggleActivityBarVisibility";
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.toggleCenteredLayout",
            title: {
                ...( localize2(2848, "Toggle Centered Layout")),
                mnemonicTitle: ( localize(2849, "&&Centered Layout"))
            },
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated()),
            category: Categories.View,
            f1: true,
            toggled: IsMainEditorCenteredLayoutContext,
            menu: [{
                id: MenuId.MenubarAppearanceMenu,
                group: "1_toggle_view",
                order: 3
            }]
        });
    }
    run(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const editorGroupService = accessor.get(IEditorGroupsService);
        layoutService.centerMainEditorLayout(!layoutService.isMainEditorLayoutCentered());
        editorGroupService.activeGroup.focus();
    }
});
const sidebarPositionConfigurationKey = "workbench.sideBar.location";
class MoveSidebarPositionAction extends Action2 {
    constructor(id, title, position) {
        super({
            id,
            title,
            f1: false
        });
        this.position = position;
    }
    async run(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const configurationService = accessor.get(IConfigurationService);
        const position = layoutService.getSideBarPosition();
        if (position !== this.position) {
            return configurationService.updateValue(sidebarPositionConfigurationKey, positionToString(this.position));
        }
    }
}
class MoveSidebarRightAction extends MoveSidebarPositionAction {
    static {
        this.ID = "workbench.action.moveSideBarRight";
    }
    constructor() {
        super(MoveSidebarRightAction.ID, ( localize2(2850, "Move Primary Side Bar Right")), Position.RIGHT);
    }
}
class MoveSidebarLeftAction extends MoveSidebarPositionAction {
    static {
        this.ID = "workbench.action.moveSideBarLeft";
    }
    constructor() {
        super(MoveSidebarLeftAction.ID, ( localize2(2851, "Move Primary Side Bar Left")), Position.LEFT);
    }
}
registerAction2(MoveSidebarRightAction);
registerAction2(MoveSidebarLeftAction);
class ToggleSidebarPositionAction extends Action2 {
    static {
        this.ID = "workbench.action.toggleSidebarPosition";
    }
    static {
        this.LABEL = ( localize(2852, "Toggle Primary Side Bar Position"));
    }
    static getLabel(layoutService) {
        return layoutService.getSideBarPosition() === Position.LEFT ? ( localize(2850, "Move Primary Side Bar Right")) : ( localize(2851, "Move Primary Side Bar Left"));
    }
    constructor() {
        super({
            id: ToggleSidebarPositionAction.ID,
            title: ( localize2(2852, "Toggle Primary Side Bar Position")),
            category: Categories.View,
            f1: true
        });
    }
    run(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const configurationService = accessor.get(IConfigurationService);
        const position = layoutService.getSideBarPosition();
        const newPositionValue = (position === Position.LEFT) ? "right" : "left";
        return configurationService.updateValue(sidebarPositionConfigurationKey, newPositionValue);
    }
}
registerAction2(ToggleSidebarPositionAction);
const configureLayoutIcon = registerIcon("configure-layout-icon", Codicon.layout, ( localize(2853, "Icon represents workbench layout configuration.")));
MenuRegistry.appendMenuItem(MenuId.LayoutControlMenu, {
    submenu: MenuId.LayoutControlMenuSubmenu,
    title: ( localize(2854, "Configure Layout")),
    icon: configureLayoutIcon,
    group: "1_workbench_layout",
    when: ( ContextKeyExpr.and(( IsAuxiliaryWindowContext.negate()), ( ContextKeyExpr.equals("config.workbench.layoutControl.type", "menu"))))
});
MenuRegistry.appendMenuItems([{
    id: MenuId.ViewContainerTitleContext,
    item: {
        group: "3_workbench_layout_move",
        command: {
            id: ToggleSidebarPositionAction.ID,
            title: ( localize(2855, "Move Primary Side Bar Right"))
        },
        when: ( ContextKeyExpr.and(( ContextKeyExpr.notEquals("config.workbench.sideBar.location", "right")), ( ContextKeyExpr.equals(
            "viewContainerLocation",
            ViewContainerLocationToString(ViewContainerLocation.Sidebar)
        )))),
        order: 1
    }
}, {
    id: MenuId.ViewContainerTitleContext,
    item: {
        group: "3_workbench_layout_move",
        command: {
            id: ToggleSidebarPositionAction.ID,
            title: ( localize(2856, "Move Primary Side Bar Left"))
        },
        when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("config.workbench.sideBar.location", "right")), ( ContextKeyExpr.equals(
            "viewContainerLocation",
            ViewContainerLocationToString(ViewContainerLocation.Sidebar)
        )))),
        order: 1
    }
}, {
    id: MenuId.ViewContainerTitleContext,
    item: {
        group: "3_workbench_layout_move",
        command: {
            id: ToggleSidebarPositionAction.ID,
            title: ( localize(2857, "Move Secondary Side Bar Left"))
        },
        when: ( ContextKeyExpr.and(( ContextKeyExpr.notEquals("config.workbench.sideBar.location", "right")), ( ContextKeyExpr.equals(
            "viewContainerLocation",
            ViewContainerLocationToString(ViewContainerLocation.AuxiliaryBar)
        )))),
        order: 1
    }
}, {
    id: MenuId.ViewContainerTitleContext,
    item: {
        group: "3_workbench_layout_move",
        command: {
            id: ToggleSidebarPositionAction.ID,
            title: ( localize(2858, "Move Secondary Side Bar Right"))
        },
        when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("config.workbench.sideBar.location", "right")), ( ContextKeyExpr.equals(
            "viewContainerLocation",
            ViewContainerLocationToString(ViewContainerLocation.AuxiliaryBar)
        )))),
        order: 1
    }
}]);
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
    group: "3_workbench_layout_move",
    command: {
        id: ToggleSidebarPositionAction.ID,
        title: ( localize(2859, "&&Move Primary Side Bar Right"))
    },
    when: ( ContextKeyExpr.notEquals("config.workbench.sideBar.location", "right")),
    order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
    group: "3_workbench_layout_move",
    command: {
        id: ToggleSidebarPositionAction.ID,
        title: ( localize(2860, "&&Move Primary Side Bar Left"))
    },
    when: ( ContextKeyExpr.equals("config.workbench.sideBar.location", "right")),
    order: 2
});
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.toggleEditorVisibility",
            title: {
                ...( localize2(2861, "Toggle Editor Area Visibility")),
                mnemonicTitle: ( localize(2862, "Show &&Editor Area"))
            },
            category: Categories.View,
            f1: true,
            toggled: MainEditorAreaVisibleContext,
            precondition: ( ContextKeyExpr.and(( IsAuxiliaryWindowFocusedContext.toNegated()), ( ContextKeyExpr.or(( PanelAlignmentContext.isEqualTo("center")), ( PanelPositionContext.notEqualsTo("bottom"))))))
        });
    }
    run(accessor) {
        accessor.get(IWorkbenchLayoutService).toggleMaximizedPanel();
    }
});
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
    group: "2_appearance",
    title: ( localize(2863, "&&Appearance")),
    submenu: MenuId.MenubarAppearanceMenu,
    order: 1
});
class ToggleSidebarVisibilityAction extends Action2 {
    static {
        this.ID = "workbench.action.toggleSidebarVisibility";
    }
    static {
        this.LABEL = ( localize(2864, "Hide Primary Side Bar"));
    }
    constructor() {
        super({
            id: ToggleSidebarVisibilityAction.ID,
            title: ( localize2(2865, "Toggle Primary Side Bar Visibility")),
            toggled: {
                condition: SideBarVisibleContext,
                title: ( localize(2866, "Primary Side Bar")),
                mnemonicTitle: ( localize(2867, "&&Primary Side Bar"))
            },
            metadata: {
                description: ( localize(2868, "Open/Show and Close/Hide Sidebar"))
            },
            category: Categories.View,
            f1: true,
            keybinding: {
                weight: KeybindingWeight.WorkbenchContrib,
                primary: KeyMod$1.CtrlCmd | KeyCode.KeyB
            },
            menu: [{
                id: MenuId.LayoutControlMenuSubmenu,
                group: "0_workbench_layout",
                order: 0
            }, {
                id: MenuId.MenubarAppearanceMenu,
                group: "2_workbench_layout",
                order: 1
            }]
        });
    }
    run(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const isCurrentlyVisible = layoutService.isVisible(Parts.SIDEBAR_PART);
        layoutService.setPartHidden(isCurrentlyVisible, Parts.SIDEBAR_PART);
        const alertMessage = isCurrentlyVisible ? ( localize(2869, "Primary Side Bar hidden")) : ( localize(2870, "Primary Side Bar shown"));
        alert(alertMessage);
    }
}
registerAction2(ToggleSidebarVisibilityAction);
MenuRegistry.appendMenuItems([{
    id: MenuId.ViewContainerTitleContext,
    item: {
        group: "3_workbench_layout_move",
        command: {
            id: ToggleSidebarVisibilityAction.ID,
            title: ( localize(2864, "Hide Primary Side Bar"))
        },
        when: ( ContextKeyExpr.and(SideBarVisibleContext, ( ContextKeyExpr.equals(
            "viewContainerLocation",
            ViewContainerLocationToString(ViewContainerLocation.Sidebar)
        )))),
        order: 2
    }
}, {
    id: MenuId.LayoutControlMenu,
    item: {
        group: "2_pane_toggles",
        command: {
            id: ToggleSidebarVisibilityAction.ID,
            title: ( localize(2871, "Toggle Primary Side Bar")),
            icon: panelLeftOffIcon,
            toggled: {
                condition: SideBarVisibleContext,
                icon: panelLeftIcon
            }
        },
        when: ( ContextKeyExpr.and(( IsAuxiliaryWindowContext.negate()), ( ContextKeyExpr.or(( ContextKeyExpr.equals("config.workbench.layoutControl.type", "toggles")), ( ContextKeyExpr.equals("config.workbench.layoutControl.type", "both")))), ( ContextKeyExpr.equals("config.workbench.sideBar.location", "left")))),
        order: 0
    }
}, {
    id: MenuId.LayoutControlMenu,
    item: {
        group: "2_pane_toggles",
        command: {
            id: ToggleSidebarVisibilityAction.ID,
            title: ( localize(2871, "Toggle Primary Side Bar")),
            icon: panelRightOffIcon,
            toggled: {
                condition: SideBarVisibleContext,
                icon: panelRightIcon
            }
        },
        when: ( ContextKeyExpr.and(( IsAuxiliaryWindowContext.negate()), ( ContextKeyExpr.or(( ContextKeyExpr.equals("config.workbench.layoutControl.type", "toggles")), ( ContextKeyExpr.equals("config.workbench.layoutControl.type", "both")))), ( ContextKeyExpr.equals("config.workbench.sideBar.location", "right")))),
        order: 2
    }
}]);
class ToggleStatusbarVisibilityAction extends Action2 {
    static {
        this.ID = "workbench.action.toggleStatusbarVisibility";
    }
    static {
        this.statusbarVisibleKey = "workbench.statusBar.visible";
    }
    constructor() {
        super({
            id: ToggleStatusbarVisibilityAction.ID,
            title: {
                ...( localize2(2872, "Toggle Status Bar Visibility")),
                mnemonicTitle: ( localize(2873, "S&&tatus Bar"))
            },
            category: Categories.View,
            f1: true,
            toggled: ( ContextKeyExpr.equals("config.workbench.statusBar.visible", true)),
            menu: [{
                id: MenuId.MenubarAppearanceMenu,
                group: "2_workbench_layout",
                order: 3
            }]
        });
    }
    run(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const configurationService = accessor.get(IConfigurationService);
        const visibility = layoutService.isVisible(Parts.STATUSBAR_PART, mainWindow);
        const newVisibilityValue = !visibility;
        return configurationService.updateValue(ToggleStatusbarVisibilityAction.statusbarVisibleKey, newVisibilityValue);
    }
}
registerAction2(ToggleStatusbarVisibilityAction);
class AbstractSetShowTabsAction extends Action2 {
    constructor(settingName, value, title, id, precondition, description) {
        super({
            id,
            title,
            category: Categories.View,
            precondition,
            metadata: description ? {
                description
            } : undefined,
            f1: true
        });
        this.settingName = settingName;
        this.value = value;
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        return configurationService.updateValue(this.settingName, this.value);
    }
}
class HideEditorTabsAction extends AbstractSetShowTabsAction {
    static {
        this.ID = "workbench.action.hideEditorTabs";
    }
    constructor() {
        const precondition = ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.NONE)).negate()), ( InEditorZenModeContext.negate())));
        const title = ( localize2(2874, "Hide Editor Tabs"));
        super(
            LayoutSettings.EDITOR_TABS_MODE,
            EditorTabsMode.NONE,
            title,
            HideEditorTabsAction.ID,
            precondition,
            ( localize2(2875, "Hide Tab Bar"))
        );
    }
}
class ZenHideEditorTabsAction extends AbstractSetShowTabsAction {
    static {
        this.ID = "workbench.action.zenHideEditorTabs";
    }
    constructor() {
        const precondition = ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(`config.${ZenModeSettings.SHOW_TABS}`, EditorTabsMode.NONE)).negate()), InEditorZenModeContext));
        const title = ( localize2(2876, "Hide Editor Tabs in Zen Mode"));
        super(
            ZenModeSettings.SHOW_TABS,
            EditorTabsMode.NONE,
            title,
            ZenHideEditorTabsAction.ID,
            precondition,
            ( localize2(2877, "Hide Tab Bar in Zen Mode"))
        );
    }
}
class ShowMultipleEditorTabsAction extends AbstractSetShowTabsAction {
    static {
        this.ID = "workbench.action.showMultipleEditorTabs";
    }
    constructor() {
        const precondition = ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.MULTIPLE)).negate()), ( InEditorZenModeContext.negate())));
        const title = ( localize2(2878, "Show Multiple Editor Tabs"));
        super(
            LayoutSettings.EDITOR_TABS_MODE,
            EditorTabsMode.MULTIPLE,
            title,
            ShowMultipleEditorTabsAction.ID,
            precondition,
            ( localize2(2879, "Show Tab Bar with multiple tabs"))
        );
    }
}
class ZenShowMultipleEditorTabsAction extends AbstractSetShowTabsAction {
    static {
        this.ID = "workbench.action.zenShowMultipleEditorTabs";
    }
    constructor() {
        const precondition = ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(`config.${ZenModeSettings.SHOW_TABS}`, EditorTabsMode.MULTIPLE)).negate()), InEditorZenModeContext));
        const title = ( localize2(2880, "Show Multiple Editor Tabs in Zen Mode"));
        super(
            ZenModeSettings.SHOW_TABS,
            EditorTabsMode.MULTIPLE,
            title,
            ZenShowMultipleEditorTabsAction.ID,
            precondition,
            ( localize2(2881, "Show Tab Bar in Zen Mode"))
        );
    }
}
class ShowSingleEditorTabAction extends AbstractSetShowTabsAction {
    static {
        this.ID = "workbench.action.showEditorTab";
    }
    constructor() {
        const precondition = ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.SINGLE)).negate()), ( InEditorZenModeContext.negate())));
        const title = ( localize2(2882, "Show Single Editor Tab"));
        super(
            LayoutSettings.EDITOR_TABS_MODE,
            EditorTabsMode.SINGLE,
            title,
            ShowSingleEditorTabAction.ID,
            precondition,
            ( localize2(2883, "Show Tab Bar with one Tab"))
        );
    }
}
class ZenShowSingleEditorTabAction extends AbstractSetShowTabsAction {
    static {
        this.ID = "workbench.action.zenShowEditorTab";
    }
    constructor() {
        const precondition = ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(`config.${ZenModeSettings.SHOW_TABS}`, EditorTabsMode.SINGLE)).negate()), InEditorZenModeContext));
        const title = ( localize2(2884, "Show Single Editor Tab in Zen Mode"));
        super(
            ZenModeSettings.SHOW_TABS,
            EditorTabsMode.SINGLE,
            title,
            ZenShowSingleEditorTabAction.ID,
            precondition,
            ( localize2(2885, "Show Tab Bar in Zen Mode with one Tab"))
        );
    }
}
registerAction2(HideEditorTabsAction);
registerAction2(ZenHideEditorTabsAction);
registerAction2(ShowMultipleEditorTabsAction);
registerAction2(ZenShowMultipleEditorTabsAction);
registerAction2(ShowSingleEditorTabAction);
registerAction2(ZenShowSingleEditorTabAction);
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
    submenu: MenuId.EditorTabsBarShowTabsSubmenu,
    title: ( localize(2886, "Tab Bar")),
    group: "3_workbench_layout_move",
    order: 10,
    when: ( InEditorZenModeContext.negate())
});
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
    submenu: MenuId.EditorTabsBarShowTabsZenModeSubmenu,
    title: ( localize(2886, "Tab Bar")),
    group: "3_workbench_layout_move",
    order: 10,
    when: InEditorZenModeContext
});
class EditorActionsTitleBarAction extends Action2 {
    static {
        this.ID = "workbench.action.editorActionsTitleBar";
    }
    constructor() {
        super({
            id: EditorActionsTitleBarAction.ID,
            title: ( localize2(2887, "Move Editor Actions to Title Bar")),
            category: Categories.View,
            precondition: ( ( ContextKeyExpr.equals(
                `config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`,
                EditorActionsLocation.TITLEBAR
            )).negate()),
            metadata: {
                description: ( localize2(2888, "Move Editor Actions from the tab bar to the title bar"))
            },
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        return configurationService.updateValue(LayoutSettings.EDITOR_ACTIONS_LOCATION, EditorActionsLocation.TITLEBAR);
    }
}
registerAction2(EditorActionsTitleBarAction);
class EditorActionsDefaultAction extends Action2 {
    static {
        this.ID = "workbench.action.editorActionsDefault";
    }
    constructor() {
        super({
            id: EditorActionsDefaultAction.ID,
            title: ( localize2(2889, "Move Editor Actions to Tab Bar")),
            category: Categories.View,
            precondition: ( ContextKeyExpr.and(( ( ContextKeyExpr.equals(
                `config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`,
                EditorActionsLocation.DEFAULT
            )).negate()), ( ( ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.NONE)).negate()))),
            metadata: {
                description: ( localize2(2890, "Move Editor Actions from the title bar to the tab bar"))
            },
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        return configurationService.updateValue(LayoutSettings.EDITOR_ACTIONS_LOCATION, EditorActionsLocation.DEFAULT);
    }
}
registerAction2(EditorActionsDefaultAction);
class HideEditorActionsAction extends Action2 {
    static {
        this.ID = "workbench.action.hideEditorActions";
    }
    constructor() {
        super({
            id: HideEditorActionsAction.ID,
            title: ( localize2(2891, "Hide Editor Actions")),
            category: Categories.View,
            precondition: ( ( ContextKeyExpr.equals(
                `config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`,
                EditorActionsLocation.HIDDEN
            )).negate()),
            metadata: {
                description: ( localize2(2892, "Hide Editor Actions in the tab and title bar"))
            },
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        return configurationService.updateValue(LayoutSettings.EDITOR_ACTIONS_LOCATION, EditorActionsLocation.HIDDEN);
    }
}
registerAction2(HideEditorActionsAction);
class ShowEditorActionsAction extends Action2 {
    static {
        this.ID = "workbench.action.showEditorActions";
    }
    constructor() {
        super({
            id: ShowEditorActionsAction.ID,
            title: ( localize2(2893, "Show Editor Actions")),
            category: Categories.View,
            precondition: ( ContextKeyExpr.equals(
                `config.${LayoutSettings.EDITOR_ACTIONS_LOCATION}`,
                EditorActionsLocation.HIDDEN
            )),
            metadata: {
                description: ( localize2(2894, "Make Editor Actions visible."))
            },
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        return configurationService.updateValue(LayoutSettings.EDITOR_ACTIONS_LOCATION, EditorActionsLocation.DEFAULT);
    }
}
registerAction2(ShowEditorActionsAction);
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
    submenu: MenuId.EditorActionsPositionSubmenu,
    title: ( localize(2895, "Editor Actions Position")),
    group: "3_workbench_layout_move",
    order: 11
});
class ConfigureEditorTabsAction extends Action2 {
    static {
        this.ID = "workbench.action.configureEditorTabs";
    }
    constructor() {
        super({
            id: ConfigureEditorTabsAction.ID,
            title: ( localize2(2896, "Configure Tabs")),
            category: Categories.View
        });
    }
    run(accessor) {
        const preferencesService = accessor.get(IPreferencesService);
        preferencesService.openSettings({
            jsonEditor: false,
            query: "workbench.editor tab"
        });
    }
}
registerAction2(ConfigureEditorTabsAction);
class ConfigureEditorAction extends Action2 {
    static {
        this.ID = "workbench.action.configureEditor";
    }
    constructor() {
        super({
            id: ConfigureEditorAction.ID,
            title: ( localize2(2897, "Configure Editors")),
            category: Categories.View
        });
    }
    run(accessor) {
        const preferencesService = accessor.get(IPreferencesService);
        preferencesService.openSettings({
            jsonEditor: false,
            query: "workbench.editor"
        });
    }
}
registerAction2(ConfigureEditorAction);
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.toggleSeparatePinnedEditorTabs",
            title: ( localize2(2898, "Separate Pinned Editor Tabs")),
            category: Categories.View,
            precondition: ( ContextKeyExpr.equals(`config.${LayoutSettings.EDITOR_TABS_MODE}`, EditorTabsMode.MULTIPLE)),
            metadata: {
                description: ( localize2(
                    2899,
                    "Toggle whether pinned editor tabs are shown on a separate row above unpinned tabs."
                ))
            },
            f1: true
        });
    }
    run(accessor) {
        const configurationService = accessor.get(IConfigurationService);
        const oldettingValue = configurationService.getValue("workbench.editor.pinnedTabsOnSeparateRow");
        const newSettingValue = !oldettingValue;
        return configurationService.updateValue("workbench.editor.pinnedTabsOnSeparateRow", newSettingValue);
    }
});
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.toggleZenMode",
            title: {
                ...( localize2(2900, "Toggle Zen Mode")),
                mnemonicTitle: ( localize(2901, "Zen Mode"))
            },
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated()),
            category: Categories.View,
            f1: true,
            keybinding: {
                weight: KeybindingWeight.WorkbenchContrib,
                primary: KeyChord(KeyMod$1.CtrlCmd | KeyCode.KeyK, KeyCode.KeyZ)
            },
            toggled: InEditorZenModeContext,
            menu: [{
                id: MenuId.MenubarAppearanceMenu,
                group: "1_toggle_view",
                order: 2
            }]
        });
    }
    run(accessor) {
        return accessor.get(IWorkbenchLayoutService).toggleZenMode();
    }
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
    id: "workbench.action.exitZenMode",
    weight: KeybindingWeight.EditorContrib - 1000,
    handler(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const contextKeyService = accessor.get(IContextKeyService);
        if (InEditorZenModeContext.getValue(contextKeyService)) {
            layoutService.toggleZenMode();
        }
    },
    when: InEditorZenModeContext,
    primary: KeyChord(KeyCode.Escape, KeyCode.Escape)
});
if (isWindows || isLinux || isWeb) {
    registerAction2(class ToggleMenubarAction extends Action2 {
        constructor() {
            super({
                id: "workbench.action.toggleMenuBar",
                title: {
                    ...( localize2(2902, "Toggle Menu Bar")),
                    mnemonicTitle: ( localize(2903, "Menu &&Bar"))
                },
                category: Categories.View,
                f1: true,
                toggled: ( ContextKeyExpr.and(( IsMacNativeContext.toNegated()), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "hidden")), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "toggle")), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "compact")))),
                menu: [{
                    id: MenuId.MenubarAppearanceMenu,
                    group: "2_workbench_layout",
                    order: 0
                }]
            });
        }
        run(accessor) {
            return accessor.get(IWorkbenchLayoutService).toggleMenuBar();
        }
    });
    for (const menuId of [MenuId.TitleBarContext, MenuId.TitleBarTitleContext]) {
        MenuRegistry.appendMenuItem(menuId, {
            command: {
                id: "workbench.action.toggleMenuBar",
                title: ( localize(2904, "Menu Bar")),
                toggled: ( ContextKeyExpr.and(( IsMacNativeContext.toNegated()), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "hidden")), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "toggle")), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "compact"))))
            },
            when: ( ContextKeyExpr.and(( IsAuxiliaryWindowFocusedContext.toNegated()), ( ContextKeyExpr.notEquals(TitleBarStyleContext.key, TitlebarStyle.NATIVE)), ( IsMainWindowFullscreenContext.negate()))),
            group: "2_config",
            order: 0
        });
    }
}
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.resetViewLocations",
            title: ( localize2(2905, "Reset View Locations")),
            category: Categories.View,
            f1: true
        });
    }
    run(accessor) {
        return accessor.get(IViewDescriptorService).reset();
    }
});
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.moveView",
            title: ( localize2(2906, "Move View")),
            category: Categories.View,
            f1: true
        });
    }
    async run(accessor) {
        const viewDescriptorService = accessor.get(IViewDescriptorService);
        const instantiationService = accessor.get(IInstantiationService);
        const quickInputService = accessor.get(IQuickInputService);
        const contextKeyService = accessor.get(IContextKeyService);
        const paneCompositePartService = accessor.get(IPaneCompositePartService);
        const focusedViewId = FocusedViewContext.getValue(contextKeyService);
        let viewId;
        if (focusedViewId && viewDescriptorService.getViewDescriptorById(focusedViewId)?.canMoveView) {
            viewId = focusedViewId;
        }
        try {
            viewId = await this.getView(quickInputService, viewDescriptorService, paneCompositePartService, viewId);
            if (!viewId) {
                return;
            }
            const moveFocusedViewAction = ( new MoveFocusedViewAction());
            instantiationService.invokeFunction(accessor => moveFocusedViewAction.run(accessor, viewId));
        } catch {}
    }
    getViewItems(viewDescriptorService, paneCompositePartService) {
        const results = [];
        const viewlets = paneCompositePartService.getVisiblePaneCompositeIds(ViewContainerLocation.Sidebar);
        viewlets.forEach(viewletId => {
            const container = viewDescriptorService.getViewContainerById(viewletId);
            const containerModel = viewDescriptorService.getViewContainerModel(container);
            let hasAddedView = false;
            containerModel.visibleViewDescriptors.forEach(viewDescriptor => {
                if (viewDescriptor.canMoveView) {
                    if (!hasAddedView) {
                        results.push({
                            type: "separator",
                            label: ( localize(2907, "Side Bar / {0}", containerModel.title))
                        });
                        hasAddedView = true;
                    }
                    results.push({
                        id: viewDescriptor.id,
                        label: viewDescriptor.name.value
                    });
                }
            });
        });
        const panels = paneCompositePartService.getPinnedPaneCompositeIds(ViewContainerLocation.Panel);
        panels.forEach(panel => {
            const container = viewDescriptorService.getViewContainerById(panel);
            const containerModel = viewDescriptorService.getViewContainerModel(container);
            let hasAddedView = false;
            containerModel.visibleViewDescriptors.forEach(viewDescriptor => {
                if (viewDescriptor.canMoveView) {
                    if (!hasAddedView) {
                        results.push({
                            type: "separator",
                            label: ( localize(2908, "Panel / {0}", containerModel.title))
                        });
                        hasAddedView = true;
                    }
                    results.push({
                        id: viewDescriptor.id,
                        label: viewDescriptor.name.value
                    });
                }
            });
        });
        const sidePanels = paneCompositePartService.getPinnedPaneCompositeIds(ViewContainerLocation.AuxiliaryBar);
        sidePanels.forEach(panel => {
            const container = viewDescriptorService.getViewContainerById(panel);
            const containerModel = viewDescriptorService.getViewContainerModel(container);
            let hasAddedView = false;
            containerModel.visibleViewDescriptors.forEach(viewDescriptor => {
                if (viewDescriptor.canMoveView) {
                    if (!hasAddedView) {
                        results.push({
                            type: "separator",
                            label: ( localize(2909, "Secondary Side Bar / {0}", containerModel.title))
                        });
                        hasAddedView = true;
                    }
                    results.push({
                        id: viewDescriptor.id,
                        label: viewDescriptor.name.value
                    });
                }
            });
        });
        return results;
    }
    async getView(quickInputService, viewDescriptorService, paneCompositePartService, viewId) {
        const disposables = ( new DisposableStore());
        const quickPick = disposables.add(quickInputService.createQuickPick({
            useSeparators: true
        }));
        quickPick.placeholder = ( localize(2910, "Select a View to Move"));
        quickPick.items = this.getViewItems(viewDescriptorService, paneCompositePartService);
        quickPick.selectedItems = quickPick.items.filter(item => item.id === viewId);
        return ( new Promise((resolve, reject) => {
            disposables.add(quickPick.onDidAccept(() => {
                const viewId = quickPick.selectedItems[0];
                if (viewId.id) {
                    resolve(viewId.id);
                } else {
                    reject();
                }
                quickPick.hide();
            }));
            disposables.add(quickPick.onDidHide(() => {
                disposables.dispose();
                reject();
            }));
            quickPick.show();
        }));
    }
});
class MoveFocusedViewAction extends Action2 {
    constructor() {
        super({
            id: "workbench.action.moveFocusedView",
            title: ( localize2(2911, "Move Focused View")),
            category: Categories.View,
            precondition: ( FocusedViewContext.notEqualsTo("")),
            f1: true
        });
    }
    run(accessor, viewId) {
        const viewDescriptorService = accessor.get(IViewDescriptorService);
        const viewsService = accessor.get(IViewsService);
        const quickInputService = accessor.get(IQuickInputService);
        const contextKeyService = accessor.get(IContextKeyService);
        const dialogService = accessor.get(IDialogService);
        const paneCompositePartService = accessor.get(IPaneCompositePartService);
        const focusedViewId = viewId || FocusedViewContext.getValue(contextKeyService);
        if (focusedViewId === undefined || focusedViewId.trim() === "") {
            dialogService.error(( localize(2912, "There is no view currently focused.")));
            return;
        }
        const viewDescriptor = viewDescriptorService.getViewDescriptorById(focusedViewId);
        if (!viewDescriptor?.canMoveView) {
            dialogService.error(( localize(2913, "The currently focused view is not movable.")));
            return;
        }
        const disposables = ( new DisposableStore());
        const quickPick = disposables.add(quickInputService.createQuickPick({
            useSeparators: true
        }));
        quickPick.placeholder = ( localize(2914, "Select a Destination for the View"));
        quickPick.title = ( localize(2915, "View: Move {0}", viewDescriptor.name.value));
        const items = [];
        const currentContainer = viewDescriptorService.getViewContainerByViewId(focusedViewId);
        const currentLocation = viewDescriptorService.getViewLocationById(focusedViewId);
        const isViewSolo = viewDescriptorService.getViewContainerModel(currentContainer).allViewDescriptors.length === 1;
        if (!(isViewSolo && currentLocation === ViewContainerLocation.Panel)) {
            items.push({
                id: "_.panel.newcontainer",
                label: ( localize(2916, "New Panel Entry"))
            });
        }
        if (!(isViewSolo && currentLocation === ViewContainerLocation.Sidebar)) {
            items.push({
                id: "_.sidebar.newcontainer",
                label: ( localize(2917, "New Side Bar Entry"))
            });
        }
        if (!(isViewSolo && currentLocation === ViewContainerLocation.AuxiliaryBar)) {
            items.push({
                id: "_.auxiliarybar.newcontainer",
                label: ( localize(2918, "New Secondary Side Bar Entry"))
            });
        }
        items.push({
            type: "separator",
            label: ( localize(2919, "Side Bar"))
        });
        const pinnedViewlets = paneCompositePartService.getVisiblePaneCompositeIds(ViewContainerLocation.Sidebar);
        items.push(...( pinnedViewlets.filter(viewletId => {
            if (viewletId === viewDescriptorService.getViewContainerByViewId(focusedViewId).id) {
                return false;
            }
            return !viewDescriptorService.getViewContainerById(viewletId).rejectAddedViews;
        }).map(viewletId => {
            return {
                id: viewletId,
                label: viewDescriptorService.getViewContainerModel(viewDescriptorService.getViewContainerById(viewletId)).title
            };
        })));
        items.push({
            type: "separator",
            label: ( localize(2920, "Panel"))
        });
        const pinnedPanels = paneCompositePartService.getPinnedPaneCompositeIds(ViewContainerLocation.Panel);
        items.push(...( pinnedPanels.filter(panel => {
            if (panel === viewDescriptorService.getViewContainerByViewId(focusedViewId).id) {
                return false;
            }
            return !viewDescriptorService.getViewContainerById(panel).rejectAddedViews;
        }).map(panel => {
            return {
                id: panel,
                label: viewDescriptorService.getViewContainerModel(viewDescriptorService.getViewContainerById(panel)).title
            };
        })));
        items.push({
            type: "separator",
            label: ( localize(2921, "Secondary Side Bar"))
        });
        const pinnedAuxPanels = paneCompositePartService.getPinnedPaneCompositeIds(ViewContainerLocation.AuxiliaryBar);
        items.push(...( pinnedAuxPanels.filter(panel => {
            if (panel === viewDescriptorService.getViewContainerByViewId(focusedViewId).id) {
                return false;
            }
            return !viewDescriptorService.getViewContainerById(panel).rejectAddedViews;
        }).map(panel => {
            return {
                id: panel,
                label: viewDescriptorService.getViewContainerModel(viewDescriptorService.getViewContainerById(panel)).title
            };
        })));
        quickPick.items = items;
        disposables.add(quickPick.onDidAccept(() => {
            const destination = quickPick.selectedItems[0];
            if (destination.id === "_.panel.newcontainer") {
                viewDescriptorService.moveViewToLocation(viewDescriptor, ViewContainerLocation.Panel, this.desc.id);
                viewsService.openView(focusedViewId, true);
            } else if (destination.id === "_.sidebar.newcontainer") {
                viewDescriptorService.moveViewToLocation(viewDescriptor, ViewContainerLocation.Sidebar, this.desc.id);
                viewsService.openView(focusedViewId, true);
            } else if (destination.id === "_.auxiliarybar.newcontainer") {
                viewDescriptorService.moveViewToLocation(viewDescriptor, ViewContainerLocation.AuxiliaryBar, this.desc.id);
                viewsService.openView(focusedViewId, true);
            } else if (destination.id) {
                viewDescriptorService.moveViewsToContainer(
                    [viewDescriptor],
                    viewDescriptorService.getViewContainerById(destination.id),
                    undefined,
                    this.desc.id
                );
                viewsService.openView(focusedViewId, true);
            }
            quickPick.hide();
        }));
        disposables.add(quickPick.onDidHide(() => disposables.dispose()));
        quickPick.show();
    }
}
registerAction2(MoveFocusedViewAction);
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.resetFocusedViewLocation",
            title: ( localize2(2922, "Reset Focused View Location")),
            category: Categories.View,
            f1: true,
            precondition: ( FocusedViewContext.notEqualsTo(""))
        });
    }
    run(accessor) {
        const viewDescriptorService = accessor.get(IViewDescriptorService);
        const contextKeyService = accessor.get(IContextKeyService);
        const dialogService = accessor.get(IDialogService);
        const viewsService = accessor.get(IViewsService);
        const focusedViewId = FocusedViewContext.getValue(contextKeyService);
        let viewDescriptor = null;
        if (focusedViewId !== undefined && focusedViewId.trim() !== "") {
            viewDescriptor = viewDescriptorService.getViewDescriptorById(focusedViewId);
        }
        if (!viewDescriptor) {
            dialogService.error(( localize(2923, "There is no view currently focused.")));
            return;
        }
        const defaultContainer = viewDescriptorService.getDefaultContainerById(viewDescriptor.id);
        if (!defaultContainer || defaultContainer === viewDescriptorService.getViewContainerByViewId(viewDescriptor.id)) {
            return;
        }
        viewDescriptorService.moveViewsToContainer([viewDescriptor], defaultContainer, undefined, this.desc.id);
        viewsService.openView(viewDescriptor.id, true);
    }
});
class BaseResizeViewAction extends Action2 {
    static {
        this.RESIZE_INCREMENT = 60;
    }
    resizePart(widthChange, heightChange, layoutService, partToResize) {
        if (layoutService.activeContainer !== layoutService.mainContainer) {
            return;
        }
        let part;
        if (partToResize === undefined) {
            const isEditorFocus = layoutService.hasFocus(Parts.EDITOR_PART);
            const isSidebarFocus = layoutService.hasFocus(Parts.SIDEBAR_PART);
            const isPanelFocus = layoutService.hasFocus(Parts.PANEL_PART);
            const isAuxiliaryBarFocus = layoutService.hasFocus(Parts.AUXILIARYBAR_PART);
            if (isSidebarFocus) {
                part = Parts.SIDEBAR_PART;
            } else if (isPanelFocus) {
                part = Parts.PANEL_PART;
            } else if (isEditorFocus) {
                part = Parts.EDITOR_PART;
            } else if (isAuxiliaryBarFocus) {
                part = Parts.AUXILIARYBAR_PART;
            }
        } else {
            part = partToResize;
        }
        if (part) {
            layoutService.resizePart(part, widthChange, heightChange);
        }
    }
}
class IncreaseViewSizeAction extends BaseResizeViewAction {
    constructor() {
        super({
            id: "workbench.action.increaseViewSize",
            title: ( localize2(2924, "Increase Current View Size")),
            f1: true,
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated())
        });
    }
    run(accessor) {
        this.resizePart(
            BaseResizeViewAction.RESIZE_INCREMENT,
            BaseResizeViewAction.RESIZE_INCREMENT,
            accessor.get(IWorkbenchLayoutService)
        );
    }
}
class IncreaseViewWidthAction extends BaseResizeViewAction {
    constructor() {
        super({
            id: "workbench.action.increaseViewWidth",
            title: ( localize2(2925, "Increase Editor Width")),
            f1: true,
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated())
        });
    }
    run(accessor) {
        this.resizePart(
            BaseResizeViewAction.RESIZE_INCREMENT,
            0,
            accessor.get(IWorkbenchLayoutService),
            Parts.EDITOR_PART
        );
    }
}
class IncreaseViewHeightAction extends BaseResizeViewAction {
    constructor() {
        super({
            id: "workbench.action.increaseViewHeight",
            title: ( localize2(2926, "Increase Editor Height")),
            f1: true,
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated())
        });
    }
    run(accessor) {
        this.resizePart(
            0,
            BaseResizeViewAction.RESIZE_INCREMENT,
            accessor.get(IWorkbenchLayoutService),
            Parts.EDITOR_PART
        );
    }
}
class DecreaseViewSizeAction extends BaseResizeViewAction {
    constructor() {
        super({
            id: "workbench.action.decreaseViewSize",
            title: ( localize2(2927, "Decrease Current View Size")),
            f1: true,
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated())
        });
    }
    run(accessor) {
        this.resizePart(
            -BaseResizeViewAction.RESIZE_INCREMENT,
            -BaseResizeViewAction.RESIZE_INCREMENT,
            accessor.get(IWorkbenchLayoutService)
        );
    }
}
class DecreaseViewWidthAction extends BaseResizeViewAction {
    constructor() {
        super({
            id: "workbench.action.decreaseViewWidth",
            title: ( localize2(2928, "Decrease Editor Width")),
            f1: true,
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated())
        });
    }
    run(accessor) {
        this.resizePart(
            -BaseResizeViewAction.RESIZE_INCREMENT,
            0,
            accessor.get(IWorkbenchLayoutService),
            Parts.EDITOR_PART
        );
    }
}
class DecreaseViewHeightAction extends BaseResizeViewAction {
    constructor() {
        super({
            id: "workbench.action.decreaseViewHeight",
            title: ( localize2(2929, "Decrease Editor Height")),
            f1: true,
            precondition: ( IsAuxiliaryWindowFocusedContext.toNegated())
        });
    }
    run(accessor) {
        this.resizePart(
            0,
            -BaseResizeViewAction.RESIZE_INCREMENT,
            accessor.get(IWorkbenchLayoutService),
            Parts.EDITOR_PART
        );
    }
}
registerAction2(IncreaseViewSizeAction);
registerAction2(IncreaseViewWidthAction);
registerAction2(IncreaseViewHeightAction);
registerAction2(DecreaseViewSizeAction);
registerAction2(DecreaseViewWidthAction);
registerAction2(DecreaseViewHeightAction);
registerAction2(class AlignQuickInputTopAction extends Action2 {
    constructor() {
        super({
            id: "workbench.action.alignQuickInputTop",
            title: ( localize2(2930, "Align Quick Input Top")),
            f1: false
        });
    }
    run(accessor) {
        const quickInputService = accessor.get(IQuickInputService);
        quickInputService.setAlignment("top");
    }
});
registerAction2(class AlignQuickInputCenterAction extends Action2 {
    constructor() {
        super({
            id: "workbench.action.alignQuickInputCenter",
            title: ( localize2(2931, "Align Quick Input Center")),
            f1: false
        });
    }
    run(accessor) {
        const quickInputService = accessor.get(IQuickInputService);
        quickInputService.setAlignment("center");
    }
});
function isContextualLayoutVisualIcon(icon) {
    return icon.iconA !== undefined;
}
const CreateToggleLayoutItem = (id, active, label, visualIcon) => {
    return {
        id,
        active,
        label,
        visualIcon,
        activeIcon: Codicon.eye,
        inactiveIcon: Codicon.eyeClosed,
        activeAriaLabel: ( localize(2932, "Select to Hide")),
        inactiveAriaLabel: ( localize(2933, "Select to Show")),
        useButtons: true
    };
};
const CreateOptionLayoutItem = (id, active, label, visualIcon) => {
    return {
        id,
        active,
        label,
        visualIcon,
        activeIcon: Codicon.check,
        activeAriaLabel: ( localize(2934, "Active")),
        useButtons: false
    };
};
const MenuBarToggledContext = ( ContextKeyExpr.and(( IsMacNativeContext.toNegated()), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "hidden")), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "toggle")), ( ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, "compact"))));
const ToggleVisibilityActions = [];
if (!isMacintosh || !isNative) {
    ToggleVisibilityActions.push(
        CreateToggleLayoutItem("workbench.action.toggleMenuBar", MenuBarToggledContext, ( localize(2935, "Menu Bar")), menubarIcon)
    );
}
ToggleVisibilityActions.push(
    ...[CreateToggleLayoutItem(ToggleActivityBarVisibilityActionId, ( ContextKeyExpr.notEquals("config.workbench.activityBar.location", "hidden")), ( localize(2936, "Activity Bar")), {
        whenA: ( ContextKeyExpr.equals("config.workbench.sideBar.location", "left")),
        iconA: activityBarLeftIcon,
        iconB: activityBarRightIcon
    }), CreateToggleLayoutItem(ToggleSidebarVisibilityAction.ID, SideBarVisibleContext, ( localize(2937, "Primary Side Bar")), {
        whenA: ( ContextKeyExpr.equals("config.workbench.sideBar.location", "left")),
        iconA: panelLeftIcon,
        iconB: panelRightIcon
    }), CreateToggleLayoutItem(ToggleAuxiliaryBarAction.ID, AuxiliaryBarVisibleContext, ( localize(2921, "Secondary Side Bar")), {
        whenA: ( ContextKeyExpr.equals("config.workbench.sideBar.location", "left")),
        iconA: panelRightIcon,
        iconB: panelLeftIcon
    }), CreateToggleLayoutItem(TogglePanelAction.ID, PanelVisibleContext, ( localize(2920, "Panel")), panelIcon), CreateToggleLayoutItem(ToggleStatusbarVisibilityAction.ID, ( ContextKeyExpr.equals("config.workbench.statusBar.visible", true)), ( localize(2938, "Status Bar")), statusBarIcon)]
);
const MoveSideBarActions = [CreateOptionLayoutItem(MoveSidebarLeftAction.ID, ( ContextKeyExpr.equals("config.workbench.sideBar.location", "left")), ( localize(2939, "Left")), panelLeftIcon), CreateOptionLayoutItem(MoveSidebarRightAction.ID, ( ContextKeyExpr.equals("config.workbench.sideBar.location", "right")), ( localize(2940, "Right")), panelRightIcon)];
const AlignPanelActions = [CreateOptionLayoutItem("workbench.action.alignPanelLeft", ( PanelAlignmentContext.isEqualTo("left")), ( localize(2941, "Left")), panelAlignmentLeftIcon), CreateOptionLayoutItem("workbench.action.alignPanelRight", ( PanelAlignmentContext.isEqualTo("right")), ( localize(2942, "Right")), panelAlignmentRightIcon), CreateOptionLayoutItem("workbench.action.alignPanelCenter", ( PanelAlignmentContext.isEqualTo("center")), ( localize(2943, "Center")), panelAlignmentCenterIcon), CreateOptionLayoutItem("workbench.action.alignPanelJustify", ( PanelAlignmentContext.isEqualTo("justify")), ( localize(2944, "Justify")), panelAlignmentJustifyIcon)];
const QuickInputActions = [
    CreateOptionLayoutItem("workbench.action.alignQuickInputTop", ( QuickInputAlignmentContextKey.isEqualTo("top")), ( localize(2945, "Top")), quickInputAlignmentTopIcon),
    CreateOptionLayoutItem("workbench.action.alignQuickInputCenter", ( QuickInputAlignmentContextKey.isEqualTo("center")), ( localize(2946, "Center")), quickInputAlignmentCenterIcon)
];
const MiscLayoutOptions = [CreateOptionLayoutItem(
    "workbench.action.toggleFullScreen",
    IsMainWindowFullscreenContext,
    ( localize(2947, "Full Screen")),
    fullscreenIcon
), CreateOptionLayoutItem("workbench.action.toggleZenMode", InEditorZenModeContext, ( localize(2948, "Zen Mode")), zenModeIcon), CreateOptionLayoutItem(
    "workbench.action.toggleCenteredLayout",
    IsMainEditorCenteredLayoutContext,
    ( localize(2949, "Centered Layout")),
    centerLayoutIcon
)];
const LayoutContextKeySet = ( new Set());
for (const {
    active
} of [
    ...ToggleVisibilityActions,
    ...MoveSideBarActions,
    ...AlignPanelActions,
    ...QuickInputActions,
    ...MiscLayoutOptions
]) {
    for (const key of ( active.keys())) {
        LayoutContextKeySet.add(key);
    }
}
registerAction2(class CustomizeLayoutAction extends Action2 {
    constructor() {
        super({
            id: "workbench.action.customizeLayout",
            title: ( localize2(2950, "Customize Layout...")),
            f1: true,
            icon: configureLayoutIcon,
            menu: [{
                id: MenuId.LayoutControlMenuSubmenu,
                group: "z_end"
            }, {
                id: MenuId.LayoutControlMenu,
                when: ( ContextKeyExpr.and(( IsAuxiliaryWindowContext.toNegated()), ( ContextKeyExpr.equals("config.workbench.layoutControl.type", "both")))),
                group: "1_layout"
            }]
        });
    }
    getItems(contextKeyService, keybindingService) {
        const toQuickPickItem = item => {
            const toggled = item.active.evaluate(contextKeyService.getContext(null));
            let label = item.useButtons ? item.label : item.label + (toggled && item.activeIcon ? ` $(${item.activeIcon.id})` : (!toggled && item.inactiveIcon ? ` $(${item.inactiveIcon.id})` : ""));
            const ariaLabel = item.label + (toggled && item.activeAriaLabel ? ` (${item.activeAriaLabel})` : (!toggled && item.inactiveAriaLabel ? ` (${item.inactiveAriaLabel})` : ""));
            if (item.visualIcon) {
                let icon = item.visualIcon;
                if (isContextualLayoutVisualIcon(icon)) {
                    const useIconA = icon.whenA.evaluate(contextKeyService.getContext(null));
                    icon = useIconA ? icon.iconA : icon.iconB;
                }
                label = `$(${icon.id}) ${label}`;
            }
            const icon = toggled ? item.activeIcon : item.inactiveIcon;
            return {
                type: "item",
                id: item.id,
                label,
                ariaLabel,
                keybinding: keybindingService.lookupKeybinding(item.id, contextKeyService),
                buttons: !item.useButtons ? undefined : [{
                    alwaysVisible: false,
                    tooltip: ariaLabel,
                    iconClass: icon ? ThemeIcon.asClassName(icon) : undefined
                }]
            };
        };
        return [{
            type: "separator",
            label: ( localize(2951, "Visibility"))
        }, ...( ToggleVisibilityActions.map(toQuickPickItem)), {
            type: "separator",
            label: ( localize(2952, "Primary Side Bar Position"))
        }, ...( MoveSideBarActions.map(toQuickPickItem)), {
            type: "separator",
            label: ( localize(2953, "Panel Alignment"))
        }, ...( AlignPanelActions.map(toQuickPickItem)), {
            type: "separator",
            label: ( localize(2954, "Quick Input Position"))
        }, ...( QuickInputActions.map(toQuickPickItem)), {
            type: "separator",
            label: ( localize(2955, "Modes"))
        }, ...( MiscLayoutOptions.map(toQuickPickItem))];
    }
    run(accessor) {
        if (this._currentQuickPick) {
            this._currentQuickPick.hide();
            return;
        }
        const configurationService = accessor.get(IConfigurationService);
        const contextKeyService = accessor.get(IContextKeyService);
        const commandService = accessor.get(ICommandService);
        const quickInputService = accessor.get(IQuickInputService);
        const keybindingService = accessor.get(IKeybindingService);
        const disposables = ( new DisposableStore());
        const quickPick = disposables.add(quickInputService.createQuickPick({
            useSeparators: true
        }));
        this._currentQuickPick = quickPick;
        quickPick.items = this.getItems(contextKeyService, keybindingService);
        quickPick.ignoreFocusOut = true;
        quickPick.hideInput = true;
        quickPick.title = ( localize(2956, "Customize Layout"));
        const closeButton = {
            alwaysVisible: true,
            iconClass: ThemeIcon.asClassName(Codicon.close),
            tooltip: ( localize(2957, "Close"))
        };
        const resetButton = {
            alwaysVisible: true,
            iconClass: ThemeIcon.asClassName(Codicon.discard),
            tooltip: ( localize(2958, "Restore Defaults"))
        };
        quickPick.buttons = [resetButton, closeButton];
        let selectedItem = undefined;
        disposables.add(contextKeyService.onDidChangeContext(changeEvent => {
            if (changeEvent.affectsSome(LayoutContextKeySet)) {
                quickPick.items = this.getItems(contextKeyService, keybindingService);
                if (selectedItem) {
                    quickPick.activeItems = quickPick.items.filter(item => item.id === selectedItem?.id);
                }
                setTimeout(() => quickInputService.focus(), 0);
            }
        }));
        disposables.add(quickPick.onDidAccept(event => {
            if (quickPick.selectedItems.length) {
                selectedItem = quickPick.selectedItems[0];
                commandService.executeCommand(selectedItem.id);
            }
        }));
        disposables.add(quickPick.onDidTriggerItemButton(event => {
            if (event.item) {
                selectedItem = event.item;
                commandService.executeCommand(selectedItem.id);
            }
        }));
        disposables.add(quickPick.onDidTriggerButton(button => {
            if (button === closeButton) {
                quickPick.hide();
            } else if (button === resetButton) {
                const resetSetting = id => {
                    const config = configurationService.inspect(id);
                    configurationService.updateValue(id, config.defaultValue);
                };
                resetSetting("workbench.activityBar.location");
                resetSetting("workbench.sideBar.location");
                resetSetting("workbench.statusBar.visible");
                resetSetting("workbench.panel.defaultLocation");
                if (!isMacintosh || !isNative) {
                    resetSetting("window.menuBarVisibility");
                }
                commandService.executeCommand("workbench.action.alignPanelCenter");
                commandService.executeCommand("workbench.action.alignQuickInputTop");
            }
        }));
        disposables.add(quickPick.onDidHide(() => {
            quickPick.dispose();
        }));
        disposables.add(quickPick.onDispose(() => {
            this._currentQuickPick = undefined;
            disposables.dispose();
        }));
        quickPick.show();
    }
});

export { ConfigureEditorAction, ConfigureEditorTabsAction, EditorActionsDefaultAction, EditorActionsTitleBarAction, HideEditorActionsAction, HideEditorTabsAction, ShowEditorActionsAction, ShowMultipleEditorTabsAction, ShowSingleEditorTabAction, ToggleActivityBarVisibilityActionId, ToggleSidebarPositionAction, ToggleSidebarVisibilityAction, ToggleStatusbarVisibilityAction, ZenHideEditorTabsAction, ZenShowMultipleEditorTabsAction, ZenShowSingleEditorTabAction };
