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 ElTreeGridColumnDefDirective_1;
import { Directive, Input } from '@angular/core';
import { ElCdkColumnDef } from '../cdk/table/type-mappings';
import { EL_SORT_HEADER_COLUMN_DEF, ElColumnDefDirective } from '../cdk/table/cell';
/**
 * Column definition for the tree-grid.
 * Defines a set of cells available for a table column.
 */
let ElTreeGridColumnDefDirective = ElTreeGridColumnDefDirective_1 = class ElTreeGridColumnDefDirective extends ElColumnDefDirective {
    /**
     * Column definition for the tree-grid.
     * Defines a set of cells available for a table column.
     */
    constructor() {
        super(...arguments);
        this.hideOnValue = null;
        this.showOnValue = null;
    }
    /**
     * Amount of pixels of viewport at which column should be hidden.
     * type number
     */
    get hideOn() {
        return this.hideOnValue;
    }
    set hideOn(value) {
        this.hideOnValue = !value && value !== 0
            ? null
            : parseInt(value, 10);
    }
    /**
     * Amount of pixels of viewport at which column should be shown.
     * type number
     */
    get showOn() {
        return this.showOnValue;
    }
    set showOn(value) {
        this.showOnValue = !value && value !== 0
            ? null
            : parseInt(value, 10);
    }
    ngOnChanges() {
        if (this.hideOn != null && this.showOn != null) {
            throw new Error(`hideOn and showOn are mutually exclusive and can't be used simultaneously.`);
        }
    }
    shouldHide(width) {
        return !this.shouldShow(width);
    }
    shouldShow(width) {
        if (this.hideOn == null && this.showOn == null) {
            return true;
        }
        if (this.hideOn != null) {
            return width > this.hideOn;
        }
        return width >= this.showOn;
    }
};
__decorate([
    Input('elTreeGridColumnDef'),
    __metadata("design:type", String)
], ElTreeGridColumnDefDirective.prototype, "name", void 0);
__decorate([
    Input(),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], ElTreeGridColumnDefDirective.prototype, "hideOn", null);
__decorate([
    Input(),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], ElTreeGridColumnDefDirective.prototype, "showOn", null);
ElTreeGridColumnDefDirective = ElTreeGridColumnDefDirective_1 = __decorate([
    Directive({
        selector: '[elTreeGridColumnDef]',
        providers: [
            { provide: ElCdkColumnDef, useExisting: ElTreeGridColumnDefDirective_1 },
            { provide: EL_SORT_HEADER_COLUMN_DEF, useExisting: ElTreeGridColumnDefDirective_1 },
        ],
    })
], ElTreeGridColumnDefDirective);
export { ElTreeGridColumnDefDirective };
//# sourceMappingURL=tree-grid-column-def.directive.js.map