using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class LoopbackModeInfo
{
	public static LoopbackModeEnum ValueToLoopbackMode(uint value)
	{
		switch (value)
		{
		case 0u:
			return LoopbackModeEnum.No_Loopback_mode_enabled;
		case 1u:
			return LoopbackModeEnum.Enable_Local_Loopback;
		case 2u:
			return LoopbackModeEnum.Enable_Remote_Loopback;
		default:
			if (value >= 3 && value <= 255)
			{
				return LoopbackModeEnum.RESERVED;
			}
			return LoopbackModeEnum.InvalidLoopbackModeValue;
		}
	}

	public static uint LoopbackModeToValue(LoopbackModeEnum enumItem)
	{
		return enumItem switch
		{
			LoopbackModeEnum.No_Loopback_mode_enabled => 0u, 
			LoopbackModeEnum.Enable_Local_Loopback => 1u, 
			LoopbackModeEnum.Enable_Remote_Loopback => 2u, 
			LoopbackModeEnum.RESERVED => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string LoopbackModeToString(LoopbackModeEnum enumItem)
	{
		return enumItem switch
		{
			LoopbackModeEnum.No_Loopback_mode_enabled => "No_Loopback_mode_enabled", 
			LoopbackModeEnum.Enable_Local_Loopback => "Enable_Local_Loopback", 
			LoopbackModeEnum.Enable_Remote_Loopback => "Enable_Remote_Loopback", 
			LoopbackModeEnum.RESERVED => "Reserved", 
			_ => "Invalid LoopbackMode Value", 
		};
	}

	public static string LoopbackModeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = No_Loopback_mode_enabled");
		stringBuilder.AppendLine("0x1 = Enable_Local_Loopback");
		stringBuilder.AppendLine("0x2 = Enable_Remote_Loopback");
		stringBuilder.AppendLine("0x3-0xFF = Reserved");
		return stringBuilder.ToString();
	}
}
