/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, Input, Output, EventEmitter, ContentChild, ChangeDetectionStrategy } from '@angular/core';
import { Router } from '@angular/router';
import { BreadcrumbService } from '../../services/nav/breadcrumb.service';
import { BreadcrumbOverrideDirective } from './breadcrumb-override.directive';
import { ScrollService } from '../../services/interactions/scroll.service';
var BreadcrumbComponent = /** @class */ (function () {
    function BreadcrumbComponent(router, breadcrumbService, scrollService) {
        this.router = router;
        this.breadcrumbService = breadcrumbService;
        this.scrollService = scrollService;
        this.useBootstrap = true;
        this.hasTabs = false;
        this.hasOverview = false;
        this.prefix = '';
        this.hasQuickNav = false;
        this.quickNavOptions = [];
        this.customBreadcrumbTemplates = [];
        this.quickNavSelectionChanged$ = new EventEmitter();
    }
    /**
     * @return {?}
     */
    BreadcrumbComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.urls = new Array();
        if (this.prefix.length > 0) {
            this.urls.unshift(this.prefix);
        }
        this.generateBreadcrumbTrail(this.router.url);
        this.scrollService.hasTabs = this.hasTabs;
        this.scrollService.hasOverview = this.hasOverview;
    };
    /**
     * @return {?}
     */
    BreadcrumbComponent.prototype.ngOnChanges = /**
     * @return {?}
     */
    function () {
        if (!this.urls) {
            return;
        }
        this.urls.length = 0;
        this.generateBreadcrumbTrail(this.router.url);
        this.scrollService.hasTabs = this.hasTabs;
        this.scrollService.hasOverview = this.hasOverview;
    };
    /**
     * @param {?} url
     * @return {?}
     */
    BreadcrumbComponent.prototype.generateBreadcrumbTrail = /**
     * @param {?} url
     * @return {?}
     */
    function (url) {
        if (!this.breadcrumbService.isRouteHidden(url)) {
            // Add url to beginning of array (since the url is being recursively broken down from full url to its parent)
            this.urls.unshift(url);
        }
        if (url.lastIndexOf('/') > 0) {
            // Find last '/' and add everything before it as a parent route
            this.generateBreadcrumbTrail(url.substr(0, url.lastIndexOf('/')));
        }
        else if (this.prefix.length > 0) {
            this.urls.unshift(this.prefix);
        }
    };
    /**
     * @param {?} url
     * @return {?}
     */
    BreadcrumbComponent.prototype.navigateTo = /**
     * @param {?} url
     * @return {?}
     */
    function (url) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.router.navigateByUrl(url)];
                    case 1:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    /**
     * @param {?} url
     * @return {?}
     */
    BreadcrumbComponent.prototype.friendlyName = /**
     * @param {?} url
     * @return {?}
     */
    function (url) {
        return !url ? '' : this.breadcrumbService.getFriendlyNameForRoute(url);
    };
    /**
     * @return {?}
     */
    BreadcrumbComponent.prototype.emitQuickNavChange = /**
     * @return {?}
     */
    function () {
        this.quickNavSelectionChanged$.emit(this.quickNavSelection);
    };
    BreadcrumbComponent.decorators = [
        { type: Component, args: [{
                    selector: 'breadcrumb',
                    template: "<div class=\"breadcrumbs-bg\"\n     [class.with-overview-fix-tabs]=\"hasOverview && hasTabs && scrollService.stickyTabs$ | async\"\n     [class.with-tabs]=\"hasTabs\"\n     [class.with-overview]=\"hasOverview\">\n</div>\n<div [ngClass]=\"{'with-tabs': hasTabs }\" class=\"breadcrumbs\">\n  <!--  Override: Content can be projected into the breadcrumb which will override the default behavior -->\n  <div class=\"override\" *ngIf=\"overrideDirective\"><ng-content></ng-content></div>\n  <!-- Default: Show the breadcrumbs if the user has not supplied override content   -->\n  <ul [class.breadcrumb]=\"useBootstrap\" *ngIf=\"!overrideDirective\">\n    <li *ngFor=\"let url of urls; let last = last; let i = index\"\n      [ngClass]=\"{ 'breadcrumb-item': useBootstrap, 'active': last }\">\n      <ng-container *ngIf=\"!last\">\n        <a role=\"button\" (click)=\"navigateTo(url == prefix ? '/' : url)\">\n          <ng-container *ngIf=\"customBreadcrumbTemplates[i]\">\n            <ng-container *ngTemplateOutlet=\"customBreadcrumbTemplates[i]\">\n            </ng-container>\n          </ng-container>\n          <ng-container *ngIf=\"!customBreadcrumbTemplates[i]\">{{ url == prefix ? url : friendlyName(url) }}</ng-container></a>\n        <i class=\"ico ico-chevron-right\"></i>\n      </ng-container>\n      <ng-container *ngIf=\"last && !hasQuickNav\">\n        <ng-container *ngIf=\"customBreadcrumbTemplates[i]\">\n          <ng-container *ngTemplateOutlet=\"customBreadcrumbTemplates[i]\"></ng-container>\n        </ng-container>\n        <ng-container *ngIf=\"!customBreadcrumbTemplates[i]\">\n          {{ friendlyName(url == prefix ? '/' : url) }}\n        </ng-container>\n      </ng-container>\n    </li>\n    <li *ngIf=\"hasQuickNav\">\n      <select class=\"form-control form-control-inline\" [(ngModel)]=\"quickNavSelection\" (change)=\"emitQuickNavChange()\">\n        <option *ngFor=\"let option of quickNavOptions\" [value]=\"option.value\">{{ option.label }}</option>\n      </select>\n    </li>\n  </ul>\n</div>\n",
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    styles: ["\n    .breadcrumbs-bg {\n        height: 104px;\n        transform: translateY(-44px);\n        transition: transform 75ms ease-in;\n    }\n    .breadcrumbs-bg.with-tabs:not(.with-overview),\n    .breadcrumbs-bg.with-overview-fix-tabs {\n        transform: translateY(0px);\n    }\n  "]
                }] }
    ];
    /** @nocollapse */
    BreadcrumbComponent.ctorParameters = function () { return [
        { type: Router },
        { type: BreadcrumbService },
        { type: ScrollService }
    ]; };
    BreadcrumbComponent.propDecorators = {
        useBootstrap: [{ type: Input }],
        hasTabs: [{ type: Input }],
        hasOverview: [{ type: Input }],
        prefix: [{ type: Input }],
        hasQuickNav: [{ type: Input }],
        quickNavOptions: [{ type: Input }],
        quickNavSelection: [{ type: Input }],
        customBreadcrumbTemplates: [{ type: Input }],
        quickNavSelectionChanged$: [{ type: Output }],
        overrideDirective: [{ type: ContentChild, args: [BreadcrumbOverrideDirective,] }]
    };
    return BreadcrumbComponent;
}());
export { BreadcrumbComponent };
if (false) {
    /** @type {?} */
    BreadcrumbComponent.prototype.useBootstrap;
    /** @type {?} */
    BreadcrumbComponent.prototype.hasTabs;
    /** @type {?} */
    BreadcrumbComponent.prototype.hasOverview;
    /** @type {?} */
    BreadcrumbComponent.prototype.prefix;
    /** @type {?} */
    BreadcrumbComponent.prototype.hasQuickNav;
    /** @type {?} */
    BreadcrumbComponent.prototype.quickNavOptions;
    /** @type {?} */
    BreadcrumbComponent.prototype.quickNavSelection;
    /** @type {?} */
    BreadcrumbComponent.prototype.customBreadcrumbTemplates;
    /** @type {?} */
    BreadcrumbComponent.prototype.quickNavSelectionChanged$;
    /** @type {?} */
    BreadcrumbComponent.prototype.overrideDirective;
    /** @type {?} */
    BreadcrumbComponent.prototype.urls;
    /**
     * @type {?}
     * @private
     */
    BreadcrumbComponent.prototype.router;
    /**
     * @type {?}
     * @private
     */
    BreadcrumbComponent.prototype.breadcrumbService;
    /** @type {?} */
    BreadcrumbComponent.prototype.scrollService;
}
//# sourceMappingURL=data:application/json;base64, 