"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EditorSideBrowserContributionRunner = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const ide_editor_1 = require("@opensumi/ide-editor");
const browser_1 = require("@opensumi/ide-editor/lib/browser");
const workbench_editor_service_1 = require("@opensumi/ide-editor/lib/browser/workbench-editor.service");
const types_1 = require("../types");
let EditorSideBrowserContributionRunner = class EditorSideBrowserContributionRunner extends types_1.AbstractSumiBrowserContributionRunner {
    run(param) {
        const disposer = new ide_core_common_1.Disposable();
        const editorSide = this.contribution.editorSide;
        if (editorSide) {
            editorSide.view.forEach((component) => {
                disposer.addDispose(this.registerEditorSideComponent(component, param));
            });
        }
        return disposer;
    }
    registerEditorSideComponent(viewContribution, runParam) {
        const disposer = new ide_core_common_1.Disposable();
        const { extendProtocol, extendService } = runParam.getExtensionExtendService(this.extension, viewContribution.id);
        disposer.addDispose(this.editorComponentRegistry.registerEditorSideWidget({
            id: viewContribution.id,
            side: viewContribution.side,
            component: viewContribution.component,
            initialProps: {
                kaitianExtendService: extendService,
                kaitianExtendSet: extendProtocol,
                sumiExtendService: extendService,
                sumiExtendSet: extendProtocol,
            },
            displaysOnResource: () => this.editorService.editorContextKeyService.match(viewContribution === null || viewContribution === void 0 ? void 0 : viewContribution.when),
        }));
        return disposer;
    }
};
exports.EditorSideBrowserContributionRunner = EditorSideBrowserContributionRunner;
tslib_1.__decorate([
    (0, di_1.Autowired)(browser_1.EditorComponentRegistry),
    tslib_1.__metadata("design:type", browser_1.EditorComponentRegistry)
], EditorSideBrowserContributionRunner.prototype, "editorComponentRegistry", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_editor_1.WorkbenchEditorService),
    tslib_1.__metadata("design:type", workbench_editor_service_1.WorkbenchEditorServiceImpl)
], EditorSideBrowserContributionRunner.prototype, "editorService", void 0);
exports.EditorSideBrowserContributionRunner = EditorSideBrowserContributionRunner = tslib_1.__decorate([
    (0, di_1.Injectable)({ multiple: true })
], EditorSideBrowserContributionRunner);
//# sourceMappingURL=editorSide.js.map