import { makeAutoObservable } from 'mobx';
import { ConditionalModalState } from './ConditionalModalState';
import { FieldOperationsBIReporter } from './FieldOperationsBIReporter';
export class DeleteFieldModalState {
    constructor(params) {
        this.biReporter = new FieldOperationsBIReporter({
            reportBi: params.reportBi,
        });
        this.fieldManagement = params.fieldManagement;
        this.archive = params.archive;
        this.modal = new ConditionalModalState({
            onConfirm: async () => {
                if (!this.modal.value) {
                    return;
                }
                this.biReporter.reportDeleteFieldModalCtaClicked('Delete');
                await this.fieldManagement.deleteField(this.modal.value.id, this.modal.value.origin);
                // Close archived panel if no items left
                if (this.archive.items.length === 0) {
                    this.archive.closePanel();
                }
            },
            onClose: () => {
                this.biReporter.reportDeleteFieldModalCtaClicked('Cancel');
            },
        });
        makeAutoObservable(this);
    }
}
//# sourceMappingURL=DeleteFieldModalState.js.map