Decompiled source of Adjustable Chat v0.0.1

OutwardAdjustableChat.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using OutwardAdjustableChat.Components;
using OutwardAdjustableChat.Data;
using OutwardAdjustableChat.Managers;
using OutwardAdjustableChat.Services;
using OutwardModsCommunicator.EventBus;
using OutwardModsCommunicator.Managers;
using SideLoader;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardAdjustableChat")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardAdjustableChat")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace OutwardAdjustableChat
{
	[BepInPlugin("gymmed.adjustable_chat", "Adjustable Chat", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class OutwardAdjustableChat : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ResourcesPrefabManager), "Load")]
		public class ResourcesPrefabManager_Load
		{
			private static void Postfix(ResourcesPrefabManager __instance)
			{
				EventBusDataPresenter.LogRegisteredEvents();
				EventBusDataPresenter.LogAllModsSubsribers();
			}
		}

		public const string GUID = "gymmed.adjustable_chat";

		public const string NAME = "Adjustable Chat";

		public const string VERSION = "0.0.1";

		public static string prefix = "[Adjustable-Chat]";

		public const string EVENTS_LISTENER_GUID = "gymmed.adjustable_chat_*";

		internal static ManualLogSource Log;

		internal void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			LogMessage("Hello world from Adjustable Chat 0.0.1!");
			new Harmony("gymmed.adjustable_chat").PatchAll();
			SL.OnSceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded()
		{
			ChatPanelStyler.ApplyToAllCharacters();
		}

		internal void Update()
		{
		}

		public static void LogMessage(string message)
		{
			Log.LogMessage((object)(prefix + " " + message));
		}

		public static void LogSL(string message)
		{
			SL.Log(prefix + " " + message);
		}

		public static string GetProjectLocation()
		{
			return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}
	}
}
namespace OutwardAdjustableChat.Services
{
	public class ChatPanelStateManager
	{
		private static readonly string FILE_NAME = "ChatPanelState.xml";

		private static ChatPanelStateManager _instance;

		private ChatPanelStateData _currentState;

		private bool _isModified;

		private bool _hasLoadedState;

		private string _currentCharUID;

		private Dictionary<string, ChatPanelStateData> _pendingStates = new Dictionary<string, ChatPanelStateData>();

		public static ChatPanelStateManager Instance => _instance ?? (_instance = new ChatPanelStateManager());

		public bool IsModified => _isModified;

		public bool HasLoadedState => _hasLoadedState;

		public event Action OnStateModified;

		private ChatPanelStateManager()
		{
			_currentState = null;
			_hasLoadedState = false;
		}

		public void MarkModified()
		{
			if (!_isModified)
			{
				_isModified = true;
				this.OnStateModified?.Invoke();
			}
		}

		public void ResetModified()
		{
			_isModified = false;
		}

		public void Save(string charUID)
		{
			if (string.IsNullOrEmpty(charUID))
			{
				OutwardAdjustableChat.LogMessage("Cannot save ChatPanel state: invalid charUID");
			}
			else
			{
				if (!_isModified || _currentState == null)
				{
					return;
				}
				try
				{
					string text = Path.Combine(PathsManager.GetCharacterSavePath(charUID), FILE_NAME);
					XmlSerializer xmlSerializer = new XmlSerializer(typeof(ChatPanelStateData));
					using (StreamWriter textWriter = new StreamWriter(text))
					{
						xmlSerializer.Serialize(textWriter, _currentState);
					}
					OutwardAdjustableChat.LogMessage("ChatPanel state saved to " + text);
					ResetModified();
				}
				catch (Exception ex)
				{
					OutwardAdjustableChat.LogMessage("Error saving ChatPanel state: " + ex.Message);
				}
			}
		}

		public void Load(string charUID)
		{
			if (string.IsNullOrEmpty(charUID))
			{
				OutwardAdjustableChat.LogMessage("Cannot load ChatPanel state: invalid charUID");
				return;
			}
			_currentCharUID = charUID;
			_hasLoadedState = false;
			_currentState = null;
			try
			{
				string text = Path.Combine(PathsManager.GetCharacterSavePath(charUID), FILE_NAME);
				if (!File.Exists(text))
				{
					OutwardAdjustableChat.LogMessage("ChatPanel state file not found at " + text + ", skipping apply");
					return;
				}
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(ChatPanelStateData));
				using (StreamReader textReader = new StreamReader(text))
				{
					_currentState = (ChatPanelStateData)xmlSerializer.Deserialize(textReader);
					_hasLoadedState = true;
				}
				OutwardAdjustableChat.LogMessage("ChatPanel state loaded from " + text);
				_pendingStates[charUID] = _currentState;
			}
			catch (Exception ex)
			{
				OutwardAdjustableChat.LogMessage("Error loading ChatPanel state: " + ex.Message);
				_currentState = null;
				_hasLoadedState = false;
			}
		}

		public bool HasPendingState(string charUID)
		{
			if (!string.IsNullOrEmpty(charUID))
			{
				return _pendingStates.ContainsKey(charUID);
			}
			return false;
		}

