/**
 * @fileoverview added by tsickle
 * Generated from: lib/table-header-cell/table-header-cell.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { ChangeDetectionStrategy, Component, HostBinding, HostListener, Input, ViewEncapsulation } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
var BbTableHeaderCell = /** @class */ (function () {
    function BbTableHeaderCell() {
        // Styling.
        this.disabled = false;
        // Constants.
        this._name = null;
        this._sort = 'none';
        this._sortDirections = ['asc', 'desc', 'none'];
        // State.
        this.state = new BehaviorSubject(null);
    }
    Object.defineProperty(BbTableHeaderCell.prototype, "name", {
        get: /**
         * @return {?}
         */
        function () {
            return this._name;
        },
        set: /**
         * @param {?} value
         * @return {?}
         */
        function (value) {
            this._name = value;
            this.setState();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BbTableHeaderCell.prototype, "sort", {
        get: /**
         * @return {?}
         */
        function () {
            return this._sort;
        },
        set: /**
         * @param {?} value
         * @return {?}
         */
        function (value) {
            this._sort = value;
            this.setState();
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @return {?}
     */
    BbTableHeaderCell.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.setState();
    };
    /**
     * @return {?}
     */
    BbTableHeaderCell.prototype.onClick = /**
     * @return {?}
     */
    function () {
        var _this = this;
        // Check if the header cell is disabled.
        if (this.disabled) {
            return;
        }
        // Find the index of the current sort.
        /** @type {?} */
        var index = this._sortDirections.findIndex((/**
         * @param {?} item
         * @return {?}
         */
        function (item) { return item === _this.sort; }));
        // Increase the current index.
        /** @type {?} */
        var newIndex = index + 1;
        // If the sort is out of bounds set it to null.
        if (newIndex >= this._sortDirections.length) {
            newIndex = 0;
        }
        // Set the new sort.
        this.sort = this._sortDirections[newIndex];
    };
    /**
     * @return {?}
     */
    BbTableHeaderCell.prototype.setState = /**
     * @return {?}
     */
    function () {
        this.state.next({
            name: this.name,
            direction: this.sort
        });
    };
    BbTableHeaderCell.decorators = [
        { type: Component, args: [{
                    selector: 'bb-table-header-cell',
                    template: "<ng-content></ng-content>\r\n\r\n<!-- The indicator for the sort direction. -->\r\n<button *ngIf=\"!disabled\"\r\n        [class.asc]=\"sort === 'asc'\"\r\n        [class.desc]=\"sort === 'desc'\"\r\n        class=\"bb-table-header-cell-toggle\"\r\n        type=\"button\"></button>\r\n",
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    host: { 'class': 'bb-table-header-cell' },
                    encapsulation: ViewEncapsulation.None,
                    preserveWhitespaces: false,
                    styles: [".bb-table-header-cell{height:50px;color:#212529;cursor:pointer;font-size:16px;font-weight:500;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;padding:10px 20px;position:relative;display:table-cell;vertical-align:middle;border-bottom:1px solid #d8d8d8}.bb-table-header-cell:active>.bb-table-header-cell-toggle{background-color:rgba(0,0,0,.08)}.bb-table-header-cell:not(.disabled){padding-right:52px}.bb-table-header-cell.fit{width:1%;white-space:nowrap}.bb-table-header-cell.left{text-align:left}.bb-table-header-cell.center{text-align:center}.bb-table-header-cell.right{text-align:right}.bb-table-header-cell.disabled{cursor:default;pointer-events:none}.bb-table-header-cell-toggle{top:50%;right:14px;width:22px;border:none;height:22px;margin-left:auto;position:absolute;border-radius:4px;-ms-transform:translateY(-50%);transform:translateY(-50%);background-position:center;background-repeat:no-repeat;background-color:transparent;transition:background-color .2s cubic-bezier(0,0,.2,1);background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.desc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"black\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.asc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"black\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}"]
                }] }
    ];
    BbTableHeaderCell.propDecorators = {
        disabled: [{ type: HostBinding, args: ['class.disabled',] }, { type: Input }],
        name: [{ type: Input }],
        sort: [{ type: Input }],
        onClick: [{ type: HostListener, args: ['click',] }]
    };
    return BbTableHeaderCell;
}());
export { BbTableHeaderCell };
if (false) {
    /** @type {?} */
    BbTableHeaderCell.prototype.disabled;
    /**
     * @type {?}
     * @private
     */
    BbTableHeaderCell.prototype._name;
    /**
     * @type {?}
     * @private
     */
    BbTableHeaderCell.prototype._sort;
    /**
     * @type {?}
     * @private
     */
    BbTableHeaderCell.prototype._sortDirections;
    /** @type {?} */
    BbTableHeaderCell.prototype.state;
}
//# sourceMappingURL=data:application/json;base64, 