import { Input, Component } from '@angular/core';
import { AlToastService } from '../services/al-toast.service';
import { MessageService } from 'primeng-lts/api';
import * as i0 from "@angular/core";
import * as i1 from "../services/al-toast.service";
import * as i2 from "primeng-lts/api";
import * as i3 from "primeng-lts/toast";
import * as i4 from "@angular/common";
function AlToastComponent_ng_template_1_i_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i");
} if (rf & 2) {
    const message_r1 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵclassMapInterpolate1("p-col-fixed toast-icon pi ", message_r1.data.iconClass, "");
} }
function AlToastComponent_ng_template_1_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const message_r1 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(message_r1.data.title);
} }
function AlToastComponent_ng_template_1_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const message_r1 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(message_r1.data.message);
} }
function AlToastComponent_ng_template_1_div_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 12);
} if (rf & 2) {
    const message_r1 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("innerHTML", message_r1.data.html, i0.ɵɵsanitizeHtml);
} }
const _c0 = function (a0) { return { "disabled": a0 }; };
function AlToastComponent_ng_template_1_div_7_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵelementStart(1, "a", 16);
    i0.ɵɵlistener("click", function AlToastComponent_ng_template_1_div_7_div_1_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r14); const button_r12 = ctx.$implicit; const ctx_r13 = i0.ɵɵnextContext(3); return ctx_r13.clickEvent(button_r12); });
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "uppercase");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const button_r12 = ctx.$implicit;
    i0.ɵɵclassMapInterpolate1("button-container ", button_r12.class ? button_r12.class : "", "");
    i0.ɵɵstyleProp("text-align", button_r12.textAlign);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(10, _c0, button_r12.disabled));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("id", button_r12.key);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 8, button_r12.label));
} }
function AlToastComponent_ng_template_1_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵtemplate(1, AlToastComponent_ng_template_1_div_7_div_1_Template, 4, 12, "div", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const message_r1 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", message_r1.data.buttons);
} }
function AlToastComponent_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵtemplate(1, AlToastComponent_ng_template_1_i_1_Template, 1, 3, "i", 3);
    i0.ɵɵelementStart(2, "div", 4);
    i0.ɵɵelementStart(3, "div", 5);
    i0.ɵɵtemplate(4, AlToastComponent_ng_template_1_div_4_Template, 2, 1, "div", 6);
    i0.ɵɵtemplate(5, AlToastComponent_ng_template_1_div_5_Template, 2, 1, "div", 7);
    i0.ɵɵtemplate(6, AlToastComponent_ng_template_1_div_6_Template, 1, 1, "div", 8);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(7, AlToastComponent_ng_template_1_div_7_Template, 2, 1, "div", 9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const message_r1 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r1.data.iconClass);
    i0.ɵɵadvance(2);
    i0.ɵɵstyleProp("text-align", message_r1.data.textAlign);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r1.data.title);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r1.data.message);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r1.data.html);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r1.data.buttons);
} }
export class AlToastComponent {
    constructor(alToastService, messageService) {
        this.alToastService = alToastService;
        this.messageService = messageService;
        this.onShow = (alToastMessage) => {
            this.messageService.add(alToastMessage);
        };
        this.onClose = () => {
            this.messageService.clear(this.key);
        };
        if (!this.position) {
            this.position = 'bottom-center';
        }
    }
    ngOnInit() {
        this.showEmiter = this.alToastService.getShowEmitter(this.key).subscribe(this.onShow);
        this.closeEmiter = this.alToastService.getCloseEmitter(this.key).subscribe(this.onClose);
    }
    ngOnDestroy() {
        if (this.showEmiter) {
            this.showEmiter.unsubscribe();
        }
        if (this.closeEmiter) {
            this.closeEmiter.unsubscribe();
        }
        this.alToastService.cleanEmitters(this.key);
    }
    clickEvent(button) {
        this.alToastService.emitButtonClicked(this.key, button);
    }
}
/** @nocollapse */ AlToastComponent.ɵfac = function AlToastComponent_Factory(t) { return new (t || AlToastComponent)(i0.ɵɵdirectiveInject(i1.AlToastService), i0.ɵɵdirectiveInject(i2.MessageService)); };
/** @nocollapse */ AlToastComponent.ɵcmp = i0.ɵɵdefineComponent({ type: AlToastComponent, selectors: [["al-toast"]], inputs: { key: "key", position: "position" }, decls: 2, vars: 2, consts: [["styleClass", "custom-toast", 3, "position", "key"], ["pTemplate", "message"], [1, "p-grid", "p-nogutter"], [3, "class", 4, "ngIf"], [1, "p-col", "p-nogutter"], [1, "ui-toast-content", "p-col"], ["class", "ui-toast-title", 4, "ngIf"], ["class", "ui-toast-message-text", 4, "ngIf"], ["class", "ui-toast-message-html", 3, "innerHTML", 4, "ngIf"], ["class", "p-grid toast-buttons p-nogutter", 4, "ngIf"], [1, "ui-toast-title"], [1, "ui-toast-message-text"], [1, "ui-toast-message-html", 3, "innerHTML"], [1, "p-grid", "toast-buttons", "p-nogutter"], [3, "class", "text-align", "ngClass", 4, "ngFor", "ngForOf"], [3, "ngClass"], [3, "id", "click"]], template: function AlToastComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "p-toast", 0);
        i0.ɵɵtemplate(1, AlToastComponent_ng_template_1_Template, 8, 7, "ng-template", 1);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵproperty("position", ctx.position)("key", ctx.key);
    } }, directives: [i3.Toast, i2.PrimeTemplate, i4.NgIf, i4.NgForOf, i4.NgClass], pipes: [i4.UpperCasePipe], styles: ["[_nghost-%COMP%]     .custom-toast .ui-toast-message{color:#fff;background:#535353;padding:12px 15px}[_nghost-%COMP%]     .custom-toast .ui-toast-message.ui-toast-message-success{background:#81c783}[_nghost-%COMP%]     .custom-toast .ui-toast-message.ui-toast-message-error{background:#ef534f}[_nghost-%COMP%]     .custom-toast .ui-toast-message.ui-toast-message-warn{background:#f78c1e}[_nghost-%COMP%]     .custom-toast .ui-toast-content{margin:0 10px}[_nghost-%COMP%]     .custom-toast .ui-toast-content .ui-toast-message-html a{cursor:pointer;color:#ffb74d}[_nghost-%COMP%]     .custom-toast .ui-toast-content .ui-toast-message-html .material-icons{vertical-align:bottom}[_nghost-%COMP%]     .custom-toast .ui-toast-icon{position:inherit}[_nghost-%COMP%]     .custom-toast.ui-toast{width:50%}[_nghost-%COMP%]     .custom-toast.ui-toast-bottom-center{margin-left:-25%}[_nghost-%COMP%]     .custom-toast .toast-buttons{margin-top:24px}[_nghost-%COMP%]     .custom-toast .toast-buttons .button-container{padding:5px 10px}[_nghost-%COMP%]     .custom-toast .toast-buttons .button-container a{cursor:pointer;color:#ffb74d;font-weight:600;padding:0}[_nghost-%COMP%]     .custom-toast .toast-buttons .button-container.secondaryButton a{color:#868686}[_nghost-%COMP%]     .custom-toast .toast-buttons .button-container.tertiaryButton a{color:#ededed}[_nghost-%COMP%]     .custom-toast .toast-icon{font-size:24px;padding:0}"] });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(AlToastComponent, [{
        type: Component,
        args: [{
                selector: 'al-toast',
                templateUrl: './al-toast.component.html',
                styleUrls: ['./al-toast.component.scss']
            }]
    }], function () { return [{ type: i1.AlToastService }, { type: i2.MessageService }]; }, { key: [{
            type: Input
        }], position: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 