import { forceUpdate, h } from "@stencil/core";
import { EventBus } from "../../../utils/EventBus";
import { ToastEventsEnum } from "./toast-list.types";
export class ToastList {
    constructor() {
        this.eventBus = new EventBus();
    }
    async getEventBus() {
        return this.eventBus;
    }
    disconnectedCallback() {
        this.eventBus.unsubscribe(ToastEventsEnum.TRANSACTION_TOAST_DATA_UPDATE, this.transactionToastUpdate.bind(this));
        this.eventBus.unsubscribe(ToastEventsEnum.CUSTOM_TOAST_DATA_UPDATE, this.customToastsUpdate.bind(this));
    }
    handleCustomToastDelete(toastId) {
        this.eventBus.publish(ToastEventsEnum.CLOSE_TOAST, toastId);
    }
    handleTransactionToastDelete(toastId) {
        this.eventBus.publish(ToastEventsEnum.CLOSE_TOAST, toastId);
    }
    handleViewAllClick() {
        this.eventBus.publish(ToastEventsEnum.OPEN_NOTIFICATIONS_FEED);
    }
    render() {
        var _a, _b, _c;
        return (h("div", { key: 'ecd27ee25917846af7652af3134088c3a566bd0d', class: "toast-list", id: "toast-list" }, (_a = this.customToasts) === null || _a === void 0 ? void 0 :
            _a.map(toast => h("generic-toast", { toast: toast, onHandleDeleteToast: this.handleCustomToastDelete.bind(this, toast.toastId) })), (_b = this.transactionToasts) === null || _b === void 0 ? void 0 :
            _b.map(toast => h("transaction-toast", Object.assign({}, toast, { onHandleDeleteToast: this.handleTransactionToastDelete.bind(this, toast.toastId) }))), ((_c = this.transactionToasts) === null || _c === void 0 ? void 0 : _c.length) > 0 && (h("div", { key: '044ea08bc44746eb925c9e48a61c6edfa7ea4a2f', class: "view-all-button-container" }, h("button", { key: 'e5b2929bf2e99f1d8bd29394d5ccef20dd7b671b', class: "view-all-button", onClick: this.handleViewAllClick.bind(this) }, "View All")))));
    }
    transactionToastUpdate(payload) {
        this.transactionToasts = [...payload];
        forceUpdate(this);
    }
    customToastsUpdate(payload) {
        this.customToasts = [...payload];
        forceUpdate(this);
    }
    componentDidLoad() {
        this.eventBus.subscribe(ToastEventsEnum.TRANSACTION_TOAST_DATA_UPDATE, this.transactionToastUpdate.bind(this));
        this.eventBus.subscribe(ToastEventsEnum.CUSTOM_TOAST_DATA_UPDATE, this.customToastsUpdate.bind(this));
    }
    static get is() { return "toast-list"; }
    static get originalStyleUrls() {
        return {
            "$": ["toast-list.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["toast-list.css"]
        };
    }
    static get properties() {
        return {
            "transactionToasts": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ITransactionToast[]",
                    "resolved": "ITransactionToast[]",
                    "references": {
                        "ITransactionToast": {
                            "location": "import",
                            "path": "./components/transaction-toast/transaction-toast.type",
                            "id": "src/components/functional/toasts-list/components/transaction-toast/transaction-toast.type.ts::ITransactionToast"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "customToasts": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "CustomToastType[]",
                    "resolved": "CustomToastType[]",
                    "references": {
                        "CustomToastType": {
                            "location": "import",
                            "path": "./components/transaction-toast/transaction-toast.type",
                            "id": "src/components/functional/toasts-list/components/transaction-toast/transaction-toast.type.ts::CustomToastType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get methods() {
        return {
            "getEventBus": {
                "complexType": {
                    "signature": "() => Promise<IEventBus>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "IEventBus": {
                            "location": "import",
                            "path": "utils/EventBus",
                            "id": "src/utils/EventBus.ts::IEventBus"
                        }
                    },
                    "return": "Promise<IEventBus>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            }
        };
    }
}
//# sourceMappingURL=toast-list.js.map
