"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainThreadWebviewView = exports.MainThreadWebview = void 0;
const tslib_1 = require("tslib");
const throttle_1 = tslib_1.__importDefault(require("lodash/throttle"));
const di_1 = require("@opensumi/di");
const ide_connection_1 = require("@opensumi/ide-connection");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const command_opener_1 = require("@opensumi/ide-core-browser/lib/opener/command-opener");
const http_opener_1 = require("@opensumi/ide-core-browser/lib/opener/http-opener");
const static_resource_1 = require("@opensumi/ide-core-browser/lib/static-resource");
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 ide_main_layout_1 = require("@opensumi/ide-main-layout");
const ide_theme_1 = require("@opensumi/ide-theme");
const ide_webview_1 = require("@opensumi/ide-webview");
const vscode_1 = require("../../../common/vscode");
const converter_1 = require("../../../common/vscode/converter");
const extension_webview_view_1 = require("../../components/extension-webview-view");
const types_1 = require("../../types");
const { addMapElement } = ide_core_browser_1.arrays;
let MainThreadWebview = class MainThreadWebview extends ide_core_browser_1.Disposable {
    constructor(rpcProtocol) {
        super();
        this.rpcProtocol = rpcProtocol;
        this.webviewPanels = new Map();
        this.webviews = new Map();
        this.plainWebviews = new Map();
        this.webviewPanelStates = new Map();
        this._hasSerializer = new Set();
        this.statePersister = new Map();
        this.proxy = this.rpcProtocol.getProxy(vscode_1.ExtHostAPIIdentifier.ExtHostWebview);
        this.sumiProxy = this.rpcProtocol.getProxy(vscode_1.ExtHostAPIIdentifier.SumiExtHostWebview);
        this.initEvents();
        this.extWebviewStorage = this.getStorage(new ide_core_browser_1.URI('extension-webview-panels').withScheme(ide_core_browser_1.STORAGE_SCHEMA.SCOPE));
        this.webviewService.registerWebviewReviver({
            revive: (id) => this.reviveWebview(id),
            handles: async (id) => {
                const persistedWebviewPanelMeta = (await this.extWebviewStorage).get(id);
                if (persistedWebviewPanelMeta) {
                    return 10;
                }
                else {
                    return -1;
                }
            },
        });
    }
    async init() {
        await this.proxy.$init();
    }
    isSupportedLink(uri, options, extension) {
        if (http_opener_1.HttpOpener.standardSupportedLinkSchemes.has(uri.scheme)) {
            return true;
        }
        // webview 支持打开 command 协议
        if (!!options.enableCommandUris && uri.scheme === ide_core_browser_1.Schemes.command) {
            // 从 webview 过来的 command 也要做安全校验
            const { id, args } = command_opener_1.CommandOpener.parseURI(uri);
            const isPermitted = this.commandRegistry.isPermittedCommand(id, extension, ...args);
            if (!isPermitted) {
                throw new Error(`Extension ${extension.id} has not permit to execute ${id}`);
            }
            return true;
        }
        return false;
    }
    initEvents() {
        this.addDispose(this.editorService.onActiveResourceChange(() => {
            this.onChange();
        }));
        this.addDispose(this.eventBus.on(browser_1.EditorGroupChangeEvent, () => {
            this.onChange();
        }));
    }
    isActive(webviewPanel, resource, openType) {
        return (webviewPanel.resourceState.uri.isEqual(resource === null || resource === void 0 ? void 0 : resource.uri) &&
            webviewPanel.resourceState.openTypeId === (openType === null || openType === void 0 ? void 0 : openType.componentId));
    }
    onChange() {
        const currentResource = this.editorService.currentResource;
        const currentOpenType = this.editorService.currentEditorGroup.currentOpenType;
        const visibleResources = this.editorService.editorGroups.map((g) => ({
            resource: g.currentResource,
            openType: g.currentOpenType,
            index: g.index + 1,
        }));
        this.webviewPanelStates.forEach((state, id) => {
            if (!this.hasWebviewPanel(id)) {
                return;
            }
            let hasChange = false;
            const webviewPanel = this.getWebviewPanel(id);
            if (state.active) {
                if (!currentResource || !this.isActive(webviewPanel, currentResource, currentOpenType)) {
                    state.active = false;
                    hasChange = true;
                }
            }
            else {
                if (currentResource && this.isActive(webviewPanel, currentResource, currentOpenType)) {
                    state.active = true;
                    hasChange = true;
                }
            }
            if (state.visible) {
                const exist = visibleResources.find((r) => r.resource && this.isActive(webviewPanel, r.resource, r.openType));
                if (!exist) {
                    state.visible = false;
                    state.position = -1;
                    hasChange = true;
                }
                else {
                    if (exist.index !== state.position) {
                        state.position = exist.index;
                        hasChange = true;
                    }
                }
            }
            else {
                const exist = visibleResources.find((r) => r.resource && this.isActive(webviewPanel, r.resource, r.openType));
                if (exist) {
                    state.visible = true;
                    state.position = exist.index;
                    hasChange = true;
                }
            }
            if (hasChange) {
                this.proxy.$onDidChangeWebviewPanelViewState(id, state);
                if (state.position !== this.getWebviewPanel(id).viewColumn) {
                    this.getWebviewPanel(id).viewColumn = state.position;
                    this._persistWebviewPanelMeta(id);
                }
            }
        });
    }
    $createWebviewPanel(id, viewType, title, showOptions = {}, options = {}, extension) {
        this.doCreateWebviewPanel(id, viewType, title, showOptions, options, extension);
    }
    pipeBrowserHostedWebviewPanel(webview, resourceState, viewType, options, extension) {
        const id = webview.id;
        const webviewPanel = new WebviewPanel(id, viewType, resourceState, {}, {}, extension, webview);
        this.onCreateWebviewPanel(webviewPanel);
        this.proxy.$pipeBrowserHostedWebviewPanel(id, viewType);
    }
    async reviveWebview(id) {
        var _a;
        const persistedWebviewPanelMeta = (await this.extWebviewStorage).get(id);
        if (!persistedWebviewPanelMeta) {
            throw new Error('No revival info for webview ' + id);
        }
        const { viewType, webviewOptions, extensionInfo, title } = persistedWebviewPanelMeta;
        await this.activation.fireEvent('onWebviewPanel', viewType);
        const state = await this.getPersistedWebviewState(viewType, id);
        const editorWebview = this.webviewService.createEditorWebviewComponent({
            allowScripts: webviewOptions.enableScripts,
            allowForms: (_a = webviewOptions.enableForms) !== null && _a !== void 0 ? _a : webviewOptions.enableScripts,
            longLive: webviewOptions.retainContextWhenHidden,
        }, id, {
            extWebview: viewType,
        });
        const viewColumn = editorWebview.group ? editorWebview.group.index + 1 : persistedWebviewPanelMeta.viewColumn;
        await this.doCreateWebviewPanel(id, viewType, title, { viewColumn }, webviewOptions, extensionInfo, state);
        await this.proxy.$deserializeWebviewPanel(id, viewType, title, await this.getPersistedWebviewState(viewType, id), viewColumn, webviewOptions);
    }
    onCreateWebviewPanel(webviewPanel) {
        this.webviewPanels.set(webviewPanel.id, webviewPanel);
        const webview = webviewPanel.webview;
        const id = webviewPanel.id;
        if (webviewPanel.editorWebview) {
            webviewPanel.addDispose(webviewPanel.editorWebview);
        }
        webviewPanel.addDispose(this.connectWebview(webviewPanel.id, webviewPanel.webview));
        webviewPanel.addDispose(webview.onRemove(() => {
            webview.dispose();
            this.proxy.$onDidDisposeWebviewPanel(id);
        }));
        this.webviewPanelStates.set(webviewPanel.id, {
            active: false,
            visible: false,
            position: -1,
        });
        this.addDispose({
            dispose: () => {
                if (this.webviewPanels.has(id)) {
                    this.getWebviewPanel(id).dispose();
                }
            },
        });
        webview.onDidClickLink((e) => {
            if (this.isSupportedLink(e, webviewPanel.options, webviewPanel.extensionInfo)) {
                this.openerService.open(e);
            }
        });
        this.addDispose(webview.onDidUpdateState((state) => {
            if (this._hasSerializer.has(webviewPanel.viewType)) {
                this.persistWebviewState(webviewPanel.viewType, id, state);
            }
        }));
        this._persistWebviewPanelMeta(id);
    }
    async doCreateWebviewPanel(id, viewType, title, showOptions = {}, options = {}, extension, initialState) {
        var _a;
        const editorWebview = this.webviewService.createEditorWebviewComponent({
            allowScripts: options.enableScripts,
            allowForms: (_a = options.enableForms) !== null && _a !== void 0 ? _a : options.enableScripts,
            longLive: options.retainContextWhenHidden,
        }, id, {
            extWebview: viewType,
        });
        const webviewPanel = new WebviewPanel(id, viewType, {
            uri: editorWebview.webviewUri,
            openTypeId: editorWebview.componentId,
        }, showOptions, options, extension, editorWebview.webview, editorWebview);
        editorWebview.title = title;
        this.onCreateWebviewPanel(webviewPanel);
        editorWebview.supportsRevive = this._hasSerializer.has(webviewPanel.viewType);
        const editorOpenOptions = (0, converter_1.viewColumnToResourceOpenOptions)(showOptions.viewColumn);
        editorWebview.open(editorOpenOptions);
        if (initialState) {
            webviewPanel.webview.state = initialState;
        }
    }
    getWebviewPanel(id) {
        if (!this.webviewPanels.has(id)) {
            throw new Error(`No Webview with id: ${id} was found in the browser process.`);
        }
        return this.webviewPanels.get(id);
    }
    hasWebviewPanel(id) {
        return this.webviewPanels.has(id);
    }
    $disposeWebview(id) {
        const webviewPanel = this.getWebviewPanel(id);
        webviewPanel.dispose();
        this.webviewPanels.delete(id);
        this._persistWebviewPanelMeta(id);
    }
    $reveal(id, showOptions = {}) {
        var _a;
        const webviewPanel = this.getWebviewPanel(id);
        const viewColumn = Object.assign({}, webviewPanel.showOptions, showOptions).viewColumn;
        (_a = webviewPanel.editorWebview) === null || _a === void 0 ? void 0 : _a.open((0, converter_1.viewColumnToResourceOpenOptions)(viewColumn));
    }
    $setTitle(id, value) {
        const webviewPanel = this.getWebviewPanel(id);
        if (!webviewPanel.editorWebview) {
            return;
        }
        webviewPanel.editorWebview.title = value;
        webviewPanel.title = value;
        this._persistWebviewPanelMeta(id);
    }
    $setIconPath(id, value) {
        const webviewPanel = this.getWebviewPanel(id);
        if (!webviewPanel.editorWebview) {
            return;
        }
        if (!value) {
            webviewPanel.editorWebview.icon = '';
        }
        else {
            webviewPanel.editorWebview.icon =
                this.iconService.fromIcon('', value, ide_theme_1.IconType.Background) + ' background-tab-icon';
        }
    }
    connectWebview(id, webview) {
        this.webviews.set(id, webview);
        const disposable = new ide_core_browser_1.Disposable();
        disposable.addDispose(webview.onMessage((message) => {
            this.proxy.$onMessage(id, message);
        }));
        disposable.addDispose(addMapElement(this.webviews, id, webview));
        webview.onDispose(() => {
            disposable.dispose();
        });
        return disposable;
    }
    getWebview(id) {
        return this.webviews.get(id);
    }
    $setHtml(id, value) {
        var _a;
        (_a = this.getWebview(id)) === null || _a === void 0 ? void 0 : _a.setContent(value);
    }
    $setOptions(id, options) {
        var _a;
        (_a = this.getWebview(id)) === null || _a === void 0 ? void 0 : _a.updateOptions({ allowScripts: options.enableScripts, allowForms: options.enableForms });
    }
    async $postMessage(id, value) {
        var _a;
        try {
            await ((_a = this.getWebview(id)) === null || _a === void 0 ? void 0 : _a.postMessage(value));
            return true;
        }
        catch (e) {
            return false;
        }
    }
    $registerSerializer(viewType) {
        this._hasSerializer.add(viewType);
        this.webviewPanels.forEach((panel) => {
            if (panel.viewType === viewType) {
                if (panel.editorWebview) {
                    panel.editorWebview.supportsRevive = true;
                }
            }
        });
    }
    $unregisterSerializer(viewType) {
        this._hasSerializer.add(viewType);
    }
    _persistWebviewPanelMeta(id) {
        return this.extWebviewStorage.then((storage) => {
            if (this.webviewPanels.has(id)) {
                storage.set(id, this.getWebviewPanel(id).toJSON());
            }
            else {
                storage.delete(id);
            }
        });
    }
    async persistWebviewState(viewType, id, state) {
        if (!this.statePersister.has(viewType)) {
            this.statePersister.set(viewType, this.getStorage(new ide_core_browser_1.URI('extension-webview/' + viewType).withScheme(ide_core_browser_1.STORAGE_SCHEMA.SCOPE)).then((storage) => {
                const func = (0, throttle_1.default)((state) => storage.set(id, state), 500);
                return async (state) => {
                    await func(state);
                };
            }));
        }
        (await this.statePersister.get(viewType))(state);
    }
    async getPersistedWebviewState(viewType, id) {
        const storage = await this.getStorage(new ide_core_browser_1.URI('extension-webview/' + viewType).withScheme(ide_core_browser_1.STORAGE_SCHEMA.SCOPE));
        return storage.get(id);
    }
    $connectPlainWebview(id) {
        if (!this.plainWebviews.has(id)) {
            const handle = this.webviewService.getEditorPlainWebviewComponent(id) ||
                this.webviewService.getOrCreatePlainWebviewComponent(id);
            if (handle) {
                this.plainWebviews.set(id, handle);
                handle.webview.onMessage((message) => {
                    this.sumiProxy.$acceptMessage(id, message);
                });
                handle.webview.onDispose(() => {
                    this.plainWebviews.delete(id);
                });
            }
        }
    }
    async $postMessageToPlainWebview(id, value) {
        if (this.plainWebviews.has(id)) {
            try {
                await this.plainWebviews.get(id).webview.postMessage(value);
                return true;
            }
            catch (e) {
                this.logger.error(e);
                return false;
            }
        }
        return false;
    }
    async $createPlainWebview(id, title, iconPath) {
        const webviewComponent = this.webviewService.createEditorPlainWebviewComponent({}, id);
        webviewComponent.title = title;
        if (iconPath) {
            webviewComponent.icon = this.iconService.fromIcon('', iconPath) || '';
        }
        this.$connectPlainWebview(id);
    }
    async $plainWebviewLoadUrl(id, uri) {
        if (!this.plainWebviews.has(id)) {
            throw new Error('No Plain Webview With id ' + id);
        }
        await this.plainWebviews.get(id).webview.loadURL(uri);
    }
    /**
     * A string that sets the session used by the page.
     *
     * fallback to a generated id.
     */
    async $setPlainWebviewPartition(id, value) {
        if (!this.plainWebviews.has(id)) {
            throw new Error('No Plain Webview With id ' + id);
        }
        const webview = this.plainWebviews.get(id).webview;
        webview.setPartition(value !== null && value !== void 0 ? value : id);
    }
    async $disposePlainWebview(id) {
        var _a;
        if (this.plainWebviews.has(id)) {
            (_a = this.plainWebviews.get(id)) === null || _a === void 0 ? void 0 : _a.dispose();
        }
    }
    async $revealPlainWebview(id, groupIndex) {
        if (!this.plainWebviews.has(id)) {
            throw new Error('No Plain Webview With id ' + id);
        }
        const handle = this.plainWebviews.get(id);
        if (!handle.open) {
            throw new Error('not able to open plain webview id:' + id);
        }
        await handle.open({ groupIndex });
    }
    async $getWebviewResourceRoots() {
        return Array.from(this.staticResourceService.resourceRoots);
    }
};
exports.MainThreadWebview = MainThreadWebview;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_webview_1.IWebviewService),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebview.prototype, "webviewService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(types_1.IActivationEventService),
    tslib_1.__metadata("design:type", types_1.IActivationEventService)
], MainThreadWebview.prototype, "activation", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.StorageProvider),
    tslib_1.__metadata("design:type", Function)
], MainThreadWebview.prototype, "getStorage", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(),
    tslib_1.__metadata("design:type", ide_editor_1.WorkbenchEditorService)
], MainThreadWebview.prototype, "editorService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_theme_1.IIconService),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebview.prototype, "iconService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.IEventBus),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebview.prototype, "eventBus", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.ILogger),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebview.prototype, "logger", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(static_resource_1.StaticResourceService),
    tslib_1.__metadata("design:type", static_resource_1.StaticResourceService)
], MainThreadWebview.prototype, "staticResourceService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.IOpenerService),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebview.prototype, "openerService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.CommandRegistry),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebview.prototype, "commandRegistry", void 0);
exports.MainThreadWebview = MainThreadWebview = tslib_1.__decorate([
    (0, di_1.Injectable)({ multiple: true }),
    tslib_1.__param(0, (0, di_1.Optional)(Symbol())),
    tslib_1.__metadata("design:paramtypes", [Object])
], MainThreadWebview);
class WebviewPanel extends ide_core_browser_1.Disposable {
    constructor(id, viewType, resourceState, showOptions, options, extensionInfo, webview, editorWebview) {
        super();
        this.id = id;
        this.viewType = viewType;
        this.resourceState = resourceState;
        this.showOptions = showOptions;
        this.options = options;
        this.extensionInfo = extensionInfo;
        this.webview = webview;
        this.editorWebview = editorWebview;
    }
    toJSON() {
        return {
            id: this.id,
            viewType: this.viewType,
            viewColumn: this.viewColumn,
            extensionInfo: this.extensionInfo,
            webviewOptions: this.options,
            title: this.title,
        };
    }
}
class WebviewView extends ide_core_browser_1.Disposable {
    constructor(id, viewType, extension, webview) {
        super();
        this.id = id;
        this.viewType = viewType;
        this.extension = extension;
        this.webview = webview;
    }
}
let MainThreadWebviewView = class MainThreadWebviewView extends ide_core_common_1.WithEventBus {
    constructor(rpcProtocol, mainThreadWebview) {
        super();
        this.mainThreadWebview = mainThreadWebview;
        this._webviewViews = new Map();
        this._resolvers = new Map();
        this.proxy = rpcProtocol.getProxy(vscode_1.ExtHostAPIIdentifier.ExtHostWebviewView);
    }
    $registerWebviewViewProvider(extension, viewType, options = {}) {
        this._resolvers.set(viewType, {
            extension,
            options,
        });
        this.eventBus.fire(new vscode_1.WebviewViewResolverRegistrationEvent({
            viewType,
            options,
        }));
    }
    $unregisterWebviewViewProvider(viewType) {
        this._resolvers.delete(viewType);
        this.eventBus.fire(new vscode_1.WebviewViewResolverRegistrationRemovalEvent({
            viewType,
        }));
    }
    $setWebviewViewTitle(handle, value) {
        var _a;
        const webviewView = this._webviewViews.get(handle);
        if (webviewView) {
            (_a = this.mainLayout.getTabbarHandler(webviewView.viewType)) === null || _a === void 0 ? void 0 : _a.updateViewTitle(webviewView.viewType, value || '');
        }
    }
    $setWebviewViewDescription(handle, value) {
        const webviewView = this._webviewViews.get(handle);
        if (webviewView) {
        }
    }
    onWebviewViewShouldShow(e) {
        const viewType = e.payload.viewType;
        if (this._resolvers.has(viewType)) {
            e.payload.disposer.addDispose(this.resolveWebviewView(e.payload.container, viewType, e.payload.title, e.payload.cancellationToken));
        }
        else {
            // 等待注册完成
            this.addDispose(this.eventBus.on(vscode_1.WebviewViewResolverRegistrationEvent, (re) => {
                if (re.payload.viewType === viewType && this._resolvers.has(viewType)) {
                    e.payload.disposer.addDispose(this.resolveWebviewView(e.payload.container, viewType, e.payload.title, e.payload.cancellationToken));
                }
            }));
        }
    }
    resolveWebviewView(container, viewType, title, cancellationToken) {
        var _a;
        const disposer = new ide_core_browser_1.Disposable();
        const webview = this.webviewService.createWebview();
        const options = (_a = this._resolvers.get(viewType)) === null || _a === void 0 ? void 0 : _a.options;
        const extension = this._resolvers.get(viewType).extension;
        const id = webview.id;
        const webviewView = new WebviewView(id, viewType, extension, webview);
        webviewView.addDispose(this.mainThreadWebview.connectWebview(id, webview));
        webviewView.addDispose(addMapElement(this._webviewViews, id, webviewView));
        webviewView.addDispose(webview);
        // 如果当前 view container 变化时触发 webview 的显隐
        const changeWebviewViewVisibility = () => {
            const isVisible = this.mainLayout.isViewVisible(viewType);
            this.proxy.$onDidChangeWebviewViewVisibility(id, isVisible);
            if (!(options === null || options === void 0 ? void 0 : options.retainContextWhenHidden)) {
                if (isVisible) {
                    webview.appendTo(container);
                    webviewView.addDispose(this.mainThreadWebview.connectWebview(id, webview));
                }
                else {
                    webview.remove();
                }
            }
        };
        disposer.addDispose(this.eventBus.on(ide_main_layout_1.ViewCollapseChangedEvent, (e) => {
            if (e.payload.viewId === viewType) {
                changeWebviewViewVisibility();
            }
        }));
        const tabbarHandler = this.mainLayout.getTabbarHandler(viewType);
        if (tabbarHandler) {
            disposer.addDispose(tabbarHandler === null || tabbarHandler === void 0 ? void 0 : tabbarHandler.onActivate(() => {
                changeWebviewViewVisibility();
            }));
            disposer.addDispose(tabbarHandler === null || tabbarHandler === void 0 ? void 0 : tabbarHandler.onInActivate(() => {
                changeWebviewViewVisibility();
            }));
        }
        this.proxy.$resolveWebviewView(id, viewType, title, webview.state, cancellationToken);
        const isVisible = this.mainLayout.isViewVisible(viewType);
        this.proxy.$onDidChangeWebviewViewVisibility(id, isVisible);
        if ((options === null || options === void 0 ? void 0 : options.retainContextWhenHidden) || isVisible) {
            webview.appendTo(container);
        }
        disposer.addDispose(webviewView);
        return {
            dispose: () => webviewView.dispose(),
        };
    }
    $setBadge(handle, badge) {
        const webviewView = this._webviewViews.get(handle);
        if (webviewView) {
            webviewView.badge = badge;
            const handler = this.mainLayout.getTabbarHandler(webviewView.viewType);
            if (handler) {
                handler.setBadge(badge ? badge : '');
                handler.accordionService.updateViewBadge(webviewView.viewType, badge ? badge : '');
            }
        }
    }
    $show(handle, preserveFocus) {
        const webviewView = this._webviewViews.get(handle);
        if (webviewView) {
            this.mainLayout.revealView(webviewView.viewType);
        }
    }
};
exports.MainThreadWebviewView = MainThreadWebviewView;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_main_layout_1.IMainLayoutService),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebviewView.prototype, "mainLayout", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_webview_1.IWebviewService),
    tslib_1.__metadata("design:type", Object)
], MainThreadWebviewView.prototype, "webviewService", void 0);
tslib_1.__decorate([
    (0, ide_core_common_1.OnEvent)(extension_webview_view_1.WebviewViewShouldShowEvent),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [extension_webview_view_1.WebviewViewShouldShowEvent]),
    tslib_1.__metadata("design:returntype", void 0)
], MainThreadWebviewView.prototype, "onWebviewViewShouldShow", null);
exports.MainThreadWebviewView = MainThreadWebviewView = tslib_1.__decorate([
    (0, di_1.Injectable)({ multiple: true }),
    tslib_1.__metadata("design:paramtypes", [Object, MainThreadWebview])
], MainThreadWebviewView);
//# sourceMappingURL=main.thread.api.webview.js.map