import { h, Host } from "@stencil/core";
import { DefaultIcon } from "./assets/default-icon";
export class TransactionListItem {
    renderPrimaryIcon() {
        if (!this.transaction.asset) {
            return h(DefaultIcon, null);
        }
        if (this.transaction.asset.imageUrl) {
            return h("img", { src: this.transaction.asset.imageUrl, alt: "Transaction icon", class: "icon-image", loading: "lazy" });
        }
        if (this.transaction.asset.icon) {
            return h("fa-icon", { icon: this.transaction.asset.icon, class: "icon-text" });
        }
        if (this.transaction.asset.text) {
            return h("span", { class: "icon-text" }, this.transaction.asset.text);
        }
        return h(DefaultIcon, null);
    }
    renderDetails() {
        if (!this.transaction.details) {
            return null;
        }
        return (h("div", { class: "transaction-info" }, h("span", { class: "transaction-target" }, this.transaction.details.directionLabel && h("span", { class: "direction-label" }, this.transaction.details.directionLabel), this.transaction.details.initiatorAsset && h("img", { src: this.transaction.details.initiatorAsset, alt: "Service icon", class: "service-icon", loading: "lazy" }), h("trim-text", { text: this.transaction.details.initiator, class: "initiator" }))));
    }
    render() {
        if (!this.transaction) {
            return h(Host, null);
        }
        return (h(Host, null, h("div", { class: "transaction-item" }, h("div", { class: "transaction-icon" }, this.renderPrimaryIcon()), h("div", { class: "transaction-details" }, h("h4", { class: "transaction-title" }, this.transaction.action.name), this.renderDetails()), this.transaction.amount && (h("div", { class: "transaction-right" }, h("div", { class: {
                'transaction-amount': true,
                'amount-negative': this.transaction.amount.startsWith('-'),
                'amount-positive': !this.transaction.amount.startsWith('-'),
            } }, this.transaction.amount))))));
    }
    static get is() { return "transaction-list-item"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["transaction-list-item.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["transaction-list-item.css"]
        };
    }
    static get properties() {
        return {
            "transaction": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ITransactionListItem",
                    "resolved": "ITransactionListItem",
                    "references": {
                        "ITransactionListItem": {
                            "location": "import",
                            "path": "./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
            }
        };
    }
}
//# sourceMappingURL=transaction-list-item.js.map
