using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class ClockOffsetInfo
{
	public static ClockOffsetEnumCollection ValueToClockOffset(uint value)
	{
		ClockOffsetEnumCollection clockOffsetEnumCollection = new ClockOffsetEnumCollection();
		clockOffsetEnumCollection.Bits162OfClknslaveClk = value & 0x7FFFu;
		clockOffsetEnumCollection.ClockOffsetValidFlag = ClockOffsetEnumCollection.ClockOffsetValidFlagInfo.ValueToClockOffsetValidFlag((value & 0x8000) >> 15);
		return clockOffsetEnumCollection;
	}

	public static uint ClockOffsetToValue(ClockOffsetEnumCollection enumCollection)
	{
		uint num = 0u;
		num |= enumCollection.Bits162OfClknslaveClk;
		return num | (ClockOffsetEnumCollection.ClockOffsetValidFlagInfo.ClockOffsetValidFlagToValue(enumCollection.ClockOffsetValidFlag) << 15);
	}

	public static string ClockOffsetToString(ClockOffsetEnumCollection enumCollection)
	{
		string text = "";
		object obj = text;
		text = string.Concat(obj, "Bits 16-2 of CLKNslave-CLK: ", enumCollection.Bits162OfClknslaveClk, "\r\n");
		text = text + "Clock_Offset_Valid_Flag: " + ClockOffsetEnumCollection.ClockOffsetValidFlagInfo.ClockOffsetValidFlagToString(enumCollection.ClockOffsetValidFlag) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string ClockOffsetToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bits 14-0: Bits 16-2 of CLKNslave-CLK");
		stringBuilder.AppendLine("Bit 15: Clock_Offset_Valid_Flag");
		stringBuilder.AppendLine(ClockOffsetEnumCollection.ClockOffsetValidFlagInfo.ClockOffsetValidFlagToDescription());
		return stringBuilder.ToString();
	}
}
