/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-sidebar-group/dashboard-sidebar-group.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { ChangeDetectionStrategy, Component, Host, HostListener, Input, Optional, ViewEncapsulation } from '@angular/core';
import { BbDashboardSidebar } from '../dashboard-sidebar/dashboard-sidebar.component';
import { mixinDisabled } from '@bravobit/bb-foundation';
import { of } from 'rxjs';
var BbDashboardSidebarGroupBase = /** @class */ (function () {
    function BbDashboardSidebarGroupBase(_parent) {
        this._parent = _parent;
    }
    return BbDashboardSidebarGroupBase;
}());
if (false) {
    /**
     * @type {?}
     * @protected
     */
    BbDashboardSidebarGroupBase.prototype._parent;
}
/** @type {?} */
var BbDashboardSidebarGroupMixinBase = mixinDisabled(BbDashboardSidebarGroupBase);
var BbDashboardSidebarGroup = /** @class */ (function (_super) {
    tslib_1.__extends(BbDashboardSidebarGroup, _super);
    function BbDashboardSidebarGroup(_parent) {
        var _this = _super.call(this, _parent) || this;
        _this._parent = _parent;
        // Inputs.
        _this.id = null;
        _this.icon = null;
        _this.title = null;
        // State.
        _this._isExpanded = false;
        return _this;
    }
    Object.defineProperty(BbDashboardSidebarGroup.prototype, "hasToggle", {
        get: /**
         * @return {?}
         */
        function () {
            // Check if the user provided a icon and/or title.
            return !!this.icon || !!this.title;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BbDashboardSidebarGroup.prototype, "isExpanded", {
        get: /**
         * @return {?}
         */
        function () {
            // If there is an icon or title the group can be
            // expanded by clicking, else not.
            return this.hasToggle
                ? this._isExpanded
                : true;
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @return {?}
     */
    BbDashboardSidebarGroup.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        var _this = this;
        // Check if the id has been supplied.
        if (!this.id) {
            throw new Error('Id is required.');
        }
        // Register the group at the parent and
        // retrieve the slice of the state.
        /** @type {?} */
        var observable$ = this._parent
            ? this._parent.registerGroup(this.id)
            : of(false);
        // Subscribe to the state.
        this._subscription = observable$
            .subscribe((/**
         * @param {?} isExpanded
         * @return {?}
         */
        function (isExpanded) { return _this._isExpanded = isExpanded; }));
    };
    /**
     * @return {?}
     */
    BbDashboardSidebarGroup.prototype.ngOnDestroy = /**
     * @return {?}
     */
    function () {
        // Unsubscribe to prevent memory leaks.
        this._subscription && this._subscription.unsubscribe();
        // Unregister the group at the parent.
        this._parent && this._parent.unregisterGroup(this.id);
    };
    /**
     * @return {?}
     */
    BbDashboardSidebarGroup.prototype.onClick = /**
     * @return {?}
     */
    function () {
        // Verify the group is not disabled.
        if (this.disabled) {
            return;
        }
        // Change the state.
        /** @type {?} */
        var newValue = !this._isExpanded;
        // Set the state of the sidebar group.
        this._parent && this._parent.toggleGroup(this.id, newValue);
    };
    /**
     * @param {?} event
     * @return {?}
     */
    BbDashboardSidebarGroup.prototype.onGroupClicked = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        // If the group is not disabled don't do anything.
        if (!this.disabled) {
            return;
        }
        event.preventDefault();
        event.stopPropagation();
    };
    BbDashboardSidebarGroup.decorators = [
        { type: Component, args: [{
                    selector: 'bb-dashboard-sidebar-group',
                    template: "<!--\r\n    The wrapper that contains the title and icon.\r\n-->\r\n<button *ngIf=\"hasToggle\"\r\n        (click)=\"onClick()\"\r\n        class=\"bb-dashboard-sidebar-group-title\"\r\n        type=\"button\"\r\n        role=\"switch\">\r\n    <bb-icon *ngIf=\"icon as iconName\"\r\n             [src]=\"iconName\"\r\n             class=\"bb-dashboard-sidebar-group-icon\">\r\n    </bb-icon>\r\n    <span *ngIf=\"title as titleText\"\r\n          role=\"heading\"\r\n          class=\"bb-dashboard-sidebar-group-text\">\r\n        {{ titleText }}\r\n    </span>\r\n    <span class=\"bb-dashboard-sidebar-group-toggle\">\r\n       <svg xmlns=\"http://www.w3.org/2000/svg\"\r\n            viewBox=\"0 0 21.7 30.9\"\r\n            width=\"10\"\r\n            height=\"10\"\r\n            role=\"img\">\r\n           <path\r\n               d=\"M10.1.3L.2 11.8c-.6.6-.1 1.7.8 1.7h19.7c.9 0 1.3-1 .8-1.7L11.6.3c-.4-.4-1.1-.4-1.5 0zM10.1 30.6L.2 19.1c-.6-.6-.1-1.7.8-1.7h19.7c.9 0 1.3 1 .8 1.7l-9.8 11.5c-.5.4-1.2.4-1.6 0z\">\r\n           </path>\r\n       </svg>\r\n    </span>\r\n</button>\r\n\r\n<!--\r\n    The sidebar items that contain the\r\n    links to navigate to other pages.\r\n-->\r\n<ng-content select=\"[bb-dashboard-sidebar-item]\">\r\n</ng-content>\r\n",
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    encapsulation: ViewEncapsulation.None,
                    preserveWhitespaces: false,
                    inputs: ['disabled'],
                    host: {
                        'class': 'bb-dashboard-sidebar-group',
                        '[class.expanded]': 'isExpanded',
                        '[class.with-toggle]': 'hasToggle',
                        '[class.has-icon]': '!!icon',
                        '[class.disabled]': 'disabled',
                        'role': 'group'
                    },
                    styles: [".bb-dashboard-sidebar-group{color:#000;display:block;overflow:hidden;border-bottom:1px solid rgba(0,0,0,.1);transition:background-color .2s cubic-bezier(0,0,.2,1),padding-bottom .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-group.expanded{background-color:rgba(0,0,0,.04)}.bb-dashboard-sidebar-group.expanded .bb-dashboard-sidebar-group-title{color:#000}.bb-dashboard-sidebar-group.expanded .bb-dashboard-sidebar-item{opacity:1;height:32px;line-height:32px;padding:6px 16px}.bb-dashboard-sidebar-group.expanded .bb-dashboard-sidebar-group-toggle{opacity:0;-ms-transform:translateX(10px);transform:translateX(10px)}.bb-dashboard-sidebar-group.with-toggle.expanded{padding-bottom:20px}.bb-dashboard-sidebar-group.has-icon .bb-dashboard-sidebar-item{padding-left:54px}.bb-dashboard-sidebar-group.disabled{opacity:.5}.bb-dashboard-sidebar-group-title{margin:0;width:100%;border:none;display:-ms-flexbox;display:flex;cursor:pointer;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-align:center;align-items:center;padding:17px 15px;color:rgba(0,0,0,.8);background-color:transparent;transition:color .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-group-title:active>.bb-dashboard-sidebar-group-toggle{background-color:rgba(0,0,0,.08)}.bb-dashboard-sidebar-group-icon{margin-right:15px;color:rgba(0,0,0,.25)}.bb-dashboard-sidebar-group-text{width:100%;display:block;font-size:14px;max-width:100%;overflow:hidden;font-weight:500;line-height:15px;white-space:nowrap;text-overflow:ellipsis;text-transform:uppercase}.bb-dashboard-sidebar-group-toggle{width:22px;height:22px;display:-ms-flexbox;display:flex;min-width:22px;min-height:22px;margin-left:auto;border-radius:3px;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;transition:opacity .2s cubic-bezier(0,0,.2,1),transform .2s cubic-bezier(0,0,.2,1),background-color .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-group-toggle>svg{width:10px;height:10px;fill:rgba(0,0,0,.25)}"]
                }] }
    ];
    /** @nocollapse */
    BbDashboardSidebarGroup.ctorParameters = function () { return [
        { type: BbDashboardSidebar, decorators: [{ type: Optional }, { type: Host }] }
    ]; };
    BbDashboardSidebarGroup.propDecorators = {
        id: [{ type: Input }],
        icon: [{ type: Input }],
        title: [{ type: Input }],
        onGroupClicked: [{ type: HostListener, args: ['click', ['$event'],] }]
    };
    return BbDashboardSidebarGroup;
}(BbDashboardSidebarGroupMixinBase));
export { BbDashboardSidebarGroup };
if (false) {
    /** @type {?} */
    BbDashboardSidebarGroup.prototype.id;
    /** @type {?} */
    BbDashboardSidebarGroup.prototype.icon;
    /** @type {?} */
    BbDashboardSidebarGroup.prototype.title;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebarGroup.prototype._isExpanded;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebarGroup.prototype._subscription;
    /**
     * @type {?}
     * @protected
     */
    BbDashboardSidebarGroup.prototype._parent;
}
//# sourceMappingURL=data:application/json;base64, 