using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class ScanEnableInfo
{
	public static ScanEnableEnum ValueToScanEnable(uint value)
	{
		switch (value)
		{
		case 0u:
			return ScanEnableEnum.No_Scans_enabled;
		case 1u:
			return ScanEnableEnum.Inquiry_Scan_enabled_Page_Scan_disabled;
		case 2u:
			return ScanEnableEnum.Inquiry_Scan_disabled_Page_Scan_enabled;
		case 3u:
			return ScanEnableEnum.Inquiry_Scan_enabled_Page_Scan_enabled;
		default:
			if (value >= 4 && value <= 255)
			{
				return ScanEnableEnum.RESERVED;
			}
			return ScanEnableEnum.InvalidScanEnableValue;
		}
	}

	public static uint ScanEnableToValue(ScanEnableEnum enumItem)
	{
		return enumItem switch
		{
			ScanEnableEnum.No_Scans_enabled => 0u, 
			ScanEnableEnum.Inquiry_Scan_enabled_Page_Scan_disabled => 1u, 
			ScanEnableEnum.Inquiry_Scan_disabled_Page_Scan_enabled => 2u, 
			ScanEnableEnum.Inquiry_Scan_enabled_Page_Scan_enabled => 3u, 
			ScanEnableEnum.RESERVED => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string ScanEnableToString(ScanEnableEnum enumItem)
	{
		return enumItem switch
		{
			ScanEnableEnum.No_Scans_enabled => "No_Scans_enabled", 
			ScanEnableEnum.Inquiry_Scan_enabled_Page_Scan_disabled => "Inquiry_Scan_enabled_Page_Scan_disabled", 
			ScanEnableEnum.Inquiry_Scan_disabled_Page_Scan_enabled => "Inquiry_Scan_disabled_Page_Scan_enabled", 
			ScanEnableEnum.Inquiry_Scan_enabled_Page_Scan_enabled => "Inquiry_Scan_enabled_Page_Scan_enabled", 
			ScanEnableEnum.RESERVED => "Reserved", 
			_ => "Invalid ScanEnable Value", 
		};
	}

	public static string ScanEnableToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = No_Scans_enabled");
		stringBuilder.AppendLine("0x1 = Inquiry_Scan_enabled_Page_Scan_disabled");
		stringBuilder.AppendLine("0x2 = Inquiry_Scan_disabled_Page_Scan_enabled");
		stringBuilder.AppendLine("0x3 = Inquiry_Scan_enabled_Page_Scan_enabled");
		stringBuilder.AppendLine("0x4-0xFF = Reserved");
		return stringBuilder.ToString();
	}
}
