import React, { memo } from 'react';
import classNames from 'classnames';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faImage } from '@fortawesome/free-solid-svg-icons';
const AnswerIndicator = (props) => {
    const { id, type, answer, error, displayNumber } = props;
    const value = answer === null || answer === void 0 ? void 0 : answer.value;
    const answerIsLongText = (answer === null || answer === void 0 ? void 0 : answer.type) === 'richText';
    const answerIsFormula = answerIsLongText && (value === null || value === void 0 ? void 0 : value.includes('src="/math.svg?latex='));
    const answerIsImage = answerIsLongText && ((value === null || value === void 0 ? void 0 : value.includes('<img src="/screenshot/')) || (value === null || value === void 0 ? void 0 : value.includes('<img src="data:image/png;')));
    const onClick = (e) => {
        e.stopPropagation();
        window.location.href = `#question-nr-${displayNumber}`;
    };
    return (React.createElement("div", { className: "answer-indicator-container", onClick: onClick, key: id },
        React.createElement("div", { className: classNames('answer-indicator', {
                ok: value && !error,
                error,
                big: type === 'rich-text'
            }), "data-indicator-id": id }, (answer === null || answer === void 0 ? void 0 : answer.type) === 'richText' && (React.createElement(React.Fragment, null,
            (answerIsLongText && (answer === null || answer === void 0 ? void 0 : answer.characterCount) && React.createElement("span", null, answer.characterCount)) || '',
            answerIsFormula && React.createElement("span", { className: "formula" }, "\u2211"),
            answerIsImage && (React.createElement("span", { className: "img" },
                React.createElement(FontAwesomeIcon, { icon: faImage, size: "lg" }))))))));
};
export const Indicator = memo(AnswerIndicator);
//# sourceMappingURL=AnswerIndicator.js.map