import { UMB_CONTENT_ROLLBACK_MODAL } from '../modal/constants.js';
import { UmbEntityActionBase } from '../../../../core/entity-action/index.js';
import { umbOpenModal } from '../../../../core/modal/index.js';
import { UMB_NOTIFICATION_CONTEXT } from '../../../../core/notification/index.js';
import { UmbLocalizationController } from '../../../../../libs/localization-api/index.js';
export class UmbContentRollbackEntityAction extends UmbEntityActionBase {
    #localize = new UmbLocalizationController(this);
    async execute() {
        const result = await umbOpenModal(this, UMB_CONTENT_ROLLBACK_MODAL, {
            data: {
                rollbackRepositoryAlias: this.args.meta.rollbackRepositoryAlias,
                detailRepositoryAlias: this.args.meta.detailRepositoryAlias,
            },
        }).catch(() => undefined);
        if (!result)
            return;
        const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT);
        if (!notificationContext) {
            throw new Error('Notification context not found');
        }
        notificationContext.peek('positive', {
            data: { message: this.#localize.term('rollback_documentRolledBack') },
        });
    }
}
export { UmbContentRollbackEntityAction as api };
