import "./index-DfebxkL9.js";
import { i as instance } from "./vendor-i18n-wisIXUFi.js";
const BYTES_IN_GB = 1024 * 1024 * 1024;
const BYTES_IN_MB = 1024 * 1024;
const BYTES_IN_KB = 1024;
const formatNumber = (number) => {
  return new Intl.NumberFormat(instance.language || "ru-RU").format(number);
};
const formatByteToGb = (size) => {
  if (!size || isNaN(size) || size < 1) {
    return "0";
  }
  const marker = BYTES_IN_GB;
  const gigabytes = parseFloat((size / marker).toFixed(4));
  const options = {
    style: "unit",
    unit: "gigabyte"
    /* gigabyte */
  };
  return gigabytes > 0 ? new Intl.NumberFormat(instance.language || "ru-RU", options).format(gigabytes) : "0";
};
const formatDataSizeUnits = (size) => {
  var _a;
  if (!size || isNaN(size) || size < 1) {
    return "0";
  }
  const terabytes = size / (BYTES_IN_GB * 1024);
  const gigabytes = size / BYTES_IN_GB;
  const megabytes = size / BYTES_IN_MB;
  const kilobytes = size / BYTES_IN_KB;
  let formattedSize;
  let unit;
  if (terabytes >= 1) {
    formattedSize = parseFloat(terabytes.toFixed(1));
    unit = "terabyte";
  } else if (gigabytes >= 1) {
    formattedSize = parseFloat(gigabytes.toFixed(1));
    unit = "gigabyte";
  } else if (megabytes >= 1) {
    formattedSize = parseFloat(megabytes.toFixed(1));
    unit = "megabyte";
  } else {
    formattedSize = parseFloat(kilobytes.toFixed(1));
    unit = "kilobyte";
  }
  const options = {
    style: "unit",
    unit
  };
  return (_a = new Intl.NumberFormat(instance.language || "ru-Ru", options).format(formattedSize)) == null ? void 0 : _a.toUpperCase();
};
const convertByteToGb = (size) => {
  if (!size || isNaN(size) || size < 0) {
    return 0;
  }
  const marker = BYTES_IN_GB;
  return parseFloat((size / marker).toFixed(2));
};
const convertGbToByte = (size) => {
  if (!size || isNaN(size) || size < 0) {
    return 0;
  }
  const marker = BYTES_IN_GB;
  return size * marker;
};
export {
  formatDataSizeUnits as a,
  convertGbToByte as b,
  convertByteToGb as c,
  formatNumber as d,
  formatByteToGb as f
};
//# sourceMappingURL=format-CMT-x-V3.js.map
