import { DispatchStateChangeUC } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { UndoRedoEntity, } from "../../UndoRedo/Entities/UndoRedoEntity";
import { QuestionEntity } from "../Entities";
export class ToggleIsCorrectUndoRedo {
    constructor(answerID, appObjects) {
        this.answerID = answerID;
        this.undoAction = () => {
            if (!this.questionEntity || !this.dispatchStateChange)
                return;
            const answer = this.questionEntity.getAnswer(this.answerID);
            if (!answer)
                return;
            answer.isCorrect = !answer.isCorrect;
            this.dispatchStateChange.doDispatch();
        };
        this.redoAction = () => {
            if (!this.questionEntity || !this.dispatchStateChange)
                return;
            const answer = this.questionEntity.getAnswer(this.answerID);
            if (!answer)
                return;
            answer.isCorrect = !answer.isCorrect;
            this.dispatchStateChange.doDispatch();
        };
        this.questionEntity = QuestionEntity.get(appObjects);
        if (!this.questionEntity) {
            appObjects.submitWarning("DeleteAnswerUndoRedo", "Unable to find QuestionEntity");
            return;
        }
        this.dispatchStateChange = DispatchStateChangeUC.get(appObjects);
        if (!this.dispatchStateChange) {
            appObjects.submitWarning("DeleteAnswerUndoRedo", "Unable to find DispatchStateChangeUC");
            return;
        }
        const undoRedo = UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("DeleteAnswerUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=ToggleIsCorrectUndoRedo.js.map