import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
import { h } from "@stencil/core";
export class TransactionToastDetails {
    constructor() {
        this.maxShownTransactions = 5;
        this.isExpanded = false;
        this.showAllTransactions = false;
    }
    toggleExpand() {
        this.isExpanded = !this.isExpanded;
        // Reset showAllTransactions when collapsing
        if (!this.isExpanded) {
            this.showAllTransactions = false;
        }
    }
    showMoreTransactions() {
        this.showAllTransactions = true;
    }
    render() {
        if (this.transactions == null) {
            return null;
        }
        const hasMoreTransactionsToShow = this.transactions.length > this.maxShownTransactions;
        const hiddenTransactionsCount = this.transactions.length - this.maxShownTransactions;
        const visibleTransactions = this.showAllTransactions ? this.transactions : this.transactions.slice(0, this.maxShownTransactions);
        return (h("div", { class: "transaction-details-container" }, h("div", { class: "transaction-details-status", onClick: this.toggleExpand.bind(this) }, h("mvx-fa-icon", { icon: faChevronDown, class: `transaction-details-status-icon ${this.isExpanded ? 'rotate-up' : ''}` }), h("span", { class: "transaction-details-status-text" }, this.processedTransactionsStatus)), h("div", { class: {
                'transaction-details-list': true,
                'expanded': this.isExpanded,
            } }, visibleTransactions.map(({ hash, status, link }, index) => (h("mvx-transaction-toast-details-body", { transactionClass: this.transactionClass, hash: hash, status: status, link: link, index: `#${index + 1}`, key: hash }))), hasMoreTransactionsToShow && !this.showAllTransactions && (h("div", { class: "view-all-container" }, h("button", { type: "button", class: "show-more-button", onClick: this.showMoreTransactions.bind(this) }, "Show ", hiddenTransactionsCount, " more"))))));
    }
    static get is() { return "mvx-transaction-toast-details"; }
    static get originalStyleUrls() {
        return {
            "$": ["transaction-toast-details.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["transaction-toast-details.css"]
        };
    }
    static get properties() {
        return {
            "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
            },
            "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": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "transactionClass": {
                "type": "string",
                "attribute": "transaction-class",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "maxShownTransactions": {
                "type": "number",
                "attribute": "max-shown-transactions",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "5"
            }
        };
    }
    static get states() {
        return {
            "isExpanded": {},
            "showAllTransactions": {}
        };
    }
}
//# sourceMappingURL=transaction-toast-details.js.map
