using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AdvertisingChannelMapInfo
{
	public static AdvertisingChannelMapEnumCollection ValueToAdvertisingChannelMap(uint value)
	{
		AdvertisingChannelMapEnumCollection advertisingChannelMapEnumCollection = new AdvertisingChannelMapEnumCollection();
		advertisingChannelMapEnumCollection.Channel37ShallBeUsed = EnableBitInfo.ValueToEnableBit(value & 1u);
		advertisingChannelMapEnumCollection.Channel38ShallBeUsed = EnableBitInfo.ValueToEnableBit((value & 2) >> 1);
		advertisingChannelMapEnumCollection.Channel39ShallBeUsed = EnableBitInfo.ValueToEnableBit((value & 4) >> 2);
		return advertisingChannelMapEnumCollection;
	}

	public static uint AdvertisingChannelMapToValue(AdvertisingChannelMapEnumCollection enumCollection)
	{
		uint num = 0u;
		num |= EnableBitInfo.EnableBitToValue(enumCollection.Channel37ShallBeUsed);
		num |= EnableBitInfo.EnableBitToValue(enumCollection.Channel38ShallBeUsed) << 1;
		return num | (EnableBitInfo.EnableBitToValue(enumCollection.Channel39ShallBeUsed) << 2);
	}

	public static string AdvertisingChannelMapToString(AdvertisingChannelMapEnumCollection enumCollection)
	{
		string text = "";
		text = text + "Channel 37 shall be used: " + EnableBitInfo.EnableBitToString(enumCollection.Channel37ShallBeUsed) + "\r\n";
		text = text + "Channel 38 shall be used: " + EnableBitInfo.EnableBitToString(enumCollection.Channel38ShallBeUsed) + "\r\n";
		text = text + "Channel 39 shall be used: " + EnableBitInfo.EnableBitToString(enumCollection.Channel39ShallBeUsed) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string AdvertisingChannelMapToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bit 0: Channel 37 shall be used");
		stringBuilder.AppendLine("Bit 1: Channel 38 shall be used");
		stringBuilder.AppendLine("Bit 2: Channel 39 shall be used");
		stringBuilder.AppendLine("Bits 7-3: Reserved for future use");
		return stringBuilder.ToString();
	}
}
