import { Host, h } from "@stencil/core";
export class SpwToastController {
    constructor() {
        /**
         * Position du conteneur de toasts sur l'écran.
         * Valeurs: 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center'
         */
        this.position = 'bottom-right';
    }
    /**
     * Crée et affiche un nouveau toast.
     * @returns la référence à l'élément spw-toast créé
     */
    async create(options) {
        var _a;
        const toast = document.createElement('spw-toast');
        if (options.heading)
            toast.heading = options.heading;
        if (options.message)
            toast.message = options.message;
        if (options.linkLabel)
            toast.linkLabel = options.linkLabel;
        if (options.linkHref)
            toast.linkHref = options.linkHref;
        if (options.icon)
            toast.icon = options.icon;
        toast.variant = (_a = options.variant) !== null && _a !== void 0 ? _a : 'default';
        toast.duration = options.duration !== undefined ? options.duration : 5000;
        toast.dismissable = options.dismissable !== undefined ? options.dismissable : true;
        if (options.onLinkClick) {
            toast.addEventListener('spwToastLinkClick', options.onLinkClick);
        }
        this.stackEl.appendChild(toast);
        return toast;
    }
    /**
     * Ferme tous les toasts affichés.
     */
    async dismissAll() {
        const toasts = Array.from(this.stackEl.querySelectorAll('spw-toast'));
        await Promise.all(toasts.map(t => { var _a; return (_a = t.dismiss) === null || _a === void 0 ? void 0 : _a.call(t); }));
    }
    render() {
        return (h(Host, { key: 'b320fb0051b98993b6d40809ac3c4eb8f9607d43' }, h("div", { key: '6709e4ece4e9f39f0c1e53e78331814b5281aa43', class: {
                'spw-toast-controller__stack': true,
                [`spw-toast-controller__stack--${this.position}`]: true,
            }, "aria-label": "Notifications", ref: el => (this.stackEl = el) })));
    }
    static get is() { return "spw-toast-controller"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["spw-toast-controller.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["spw-toast-controller.css"]
        };
    }
    static get properties() {
        return {
            "position": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center'",
                    "resolved": "\"bottom-center\" | \"bottom-left\" | \"bottom-right\" | \"top-center\" | \"top-left\" | \"top-right\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Position du conteneur de toasts sur l'\u00E9cran.\nValeurs: 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center'"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "position",
                "defaultValue": "'bottom-right'"
            }
        };
    }
    static get methods() {
        return {
            "create": {
                "complexType": {
                    "signature": "(options: SpwToastOptions) => Promise<HTMLElement>",
                    "parameters": [{
                            "name": "options",
                            "type": "SpwToastOptions",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "HTMLElement": {
                            "location": "global",
                            "id": "global::HTMLElement"
                        },
                        "SpwToastOptions": {
                            "location": "local",
                            "path": "/Users/pectonite/Desktop/SPW/spw-design-system/packages/spw-stencil-library/src/components/spw-toast/spw-toast-controller/spw-toast-controller.tsx",
                            "id": "src/components/spw-toast/spw-toast-controller/spw-toast-controller.tsx::SpwToastOptions"
                        }
                    },
                    "return": "Promise<HTMLElement>"
                },
                "docs": {
                    "text": "Cr\u00E9e et affiche un nouveau toast.",
                    "tags": [{
                            "name": "returns",
                            "text": "la r\u00E9f\u00E9rence \u00E0 l'\u00E9l\u00E9ment spw-toast cr\u00E9\u00E9"
                        }]
                }
            },
            "dismissAll": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Ferme tous les toasts affich\u00E9s.",
                    "tags": []
                }
            }
        };
    }
}
