"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatBrowserContributionRunner = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const types_1 = require("../types");
let ChatBrowserContributionRunner = class ChatBrowserContributionRunner extends types_1.AbstractSumiBrowserContributionRunner {
    run(param) {
        const disposer = new ide_core_common_1.Disposable();
        if (!this.injector.creatorMap.has(ide_core_common_1.ChatAgentViewServiceToken)) {
            this.logger.warn('Not found ChatAgentViewServiceToken');
            return disposer;
        }
        const { chat } = this.contribution;
        if (!chat || !Array.isArray(chat.view)) {
            return disposer;
        }
        chat.view.forEach((view) => {
            if (!view.id || !view.component) {
                return;
            }
            const { extendProtocol, extendService } = param.getExtensionExtendService(this.extension, view.id);
            const componentId = `${this.extension.id}:${view.id}`;
            disposer.addDispose(this.chatAgentViewService.registerChatComponent({
                id: componentId,
                component: view.component,
                initialProps: {
                    kaitianExtendService: extendService,
                    kaitianExtendSet: extendProtocol,
                    sumiExtendService: extendService,
                    sumiExtendSet: extendProtocol,
                },
            }));
        });
        return disposer;
    }
};
exports.ChatBrowserContributionRunner = ChatBrowserContributionRunner;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_common_1.ChatAgentViewServiceToken),
    tslib_1.__metadata("design:type", Object)
], ChatBrowserContributionRunner.prototype, "chatAgentViewService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_common_1.ILogger),
    tslib_1.__metadata("design:type", Object)
], ChatBrowserContributionRunner.prototype, "logger", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(di_1.INJECTOR_TOKEN),
    tslib_1.__metadata("design:type", di_1.Injector)
], ChatBrowserContributionRunner.prototype, "injector", void 0);
exports.ChatBrowserContributionRunner = ChatBrowserContributionRunner = tslib_1.__decorate([
    (0, di_1.Injectable)({ multiple: true })
], ChatBrowserContributionRunner);
//# sourceMappingURL=chat.js.map