import { Component, Input } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { distinctUntilChanged, filter, map, switchMap } from 'rxjs/operators';
import { DrawerService } from '../drawer.service';
import * as i0 from "@angular/core";
import * as i1 from "../drawer.service";
import * as i2 from "@angular/cdk/a11y";
import * as i3 from "@angular/common";
import * as i4 from "../../common/component-outlet.directive";
import * as i5 from "../../i18n/c8y-translate.pipe";
export class DrawerOutletComponent {
    constructor(drawerService) {
        this.drawerService = drawerService;
        this.drawerPosition$ = new BehaviorSubject(null);
        const cleanedPosition$ = this.drawerPosition$.pipe(filter(p => !!p), distinctUntilChanged());
        this.isLeft$ = cleanedPosition$.pipe(map(position => position === 'left'));
        this.drawerItems$ = cleanedPosition$.pipe(filter(p => !!p), distinctUntilChanged(), switchMap(position => this.drawerService.getDrawersForPosition$(position)));
    }
    ngOnChanges(changes) {
        if (changes.position) {
            this.drawerPosition$.next(this.position);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: DrawerOutletComponent, deps: [{ token: i1.DrawerService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: DrawerOutletComponent, selector: "c8y-drawer-outlet", inputs: { position: "position", open: "open" }, usesOnChanges: true, ngImport: i0, template: "<nav\n  id=\"navigator\"\n  class=\"navigator\"\n  [attr.aria-label]=\"'Navigator' | translate\"\n  [ngClass]=\"{ open: open }\"\n  *ngIf=\"isLeft$ | async; else right\"\n>\n  <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n</nav>\n\n<ng-template #right>\n  <aside class=\"c8y-right-drawer\" [cdkTrapFocus]=\"open\" [attr.aria-label]=\"'User menu' | translate\">\n    <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n  </aside>\n</ng-template>\n\n<ng-template #content>\n  <ng-container *ngFor=\"let drawerItem of drawerItems$ | async\">\n    <ng-container *c8yComponentOutlet=\"drawerItem.component; environmentInjector: drawerItem.injector\"></ng-container>\n  </ng-container>\n</ng-template>\n", dependencies: [{ kind: "directive", type: i2.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i4.C8yComponentOutlet, selector: "[c8yComponentOutlet]", inputs: ["c8yComponentOutlet", "c8yComponentOutletInjector", "c8yComponentOutletEnvironmentInjector"] }, { kind: "pipe", type: i5.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: DrawerOutletComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-drawer-outlet', template: "<nav\n  id=\"navigator\"\n  class=\"navigator\"\n  [attr.aria-label]=\"'Navigator' | translate\"\n  [ngClass]=\"{ open: open }\"\n  *ngIf=\"isLeft$ | async; else right\"\n>\n  <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n</nav>\n\n<ng-template #right>\n  <aside class=\"c8y-right-drawer\" [cdkTrapFocus]=\"open\" [attr.aria-label]=\"'User menu' | translate\">\n    <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n  </aside>\n</ng-template>\n\n<ng-template #content>\n  <ng-container *ngFor=\"let drawerItem of drawerItems$ | async\">\n    <ng-container *c8yComponentOutlet=\"drawerItem.component; environmentInjector: drawerItem.injector\"></ng-container>\n  </ng-container>\n</ng-template>\n" }]
        }], ctorParameters: () => [{ type: i1.DrawerService }], propDecorators: { position: [{
                type: Input
            }], open: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 