"use strict";
var __extends = (this && this.__extends) || (function () {
    var 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 function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var dashboardSection_1 = require("./dashboardSection");
var dashboardFilters_1 = require("../filters/dashboardFilters");
var Dashboard = /** @class */ (function (_super) {
    __extends(Dashboard, _super);
    function Dashboard() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    /**
     *  Render method
     */
    Dashboard.prototype.render = function () {
        var sectionRows = [];
        var sectionRow = [];
        var colInd = 0;
        for (var i = 0; i < this.props.sections.length; i++) {
            if (colInd < this.props.size) {
                if (colInd + this.props.sections[i].cols > this.props.size) {
                    colInd = this.props.size;
                    i--;
                }
                else {
                    sectionRow.push(this.props.sections[i]);
                    colInd += this.props.sections[i].cols;
                }
                if (colInd >= this.props.size || i === this.props.sections.length - 1) {
                    colInd = 0;
                    sectionRows.push({ SectionRow: sectionRow });
                    sectionRow = [];
                }
            }
        }
        return React.createElement("div", null,
            React.createElement("p", { style: { margin: '5px 2px', fontWeight: 400, fontSize: '1.2rem' } }, this.props.name),
            React.createElement(dashboardFilters_1.DashboardFilter, { filters: this.props.filters }),
            React.createElement("table", { style: { width: '100%', tableLayout: 'fixed' } }, sectionRows.map(function (cr) {
                return React.createElement("tr", null, cr.SectionRow.map(function (c) {
                    return React.createElement("td", { colSpan: c.cols },
                        React.createElement(dashboardSection_1.DashboardSection, { id: c.id }));
                }));
            })));
    };
    return Dashboard;
}(React.Component));
exports.Dashboard = Dashboard;
exports.default = Dashboard;