		public ChatPanelStateData GetAndClearPendingState(string charUID)
		{
			if (_pendingStates.TryGetValue(charUID, out var value))
			{
				_pendingStates.Remove(charUID);
				return value;
			}
			return null;
		}

		public void SetState(ChatPanelStateData state)
		{
			_currentState = state ?? new ChatPanelStateData();
		}

		public ChatPanelStateData GetState()
		{
			return _currentState;
		}

		public void UpdateCurrentStateFromUI(Transform displayTransform, Transform backgroundTransform, RectTransform chatPanelTransform)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (_currentState == null)
			{
				_currentState = new ChatPanelStateData();
			}
			if ((Object)(object)displayTransform != (Object)null)
			{
				RectTransform val = (RectTransform)(object)((displayTransform is RectTransform) ? displayTransform : null);
				if ((Object)(object)val != (Object)null)
				{
					_currentState.DisplaySize = val.sizeDelta;
				}
			}
			if ((Object)(object)chatPanelTransform != (Object)null)
			{
				_currentState.PositionOffset = chatPanelTransform.anchoredPosition;
			}
			if ((Object)(object)backgroundTransform != (Object)null)
			{
				RectTransform val2 = (RectTransform)(object)((backgroundTransform is RectTransform) ? backgroundTransform : null);
				if ((Object)(object)val2 != (Object)null)
				{
					_currentState.BackgroundSize = val2.sizeDelta;
				}
			}
		}

		public void ApplyToUI(Transform displayTransform, Transform backgroundTransform, RectTransform chatPanelTransform, ChatPanelStateData state = null)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			ChatPanelStateData chatPanelStateData = state ?? _currentState;
			if (chatPanelStateData == null)
			{
				return;
			}
			if ((Object)(object)displayTransform != (Object)null)
			{
				RectTransform val = (RectTransform)(object)((displayTransform is RectTransform) ? displayTransform : null);
				if ((Object)(object)val != (Object)null)
				{
					val.sizeDelta = chatPanelStateData.DisplaySize;
				}
			}
			if ((Object)(object)chatPanelTransform != (Object)null)
			{
				chatPanelTransform.anchoredPosition = chatPanelStateData.PositionOffset;
			}
			if ((Object)(object)backgroundTransform != (Object)null)
			{
				RectTransform val2 = (RectTransform)(object)((backgroundTransform is RectTransform) ? backgroundTransform : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.sizeDelta = chatPanelStateData.BackgroundSize;
				}
			}
		}
	}
	public static class ChatPanelStyler
	{
		private static Sprite _cachedSprite;

		private const float BORDER_SIZE = 14f;

		private const float BOTTOM_BORDER_SIZE = 58f;

		public static void ApplyToAllCharacters()
		{
			try
			{
				if ((Object)(object)CharacterManager.Instance == (Object)null)
				{
					LogDebug("ApplyToAllCharacters: CharacterManager.Instance is null");
					return;
				}
				Character firstLocalCharacter = CharacterManager.Instance.GetFirstLocalCharacter();
				object obj;
				if (firstLocalCharacter == null)
				{
					obj = null;
				}
				else
				{
					CharacterUI characterUI = firstLocalCharacter.CharacterUI;
					obj = ((characterUI != null) ? characterUI.ChatPanel : null);
				}
				if ((Object)obj != (Object)null)
				{
					ApplyStyle(firstLocalCharacter.CharacterUI.ChatPanel);
				}
				Character secondLocalCharacter = CharacterManager.Instance.GetSecondLocalCharacter();
				object obj2;
				if (secondLocalCharacter == null)
				{
					obj2 = null;
				}
				else
				{
					CharacterUI characterUI2 = secondLocalCharacter.CharacterUI;
					obj2 = ((characterUI2 != null) ? characterUI2.ChatPanel : null);
				}
				if ((Object)obj2 != (Object)null)
				{
					ApplyStyle(secondLocalCharacter.CharacterUI.ChatPanel);
				}
			}
			catch (Exception ex)
			{
				LogDebug("ApplyToAllCharacters: Exception - " + ex.Message);
			}
		}

		private static void ApplyStyle(ChatPanel chatPanel)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Transform val = ((Component)chatPanel).transform.Find("Display");
				if ((Object)(object)val == (Object)null)
				{
					LogDebug("ApplyStyle: Display transform not found");
					return;
				}
				Transform val2 = val.Find("Background");
				if ((Object)(object)val2 == (Object)null)
				{
					LogDebug("ApplyStyle: Background transform not found");
					return;
				}
				Image component = ((Component)val2).GetComponent<Image>();
				if ((Object)(object)component == (Object)null)
				{
					LogDebug("ApplyStyle: Image component not found");
					return;
				}
				if ((Object)(object)component.sprite == (Object)null)
				{
					LogDebug("ApplyStyle: No sprite on Image");
					return;
				}
				Sprite sprite = component.sprite;
				if ((Object)(object)_cachedSprite == (Object)null)
				{
					_cachedSprite = Sprite.Create(sprite.texture, sprite.rect, sprite.pivot, sprite.pixelsPerUnit, 0u, (SpriteMeshType)0, new Vector4(14f, 58f, 14f, 14f));
					((Object)_cachedSprite).name = ((Object)sprite).name + "_Styled";
				}
				component.sprite = _cachedSprite;
				component.type = (Type)1;
				((Graphic)component).SetAllDirty();
			}
			catch (Exception ex)
			{
				LogDebug("ApplyStyle: Exception - " + ex.Message);
			}
		}

		private static void LogDebug(string message)
		{
		}
	}
}
namespace OutwardAdjustableChat.Patches
{
	[HarmonyPatch]
	public static class ChatPanelLoadPatch
	{
		[HarmonyPatch(typeof(CharacterSaveInstanceHolder), "ApplyLoadedSaveToChar")]
		[HarmonyPostfix]
		private static void OnCharacterLoaded(CharacterSaveInstanceHolder __instance, Character _character)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_character == (Object)null)
			{
				return;
			}
			UID uID = _character.UID;
			string value = ((UID)(ref uID)).Value;
			if (string.IsNullOrEmpty(value))
			{
				OutwardAdjustableChat.LogMessage("ChatPanelLoadPatch: Cannot load - invalid charUID");
				return;
			}
			try
			{
				CharacterUI characterUI = _character.CharacterUI;
				ChatPanel val = ((characterUI != null) ? characterUI.ChatPanel : null);
				if ((Object)(object)val == (Object)null)
				{
					ChatPanelStateManager.Instance.Load(value);
					return;
				}
				Transform val2 = ((Component)val).transform.Find("Display");
				if (!((Object)(object)val2 == (Object)null))
				{
					ChatPanelInteraction chatPanelInteraction = ((Component)val2).GetComponent<ChatPanelInteraction>();
					if ((Object)(object)chatPanelInteraction == (Object)null)
					{
						chatPanelInteraction = ((Component)val2).gameObject.AddComponent<ChatPanelInteraction>();
					}
					((Behaviour)chatPanelInteraction).enabled = true;
					ChatPanelStateManager.Instance.Load(value);
					Transform backgroundTransform = val2.Find("Background");
					Transform transform = ((Component)val).transform;
					RectTransform chatPanelTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					ChatPanelStateManager.Instance.ApplyToUI(val2, backgroundTransform, chatPanelTransform);
					ChatPanelStateManager.Instance.ResetModified();
				}
			}
			catch (Exception ex)
			{
				OutwardAdjustableChat.LogMessage("ChatPanelLoadPatch: Exception - " + ex.Message);
			}
		}
	}
	[HarmonyPatch]
	public static class ChatPanelResizerPatch
	{
		[HarmonyPatch(typeof(ChatPanel), "StartInit")]
		[HarmonyPostfix]
		private static void OnStartInit(ChatPanel __instance)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("Display");
			if ((Object)(object)val == (Object)null)
			{
				OutwardAdjustableChat.LogMessage("ChatPanelResizerPatch: Display transform not found");
				return;
			}
			ChatPanelInteraction chatPanelInteraction = ((Component)val).GetComponent<ChatPanelInteraction>();
			if ((Object)(object)chatPanelInteraction != (Object)null)
			{
				((Behaviour)chatPanelInteraction).enabled = true;
			}
			else
			{
				chatPanelInteraction = ((Component)val).gameObject.AddComponent<ChatPanelInteraction>();
				((Behaviour)chatPanelInteraction).enabled = true;
			}
			Character localCharacter = ((UIElement)__instance).LocalCharacter;
			object obj;
			if (localCharacter == null)
			{
				obj = null;
			}
			else
			{
				UID uID = localCharacter.UID;
				obj = ((UID)(ref uID)).Value;
			}
			string text = (string)obj;
			if (!string.IsNullOrEmpty(text) && ChatPanelStateManager.Instance.HasPendingState(text))
			{
				ChatPanelStateData andClearPendingState = ChatPanelStateManager.Instance.GetAndClearPendingState(text);
				if ((Object)(object)chatPanelInteraction != (Object)null)
				{
					chatPanelInteraction.SetPendingState(andClearPendingState);
				}
			}
		}
	}
	[HarmonyPatch]
	public static class ChatPanelSavePatch
	{
		[HarmonyPatch(typeof(SaveInstance), "Save")]
		[HarmonyPostfix]
		private static void OnSaveComplete(bool __result, SaveInstance __instance, bool _saveChar, bool _saveWorld)
		{
			if (!_saveChar || __instance?.CharSave?.PSave == null)
			{
				return;
			}
			string uID = ((CharacterSaveData)__instance.CharSave.PSave).UID;
			if (string.IsNullOrEmpty(uID))
			{
				OutwardAdjustableChat.LogMessage("ChatPanelSavePatch: Cannot save - invalid charUID");
				return;
			}
			CharacterUI obj = CharacterManager.Instance.GetCharacter(uID)?.CharacterUI;
			ChatPanel val = ((obj != null) ? obj.ChatPanel : null);
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = ((Component)val).transform.Find("Display");
				Transform backgroundTransform = ((val2 != null) ? val2.Find("Background") : null);
				Transform transform = ((Component)val).transform;
				RectTransform chatPanelTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				ChatPanelStateManager.Instance.UpdateCurrentStateFromUI(val2, backgroundTransform, chatPanelTransform);
			}
			ChatPanelStateManager.Instance.Save(uID);
		}
	}
}
namespace OutwardAdjustableChat.Managers
{
	public static class PathsManager
	{
		public const string ConfigDirectoryName = "Adjust_Chat";

