using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class CodecTypesInfo
{
	public static CodecTypesEnum ValueToCodecTypes(uint value)
	{
		return value switch
		{
			0u => CodecTypesEnum.SBC, 
			2u => CodecTypesEnum.AAC, 
			4u => CodecTypesEnum.LDAC, 
			8u => CodecTypesEnum.APTX, 
			9u => CodecTypesEnum.APTX_HD, 
			10u => CodecTypesEnum.APTX_ADAPTIVE, 
			11u => CodecTypesEnum.APTX_TWS, 
			_ => CodecTypesEnum.InvalidCodecTypesValue, 
		};
	}

	public static uint CodecTypesToValue(CodecTypesEnum enumItem)
	{
		return enumItem switch
		{
			CodecTypesEnum.SBC => 0u, 
			CodecTypesEnum.AAC => 2u, 
			CodecTypesEnum.LDAC => 4u, 
			CodecTypesEnum.APTX => 8u, 
			CodecTypesEnum.APTX_HD => 9u, 
			CodecTypesEnum.APTX_ADAPTIVE => 10u, 
			CodecTypesEnum.APTX_TWS => 11u, 
			_ => uint.MaxValue, 
		};
	}

	public static string CodecTypesToString(CodecTypesEnum enumItem)
	{
		return enumItem switch
		{
			CodecTypesEnum.SBC => "SBC", 
			CodecTypesEnum.AAC => "AAC", 
			CodecTypesEnum.LDAC => "LDAC", 
			CodecTypesEnum.APTX => "APT-X", 
			CodecTypesEnum.APTX_HD => "APT-X HD", 
			CodecTypesEnum.APTX_ADAPTIVE => "APT-X ADAPTIVE", 
			CodecTypesEnum.APTX_TWS => "APT-X TWS", 
			_ => "Invalid CodecTypes Value", 
		};
	}

	public static string CodecTypesToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = SBC");
		stringBuilder.AppendLine("0x2 = AAC");
		stringBuilder.AppendLine("0x4 = LDAC");
		stringBuilder.AppendLine("0x8 = APT-X");
		stringBuilder.AppendLine("0x9 = APT-X HD");
		stringBuilder.AppendLine("0xA = APT-X ADAPTIVE");
		stringBuilder.AppendLine("0xB = APT-X TWS");
		return stringBuilder.ToString();
	}
}
