import { faTimes } from "@fortawesome/free-solid-svg-icons";
import { h } from "@stencil/core";
import { DataTestIdsEnum } from "../../../../../../../constants/dataTestIds.enum";
export class TransactionToastContent {
    handleDeleteToast() {
        this.deleteToast.emit();
    }
    renderPrimaryIcon() {
        var _a, _b;
        const transaction = (_a = this.transactions) === null || _a === void 0 ? void 0 : _a[0];
        if (!(transaction === null || transaction === void 0 ? void 0 : transaction.asset)) {
            return h("mvx-default-transaction-icon-small", null);
        }
        if (transaction.asset.imageUrl) {
            return h("img", { src: transaction.asset.imageUrl, alt: "Transaction icon", class: "transaction-toast-icon", loading: "lazy" });
        }
        if (transaction.asset.icon) {
            return h("mvx-fa-icon", { icon: transaction.asset.icon, class: "transaction-toast-icon" });
        }
        if (transaction.asset.text) {
            return h("span", { class: "transaction-toast-icon" }, transaction.asset.text);
        }
        if (this.toastDataState.icon) {
            return h("fa-icon", { icon: this.toastDataState.icon, class: `transaction-toast-icon ${(_b = this.toastDataState.iconClassName) !== null && _b !== void 0 ? _b : ''}` });
        }
        return h("mvx-default-transaction-icon-small", null);
    }
    renderDetails() {
        var _a;
        const transaction = (_a = this.transactions) === null || _a === void 0 ? void 0 : _a[0];
        if (!transaction) {
            return null;
        }
        return (h("div", { class: "transaction-toast-details-info" }, transaction.directionLabel && h("span", { class: "transaction-toast-details-info-text" }, transaction.directionLabel), h("div", { class: "transaction-toast-details-info-icon" }, transaction.interactorAsset ? h("img", { src: transaction.interactorAsset, alt: "Service icon", loading: "lazy" }) : h("mvx-default-transaction-icon-small", null)), h("mvx-trim-text", { text: transaction.interactor, class: "transaction-toast-details-info-text" })));
    }
    render() {
        var _a;
        const { title, hasCloseButton } = this.toastDataState;
        const transaction = this.transactions[0];
        const showAmount = this.transactions.length === 1 && (transaction === null || transaction === void 0 ? void 0 : transaction.amount);
        const showExplorerLinkButton = (transaction === null || transaction === void 0 ? void 0 : transaction.link) && this.transactions.length === 1;
        return (h("div", { key: '5efff505e6d9628641553f02b36eef143d695e02', class: {
                'transaction-toast-content-wrapper': true,
                'full-width': this.fullWidth,
            }, "data-testid": DataTestIdsEnum.transactionToastContent }, h("div", { key: 'cf62356816fea007a834b810dbcbda9d9b407fa2', class: "transaction-toast-content" }, h("div", { key: 'e7382f49caa792f945f44b094363a1fcc8537d2e', class: "transaction-toast-icon" }, this.renderPrimaryIcon()), h("div", { key: '48906f4fbc152866cb1aeaf24384f3c7f1896d9a', class: "transaction-toast-details" }, h("div", { key: '8086cd840a9ddf64d74017861c56046f9f5d1f00', class: "transaction-toast-details-header" }, h("h4", { key: 'df1b8dd917d5c5b504393c0c76e6439cf868fc54', class: {
                'transaction-toast-title': true,
                'transaction-toast-title-short': Boolean(showAmount),
            } }, title || ((_a = transaction === null || transaction === void 0 ? void 0 : transaction.action) === null || _a === void 0 ? void 0 : _a.name)), showAmount && h("div", { key: 'f08d5b9c31b798332ccd9dad65ae419dba8708f1', class: "transaction-toast-amount" }, transaction.amount)), this.renderDetails()), hasCloseButton && h("fa-icon", { key: 'eefe58772ba4d6e3f025f27c1311dd41d44f270d', icon: faTimes, class: "transaction-toast-close-icon", onClick: this.handleDeleteToast.bind(this) }), !hasCloseButton && showExplorerLinkButton && h("mvx-explorer-link", { key: '70b7ad2e590b31a98c22d9866253d6dd86228090', link: transaction.link, class: "transaction-toast-action-button" })), !showExplorerLinkButton && h("mvx-transaction-toast-details", { key: '6e73eb2917b8d7aec13b907711f5d7b2d0944938', transactions: this.transactions, processedTransactionsStatus: this.processedTransactionsStatus })));
    }
    static get is() { return "mvx-transaction-toast-content"; }
    static get originalStyleUrls() {
        return {
            "$": ["transaction-toast-content.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["transaction-toast-content.css"]
        };
    }
    static get properties() {
        return {
            "transactions": {
                "type": "unknown",
                "attribute": "transactions",
                "mutable": false,
                "complexType": {
                    "original": "ITransactionListItem[]",
                    "resolved": "ITransactionListItem[]",
                    "references": {
                        "ITransactionListItem": {
                            "location": "import",
                            "path": "components/visual/transaction-list-item/transaction-list-item.types",
                            "id": "src/components/visual/transaction-list-item/transaction-list-item.types.ts::ITransactionListItem"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "toastDataState": {
                "type": "unknown",
                "attribute": "toast-data-state",
                "mutable": false,
                "complexType": {
                    "original": "IToastDataState",
                    "resolved": "IToastDataState",
                    "references": {
                        "IToastDataState": {
                            "location": "import",
                            "path": "../../transaction-toast.type",
                            "id": "src/components/functional/toasts-list/components/transaction-toast/transaction-toast.type.ts::IToastDataState"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "processedTransactionsStatus": {
                "type": "string",
                "attribute": "processed-transactions-status",
                "mutable": false,
                "complexType": {
                    "original": "string | JSX.Element",
                    "resolved": "Element | string",
                    "references": {
                        "JSX": {
                            "location": "import",
                            "path": "@stencil/core",
                            "id": "node_modules::LocalJSX"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "fullWidth": {
                "type": "boolean",
                "attribute": "full-width",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get events() {
        return [{
                "method": "deleteToast",
                "name": "deleteToast",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
}
//# sourceMappingURL=transaction-toast-content.js.map
