using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class PeerAddressTypeInfo
{
	public static PeerAddressTypeEnum ValueToPeerAddressType(uint value)
	{
		switch (value)
		{
		case 0u:
			return PeerAddressTypeEnum.Public_Device_Address_or_Public_Identity_Address;
		case 1u:
			return PeerAddressTypeEnum.Random_Device_Address_or_Random_static_Identity_Address;
		default:
			if (value >= 2 && value <= 255)
			{
				return PeerAddressTypeEnum.Reserved_for_future_use;
			}
			return PeerAddressTypeEnum.InvalidPeerAddressTypeValue;
		}
	}

	public static uint PeerAddressTypeToValue(PeerAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			PeerAddressTypeEnum.Public_Device_Address_or_Public_Identity_Address => 0u, 
			PeerAddressTypeEnum.Random_Device_Address_or_Random_static_Identity_Address => 1u, 
			PeerAddressTypeEnum.Reserved_for_future_use => 2u, 
			_ => uint.MaxValue, 
		};
	}

	public static string PeerAddressTypeToString(PeerAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			PeerAddressTypeEnum.Public_Device_Address_or_Public_Identity_Address => "Public Device Address or Public Identity Address", 
			PeerAddressTypeEnum.Random_Device_Address_or_Random_static_Identity_Address => "Random Device Address or Random (static) Identity Address", 
			PeerAddressTypeEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid PeerAddressType Value", 
		};
	}

	public static string PeerAddressTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Public Device Address or Public Identity Address");
		stringBuilder.AppendLine("0x1 = Random Device Address or Random (static) Identity Address");
		stringBuilder.AppendLine("0x2-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
