"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormattedText = void 0;
const react_1 = __importDefault(require("react"));
const FormattedText_css_1 = __importDefault(require("./FormattedText.css"));
/**
 * FormattedText replaces new line characters with HTML line breaks (`<br />`).
 * Use this component when you want to render text created by an editor or a `<textarea>`.
 * For more complex use cases involving basic HTML tags, format the content as a React component
 * and pass it in as a child. The component will recieve customized styling based on the supported tags.
 */
function FormattedText({ children }) {
    if (typeof children === 'string') {
        return (<>
        {children
            .split('\n')
            .filter(Boolean)
            .map((content, index) => (<>
              {index > 0 && <br />}
              {content}
            </>))}
      </>);
    }
    else {
        return <div className={FormattedText_css_1.default.FormattedText}>{children}</div>;
    }
}
exports.FormattedText = FormattedText;
