using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class RfTechnologiesInfo
{
	public static RfTechnologiesEnum ValueToRfTechnologies(uint value)
	{
		switch (value)
		{
		case 0u:
			return RfTechnologiesEnum.NFC_RF_TECHNOLOGY_A;
		case 1u:
			return RfTechnologiesEnum.NFC_RF_TECHNOLOGY_B;
		case 2u:
			return RfTechnologiesEnum.NFC_RF_TECHNOLOGY_F;
		case 3u:
			return RfTechnologiesEnum.NFC_RF_TECHNOLOGY_15693;
		default:
			if (value >= 4 && value <= 127)
			{
				return RfTechnologiesEnum.RFU;
			}
			if (value >= 128 && value <= 254)
			{
				return RfTechnologiesEnum.PROPRIETARY;
			}
			if (value == 255)
			{
				return RfTechnologiesEnum.RFU;
			}
			return RfTechnologiesEnum.InvalidRfTechnologiesValue;
		}
	}

	public static uint RfTechnologiesToValue(RfTechnologiesEnum enumItem)
	{
		switch (enumItem)
		{
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_A:
			return 0u;
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_B:
			return 1u;
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_F:
			return 2u;
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_15693:
			return 3u;
		case RfTechnologiesEnum.RFU:
			return 4u;
		case RfTechnologiesEnum.PROPRIETARY:
			return 128u;
		default:
			if (enumItem == RfTechnologiesEnum.RFU)
			{
				return 255u;
			}
			return uint.MaxValue;
		}
	}

	public static string RfTechnologiesToString(RfTechnologiesEnum enumItem)
	{
		switch (enumItem)
		{
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_A:
			return "NFC_RF_TECHNOLOGY_A";
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_B:
			return "NFC_RF_TECHNOLOGY_B";
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_F:
			return "NFC_RF_TECHNOLOGY_F";
		case RfTechnologiesEnum.NFC_RF_TECHNOLOGY_15693:
			return "NFC_RF_TECHNOLOGY_15693";
		case RfTechnologiesEnum.RFU:
			return "RFU";
		case RfTechnologiesEnum.PROPRIETARY:
			return "PROPRIETARY";
		default:
			if (enumItem == RfTechnologiesEnum.RFU)
			{
				return "RFU";
			}
			return "Invalid RfTechnologies Value";
		}
	}

	public static string RfTechnologiesToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = NFC_RF_TECHNOLOGY_A");
		stringBuilder.AppendLine("0x1 = NFC_RF_TECHNOLOGY_B");
		stringBuilder.AppendLine("0x2 = NFC_RF_TECHNOLOGY_F");
		stringBuilder.AppendLine("0x3 = NFC_RF_TECHNOLOGY_15693");
		stringBuilder.AppendLine("0x4-0x7F = RFU");
		stringBuilder.AppendLine("0x80-0xFE = PROPRIETARY");
		stringBuilder.AppendLine("0xFF = RFU");
		return stringBuilder.ToString();
	}
}
