import { getText } from "../../../../locales";
var THOUSAND = 1000;
var MILLION = 1000000;
var BILLION = 1000000000;
var getUnitText = function getUnitText(key) {
  var textKey = "pisell-number-format-".concat(key);
  return getText(textKey);
};
export var formatNumberWithUnit = function formatNumberWithUnit(value) {
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  var previewFormatter = arguments.length > 2 ? arguments[2] : undefined;
  if (!value) return '0';
  var units = {
    billion: {
      value: BILLION,
      getText: function getText() {
        return getUnitText('billion');
      }
    },
    million: {
      value: MILLION,
      getText: function getText() {
        return getUnitText('million');
      }
    },
    thousand: {
      value: THOUSAND,
      getText: function getText() {
        return getUnitText('thousand');
      }
    }
  };
  if (!previewFormatter || previewFormatter === 'none') {
    return value.toFixed(precision);
  }
  var unit = units[previewFormatter];
  if (!unit) return value.toFixed(precision);
  var convertedValue = value / unit.value;
  var suffix = unit.getText();
  return "".concat(convertedValue.toFixed(precision)).concat(suffix);
};