"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuestionAnswerEntity = exports.LONG_FEEDBACK_VALIDATION_MESSAGE = exports.MAX_FEEDBACK_LENGTH = exports.LONG_TEXT_VALIDATION_MESSAGE = exports.MAX_QUESTION_LENGTH = exports.EMPTY_TEXT_VALIDATION_MESSAGE = void 0;
exports.makeQuestionAnswerEntity = makeQuestionAnswerEntity;
const core_1 = require("@vived/core");
exports.EMPTY_TEXT_VALIDATION_MESSAGE = "Answer text is required.";
exports.MAX_QUESTION_LENGTH = 40;
exports.LONG_TEXT_VALIDATION_MESSAGE = `Answer text may not exceed ${exports.MAX_QUESTION_LENGTH} characters.`;
exports.MAX_FEEDBACK_LENGTH = 200;
exports.LONG_FEEDBACK_VALIDATION_MESSAGE = `Answer feedback may not exceed ${exports.MAX_FEEDBACK_LENGTH} characters.`;
class QuestionAnswerEntity extends core_1.AppObjectEntity {
}
exports.QuestionAnswerEntity = QuestionAnswerEntity;
QuestionAnswerEntity.type = "QuestionAnswerEntity";
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 exports.EMPTY_TEXT_VALIDATION_MESSAGE;
        }
        else if (this.text.length > exports.MAX_QUESTION_LENGTH) {
            return exports.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 > exports.MAX_FEEDBACK_LENGTH) {
            return exports.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 core_1.MemoizedString("", this.notifyOnChange);
        this.memoizedFeedback = new core_1.MemoizedString("", this.notifyOnChange);
        this.memoizedIsCorrect = new core_1.MemoizedBoolean(false, this.notifyOnChange);
        this.memoizedShowFeedback = new core_1.MemoizedBoolean(false, this.notifyOnChange);
    }
}
//# sourceMappingURL=QuestionAnswerEntity.js.map