		public static readonly string ConfigPath;

		public static readonly string DefaultBalanceRulesPath;

		public static void Initialize()
		{
			if (!Directory.Exists(ConfigPath))
			{
				Directory.CreateDirectory(ConfigPath);
			}
		}

		public static string GetCharacterSavePath(string charUID)
		{
			if (string.IsNullOrEmpty(charUID))
			{
				OutwardAdjustableChat.LogMessage("GetCharacterSavePath: charUID is null or empty");
				return ConfigPath;
			}
			string text = Path.Combine(ConfigPath, charUID);
			try
			{
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
				}
			}
			catch (Exception ex)
			{
				OutwardAdjustableChat.LogMessage("Error creating character save directory: " + ex.Message);
				return ConfigPath;
			}
			return text;
		}

		static PathsManager()
		{
			ConfigPath = Path.Combine(PathsManager.ConfigPath, "Adjust_Chat");
			DefaultBalanceRulesPath = Path.Combine(ConfigPath, "ChatAdjustments.xml");
			Initialize();
		}
	}
}
namespace OutwardAdjustableChat.Events
{
	public static class EventBusPublisher
	{
		public const string Event_NameFromOtherMod = "GUID";

		public const string OtherMod_Listener = "GUID";

		public static void SendYourMessage(object yourVariable)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0012: Expected O, but got Unknown
			EventPayload val = new EventPayload();
			((Dictionary<string, object>)val)["eventVariableName"] = yourVariable;
			EventPayload val2 = val;
			EventBus.Publish("GUID", "GUID", val2);
		}
	}
	public static class EventBusRegister
	{
		public static void RegisterEvents()
		{
			EventBus.RegisterEvent("gymmed.adjustable_chat_*", "ExecuteMyCode", "My code/method description", new(string, Type, string)[1] { ("callerGUID", typeof(string), "Optional variable for printing caller id.") });
		}
	}
	public static class EventBusSubscriber
	{
		public const string Event_ExecuteMyCode = "ExecuteMyCode";

		public static void AddSubscribers()
		{
			EventBus.Subscribe("gymmed.outward_game_settings", "EnchantmentMenu@TryEnchant", (Action<EventPayload>)OnTryEnchant);
			EventBus.Subscribe("gymmed.adjustable_chat_*", "ExecuteMyCode", (Action<EventPayload>)MyExecutingFunction);
		}

		private static void MyExecutingFunction(EventPayload payload)
		{
			if (payload != null)
			{
				string text = payload.Get<string>("callerGUID", (string)null);
				if (!string.IsNullOrEmpty(text))
				{
					OutwardAdjustableChat.LogSL(text + " successfully passed callerGUID!");
				}
				EventBusDataPresenter.LogPayload(payload);
				OutwardAdjustableChat.LogSL("gymmed.adjustable_chat caught and executed published event!");
			}
		}

		private static void OnTryEnchant(EventPayload payload)
		{
			if (payload == null)
			{
				return;
			}
			EnchantmentMenu val = payload.Get<EnchantmentMenu>("menu", (EnchantmentMenu)null);
			if ((Object)(object)val == (Object)null)
			{
				OutwardAdjustableChat.LogSL("Mod gymmed.outward_game_settings event EnchantmentMenu@TryEnchant returned null for EnchantmentMenu");
				EventBusDataPresenter.LogPayload(payload);
				return;
			}
			OutwardAdjustableChat.LogSL("gymmed.adjustable_chat successfully communicated with gymmed.outward_game_settings mod and passed menu!");
			int enchantmentID = val.GetEnchantmentID();
			if (enchantmentID != -1)
			{
				Enchantment enchantmentPrefab = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(enchantmentID);
				if (!((Object)(object)enchantmentPrefab == (Object)null))
				{
					OutwardAdjustableChat.LogSL(enchantmentPrefab.Name + " tried to be applied!");
				}
			}
		}
	}
}
namespace OutwardAdjustableChat.Data
{
	[Serializable]
	public class ChatPanelStateData
	{
		public Vector2 DisplaySize;

