import _extends from "@babel/runtime/helpers/esm/extends";
import React, { forwardRef } from "react";
import { formatCurrency, formatNumber } from "../../utils";
import { Tooltip } from "../Tooltip";
import { Typography } from "../Typography/Typography";
export const DisplayCurrency = /*#__PURE__*/forwardRef((_ref, ref) => {
  let {
    value,
    variant = "Body 2",
    currencyCode = "USD",
    currencyPosition = "right",
    thousandSeparator = ",",
    decimalSeparator = ".",
    trimDecimals = true,
    decimalSpaces = 2,
    format = "long",
    disableTooltip = false,
    className,
    as = "span",
    currencyClassName,
    ...rest
  } = _ref;
  const formattedValue = formatNumber(value, thousandSeparator, decimalSeparator, trimDecimals, decimalSpaces, "short", 10000);
  const formattedLongValue = formatNumber(value, thousandSeparator, decimalSeparator, trimDecimals, decimalSpaces, "long", 10000);
  if (format === "short") {
    return /*#__PURE__*/React.createElement(Tooltip, {
      title: formatCurrency(value, thousandSeparator, decimalSeparator, false, decimalSpaces, "long", currencyCode, currencyPosition),
      disable: disableTooltip || !formattedLongValue.includes(thousandSeparator) && !formattedLongValue.includes(decimalSeparator)
    }, /*#__PURE__*/React.createElement(Typography, _extends({
      as: as,
      variant: variant,
      className: className,
      ref: ref
    }, rest), currencyPosition === "left" ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
      className: currencyClassName
    }, currencyCode), " ", formattedValue) : /*#__PURE__*/React.createElement(React.Fragment, null, formattedValue, " ", /*#__PURE__*/React.createElement("span", {
      className: currencyClassName
    }, currencyCode))));
  }
  return /*#__PURE__*/React.createElement(Typography, _extends({
    as: as,
    variant: variant,
    className: className,
    ref: ref
  }, rest), currencyPosition === "left" ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
    className: currencyClassName
  }, currencyCode), " ", formattedLongValue) : /*#__PURE__*/React.createElement(React.Fragment, null, formattedLongValue, " ", /*#__PURE__*/React.createElement("span", {
    className: currencyClassName
  }, currencyCode)));
});
DisplayCurrency.displayName = "DisplayCurrency";
//# sourceMappingURL=DisplayCurrency.js.map