
import { registerCss } from '../../../../../../../css.js';
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import * as menubarControl from './media/menubarControl.css';
import { localize, localize2 } from '../../../../nls.js';
import { MenuId, SubmenuItemAction, registerAction2, Action2, MenuItemAction } from '../../../../platform/actions/common/actions.js';
import { IMenuService } from '../../../../platform/actions/common/actions.service.js';
import { MenuSettings, getMenuBarVisibility, hasNativeMenu } from '../../../../platform/window/common/window.js';
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.service.js';
import { Separator, toAction, ActionRunner, SubmenuAction, Action } from '../../../../base/common/actions.js';
import { addDisposableListener, EventType, Dimension } from '../../../../base/browser/dom.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.service.js';
import { isMacintosh, isNative, isWeb, isIOS } from '../../../../base/common/platform.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.service.js';
import { Emitter } from '../../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { isRecentFolder, isRecentWorkspace } from '../../../../platform/workspaces/common/workspaces.js';
import { IWorkspacesService } from '../../../../platform/workspaces/common/workspaces.service.js';
import { RunOnceScheduler } from '../../../../base/common/async.js';
import { Verbosity } from '../../../../platform/label/common/label.js';
import { ILabelService } from '../../../../platform/label/common/label.service.js';
import { StateType } from '../../../../platform/update/common/update.js';
import { IUpdateService } from '../../../../platform/update/common/update.service.js';
import { StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { IStorageService } from '../../../../platform/storage/common/storage.service.js';
import '../../../../platform/notification/common/notification.js';
import { INotificationService } from '../../../../platform/notification/common/notification.service.js';
import { IPreferencesService } from '../../../services/preferences/common/preferences.service.js';
import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.service.js';
import { MenuBar } from '../../../../base/browser/ui/menu/menubar.js';
import { HorizontalDirection, VerticalDirection } from '../../../../base/browser/ui/menu/menu.js';
import { unmnemonicLabel, mnemonicMenuLabel } from '../../../../base/common/labels.js';
import { IAccessibilityService } from '../../../../platform/accessibility/common/accessibility.service.js';
import { isFullscreen, onDidChangeFullscreen } from '../../../../base/browser/browser.js';
import { IHostService } from '../../../services/host/browser/host.service.js';
import { BrowserFeatures } from '../../../../base/browser/canIUse.js';
import { KeyMod as KeyMod$1, KeyCode } from '../../../../base/common/keyCodes.js';
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
import { IsWebContext } from '../../../../platform/contextkey/common/contextkeys.js';
import { ICommandService } from '../../../../platform/commands/common/commands.service.js';
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.service.js';
import { OpenRecentAction } from '../../actions/windowActions.js';
import { isICommandActionToggleInfo } from '../../../../platform/action/common/action.js';
import { getFlatContextMenuActions } from '../../../../platform/actions/browser/menuEntryActionViewItem.js';
import { defaultMenuStyles } from '../../../../platform/theme/browser/defaultStyles.js';
import { mainWindow } from '../../../../base/browser/window.js';
import { ActivityBarPosition } from '../../../services/layout/browser/layoutService.js';
import Severity$1 from '../../../../base/common/severity.js';

registerCss(menubarControl);
class MenubarControl extends Disposable {
    static {
        this.MAX_MENU_RECENT_ENTRIES = 10;
    }
    constructor(
        menuService,
        workspacesService,
        contextKeyService,
        keybindingService,
        configurationService,
        labelService,
        updateService,
        storageService,
        notificationService,
        preferencesService,
        environmentService,
        accessibilityService,
        hostService,
        commandService
    ) {
        super();
        this.menuService = menuService;
        this.workspacesService = workspacesService;
        this.contextKeyService = contextKeyService;
        this.keybindingService = keybindingService;
        this.configurationService = configurationService;
        this.labelService = labelService;
        this.updateService = updateService;
        this.storageService = storageService;
        this.notificationService = notificationService;
        this.preferencesService = preferencesService;
        this.environmentService = environmentService;
        this.accessibilityService = accessibilityService;
        this.hostService = hostService;
        this.commandService = commandService;
        this.keys = [
            MenuSettings.MenuBarVisibility,
            "window.enableMenuBarMnemonics",
            "window.customMenuBarAltFocus",
            "workbench.sideBar.location",
            "window.nativeTabs"
        ];
        this.menus = {};
        this.topLevelTitles = {};
        this.recentlyOpened = {
            files: [],
            workspaces: []
        };
        this.mainMenu = this._register(
            this.menuService.createMenu(MenuId.MenubarMainMenu, this.contextKeyService)
        );
        this.mainMenuDisposables = this._register(( new DisposableStore()));
        this.setupMainMenu();
        this.menuUpdater = this._register(( new RunOnceScheduler(() => this.doUpdateMenubar(false), 200)));
        this.notifyUserOfCustomMenubarAccessibility();
    }
    registerListeners() {
        this._register(this.hostService.onDidChangeFocus(e => this.onDidChangeWindowFocus(e)));
        this._register(
            this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e))
        );
        this._register(this.updateService.onStateChange(() => this.onUpdateStateChange()));
        this._register(this.workspacesService.onDidChangeRecentlyOpened(() => {
            this.onDidChangeRecentlyOpened();
        }));
        this._register(this.keybindingService.onDidUpdateKeybindings(() => this.updateMenubar()));
        this._register(this.labelService.onDidChangeFormatters(() => {
            this.onDidChangeRecentlyOpened();
        }));
        this._register(this.mainMenu.onDidChange(() => {
            this.setupMainMenu();
            this.doUpdateMenubar(true);
        }));
    }
    setupMainMenu() {
        this.mainMenuDisposables.clear();
        this.menus = {};
        this.topLevelTitles = {};
        const [, mainMenuActions] = this.mainMenu.getActions()[0];
        for (const mainMenuAction of mainMenuActions) {
            if (mainMenuAction instanceof SubmenuItemAction && typeof mainMenuAction.item.title !== "string") {
                this.menus[mainMenuAction.item.title.original] = this.mainMenuDisposables.add(
                    this.menuService.createMenu(mainMenuAction.item.submenu, this.contextKeyService, {
                        emitEventsForSubmenuChanges: true
                    })
                );
                this.topLevelTitles[mainMenuAction.item.title.original] = mainMenuAction.item.title.mnemonicTitle ?? mainMenuAction.item.title.value;
            }
        }
    }
    updateMenubar() {
        this.menuUpdater.schedule();
    }
    calculateActionLabel(action) {
        const label = action.label;
        return label;
    }
    onUpdateStateChange() {
        this.updateMenubar();
    }
    onUpdateKeybindings() {
        this.updateMenubar();
    }
    getOpenRecentActions() {
        if (!this.recentlyOpened) {
            return [];
        }
        const {
            workspaces,
            files
        } = this.recentlyOpened;
        const result = [];
        if (workspaces.length > 0) {
            for (let i = 0; i < MenubarControl.MAX_MENU_RECENT_ENTRIES && i < workspaces.length; i++) {
                result.push(this.createOpenRecentMenuAction(workspaces[i]));
            }
            result.push(( new Separator()));
        }
        if (files.length > 0) {
            for (let i = 0; i < MenubarControl.MAX_MENU_RECENT_ENTRIES && i < files.length; i++) {
                result.push(this.createOpenRecentMenuAction(files[i]));
            }
            result.push(( new Separator()));
        }
        return result;
    }
    onDidChangeWindowFocus(hasFocus) {
        if (hasFocus) {
            this.onDidChangeRecentlyOpened();
        }
    }
    onConfigurationUpdated(event) {
        if (( this.keys.some(key => event.affectsConfiguration(key)))) {
            this.updateMenubar();
        }
        if (event.affectsConfiguration("editor.accessibilitySupport")) {
            this.notifyUserOfCustomMenubarAccessibility();
        }
        if (event.affectsConfiguration(MenuSettings.MenuBarVisibility)) {
            this.onDidChangeRecentlyOpened();
        }
    }
    get menubarHidden() {
        return isMacintosh && isNative ? false : getMenuBarVisibility(this.configurationService) === "hidden";
    }
    onDidChangeRecentlyOpened() {
        if (!this.menubarHidden) {
            this.workspacesService.getRecentlyOpened().then(recentlyOpened => {
                this.recentlyOpened = recentlyOpened;
                this.updateMenubar();
            });
        }
    }
    createOpenRecentMenuAction(recent) {
        let label;
        let uri;
        let commandId;
        let openable;
        const remoteAuthority = recent.remoteAuthority;
        if (isRecentFolder(recent)) {
            uri = recent.folderUri;
            label = recent.label || this.labelService.getWorkspaceLabel(uri, {
                verbose: Verbosity.LONG
            });
            commandId = "openRecentFolder";
            openable = {
                folderUri: uri
            };
        } else if (isRecentWorkspace(recent)) {
            uri = recent.workspace.configPath;
            label = recent.label || this.labelService.getWorkspaceLabel(recent.workspace, {
                verbose: Verbosity.LONG
            });
            commandId = "openRecentWorkspace";
            openable = {
                workspaceUri: uri
            };
        } else {
            uri = recent.fileUri;
            label = recent.label || this.labelService.getUriLabel(uri, {
                appendWorkspaceSuffix: true
            });
            commandId = "openRecentFile";
            openable = {
                fileUri: uri
            };
        }
        const ret = toAction({
            id: commandId,
            label: unmnemonicLabel(label),
            run: browserEvent => {
                const openInNewWindow = browserEvent && ((!isMacintosh && (browserEvent.ctrlKey || browserEvent.shiftKey)) || (isMacintosh && (browserEvent.metaKey || browserEvent.altKey)));
                return this.hostService.openWindow([openable], {
                    forceNewWindow: !!openInNewWindow,
                    remoteAuthority: remoteAuthority || null
                });
            }
        });
        return Object.assign(ret, {
            uri,
            remoteAuthority
        });
    }
    notifyUserOfCustomMenubarAccessibility() {
        if (isWeb || isMacintosh) {
            return;
        }
        const hasBeenNotified = this.storageService.getBoolean("menubar/accessibleMenubarNotified", StorageScope.APPLICATION, false);
        const usingCustomMenubar = !hasNativeMenu(this.configurationService);
        if (hasBeenNotified || usingCustomMenubar || !this.accessibilityService.isScreenReaderOptimized()) {
            return;
        }
        const message = ( localize(
            3863,
            "Accessibility support is enabled for you. For the most accessible experience, we recommend the custom menu style."
        ));
        this.notificationService.prompt(Severity$1.Info, message, [{
            label: ( localize(3864, "Open Settings")),
            run: () => {
                return this.preferencesService.openUserSettings({
                    query: MenuSettings.MenuStyle
                });
            }
        }]);
        this.storageService.store(
            "menubar/accessibleMenubarNotified",
            true,
            StorageScope.APPLICATION,
            StorageTarget.USER
        );
    }
}
let focusMenuBarEmitter = undefined;
function enableFocusMenuBarAction() {
    if (!focusMenuBarEmitter) {
        focusMenuBarEmitter = ( new Emitter());
        registerAction2(class extends Action2 {
            constructor() {
                super({
                    id: `workbench.actions.menubar.focus`,
                    title: ( localize2(3865, "Focus Application Menu")),
                    keybinding: {
                        primary: KeyMod$1.Alt | KeyCode.F10,
                        weight: KeybindingWeight.WorkbenchContrib,
                        when: IsWebContext
                    },
                    f1: true
                });
            }
            async run() {
                focusMenuBarEmitter?.fire();
            }
        });
    }
    return focusMenuBarEmitter;
}
let CustomMenubarControl = class CustomMenubarControl extends MenubarControl {
    constructor(
        menuService,
        workspacesService,
        contextKeyService,
        keybindingService,
        configurationService,
        labelService,
        updateService,
        storageService,
        notificationService,
        preferencesService,
        environmentService,
        accessibilityService,
        telemetryService,
        hostService,
        commandService
    ) {
        super(
            menuService,
            workspacesService,
            contextKeyService,
            keybindingService,
            configurationService,
            labelService,
            updateService,
            storageService,
            notificationService,
            preferencesService,
            environmentService,
            accessibilityService,
            hostService,
            commandService
        );
        this.telemetryService = telemetryService;
        this.alwaysOnMnemonics = false;
        this.focusInsideMenubar = false;
        this.pendingFirstTimeUpdate = false;
        this.visible = true;
        this.webNavigationMenu = this._register(
            this.menuService.createMenu(MenuId.MenubarHomeMenu, this.contextKeyService)
        );
        this.reinstallDisposables = this._register(( new DisposableStore()));
        this.updateActionsDisposables = this._register(( new DisposableStore()));
        this._onVisibilityChange = this._register(( new Emitter()));
        this._onFocusStateChange = this._register(( new Emitter()));
        this.actionRunner = this._register(( new ActionRunner()));
        this._register(this.actionRunner.onDidRun(e => {
            this.telemetryService.publicLog2("workbenchActionExecuted", {
                id: e.action.id,
                from: "menu"
            });
        }));
        this.workspacesService.getRecentlyOpened().then(recentlyOpened => {
            this.recentlyOpened = recentlyOpened;
        });
        this.registerListeners();
    }
    doUpdateMenubar(firstTime) {
        if (!this.focusInsideMenubar) {
            this.setupCustomMenubar(firstTime);
        }
        if (firstTime) {
            this.pendingFirstTimeUpdate = true;
        }
    }
    getUpdateAction() {
        const state = this.updateService.state;
        switch (state.type) {
        case StateType.Idle:
            return toAction({
                id: "update.check",
                label: ( localize(3866, "Check for &&Updates...")),
                enabled: true,
                run: () => this.updateService.checkForUpdates(true)
            });
        case StateType.CheckingForUpdates:
            return toAction({
                id: "update.checking",
                label: ( localize(3867, "Checking for Updates...")),
                enabled: false,
                run: () => {}
            });
        case StateType.AvailableForDownload:
            return toAction({
                id: "update.downloadNow",
                label: ( localize(3868, "D&&ownload Update")),
                enabled: true,
                run: () => this.updateService.downloadUpdate(true)
            });
        case StateType.Downloading:
        case StateType.Overwriting:
            return toAction({
                id: "update.downloading",
                label: ( localize(3869, "Downloading Update...")),
                enabled: false,
                run: () => {}
            });
        case StateType.Downloaded:
            return isMacintosh ? null : toAction({
                id: "update.install",
                label: ( localize(3870, "Install &&Update...")),
                enabled: true,
                run: () => this.updateService.applyUpdate()
            });
        case StateType.Updating:
            return toAction({
                id: "update.updating",
                label: ( localize(3871, "Installing Update...")),
                enabled: false,
                run: () => {}
            });
        case StateType.Ready:
            return toAction({
                id: "update.restart",
                label: ( localize(3872, "Restart to &&Update")),
                enabled: true,
                run: () => this.updateService.quitAndInstall()
            });
        default:
            return null;
        }
    }
    get currentMenubarVisibility() {
        return getMenuBarVisibility(this.configurationService);
    }
    get currentDisableMenuBarAltFocus() {
        const settingValue = this.configurationService.getValue("window.customMenuBarAltFocus");
        let disableMenuBarAltBehavior = false;
        if (typeof settingValue === "boolean") {
            disableMenuBarAltBehavior = !settingValue;
        }
        return disableMenuBarAltBehavior;
    }
    insertActionsBefore(nextAction, target) {
        switch (nextAction.id) {
        case OpenRecentAction.ID:
            target.push(...this.getOpenRecentActions());
            break;
        case "workbench.action.showAboutDialog":
            if (!isMacintosh && !isWeb) {
                const updateAction = this.getUpdateAction();
                if (updateAction) {
                    updateAction.label = mnemonicMenuLabel(updateAction.label);
                    target.push(updateAction);
                    target.push(( new Separator()));
                }
            }
            break;
        }
    }
    get currentEnableMenuBarMnemonics() {
        let enableMenuBarMnemonics = this.configurationService.getValue("window.enableMenuBarMnemonics");
        if (typeof enableMenuBarMnemonics !== "boolean") {
            enableMenuBarMnemonics = true;
        }
        return enableMenuBarMnemonics && (!isWeb || isFullscreen(mainWindow));
    }
    get currentCompactMenuMode() {
        if (this.currentMenubarVisibility !== "compact") {
            return undefined;
        }
        const currentSidebarLocation = this.configurationService.getValue("workbench.sideBar.location");
        const horizontalDirection = currentSidebarLocation === "right" ? HorizontalDirection.Left : HorizontalDirection.Right;
        const activityBarLocation = this.configurationService.getValue("workbench.activityBar.location");
        const verticalDirection = activityBarLocation === ActivityBarPosition.BOTTOM ? VerticalDirection.Above : VerticalDirection.Below;
        return {
            horizontal: horizontalDirection,
            vertical: verticalDirection
        };
    }
    onDidVisibilityChange(visible) {
        this.visible = visible;
        this.onDidChangeRecentlyOpened();
        this._onVisibilityChange.fire(visible);
    }
    toActionsArray(menu) {
        return getFlatContextMenuActions(menu.getActions({
            shouldForwardArgs: true
        }));
    }
    setupCustomMenubar(firstTime) {
        if (!this.container) {
            return;
        }
        if (firstTime) {
            if (this.menubar) {
                this.reinstallDisposables.clear();
            }
            this.menubar = this.reinstallDisposables.add(( new MenuBar(this.container, this.getMenuBarOptions(), defaultMenuStyles)));
            this.accessibilityService.alwaysUnderlineAccessKeys().then(val => {
                this.alwaysOnMnemonics = val;
                this.menubar?.update(this.getMenuBarOptions());
            });
            this.reinstallDisposables.add(this.menubar.onFocusStateChange(focused => {
                this._onFocusStateChange.fire(focused);
                if (!focused) {
                    if (this.pendingFirstTimeUpdate) {
                        this.setupCustomMenubar(true);
                        this.pendingFirstTimeUpdate = false;
                    } else {
                        this.updateMenubar();
                    }
                    this.focusInsideMenubar = false;
                }
            }));
            this.reinstallDisposables.add(this.menubar.onVisibilityChange(e => this.onDidVisibilityChange(e)));
            this.reinstallDisposables.add(addDisposableListener(this.container, EventType.FOCUS_IN, () => {
                this.focusInsideMenubar = true;
            }));
            this.reinstallDisposables.add(addDisposableListener(this.container, EventType.FOCUS_OUT, () => {
                this.focusInsideMenubar = false;
            }));
            if (this.menubar.isVisible) {
                this.onDidVisibilityChange(true);
            }
        } else {
            this.menubar?.update(this.getMenuBarOptions());
        }
        const updateActions = (menuActions, target, topLevelTitle, store) => {
            target.splice(0);
            for (const menuItem of menuActions) {
                this.insertActionsBefore(menuItem, target);
                if (menuItem instanceof Separator) {
                    target.push(menuItem);
                } else if (menuItem instanceof SubmenuItemAction || menuItem instanceof MenuItemAction) {
                    let title = typeof menuItem.item.title === "string" ? menuItem.item.title : menuItem.item.title.mnemonicTitle ?? menuItem.item.title.value;
                    if (menuItem instanceof SubmenuItemAction) {
                        const submenuActions = [];
                        updateActions(menuItem.actions, submenuActions, topLevelTitle, store);
                        if (submenuActions.length > 0) {
                            target.push(( new SubmenuAction(menuItem.id, mnemonicMenuLabel(title), submenuActions)));
                        }
                    } else {
                        if (isICommandActionToggleInfo(menuItem.item.toggled)) {
                            title = menuItem.item.toggled.mnemonicTitle ?? menuItem.item.toggled.title ?? title;
                        }
                        const newAction = store.add(( new Action(
                            menuItem.id,
                            mnemonicMenuLabel(title),
                            menuItem.class,
                            menuItem.enabled,
                            () => this.commandService.executeCommand(menuItem.id)
                        )));
                        newAction.tooltip = menuItem.tooltip;
                        newAction.checked = menuItem.checked;
                        target.push(newAction);
                    }
                }
            }
            if (topLevelTitle === "File" && this.currentCompactMenuMode === undefined) {
                const webActions = this.getWebNavigationActions();
                if (webActions.length) {
                    target.push(...webActions);
                }
            }
        };
        for (const title of ( Object.keys(this.topLevelTitles))) {
            const menu = this.menus[title];
            if (firstTime && menu) {
                const menuChangedDisposable = this.reinstallDisposables.add(( new DisposableStore()));
                this.reinstallDisposables.add(menu.onDidChange(() => {
                    if (!this.focusInsideMenubar) {
                        const actions = [];
                        menuChangedDisposable.clear();
                        updateActions(this.toActionsArray(menu), actions, title, menuChangedDisposable);
                        this.menubar?.updateMenu({
                            actions,
                            label: mnemonicMenuLabel(this.topLevelTitles[title])
                        });
                    }
                }));
                if (menu === this.menus.File) {
                    const webMenuChangedDisposable = this.reinstallDisposables.add(( new DisposableStore()));
                    this.reinstallDisposables.add(this.webNavigationMenu.onDidChange(() => {
                        if (!this.focusInsideMenubar) {
                            const actions = [];
                            webMenuChangedDisposable.clear();
                            updateActions(this.toActionsArray(menu), actions, title, webMenuChangedDisposable);
                            this.menubar?.updateMenu({
                                actions,
                                label: mnemonicMenuLabel(this.topLevelTitles[title])
                            });
                        }
                    }));
                }
            }
            const actions = [];
            if (menu) {
                this.updateActionsDisposables.clear();
                updateActions(this.toActionsArray(menu), actions, title, this.updateActionsDisposables);
            }
            if (this.menubar) {
                if (!firstTime) {
                    this.menubar.updateMenu({
                        actions,
                        label: mnemonicMenuLabel(this.topLevelTitles[title])
                    });
                } else {
                    this.menubar.push({
                        actions,
                        label: mnemonicMenuLabel(this.topLevelTitles[title])
                    });
                }
            }
        }
    }
    getWebNavigationActions() {
        if (!isWeb) {
            return [];
        }
        const webNavigationActions = [];
        for (const groups of this.webNavigationMenu.getActions()) {
            const [, actions] = groups;
            for (const action of actions) {
                if (action instanceof MenuItemAction) {
                    const title = typeof action.item.title === "string" ? action.item.title : action.item.title.mnemonicTitle ?? action.item.title.value;
                    webNavigationActions.push(toAction({
                        id: action.id,
                        label: mnemonicMenuLabel(title),
                        class: action.class,
                        enabled: action.enabled,
                        run: async event => {
                            this.commandService.executeCommand(action.id, event);
                        }
                    }));
                }
            }
            webNavigationActions.push(( new Separator()));
        }
        if (webNavigationActions.length) {
            webNavigationActions.pop();
        }
        return webNavigationActions;
    }
    getMenuBarOptions() {
        return {
            enableMnemonics: this.currentEnableMenuBarMnemonics,
            disableAltFocus: this.currentDisableMenuBarAltFocus,
            visibility: this.currentMenubarVisibility,
            actionRunner: this.actionRunner,
            getKeybinding: action => this.keybindingService.lookupKeybinding(action.id),
            alwaysOnMnemonics: this.alwaysOnMnemonics,
            compactMode: this.currentCompactMenuMode,
            getCompactMenuActions: () => {
                if (!isWeb) {
                    return [];
                }
                return this.getWebNavigationActions();
            }
        };
    }
    onDidChangeWindowFocus(hasFocus) {
        if (!this.visible) {
            return;
        }
        super.onDidChangeWindowFocus(hasFocus);
        if (this.container) {
            if (hasFocus) {
                this.container.classList.remove("inactive");
            } else {
                this.container.classList.add("inactive");
                this.menubar?.blur();
            }
        }
    }
    onUpdateStateChange() {
        if (!this.visible) {
            return;
        }
        super.onUpdateStateChange();
    }
    onDidChangeRecentlyOpened() {
        if (!this.visible) {
            return;
        }
        super.onDidChangeRecentlyOpened();
    }
    onUpdateKeybindings() {
        if (!this.visible) {
            return;
        }
        super.onUpdateKeybindings();
    }
    registerListeners() {
        super.registerListeners();
        this._register(addDisposableListener(mainWindow, EventType.RESIZE, () => {
            if (this.menubar && !(isIOS && BrowserFeatures.pointerEvents)) {
                this.menubar.blur();
            }
        }));
        if (isWeb) {
            this._register(onDidChangeFullscreen(windowId => {
                if (windowId === mainWindow.vscodeWindowId) {
                    this.updateMenubar();
                }
            }));
            this._register(this.webNavigationMenu.onDidChange(() => this.updateMenubar()));
            this._register(enableFocusMenuBarAction().event(() => this.menubar?.toggleFocus()));
        }
    }
    get onVisibilityChange() {
        return this._onVisibilityChange.event;
    }
    get onFocusStateChange() {
        return this._onFocusStateChange.event;
    }
    getMenubarItemsDimensions() {
        if (this.menubar) {
            return ( new Dimension(this.menubar.getWidth(), this.menubar.getHeight()));
        }
        return ( new Dimension(0, 0));
    }
    create(parent) {
        this.container = parent;
        if (this.container) {
            this.doUpdateMenubar(true);
        }
        return this.container;
    }
    layout(dimension) {
        this.menubar?.update(this.getMenuBarOptions());
    }
    toggleFocus() {
        this.menubar?.toggleFocus();
    }
};
CustomMenubarControl = ( __decorate([( __param(0, IMenuService)), ( __param(1, IWorkspacesService)), ( __param(2, IContextKeyService)), ( __param(3, IKeybindingService)), ( __param(4, IConfigurationService)), ( __param(5, ILabelService)), ( __param(6, IUpdateService)), ( __param(7, IStorageService)), ( __param(8, INotificationService)), ( __param(9, IPreferencesService)), ( __param(10, IWorkbenchEnvironmentService)), ( __param(11, IAccessibilityService)), ( __param(12, ITelemetryService)), ( __param(13, IHostService)), ( __param(14, ICommandService))], CustomMenubarControl));

export { CustomMenubarControl, MenubarControl };
