using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class QbceTransmitterPhyPreferenceInfo
{
	public static QbceTransmitterPhyPreferenceEnumCollection ValueToQbceTransmitterPhyPreference(uint value)
	{
		QbceTransmitterPhyPreferenceEnumCollection qbceTransmitterPhyPreferenceEnumCollection = new QbceTransmitterPhyPreferenceEnumCollection();
		qbceTransmitterPhyPreferenceEnumCollection.Le1mTxPhyPreference = Le1mPhyPreferenceInfo.ValueToLe1mPhyPreference(value & 1u);
		qbceTransmitterPhyPreferenceEnumCollection.Le2mTxPhyPreference = Le2mPhyPreferenceInfo.ValueToLe2mPhyPreference((value & 2) >> 1);
		qbceTransmitterPhyPreferenceEnumCollection.LeCodedTxPhyPreference = LeCodedPhyPreferenceInfo.ValueToLeCodedPhyPreference((value & 4) >> 2);
		qbceTransmitterPhyPreferenceEnumCollection.QhsPTxPhyPreference = QhsPPhyPreferenceInfo.ValueToQhsPPhyPreference((value & 8) >> 3);
		qbceTransmitterPhyPreferenceEnumCollection.QhsFTxPhyPreference = QhsFPhyPreferenceInfo.ValueToQhsFPhyPreference((value & 0x10) >> 4);
		return qbceTransmitterPhyPreferenceEnumCollection;
	}

	public static uint QbceTransmitterPhyPreferenceToValue(QbceTransmitterPhyPreferenceEnumCollection enumCollection)
	{
		uint num = 0u;
		num |= Le1mPhyPreferenceInfo.Le1mPhyPreferenceToValue(enumCollection.Le1mTxPhyPreference);
		num |= Le2mPhyPreferenceInfo.Le2mPhyPreferenceToValue(enumCollection.Le2mTxPhyPreference) << 1;
		num |= LeCodedPhyPreferenceInfo.LeCodedPhyPreferenceToValue(enumCollection.LeCodedTxPhyPreference) << 2;
		num |= QhsPPhyPreferenceInfo.QhsPPhyPreferenceToValue(enumCollection.QhsPTxPhyPreference) << 3;
		return num | (QhsFPhyPreferenceInfo.QhsFPhyPreferenceToValue(enumCollection.QhsFTxPhyPreference) << 4);
	}

	public static string QbceTransmitterPhyPreferenceToString(QbceTransmitterPhyPreferenceEnumCollection enumCollection)
	{
		string text = "";
		text = text + "LE 1M TX PHY Preference: " + Le1mPhyPreferenceInfo.Le1mPhyPreferenceToString(enumCollection.Le1mTxPhyPreference) + "\r\n";
		text = text + "LE 2M TX PHY Preference: " + Le2mPhyPreferenceInfo.Le2mPhyPreferenceToString(enumCollection.Le2mTxPhyPreference) + "\r\n";
		text = text + "LE Coded TX PHY Preference: " + LeCodedPhyPreferenceInfo.LeCodedPhyPreferenceToString(enumCollection.LeCodedTxPhyPreference) + "\r\n";
		text = text + "QHS-P TX PHY Preference: " + QhsPPhyPreferenceInfo.QhsPPhyPreferenceToString(enumCollection.QhsPTxPhyPreference) + "\r\n";
		text = text + "QHS-F TX PHY Preference: " + QhsFPhyPreferenceInfo.QhsFPhyPreferenceToString(enumCollection.QhsFTxPhyPreference) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string QbceTransmitterPhyPreferenceToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bit 0: LE 1M TX PHY Preference");
		stringBuilder.AppendLine(Le1mPhyPreferenceInfo.Le1mPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bit 1: LE 2M TX PHY Preference");
		stringBuilder.AppendLine(Le2mPhyPreferenceInfo.Le2mPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bit 2: LE Coded TX PHY Preference");
		stringBuilder.AppendLine(LeCodedPhyPreferenceInfo.LeCodedPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bit 3: QHS-P TX PHY Preference");
		stringBuilder.AppendLine(QhsPPhyPreferenceInfo.QhsPPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bit 4: QHS-F TX PHY Preference");
		stringBuilder.AppendLine(QhsFPhyPreferenceInfo.QhsFPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bits 7-5: Reserved for future use");
		return stringBuilder.ToString();
	}
}
