"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteAllCalloutsUndoRedo = void 0;
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
const CalloutRepo_1 = require("../Entities/CalloutRepo");
class DeleteAllCalloutsUndoRedo {
    constructor(deletedCallouts, appObjects) {
        this.deletedCallouts = deletedCallouts;
        this.appObjects = appObjects;
        this.undoAction = () => {
            this.deletedCallouts.forEach((deletedCallout) => {
                const repo = CalloutRepo_1.CalloutRepo.getById(deletedCallout.parentID, this.appObjects);
                if (!repo) {
                    return;
                }
                const callout = repo.makeCallout(deletedCallout.id);
                callout.data = deletedCallout;
            });
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
        this.redoAction = () => {
            this.deletedCallouts.forEach((deletedCallout) => {
                const repo = CalloutRepo_1.CalloutRepo.getById(deletedCallout.parentID, this.appObjects);
                if (!repo) {
                    return;
                }
                repo.deleteCallout(deletedCallout.id);
            });
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
        const undoRedo = UndoRedoEntity_1.UndoRedoEntity.get(this.appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("DeleteAllCalloutsUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.DeleteAllCalloutsUndoRedo = DeleteAllCalloutsUndoRedo;
//# sourceMappingURL=DeleteAllCalloutsUndoRedo.js.map