import { jsx as _jsx } from "react/jsx-runtime";
import cx from "classnames";
import { ClientFormatterFacade } from "@gooddata/number-formatter";
export function Label({ value, style, className, }) {
    return (_jsx("div", { className: cx("gd-measure-format-preview-formatted", className), children: _jsx("span", { style: style, children: value }) }));
}
function getFormattedNumber(value, format, separators) {
    return ClientFormatterFacade.formatValue(value, format, separators);
}
export function FormattedPreview({ previewNumber, format, colors = true, separators, className: customClassName, }) {
    if (format === "") {
        return _jsx(Label, {});
    }
    const style = { color: "", backgroundColor: "" };
    const { formattedValue, colors: formattedColors } = getFormattedNumber(previewNumber, format, separators);
    if (colors) {
        style.color = formattedColors.color ?? "";
        style.backgroundColor = formattedColors.backgroundColor ?? "";
    }
    return _jsx(Label, { value: formattedValue, className: customClassName, style: style });
}
