import {
	DataFormats,
	DataRateFormats,
	MiscellaneousFormats,
	ThroughputFormats,
	TimeFormats,
} from 'container/NewWidget/RightContainer/types';

export const dataFormatConfig: Record<DataFormats, number> = {
	[DataFormats.BytesIEC]: 1,
	[DataFormats.BytesSI]: 1,
	[DataFormats.BitsIEC]: 1 / 8,
	[DataFormats.BitsSI]: 1 / 8,
	[DataFormats.KibiBytes]: 1024,
	[DataFormats.KiloBytes]: 1000,
	[DataFormats.MebiBytes]: 1024 ** 2,
	[DataFormats.MegaBytes]: 1000 ** 2,
	[DataFormats.GibiBytes]: 1024 ** 3,
	[DataFormats.GigaBytes]: 1000 ** 3,
	[DataFormats.TebiBytes]: 1024 ** 4,
	[DataFormats.TeraBytes]: 1000 ** 4,
	[DataFormats.PebiBytes]: 1024 ** 5,
	[DataFormats.PetaBytes]: 1000 ** 5,
};

export const throughputConfig: Record<ThroughputFormats, number> = {
	[ThroughputFormats.CountsPerSec]: 1,
	[ThroughputFormats.OpsPerSec]: 1,
	[ThroughputFormats.RequestsPerSec]: 1,
	[ThroughputFormats.ReadsPerSec]: 1,
	[ThroughputFormats.WritesPerSec]: 1,
	[ThroughputFormats.IOOpsPerSec]: 1,
	[ThroughputFormats.CountsPerMin]: 1 / 60,
	[ThroughputFormats.OpsPerMin]: 1 / 60,
	[ThroughputFormats.ReadsPerMin]: 1 / 60,
	[ThroughputFormats.WritesPerMin]: 1 / 60,
};

export const timeUnitsConfig: Record<TimeFormats, number> = {
	[TimeFormats.Hertz]: 1,
	[TimeFormats.Nanoseconds]: 1e-9,
	[TimeFormats.Microseconds]: 1e-6,
	[TimeFormats.Milliseconds]: 1e-3,
	[TimeFormats.Seconds]: 1,
	[TimeFormats.Minutes]: 60,
	[TimeFormats.Hours]: 3600,
	[TimeFormats.Days]: 86400,
	[TimeFormats.DurationMs]: 1e-3,
	[TimeFormats.DurationS]: 1,
	[TimeFormats.DurationHms]: 3600,
	[TimeFormats.DurationDhms]: 86400,
	[TimeFormats.Timeticks]: 1e-3,
	[TimeFormats.ClockMs]: 1e-3,
	[TimeFormats.ClockS]: 1,
};

export const dataRateUnitsConfig: Record<DataRateFormats, number> = {
	[DataRateFormats.PacketsPerSec]: 1,
	[DataRateFormats.BytesPerSecIEC]: dataFormatConfig[DataFormats.BytesIEC],
	[DataRateFormats.BytesPerSecSI]: dataFormatConfig[DataFormats.BytesSI],
	[DataRateFormats.BitsPerSecIEC]: dataFormatConfig[DataFormats.BitsIEC],
	[DataRateFormats.BitsPerSecSI]: dataFormatConfig[DataFormats.BitsSI],
	[DataRateFormats.KibiBytesPerSec]: dataFormatConfig[DataFormats.KibiBytes],
	[DataRateFormats.KibiBitsPerSec]: dataFormatConfig[DataFormats.KibiBytes] * 8,
	[DataRateFormats.KiloBytesPerSec]: dataFormatConfig[DataFormats.KiloBytes],
	[DataRateFormats.KiloBitsPerSec]: dataFormatConfig[DataFormats.KiloBytes] * 8,
	[DataRateFormats.MebiBytesPerSec]: dataFormatConfig[DataFormats.MebiBytes],
	[DataRateFormats.MebiBitsPerSec]: dataFormatConfig[DataFormats.MebiBytes] * 8,
	[DataRateFormats.MegaBytesPerSec]: dataFormatConfig[DataFormats.MegaBytes],
	[DataRateFormats.MegaBitsPerSec]: dataFormatConfig[DataFormats.MegaBytes] * 8,
	[DataRateFormats.GibiBytesPerSec]: dataFormatConfig[DataFormats.GibiBytes],
	[DataRateFormats.GibiBitsPerSec]: dataFormatConfig[DataFormats.GibiBytes] * 8,
	[DataRateFormats.GigaBytesPerSec]: dataFormatConfig[DataFormats.GigaBytes],
	[DataRateFormats.GigaBitsPerSec]: dataFormatConfig[DataFormats.GigaBytes] * 8,
	[DataRateFormats.TebiBytesPerSec]: dataFormatConfig[DataFormats.TebiBytes],
	[DataRateFormats.TebiBitsPerSec]: dataFormatConfig[DataFormats.TebiBytes] * 8,
	[DataRateFormats.TeraBytesPerSec]: dataFormatConfig[DataFormats.TeraBytes],
	[DataRateFormats.TeraBitsPerSec]: dataFormatConfig[DataFormats.TeraBytes] * 8,
	[DataRateFormats.PebiBytesPerSec]: dataFormatConfig[DataFormats.PebiBytes],
	[DataRateFormats.PebiBitsPerSec]: dataFormatConfig[DataFormats.PebiBytes] * 8,
	[DataRateFormats.PetaBytesPerSec]: dataFormatConfig[DataFormats.PetaBytes],
	[DataRateFormats.PetaBitsPerSec]: dataFormatConfig[DataFormats.PetaBytes] * 8,
};

export const miscUnitsConfig: Record<MiscellaneousFormats, number> = {
	[MiscellaneousFormats.None]: 1,
	[MiscellaneousFormats.String]: 1,
	[MiscellaneousFormats.Short]: 1,
	[MiscellaneousFormats.Percent]: 0.01,
	[MiscellaneousFormats.PercentUnit]: 1,
	[MiscellaneousFormats.Humidity]: 1,
	[MiscellaneousFormats.Decibel]: 1,
	[MiscellaneousFormats.Hexadecimal0x]: 1,
	[MiscellaneousFormats.Hexadecimal]: 1,
	[MiscellaneousFormats.ScientificNotation]: 1,
	[MiscellaneousFormats.LocaleFormat]: 1,
	[MiscellaneousFormats.Pixels]: 1,
};
