'use strict';

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

const index = require('./index-14914b7b.js');
const EventBus = require('./EventBus-1890a8f3.js');
const dataTestIds_enum = require('./dataTestIds.enum-0f98ecfd.js');

// types here need to be synced with the types in sdk-dapp-core pendingTransactions.types.ts
var PendingTransactionsEventsEnum;
(function (PendingTransactionsEventsEnum) {
    PendingTransactionsEventsEnum["CLOSE"] = "CLOSE";
    PendingTransactionsEventsEnum["DATA_UPDATE"] = "DATA_UPDATE";
})(PendingTransactionsEventsEnum || (PendingTransactionsEventsEnum = {}));

const pendingTransactionsModalCss = ".modal-body{display:flex;justify-content:center;align-items:center;padding:16px}.close-button{cursor:pointer;color:#ffff;background-color:#343a40;border-color:#343a40;border-radius:0.25rem;padding:0.375rem 0.75rem;border:1px solid rgba(0, 0, 0, 0)}";
const PendingTransactionsModalStyle0 = pendingTransactionsModalCss;

const PendingTransactionstModal = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.eventBus = new EventBus.EventBus();
        this.data = {
            isPending: false,
            title: '',
            subtitle: '',
        };
    }
    async getEventBus() {
        return this.eventBus;
    }
    render() {
        return (index.h("generic-modal", { key: 'e7d6f701dea377962b846f350b74f450da0e0ce1', modalTitle: index.h("div", { "data-testid": dataTestIds_enum.DataTestIdsEnum.pendingTransactionsTitle }, this.data.title), modalSubtitle: index.h("div", { "data-testid": dataTestIds_enum.DataTestIdsEnum.pendingTransactionsSubtitle }, this.data.subtitle), onClose: () => this.close(), body: index.h("div", { class: "modal-body" }, index.h("button", { class: "close-button", onClick: () => this.close() }, "Close")) }));
    }
    close(props = { isUserClick: true }) {
        if (props.isUserClick) {
            this.eventBus.publish(PendingTransactionsEventsEnum.CLOSE);
        }
        if (this.hostElement && this.hostElement.parentNode) {
            this.hostElement.parentNode.removeChild(this.hostElement);
        }
    }
    dataUpdate(payload) {
        if (payload.shouldClose) {
            return this.close({ isUserClick: false });
        }
        this.data = Object.assign({}, payload);
        index.forceUpdate(this);
    }
    componentDidLoad() {
        this.eventBus.subscribe(PendingTransactionsEventsEnum.DATA_UPDATE, this.dataUpdate.bind(this));
    }
    disconnectedCallback() {
        this.eventBus.unsubscribe(PendingTransactionsEventsEnum.DATA_UPDATE, this.dataUpdate.bind(this));
    }
    get hostElement() { return index.getElement(this); }
};
PendingTransactionstModal.style = PendingTransactionsModalStyle0;

exports.pending_transactions_modal = PendingTransactionstModal;

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