import { p as proxyCustomElement, H, h, f as forceUpdate } from './p-ac76a689.js';
import { E as EventBus } from './p-9d530225.js';
import { D as DataTestIdsEnum } from './p-545d6d1c.js';
import { d as defineCustomElement$2 } from './p-fa6edc93.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 = /*@__PURE__*/ proxyCustomElement(class PendingTransactionstModal extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.eventBus = new EventBus();
        this.data = {
            isPending: false,
            title: '',
            subtitle: '',
        };
    }
    async getEventBus() {
        return this.eventBus;
    }
    render() {
        return (h("generic-modal", { key: 'e7d6f701dea377962b846f350b74f450da0e0ce1', modalTitle: h("div", { "data-testid": DataTestIdsEnum.pendingTransactionsTitle }, this.data.title), modalSubtitle: h("div", { "data-testid": DataTestIdsEnum.pendingTransactionsSubtitle }, this.data.subtitle), onClose: () => this.close(), body: h("div", { class: "modal-body" }, 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);
        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 this; }
    static get style() { return PendingTransactionsModalStyle0; }
}, [1, "pending-transactions-modal", {
        "data": [16],
        "getEventBus": [64]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["pending-transactions-modal", "generic-modal"];
    components.forEach(tagName => { switch (tagName) {
        case "pending-transactions-modal":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, PendingTransactionstModal);
            }
            break;
        case "generic-modal":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}
defineCustomElement$1();

const PendingTransactionsModal = PendingTransactionstModal;
const defineCustomElement = defineCustomElement$1;

export { PendingTransactionsModal, defineCustomElement };

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