/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
import { Component } from '@angular/core';
import { transition, trigger, useAnimation } from '@angular/animations';
import { fadeIn, fadeOut } from 'ng-animate';
import { LanguageStore } from '../../store/language/language.store';
import { MessageService } from '../../services/message/message.service';
import * as i0 from "@angular/core";
import * as i1 from "../../services/message/message.service";
import * as i2 from "../../store/language/language.store";
import * as i3 from "@angular/common";
function MessageUiComponent_div_0_div_1_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const message_r5 = i0.ɵɵnextContext().$implicit;
    const appStrings_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(appStrings_r1[message_r5.labelKey] || message_r5.labelKey || "");
} }
function MessageUiComponent_div_0_div_1_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const message_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(message_r5.text);
} }
function MessageUiComponent_div_0_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵlistener("click", function MessageUiComponent_div_0_div_1_div_1_Template_div_click_0_listener() { const restoredCtx = i0.ɵɵrestoreView(_r12); const message_r5 = restoredCtx.$implicit; const ctx_r11 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r11.close(message_r5)); });
    i0.ɵɵtemplate(1, MessageUiComponent_div_0_div_1_div_1_ng_container_1_Template, 2, 1, "ng-container", 6);
    i0.ɵɵtemplate(2, MessageUiComponent_div_0_div_1_div_1_ng_container_2_Template, 2, 1, "ng-container", 6);
    i0.ɵɵelementStart(3, "a", 7);
    i0.ɵɵlistener("click", function MessageUiComponent_div_0_div_1_div_1_Template_a_click_3_listener() { const restoredCtx = i0.ɵɵrestoreView(_r12); const message_r5 = restoredCtx.$implicit; const ctx_r13 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r13.close(message_r5)); });
    i0.ɵɵelementStart(4, "span", 8);
    i0.ɵɵtext(5, "\u00D7");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const message_r5 = ctx.$implicit;
    i0.ɵɵclassMapInterpolate1("message ", message_r5.type, " alert-dismissible fade show shadow");
    i0.ɵɵproperty("@fade", undefined);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r5.labelKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r5.text && !message_r5.labelKey);
} }
function MessageUiComponent_div_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵtemplate(1, MessageUiComponent_div_0_div_1_div_1_Template, 6, 6, "div", 4);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const items_r3 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", items_r3);
} }
function MessageUiComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, MessageUiComponent_div_0_div_1_Template, 2, 1, "div", 2);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 1, ctx_r0.messages$));
} }
class MessageUiComponent {
    constructor(messageService, languages) {
        this.messageService = messageService;
        this.languages = languages;
        this.appStrings$ = languages.appStrings$;
    }
    ngOnInit() {
        this.messages$ = this.messageService.messages$;
    }
    close(message) {
        this.messageService.contains(message, true);
    }
    static { this.ɵfac = function MessageUiComponent_Factory(t) { return new (t || MessageUiComponent)(i0.ɵɵdirectiveInject(i1.MessageService), i0.ɵɵdirectiveInject(i2.LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MessageUiComponent, selectors: [["scrm-message-ui"]], decls: 2, vars: 3, consts: [["class", "container-fluid alert-fixed message-wrapper", 4, "ngIf"], [1, "container-fluid", "alert-fixed", "message-wrapper"], ["class", "d-flex justify-content-center flex-column align-items-center message-container", 4, "ngIf"], [1, "d-flex", "justify-content-center", "flex-column", "align-items-center", "message-container"], ["role", "alert", 3, "class", "click", 4, "ngFor", "ngForOf"], ["role", "alert", 3, "click"], [4, "ngIf"], ["type", "button", "data-dismiss", "alert", "aria-label", "Close", 1, "close", 3, "click"], ["aria-hidden", "true"]], template: function MessageUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MessageUiComponent_div_0_Template, 3, 3, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.appStrings$));
        } }, dependencies: [i3.NgForOf, i3.NgIf, i3.AsyncPipe], encapsulation: 2, data: { animation: [
                trigger('fade', [
                    transition(':enter', useAnimation(fadeIn, {
                        params: { timing: 0.5, delay: 0 }
                    })),
                    transition(':leave', useAnimation(fadeOut, {
                        params: { timing: 0.5, delay: 0 }
                    })),
                ])
            ] } }); }
}
export { MessageUiComponent };
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-message-ui', animations: [
                    trigger('fade', [
                        transition(':enter', useAnimation(fadeIn, {
                            params: { timing: 0.5, delay: 0 }
                        })),
                        transition(':leave', useAnimation(fadeOut, {
                            params: { timing: 0.5, delay: 0 }
                        })),
                    ])
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"container-fluid alert-fixed message-wrapper\" *ngIf=\"(appStrings$ | async) as appStrings\">\n    <div class=\"d-flex justify-content-center flex-column align-items-center message-container\"\n         *ngIf=\"(messages$ | async) as items\">\n        <div *ngFor=\"let message of items\"\n             (click)=\"close(message)\"\n             class=\"message {{ message.type }} alert-dismissible fade show shadow\"\n             [@fade]\n             role=\"alert\">\n            <ng-container *ngIf=\"message.labelKey\">{{appStrings[message.labelKey] || message.labelKey || ''}}</ng-container>\n            <ng-container *ngIf=\"message.text && !message.labelKey\">{{message.text}}</ng-container>\n            <a (click)=\"close(message)\" type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">\n                <span aria-hidden=\"true\">&times;</span>\n            </a>\n        </div>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: i1.MessageService }, { type: i2.LanguageStore }]; }, null); })();
//# sourceMappingURL=data:application/json;base64, 