using System.IO;
using System.Text;

namespace Crysome.Common.Network.Packets.Server;

public class HvncRunRequestPacket : IPacket
{
	public const byte ActionExplorer = 0;

	public const byte ActionRunDialog = 1;

	public const byte ActionCmd = 2;

	public const byte ActionPowerShell = 3;

	public const byte ActionChrome = 4;

	public const byte ActionEdge = 5;

	public const byte ActionFirefox = 6;

	public const byte ActionOpera = 7;

	public const byte ActionOperaGX = 8;

	public const byte ActionBrave = 9;

	public const byte ActionCustom = 10;

	public const byte ActionCloneChrome = 11;

	public const byte ActionCloneEdge = 12;

	public const byte ActionCloneFirefox = 13;

	public const byte ActionCloneOpera = 14;

	public const byte ActionCloneOperaGX = 15;

	public const byte ActionCloneBrave = 16;

	public const byte ActionNotepad = 17;

	public const byte ActionCalculator = 18;

	public const byte ActionDiscord = 19;

	public byte Action { get; set; }

	public string Path { get; set; }

	public void Write(BinaryWriter w)
	{
		w.Write(Action);
		byte[] bytes = Encoding.UTF8.GetBytes(Path ?? "");
		w.Write(bytes.Length);
		if (bytes.Length != 0)
		{
			w.Write(bytes);
		}
	}

	public void Read(BinaryReader r)
	{
		Action = r.ReadByte();
		int num = r.ReadInt32();
		Path = ((num > 0) ? Encoding.UTF8.GetString(r.ReadBytes(num)) : "");
	}
}
