import * as i0 from '@angular/core';
import { InjectionToken, inject, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Injectable, NgModule } from '@angular/core';
import { BaseToastDurationDismissibleRef, BaseToastDurationDismissibleConfig, BaseToastDurationDismissibleContainerComponent, BaseDismissibleToastService, ToastBottomCenterPosition } from '@fundamental-ngx/cdk/utils';
import * as i1 from '@angular/cdk/portal';
import { PortalModule } from '@angular/cdk/portal';
import { OverlayModule, OverlayContainer } from '@angular/cdk/overlay';

/** Injection token that can be used to access the data that was passed in to a Message Toast. */
const MESSAGE_TOAST_DATA = new InjectionToken('MessageToastData');
const MESSAGE_TOAST_CONFIG = new InjectionToken('MessageToastConfig');

class MessageToastRef extends BaseToastDurationDismissibleRef {
    /** @hidden */
    constructor(containerInstance, overlayRef, positionStrategy) {
        super(containerInstance, overlayRef, positionStrategy);
        this.containerInstance = containerInstance;
        this.overlayRef = overlayRef;
        this.positionStrategy = positionStrategy;
        /** Observable that is triggered when the message toast has timed out. */
        this.afterTimeout = this._afterDismissed$.asObservable();
        this.data = this.containerInstance.config.data;
    }
}

class MessageToastTextComponent {
    constructor() {
        /** @hidden */
        this.toastRef = inject(MessageToastRef);
        /** @hidden */
        this.message = inject(MESSAGE_TOAST_DATA);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastTextComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.0", type: MessageToastTextComponent, isStandalone: true, selector: "fd-message-toast-text", ngImport: i0, template: `{{ message }}`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastTextComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'fd-message-toast-text',
                    template: `{{ message }}`,
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    encapsulation: ViewEncapsulation.None
                }]
        }] });

/**
 * Configuration used when opening a Message Toast.
 */
class MessageToastConfig extends BaseToastDurationDismissibleConfig {
    constructor() {
        super(...arguments);
        /** Whether the Message Toast should be animated. */
        this.animated = false;
    }
}

class MessageToastComponent extends BaseToastDurationDismissibleContainerComponent {
    /** @hidden */
    constructor() {
        super(inject(MessageToastConfig));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.0", type: MessageToastComponent, isStandalone: true, selector: "fd-message-toast", host: { attributes: { "role": "alert", "tabindex": "-1" }, properties: { "style.width": "width", "style.min-width": "minWidth", "style.max-width": "maxWidth", "style.height": "height", "style.min-height": "minHeight", "style.max-height": "maxHeight", "attr.aria-label": "ariaLabel", "attr.aria-live": "\"polite\"", "attr.id": "id" }, classAttribute: "fd-message-toast" }, usesInheritance: true, ngImport: i0, template: `<ng-template cdkPortalOutlet></ng-template>`, isInline: true, styles: [".cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed;z-index:1000}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}.cdk-overlay-backdrop{position:absolute;inset:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation;z-index:1000;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}.cdk-overlay-backdrop-showing{opacity:1}@media(forced-colors:active){.cdk-overlay-backdrop-showing{opacity:.6}}.cdk-overlay-dark-backdrop{background:#00000052}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}.cdk-overlay-popover{background:none;border:none;padding:0;outline:0;overflow:visible;position:fixed;pointer-events:none;white-space:normal;color:inherit;text-decoration:none;width:100%;height:100%;inset:0 auto auto 0}.cdk-overlay-popover::backdrop{display:none}.cdk-overlay-popover .cdk-overlay-backdrop{position:fixed;z-index:auto}.fd-message-toast{background-color:var(--sapIndicationColor_9_Background);border:0;border-radius:var(--sapElement_BorderCornerRadius);-webkit-box-shadow:var(--sapContent_Lite_Shadow);box-shadow:var(--sapContent_Lite_Shadow);-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);color:var(--sapContent_ContrastTextColor);display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;max-width:15rem;padding-block:0;padding-block:1rem;padding-inline:0;padding-inline:1rem;text-align:center;width:auto}.fd-message-toast:after,.fd-message-toast:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}\n/*!\n * Fundamental Library Styles v0.41.7\n * Copyright (c) 2026 SAP SE or an SAP affiliate company.\n * Licensed under Apache License 2.0 (https://github.com/SAP/fundamental-styles/blob/main/LICENSE)\n */\n"], dependencies: [{ kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i1.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fd-message-toast', template: `<ng-template cdkPortalOutlet></ng-template>`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
                        '[style.width]': 'width',
                        '[style.min-width]': 'minWidth',
                        '[style.max-width]': 'maxWidth',
                        '[style.height]': 'height',
                        '[style.min-height]': 'minHeight',
                        '[style.max-height]': 'maxHeight',
                        '[attr.aria-label]': 'ariaLabel',
                        '[attr.aria-live]': '"polite"',
                        '[attr.id]': 'id',
                        role: 'alert',
                        tabindex: '-1',
                        class: 'fd-message-toast'
                    }, imports: [PortalModule], styles: [".cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed;z-index:1000}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}.cdk-overlay-backdrop{position:absolute;inset:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation;z-index:1000;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}.cdk-overlay-backdrop-showing{opacity:1}@media(forced-colors:active){.cdk-overlay-backdrop-showing{opacity:.6}}.cdk-overlay-dark-backdrop{background:#00000052}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}.cdk-overlay-popover{background:none;border:none;padding:0;outline:0;overflow:visible;position:fixed;pointer-events:none;white-space:normal;color:inherit;text-decoration:none;width:100%;height:100%;inset:0 auto auto 0}.cdk-overlay-popover::backdrop{display:none}.cdk-overlay-popover .cdk-overlay-backdrop{position:fixed;z-index:auto}.fd-message-toast{background-color:var(--sapIndicationColor_9_Background);border:0;border-radius:var(--sapElement_BorderCornerRadius);-webkit-box-shadow:var(--sapContent_Lite_Shadow);box-shadow:var(--sapContent_Lite_Shadow);-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);color:var(--sapContent_ContrastTextColor);display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;max-width:15rem;padding-block:0;padding-block:1rem;padding-inline:0;padding-inline:1rem;text-align:center;width:auto}.fd-message-toast:after,.fd-message-toast:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}\n/*!\n * Fundamental Library Styles v0.41.7\n * Copyright (c) 2026 SAP SE or an SAP affiliate company.\n * Licensed under Apache License 2.0 (https://github.com/SAP/fundamental-styles/blob/main/LICENSE)\n */\n"] }]
        }], ctorParameters: () => [] });

