"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MenubarsContributionPoint = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_components_1 = require("@opensumi/ide-components");
const next_1 = require("@opensumi/ide-core-browser/lib/menu/next");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const ide_theme_1 = require("@opensumi/ide-theme");
const common_1 = require("../../../common");
const types_1 = require("../../types");
let MenubarsContributionPoint = class MenubarsContributionPoint extends common_1.VSCodeContributePoint {
    contribute() {
        for (const contrib of this.contributesMap) {
            const { extensionId, contributes } = contrib;
            const extension = this.extensionManageService.getExtensionInstanceByExtId(extensionId);
            if (!extension) {
                continue;
            }
            for (const menubarItem of contributes) {
                const iconClass = extension.icon
                    ? this.iconService.fromIcon('', extension.icon, ide_theme_1.IconType.Background)
                    : (0, ide_components_1.getIcon)('default-menu-icon');
                this.addDispose(this.menuRegistry.registerMenubarItem(menubarItem.id, {
                    label: this.getLocalizeFromNlsJSON(menubarItem.title, extensionId),
                    order: menubarItem.order,
                    nativeRole: menubarItem.nativeRole,
                    iconClass,
                }));
            }
        }
    }
};
exports.MenubarsContributionPoint = MenubarsContributionPoint;
MenubarsContributionPoint.schema = {
    description: (0, ide_core_common_1.localize)('sumiContributes.menubars'),
    type: 'array',
    items: {
        type: 'object',
        required: ['id', 'title'],
        defaultSnippets: [
            {
                body: {
                    id: '${1}',
                    title: '${2}',
                },
            },
        ],
        properties: {
            id: {
                type: 'string',
                description: (0, ide_core_common_1.localize)('sumiContributes.menubars.id'),
            },
            title: {
                type: 'string',
                description: (0, ide_core_common_1.localize)('sumiContributes.menubars.title'),
            },
            order: {
                type: 'number',
                description: (0, ide_core_common_1.localize)('sumiContributes.menubars.order'),
            },
            nativeRole: {
                type: 'string',
                description: (0, ide_core_common_1.localize)('sumiContributes.menubars.order'),
            },
        },
    },
};
tslib_1.__decorate([
    (0, di_1.Autowired)(next_1.IMenuRegistry),
    tslib_1.__metadata("design:type", next_1.IMenuRegistry)
], MenubarsContributionPoint.prototype, "menuRegistry", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(types_1.AbstractExtInstanceManagementService),
    tslib_1.__metadata("design:type", types_1.AbstractExtInstanceManagementService)
], MenubarsContributionPoint.prototype, "extensionManageService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_theme_1.IIconService),
    tslib_1.__metadata("design:type", Object)
], MenubarsContributionPoint.prototype, "iconService", void 0);
exports.MenubarsContributionPoint = MenubarsContributionPoint = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    (0, common_1.Contributes)('menubars'),
    (0, common_1.LifeCycle)(3 /* LifeCyclePhase.Starting */)
], MenubarsContributionPoint);
//# sourceMappingURL=menubar.js.map