'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-9564483d.js');
const EventBus = require('./EventBus-1890a8f3.js');
const signTransactionsModalStore = require('./signTransactionsModalStore-81808972.js');

var SignEventsEnum;
(function (SignEventsEnum) {
    SignEventsEnum["CONFIRM"] = "CONFIRM";
    SignEventsEnum["BACK"] = "BACK";
    SignEventsEnum["CLOSE"] = "CLOSE";
    SignEventsEnum["DATA_UPDATE"] = "DATA_UPDATE";
    SignEventsEnum["SET_PPU"] = "SET_PPU";
})(SignEventsEnum || (SignEventsEnum = {}));

const signTransactionsModalCss = "*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.flex{display:flex}*{box-sizing:border-box;margin:0;padding:0}.transaction-header-container{display:flex;flex-direction:column}.loading-spinner{align-items:center;display:flex;justify-content:center;min-height:350px}.static{position:static}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}";
const SignTransactionsModalStyle0 = signTransactionsModalCss;

const signScreens = {
    FungibleESDT: 'token-component',
    SemiFungibleESDT: 'fungible-component',
    NonFungibleESDT: 'fungible-component',
    MetaESDT: 'token-component',
};
const SignTransactionsModal = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.eventBus = new EventBus.EventBus();
        this.data = {
            commonData: {
                egldLabel: '',
                feeLimit: '',
                feeInFiatLimit: '',
                transactionsCount: 0,
                currentIndex: 0,
                ppuOptions: [],
            },
            tokenTransaction: null,
            nftTransaction: null,
            sftTransaction: null,
        };
    }
    async getEventBus() {
        return this.eventBus;
    }
    onDataChange(data) {
        for (const key in data) {
            if (Object.prototype.hasOwnProperty.call(signTransactionsModalStore.state, key)) {
                signTransactionsModalStore.state[key] = data[key];
            }
        }
        signTransactionsModalStore.state.isWaitingForSignature = false;
        signTransactionsModalStore.state.isLoading = false;
    }
    componentWillLoad() {
        signTransactionsModalStore.state.onConfirm = () => {
            this.eventBus.publish(SignEventsEnum.CONFIRM);
        };
        signTransactionsModalStore.state.onCancel = () => {
            this.eventBus.publish(SignEventsEnum.CLOSE);
        };
        signTransactionsModalStore.state.onBack = () => {
            this.eventBus.publish(SignEventsEnum.BACK);
        };
        signTransactionsModalStore.state.onSetPpu = (ppu) => {
            this.eventBus.publish(SignEventsEnum.SET_PPU, ppu);
        };
    }
    render() {
        const { commonData, isLoading } = signTransactionsModalStore.state;
        const { tokenType, currentIndex, transactionsCount } = commonData;
        const SignScreen = signScreens[tokenType];
        return (index.h("generic-modal", { key: 'd40e2e6b2de1b0c5321c8e155d78dbe99f96b613', onClose: () => this.close(), modalTitle: "Sign transaction", modalSubtitle: `Transaction ${currentIndex + 1} of ${transactionsCount}`, body: isLoading ? (index.h("div", { class: "loading-spinner" }, index.h("generic-spinner", null))) : (index.h(SignScreen, null)) }));
    }
    close(props = { isUserClick: true }) {
        signTransactionsModalStore.resetState();
        if (props.isUserClick) {
            this.eventBus.publish(SignEventsEnum.CLOSE);
        }
        if (this.hostElement && this.hostElement.parentNode) {
            this.hostElement.parentNode.removeChild(this.hostElement);
        }
    }
    dataUpdate(payload) {
        this.data = Object.assign({}, payload);
        index.forceUpdate(this);
    }
    componentDidLoad() {
        this.eventBus.subscribe(SignEventsEnum.DATA_UPDATE, this.dataUpdate.bind(this));
    }
    disconnectedCallback() {
        signTransactionsModalStore.resetState();
        this.eventBus.unsubscribe(SignEventsEnum.DATA_UPDATE, this.dataUpdate.bind(this));
    }
    get hostElement() { return index.getElement(this); }
    static get watchers() { return {
        "data": ["onDataChange"]
    }; }
};
SignTransactionsModal.style = SignTransactionsModalStyle0;

exports.sign_transactions_modal = SignTransactionsModal;

//# sourceMappingURL=sign-transactions-modal.cjs.entry.js.map