var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { h } from "@stencil/core";
import { DataTestIdsEnum } from "../../../../../constants/dataTestIds.enum";
import { formatAddress } from "../../../../../utils/utils";
import state from "../../signTransactionsPanelStore";
export class SignTransaction {
    getSignButtonProps() {
        const { needsSigning } = state.commonData;
        if (needsSigning) {
            return {
                'signText': 'Sign',
                'disabled': state.isWaitingForSignature,
                'data-testid': DataTestIdsEnum.signTransactionBtn,
                'onClick': state.onConfirm,
            };
        }
        return {
            'signText': 'Next',
            'disabled': false,
            'data-testid': DataTestIdsEnum.signNextTransactionBtn,
            'onClick': state.onConfirm,
        };
    }
    getBackButtonProps() {
        const { transactionsCount, currentIndex } = state.commonData;
        const isMultipleTransactions = transactionsCount > 1;
        if (!isMultipleTransactions) {
            return {};
        }
        if (currentIndex === 0) {
            return {
                'data-testid': DataTestIdsEnum.signCancelBtn,
                'backButtonText': 'Cancel',
                'onClick': state.onCancel,
            };
        }
        return {
            'data-testid': DataTestIdsEnum.signBackBtn,
            'backButtonText': 'Back',
            'onClick': state.onBack,
            'disabled': state.isWaitingForSignature,
        };
    }
    getHighlightedData() {
        const { data, highlight } = state.commonData;
        if (!highlight || !data) {
            return data;
        }
        const parts = data.split(highlight);
        return (h("span", null, parts.map((part, index) => (h("span", null, h("span", { class: "data-content" }, part), index < parts.length - 1 && h("span", { class: "highlight" }, highlight))))));
    }
    render() {
        const { receiver, scCall } = state.commonData;
        const _a = this.getSignButtonProps(), { signText } = _a, signButtonProps = __rest(_a, ["signText"]);
        const _b = this.getBackButtonProps(), { backButtonText } = _b, backButtonProps = __rest(_b, ["backButtonText"]);
        const highlightedData = this.getHighlightedData();
        return (h("div", { key: '624942dee4fb92ee4d8232962405fc0e0e862d95', class: "transaction-container" }, this.header, h("div", { key: '5cf27b3b1c67280841670c361bc66b0b42b445ca', class: "receiver-container" }, h("p", { key: 'e0d9307210aa2c978ba0fb39ffdbcbc9a314c8b2' }, "To"), h("p", { key: '32f5055b3b2abb129bcd76394535d953af04a2f0' }, formatAddress(receiver, 40))), h("mvx-transaction-fee-component", { key: 'c2a7495f4674c62756efc553521812f39399236d' }), scCall && (h("div", { key: '290fadee8e071314d3f77310de636b955ce9153f', class: "data-container" }, h("p", { key: '90058ebb6901854f417e6abc14d6e53a835600b2' }, "Smart Contract Call"), h("div", { key: 'e8925bb61e16223f40e4762c1f020d24cef3bf3b', class: "data-content-container" }, scCall))), h("div", { key: 'f1709e5d72218d5e4b26017f89d91771a0ae649c', class: "data-container" }, h("p", { key: '91eafb95c80f5b7ca022646e8c66023db0737737' }, "Data"), h("div", { key: '68de8066c8b909fbeb87aa802070d1f9783be34c', class: "data-content-container" }, highlightedData)), h("div", { key: '3fc6465b2e49f6f40c2e06b2d5cc85472454ce41', class: "sign-button-container" }, h("button", Object.assign({ key: 'd53bce6bb3f33df666154bf8bdf4258a0c849107', class: "sign-button" }, signButtonProps), signText), backButtonText && (h("button", Object.assign({ key: 'd7adb745bdd6d97bbb073820473186122cb7ba89', class: "sign-back-button" }, backButtonProps), backButtonText)))));
    }
    static get is() { return "mvx-sign-transaction-component"; }
    static get originalStyleUrls() {
        return {
            "$": ["sign-transaction-component.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["sign-transaction-component.css"]
        };
    }
    static get properties() {
        return {
            "header": {
                "type": "unknown",
                "attribute": "header",
                "mutable": false,
                "complexType": {
                    "original": "VNode",
                    "resolved": "VNode",
                    "references": {
                        "VNode": {
                            "location": "import",
                            "path": "@stencil/core",
                            "id": "node_modules::VNode"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
}
//# sourceMappingURL=sign-transaction-component.js.map
