"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerConsoleViewContribution = exports.ServerConsole = exports.SERVER_CONSOLE_WIDGET_ICON = exports.SERVER_CONSOLE_WIDGET_ID = void 0;
var inversify_1 = require("inversify");
var base_console_1 = require("./base-console");
var browser_1 = require("@theia/core/lib/browser");
var fxdk_data_service_1 = require("fxdk-services/lib/browser/fxdk-data-service");
exports.SERVER_CONSOLE_WIDGET_ID = 'fxdk-server-console';
exports.SERVER_CONSOLE_WIDGET_ICON = 'fa fa-terminal';
var ServerConsole = /** @class */ (function (_super) {
    __extends(ServerConsole, _super);
    function ServerConsole() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ServerConsole.prototype.setup = function () {
        var _this = this;
        this.id = exports.SERVER_CONSOLE_WIDGET_ID;
        this.title.caption = 'Server console';
        this.title.label = 'Server console';
        this.title.iconClass = 'fa fa-terminal';
        this.title.closable = true;
        this.toDispose.push(this.dataService.onBufferedServerOutputChanged(function () { return _this.setBufferedOutput(_this.dataService.getBufferedServerOutput()); }));
        this.toDispose.push(this.dataService.onStructuredServerMessageReceived(function (message) { return _this.receiveStructuredMessage(message); }));
        this.toDispose.push(this.dataService.onClearAllServerOutputs(function () { return _this.clear(); }));
    };
    ServerConsole.prototype.initilizeConsole = function () {
        var _this = this;
        this.setBufferedOutput(this.dataService.getBufferedServerOutput());
        this.dataService.getStructuredServerMessages().forEach(function (message) { return _this.receiveStructuredMessage(message); });
    };
    ServerConsole.prototype.handleCommand = function (command) {
        this.dataService.sendMessageToShell('server:sendCommand', command);
    };
    __decorate([
        inversify_1.inject(fxdk_data_service_1.FxdkDataService),
        __metadata("design:type", fxdk_data_service_1.FxdkDataService)
    ], ServerConsole.prototype, "dataService", void 0);
    ServerConsole = __decorate([
        inversify_1.injectable()
    ], ServerConsole);
    return ServerConsole;
}(base_console_1.BaseConsole));
exports.ServerConsole = ServerConsole;
var ServerConsoleViewContribution = /** @class */ (function (_super) {
    __extends(ServerConsoleViewContribution, _super);
    function ServerConsoleViewContribution() {
        return _super.call(this, {
            widgetId: exports.SERVER_CONSOLE_WIDGET_ID,
            widgetName: 'Server console',
            toggleCommandId: ServerConsoleViewContribution_1.TOGGLE_COMMAND_ID,
            defaultWidgetOptions: {
                area: 'bottom',
            }
        }) || this;
    }
    ServerConsoleViewContribution_1 = ServerConsoleViewContribution;
    var ServerConsoleViewContribution_1;
    ServerConsoleViewContribution.TOGGLE_COMMAND_ID = 'Z_fxdkServerConsole:toggle';
    ServerConsoleViewContribution = ServerConsoleViewContribution_1 = __decorate([
        inversify_1.injectable(),
        __metadata("design:paramtypes", [])
    ], ServerConsoleViewContribution);
    return ServerConsoleViewContribution;
}(browser_1.AbstractViewContribution));
exports.ServerConsoleViewContribution = ServerConsoleViewContribution;
//# sourceMappingURL=server-console.js.map