var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { customElement } from '../../../../external/lit/index.js';
import { UUIModalDialogElement } from '../../../../external/uui/index.js';
/**
 * A modal dialog element that cannot be dismissed by pressing ESC.
 * Use this when the user must interact with the modal content (e.g. re-authentication on timeout).
 */
let UmbPersistentModalDialogElement = class UmbPersistentModalDialogElement extends UUIModalDialogElement {
    #abortController;
    _openModal() {
        this.#abortController?.abort();
        this.#abortController = new AbortController();
        const signal = this.#abortController.signal;
        this._dialogElement?.showModal();
        this._dialogElement?.addEventListener('keydown', (e) => e.key === 'Escape' && e.preventDefault(), { signal });
        this._dialogElement?.addEventListener('cancel', (e) => e.preventDefault(), { signal });
        // Defer isOpen to avoid scheduling a Lit update during firstUpdated
        queueMicrotask(() => {
            this.isOpen = true;
        });
    }
    forceClose() {
        this.#abortController?.abort();
        super.forceClose();
    }
};
UmbPersistentModalDialogElement = __decorate([
    customElement('umb-persistent-modal-dialog')
], UmbPersistentModalDialogElement);
export { UmbPersistentModalDialogElement };
export default UmbPersistentModalDialogElement;
