using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class DeactivationTypesInfo
{
	public static DeactivationTypesEnum ValueToDeactivationTypes(uint value)
	{
		switch (value)
		{
		case 0u:
			return DeactivationTypesEnum.IDLE_MODE;
		case 1u:
			return DeactivationTypesEnum.SLEEP_MODE;
		case 2u:
			return DeactivationTypesEnum.SLEEP_AF_MODE;
		case 3u:
			return DeactivationTypesEnum.DISCOVERY;
		default:
			if (value >= 4 && value <= 255)
			{
				return DeactivationTypesEnum.RFU;
			}
			return DeactivationTypesEnum.InvalidDeactivationTypesValue;
		}
	}

	public static uint DeactivationTypesToValue(DeactivationTypesEnum enumItem)
	{
		return enumItem switch
		{
			DeactivationTypesEnum.IDLE_MODE => 0u, 
			DeactivationTypesEnum.SLEEP_MODE => 1u, 
			DeactivationTypesEnum.SLEEP_AF_MODE => 2u, 
			DeactivationTypesEnum.DISCOVERY => 3u, 
			DeactivationTypesEnum.RFU => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string DeactivationTypesToString(DeactivationTypesEnum enumItem)
	{
		return enumItem switch
		{
			DeactivationTypesEnum.IDLE_MODE => "IDLE_MODE", 
			DeactivationTypesEnum.SLEEP_MODE => "SLEEP_MODE", 
			DeactivationTypesEnum.SLEEP_AF_MODE => "SLEEP_AF_MODE", 
			DeactivationTypesEnum.DISCOVERY => "DISCOVERY", 
			DeactivationTypesEnum.RFU => "RFU", 
			_ => "Invalid DeactivationTypes Value", 
		};
	}

	public static string DeactivationTypesToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = IDLE_MODE");
		stringBuilder.AppendLine("0x1 = SLEEP_MODE");
		stringBuilder.AppendLine("0x2 = SLEEP_AF_MODE");
		stringBuilder.AppendLine("0x3 = DISCOVERY");
		stringBuilder.AppendLine("0x4-0xFF = RFU");
		return stringBuilder.ToString();
	}
}
