
import { registerCss } from '../../../../../../../css.js';
import * as sidebarpart from './media/sidebarpart.css';
import { localize2 } from '../../../../nls.js';
import { registerAction2, Action2 } from '../../../../platform/actions/common/actions.js';
import { Parts } from '../../../services/layout/browser/layoutService.js';
import { IWorkbenchLayoutService } from '../../../services/layout/browser/layoutService.service.js';
import { KeyMod as KeyMod$1, KeyCode } from '../../../../base/common/keyCodes.js';
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
import { IPaneCompositePartService } from '../../../services/panecomposite/browser/panecomposite.service.js';
import { ViewContainerLocation } from '../../../common/views.js';
import { SideBarVisibleContext } from '../../../common/contextkeys.js';

registerCss(sidebarpart);
registerAction2(class extends Action2 {
    constructor() {
        super({
            id: "workbench.action.closeSidebar",
            title: ( localize2(3842, "Close Primary Side Bar")),
            category: Categories.View,
            f1: true,
            precondition: SideBarVisibleContext
        });
    }
    run(accessor) {
        accessor.get(IWorkbenchLayoutService).setPartHidden(true, Parts.SIDEBAR_PART);
    }
});
class FocusSideBarAction extends Action2 {
    constructor() {
        super({
            id: "workbench.action.focusSideBar",
            title: ( localize2(3843, "Focus into Primary Side Bar")),
            category: Categories.View,
            f1: true,
            keybinding: {
                weight: KeybindingWeight.WorkbenchContrib,
                when: null,
                primary: KeyMod$1.CtrlCmd | KeyCode.Digit0
            }
        });
    }
    async run(accessor) {
        const layoutService = accessor.get(IWorkbenchLayoutService);
        const paneCompositeService = accessor.get(IPaneCompositePartService);
        if (!layoutService.isVisible(Parts.SIDEBAR_PART)) {
            layoutService.setPartHidden(false, Parts.SIDEBAR_PART);
        }
        const viewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
        viewlet?.focus();
    }
}
registerAction2(FocusSideBarAction);

export { FocusSideBarAction };