class MessageToastService extends BaseDismissibleToastService {
    constructor() {
        super(...arguments);
        /** @hidden */
        this.toastTextComponent = MessageToastTextComponent;
        /** @hidden */
        this.toastContainerComponent = MessageToastComponent;
        /** @hidden */
        this.toastDataInjectionToken = MESSAGE_TOAST_DATA;
        /** @hidden */
        this.toastPositionStrategy = ToastBottomCenterPosition;
        /** @hidden */
        this.defaultConfig = inject(MESSAGE_TOAST_CONFIG);
    }
    /**
     * Opens toast with a provided message.
     * @param message Message to display in a Message Toast.
     * @param config Toast configuration.
     * @returns Toast reference.
     */
    open(message, config) {
        if (message instanceof TemplateRef) {
            return this.openFromTemplate(message, config ?? this.defaultConfig);
        }
        else if (typeof message === 'string') {
            return this.openFromString(message, config);
        }
        return this.openFromComponent(message, config ?? this.defaultConfig);
    }
    /**
     * Opens a Toast with provided message as a content.
     * @param message string to render inside a Toast.
     * @param config Toast configuration
     */
    openFromString(message, config) {
        const mergedConfig = { ...this.defaultConfig, ...config };
        mergedConfig.data = message;
        return this.openFromComponent(this.toastTextComponent, mergedConfig);
    }
    /**
     * Opens a Toast with provided component inside.
     * @param component Component to render inside a Toast.
     * @param config Toast configuration.
     * @returns Toast reference.
     */
    openFromComponent(component, config) {
        return this._attach(component, config);
    }
    /**
     * Opens a Toast with provided Template Reference.
     * @param template Template Reference to render inside a Toast.
     * @param config Toast configuration.
     * @returns Toast reference.
     */
    openFromTemplate(template, config) {
        return this._attach(template, config);
    }
    /** @hidden */
    getContainerComponentProviders(config) {
        return [{ provide: MessageToastConfig, useValue: config }];
    }
    /** @hidden */
    getContentComponentProviders(config, messageToastRef) {
        return [
            { provide: MessageToastRef, useValue: messageToastRef },
            { provide: this.toastDataInjectionToken, useValue: config.data }
        ];
    }
    /** @hidden */
    getToastRef(containerRef, overlayRef, positionStrategy = ToastBottomCenterPosition) {
        return new MessageToastRef(containerRef, overlayRef, positionStrategy);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastService, decorators: [{
            type: Injectable
        }] });

/**
 * Function allows to provide custom configuration for Message Toast.
 * @param config
 * @returns
 */
function provideMessageToastConfig(config) {
    return {
        provide: MESSAGE_TOAST_CONFIG,
        useValue: config
    };
}

/**
 * @deprecated
 * Use direct imports of components and directives.
 */
class MessageToastModule {
    /**
     * Allows configuring module on a global level with custom configuration.
     * @param config User's custom configuration.
     */
    static withConfig(config) {
        return {
            ngModule: MessageToastModule,
            providers: [provideMessageToastConfig(config)]
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: MessageToastModule, imports: [PortalModule, OverlayModule, MessageToastComponent, MessageToastTextComponent], exports: [MessageToastComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastModule, providers: [MessageToastService, { provide: MESSAGE_TOAST_CONFIG, useValue: new MessageToastConfig() }], imports: [PortalModule, OverlayModule, MessageToastComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: MessageToastModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [PortalModule, OverlayModule, MessageToastComponent, MessageToastTextComponent],
                    exports: [MessageToastComponent],
                    providers: [MessageToastService, { provide: MESSAGE_TOAST_CONFIG, useValue: new MessageToastConfig() }]
                }]
        }] });

/**
 * Custom overlay container for CDK Overlay.
 */
class ToastOverlayContainer extends OverlayContainer {
    /**
     * This method returns the overlay container element. It will lazily
     * create the element the first time it is called to facilitate using
     * the container in non-browser environments.
     * @returns the container element
     */
    getContainerElement() {
        const containerElement = super.getContainerElement();
        containerElement.classList.add('fd-message-toast-container');
        return containerElement;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToastOverlayContainer, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToastOverlayContainer }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ToastOverlayContainer, decorators: [{
            type: Injectable
        }] });

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

export { MESSAGE_TOAST_CONFIG, MESSAGE_TOAST_DATA, MessageToastComponent, MessageToastConfig, MessageToastModule, MessageToastRef, MessageToastService, MessageToastTextComponent, ToastOverlayContainer, provideMessageToastConfig };
//# sourceMappingURL=fundamental-ngx-core-message-toast.mjs.map
