import { AppObjectUC } from "@vived/core";
import { DispatchStateChangeUC } from "../../Dispatcher";
import { QuestionAnswerEntity } from "../Entities/QuestionAnswerEntity";
import { SetAnswerFeedbackUndoRedo } from "./SetAnswerFeedbackUndoRedo";
export class SetAnswerFeedbackUC extends AppObjectUC {
}
SetAnswerFeedbackUC.type = "SetAnswerFeedbackUC";
export function makeSetAnswerFeedbackUC(appObject) {
    return new SetAnswerFeedbackUCImp(appObject);
}
class SetAnswerFeedbackUCImp extends SetAnswerFeedbackUC {
    setFeedback(feedback) {
        if (!this.answer)
            return;
        if (this.answer.feedbackText === feedback)
            return;
        const previousFeedback = this.answer.feedbackText;
        this.answer.feedbackText = feedback;
        DispatchStateChangeUC.get(this.appObject.appObjectRepo)?.doDispatch();
        new SetAnswerFeedbackUndoRedo(previousFeedback, this.answer.id, this.appObject.appObjectRepo);
    }
    constructor(appObject) {
        super(appObject, SetAnswerFeedbackUC.type);
        this.answer = appObject.getComponent(QuestionAnswerEntity.type);
        if (!this.answer) {
            this.warn("SetAnswerFeedbackUC has been added to an app object that does not have QuestionAnswerEntity");
        }
    }
}
//# sourceMappingURL=SetAnswerFeedbackUC.js.map