import { jsx as _jsx } from "react/jsx-runtime";
import get from "lodash/get";
import { HighlightedText } from "./HighlightedText";
export function DetailTextContent({ result, path, isHighlighted = true, }) {
    const hihglithTextLines = result.highlight[path];
    const text = get(result.source, path);
    if (!text || typeof text !== "string")
        return null;
    const textWithBreaksAndTabsAndCarriageReturns = text
        .replace(/\r/g, "")
        .replace(/\n/g, "<br />")
        .replace(/\t/g, "&emsp;");
    if (!isHighlighted)
        return (_jsx("div", { dangerouslySetInnerHTML: {
                __html: textWithBreaksAndTabsAndCarriageReturns,
            } }));
    if (hihglithTextLines) {
        return (_jsx("div", { className: "openk9-embeddable-detail-text-content", children: hihglithTextLines.map((text, index) => (_jsx("div", { className: "openk9-embeddable-hihglith-text-lines", children: _jsx(HighlightedText, { text: text }) }, index))) }));
    }
    return _jsx("div", { children: text });
}
