import React from 'react';
import { useExamTranslation } from '../../i18n';
export function AnswerCharacterCounter({ characterCount, maxLength }) {
    const { t } = useExamTranslation();
    const percentage = countSurplusPercentage(characterCount, maxLength);
    return (React.createElement("div", { className: "e-font-size-xs e-grading-answer-length" },
        t('answer-length', {
            count: characterCount
        }),
        percentage > 0 ? (React.createElement("span", { className: "e-grading-answer-max-length-surplus" }, t('max-length-surplus', {
            maxLength,
            percentage
        }))) : ('')));
}
function countSurplusPercentage(characters, maxCharacters) {
    if (!maxCharacters || characters <= maxCharacters) {
        return 0;
    }
    return Math.floor((100 * characters) / maxCharacters - 100);
}
//# sourceMappingURL=AnswerCharacterCounter.js.map