"use strict";
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);
};
var core_1 = require("@angular/core");
var lodash_1 = require("lodash");
var typescript_angular_utilities_1 = require("typescript-angular-utilities");
var __string = typescript_angular_utilities_1.services.string;
var __object = typescript_angular_utilities_1.services.object;
var breakpoint_1 = require("../../../../services/breakpoints/breakpoint");
var SizeForBreakpoints = (function () {
    function SizeForBreakpoints(stringUtility, objectUtility) {
        this.stringUtility = stringUtility;
        this.objectUtility = objectUtility;
    }
    SizeForBreakpoints.prototype.getClass = function (sizes, styling) {
        sizes = this.buildSizes(sizes);
        var classes = [];
        classes.push(this.getColumnClass(sizes, breakpoint_1.xs));
        classes.push(this.getColumnClass(sizes, breakpoint_1.sm));
        classes.push(this.getColumnClass(sizes, breakpoint_1.md));
        classes.push(this.getColumnClass(sizes, breakpoint_1.lg));
        return classes.join(' ') + ' ' + styling;
    };
    SizeForBreakpoints.prototype.buildSizes = function (sizes) {
        // mutates the original size. If necessary, we could clone here
        if (lodash_1.isObject(sizes)) {
            sizes[breakpoint_1.xs] = this.objectUtility.valueOrDefault(sizes[breakpoint_1.xs], 0);
            sizes[breakpoint_1.sm] = this.objectUtility.valueOrDefault(sizes[breakpoint_1.sm], sizes[breakpoint_1.xs]);
            sizes[breakpoint_1.md] = this.objectUtility.valueOrDefault(sizes[breakpoint_1.md], sizes[breakpoint_1.sm]);
            sizes[breakpoint_1.lg] = this.objectUtility.valueOrDefault(sizes[breakpoint_1.lg], sizes[breakpoint_1.md]);
        }
        else {
            sizes = {
                xs: sizes,
                sm: sizes,
                md: sizes,
                lg: sizes,
            };
        }
        return sizes;
    };
    SizeForBreakpoints.prototype.getColumnClass = function (columnSizes, attribute) {
        var value = columnSizes[attribute];
        if (value > 0 && value !== 'hidden') {
            return this.stringUtility.substitute('col-{0}-{1}', attribute, value);
        }
        else {
            return 'hidden-' + attribute;
        }
    };
    return SizeForBreakpoints;
}());
SizeForBreakpoints = __decorate([
    core_1.Injectable(),
    __metadata("design:paramtypes", [__string.StringUtility, __object.ObjectUtility])
], SizeForBreakpoints);
exports.SizeForBreakpoints = SizeForBreakpoints;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2l6ZUZvckJyZWFrcG9pbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsic2l6ZUZvckJyZWFrcG9pbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSxzQ0FBMkM7QUFDM0MsaUNBQWtDO0FBRWxDLDZFQUF3RDtBQUN4RCxJQUFPLFFBQVEsR0FBRyx1Q0FBUSxDQUFDLE1BQU0sQ0FBQztBQUNsQyxJQUFPLFFBQVEsR0FBRyx1Q0FBUSxDQUFDLE1BQU0sQ0FBQztBQUVsQywwRUFBNkU7QUFJN0UsSUFBYSxrQkFBa0I7SUFJOUIsNEJBQVksYUFBcUMsRUFDN0MsYUFBcUM7UUFDeEMsSUFBSSxDQUFDLGFBQWEsR0FBRyxhQUFhLENBQUM7UUFDbkMsSUFBSSxDQUFDLGFBQWEsR0FBRyxhQUFhLENBQUM7SUFDcEMsQ0FBQztJQUVELHFDQUFRLEdBQVIsVUFBUyxLQUErQixFQUFFLE9BQWU7UUFDeEQsS0FBSyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDL0IsSUFBSSxPQU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