using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class PageScanRepetitionModeInfo
{
	public static PageScanRepetitionModeEnum ValueToPageScanRepetitionMode(uint value)
	{
		switch (value)
		{
		case 0u:
			return PageScanRepetitionModeEnum.R0;
		case 1u:
			return PageScanRepetitionModeEnum.R1;
		case 2u:
			return PageScanRepetitionModeEnum.R2;
		default:
			if (value >= 3 && value <= 255)
			{
				return PageScanRepetitionModeEnum.RESERVED;
			}
			return PageScanRepetitionModeEnum.InvalidPageScanRepetitionModeValue;
		}
	}

	public static uint PageScanRepetitionModeToValue(PageScanRepetitionModeEnum enumItem)
	{
		return enumItem switch
		{
			PageScanRepetitionModeEnum.R0 => 0u, 
			PageScanRepetitionModeEnum.R1 => 1u, 
			PageScanRepetitionModeEnum.R2 => 2u, 
			PageScanRepetitionModeEnum.RESERVED => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string PageScanRepetitionModeToString(PageScanRepetitionModeEnum enumItem)
	{
		return enumItem switch
		{
			PageScanRepetitionModeEnum.R0 => "R0", 
			PageScanRepetitionModeEnum.R1 => "R1", 
			PageScanRepetitionModeEnum.R2 => "R2", 
			PageScanRepetitionModeEnum.RESERVED => "RESERVED", 
			_ => "Invalid PageScanRepetitionMode Value", 
		};
	}

	public static string PageScanRepetitionModeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = R0");
		stringBuilder.AppendLine("0x1 = R1");
		stringBuilder.AppendLine("0x2 = R2");
		stringBuilder.AppendLine("0x3-0xFF = RESERVED");
		return stringBuilder.ToString();
	}
}
