import { formatNumberWithUnit } from "./utils.js";
import React from "react";
import classNames from "classnames";
import "./ReadPretty.less";
//#region src/components/dataSourceComponents/fields/InputNumber/ReadPretty.tsx
const ReadPretty = (props) => {
	const { value, useThousandsSeparator, previewFormatter, precision = 0, addonAfter, renderMode } = props;
	const className = classNames("pisell-input-number-read-pretty", { "pisell-input-number-read-pretty-table-view": renderMode === "tableView" });
	if (!value && value !== 0) return /* @__PURE__ */ React.createElement("span", { className }, "-");
	const formattedValue = formatNumberWithUnit(Number(value), precision, previewFormatter);
	if (useThousandsSeparator && (!previewFormatter || previewFormatter === "none")) {
		const parts = formattedValue.split(".");
		parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
		return /* @__PURE__ */ React.createElement("span", { className }, parts.join("."), addonAfter);
	}
	return /* @__PURE__ */ React.createElement("span", { className }, formattedValue, addonAfter);
};
//#endregion
export { ReadPretty as default };
