import { styled } from '@linaria/react';
import Bit from '../../core/Bit/index.js';
import BitPerSecond from '../../core/BitPerSecond/index.js';
import Bps from '../../core/Bps/index.js';
import Byte from '../../core/Byte/index.js';
import BytePerSecond from '../../core/BytePerSecond/index.js';
import Empty from '../../core/Empty/index.js';
import Frequency from '../../core/Frequency/index.js';
import Percent from '../../core/Percent/index.js';
import Second from '../../core/Second/index.js';
import Speed from '../../core/Speed/index.js';
import BarChart from '../BarChart/index.js';
import DeprecatedDonutChart from '../DeprecatedDonutChart/index.js';
import React__default from 'react';

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
  enumerable: true,
  configurable: true,
  writable: true,
  value
}) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
    if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  }
  return a;
};
const units = {
  Percent,
  Byte,
  BytePerSecond,
  Frequency,
  Speed,
  Bps,
  BitPerSecond,
  Bit,
  Second
};
const Wrapper = /*#__PURE__*/styled('div')({
  name: "Wrapper",
  class: "E_4100_0_7_wg1tsps",
  propsAsIs: false
});
const BarChartWrapper = "E_4100_0_7_b1ctd5xy";
const UnitWrapper = "E_4100_0_7_u1p8acpn";
const Sizes = {
  small: {
    width: 22,
    height: 22,
    barSize: 4,
    innerRadius: 8,
    outerRadius: 16
  },
  medium: {
    width: 50,
    height: 50,
    barSize: 8,
    innerRadius: 18,
    outerRadius: 34
  },
  large: {
    width: 100,
    height: 100,
    barSize: 15,
    innerRadius: 40,
    outerRadius: 70
  }
};
const UnitWithChart = ({
  rawValue,
  total,
  unit,
  color = "#0080FF",
  size = "small",
  chartType = "donutChart",
  data,
  saturated
}) => {
  if (typeof rawValue !== "number" || typeof total !== "number") {
    return /* @__PURE__ */React__default.createElement(Empty, null);
  }
  const Unit = units[unit];
  return /* @__PURE__ */React__default.createElement(Wrapper, {
    className: "unit-chart"
  }, chartType === "barChart" && /* @__PURE__ */React__default.createElement("span", {
    className: BarChartWrapper
  }, /* @__PURE__ */React__default.createElement("span", {
    className: "chart"
  }, /* @__PURE__ */React__default.createElement(BarChart, {
    data: data || [],
    total
  }))), /* @__PURE__ */React__default.createElement("span", {
    className: UnitWrapper
  }, unit === "Percent" ? /* @__PURE__ */React__default.createElement(Percent, {
    rawValue,
    decimals: 1,
    saturated
  }) : /* @__PURE__ */React__default.createElement(Unit, {
    rawValue
  })), chartType === "donutChart" && /* @__PURE__ */React__default.createElement(DeprecatedDonutChart, __spreadValues({
    data: [{
      used: rawValue / total,
      fill: color
    }],
    dataKey: "used"
  }, Sizes[size])));
};
var UnitWithChart$1 = UnitWithChart;

export { UnitWrapper, UnitWithChart$1 as default };
