using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class WhiteListAddressTypeInfo
{
	public static WhiteListAddressTypeEnum ValueToWhiteListAddressType(uint value)
	{
		switch (value)
		{
		case 0u:
			return WhiteListAddressTypeEnum.Public_Device_Address;
		case 1u:
			return WhiteListAddressTypeEnum.Random_Device_Address;
		default:
			if (value >= 2 && value <= 254)
			{
				return WhiteListAddressTypeEnum.Reserved_for_future_use;
			}
			if (value == 255)
			{
				return WhiteListAddressTypeEnum.Devices_sending_anonymous_advertisements;
			}
			return WhiteListAddressTypeEnum.InvalidWhiteListAddressTypeValue;
		}
	}

	public static uint WhiteListAddressTypeToValue(WhiteListAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			WhiteListAddressTypeEnum.Public_Device_Address => 0u, 
			WhiteListAddressTypeEnum.Random_Device_Address => 1u, 
			WhiteListAddressTypeEnum.Reserved_for_future_use => 2u, 
			WhiteListAddressTypeEnum.Devices_sending_anonymous_advertisements => 255u, 
			_ => uint.MaxValue, 
		};
	}

	public static string WhiteListAddressTypeToString(WhiteListAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			WhiteListAddressTypeEnum.Public_Device_Address => "Public Device Address", 
			WhiteListAddressTypeEnum.Random_Device_Address => "Random Device Address", 
			WhiteListAddressTypeEnum.Reserved_for_future_use => "Reserved for future use", 
			WhiteListAddressTypeEnum.Devices_sending_anonymous_advertisements => "Devices sending anonymous advertisements", 
			_ => "Invalid WhiteListAddressType Value", 
		};
	}

	public static string WhiteListAddressTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Public Device Address");
		stringBuilder.AppendLine("0x1 = Random Device Address");
		stringBuilder.AppendLine("0x2-0xFE = Reserved for future use");
		stringBuilder.AppendLine("0xFF = Devices sending anonymous advertisements");
		return stringBuilder.ToString();
	}
}
