using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class PeerResolvableAddressTypeInfo
{
	public static PeerResolvableAddressTypeEnum ValueToPeerResolvableAddressType(uint value)
	{
		switch (value)
		{
		case 0u:
			return PeerResolvableAddressTypeEnum.Public_Device_Address;
		case 1u:
			return PeerResolvableAddressTypeEnum.Random_Device_Address;
		case 2u:
			return PeerResolvableAddressTypeEnum.Public_Identity_Address_corresponds_to_Resolved_Private_Address;
		case 3u:
			return PeerResolvableAddressTypeEnum.Random_static_Identity_Address_corresponds_to_Resolved_Private_Address;
		default:
			if (value >= 4 && value <= 255)
			{
				return PeerResolvableAddressTypeEnum.Reserved_for_future_use;
			}
			return PeerResolvableAddressTypeEnum.InvalidPeerResolvableAddressTypeValue;
		}
	}

	public static uint PeerResolvableAddressTypeToValue(PeerResolvableAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			PeerResolvableAddressTypeEnum.Public_Device_Address => 0u, 
			PeerResolvableAddressTypeEnum.Random_Device_Address => 1u, 
			PeerResolvableAddressTypeEnum.Public_Identity_Address_corresponds_to_Resolved_Private_Address => 2u, 
			PeerResolvableAddressTypeEnum.Random_static_Identity_Address_corresponds_to_Resolved_Private_Address => 3u, 
			PeerResolvableAddressTypeEnum.Reserved_for_future_use => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string PeerResolvableAddressTypeToString(PeerResolvableAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			PeerResolvableAddressTypeEnum.Public_Device_Address => "Public Device Address", 
			PeerResolvableAddressTypeEnum.Random_Device_Address => "Random Device Address", 
			PeerResolvableAddressTypeEnum.Public_Identity_Address_corresponds_to_Resolved_Private_Address => "Public Identity Address (corresponds to Resolved Private Address)", 
			PeerResolvableAddressTypeEnum.Random_static_Identity_Address_corresponds_to_Resolved_Private_Address => "Random (static) Identity Address (corresponds to Resolved Private Address)", 
			PeerResolvableAddressTypeEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid PeerResolvableAddressType Value", 
		};
	}

	public static string PeerResolvableAddressTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Public Device Address");
		stringBuilder.AppendLine("0x1 = Random Device Address");
		stringBuilder.AppendLine("0x2 = Public Identity Address (corresponds to Resolved Private Address)");
		stringBuilder.AppendLine("0x3 = Random (static) Identity Address (corresponds to Resolved Private Address)");
		stringBuilder.AppendLine("0x4-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
