/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { Component, ContentChild, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/button";
import * as i3 from "@angular/material/card";
import * as i4 from "@angular/material/icon";
export class DejaMessageBoxComponent {
    constructor() {
        // eslint-disable-next-line @angular-eslint/no-output-native
        this.close = new EventEmitter();
        this._showCloseIcon = false;
    }
    set horizontal(value) {
        this._horizontal = coerceBooleanProperty(value);
    }
    get horizontal() {
        return this._horizontal;
    }
    set showCloseIcon(value) {
        this._showCloseIcon = coerceBooleanProperty(value);
    }
    get showCloseIcon() {
        return this._showCloseIcon;
    }
    ngOnInit() {
        if (!this.icon && this.type) {
            this.icon = this.getIconFromType(this.type);
        }
        if (this.actions) {
            this.actions.forEach(action => {
                if (!action.icon && action.type) {
                    action.icon = this.getIconFromType(action.type);
                }
            });
        }
    }
    onClose() {
        this.close.emit();
    }
    getIconFromType(type) {
        switch (type) {
            case 'info':
            case 'primary':
                type = 'primary';
                return 'info_outline';
            case 'success':
                return 'done';
            case 'warn':
                return 'warning_outline';
            case 'danger':
                return 'error_outline';
            default:
                return null;
        }
    }
}
DejaMessageBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaMessageBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
DejaMessageBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: DejaMessageBoxComponent, selector: "deja-message-box", inputs: { type: "type", title: "title", icon: "icon", actions: "actions", horizontal: "horizontal", showCloseIcon: "showCloseIcon" }, outputs: { close: "close" }, queries: [{ propertyName: "actionsTemplate", first: true, predicate: ["actionsTemplate"], descendants: true }], ngImport: i0, template: "<mat-card id=\"msgbox\" class=\"{{type}}\">\n    <mat-card-title *ngIf=\"icon || showCloseIcon\">\n        <mat-icon id=\"icon\" *ngIf=\"icon\">{{icon}}</mat-icon>\n        <span id=\"title\" *ngIf=\"!horizontal\">{{title}}</span>\n        <div class=\"header-actions\">\n            <button *ngIf=\"showCloseIcon\" mat-icon-button type=\"button\" class=\"close\" (click)=\"onClose()\">\n                <mat-icon>close</mat-icon>\n            </button>\n        </div>\n    </mat-card-title>\n    <mat-card-content>\n        <h2 id=\"title\" *ngIf=\"horizontal && title\">{{title}}</h2>\n        <ng-content></ng-content>\n    </mat-card-content>\n    <mat-card-actions *ngIf=\"actions\">\n        <span *ngFor=\"let action of actions\">\n            <button mat-button type=\"button\" *ngIf=\"action.text\" (click)=\"action.action()\" class=\"with-icon\" [attr.data-icon]=\"action.icon\">\n                {{action.text}}\n            </button>\n            <button mat-icon-button type=\"button\" *ngIf=\"action.icon && !action.text\" [class.action-button]=\"!action.type\" (click)=\"action.action()\">\n                <mat-icon *ngIf=\"action.icon\">{{action.icon}}</mat-icon>\n            </button>\n        </span>\n    </mat-card-actions>\n    <mat-card-actions *ngIf=\"!actions && actionsTemplate\">\n\t\t<ng-template [ngTemplateOutlet]=\"actionsTemplate\"></ng-template>\n\t</mat-card-actions>\n</mat-card>\n", styles: ["deja-message-box{display:block;border-radius:3px;overflow:hidden;background-color:transparent}deja-message-box #msgbox{border:0;margin:0;padding:0;display:block;border-radius:3px}deja-message-box #msgbox>.mat-card-title{text-transform:uppercase;align-items:center;display:flex;margin:0;padding:1rem 0rem 0rem 1.2rem;font-size:1rem}deja-message-box #msgbox>.mat-card-title #icon{margin-right:.3rem}deja-message-box #msgbox>.mat-card-title .header-actions{position:absolute;top:0;right:0}deja-message-box #msgbox>.mat-card-content{margin:0;overflow:hidden;font-weight:300;padding:.5rem .75rem .75rem 1.3rem}deja-message-box #msgbox>.mat-card-content h2{font-size:1rem;margin:0;font-weight:500;text-transform:uppercase;line-height:1.5rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}deja-message-box #msgbox>.mat-card-actions{align-items:center;display:flex;justify-content:flex-end;margin:0;padding:.5rem}deja-message-box[horizontal] #msgbox{align-items:stretch;display:flex;flex-direction:row;padding:0;position:relative}deja-message-box[horizontal] #msgbox>.mat-card-title{align-items:center;display:flex;flex:0 0 auto;justify-content:center;margin:0;text-align:center;padding:.5rem 0rem .5rem .8rem}deja-message-box[horizontal] #msgbox>.mat-card-title #icon{margin:0}deja-message-box[horizontal] #msgbox>.mat-card-content{align-self:center;flex:1 1 auto;padding:.75rem}deja-message-box[horizontal] #msgbox>.mat-card-actions{margin:0;padding:0;position:absolute;right:0;top:0}deja-message-box[horizontal] #msgbox>.mat-card-actions [mat-icon-button] mat-icon{font-size:1rem}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button],             button[mat-fab], button[mat-mini-fab], button[mat-stroked-button],             button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "directive", type: i3.MatCardContent, selector: "mat-card-content, [mat-card-content], [matCardContent]" }, { kind: "directive", type: i3.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "directive", type: i3.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaMessageBoxComponent, decorators: [{
            type: Component,
            args: [{ encapsulation: ViewEncapsulation.None, selector: 'deja-message-box', template: "<mat-card id=\"msgbox\" class=\"{{type}}\">\n    <mat-card-title *ngIf=\"icon || showCloseIcon\">\n        <mat-icon id=\"icon\" *ngIf=\"icon\">{{icon}}</mat-icon>\n        <span id=\"title\" *ngIf=\"!horizontal\">{{title}}</span>\n        <div class=\"header-actions\">\n            <button *ngIf=\"showCloseIcon\" mat-icon-button type=\"button\" class=\"close\" (click)=\"onClose()\">\n                <mat-icon>close</mat-icon>\n            </button>\n        </div>\n    </mat-card-title>\n    <mat-card-content>\n        <h2 id=\"title\" *ngIf=\"horizontal && title\">{{title}}</h2>\n        <ng-content></ng-content>\n    </mat-card-content>\n    <mat-card-actions *ngIf=\"actions\">\n        <span *ngFor=\"let action of actions\">\n            <button mat-button type=\"button\" *ngIf=\"action.text\" (click)=\"action.action()\" class=\"with-icon\" [attr.data-icon]=\"action.icon\">\n                {{action.text}}\n            </button>\n            <button mat-icon-button type=\"button\" *ngIf=\"action.icon && !action.text\" [class.action-button]=\"!action.type\" (click)=\"action.action()\">\n                <mat-icon *ngIf=\"action.icon\">{{action.icon}}</mat-icon>\n            </button>\n        </span>\n    </mat-card-actions>\n    <mat-card-actions *ngIf=\"!actions && actionsTemplate\">\n\t\t<ng-template [ngTemplateOutlet]=\"actionsTemplate\"></ng-template>\n\t</mat-card-actions>\n</mat-card>\n", styles: ["deja-message-box{display:block;border-radius:3px;overflow:hidden;background-color:transparent}deja-message-box #msgbox{border:0;margin:0;padding:0;display:block;border-radius:3px}deja-message-box #msgbox>.mat-card-title{text-transform:uppercase;align-items:center;display:flex;margin:0;padding:1rem 0rem 0rem 1.2rem;font-size:1rem}deja-message-box #msgbox>.mat-card-title #icon{margin-right:.3rem}deja-message-box #msgbox>.mat-card-title .header-actions{position:absolute;top:0;right:0}deja-message-box #msgbox>.mat-card-content{margin:0;overflow:hidden;font-weight:300;padding:.5rem .75rem .75rem 1.3rem}deja-message-box #msgbox>.mat-card-content h2{font-size:1rem;margin:0;font-weight:500;text-transform:uppercase;line-height:1.5rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}deja-message-box #msgbox>.mat-card-actions{align-items:center;display:flex;justify-content:flex-end;margin:0;padding:.5rem}deja-message-box[horizontal] #msgbox{align-items:stretch;display:flex;flex-direction:row;padding:0;position:relative}deja-message-box[horizontal] #msgbox>.mat-card-title{align-items:center;display:flex;flex:0 0 auto;justify-content:center;margin:0;text-align:center;padding:.5rem 0rem .5rem .8rem}deja-message-box[horizontal] #msgbox>.mat-card-title #icon{margin:0}deja-message-box[horizontal] #msgbox>.mat-card-content{align-self:center;flex:1 1 auto;padding:.75rem}deja-message-box[horizontal] #msgbox>.mat-card-actions{margin:0;padding:0;position:absolute;right:0;top:0}deja-message-box[horizontal] #msgbox>.mat-card-actions [mat-icon-button] mat-icon{font-size:1rem}\n"] }]
        }], propDecorators: { close: [{
                type: Output
            }], type: [{
                type: Input
            }], title: [{
                type: Input
            }], icon: [{
                type: Input
            }], actions: [{
                type: Input
            }], actionsTemplate: [{
                type: ContentChild,
                args: ['actionsTemplate']
            }], horizontal: [{
                type: Input
            }], showCloseIcon: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 