import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Injectable, Inject, NgModule } from '@angular/core';
import { ToastBaseComponent } from '@ironsource/fusion-ui/components/toast/common/base';
import * as i1 from '@angular/common';
import { DOCUMENT, CommonModule } from '@angular/common';
import * as i2 from '@ironsource/fusion-ui/components/icon/v1';
import { IconModule } from '@ironsource/fusion-ui/components/icon/v1';
import * as i3 from '@ironsource/fusion-ui/components/dynamic-components/v1';
import { DynamicComponentsModule } from '@ironsource/fusion-ui/components/dynamic-components/v1';
import { TOAST_HOLDER_CLASS_NAME, TOAST_LOCATION_STYLE_MAP } from '@ironsource/fusion-ui/components/toast/common/entities';
export * from '@ironsource/fusion-ui/components/toast/common/entities';
import * as i1$1 from '@ironsource/fusion-ui/services/log';
import { take } from 'rxjs/operators';

function ToastComponent_ng_container_2_div_2_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "fusion-icon", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(3);
    i0.ɵɵclassMapInterpolate1("fu-toast-icon-typed ", ctx_r5.type, "");
    i0.ɵɵadvance();
    i0.ɵɵproperty("name", ctx_r5.iconName);
} }
function ToastComponent_ng_container_2_div_2_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 13);
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵstyleProp("background-image", ctx_r6.image);
} }
function ToastComponent_ng_container_2_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵtemplate(1, ToastComponent_ng_container_2_div_2_div_1_Template, 2, 4, "div", 10)(2, ToastComponent_ng_container_2_div_2_div_2_Template, 1, 2, "div", 11);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", ctx_r4.hasIcon);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", ctx_r4.image);
} }
function ToastComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r8 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 4);
    i0.ɵɵtemplate(2, ToastComponent_ng_container_2_div_2_Template, 3, 2, "div", 5);
    i0.ɵɵelementStart(3, "div", 6);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 7)(6, "fusion-icon", 8);
    i0.ɵɵlistener("click", function ToastComponent_ng_container_2_Template_fusion_icon_click_6_listener() { i0.ɵɵrestoreView(_r8); const ctx_r7 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r7.onCloseClicked()); });
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵclassProp("fu-toast-without-icon", ctx_r1.hasIconHolder);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", !ctx_r1.hasIconHolder);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.text, " ");
} }
function ToastComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "fusion-dynamic-components", 14);
    i0.ɵɵlistener("click", function ToastComponent_ng_template_3_Template_fusion_dynamic_components_click_0_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r9.onCloseClicked()); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵproperty("configuration", ctx_r2.custom);
} }
class ToastComponent extends ToastBaseComponent {
    static { this.ɵfac = /*@__PURE__*/ (() => { let ɵToastComponent_BaseFactory; return function ToastComponent_Factory(t) { return (ɵToastComponent_BaseFactory || (ɵToastComponent_BaseFactory = i0.ɵɵgetInheritedFactory(ToastComponent)))(t || ToastComponent); }; })(); }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ToastComponent, selectors: [["fusion-toast"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 5, vars: 3, consts: [[3, "className"], ["toast", ""], [4, "ngIf", "ngIfElse"], ["customContent", ""], [1, "fu-toast"], ["class", "fu-toast-icon-holder", 4, "ngIf"], [1, "fu-toast-content"], [1, "fu-toast-close-button-holder"], ["name", "close", 1, "fu-toast-close-button", 3, "click"], [1, "fu-toast-icon-holder"], [3, "class", 4, "ngIf"], ["class", "fu-toast-image", 3, "backgroundImage", 4, "ngIf"], [3, "name"], [1, "fu-toast-image"], [3, "configuration", "click"]], template: function ToastComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0, 1);
            i0.ɵɵtemplate(2, ToastComponent_ng_container_2_Template, 7, 4, "ng-container", 2)(3, ToastComponent_ng_template_3_Template, 1, 1, "ng-template", null, 3, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            const _r3 = i0.ɵɵreference(4);
            i0.ɵɵproperty("className", ctx.locationClass);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", !ctx.custom)("ngIfElse", _r3);
        } }, dependencies: [i1.NgIf, i2.IconComponent, i3.DynamicComponentsComponent], styles: ["[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-content[_ngcontent-%COMP%]{font-size:12px;font-family:HelveticaNeue-Medium,helvetica,sans-serif;font-weight:400;letter-spacing:.04px}[_nghost-%COMP%]   *[_ngcontent-%COMP%]{box-sizing:border-box}[_nghost-%COMP%]{margin:0;padding:0;vertical-align:initial;text-align:initial}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-image[_ngcontent-%COMP%], [_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed[_ngcontent-%COMP%]{margin-left:var(--toast-icon-margin-left, 12px);width:var(--toast-icon-width, 32px);height:var(--toast-icon-height, 32px)}[_nghost-%COMP%]   .top-right[_ngcontent-%COMP%], [_nghost-%COMP%]   .top-center[_ngcontent-%COMP%], [_nghost-%COMP%]   .top-left[_ngcontent-%COMP%]{position:fixed;top:var(--toast-location-top-marging, 20px);z-index:3030}[_nghost-%COMP%]   .bottom-right[_ngcontent-%COMP%], [_nghost-%COMP%]   .bottom-center[_ngcontent-%COMP%], [_nghost-%COMP%]   .bottom-left[_ngcontent-%COMP%]{position:fixed;bottom:var(--toast-location-bottom-marging, 20px);z-index:3030;animation:_ngcontent-%COMP%_bottom-fadein .5s}@keyframes _ngcontent-%COMP%_top-fadein{0%{top:-20px;opacity:0;height:0px}to{top:20px;opacity:1;height:64px}}@keyframes _ngcontent-%COMP%_bottom-fadein{0%{bottom:-20px;opacity:0;height:0px}to{bottom:20px;opacity:1;height:64px}}@keyframes _ngcontent-%COMP%_fadein{0%{opacity:0}to{opacity:1}}@keyframes _ngcontent-%COMP%_fadeout{0%{opacity:1;height:64px}to{opacity:0;height:0;margin-top:-8px}}@keyframes _ngcontent-%COMP%_slide-out-right{0%{right:20px;opacity:1;height:64px}to{right:-340px;opacity:0;height:0}}@keyframes _ngcontent-%COMP%_slide-out-left{0%{left:20px;opacity:1;height:64px}to{left:-340px;opacity:0;height:0}}[_nghost-%COMP%]{margin-bottom:var(--toast-margin-bottom, 8px);display:block}[_nghost-%COMP%]   .fu-fadein[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_fadein .5s}[_nghost-%COMP%]   .fu-top-fadein[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_top-fadein .5s}[_nghost-%COMP%]   .fu-bottom-fadein[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_bottom-fadein .5s}[_nghost-%COMP%]   .fu-fadeout[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_fadeout .5s}[_nghost-%COMP%]   .fu-slide-out-right[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_slide-out-right .8s}[_nghost-%COMP%]   .fu-slide-out-left[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_slide-out-left .8s}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]{width:var(--toast-width, 340px);height:var(--toast-height, 64px);border:var(--toast-border, solid 1px var(--fu-light-300, #e5e7e9));border-radius:var(--toast-border-radius, 8px);background-color:var(--toast-background-color, var(--fu-white, #ffffff));box-shadow:var(--toast-box-shadow, 0 3px 4px 0 rgba(0, 0, 0, .1));display:flex;align-items:center;align-content:stretch}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]{width:56px}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed[_ngcontent-%COMP%]{border-radius:16px;border:solid 2px transparent;position:relative}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed[_ngcontent-%COMP%]   fusion-icon[_ngcontent-%COMP%]{position:absolute;top:calc(50% - 8px);left:calc(50% - 8px)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed[_ngcontent-%COMP%]   fusion-icon[_ngcontent-%COMP%]     svg{width:16px;height:16px}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed[_ngcontent-%COMP%]   fusion-icon[_ngcontent-%COMP%]     svg *{fill:var(--toast-icon-color, currentColor)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed.success[_ngcontent-%COMP%]{border-color:var(--fu-positive-200, #b4e9d2);color:var(--fu-positive-500, #22c891)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed.alert[_ngcontent-%COMP%]{border-color:var(--fu-primary-200, #c9dfff);color:var(--fu-primary-500, #3083ff)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed.error[_ngcontent-%COMP%]{border-color:var(--fu-negative-200, #ffcbce);color:var(--fu-negative-500, #ff6a63)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-icon-typed.warning[_ngcontent-%COMP%]{border-color:var(--fu-neutral-200, #ffe0a3);color:var(--fu-neutral-500, #ffb424)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-icon-holder[_ngcontent-%COMP%]   .fu-toast-image[_ngcontent-%COMP%]{background-repeat:no-repeat;background-position:center;background-size:cover}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-close-button-holder[_ngcontent-%COMP%]{width:48px;height:100%;border-left:solid 1px var(--fu-light-300, #e5e7e9);position:relative}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-close-button-holder[_ngcontent-%COMP%]   fusion-icon[class^=fu-toast-close-button][_ngcontent-%COMP%]{position:absolute;left:16px;top:calc(50% - 7px);cursor:pointer}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-close-button-holder[_ngcontent-%COMP%]   fusion-icon[class^=fu-toast-close-button][_ngcontent-%COMP%]     svg{width:14px;height:14px}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-close-button-holder[_ngcontent-%COMP%]   fusion-icon[class^=fu-toast-close-button][_ngcontent-%COMP%]     svg *{fill:var(--fu-light-500, #d2d5d8)}[_nghost-%COMP%]   .fu-toast[_ngcontent-%COMP%]   .fu-toast-content[_ngcontent-%COMP%]{width:calc(100% - 104px);padding:12px 0;line-height:1.4;color:var(--fu-light-900, #7b838c)}[_nghost-%COMP%]   .fu-toast.fu-toast-without-icon[_ngcontent-%COMP%]   .fu-toast-content[_ngcontent-%COMP%]{padding-left:24px;width:calc(100% - 48px)}[_nghost-%COMP%]   .top-left[_ngcontent-%COMP%]{left:var(--toast-location-left-margin, 20px)}[_nghost-%COMP%]   .top-center[_ngcontent-%COMP%]{left:calc(50% - var(--toast-width, 340px) / 2)}[_nghost-%COMP%]   .top-right[_ngcontent-%COMP%]{right:var(--toast-location-right-margin, 20px)}[_nghost-%COMP%]   .bottom-left[_ngcontent-%COMP%]{left:var(--toast-location-left-margin, 20px)}[_nghost-%COMP%]   .bottom-center[_ngcontent-%COMP%]{left:calc(50% - var(--toast-width, 340px) / 2)}[_nghost-%COMP%]   .bottom-right[_ngcontent-%COMP%]{right:var(--toast-location-right-margin, 20px)}"], changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastComponent, [{
        type: Component,
        args: [{ selector: 'fusion-toast', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [className]=\"locationClass\" #toast>\n    <ng-container *ngIf=\"!custom; else customContent\">\n        <div class=\"fu-toast\" [class.fu-toast-without-icon]=\"hasIconHolder\">\n            <div class=\"fu-toast-icon-holder\" *ngIf=\"!hasIconHolder\">\n                <div class=\"fu-toast-icon-typed {{ type }}\" *ngIf=\"hasIcon\">\n                    <fusion-icon [name]=\"iconName\"></fusion-icon>\n                </div>\n                <div class=\"fu-toast-image\" *ngIf=\"image\" [style.backgroundImage]=\"image\"></div>\n            </div>\n            <div class=\"fu-toast-content\">\n                {{ text }}\n            </div>\n            <div class=\"fu-toast-close-button-holder\">\n                <fusion-icon class=\"fu-toast-close-button\" name=\"close\" (click)=\"onCloseClicked()\"></fusion-icon>\n            </div>\n        </div>\n    </ng-container>\n    <ng-template #customContent>\n        <fusion-dynamic-components [configuration]=\"custom\" (click)=\"onCloseClicked()\"></fusion-dynamic-components>\n    </ng-template>\n</div>\n", styles: [":host .fu-toast .fu-toast-content{font-size:12px;font-family:HelveticaNeue-Medium,helvetica,sans-serif;font-weight:400;letter-spacing:.04px}:host *{box-sizing:border-box}:host{margin:0;padding:0;vertical-align:initial;text-align:initial}:host .fu-toast .fu-toast-icon-holder .fu-toast-image,:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed{margin-left:var(--toast-icon-margin-left, 12px);width:var(--toast-icon-width, 32px);height:var(--toast-icon-height, 32px)}:host .top-right,:host .top-center,:host .top-left{position:fixed;top:var(--toast-location-top-marging, 20px);z-index:3030}:host .bottom-right,:host .bottom-center,:host .bottom-left{position:fixed;bottom:var(--toast-location-bottom-marging, 20px);z-index:3030;animation:bottom-fadein .5s}@keyframes top-fadein{0%{top:-20px;opacity:0;height:0px}to{top:20px;opacity:1;height:64px}}@keyframes bottom-fadein{0%{bottom:-20px;opacity:0;height:0px}to{bottom:20px;opacity:1;height:64px}}@keyframes fadein{0%{opacity:0}to{opacity:1}}@keyframes fadeout{0%{opacity:1;height:64px}to{opacity:0;height:0;margin-top:-8px}}@keyframes slide-out-right{0%{right:20px;opacity:1;height:64px}to{right:-340px;opacity:0;height:0}}@keyframes slide-out-left{0%{left:20px;opacity:1;height:64px}to{left:-340px;opacity:0;height:0}}:host{margin-bottom:var(--toast-margin-bottom, 8px);display:block}:host .fu-fadein{animation:fadein .5s}:host .fu-top-fadein{animation:top-fadein .5s}:host .fu-bottom-fadein{animation:bottom-fadein .5s}:host .fu-fadeout{animation:fadeout .5s}:host .fu-slide-out-right{animation:slide-out-right .8s}:host .fu-slide-out-left{animation:slide-out-left .8s}:host .fu-toast{width:var(--toast-width, 340px);height:var(--toast-height, 64px);border:var(--toast-border, solid 1px var(--fu-light-300, #e5e7e9));border-radius:var(--toast-border-radius, 8px);background-color:var(--toast-background-color, var(--fu-white, #ffffff));box-shadow:var(--toast-box-shadow, 0 3px 4px 0 rgba(0, 0, 0, .1));display:flex;align-items:center;align-content:stretch}:host .fu-toast .fu-toast-icon-holder{width:56px}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed{border-radius:16px;border:solid 2px transparent;position:relative}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed fusion-icon{position:absolute;top:calc(50% - 8px);left:calc(50% - 8px)}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed fusion-icon ::ng-deep svg{width:16px;height:16px}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed fusion-icon ::ng-deep svg *{fill:var(--toast-icon-color, currentColor)}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed.success{border-color:var(--fu-positive-200, #b4e9d2);color:var(--fu-positive-500, #22c891)}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed.alert{border-color:var(--fu-primary-200, #c9dfff);color:var(--fu-primary-500, #3083ff)}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed.error{border-color:var(--fu-negative-200, #ffcbce);color:var(--fu-negative-500, #ff6a63)}:host .fu-toast .fu-toast-icon-holder .fu-toast-icon-typed.warning{border-color:var(--fu-neutral-200, #ffe0a3);color:var(--fu-neutral-500, #ffb424)}:host .fu-toast .fu-toast-icon-holder .fu-toast-image{background-repeat:no-repeat;background-position:center;background-size:cover}:host .fu-toast .fu-toast-close-button-holder{width:48px;height:100%;border-left:solid 1px var(--fu-light-300, #e5e7e9);position:relative}:host .fu-toast .fu-toast-close-button-holder fusion-icon[class^=fu-toast-close-button]{position:absolute;left:16px;top:calc(50% - 7px);cursor:pointer}:host .fu-toast .fu-toast-close-button-holder fusion-icon[class^=fu-toast-close-button] ::ng-deep svg{width:14px;height:14px}:host .fu-toast .fu-toast-close-button-holder fusion-icon[class^=fu-toast-close-button] ::ng-deep svg *{fill:var(--fu-light-500, #d2d5d8)}:host .fu-toast .fu-toast-content{width:calc(100% - 104px);padding:12px 0;line-height:1.4;color:var(--fu-light-900, #7b838c)}:host .fu-toast.fu-toast-without-icon .fu-toast-content{padding-left:24px;width:calc(100% - 48px)}:host .top-left{left:var(--toast-location-left-margin, 20px)}:host .top-center{left:calc(50% - var(--toast-width, 340px) / 2)}:host .top-right{right:var(--toast-location-right-margin, 20px)}:host .bottom-left{left:var(--toast-location-left-margin, 20px)}:host .bottom-center{left:calc(50% - var(--toast-width, 340px) / 2)}:host .bottom-right{right:var(--toast-location-right-margin, 20px)}\n"] }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ToastComponent, { className: "ToastComponent", filePath: "toast.component.ts", lineNumber: 10 }); })();

// @dynamic
class ToastService {
    constructor(logService, appRef, cfr, rendererFactory, injector, document) {
        this.logService = logService;
        this.appRef = appRef;
        this.cfr = cfr;
        this.rendererFactory = rendererFactory;
        this.injector = injector;
        this.document = document;
        this.renderer = rendererFactory.createRenderer(null, null);
    }
    show(configuration) {
        // prepare toasts holder element (with location)
        const toastLocation = configuration.location || 'top-right';
        const toastHostElement = this.ensureHostElement(toastLocation);
        // Create a component reference from the component
        const toastComponentRef = this.createToastComponentRef({ ...configuration, ...{ location: toastLocation } });
        // Attach component to the appRef so that it's inside the ng component tree
        this.appRef.attachView(toastComponentRef.hostView);
        // append toast element to host;
        this.appendElementLocation(toastLocation, toastHostElement, toastComponentRef.hostView.rootNodes[0]);
        // remove it from the component tree and from the DOM on close
        this.removeOnClose(toastComponentRef);
    }
    createToastComponentRef(toastConfiguration) {
        const toastComponentRef = this.cfr.resolveComponentFactory(ToastComponent).create(this.injector);
        // set component's input props
        toastComponentRef.instance.shownByService = true;
        toastComponentRef.instance.configuration = toastConfiguration;
        return toastComponentRef;
    }
    removeOnClose(componentRef) {
        componentRef.instance.toastClosed.pipe(take(1)).subscribe(() => {
            this.appRef.detachView(componentRef.hostView);
            componentRef.destroy();
        });
    }
    appendElementLocation(location, toastHostElement, toastElement) {
        if (location.startsWith('top-')) {
            toastHostElement.prepend(toastElement);
        }
        else {
            toastHostElement.appendChild(toastElement);
        }
    }
    ensureHostElement(location) {
        let toastsHolderElement = this.document.body.querySelector(`.${TOAST_HOLDER_CLASS_NAME}`);
        let useLocation = location;
        if (!toastsHolderElement) {
            toastsHolderElement = this.renderer.createElement('div');
            if (!TOAST_LOCATION_STYLE_MAP.hasOwnProperty(location)) {
                this.logService.error(new Error(`Toast holder style configuration for location ${useLocation} not found. Will use default.`));
                useLocation = 'top-right';
            }
            this.setStyleToElement(toastsHolderElement, { ...TOAST_LOCATION_STYLE_MAP.common, ...TOAST_LOCATION_STYLE_MAP[useLocation] }, useLocation);
            this.renderer.appendChild(this.document.body, toastsHolderElement);
        }
        return toastsHolderElement;
    }
    setStyleToElement(element, toastHolderStyleMap, location) {
        Object.keys(toastHolderStyleMap).forEach(key => {
            this.renderer.setStyle(element, key, toastHolderStyleMap[key]);
        });
        this.renderer.addClass(element, TOAST_HOLDER_CLASS_NAME);
        this.renderer.addClass(element, location);
    }
    static { this.ɵfac = function ToastService_Factory(t) { return new (t || ToastService)(i0.ɵɵinject(i1$1.LogService), i0.ɵɵinject(i0.ApplicationRef), i0.ɵɵinject(i0.ComponentFactoryResolver), i0.ɵɵinject(i0.RendererFactory2), i0.ɵɵinject(i0.Injector), i0.ɵɵinject(DOCUMENT)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ToastService, factory: ToastService.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], () => [{ type: i1$1.LogService }, { type: i0.ApplicationRef }, { type: i0.ComponentFactoryResolver }, { type: i0.RendererFactory2 }, { type: i0.Injector }, { type: Document, decorators: [{
                type: Inject,
                args: [DOCUMENT]
            }] }], null); })();

class ToastModule {
    static { this.ɵfac = function ToastModule_Factory(t) { return new (t || ToastModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ToastModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule, IconModule, DynamicComponentsModule, IconModule] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastModule, [{
        type: NgModule,
        args: [{
                declarations: [ToastComponent],
                imports: [CommonModule, IconModule, DynamicComponentsModule],
                exports: [ToastComponent, IconModule]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ToastModule, { declarations: [ToastComponent], imports: [CommonModule, IconModule, DynamicComponentsModule], exports: [ToastComponent, IconModule] }); })();

/**
 * Generated bundle index. Do not edit.
 */

export { ToastComponent, ToastModule, ToastService };
//# sourceMappingURL=ironsource-fusion-ui-components-toast-v2.mjs.map
