using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AdvertisingFilterPolicyInfo
{
	public static AdvertisingFilterPolicyEnum ValueToAdvertisingFilterPolicy(uint value)
	{
		switch (value)
		{
		case 0u:
			return AdvertisingFilterPolicyEnum.Process_scan_and_connection_requests_from_all_devices;
		case 1u:
			return AdvertisingFilterPolicyEnum.Process_connection_requests_from_all_devices_and_only_scan_requests_from_devices_that_are_in_the_White_List;
		case 2u:
			return AdvertisingFilterPolicyEnum.Process_scan_requests_from_all_devices_and_only_connection_requests_from_devices_that_are_in_the_White_List;
		case 3u:
			return AdvertisingFilterPolicyEnum.Process_scan_and_connection_requests_only_from_devices_in_the_White_List;
		default:
			if (value >= 4 && value <= 255)
			{
				return AdvertisingFilterPolicyEnum.Reserved_for_future_use;
			}
			return AdvertisingFilterPolicyEnum.InvalidAdvertisingFilterPolicyValue;
		}
	}

	public static uint AdvertisingFilterPolicyToValue(AdvertisingFilterPolicyEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingFilterPolicyEnum.Process_scan_and_connection_requests_from_all_devices => 0u, 
			AdvertisingFilterPolicyEnum.Process_connection_requests_from_all_devices_and_only_scan_requests_from_devices_that_are_in_the_White_List => 1u, 
			AdvertisingFilterPolicyEnum.Process_scan_requests_from_all_devices_and_only_connection_requests_from_devices_that_are_in_the_White_List => 2u, 
			AdvertisingFilterPolicyEnum.Process_scan_and_connection_requests_only_from_devices_in_the_White_List => 3u, 
			AdvertisingFilterPolicyEnum.Reserved_for_future_use => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string AdvertisingFilterPolicyToString(AdvertisingFilterPolicyEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingFilterPolicyEnum.Process_scan_and_connection_requests_from_all_devices => "Process scan and connection requests from all devices (i.e., the White List is not in use).", 
			AdvertisingFilterPolicyEnum.Process_connection_requests_from_all_devices_and_only_scan_requests_from_devices_that_are_in_the_White_List => "Process connection requests from all devices and only scan requests from devices that are in the White List.", 
			AdvertisingFilterPolicyEnum.Process_scan_requests_from_all_devices_and_only_connection_requests_from_devices_that_are_in_the_White_List => "Process scan requests from all devices and only connection requests from devices that are in the White List.", 
			AdvertisingFilterPolicyEnum.Process_scan_and_connection_requests_only_from_devices_in_the_White_List => "Process scan and connection requests only from devices in the White List.", 
			AdvertisingFilterPolicyEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid AdvertisingFilterPolicy Value", 
		};
	}

	public static string AdvertisingFilterPolicyToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Process scan and connection requests from all devices (i.e., the White List is not in use).");
		stringBuilder.AppendLine("0x1 = Process connection requests from all devices and only scan requests from devices that are in the White List.");
		stringBuilder.AppendLine("0x2 = Process scan requests from all devices and only connection requests from devices that are in the White List.");
		stringBuilder.AppendLine("0x3 = Process scan and connection requests only from devices in the White List.");
		stringBuilder.AppendLine("0x4-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
