using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class InquiryModeInfo
{
	public static InquiryModeEnum ValueToInquiryMode(uint value)
	{
		switch (value)
		{
		case 0u:
			return InquiryModeEnum.Standard_Inquiry_Result_event_format;
		case 1u:
			return InquiryModeEnum.Inquiry_Result_format_with_RSSI;
		case 2u:
			return InquiryModeEnum.Inquiry_Result_with_RSSI_format_or_Extended_Inquiry_Result_format;
		default:
			if (value >= 3 && value <= 255)
			{
				return InquiryModeEnum.RESERVED;
			}
			return InquiryModeEnum.InvalidInquiryModeValue;
		}
	}

	public static uint InquiryModeToValue(InquiryModeEnum enumItem)
	{
		return enumItem switch
		{
			InquiryModeEnum.Standard_Inquiry_Result_event_format => 0u, 
			InquiryModeEnum.Inquiry_Result_format_with_RSSI => 1u, 
			InquiryModeEnum.Inquiry_Result_with_RSSI_format_or_Extended_Inquiry_Result_format => 2u, 
			InquiryModeEnum.RESERVED => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string InquiryModeToString(InquiryModeEnum enumItem)
	{
		return enumItem switch
		{
			InquiryModeEnum.Standard_Inquiry_Result_event_format => "Standard_Inquiry_Result_event_format", 
			InquiryModeEnum.Inquiry_Result_format_with_RSSI => "Inquiry_Result_format_with_RSSI", 
			InquiryModeEnum.Inquiry_Result_with_RSSI_format_or_Extended_Inquiry_Result_format => "Inquiry_Result_with_RSSI_format_or_Extended_Inquiry_Result_format", 
			InquiryModeEnum.RESERVED => "Reserved", 
			_ => "Invalid InquiryMode Value", 
		};
	}

	public static string InquiryModeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Standard_Inquiry_Result_event_format");
		stringBuilder.AppendLine("0x1 = Inquiry_Result_format_with_RSSI");
		stringBuilder.AppendLine("0x2 = Inquiry_Result_with_RSSI_format_or_Extended_Inquiry_Result_format");
		stringBuilder.AppendLine("0x3-0xFF = Reserved");
		return stringBuilder.ToString();
	}
}
