"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
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 (b.hasOwnProperty(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 __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var outputBase = require("@jupyter-widgets/output");
var widgets_1 = require("@phosphor/widgets");
var outputarea_1 = require("@jupyterlab/outputarea");
var $ = require("jquery");
require("../css/output.css");
var OutputModel = /** @class */ (function (_super) {
    __extends(OutputModel, _super);
    function OutputModel() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    OutputModel.prototype.defaults = function () {
        return __assign({}, _super.prototype.defaults.call(this), { msg_id: '' });
    };
    OutputModel.prototype.initialize = function (attributes, options) {
        _super.prototype.initialize.call(this, attributes, options);
        this._outputs = new outputarea_1.OutputAreaModel({
            values: attributes.outputs,
            // Widgets (including this output widget) are only rendered in
            // trusted contexts
            trusted: true,
        });
    };
    Object.defineProperty(OutputModel.prototype, "outputs", {
        get: function () {
            return this._outputs;
        },
        enumerable: true,
        configurable: true
    });
    return OutputModel;
}(outputBase.OutputModel));
exports.OutputModel = OutputModel;
var OutputView = /** @class */ (function (_super) {
    __extends(OutputView, _super);
    function OutputView() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    OutputView.prototype._createElement = function (tagName) {
        this.pWidget = new widgets_1.Panel();
        return this.pWidget.node;
    };
    OutputView.prototype._setElement = function (el) {
        if (this.el || el !== this.pWidget.node) {
            // Boxes don't allow setting the element beyond the initial creation.
            throw new Error('Cannot reset the DOM element.');
        }
        this.el = this.pWidget.node;
        this.$el = $(this.pWidget.node);
    };
    OutputView.prototype.render = function () {
        var manager = this.model.widget_manager;
        var rendermime = manager.renderMime;
        this._outputView = new outputarea_1.OutputArea({
            rendermime: rendermime,
            model: this.model.outputs
        });
        this.pWidget.insertWidget(0, this._outputView);
        this.pWidget.addClass('jupyter-widgets');
        this.pWidget.addClass('widget-output');
        this.update();
    };
    return OutputView;
}(outputBase.OutputView));
exports.OutputView = OutputView;
