import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
export var fixedDecimalValue = function fixedDecimalValue(value, decimalSeparator, fixedDecimalLength) {
  if (fixedDecimalLength !== undefined && value.length > 1) {
    if (fixedDecimalLength === 0) {
      return value.replace(decimalSeparator, '');
    }
    if (value.includes(decimalSeparator)) {
      var _value$split = value.split(decimalSeparator),
        _value$split2 = _slicedToArray(_value$split, 2),
        _int = _value$split2[0],
        decimals = _value$split2[1];
      if (decimals.length === fixedDecimalLength) {
        return value;
      }
      if (decimals.length > fixedDecimalLength) {
        return "".concat(_int).concat(decimalSeparator).concat(decimals.slice(0, fixedDecimalLength));
      }
    }
    var reg = value.length > fixedDecimalLength ? new RegExp("(\\d+)(\\d{".concat(fixedDecimalLength, "})")) : new RegExp("(\\d)(\\d+)");
    var match = value.match(reg);
    if (match) {
      var _match = _slicedToArray(match, 3),
        _int2 = _match[1],
        _decimals = _match[2];
      return "".concat(_int2).concat(decimalSeparator).concat(_decimals);
    }
  }
  return value;
};