using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class DbfwPacketTypeInfo
{
	public static DbfwPacketTypeEnum ValueToDbfwPacketType(uint value)
	{
		return value switch
		{
			0u => DbfwPacketTypeEnum.NULL, 
			1u => DbfwPacketTypeEnum.POLL, 
			2u => DbfwPacketTypeEnum.FHS, 
			3u => DbfwPacketTypeEnum.DM1, 
			4u => DbfwPacketTypeEnum.DH1_OR_2DH1, 
			8u => DbfwPacketTypeEnum.EDR_3DH1, 
			9u => DbfwPacketTypeEnum.AUX1, 
			10u => DbfwPacketTypeEnum.DM3_OR_2DH3, 
			11u => DbfwPacketTypeEnum.DH3_OR_3DH3, 
			14u => DbfwPacketTypeEnum.DM5_OR_2DH5, 
			15u => DbfwPacketTypeEnum.DH5_OR_3DH5, 
			_ => DbfwPacketTypeEnum.InvalidDbfwPacketTypeValue, 
		};
	}

	public static uint DbfwPacketTypeToValue(DbfwPacketTypeEnum enumItem)
	{
		return enumItem switch
		{
			DbfwPacketTypeEnum.NULL => 0u, 
			DbfwPacketTypeEnum.POLL => 1u, 
			DbfwPacketTypeEnum.FHS => 2u, 
			DbfwPacketTypeEnum.DM1 => 3u, 
			DbfwPacketTypeEnum.DH1_OR_2DH1 => 4u, 
			DbfwPacketTypeEnum.EDR_3DH1 => 8u, 
			DbfwPacketTypeEnum.AUX1 => 9u, 
			DbfwPacketTypeEnum.DM3_OR_2DH3 => 10u, 
			DbfwPacketTypeEnum.DH3_OR_3DH3 => 11u, 
			DbfwPacketTypeEnum.DM5_OR_2DH5 => 14u, 
			DbfwPacketTypeEnum.DH5_OR_3DH5 => 15u, 
			_ => uint.MaxValue, 
		};
	}

	public static string DbfwPacketTypeToString(DbfwPacketTypeEnum enumItem)
	{
		return enumItem switch
		{
			DbfwPacketTypeEnum.NULL => "NULL", 
			DbfwPacketTypeEnum.POLL => "POLL", 
			DbfwPacketTypeEnum.FHS => "FHS", 
			DbfwPacketTypeEnum.DM1 => "DM1", 
			DbfwPacketTypeEnum.DH1_OR_2DH1 => "DH1 for BR or 2DH1 for EDR", 
			DbfwPacketTypeEnum.EDR_3DH1 => "3DH1", 
			DbfwPacketTypeEnum.AUX1 => "AUX1", 
			DbfwPacketTypeEnum.DM3_OR_2DH3 => "DM3 for BR or 2DH3 for EDR", 
			DbfwPacketTypeEnum.DH3_OR_3DH3 => "DH3 for BR or 3DH3 for EDR", 
			DbfwPacketTypeEnum.DM5_OR_2DH5 => "DM5 for BR or 2DH5 for EDR", 
			DbfwPacketTypeEnum.DH5_OR_3DH5 => "DH5 for BR or 3DH5 for EDR", 
			_ => "Invalid DbfwPacketType Value", 
		};
	}

	public static string DbfwPacketTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = NULL");
		stringBuilder.AppendLine("0x1 = POLL");
		stringBuilder.AppendLine("0x2 = FHS");
		stringBuilder.AppendLine("0x3 = DM1");
		stringBuilder.AppendLine("0x4 = DH1 for BR or 2DH1 for EDR");
		stringBuilder.AppendLine("0x8 = 3DH1");
		stringBuilder.AppendLine("0x9 = AUX1");
		stringBuilder.AppendLine("0xA = DM3 for BR or 2DH3 for EDR");
		stringBuilder.AppendLine("0xB = DH3 for BR or 3DH3 for EDR");
		stringBuilder.AppendLine("0xE = DM5 for BR or 2DH5 for EDR");
		stringBuilder.AppendLine("0xF = DH5 for BR or 3DH5 for EDR");
		return stringBuilder.ToString();
	}
}