		public Vector2 PositionOffset;

		public Vector2 BackgroundSize;
	}
}
namespace OutwardAdjustableChat.Components
{
	public class ChatPanelInteraction : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler
	{
		private const float RESIZE_HANDLE_SIZE = 10f;

		private static readonly Color RESIZE_HANDLE_COLOR = new Color(1f, 0.84f, 0f, 1f);

		private IPointerEventHandler _pointerHandler;

		private IDragHandler _dragHandler;

		private IResizeHandler _resizeHandler;

		private IInteractableAreaChecker _interactableAreaChecker;

		private RectTransform _displayRect;

		private RectTransform _backgroundRect;

		private RectTransform _chatPanelRect;

		private GameObject _resizeHandle;

		private Canvas _canvas;

		private InputField _chatEntryInput;

		private ScrollRect _chatScrollRect;

		private ChatPanel _chatPanelComponent;

		private bool _resizeHandleVisible;

		private ChatPanelStateData _pendingStateToApply;

		private bool _hasAppliedPendingState;

		public GameObject ResizeHandle => _resizeHandle;

		public InputField ChatEntryInput => _chatEntryInput;

		public ScrollRect ChatScrollRect => _chatScrollRect;

		public event Action OnInteraction;

		public Canvas GetCanvas()
		{
			return _canvas;
		}

