import _extends from "@babel/runtime/helpers/esm/extends";
import React, { forwardRef } from "react";
import { formatCurrency } 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",
    ...rest
  } = _ref;
  const formattedValue = formatCurrency(value, thousandSeparator, decimalSeparator, trimDecimals, decimalSpaces, "short", currencyCode, currencyPosition);
  const formattedLongValue = formatCurrency(value, thousandSeparator, decimalSeparator, trimDecimals, decimalSpaces, "long", currencyCode, currencyPosition);
  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), formattedValue));
  }
  return /*#__PURE__*/React.createElement(Typography, _extends({
    as: as,
    variant: variant,
    className: className,
    ref: ref
  }, rest), formattedLongValue);
});
DisplayCurrency.displayName = "DisplayCurrency";
//# sourceMappingURL=DisplayCurrency.js.map