using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class RfProtocolsInfo
{
	public static RfProtocolsEnum ValueToRfProtocols(uint value)
	{
		switch (value)
		{
		case 0u:
			return RfProtocolsEnum.UNKNOWN;
		case 1u:
			return RfProtocolsEnum.PROTOCOL_T1T;
		case 2u:
			return RfProtocolsEnum.PROTOCOL_T2T;
		case 3u:
			return RfProtocolsEnum.PROTOCOL_T3T;
		case 4u:
			return RfProtocolsEnum.PROTOCOL_ISO_DEP;
		case 5u:
			return RfProtocolsEnum.PROTOCOL_NFC_DEP;
		default:
			if (value >= 6 && value <= 127)
			{
				return RfProtocolsEnum.RFU;
			}
			if (value >= 128 && value <= 254)
			{
				return RfProtocolsEnum.PROPRIETARY;
			}
			if (value == 255)
			{
				return RfProtocolsEnum.RFU;
			}
			return RfProtocolsEnum.InvalidRfProtocolsValue;
		}
	}

	public static uint RfProtocolsToValue(RfProtocolsEnum enumItem)
	{
		switch (enumItem)
		{
		case RfProtocolsEnum.UNKNOWN:
			return 0u;
		case RfProtocolsEnum.PROTOCOL_T1T:
			return 1u;
		case RfProtocolsEnum.PROTOCOL_T2T:
			return 2u;
		case RfProtocolsEnum.PROTOCOL_T3T:
			return 3u;
		case RfProtocolsEnum.PROTOCOL_ISO_DEP:
			return 4u;
		case RfProtocolsEnum.PROTOCOL_NFC_DEP:
			return 5u;
		case RfProtocolsEnum.RFU:
			return 6u;
		case RfProtocolsEnum.PROPRIETARY:
			return 128u;
		default:
			if (enumItem == RfProtocolsEnum.RFU)
			{
				return 255u;
			}
			return uint.MaxValue;
		}
	}

	public static string RfProtocolsToString(RfProtocolsEnum enumItem)
	{
		switch (enumItem)
		{
		case RfProtocolsEnum.UNKNOWN:
			return "UNKNOWN";
		case RfProtocolsEnum.PROTOCOL_T1T:
			return "PROTOCOL_T1T";
		case RfProtocolsEnum.PROTOCOL_T2T:
			return "PROTOCOL_T2T";
		case RfProtocolsEnum.PROTOCOL_T3T:
			return "PROTOCOL_T3T";
		case RfProtocolsEnum.PROTOCOL_ISO_DEP:
			return "PROTOCOL_ISO_DEP";
		case RfProtocolsEnum.PROTOCOL_NFC_DEP:
			return "PROTOCOL_NFC_DEP";
		case RfProtocolsEnum.RFU:
			return "RFU";
		case RfProtocolsEnum.PROPRIETARY:
			return "PROPRIETARY";
		default:
			if (enumItem == RfProtocolsEnum.RFU)
			{
				return "RFU";
			}
			return "Invalid RfProtocols Value";
		}
	}

	public static string RfProtocolsToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = UNKNOWN");
		stringBuilder.AppendLine("0x1 = PROTOCOL_T1T");
		stringBuilder.AppendLine("0x2 = PROTOCOL_T2T");
		stringBuilder.AppendLine("0x3 = PROTOCOL_T3T");
		stringBuilder.AppendLine("0x4 = PROTOCOL_ISO_DEP");
		stringBuilder.AppendLine("0x5 = PROTOCOL_NFC_DEP");
		stringBuilder.AppendLine("0x6-0x7F = RFU");
		stringBuilder.AppendLine("0x80-0xFE = PROPRIETARY");
		stringBuilder.AppendLine("0xFF = RFU");
		return stringBuilder.ToString();
	}
}
