/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, Input } from '@angular/core';
import { Router } from '@angular/router';
export class NavMenuComponent {
    /**
     * @param {?} router
     */
    constructor(router) {
        this.router = router;
    }
    /**
     * @param {?} item
     * @return {?}
     */
    isTopVisible(item) {
        if (item.items === undefined) {
            return false;
        }
        /** @type {?} */
        let result = false;
        item.items.forEach((/**
         * @param {?} x
         * @return {?}
         */
        (x) => {
            if (x.route !== undefined && this.router.url.indexOf(x.route[0]) > -1) {
                result = true;
                return;
            }
        }));
        if (result) {
            return true;
        }
        if (item.route === undefined) {
            return false;
        }
        return this.isItemActive(item);
    }
    /**
     * @param {?} item
     * @return {?}
     */
    isItemActive(item) {
        if (item.route === undefined) {
            return false;
        }
        /** @type {?} */
        const urlWithoutQuery = this.router.url.split('?')[0];
        return item.highlightForChildren
            ? urlWithoutQuery.startsWith(item.route[0])
            : !item.items && urlWithoutQuery === item.route[0];
    }
}
NavMenuComponent.decorators = [
    { type: Component, args: [{
                selector: 'nav-menu',
                template: "<ul>\n  <li *ngFor=\"let item of items\">\n    <!--  Top-level item: internal link    -->\n    <a *ngIf=\"item.route && !item.href\" [routerLink]=\"item.route\" class=\"nav-primary-section-link\">\n      <i class=\"ico {{ item.icon }}\"></i>\n      <span>{{ item.label }}</span>\n      <badge *ngIf=\"item.badge\" [tooltipText]=\"item.badge.tooltipText\" [type]=\"item.badge.type\" [className]=\"item.badge.className || 'ml-2'\">{{ item.badge.label }}</badge>\n    </a>\n    <!--  Top-level item: external link    -->\n    <a *ngIf=\"item.href\" href=\"{{ item.href }}\" class=\"nav-primary-section-link\">\n      <i class=\"ico {{ item.icon }}\"></i>\n      <span>{{ item.label }}</span>\n      <badge *ngIf=\"item.badge\" [tooltipText]=\"item.badge.tooltipText\" [type]=\"item.badge.type\" [className]=\"item.badge.className || 'ml-2'\">{{ item.badge.label }}</badge>\n    </a>\n    <!-- Secondary Items -->\n    <ul *ngIf=\"item.items\" class=\"nav-primary-subsection\"\n      [ngClass]=\"{'expanded':isTopVisible(item)}\">\n      <li *ngFor=\"let sub of item.items\" class=\"nav-primary-subsection-item\">\n        <!--    label only    -->\n        <span class=\"nav-primary-label\" *ngIf=\"!sub.route && !sub.href\">\n          {{ sub.label }}\n          <badge *ngIf=\"sub.badge\" [tooltipText]=\"sub.badge.tooltipText\" [type]=\"sub.badge.type\" [className]=\"sub.badge.className || 'ml-2'\">{{ sub.badge.label }}</badge>\n        </span>\n\n        <!--  secondary item: internal link    -->\n        <a *ngIf=\"sub.route && !sub.href\" [routerLink]=\"sub.route\" class=\"nav-primary-subsection-link\"\n          [ngClass]=\"{'active':isItemActive(sub), 'expanded':isTopVisible(sub), 'has-children':sub.items}\">\n          <span>{{ sub.label }}</span>\n          <badge *ngIf=\"sub.badge\" [tooltipText]=\"sub.badge.tooltipText\" [type]=\"sub.badge.type\" [className]=\"sub.badge.className || 'ml-2'\">{{ sub.badge.label }}</badge>\n        </a>\n\n        <!--  secondary item: external link    -->\n        <a *ngIf=\"sub.href\" href=\"{{ sub.href }}\" target=\"{{ sub.target }}\" class=\"nav-primary-subsection-link\"\n          [ngClass]=\"{'active':isItemActive(sub), 'expanded':isTopVisible(sub), 'has-children':sub.items}\">\n          <span>{{ sub.label }}</span>\n          <badge *ngIf=\"sub.badge\" [tooltipText]=\"sub.badge.tooltipText\" [type]=\"sub.badge.type\" [className]=\"sub.badge.className || 'ml-2'\">{{ sub.badge.label }}</badge>\n        </a>\n        <!-- Tertiary Items -->\n        <ul *ngIf=\"sub.items\" class=\"nav-primary-subsection nav-primary-tertiary\" [ngClass]=\"{'expanded':isTopVisible(sub)}\">\n          <li *ngFor=\"let subsub of sub.items\" class=\"nav-primary-tertiary-item\">\n          <!--      tertiary : label      -->\n          <span class=\"nav-primary-label\" *ngIf=\"!subsub.route && !subsub.href\">\n            {{ subsub.label }}\n            <badge *ngIf=\"subsub.badge\" [tooltipText]=\"subsub.badge.tooltipText\" [type]=\"subsub.badge.type\" [className]=\"subsub.badge.className || 'ml-2'\">{{ subsub.badge.label }}</badge>\n          </span>\n            <!--      tertiary : internal link      -->\n            <a *ngIf=\"subsub.route && !subsub.href\" [routerLink]=\"subsub.route\" class=\"nav-primary-tertiary-link\"\n              [ngClass]=\"{'active':isItemActive(subsub)}\">\n              <span>{{ subsub.label }}</span>\n              <badge *ngIf=\"subsub.badge\" [tooltipText]=\"subsub.badge.tooltipText\" [type]=\"subsub.badge.type\" [className]=\"subsub.badge.className || 'ml-2'\">{{ subsub.badge.label }}</badge>\n            </a>\n            <!--      tertiary : external link      -->\n            <a *ngIf=\"subsub.href\" href=\"{{ subsub.href }}\" target=\"{{ subsub.target }}\" class=\"nav-primary-tertiary-link\"\n              [ngClass]=\"{'active':isItemActive(subsub)}\">\n              <span>{{ subsub.label }}</span>\n              <badge *ngIf=\"subsub.badge\" [tooltipText]=\"subsub.badge.tooltipText\" [type]=\"subsub.badge.type\" [className]=\"subsub.badge.className || 'ml-2'\">{{ subsub.badge.label }}</badge>\n            </a>\n          </li>\n        </ul>\n      </li>\n    </ul>\n  </li>\n</ul>\n"
            }] }
];
/** @nocollapse */
NavMenuComponent.ctorParameters = () => [
    { type: Router }
];
NavMenuComponent.propDecorators = {
    items: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    NavMenuComponent.prototype.items;
    /**
     * @type {?}
     * @private
     */
    NavMenuComponent.prototype.router;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF2LW1lbnUuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGFybW9yL2JyYW5ka2l0LyIsInNvdXJjZXMiOlsibGliL2NvbXBvbmVudHMvbmF2L25hdi1tZW51LmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQUUsTUFBT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