"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionsContributionPoint = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const toolbar_action_service_1 = require("@opensumi/ide-core-browser/lib/menu/next/toolbar-action.service");
const common_1 = require("../../../common");
let ActionsContributionPoint = class ActionsContributionPoint extends common_1.VSCodeContributePoint {
    contribute() {
        const _this = this;
        for (const contrib of this.contributesMap) {
            const { extensionId, contributes } = contrib;
            const actions = [];
            for (const item of contributes) {
                const { title, description } = item;
                switch (item.type) {
                    case 'action':
                        actions.push({
                            title,
                            description,
                            iconClass: (0, ide_core_browser_1.getIcon)(item.icon),
                            click: () => {
                                if (item.command) {
                                    _this.commandService.executeCommand(item.command);
                                }
                            },
                            type: item.type,
                        });
                        break;
                    case 'enum':
                        actions.push({
                            type: item.type,
                            title,
                            description,
                            select: (value) => {
                                if (item.command) {
                                    _this.commandService.executeCommand(item.command, value);
                                }
                            },
                            enum: item.enum,
                            defaultValue: item.defaultValue,
                        });
                        break;
                }
            }
            this.addDispose(this.toolbarActionService.registryActionGroup(extensionId, actions));
        }
    }
    // TODO: dispose
    dispose() {
        super.dispose();
    }
};
exports.ActionsContributionPoint = ActionsContributionPoint;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.CommandService),
    tslib_1.__metadata("design:type", Object)
], ActionsContributionPoint.prototype, "commandService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(toolbar_action_service_1.IToolbarActionService),
    tslib_1.__metadata("design:type", Object)
], ActionsContributionPoint.prototype, "toolbarActionService", void 0);
exports.ActionsContributionPoint = ActionsContributionPoint = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    (0, common_1.Contributes)('actions'),
    (0, common_1.LifeCycle)(3 /* LifeCyclePhase.Starting */)
], ActionsContributionPoint);
//# sourceMappingURL=actions.js.map