import { dispatchStateChange } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { UndoRedoEntity, } from "../../UndoRedo/Entities/UndoRedoEntity";
import { CalloutRepo } from "../Entities/CalloutRepo";
export class CreateCalloutUndoRedo {
    constructor(createdCalloutData, appObjects) {
        this.createdCalloutData = createdCalloutData;
        this.appObjects = appObjects;
        this.redoAction = () => {
            const repo = CalloutRepo.getById(this.createdCalloutData.parentID, this.appObjects);
            if (!repo) {
                return;
            }
            const callout = repo.makeCallout(this.createdCalloutData.id);
            callout.data = this.createdCalloutData;
            dispatchStateChange(this.appObjects);
        };
        this.undoAction = () => {
            const repo = CalloutRepo.getById(this.createdCalloutData.parentID, this.appObjects);
            if (!repo) {
                return;
            }
            repo.deleteCallout(this.createdCalloutData.id);
            dispatchStateChange(this.appObjects);
        };
        const undoRedo = UndoRedoEntity.get(this.appObjects);
        if (!undoRedo) {
            this.appObjects.submitError("CreateCalloutAction", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=CreateCalloutUndoRedo.js.map