import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core';
import { DismissAlertStrategy } from './dynamic-component-alert.model';
import { DynamicComponentAlertAggregator } from './dynamic-component-alert-aggregator';
import { AlertOutletBase, AlertService } from '../alert';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "../alert";
import * as i2 from "../common/icon.directive";
import * as i3 from "@angular/common";
import * as i4 from "../i18n/c8y-translate.pipe";
export class DynamicComponentAlertsComponent extends AlertOutletBase {
    constructor(alertService, ref) {
        super(alertService);
        this.alertService = alertService;
        this.ref = ref;
        this.dismissAlertStrategy = DismissAlertStrategy;
        this.destroy$ = new Subject();
    }
    ngOnInit() {
        this.alerts.anyAlertExists$.pipe(takeUntil(this.destroy$)).subscribe(() => {
            this.ref.markForCheck();
        });
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DynamicComponentAlertsComponent, deps: [{ token: i1.AlertService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: DynamicComponentAlertsComponent, selector: "c8y-dynamic-component-alerts", inputs: { alerts: "alerts" }, usesInheritance: true, ngImport: i0, template: "<ng-container *ngFor=\"let alertGroup of alerts.alertGroups\">\n  <div\n    *ngIf=\"alertGroup?.value?.alerts?.length\"\n    class=\"alert\"\n    role=\"alert\"\n    [ngClass]=\"'alert-' + alertGroup.type\"\n  >\n    <button\n      class=\"close\"\n      type=\"button\"\n      *ngIf=\"\n        alertGroup.value.alertDismissal.dismissStrategy === dismissAlertStrategy.TEMPORARY ||\n        alertGroup.value.alertDismissal.dismissStrategy ===\n          dismissAlertStrategy.TEMPORARY_OR_PERMANENT\n      \"\n      (click)=\"alerts.dismissAlertGroup(alertGroup.type, dismissPermanently.checked)\"\n    >\n      <span aria-hidden=\"true\">\u00D7</span>\n      <span class=\"sr-only\">Close</span>\n    </button>\n    <div *ngFor=\"let alertItem of alertGroup.value.alerts; let i = index\" class=\"m-t-8\">\n      <ng-container *ngIf=\"!isTemplateRef(alertItem.text); else template(alertItem.text)\">\n        <p\n          *ngIf=\"!alertItem.allowHtml\"\n          [textContent]=\"alertItem.text | translate\"\n          class=\"message\"\n        ></p>\n        <p *ngIf=\"alertItem.allowHtml\" [innerHTML]=\"alertItem.text | translate\" class=\"message\"></p>\n      </ng-container>\n\n      <p *ngIf=\"hasDetails(alertItem) && !isDetailsShow(alertItem)\" class=\"text-muted m-t-8\">\n        <button\n          title=\"{{ 'Show details' | translate }}\"\n          class=\"btn btn-clean\"\n          (click)=\"showDetails(alertItem)\"\n        >\n          <i c8yIcon=\"chevron-down\"></i>\n          {{ 'Show details' | translate }}\n        </button>\n      </p>\n      <p *ngIf=\"hasDetails(alertItem) && isDetailsShow(alertItem)\" class=\"text-muted m-t-8\">\n        <button\n          title=\"{{ 'Hide details' | translate }}\"\n          class=\"btn btn-clean\"\n          (click)=\"closeDetails()\"\n        >\n          <i c8yIcon=\"chevron-up\"></i>\n          {{ 'Hide details' | translate }}\n        </button>\n      </p>\n      <div *ngIf=\"isDetailsShow(alertItem)\">\n        <div\n          *ngIf=\"\n            !isTemplateRef(detailDisplayedAlert.contents);\n            else template(alertItem.detailedData)\n          \"\n        >\n          <pre><code [textContent]=\"detailDisplayedAlert.contents | translate\"></code></pre>\n        </div>\n      </div>\n      <hr *ngIf=\"i !== alertGroup.value.alerts.length - 1\" />\n    </div>\n\n    <label\n      title=\"{{ 'Don\\'t show again' | translate }}\"\n      class=\"c8y-checkbox m-t-16\"\n      [class.hidden]=\"\n        alertGroup.value.alertDismissal.dismissStrategy !==\n        dismissAlertStrategy.TEMPORARY_OR_PERMANENT\n      \"\n    >\n      <input type=\"checkbox\" #dismissPermanently />\n      <span></span>\n      <span>{{ \"Don't show again\" | translate }}</span>\n    </label>\n  </div>\n</ng-container>\n", dependencies: [{ kind: "directive", type: i2.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { 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: "pipe", type: i4.C8yTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DynamicComponentAlertsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-dynamic-component-alerts', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngFor=\"let alertGroup of alerts.alertGroups\">\n  <div\n    *ngIf=\"alertGroup?.value?.alerts?.length\"\n    class=\"alert\"\n    role=\"alert\"\n    [ngClass]=\"'alert-' + alertGroup.type\"\n  >\n    <button\n      class=\"close\"\n      type=\"button\"\n      *ngIf=\"\n        alertGroup.value.alertDismissal.dismissStrategy === dismissAlertStrategy.TEMPORARY ||\n        alertGroup.value.alertDismissal.dismissStrategy ===\n          dismissAlertStrategy.TEMPORARY_OR_PERMANENT\n      \"\n      (click)=\"alerts.dismissAlertGroup(alertGroup.type, dismissPermanently.checked)\"\n    >\n      <span aria-hidden=\"true\">\u00D7</span>\n      <span class=\"sr-only\">Close</span>\n    </button>\n    <div *ngFor=\"let alertItem of alertGroup.value.alerts; let i = index\" class=\"m-t-8\">\n      <ng-container *ngIf=\"!isTemplateRef(alertItem.text); else template(alertItem.text)\">\n        <p\n          *ngIf=\"!alertItem.allowHtml\"\n          [textContent]=\"alertItem.text | translate\"\n          class=\"message\"\n        ></p>\n        <p *ngIf=\"alertItem.allowHtml\" [innerHTML]=\"alertItem.text | translate\" class=\"message\"></p>\n      </ng-container>\n\n      <p *ngIf=\"hasDetails(alertItem) && !isDetailsShow(alertItem)\" class=\"text-muted m-t-8\">\n        <button\n          title=\"{{ 'Show details' | translate }}\"\n          class=\"btn btn-clean\"\n          (click)=\"showDetails(alertItem)\"\n        >\n          <i c8yIcon=\"chevron-down\"></i>\n          {{ 'Show details' | translate }}\n        </button>\n      </p>\n      <p *ngIf=\"hasDetails(alertItem) && isDetailsShow(alertItem)\" class=\"text-muted m-t-8\">\n        <button\n          title=\"{{ 'Hide details' | translate }}\"\n          class=\"btn btn-clean\"\n          (click)=\"closeDetails()\"\n        >\n          <i c8yIcon=\"chevron-up\"></i>\n          {{ 'Hide details' | translate }}\n        </button>\n      </p>\n      <div *ngIf=\"isDetailsShow(alertItem)\">\n        <div\n          *ngIf=\"\n            !isTemplateRef(detailDisplayedAlert.contents);\n            else template(alertItem.detailedData)\n          \"\n        >\n          <pre><code [textContent]=\"detailDisplayedAlert.contents | translate\"></code></pre>\n        </div>\n      </div>\n      <hr *ngIf=\"i !== alertGroup.value.alerts.length - 1\" />\n    </div>\n\n    <label\n      title=\"{{ 'Don\\'t show again' | translate }}\"\n      class=\"c8y-checkbox m-t-16\"\n      [class.hidden]=\"\n        alertGroup.value.alertDismissal.dismissStrategy !==\n        dismissAlertStrategy.TEMPORARY_OR_PERMANENT\n      \"\n    >\n      <input type=\"checkbox\" #dismissPermanently />\n      <span></span>\n      <span>{{ \"Don't show again\" | translate }}</span>\n    </label>\n  </div>\n</ng-container>\n" }]
        }], ctorParameters: () => [{ type: i1.AlertService }, { type: i0.ChangeDetectorRef }], propDecorators: { alerts: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 