using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class QbceLePhyInfo
{
	public static QbceLePhyEnum ValueToQbceLePhy(uint value)
	{
		switch (value)
		{
		case 0u:
			return QbceLePhyEnum.LE_1M;
		case 1u:
			return QbceLePhyEnum.LE_2M;
		case 2u:
			return QbceLePhyEnum.LE_Coded;
		case 3u:
			return QbceLePhyEnum.QHS_P;
		case 4u:
			return QbceLePhyEnum.QHS_F;
		default:
			if (value >= 5 && value <= 255)
			{
				return QbceLePhyEnum.Reserved_for_future_use;
			}
			return QbceLePhyEnum.InvalidQbceLePhyValue;
		}
	}

	public static uint QbceLePhyToValue(QbceLePhyEnum enumItem)
	{
		return enumItem switch
		{
			QbceLePhyEnum.LE_1M => 0u, 
			QbceLePhyEnum.LE_2M => 1u, 
			QbceLePhyEnum.LE_Coded => 2u, 
			QbceLePhyEnum.QHS_P => 3u, 
			QbceLePhyEnum.QHS_F => 4u, 
			QbceLePhyEnum.Reserved_for_future_use => 5u, 
			_ => uint.MaxValue, 
		};
	}

	public static string QbceLePhyToString(QbceLePhyEnum enumItem)
	{
		return enumItem switch
		{
			QbceLePhyEnum.LE_1M => "LE 1M PHY", 
			QbceLePhyEnum.LE_2M => "LE 2M PHY", 
			QbceLePhyEnum.LE_Coded => "LE Coded PHY", 
			QbceLePhyEnum.QHS_P => "QHS-P PHY", 
			QbceLePhyEnum.QHS_F => "QHS-F PHY", 
			QbceLePhyEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid QbceLePhy Value", 
		};
	}

	public static string QbceLePhyToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = LE 1M PHY");
		stringBuilder.AppendLine("0x1 = LE 2M PHY");
		stringBuilder.AppendLine("0x2 = LE Coded PHY");
		stringBuilder.AppendLine("0x3 = QHS-P PHY");
		stringBuilder.AppendLine("0x4 = QHS-F PHY");
		stringBuilder.AppendLine("0x5-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
