import { AppObjectEntity, MemoizedBoolean, MemoizedString, } from "@vived/core";
export const EMPTY_TEXT_VALIDATION_MESSAGE = "Answer text is required.";
export const MAX_QUESTION_LENGTH = 40;
export const LONG_TEXT_VALIDATION_MESSAGE = `Answer text may not exceed ${MAX_QUESTION_LENGTH} characters.`;
export const MAX_FEEDBACK_LENGTH = 200;
export const LONG_FEEDBACK_VALIDATION_MESSAGE = `Answer feedback may not exceed ${MAX_FEEDBACK_LENGTH} characters.`;
export class QuestionAnswerEntity extends AppObjectEntity {
}
QuestionAnswerEntity.type = "QuestionAnswerEntity";
export function makeQuestionAnswerEntity(appObject) {
    return new QuestionAnswerEntityImp(appObject);
}
class QuestionAnswerEntityImp extends QuestionAnswerEntity {
    get id() {
        return this.appObject.id;
    }
    get text() {
        return this.memoizedText.val;
    }
    set text(val) {
        this.memoizedText.val = val;
    }
    get textValidationMessage() {
        if (this.text.length === 0) {
            return EMPTY_TEXT_VALIDATION_MESSAGE;
        }
        else if (this.text.length > MAX_QUESTION_LENGTH) {
            return LONG_TEXT_VALIDATION_MESSAGE;
        }
        else {
            return;
        }
    }
    get feedbackText() {
        return this.memoizedFeedback.val;
    }
    set feedbackText(val) {
        this.memoizedFeedback.val = val;
    }
    get feedbackValidationMessage() {
        if (this.feedbackText.length > MAX_FEEDBACK_LENGTH) {
            return LONG_FEEDBACK_VALIDATION_MESSAGE;
        }
        else {
            return undefined;
        }
    }
    get isCorrect() {
        return this.memoizedIsCorrect.val;
    }
    set isCorrect(val) {
        this.memoizedIsCorrect.val = val;
    }
    get showFeedback() {
        return this.memoizedShowFeedback.val;
    }
    set showFeedback(val) {
        this.memoizedShowFeedback.val = val;
    }
    constructor(appObject) {
        super(appObject, QuestionAnswerEntity.type);
        this.memoizedText = new MemoizedString("", this.notifyOnChange);
        this.memoizedFeedback = new MemoizedString("", this.notifyOnChange);
        this.memoizedIsCorrect = new MemoizedBoolean(false, this.notifyOnChange);
        this.memoizedShowFeedback = new MemoizedBoolean(false, this.notifyOnChange);
    }
}
//# sourceMappingURL=QuestionAnswerEntity.js.map