import * as tslib_1 from "tslib";
import { Directive, Input, ElementRef, HostBinding, Renderer2, Host, Optional } from '@angular/core';
import { NbRowDirective } from './row.directive';
var EmbeddedProperty = /** @class */ (function () {
    function EmbeddedProperty() {
    }
    return EmbeddedProperty;
}());
export { EmbeddedProperty };
var NbColDirective = /** @class */ (function () {
    function NbColDirective(_elementRef, _nbRow, _renderer) {
        this._elementRef = _elementRef;
        this._nbRow = _nbRow;
        this._renderer = _renderer;
        this._classList = [];
        this._prefixCls = 'nb-col';
        this._el = this._elementRef.nativeElement;
    }
    Object.defineProperty(NbColDirective.prototype, "paddingLeft", {
        get: function () {
            return this._nbRow && this._nbRow._gutter / 2;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NbColDirective.prototype, "paddingRight", {
        get: function () {
            return this._nbRow && this._nbRow._gutter / 2;
        },
        enumerable: true,
        configurable: true
    });
    /** temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289*/
    NbColDirective.prototype.setClassMap = function () {
        var _this = this;
        this._classList.forEach(function (_className) {
            _this._renderer.removeClass(_this._el, _className);
        });
        this._classList = [
            this.nbSpan && this._prefixCls + "-" + this.nbSpan,
            this.nbOrder && this._prefixCls + "-order-" + this.nbOrder,
            this.nbOffset && this._prefixCls + "-offset-" + this.nbOffset,
            this.nbPull && this._prefixCls + "-pull-" + this.nbPull,
            this.nbPush && this._prefixCls + "-push-" + this.nbPush
        ].concat(this.generateClass());
        this._classList = this._classList.filter(function (item) {
            return !!item;
        });
        this._classList.forEach(function (_className) {
            _this._renderer.addClass(_this._el, _className);
        });
    };
    NbColDirective.prototype.generateClass = function () {
        var _this = this;
        var listOfSizeInputName = ['nbXs', 'nbSm', 'nbMd', 'nbLg', 'nbXl'];
        var listOfClassName = [];
        listOfSizeInputName.forEach(function (name) {
            var sizeName = name.replace('nb', '').toLowerCase();
            if ((typeof (_this[name]) === 'number') || (typeof (_this[name]) === 'string')) {
                listOfClassName.push(_this[name] && _this._prefixCls + "-" + sizeName + "-" + _this[name]);
            }
            else {
                listOfClassName.push(_this[name] && _this[name]['span'] && _this._prefixCls + "-" + sizeName + "-" + _this[name]['span']);
                listOfClassName.push(_this[name] && _this[name]['pull'] && _this._prefixCls + "-" + sizeName + "-pull-" + _this[name]['pull']);
                listOfClassName.push(_this[name] && _this[name]['push'] && _this._prefixCls + "-" + sizeName + "-push-" + _this[name]['push']);
                listOfClassName.push(_this[name] && _this[name]['offset'] && _this._prefixCls + "-" + sizeName + "-offset-" + _this[name]['offset']);
                listOfClassName.push(_this[name] && _this[name]['order'] && _this._prefixCls + "-" + sizeName + "-order-" + _this[name]['order']);
            }
        });
        return listOfClassName;
    };
    NbColDirective.prototype.ngOnChanges = function () {
        this.setClassMap();
    };
    NbColDirective.prototype.ngOnInit = function () {
        this.setClassMap();
    };
    tslib_1.__decorate([
        HostBinding('style.padding-left.px'),
        tslib_1.__metadata("design:type", Object),
        tslib_1.__metadata("design:paramtypes", [])
    ], NbColDirective.prototype, "paddingLeft", null);
    tslib_1.__decorate([
        HostBinding('style.padding-right.px'),
        tslib_1.__metadata("design:type", Object),
        tslib_1.__metadata("design:paramtypes", [])
    ], NbColDirective.prototype, "paddingRight", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], NbColDirective.prototype, "nbSpan", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], NbColDirective.prototype, "nbOrder", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], NbColDirective.prototype, "nbOffset", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], NbColDirective.prototype, "nbPush", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], NbColDirective.prototype, "nbPull", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbColDirective.prototype, "nbXs", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbColDirective.prototype, "nbSm", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbColDirective.prototype, "nbMd", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbColDirective.prototype, "nbLg", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbColDirective.prototype, "nbXl", void 0);
    NbColDirective = tslib_1.__decorate([
        Directive({
            selector: '[nbCol]'
        }),
        tslib_1.__param(1, Optional()), tslib_1.__param(1, Host()),
        tslib_1.__metadata("design:paramtypes", [ElementRef,
            NbRowDirective,
            Renderer2])
    ], NbColDirective);
    return NbColDirective;
}());
export { NbColDirective };
//# sourceMappingURL=col.directive.js.map