		private void Awake()
		{
			try
			{
				InitializeHandlers();
				InitializeReferences();
				CalculateScreenMaxSize();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] Awake failed: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private void Start()
		{
			ApplyPendingStateIfAvailable();
		}

		private void ApplyPendingStateIfAvailable()
		{
			if (_pendingStateToApply == null || _hasAppliedPendingState)
			{
				return;
			}
			try
			{
				Transform transform = ((Component)this).transform;
				Transform backgroundTransform = transform.Find("Background");
				Transform parent = ((Component)this).transform.parent;
				RectTransform chatPanelTransform = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				ChatPanelStateManager.Instance.ApplyToUI(transform, backgroundTransform, chatPanelTransform, _pendingStateToApply);
				ChatPanelStateManager.Instance.ResetModified();
				_hasAppliedPendingState = true;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] Start: failed to apply pending state: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private void InitializeHandlers()
		{
			_pointerHandler = new PointerEventHandler(this);
			_dragHandler = new DragHandler(this);
			_resizeHandler = new ResizeHandler(this);
			_interactableAreaChecker = new InteractableAreaChecker(this);
		}

		private void InitializeReferences()
		{
			try
			{
				_displayRect = ((Component)this).GetComponent<RectTransform>();
				Transform val = ((Component)this).transform.Find("Background");
				if ((Object)(object)val != (Object)null)
				{
					_backgroundRect = (RectTransform)(object)((val is RectTransform) ? val : null);
				}
				Transform parent = ((Component)this).transform.parent;
				if ((Object)(object)parent != (Object)null)
				{
					_chatPanelRect = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				}
				Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					_canvas = componentInParent;
				}
				ChatPanel val2 = ((parent != null) ? ((Component)parent).GetComponent<ChatPanel>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					_chatPanelComponent = val2;
					_chatEntryInput = val2.m_chatEntry;
					_chatScrollRect = val2.m_chatDisplay;
				}
				_resizeHandleVisible = false;
				CreateResizeHandle();
				CreateDragEventTrigger();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] InitializeReferences failed: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private void CreateDragEventTrigger()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			EventTrigger obj = ((Component)this).gameObject.AddComponent<EventTrigger>();
			Entry val = new Entry
			{
				eventID = (EventTriggerType)2
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)OnPointerDownForDrag);
			obj.triggers.Add(val);
			Entry val2 = new Entry
			{
				eventID = (EventTriggerType)5
			};
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)OnDrag);
			obj.triggers.Add(val2);
			Entry val3 = new Entry
			{
				eventID = (EventTriggerType)3
			};
			((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)OnDragEnd);
			obj.triggers.Add(val3);
		}

		public void OnPointerDownForDrag(BaseEventData eventData)
		{
			PointerEventData val = (PointerEventData)(object)((eventData is PointerEventData) ? eventData : null);
			if (val != null && !_interactableAreaChecker.IsClickOnInteractableArea(val))
			{
				if ((Object)(object)_chatScrollRect != (Object)null)
				{
					_chatScrollRect.StopMovement();
					((Behaviour)_chatScrollRect).enabled = false;
				}
				this.OnInteraction?.Invoke();
			}
		}

		public void OnDrag(BaseEventData eventData)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			PointerEventData val = (PointerEventData)(object)((eventData is PointerEventData) ? eventData : null);
			if (val == null || _interactableAreaChecker.IsClickOnInteractableArea(val))
			{
				return;
			}
			try
			{
				if (!((Object)(object)_chatPanelRect == (Object)null))
				{
					float canvasScaleFactor = GetCanvasScaleFactor();
					Vector2 val2 = val.delta * canvasScaleFactor;
					RectTransform chatPanelRect = _chatPanelRect;
					chatPanelRect.anchoredPosition += val2;
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] OnDrag failed: " + ex.Message));
			}
		}

		public void OnDragEnd(BaseEventData eventData)
		{
			try
			{
				if ((Object)(object)_chatScrollRect != (Object)null)
				{
					((Behaviour)_chatScrollRect).enabled = true;
				}
				ChatPanelStateManager.Instance.MarkModified();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] OnDragEnd failed: " + ex.Message));
			}
		}

		private float GetCanvasScaleFactor()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_canvas == (Object)null)
			{
				return 1f;
			}
			CanvasScaler component = ((Component)_canvas).GetComponent<CanvasScaler>();
			if ((Object)(object)component == (Object)null)
			{
				return 1f;
			}
			if ((int)_canvas.renderMode != 0)
			{
				return 1f;
			}
			Vector2 referenceResolution = component.referenceResolution;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor((float)Screen.width, (float)Screen.height);
			if ((int)component.screenMatchMode == 0)
			{
				float matchWidthOrHeight = component.matchWidthOrHeight;
				float num = Mathf.Log(referenceResolution.x / val.x, 2f);
				float num2 = Mathf.Log(referenceResolution.y / val.y, 2f);
				float num3 = Mathf.Lerp(num, num2, matchWidthOrHeight);
				return Mathf.Pow(2f, num3);
			}
			if ((int)component.screenMatchMode == 1)
			{
				return Mathf.Min(referenceResolution.x / val.x, referenceResolution.y / val.y);
			}
			return Mathf.Max(referenceResolution.x / val.x, referenceResolution.y / val.y);
		}

		private void CreateResizeHandle()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			if (!((Object)(object)_displayRect == (Object)null))
			{
				_resizeHandle = new GameObject("ResizeHandle");
				RectTransform obj = _resizeHandle.AddComponent<RectTransform>();
				((Transform)obj).SetParent((Transform)(object)_displayRect);
				((Transform)obj).localScale = Vector3.one;
				obj.anchorMin = new Vector2(1f, 0f);
				obj.anchorMax = new Vector2(1f, 0f);
				obj.pivot = new Vector2(1f, 0f);
				obj.anchoredPosition = Vector2.zero;
				obj.sizeDelta = new Vector2(10f, 10f);
				((Graphic)_resizeHandle.AddComponent<Image>()).color = RESIZE_HANDLE_COLOR;
				EventTrigger obj2 = _resizeHandle.AddComponent<EventTrigger>();
				Entry val = new Entry
				{
					eventID = (EventTriggerType)2
				};
				TriggerEvent callback = val.callback;
				IResizeHandler resizeHandler = _resizeHandler;
				((UnityEvent<BaseEventData>)(object)callback).AddListener((UnityAction<BaseEventData>)resizeHandler.OnPointerDown);
				obj2.triggers.Add(val);
				Entry val2 = new Entry
				{
					eventID = (EventTriggerType)3
				};
				TriggerEvent callback2 = val2.callback;
				IResizeHandler resizeHandler2 = _resizeHandler;
				((UnityEvent<BaseEventData>)(object)callback2).AddListener((UnityAction<BaseEventData>)resizeHandler2.OnPointerUp);
				obj2.triggers.Add(val2);
			}
		}

		private void CalculateScreenMaxSize()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			_ = Screen.width;
			_ = Screen.height;
			if ((Object)(object)_canvas != (Object)null && (int)_canvas.renderMode == 0)
			{
				CanvasScaler component = ((Component)_canvas).GetComponent<CanvasScaler>();
				if ((Object)(object)component != (Object)null)
				{
					_ = component.referenceResolution;
					_ = component.referenceResolution;
				}
			}
		}

		private void Update()
		{
			try
			{
				UpdateResizeHandleVisibility();
				if (_resizeHandler != null && _resizeHandler.IsResizing)
				{
					_resizeHandler.UpdateResize();
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] Update failed: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private void UpdateResizeHandleVisibility()
		{
			if (!((Object)(object)_chatPanelComponent == (Object)null) && !((Object)(object)_resizeHandle == (Object)null))
			{
				bool flag = ((UIElement)_chatPanelComponent).IsDisplayed && _chatPanelComponent.IsChatFocused;
				if (flag != _resizeHandleVisible)
				{
					_resizeHandle.SetActive(flag);
					_resizeHandleVisible = flag;
				}
			}
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			try
			{
				_pointerHandler?.OnPointerDown(eventData);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] OnPointerDown failed: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			try
			{
				_pointerHandler?.OnPointerUp(eventData);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelInteraction] OnPointerUp failed: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		public void HandlePointerDown(PointerEventData eventData)
		{
			if (!_interactableAreaChecker.IsClickOnInteractableArea(eventData))
			{
				if ((Object)(object)_chatScrollRect != (Object)null)
				{
					_chatScrollRect.StopMovement();
					((Behaviour)_chatScrollRect).enabled = false;
				}
				this.OnInteraction?.Invoke();
				((AbstractEventData)eventData).Use();
			}
		}

		public void HandlePointerUp(PointerEventData eventData)
		{
			if ((Object)(object)_chatScrollRect != (Object)null)
			{
				((Behaviour)_chatScrollRect).enabled = true;
			}
			((AbstractEventData)eventData).Use();
		}

		private bool IsClickOnInteractableArea(PointerEventData pointerData)
		{
			return _interactableAreaChecker.IsClickOnInteractableArea(pointerData);
		}

		private void SaveCurrentState()
		{
			ChatPanelStateManager.Instance.UpdateCurrentStateFromUI((Transform)(object)_displayRect, (Transform)(object)_backgroundRect, _chatPanelRect);
		}

		public void ApplyState(Transform displayTransform, Transform backgroundTransform, RectTransform chatPanelTransform)
		{
			ChatPanelStateManager.Instance.ApplyToUI(displayTransform, backgroundTransform, chatPanelTransform);
		}

		public void SetPendingState(ChatPanelStateData state)
		{
			if (!_hasAppliedPendingState)
			{
				_pendingStateToApply = state;
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_resizeHandle != (Object)null)
			{
				Object.Destroy((Object)(object)_resizeHandle);
			}
		}
	}
	public interface IDragHandler
	{
		bool IsDragging { get; }

		Vector2 InitialPosition { get; }

		void StartDrag(PointerEventData eventData);

		void UpdateDrag();

		void EndDrag();
	}
	public class DragHandler : IDragHandler
	{
		private readonly ChatPanelInteraction _owner;

		private RectTransform _chatPanelRect;

		private bool _isDragging;

		private Vector2 _initialPosition;

		private Vector2 _lastMousePos;

		public bool IsDragging => _isDragging;

		public Vector2 InitialPosition => _initialPosition;

		public DragHandler(ChatPanelInteraction owner)
		{
			_owner = owner;
		}

		public void StartDrag(PointerEventData eventData)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_chatPanelRect = ((Component)_owner).GetComponent<RectTransform>();
				if ((Object)(object)_chatPanelRect == (Object)null)
				{
					LogDebug("StartDrag: _chatPanelRect is null");
					return;
				}
				_isDragging = true;
				_initialPosition = _chatPanelRect.anchoredPosition;
				_lastMousePos = Vector2.op_Implicit(Input.mousePosition);
				object arg = _initialPosition;
				object arg2 = _lastMousePos;
				RectTransform chatPanelRect = _chatPanelRect;
				LogDebug($"Drag START: initialPos={arg}, initialMousePos={arg2}, rectName={((chatPanelRect != null) ? ((Object)chatPanelRect).name : null)}");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelDebug] StartDrag failed: " + ex.Message));
			}
		}

		public void UpdateDrag()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (_isDragging && !((Object)(object)_chatPanelRect == (Object)null))
				{
					Vector2 val = Vector2.op_Implicit(Input.mousePosition);
					Vector2 val2 = val - _lastMousePos;
					if (((Vector2)(ref val2)).sqrMagnitude > 0.01f)
					{
						float canvasScaleFactor = GetCanvasScaleFactor();
						Vector2 val3 = val2 * canvasScaleFactor;
						RectTransform chatPanelRect = _chatPanelRect;
						chatPanelRect.anchoredPosition += val3;
						_lastMousePos = val;
						LogDebug($"UpdateDrag: screenDelta={val2}, scaleFactor={canvasScaleFactor}, canvasDelta={val3}, newPos={_chatPanelRect.anchoredPosition}");
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelDebug] UpdateDrag failed: " + ex.Message));
			}
		}

		private float GetCanvasScaleFactor()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			Canvas canvas = _owner.GetCanvas();
			if ((Object)(object)canvas == (Object)null)
			{
				return 1f;
			}
			CanvasScaler component = ((Component)canvas).GetComponent<CanvasScaler>();
			if ((Object)(object)component == (Object)null)
			{
				return 1f;
			}
			float result = 1f;
			if ((int)canvas.renderMode == 0)
			{
				Vector2 referenceResolution = component.referenceResolution;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)Screen.width, (float)Screen.height);
				if ((int)component.screenMatchMode != 0)
				{
					result = (((int)component.screenMatchMode != 1) ? Mathf.Max(referenceResolution.x / val.x, referenceResolution.y / val.y) : Mathf.Min(referenceResolution.x / val.x, referenceResolution.y / val.y));
				}
				else
				{
					float matchWidthOrHeight = component.matchWidthOrHeight;
					float num = Mathf.Log(referenceResolution.x / val.x, 2f);
					float num2 = Mathf.Log(referenceResolution.y / val.y, 2f);
					float num3 = Mathf.Lerp(num, num2, matchWidthOrHeight);
					result = Mathf.Pow(2f, num3);
				}
			}
			return result;
		}

		public void EndDrag()
		{
			try
			{
				_isDragging = false;
				_chatPanelRect = null;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelDebug] EndDrag failed: " + ex.Message));
			}
		}

		private void LogDebug(string message)
		{
		}
	}
	public interface IInteractableAreaChecker
	{
		bool IsClickOnInteractableArea(PointerEventData pointerData);
	}
	public class InteractableAreaChecker : IInteractableAreaChecker
	{
		private readonly ChatPanelInteraction _owner;

		public InteractableAreaChecker(ChatPanelInteraction owner)
		{
			_owner = owner;
		}

		public bool IsClickOnInteractableArea(PointerEventData pointerData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			RaycastResult pointerPressRaycast = pointerData.pointerPressRaycast;
			GameObject gameObject = ((RaycastResult)(ref pointerPressRaycast)).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				return false;
			}
			if ((Object)(object)_owner.ResizeHandle != (Object)null && ((Object)(object)gameObject == (Object)(object)_owner.ResizeHandle || gameObject.transform.IsChildOf(_owner.ResizeHandle.transform)))
			{
				return true;
			}
			if ((Object)(object)_owner.ChatEntryInput != (Object)null)
			{
				Transform transform = ((Component)_owner.ChatEntryInput).transform;
				if ((Object)(object)transform != (Object)null && ((Object)(object)gameObject == (Object)(object)((Component)transform).gameObject || gameObject.transform.IsChildOf(transform)))
				{
					return true;
				}
			}
			if ((Object)(object)_owner.ChatScrollRect != (Object)null)
			{
				if ((Object)(object)_owner.ChatScrollRect.verticalScrollbar != (Object)null)
				{
					Transform transform2 = ((Component)_owner.ChatScrollRect.verticalScrollbar).transform;
					if ((Object)(object)transform2 != (Object)null && ((Object)(object)gameObject == (Object)(object)((Component)transform2).gameObject || gameObject.transform.IsChildOf(transform2)))
					{
						return true;
					}
				}
				if ((Object)(object)_owner.ChatScrollRect.horizontalScrollbar != (Object)null)
				{
					Transform transform3 = ((Component)_owner.ChatScrollRect.horizontalScrollbar).transform;
					if ((Object)(object)transform3 != (Object)null && ((Object)(object)gameObject == (Object)(object)((Component)transform3).gameObject || gameObject.transform.IsChildOf(transform3)))
					{
						return true;
					}
				}
			}
			return false;
		}
	}
	public interface IPointerEventHandler
	{
		void OnPointerDown(PointerEventData eventData);

		void OnPointerUp(PointerEventData eventData);
	}
	public class PointerEventHandler : IPointerEventHandler
	{
		private readonly ChatPanelInteraction _owner;

		public PointerEventHandler(ChatPanelInteraction owner)
		{
			_owner = owner;
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			_owner.HandlePointerDown(eventData);
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			_owner.HandlePointerUp(eventData);
		}
	}
	public interface IResizeHandler
	{
		bool IsResizing { get; }

		void OnPointerDown(BaseEventData eventData);

		void OnPointerUp(BaseEventData eventData);

		void UpdateResize();
	}
	public class ResizeHandler : IResizeHandler
	{
		private const float MIN_WIDTH = 100f;

		private const float MIN_HEIGHT = 50f;

		private readonly ChatPanelInteraction _owner;

		private RectTransform _displayRect;

		private RectTransform _backgroundRect;

		private bool _isResizing;

		private Vector2 _initialMousePos;

		private Vector2 _initialSize;

		private Vector2 _originalBackgroundSize;

		public bool IsResizing => _isResizing;

		public ResizeHandler(ChatPanelInteraction owner)
		{
			_owner = owner;
		}

		public void OnPointerDown(BaseEventData eventData)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PointerEventData val = (PointerEventData)(object)((eventData is PointerEventData) ? eventData : null);
				if (val != null)
				{
					_displayRect = ((Component)_owner).GetComponent<RectTransform>();
					Transform val2 = ((Component)_owner).transform.Find("Background");
					_backgroundRect = (RectTransform)(object)((val2 is RectTransform) ? val2 : null);
					if ((Object)(object)_displayRect == (Object)null)
					{
						LogDebug("OnPointerDown: _displayRect is null");
						return;
					}
					_isResizing = true;
					Vector2 val3 = default(Vector2);
					RectTransformUtility.ScreenPointToLocalPointInRectangle(_displayRect, val.position, val.pressEventCamera, ref val3);
					_initialMousePos = val3;
					_initialSize = _displayRect.sizeDelta;
					RectTransform backgroundRect = _backgroundRect;
					_originalBackgroundSize = ((backgroundRect != null) ? backgroundRect.sizeDelta : Vector2.zero);
					LogDebug($"Resize START: localMousePos={val3}, initialSize={_initialSize}");
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelDebug] OnPointerDown failed: " + ex.Message));
			}
		}

		public void OnPointerUp(BaseEventData eventData)
		{
			try
			{
				if (_isResizing)
				{
					_isResizing = false;
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelDebug] OnPointerUp failed: " + ex.Message));
			}
		}

		public void UpdateResize()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_displayRect == (Object)null)
				{
					LogDebug("[ChatPanelDebug] HandleResize: _displayRect is null");
					return;
				}
				Vector2 val = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle(_displayRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val);
				Vector2 val2 = val - _initialMousePos;
				LogDebug($"HandleResize: localPos={val}, delta={val2}, initialSize={_initialSize}");
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(_initialSize.x + val2.x, _initialSize.y - val2.y);
				val3.x = Mathf.Clamp(val3.x, 100f, GetMaxWidth());
				val3.y = Mathf.Clamp(val3.y, 50f, GetMaxHeight());
				_displayRect.sizeDelta = val3;
				if ((Object)(object)_backgroundRect != (Object)null)
				{
					_backgroundRect.sizeDelta = val3;
				}
				LogDebug($"HandleResize: applied newSize={val3}");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChatPanelDebug] UpdateResize failed: " + ex.Message));
			}
		}

		private float GetMaxWidth()
		{
			return Screen.width;
		}

		private float GetMaxHeight()
		{
			return Screen.height;
		}

		private void LogDebug(string message)
		{
		}
	}
}