import { g as getDefaultExportFromCjs } from './_commonjsHelpers-BFTU3MAI.js';

var numberAbbreviate$1 = {exports: {}};

var numberAbbreviate = numberAbbreviate$1.exports;

var hasRequiredNumberAbbreviate;

function requireNumberAbbreviate () {
	if (hasRequiredNumberAbbreviate) return numberAbbreviate$1.exports;
	hasRequiredNumberAbbreviate = 1;
	(function (module) {
		(function(root){

		  function NumberAbbreviate() {
		    var units;
		    if (!(this instanceof NumberAbbreviate)) {
		      // function usage: abbrev(n, decPlaces, units)
		      var n = arguments[0];
		      var decPlaces = arguments[1];
		      units = arguments[2];
		      var ab = new NumberAbbreviate(units);
		      return ab.abbreviate(n, decPlaces)
		    }
		    // class usage: new NumberAbbreviate(units)
		    units = arguments[0];
		    this.units = units == null ? ['k', 'm', 'b', 't'] : units;
		  }

		  NumberAbbreviate.prototype._abbreviate = function(number, decPlaces) {
		    decPlaces = Math.pow(10, decPlaces);

		    for (var i = this.units.length - 1; i >= 0; i--) {

		      var size = Math.pow(10, (i + 1) * 3);

		      if (size <= number) {
		        number = Math.round(number * decPlaces / size) / decPlaces;

		        if ((number === 1000) && (i < this.units.length - 1)) {
		          number = 1;
		          i++;
		        }

		        number += this.units[i];

		        break
		      }
		    }

		    return number
		  };

		  NumberAbbreviate.prototype.abbreviate = function(number, decPlaces) {
		    var isNegative = number < 0;
		    var abbreviatedNumber = this._abbreviate(Math.abs(number), decPlaces || 0);

		    return isNegative ? '-' + abbreviatedNumber : abbreviatedNumber;
		  };

		  if (module.exports) {
		    module.exports = NumberAbbreviate;
		  } else {
		    root.NumberAbbreviate = NumberAbbreviate;
		  }

		})(numberAbbreviate); 
	} (numberAbbreviate$1));
	return numberAbbreviate$1.exports;
}

var numberAbbreviateExports = requireNumberAbbreviate();
var NumAbbr = /*@__PURE__*/getDefaultExportFromCjs(numberAbbreviateExports);

/**
 * Abbreviate a number
 *
 * @param value - the number to abbreviate
 * @returns abbreviated number
 */
function abbreviate(value) {
    if (typeof value !== 'number') {
        return '';
    }
    const units = ['k', 'M', 'B', 'T'];
    const numAbbr = new NumAbbr(units);
    return numAbbr.abbreviate(value, 1);
}

export { abbreviate as a };
