import { Host, h } from "@stencil/core";
import { cls } from "../../utils/helpers";
import { Lang } from "../../services/lang";
export class XNotification {
    constructor() {
        this.interval = undefined;
        this.color = 'default';
        this.icon = undefined;
        this.visible = false;
        this.timer = undefined;
    }
    /**
     * On component loaded action
     */
    componentDidLoad() {
        this.show();
        if (this.interval) {
            const intervalElement = this.el.querySelector('.notification-with-interval');
            if (intervalElement) {
                intervalElement.style.transitionDuration = this.interval + 's';
                setTimeout(() => {
                    intervalElement.style.width = '0%';
                }, 500);
            }
            this.timer = setTimeout(() => {
                this.close();
            }, this.interval * 1000);
        }
    }
    /**
     * Show notification element
     */
    async show() {
        this.visible = true;
    }
    /**
     * Close notification element
     */
    async close() {
        this.onClose.emit();
        this.el.classList.add('notification-hidding');
        setTimeout(() => {
            this.visible = false;
            this.el.classList.remove('notification-hidding');
            this.el.remove();
        }, 400);
    }
    /**
     * Render element
     */
    render() {
        return h(Host, { key: '96c068932145e68a5aaa231789afe4f2fdc02ce3', class: cls(`notification-${this.color}`, { 'notification-with-icon': this.icon, 'notification-show': this.visible }), role: "alert", "aria-live": "assertive", "aria-atomic": "true" }, this.interval ? h("div", { class: "notification-with-interval" }) : '', this.icon && h("x-animate", { key: 'ec6d66cc674544927116b3270eb21c8488d663ea', name: "fade-in-left", autoPlay: true }, h("x-icon", { key: '7bbcd36baf6690a950388ca17a5de4d08c4a9aa6', name: this.icon })), h("button", { key: 'd5524d98092fca94876b61a9d15e5c9092df2962', type: "button", class: "notification-close", "aria-label": Lang('aria.close'), onClick: this.close.bind(this) }, h("span", { key: '251e6be7ff9b2485719bd892bffd640f8ffde825', "aria-hidden": "true" }, "\u00D7")), h("div", { key: '775c44cd80a9e25482120352dd1131ae7fb7b90c', class: "notification-body" }, h("slot", { key: '4453ed719abd9220b38706c89d9776459c871caf' })));
    }
    static get is() { return "x-notification"; }
    static get originalStyleUrls() {
        return {
            "$": ["./style.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["style.css"]
        };
    }
    static get properties() {
        return {
            "interval": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element interval time to close"
                },
                "attribute": "interval",
                "reflect": false
            },
            "color": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ColorType",
                    "resolved": "\"accent\" | \"blue\" | \"cyan\" | \"danger\" | \"default\" | \"green\" | \"indigo\" | \"info\" | \"orange\" | \"pink\" | \"primary\" | \"purple\" | \"red\" | \"success\" | \"teal\" | \"warning\" | \"yellow\"",
                    "references": {
                        "ColorType": {
                            "location": "import",
                            "path": "../../constants/colors",
                            "id": "src/constants/colors.ts::ColorType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "ELement color name"
                },
                "attribute": "color",
                "reflect": false,
                "defaultValue": "'default'"
            },
            "icon": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "IconType",
                    "resolved": "\"help\" | \"profile\" | \"watch\" | \"filter\" | \"map\" | \"info\" | \"error\" | \"testing\" | \"copy\" | \"document\" | \"data\" | \"label\" | \"link\" | \"menu\" | \"table\" | \"video\" | \"circle\" | \"image\" | \"marker\" | \"download\" | \"sync\" | \"cursor\" | \"rotate\" | \"unknown\" | \"history\" | \"print\" | \"key\" | \"danger\" | \"tv\" | \"rotate-right\" | \"rotate-left\" | \"visible\" | \"right\" | \"left\" | \"search\" | \"3ds-alt\" | \"3ds\" | \"abbreviation\" | \"activate\" | \"activity\" | \"allergies\" | \"answer\" | \"app-store\" | \"apple-pay\" | \"apple\" | \"ask-question\" | \"auth-capture\" | \"aws\" | \"back\" | \"backclear\" | \"badge-fingerprint\" | \"badge-package\" | \"badge-shield\" | \"bank-account\" | \"bank-cards\" | \"bank\" | \"barcode\" | \"basket\" | \"bin-card\" | \"bitcoin\" | \"bot\" | \"bowl\" | \"brain\" | \"browser-chrome\" | \"browser-default\" | \"browser-edge\" | \"browser-firefox\" | \"browser-ie\" | \"browser-opera\" | \"browser-safari\" | \"bug\" | \"calendar-event\" | \"calendar\" | \"call-list\" | \"car\" | \"card-amex\" | \"card-banrural\" | \"card-diners_club\" | \"card-discover\" | \"card-jcb\" | \"card-mastercard\" | \"card-unionpay\" | \"card-visa\" | \"card-wallet\" | \"cash-register\" | \"certificate\" | \"chat\" | \"chatbot\" | \"chatgpt\" | \"check-circle\" | \"check\" | \"checkmark\" | \"chip-card\" | \"chip\" | \"clean\" | \"clipboard\" | \"clock\" | \"cloud-offline\" | \"cloud\" | \"coins\" | \"comment-3ds\" | \"comment-afs\" | \"comment-avs\" | \"comment-cavv\" | \"comment-cavvf\" | \"comment-cavvw\" | \"comment-cvn\" | \"comment-error\" | \"comment-info\" | \"comment-pos\" | \"comment-val\" | \"confectionery\" | \"configuration\" | \"connected\" | \"console\" | \"contactless-payment\" | \"credit-card\" | \"crop\" | \"crown\" | \"cube\" | \"cubes\" | \"currency-settings\" | \"cut-paper\" | \"cut\" | \"cutlery\" | \"dark-mode\" | \"dashboard\" | \"debit-card\" | \"decrease-decimal\" | \"delivered-mail\" | \"desktop\" | \"device-android\" | \"device-ios\" | \"device-linux\" | \"device-mac\" | \"device-other\" | \"device-ubuntu\" | \"device-windows\" | \"discount\" | \"divide\" | \"double-tick\" | \"download-report\" | \"drag-reorder\" | \"drop\" | \"dropdown\" | \"edit\" | \"estimate\" | \"eth\" | \"exchange-bitcoin\" | \"exchange-ethereum\" | \"exchange\" | \"external-link\" | \"face-id\" | \"facebook\" | \"file-archive\" | \"file-document\" | \"file-image\" | \"file-video\" | \"file\" | \"fill-color\" | \"fill-drip\" | \"filter-alt\" | \"finance-document\" | \"financial-changes\" | \"fingerprint\" | \"flag\" | \"format-blockquote\" | \"format-bold\" | \"format-code\" | \"format-header-1\" | \"format-header-2\" | \"format-header-3\" | \"format-header\" | \"format-icon\" | \"format-italic\" | \"format-line\" | \"format-paragraph\" | \"format-quote\" | \"format-redo\" | \"format-strikethrough\" | \"format-table\" | \"format-tip\" | \"format-underline\" | \"format-undo\" | \"forward\" | \"git\" | \"google-play\" | \"google\" | \"graph\" | \"hand\" | \"handcart\" | \"hosted-checkout\" | \"hot-price\" | \"hourglass\" | \"idea\" | \"identification-documents\" | \"image-document\" | \"image-gallery\" | \"in-transit\" | \"inactive-state\" | \"increase-decimal\" | \"insert-money\" | \"instashop\" | \"invisible\" | \"invoice\" | \"job\" | \"js-squared\" | \"kitchen\" | \"lambda\" | \"lang-angular\" | \"lang-bash\" | \"lang-capacitor\" | \"lang-code\" | \"lang-cpp\" | \"lang-csharp\" | \"lang-css\" | \"lang-flutter\" | \"lang-go\" | \"lang-html\" | \"lang-ini\" | \"lang-ionic\" | \"lang-java\" | \"lang-js\" | \"lang-json\" | \"lang-kotlin\" | \"lang-laravel\" | \"lang-node-js\" | \"lang-objectivec\" | \"lang-php\" | \"lang-python\" | \"lang-react\" | \"lang-ruby\" | \"lang-sql\" | \"lang-swift\" | \"lang-typescript\" | \"lang-visual-basic\" | \"lang-vue\" | \"lang-xamarin\" | \"lang-xml\" | \"legal\" | \"licence\" | \"light-mode\" | \"list-bullet\" | \"list-numbered\" | \"list-todo\" | \"list\" | \"lock\" | \"love-fill\" | \"love\" | \"mail-bulk\" | \"mail\" | \"mailbox-full\" | \"mailbox\" | \"mailing\" | \"mediaplayer\" | \"merchant-setting\" | \"merchant\" | \"message\" | \"mindmap\" | \"minus\" | \"mobile\" | \"modules\" | \"mouse-scrolling\" | \"move\" | \"network-cable\" | \"network-group\" | \"network\" | \"nfc-tag\" | \"node-js\" | \"notifications\" | \"october\" | \"offline\" | \"onboarding\" | \"online-shop\" | \"online-support\" | \"open-box\" | \"package-tag\" | \"package\" | \"paint-brush\" | \"palette\" | \"parking-meter\" | \"parking-prohibited\" | \"parking\" | \"paycheque\" | \"pending\" | \"percentage\" | \"petition\" | \"phone\" | \"pie-chart-alt\" | \"pie-chart\" | \"pin\" | \"platform-edit\" | \"plus\" | \"power-off\" | \"prestashop\" | \"prize\" | \"qr\" | \"quickbooks\" | \"receipt-added\" | \"receipt-approved\" | \"receipt-declined\" | \"receipt-deleted\" | \"receipt-ticket\" | \"receipt\" | \"receive-cash\" | \"register\" | \"report\" | \"resend-mail\" | \"restaurant-menu\" | \"restaurant\" | \"rice-bowl\" | \"room-service\" | \"ruler\" | \"safe\" | \"sale\" | \"save-pdf\" | \"save\" | \"schedule\" | \"search-folder\" | \"select-circle\" | \"send\" | \"separate-document\" | \"settings\" | \"share\" | \"shield-lock\" | \"shield-warning\" | \"shield\" | \"ship\" | \"shipping-product\" | \"shopify\" | \"shopping-bag\" | \"shopping-cart\" | \"shopping\" | \"sim-card-sensor\" | \"sim-card\" | \"sparkling\" | \"split\" | \"star-fill\" | \"star\" | \"stocks-growth\" | \"suspend\" | \"table-alt\" | \"tag\" | \"tags\" | \"test-tube\" | \"themes\" | \"three-ways\" | \"ticket\" | \"timer\" | \"toggle-off\" | \"toggle-on\" | \"toolkit\" | \"trash-disable\" | \"trash\" | \"truck\" | \"unavailable\" | \"up-down-arrow\" | \"update\" | \"upload-cloud\" | \"upload\" | \"usb-stick\" | \"user-activity\" | \"user-admin\" | \"user-calendar\" | \"user-female\" | \"user-group\" | \"user-guide\" | \"user-male\" | \"user-permissions\" | \"user-tag\" | \"user\" | \"users-settings\" | \"vault\" | \"versions\" | \"vtex\" | \"wallet\" | \"webhook\" | \"whatsapp\" | \"wired-network\" | \"withdraw\" | \"woocommerce\" | \"workflow\"",
                    "references": {
                        "IconType": {
                            "location": "import",
                            "path": "../../constants/icons",
                            "id": "src/constants/icons.ts::IconType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element icon name"
                },
                "attribute": "icon",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "visible": {},
            "timer": {}
        };
    }
    static get events() {
        return [{
                "method": "onClose",
                "name": "close",
                "bubbles": false,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "This event is sent when the close button pressed."
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get methods() {
        return {
            "show": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Show notification element",
                    "tags": []
                }
            },
            "close": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Close notification element",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
