Decompiled source of ComfortUI v0.1.0

plugins/ComfortUI/ComfortUI.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ComfortUI.Patches;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ComfortUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ComfortUI")]
[assembly: AssemblyTitle("ComfortUI")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ComfortUI
{
	[BepInPlugin("com.pickteam.comfortui", "ComfortUI", "0.1.0")]
	public class ComfortUIPlugin : BasePlugin
	{
		public const string PluginGuid = "com.pickteam.comfortui";

		public const string PluginName = "ComfortUI";

		public const string PluginVersion = "0.1.0";

		internal static ManualLogSource Logger;

		internal static Harmony HarmonyInstance;

		internal static string ModFolder;

		public override void Load()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			ModFolder = Path.GetDirectoryName(((object)this).GetType().Assembly.Location);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("=== ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ComfortUI");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ===");
			}
			log.LogInfo(val);
			HarmonyInstance = new Harmony("com.pickteam.comfortui");
			HarmonyInstance.PatchAll();
			Patch_VendorSearch.Apply(HarmonyInstance);
			Patch_PlayerVendorSearch.Apply(HarmonyInstance);
			((BasePlugin)this).Log.LogInfo((object)"ComfortUI initialized.");
		}
	}
}
namespace ComfortUI.Patches
{
	public static class Patch_PlayerVendorSearch
	{
		private static IntPtr _vendorSlotsFieldPtr = IntPtr.Zero;

		private static bool _vendorSlotsLookedUp;

		private static IntPtr _vendablesFieldPtr = IntPtr.Zero;

		private static bool _vendablesLookedUp;

		internal static ManualLogSource Log => ComfortUIPlugin.Logger;

		public static void Apply(Harmony harmony)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			ClassInjector.RegisterTypeInIl2Cpp<PlayerVendorSearchComponent>();
			Type typeFromHandle = typeof(PlayerVendorSubController);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "Setup", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_PlayerVendorSearch), "Setup_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "Clear", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_PlayerVendorSearch), "Clear_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnChangeVendorHideUnusable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_PlayerVendorSearch), "Recapture_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Log.LogInfo((object)"Player vendor search patches applied.");
		}

		public static void Setup_Postfix(PlayerVendorSubController __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			try
			{
				PlayerVendorSearchComponent orCreate = GetOrCreate(__instance);
				orCreate.Show();
				orCreate.ClearSearch();
				orCreate.ScheduleRecapture();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] Setup_Postfix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		public static void Clear_Postfix(PlayerVendorSubController __instance)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			try
			{
				PlayerVendorSearchComponent component = ((Component)__instance).GetComponent<PlayerVendorSearchComponent>();
				if ((Object)(object)component != (Object)null)
				{
					component.ClearSearch();
					component.Hide();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] Clear_Postfix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		public static void Recapture_Postfix(PlayerVendorSubController __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			try
			{
				PlayerVendorSearchComponent component = ((Component)__instance).GetComponent<PlayerVendorSearchComponent>();
				if (!((Object)(object)component == (Object)null))
				{
					component.ScheduleRecapture();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] Recapture_Postfix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private static PlayerVendorSearchComponent GetOrCreate(PlayerVendorSubController v)
		{
			PlayerVendorSearchComponent component = ((Component)v).GetComponent<PlayerVendorSearchComponent>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = ((Component)v).gameObject.AddComponent<PlayerVendorSearchComponent>();
			component.Init(v);
			return component;
		}

		internal static List<UIVendorRow> ReadVendorSlots(PlayerVendorSubController vendor)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			List<UIVendorRow> list = new List<UIVendorRow>();
			bool flag = default(bool);
			try
			{
				if (!_vendorSlotsLookedUp)
				{
					_vendorSlotsLookedUp = true;
					IntPtr nativeClassPtr = Il2CppClassPointerStore<PlayerVendorSubController>.NativeClassPtr;
					if (nativeClassPtr != IntPtr.Zero)
					{
						_vendorSlotsFieldPtr = IL2CPP.il2cpp_class_get_field_from_name(nativeClassPtr, "vendorSlots");
					}
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] vendorSlots field lookup: classPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(nativeClassPtr != IntPtr.Zero);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", fieldPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_vendorSlotsFieldPtr != IntPtr.Zero);
					}
					log.LogInfo(val);
				}
				if (_vendorSlotsFieldPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[PVS] vendorSlots IL2CPP field not found");
					return list;
				}
				IntPtr intPtr = IL2CPP.il2cpp_field_get_value_object(_vendorSlotsFieldPtr, ((Il2CppObjectBase)vendor).Pointer);
				if (intPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[PVS] vendorSlots value is null");
					return list;
				}
				List<UIVendorRow> val2 = new List<UIVendorRow>(intPtr);
				for (int i = 0; i < val2.Count; i++)
				{
					list.Add(val2[i]);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Log;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[PVS] ReadVendorSlots error: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				log2.LogError(val3);
			}
			return list;
		}

		internal static List<PlayerVendorItemForSale> ReadVendables(PlayerVendorSubController vendor)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			List<PlayerVendorItemForSale> list = new List<PlayerVendorItemForSale>();
			bool flag = default(bool);
			try
			{
				if (!_vendablesLookedUp)
				{
					_vendablesLookedUp = true;
					IntPtr nativeClassPtr = Il2CppClassPointerStore<PlayerVendorSubController>.NativeClassPtr;
					if (nativeClassPtr != IntPtr.Zero)
					{
						_vendablesFieldPtr = IL2CPP.il2cpp_class_get_field_from_name(nativeClassPtr, "vendables");
					}
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] vendables field lookup: classPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(nativeClassPtr != IntPtr.Zero);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", fieldPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_vendablesFieldPtr != IntPtr.Zero);
					}
					log.LogInfo(val);
				}
				if (_vendablesFieldPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[PVS] vendables IL2CPP field not found");
					return list;
				}
				IntPtr intPtr = IL2CPP.il2cpp_field_get_value_object(_vendablesFieldPtr, ((Il2CppObjectBase)vendor).Pointer);
				if (intPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[PVS] vendables value is null");
					return list;
				}
				List<PlayerVendorItemForSale> val2 = new List<PlayerVendorItemForSale>(intPtr);
				for (int i = 0; i < val2.Count; i++)
				{
					list.Add(val2[i]);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Log;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[PVS] ReadVendables error: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				log2.LogError(val3);
			}
			return list;
		}
	}
	public class PlayerVendorSearchComponent : MonoBehaviour
	{
		private PlayerVendorSubController _vendor;

		private GameObject _container;

		private TMP_InputField _inputField;

		private string _currentFilter = "";

		private string _lastText = "";

		private bool _layoutAdjusted;

		private static bool _hierarchyDumped;

		private Dictionary<int, string> _allItems = new Dictionary<int, string>();

		private Dictionary<int, string> _allItemsTranslated = new Dictionary<int, string>();

		private Dictionary<int, UIVendorRow> _slotsByIID = new Dictionary<int, UIVendorRow>();

		private List<int> _allItemOrder = new List<int>();

		private static bool _translationMethodLookedUp;

		private static MethodInfo _translateMethod;

		private int _recaptureCountdown = -1;

		private static ManualLogSource Log => ComfortUIPlugin.Logger;

		public PlayerVendorSearchComponent(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Init(PlayerVendorSubController vendor)
		{
			_vendor = vendor;
			BuildUI();
		}

		public void Show()
		{
			if ((Object)(object)_container != (Object)null)
			{
				_container.SetActive(true);
			}
		}

		public void Hide()
		{
			if ((Object)(object)_container != (Object)null)
			{
				_container.SetActive(false);
			}
		}

		public void ClearSearch()
		{
			_currentFilter = "";
			_lastText = "";
			if ((Object)(object)_inputField != (Object)null)
			{
				_inputField.text = "";
			}
			RestoreAllVisible();
		}

		public void ScheduleRecapture()
		{
			_recaptureCountdown = 2;
		}

		public void CaptureItems()
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			if ((Object)(object)_vendor == (Object)null)
			{
				return;
			}
			_allItems.Clear();
			_allItemsTranslated.Clear();
			_allItemOrder.Clear();
			_slotsByIID.Clear();
			List<PlayerVendorItemForSale> list = Patch_PlayerVendorSearch.ReadVendables(_vendor);
			List<UIVendorRow> list2 = Patch_PlayerVendorSearch.ReadVendorSlots(_vendor);
			int num = Math.Min(list.Count, list2.Count);
			bool flag = default(bool);
			for (int i = 0; i < num; i++)
			{
				try
				{
					PlayerVendorItemForSale val = list[i];
					if (val != null && val.item != null)
					{
						int iID = val.item.IID;
						string value = val.item.Name ?? "";
						_allItems[iID] = value;
						_allItemOrder.Add(iID);
						_slotsByIID[iID] = list2[i];
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(32, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] Error reading vendable #");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(i);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val2);
				}
			}
			BuildTranslationCache();
			ManualLogSource log2 = Log;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[PVS] Captured ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(_allItems.Count);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" player vendor items");
			}
			log2.LogInfo(val3);
		}

		public void ApplyFilter()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			if ((Object)(object)_vendor == (Object)null || _allItems.Count == 0)
			{
				return;
			}
			string currentFilter = _currentFilter;
			int num = 0;
			foreach (int item in _allItemOrder)
			{
				if (!_allItems.TryGetValue(item, out var value) || !_slotsByIID.TryGetValue(item, out var value2))
				{
					continue;
				}
				string value3;
				bool flag = string.IsNullOrEmpty(currentFilter) || value.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) >= 0 || (_allItemsTranslated.TryGetValue(item, out value3) && value3.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) >= 0);
				if ((Object)(object)value2 != (Object)null && (Object)(object)((Component)value2).gameObject != (Object)null)
				{
					((Component)value2).gameObject.SetActive(flag);
					if (flag)
					{
						num++;
					}
				}
			}
			ManualLogSource log = Log;
			bool flag2 = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] ApplyFilter: '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(currentFilter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' → showing ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_allItems.Count);
			}
			log.LogInfo(val);
		}

		private void RestoreAllVisible()
		{
			foreach (KeyValuePair<int, UIVendorRow> item in _slotsByIID)
			{
				try
				{
					if ((Object)(object)item.Value != (Object)null && (Object)(object)((Component)item.Value).gameObject != (Object)null)
					{
						((Component)item.Value).gameObject.SetActive(true);
					}
				}
				catch
				{
				}
			}
		}

		private void BuildTranslationCache()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			MethodInfo translateMethod = GetTranslateMethod();
			if (translateMethod == null)
			{
				return;
			}
			int num = 0;
			foreach (KeyValuePair<int, string> allItem in _allItems)
			{
				try
				{
					string text = (string)translateMethod.Invoke(null, new object[1] { allItem.Value });
					if (text != null && text != allItem.Value)
					{
						_allItemsTranslated[allItem.Key] = text;
						num++;
					}
				}
				catch
				{
				}
			}
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_allItems.Count);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" items translated");
			}
			log.LogInfo(val);
		}

		private static MethodInfo GetTranslateMethod()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			if (_translationMethodLookedUp)
			{
				return _translateMethod;
			}
			_translationMethodLookedUp = true;
			bool flag = default(bool);
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					if (assembly.GetName().Name != "Translator")
					{
						continue;
					}
					Type type = assembly.GetType("TranslationDictionary");
					if (!(type == null))
					{
						_translateMethod = type.GetMethod("Translate", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null);
						ManualLogSource log = Log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] Found TranslationDictionary.Translate: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_translateMethod != null);
						}
						log.LogInfo(val);
						break;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(43, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] TranslationDictionary lookup failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val2);
			}
			return _translateMethod;
		}

		private void Update()
		{
			if ((Object)(object)_inputField == (Object)null || (Object)(object)_vendor == (Object)null)
			{
				return;
			}
			if (_recaptureCountdown > 0)
			{
				_recaptureCountdown--;
			}
			else if (_recaptureCountdown == 0)
			{
				_recaptureCountdown = -1;
				CaptureItems();
				if (!string.IsNullOrEmpty(_currentFilter))
				{
					ApplyFilter();
				}
			}
			if (_inputField.isFocused)
			{
				_inputField.ForceLabelUpdate();
			}
			string text = _inputField.text ?? "";
			if (text != _lastText)
			{
				_lastText = text;
				OnSearchChanged(text);
			}
		}

		private void BuildUI()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Expected O, but got Unknown
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_vendor == (Object)null)
			{
				return;
			}
			RectTransform vendorPanel = _vendor.VendorPanel;
			if ((Object)(object)vendorPanel == (Object)null)
			{
				Log.LogWarning((object)"[PVS] VendorPanel is null");
				return;
			}
			if (!_hierarchyDumped)
			{
				_hierarchyDumped = true;
				Log.LogInfo((object)"===== PlayerVendorPanel hierarchy =====");
				Patch_VendorSearch.DumpHierarchy((Transform)(object)vendorPanel);
				Log.LogInfo((object)"===== End hierarchy =====");
			}
			ScrollRect inventoryScrollRect = _vendor.InventoryScrollRect;
			Transform val;
			int num;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2;
			if ((Object)(object)inventoryScrollRect != (Object)null)
			{
				val = ((Component)inventoryScrollRect).transform.parent;
				num = ((Component)inventoryScrollRect).transform.GetSiblingIndex();
				ManualLogSource log = Log;
				val2 = new BepInExInfoLogInterpolatedStringHandler(59, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] Anchoring relative to ScrollRect '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)inventoryScrollRect).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sibIdx=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" parent='");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
				}
				log.LogInfo(val2);
			}
			else
			{
				RectTransform vendorInventoryArea = _vendor.VendorInventoryArea;
				if ((Object)(object)vendorInventoryArea != (Object)null)
				{
					val = ((Transform)vendorInventoryArea).parent;
					num = ((Transform)vendorInventoryArea).GetSiblingIndex();
					ManualLogSource log2 = Log;
					val2 = new BepInExInfoLogInterpolatedStringHandler(56, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] Anchoring relative to InvArea '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)vendorInventoryArea).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sibIdx=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" parent='");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					log2.LogInfo(val2);
				}
				else
				{
					val = (Transform)(object)vendorPanel;
					num = 0;
					Log.LogInfo((object)"[PVS] Fallback: using VendorPanel as parent");
				}
			}
			int layer = ((Component)vendorPanel).gameObject.layer;
			_container = new GameObject("ComfortUI_PlayerVendorSearch");
			_container.layer = layer;
			_container.transform.SetParent(val, false);
			_container.transform.SetSiblingIndex(num);
			RectTransform val3 = _container.GetComponent<RectTransform>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = _container.AddComponent<RectTransform>();
			}
			if ((Object)(object)((Component)val).GetComponent<LayoutGroup>() != (Object)null)
			{
				ManualLogSource log3 = Log;
				val2 = new BepInExInfoLogInterpolatedStringHandler(53, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] Parent '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' has LayoutGroup — using LayoutElement");
				}
				log3.LogInfo(val2);
				LayoutElement obj = _container.AddComponent<LayoutElement>();
				obj.preferredHeight = 30f;
				obj.minHeight = 30f;
				obj.flexibleWidth = 1f;
			}
			else
			{
				Log.LogInfo((object)"[PVS] No LayoutGroup — using manual anchoring");
				RectTransform val4 = (RectTransform)(((Object)(object)inventoryScrollRect != (Object)null) ? ((object)/*isinst with value type is only supported in some contexts*/) : ((object)_vendor.VendorInventoryArea));
				if ((Object)(object)val4 != (Object)null)
				{
					val3.anchorMin = new Vector2(val4.anchorMin.x, val4.anchorMax.y);
					val3.anchorMax = new Vector2(val4.anchorMax.x, val4.anchorMax.y);
					val3.pivot = new Vector2(0.5f, 1f);
					val3.offsetMin = new Vector2(val4.offsetMin.x, 0f);
					val3.offsetMax = new Vector2(val4.offsetMax.x, 0f);
					val3.sizeDelta = new Vector2(val3.sizeDelta.x, 30f);
					val3.anchoredPosition = new Vector2(val3.anchoredPosition.x, 0f);
				}
				else
				{
					val3.anchorMin = new Vector2(0f, 1f);
					val3.anchorMax = new Vector2(1f, 1f);
					val3.pivot = new Vector2(0.5f, 1f);
					val3.anchoredPosition = Vector2.zero;
					val3.sizeDelta = new Vector2(-16f, 30f);
				}
			}
			_container.AddComponent<CanvasRenderer>();
			((Graphic)_container.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.95f);
			ManualLogSource log4 = Log;
			val2 = new BepInExInfoLogInterpolatedStringHandler(63, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] Container: parent='");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sibIdx=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_container.transform.GetSiblingIndex());
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("rt.rect=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Rect>(val3.rect);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" anchPos=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(val3.anchoredPosition);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sizeDelta=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(val3.sizeDelta);
			}
			log4.LogInfo(val2);
			_inputField = TryCloneInputField(_container.transform, layer);
			if ((Object)(object)_inputField == (Object)null)
			{
				Log.LogWarning((object)"[PVS] Clone failed — manual fallback");
				_inputField = CreateInputFieldManual(_container.transform, layer);
			}
			if ((Object)(object)_inputField != (Object)null)
			{
				Log.LogInfo((object)"[PVS] InputField ready.");
			}
			else
			{
				Log.LogError((object)"[PVS] Failed to create InputField!");
			}
			AdjustScrollArea();
			Log.LogInfo((object)"[PVS] UI created.");
		}

		private TMP_InputField TryCloneInputField(Transform parent, int layer)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			TMP_InputField val = null;
			bool flag = default(bool);
			try
			{
				UIAbilitiesController instance = UIBehaviourSingleton<UIAbilitiesController>.Instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.SearchBar != (Object)null)
				{
					val = instance.SearchBar;
					Log.LogInfo((object)"[PVS] Source: UIAbilitiesController.SearchBar");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] UIAbilitiesController: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
			}
			if ((Object)(object)val == (Object)null)
			{
				try
				{
					Il2CppArrayBase<TMP_InputField> val3 = Resources.FindObjectsOfTypeAll<TMP_InputField>();
					if (val3 != null && val3.Length > 0)
					{
						val = val3[0];
						ManualLogSource log2 = Log;
						BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[PVS] Source: Resources (");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(val3.Length);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" found, using '");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val).name);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("')");
						}
						log2.LogInfo(val4);
					}
				}
				catch (Exception ex2)
				{
					ManualLogSource log3 = Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(15, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] FindAll: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
					}
					log3.LogWarning(val2);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			try
			{
				GameObject val5 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent);
				((Object)val5).name = "SearchInput_Clone";
				val5.layer = layer;
				val5.SetActive(true);
				RectTransform component = val5.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.one;
					component.offsetMin = new Vector2(6f, 2f);
					component.offsetMax = new Vector2(-6f, -2f);
				}
				SetLayerRecursive(val5.transform, layer);
				TMP_InputField component2 = val5.GetComponent<TMP_InputField>();
				if ((Object)(object)component2 != (Object)null)
				{
					((UnityEventBase)component2.onValueChanged).RemoveAllListeners();
					component2.text = "";
					component2.characterLimit = 50;
					Graphic placeholder = component2.placeholder;
					if ((Object)(object)placeholder != (Object)null)
					{
						TextMeshProUGUI component3 = ((Component)placeholder).GetComponent<TextMeshProUGUI>();
						if ((Object)(object)component3 != (Object)null)
						{
							((TMP_Text)component3).text = "Search...";
						}
						else
						{
							Text component4 = ((Component)placeholder).GetComponent<Text>();
							if ((Object)(object)component4 != (Object)null)
							{
								component4.text = "Search...";
							}
						}
					}
					Log.LogInfo((object)"[PVS] Cloned OK");
					WireClearButtons(val5.transform, component2);
					return component2;
				}
				Object.Destroy((Object)(object)val5);
			}
			catch (Exception ex3)
			{
				ManualLogSource log4 = Log;
				BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[PVS] Clone error: ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex3);
				}
				log4.LogError(val6);
			}
			return null;
		}

		private TMP_InputField CreateInputFieldManual(Transform parent, int layer)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00b9: 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)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			try
			{
				GameObject val = MakeUI("SearchInput_Manual", parent, layer);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = new Vector2(6f, 2f);
				component.offsetMax = new Vector2(-6f, -2f);
				Image val2 = val.AddComponent<Image>();
				((Graphic)val2).color = new Color(0.08f, 0.08f, 0.08f, 0.95f);
				((Graphic)val2).raycastTarget = true;
				GameObject val3 = MakeUI("Text Area", val.transform, layer);
				RectTransform component2 = val3.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = new Vector2(6f, 0f);
				component2.offsetMax = new Vector2(-6f, 0f);
				val3.AddComponent<RectMask2D>();
				GameObject obj = MakeUI("Placeholder", val3.transform, layer);
				Stretch(obj.GetComponent<RectTransform>());
				TextMeshProUGUI val4 = obj.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val4).text = "Search / Поиск...";
				((TMP_Text)val4).fontSize = 14f;
				((TMP_Text)val4).fontStyle = (FontStyles)2;
				((Graphic)val4).color = new Color(0.5f, 0.5f, 0.5f, 0.7f);
				((TMP_Text)val4).alignment = (TextAlignmentOptions)4097;
				((Graphic)val4).raycastTarget = false;
				GameObject obj2 = MakeUI("Text", val3.transform, layer);
				Stretch(obj2.GetComponent<RectTransform>());
				TextMeshProUGUI val5 = obj2.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val5).fontSize = 14f;
				((Graphic)val5).color = Color.white;
				((TMP_Text)val5).alignment = (TextAlignmentOptions)4097;
				((Graphic)val5).raycastTarget = false;
				TMP_InputField obj3 = val.AddComponent<TMP_InputField>();
				obj3.textViewport = component2;
				obj3.textComponent = (TMP_Text)(object)val5;
				obj3.placeholder = (Graphic)(object)val4;
				obj3.fontAsset = ((TMP_Text)val5).font;
				obj3.pointSize = 14f;
				obj3.characterLimit = 50;
				((Selectable)obj3).image = val2;
				Log.LogInfo((object)"[PVS] Manual InputField created");
				return obj3;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[PVS] Manual creation failed: ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
				}
				log.LogError(val6);
				return null;
			}
		}

		private static GameObject MakeUI(string name, Transform parent, int layer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.layer = layer;
			val.transform.SetParent(parent, false);
			if ((Object)(object)val.GetComponent<RectTransform>() == (Object)null)
			{
				val.AddComponent<RectTransform>();
			}
			if ((Object)(object)val.GetComponent<CanvasRenderer>() == (Object)null)
			{
				val.AddComponent<CanvasRenderer>();
			}
			return val;
		}

		private static void Stretch(RectTransform rt)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.offsetMin = Vector2.zero;
			rt.offsetMax = Vector2.zero;
		}

		private static void SetLayerRecursive(Transform t, int layer)
		{
			((Component)t).gameObject.layer = layer;
			for (int i = 0; i < t.childCount; i++)
			{
				SetLayerRecursive(t.GetChild(i), layer);
			}
		}

		private void WireClearButtons(Transform root, TMP_InputField field)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			bool flag = default(bool);
			for (int i = 0; i < root.childCount; i++)
			{
				Transform child = root.GetChild(i);
				Button component = ((Component)child).GetComponent<Button>();
				if ((Object)(object)component != (Object)null)
				{
					((UnityEventBase)component.onClick).RemoveAllListeners();
					TMP_InputField f = field;
					((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
					{
						f.text = "";
						Log.LogInfo((object)"[PVS] Clear button clicked");
					}));
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] Rewired button '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)child).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					}
					log.LogInfo(val);
				}
				WireClearButtons(child, field);
			}
		}

		private void AdjustScrollArea()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00f4: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_vendor == (Object)null || _layoutAdjusted)
			{
				return;
			}
			ScrollRect inventoryScrollRect = _vendor.InventoryScrollRect;
			bool flag = default(bool);
			if ((Object)(object)inventoryScrollRect != (Object)null)
			{
				Transform transform = ((Component)inventoryScrollRect).transform;
				RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if ((Object)(object)val != (Object)null)
				{
					val.offsetMax = new Vector2(val.offsetMax.x, val.offsetMax.y - 34f);
					_layoutAdjusted = true;
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] ScrollRect shifted: offsetMax=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(val.offsetMax);
					}
					log.LogInfo(val2);
					return;
				}
			}
			RectTransform vendorInventoryArea = _vendor.VendorInventoryArea;
			if ((Object)(object)vendorInventoryArea != (Object)null)
			{
				vendorInventoryArea.offsetMax = new Vector2(vendorInventoryArea.offsetMax.x, vendorInventoryArea.offsetMax.y - 34f);
				_layoutAdjusted = true;
				ManualLogSource log2 = Log;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PVS] InvArea shifted: offsetMax=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(vendorInventoryArea.offsetMax);
				}
				log2.LogInfo(val2);
			}
		}

		private void OnSearchChanged(string text)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			_currentFilter = text?.Trim() ?? "";
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PVS] OnSearchChanged: filter='");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_currentFilter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
			}
			log.LogInfo(val);
			ApplyFilter();
		}
	}
	public static class Patch_VendorSearch
	{
		private static IntPtr _vendableByIdFieldPtr = IntPtr.Zero;

		private static bool _fieldLookedUp;

		private static IntPtr _elementsFieldPtr = IntPtr.Zero;

		private static bool _elementsFieldLookedUp;

		internal static ManualLogSource Log => ComfortUIPlugin.Logger;

		public static void Apply(Harmony harmony)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			ClassInjector.RegisterTypeInIl2Cpp<VendorSearchComponent>();
			Type typeFromHandle = typeof(VendorSubController);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "Setup", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_VendorSearch), "Setup_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "Clear", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_VendorSearch), "Clear_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnChangeVendorHideUnusable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_VendorSearch), "Recapture_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnChangeVendorHideKnownRecipes", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_VendorSearch), "Recapture_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnChangeInventoryFolder", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch_VendorSearch), "Recapture_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Log.LogInfo((object)"Vendor search patches applied.");
		}

		public static void Setup_Postfix(VendorSubController __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			try
			{
				VendorSearchComponent orCreate = GetOrCreate(__instance);
				orCreate.Show();
				orCreate.ClearSearch();
				orCreate.CaptureItems(__instance);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(15, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Setup_Postfix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		public static void Clear_Postfix(VendorSubController __instance)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			try
			{
				VendorSearchComponent component = ((Component)__instance).GetComponent<VendorSearchComponent>();
				if ((Object)(object)component != (Object)null)
				{
					component.ClearSearch();
					component.Hide();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(15, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Clear_Postfix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		public static void Recapture_Postfix(VendorSubController __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			try
			{
				VendorSearchComponent component = ((Component)__instance).GetComponent<VendorSearchComponent>();
				if (!((Object)(object)component == (Object)null))
				{
					component.ScheduleRecapture();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Recapture_Postfix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private static VendorSearchComponent GetOrCreate(VendorSubController v)
		{
			VendorSearchComponent component = ((Component)v).GetComponent<VendorSearchComponent>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = ((Component)v).gameObject.AddComponent<VendorSearchComponent>();
			component.Init(v);
			return component;
		}

		internal static List<int> ReadScrollDisplayIds(UIScrollDisplay sd)
		{
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			List<int> list = new List<int>();
			bool flag = default(bool);
			try
			{
				BepInExInfoLogInterpolatedStringHandler val;
				if (!_elementsFieldLookedUp)
				{
					_elementsFieldLookedUp = true;
					IntPtr nativeClassPtr = Il2CppClassPointerStore<UIScrollDisplay>.NativeClassPtr;
					if (nativeClassPtr != IntPtr.Zero)
					{
						_elementsFieldPtr = IL2CPP.il2cpp_class_get_field_from_name(nativeClassPtr, "elements");
					}
					ManualLogSource log = Log;
					val = new BepInExInfoLogInterpolatedStringHandler(48, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] elements field lookup: classPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(nativeClassPtr != IntPtr.Zero);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", fieldPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_elementsFieldPtr != IntPtr.Zero);
					}
					log.LogInfo(val);
				}
				if (_elementsFieldPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[VS] elements IL2CPP field not found");
					return list;
				}
				IntPtr intPtr = IL2CPP.il2cpp_field_get_value_object(_elementsFieldPtr, ((Il2CppObjectBase)sd).Pointer);
				if (intPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[VS] elements value is null");
					return list;
				}
				List<UIScrollItem> val2 = new List<UIScrollItem>(intPtr);
				for (int i = 0; i < val2.Count; i++)
				{
					list.Add(val2[i].Id);
				}
				ManualLogSource log2 = Log;
				val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Read ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" scroll display IDs");
				}
				log2.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = Log;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[VS] ReadScrollDisplayIds error: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				log3.LogError(val3);
			}
			return list;
		}

		internal static Dictionary<int, string> ReadVendableNames(VendorSubController vendor)
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			Dictionary<int, string> dictionary = new Dictionary<int, string>();
			bool flag = default(bool);
			try
			{
				BepInExInfoLogInterpolatedStringHandler val;
				if (!_fieldLookedUp)
				{
					_fieldLookedUp = true;
					IntPtr nativeClassPtr = Il2CppClassPointerStore<VendorSubController>.NativeClassPtr;
					if (nativeClassPtr != IntPtr.Zero)
					{
						_vendableByIdFieldPtr = IL2CPP.il2cpp_class_get_field_from_name(nativeClassPtr, "vendableById");
					}
					ManualLogSource log = Log;
					val = new BepInExInfoLogInterpolatedStringHandler(46, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] IL2CPP field lookup: classPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(nativeClassPtr != IntPtr.Zero);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", fieldPtr=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_vendableByIdFieldPtr != IntPtr.Zero);
					}
					log.LogInfo(val);
				}
				if (_vendableByIdFieldPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[VS] vendableById IL2CPP field not found");
					return dictionary;
				}
				IntPtr intPtr = IL2CPP.il2cpp_field_get_value_object(_vendableByIdFieldPtr, ((Il2CppObjectBase)vendor).Pointer);
				if (intPtr == IntPtr.Zero)
				{
					Log.LogWarning((object)"[VS] vendableById value is null");
					return dictionary;
				}
				Enumerator<int, VendorInfo> enumerator = new Dictionary<int, VendorInfo>(intPtr).GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<int, VendorInfo> current = enumerator.Current;
					dictionary[current.Key] = current.Value.GetName() ?? "";
				}
				ManualLogSource log2 = Log;
				val = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Read ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(dictionary.Count);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" vendable names via IL2CPP");
				}
				log2.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] ReadVendableNames error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				log3.LogError(val2);
			}
			return dictionary;
		}

		internal static void DumpHierarchy(Transform root, int depth = 0)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)root == (Object)null))
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append(' ', depth * 2);
				StringBuilder stringBuilder2 = stringBuilder;
				StringBuilder stringBuilder3 = stringBuilder2;
				StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(13, 3, stringBuilder2);
				handler.AppendLiteral("[");
				handler.AppendFormatted(root.GetSiblingIndex());
				handler.AppendLiteral("] '");
				handler.AppendFormatted(((Object)root).name);
				handler.AppendLiteral("' active=");
				handler.AppendFormatted(((Component)root).gameObject.activeSelf);
				stringBuilder3.Append(ref handler);
				RectTransform component = ((Component)root).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder4 = stringBuilder2;
					handler = new StringBuilder.AppendInterpolatedStringHandler(49, 11, stringBuilder2);
					handler.AppendLiteral(" rect=");
					handler.AppendFormatted<Rect>(component.rect);
					handler.AppendLiteral(" anch=(");
					handler.AppendFormatted(component.anchorMin.x, "F1");
					handler.AppendLiteral(",");
					handler.AppendFormatted(component.anchorMin.y, "F1");
					handler.AppendLiteral(")-(");
					handler.AppendFormatted(component.anchorMax.x, "F1");
					handler.AppendLiteral(",");
					handler.AppendFormatted(component.anchorMax.y, "F1");
					handler.AppendLiteral(") pivot=(");
					handler.AppendFormatted(component.pivot.x, "F1");
					handler.AppendLiteral(",");
					handler.AppendFormatted(component.pivot.y, "F1");
					handler.AppendLiteral(") anchPos=(");
					handler.AppendFormatted(component.anchoredPosition.x, "F1");
					handler.AppendLiteral(",");
					handler.AppendFormatted(component.anchoredPosition.y, "F1");
					handler.AppendLiteral(") szD=(");
					handler.AppendFormatted(component.sizeDelta.x, "F1");
					handler.AppendLiteral(",");
					handler.AppendFormatted(component.sizeDelta.y, "F1");
					handler.AppendLiteral(")");
					stringBuilder4.Append(ref handler);
				}
				List<string> list = new List<string>();
				if ((Object)(object)((Component)root).GetComponent<LayoutGroup>() != (Object)null)
				{
					list.Add("LayoutGroup");
				}
				if ((Object)(object)((Component)root).GetComponent<ContentSizeFitter>() != (Object)null)
				{
					list.Add("CSF");
				}
				if ((Object)(object)((Component)root).GetComponent<LayoutElement>() != (Object)null)
				{
					list.Add("LE");
				}
				if ((Object)(object)((Component)root).GetComponent<ScrollRect>() != (Object)null)
				{
					list.Add("ScrollRect");
				}
				if ((Object)(object)((Component)root).GetComponent<Mask>() != (Object)null)
				{
					list.Add("Mask");
				}
				if ((Object)(object)((Component)root).GetComponent<RectMask2D>() != (Object)null)
				{
					list.Add("RectMask2D");
				}
				if ((Object)(object)((Component)root).GetComponent<Image>() != (Object)null)
				{
					list.Add("Image");
				}
				if ((Object)(object)((Component)root).GetComponent<CanvasRenderer>() != (Object)null)
				{
					list.Add("CR");
				}
				if ((Object)(object)((Component)root).GetComponent<Canvas>() != (Object)null)
				{
					list.Add("Canvas");
				}
				if ((Object)(object)((Component)root).GetComponent<TMP_InputField>() != (Object)null)
				{
					list.Add("TMP_IF");
				}
				if ((Object)(object)((Component)root).GetComponent<TextMeshProUGUI>() != (Object)null)
				{
					list.Add("TMP");
				}
				if ((Object)(object)((Component)root).GetComponent<Toggle>() != (Object)null)
				{
					list.Add("Toggle");
				}
				if (list.Count > 0)
				{
					stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder5 = stringBuilder2;
					handler = new StringBuilder.AppendInterpolatedStringHandler(3, 1, stringBuilder2);
					handler.AppendLiteral(" [");
					handler.AppendFormatted(string.Join(",", list));
					handler.AppendLiteral("]");
					stringBuilder5.Append(ref handler);
				}
				Log.LogInfo((object)stringBuilder.ToString());
				for (int i = 0; i < root.childCount; i++)
				{
					DumpHierarchy(root.GetChild(i), depth + 1);
				}
			}
		}
	}
	public class VendorSearchComponent : MonoBehaviour
	{
		private VendorSubController _vendor;

		private GameObject _container;

		private TMP_InputField _inputField;

		private string _currentFilter = "";

		private string _lastText = "";

		private bool _layoutAdjusted;

		private static bool _hierarchyDumped;

		private Dictionary<int, string> _allItems = new Dictionary<int, string>();

		private Dictionary<int, string> _allItemsTranslated = new Dictionary<int, string>();

		private List<int> _allItemOrder = new List<int>();

		private static bool _translationMethodLookedUp;

		private static MethodInfo _translateMethod;

		private int _recaptureCountdown = -1;

		private int _lastActiveTab = -1;

		private static ManualLogSource Log => ComfortUIPlugin.Logger;

		public string CurrentFilter => _currentFilter;

		public VendorSearchComponent(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Init(VendorSubController vendor)
		{
			_vendor = vendor;
			BuildUI();
		}

		public void Show()
		{
			if ((Object)(object)_container != (Object)null)
			{
				_container.SetActive(true);
			}
		}

		public void Hide()
		{
			if ((Object)(object)_container != (Object)null)
			{
				_container.SetActive(false);
			}
		}

		public void ClearSearch()
		{
			_currentFilter = "";
			_lastText = "";
			if ((Object)(object)_inputField != (Object)null)
			{
				_inputField.text = "";
			}
		}

		public void CaptureItems(VendorSubController vendor)
		{
			if (GetActiveTab() == 1)
			{
				CaptureItemsForSellTab(vendor);
			}
			else
			{
				CaptureItemsForBuyTab(vendor);
			}
		}

		private void CaptureItemsForSellTab(VendorSubController vendor)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			_allItems.Clear();
			_allItemsTranslated.Clear();
			_allItemOrder.Clear();
			UIScrollDisplay scrollDisplay = vendor.ScrollDisplay;
			if ((Object)(object)scrollDisplay == (Object)null)
			{
				Log.LogWarning((object)"[VS] CaptureItemsForSellTab: ScrollDisplay is null");
				return;
			}
			bool flag = default(bool);
			foreach (int item in Patch_VendorSearch.ReadScrollDisplayIds(scrollDisplay))
			{
				try
				{
					Item itemByIID = UIInventoryController.GetItemByIID(item);
					if (itemByIID != null)
					{
						string value = itemByIID.Name ?? "";
						_allItems[item] = value;
						_allItemOrder.Add(item);
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Error reading item IID ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(item);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val);
				}
			}
			BuildTranslationCache();
			ManualLogSource log2 = Log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] Captured ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_allItems.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" sell-tab items");
			}
			log2.LogInfo(val2);
		}

		private void CaptureItemsForBuyTab(VendorSubController vendor)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			Dictionary<int, string> dictionary = Patch_VendorSearch.ReadVendableNames(vendor);
			if (dictionary.Count > 0)
			{
				_allItems = dictionary;
				_allItemOrder.Clear();
				_allItemOrder.AddRange(dictionary.Keys);
				_allItemsTranslated.Clear();
				BuildTranslationCache();
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Captured ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_allItems.Count);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" buy-tab items");
				}
				log.LogInfo(val);
			}
			else
			{
				Log.LogWarning((object)"[VS] CaptureItemsForBuyTab: no items read from vendableById");
			}
		}

		private void BuildTranslationCache()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			MethodInfo translateMethod = GetTranslateMethod();
			if (translateMethod == null)
			{
				return;
			}
			int num = 0;
			foreach (KeyValuePair<int, string> allItem in _allItems)
			{
				try
				{
					string text = (string)translateMethod.Invoke(null, new object[1] { allItem.Value });
					if (text != null && text != allItem.Value)
					{
						_allItemsTranslated[allItem.Key] = text;
						num++;
					}
				}
				catch
				{
				}
			}
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_allItems.Count);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" items translated");
			}
			log.LogInfo(val);
		}

		private static MethodInfo GetTranslateMethod()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			if (_translationMethodLookedUp)
			{
				return _translateMethod;
			}
			_translationMethodLookedUp = true;
			bool flag = default(bool);
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					if (assembly.GetName().Name != "Translator")
					{
						continue;
					}
					Type type = assembly.GetType("TranslationDictionary");
					if (!(type == null))
					{
						_translateMethod = type.GetMethod("Translate", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null);
						ManualLogSource log = Log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Found TranslationDictionary.Translate: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_translateMethod != null);
						}
						log.LogInfo(val);
						break;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] TranslationDictionary lookup failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val2);
			}
			return _translateMethod;
		}

		public void ScheduleRecapture()
		{
			_recaptureCountdown = 2;
		}

		public void ApplyFilter()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			if ((Object)(object)_vendor == (Object)null)
			{
				return;
			}
			UIScrollDisplay scrollDisplay = _vendor.ScrollDisplay;
			if ((Object)(object)scrollDisplay == (Object)null || _allItems.Count == 0)
			{
				return;
			}
			string currentFilter = _currentFilter;
			int num = 0;
			scrollDisplay.Clear();
			foreach (int item in _allItemOrder)
			{
				if (_allItems.TryGetValue(item, out var value) && (string.IsNullOrEmpty(currentFilter) || value.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) >= 0 || (_allItemsTranslated.TryGetValue(item, out var value2) && value2.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) >= 0)))
				{
					scrollDisplay.Add(item);
					num++;
				}
			}
			scrollDisplay.OnDoneAdding();
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] ApplyFilter: '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(currentFilter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' → showing ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_allItems.Count);
			}
			log.LogInfo(val);
		}

		private int GetActiveTab()
		{
			if ((Object)(object)_vendor == (Object)null)
			{
				return -1;
			}
			try
			{
				if ((Object)(object)_vendor.SellTab != (Object)null && _vendor.SellTab.isOn)
				{
					return 1;
				}
				if ((Object)(object)_vendor.BuyNewTab != (Object)null && _vendor.BuyNewTab.isOn)
				{
					return 2;
				}
				if ((Object)(object)_vendor.BuyUsedTab != (Object)null && _vendor.BuyUsedTab.isOn)
				{
					return 3;
				}
				if ((Object)(object)_vendor.ConsignmentTab != (Object)null && _vendor.ConsignmentTab.isOn)
				{
					return 4;
				}
			}
			catch
			{
			}
			return 0;
		}

		private void Update()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if ((Object)(object)_inputField == (Object)null || (Object)(object)_vendor == (Object)null)
			{
				return;
			}
			int activeTab = GetActiveTab();
			if (activeTab != _lastActiveTab && _lastActiveTab >= 0)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Tab switched ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_lastActiveTab);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(activeTab);
				}
				log.LogInfo(val);
				_recaptureCountdown = 2;
			}
			_lastActiveTab = activeTab;
			if (_recaptureCountdown > 0)
			{
				_recaptureCountdown--;
			}
			else if (_recaptureCountdown == 0)
			{
				_recaptureCountdown = -1;
				CaptureItems(_vendor);
				if (!string.IsNullOrEmpty(_currentFilter))
				{
					ApplyFilter();
				}
			}
			if (_inputField.isFocused)
			{
				_inputField.ForceLabelUpdate();
			}
			string text = _inputField.text ?? "";
			if (text != _lastText)
			{
				_lastText = text;
				OnSearchChanged(text);
			}
		}

		private void BuildUI()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Expected O, but got Unknown
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_vendor == (Object)null)
			{
				return;
			}
			RectTransform vendorPanel = _vendor.VendorPanel;
			if ((Object)(object)vendorPanel == (Object)null)
			{
				Log.LogWarning((object)"VendorPanel is null");
				return;
			}
			ScrollRect inventoryScrollRect = _vendor.InventoryScrollRect;
			Transform val;
			int num;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2;
			if ((Object)(object)inventoryScrollRect != (Object)null)
			{
				val = ((Component)inventoryScrollRect).transform.parent;
				num = ((Component)inventoryScrollRect).transform.GetSiblingIndex();
				ManualLogSource log = Log;
				val2 = new BepInExInfoLogInterpolatedStringHandler(58, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] Anchoring relative to ScrollRect '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)inventoryScrollRect).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sibIdx=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" parent='");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
				}
				log.LogInfo(val2);
			}
			else
			{
				RectTransform vendorInventoryArea = _vendor.VendorInventoryArea;
				if ((Object)(object)vendorInventoryArea != (Object)null)
				{
					val = ((Transform)vendorInventoryArea).parent;
					num = ((Transform)vendorInventoryArea).GetSiblingIndex();
					ManualLogSource log2 = Log;
					val2 = new BepInExInfoLogInterpolatedStringHandler(55, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] Anchoring relative to InvArea '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)vendorInventoryArea).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sibIdx=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" parent='");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					log2.LogInfo(val2);
				}
				else
				{
					val = (Transform)(object)vendorPanel;
					num = 0;
					Log.LogInfo((object)"[VS] Fallback: using VendorPanel as parent");
				}
			}
			int layer = ((Component)vendorPanel).gameObject.layer;
			_container = new GameObject("ComfortUI_VendorSearch");
			_container.layer = layer;
			_container.transform.SetParent(val, false);
			_container.transform.SetSiblingIndex(num);
			RectTransform val3 = _container.GetComponent<RectTransform>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = _container.AddComponent<RectTransform>();
			}
			if ((Object)(object)((Component)val).GetComponent<LayoutGroup>() != (Object)null)
			{
				ManualLogSource log3 = Log;
				val2 = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] Parent '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' has LayoutGroup — using LayoutElement");
				}
				log3.LogInfo(val2);
				LayoutElement obj = _container.AddComponent<LayoutElement>();
				obj.preferredHeight = 30f;
				obj.minHeight = 30f;
				obj.flexibleWidth = 1f;
			}
			else
			{
				Log.LogInfo((object)"[VS] No LayoutGroup — using manual anchoring");
				RectTransform val4 = (RectTransform)(((Object)(object)inventoryScrollRect != (Object)null) ? ((object)/*isinst with value type is only supported in some contexts*/) : ((object)_vendor.VendorInventoryArea));
				if ((Object)(object)val4 != (Object)null)
				{
					val3.anchorMin = new Vector2(val4.anchorMin.x, val4.anchorMax.y);
					val3.anchorMax = new Vector2(val4.anchorMax.x, val4.anchorMax.y);
					val3.pivot = new Vector2(0.5f, 1f);
					val3.offsetMin = new Vector2(val4.offsetMin.x, 0f);
					val3.offsetMax = new Vector2(val4.offsetMax.x, 0f);
					val3.sizeDelta = new Vector2(val3.sizeDelta.x, 30f);
					val3.anchoredPosition = new Vector2(val3.anchoredPosition.x, 0f);
				}
				else
				{
					val3.anchorMin = new Vector2(0f, 1f);
					val3.anchorMax = new Vector2(1f, 1f);
					val3.pivot = new Vector2(0.5f, 1f);
					val3.anchoredPosition = Vector2.zero;
					val3.sizeDelta = new Vector2(-16f, 30f);
				}
			}
			_container.AddComponent<CanvasRenderer>();
			((Graphic)_container.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.95f);
			ManualLogSource log4 = Log;
			val2 = new BepInExInfoLogInterpolatedStringHandler(62, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] Container: parent='");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sibIdx=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_container.transform.GetSiblingIndex());
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("rt.rect=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Rect>(val3.rect);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" anchPos=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(val3.anchoredPosition);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("sizeDelta=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(val3.sizeDelta);
			}
			log4.LogInfo(val2);
			_inputField = TryCloneInputField(_container.transform, layer);
			if ((Object)(object)_inputField == (Object)null)
			{
				Log.LogWarning((object)"[VS] Clone failed — manual fallback");
				_inputField = CreateInputFieldManual(_container.transform, layer);
			}
			if ((Object)(object)_inputField != (Object)null)
			{
				Log.LogInfo((object)"[VS] InputField ready.");
			}
			else
			{
				Log.LogError((object)"[VS] Failed to create InputField!");
			}
			AdjustScrollArea();
			Log.LogInfo((object)"[VS] UI created.");
		}

		private TMP_InputField TryCloneInputField(Transform parent, int layer)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			TMP_InputField val = null;
			bool flag = default(bool);
			try
			{
				UIAbilitiesController instance = UIBehaviourSingleton<UIAbilitiesController>.Instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.SearchBar != (Object)null)
				{
					val = instance.SearchBar;
					Log.LogInfo((object)"[VS] Source: UIAbilitiesController.SearchBar");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] UIAbilitiesController: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
			}
			if ((Object)(object)val == (Object)null)
			{
				try
				{
					Il2CppArrayBase<TMP_InputField> val3 = Resources.FindObjectsOfTypeAll<TMP_InputField>();
					if (val3 != null && val3.Length > 0)
					{
						val = val3[0];
						ManualLogSource log2 = Log;
						BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(41, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[VS] Source: Resources (");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(val3.Length);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" found, using '");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val).name);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("')");
						}
						log2.LogInfo(val4);
					}
				}
				catch (Exception ex2)
				{
					ManualLogSource log3 = Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(14, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] FindAll: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
					}
					log3.LogWarning(val2);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			try
			{
				GameObject val5 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent);
				((Object)val5).name = "SearchInput_Clone";
				val5.layer = layer;
				val5.SetActive(true);
				RectTransform component = val5.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.one;
					component.offsetMin = new Vector2(6f, 2f);
					component.offsetMax = new Vector2(-6f, -2f);
				}
				SetLayerRecursive(val5.transform, layer);
				TMP_InputField component2 = val5.GetComponent<TMP_InputField>();
				if ((Object)(object)component2 != (Object)null)
				{
					((UnityEventBase)component2.onValueChanged).RemoveAllListeners();
					component2.text = "";
					component2.characterLimit = 50;
					Graphic placeholder = component2.placeholder;
					if ((Object)(object)placeholder != (Object)null)
					{
						TextMeshProUGUI component3 = ((Component)placeholder).GetComponent<TextMeshProUGUI>();
						if ((Object)(object)component3 != (Object)null)
						{
							((TMP_Text)component3).text = "Search...";
						}
						else
						{
							Text component4 = ((Component)placeholder).GetComponent<Text>();
							if ((Object)(object)component4 != (Object)null)
							{
								component4.text = "Search...";
							}
						}
					}
					Log.LogInfo((object)"[VS] Cloned OK");
					WireClearButtons(val5.transform, component2);
					return component2;
				}
				Object.Destroy((Object)(object)val5);
			}
			catch (Exception ex3)
			{
				ManualLogSource log4 = Log;
				BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[VS] Clone error: ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex3);
				}
				log4.LogError(val6);
			}
			return null;
		}

		private TMP_InputField CreateInputFieldManual(Transform parent, int layer)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00b9: 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)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			try
			{
				GameObject val = MakeUI("SearchInput_Manual", parent, layer);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = new Vector2(6f, 2f);
				component.offsetMax = new Vector2(-6f, -2f);
				Image val2 = val.AddComponent<Image>();
				((Graphic)val2).color = new Color(0.08f, 0.08f, 0.08f, 0.95f);
				((Graphic)val2).raycastTarget = true;
				GameObject val3 = MakeUI("Text Area", val.transform, layer);
				RectTransform component2 = val3.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = new Vector2(6f, 0f);
				component2.offsetMax = new Vector2(-6f, 0f);
				val3.AddComponent<RectMask2D>();
				GameObject obj = MakeUI("Placeholder", val3.transform, layer);
				Stretch(obj.GetComponent<RectTransform>());
				TextMeshProUGUI val4 = obj.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val4).text = "Search / Поиск...";
				((TMP_Text)val4).fontSize = 14f;
				((TMP_Text)val4).fontStyle = (FontStyles)2;
				((Graphic)val4).color = new Color(0.5f, 0.5f, 0.5f, 0.7f);
				((TMP_Text)val4).alignment = (TextAlignmentOptions)4097;
				((Graphic)val4).raycastTarget = false;
				GameObject obj2 = MakeUI("Text", val3.transform, layer);
				Stretch(obj2.GetComponent<RectTransform>());
				TextMeshProUGUI val5 = obj2.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val5).fontSize = 14f;
				((Graphic)val5).color = Color.white;
				((TMP_Text)val5).alignment = (TextAlignmentOptions)4097;
				((Graphic)val5).raycastTarget = false;
				TMP_InputField obj3 = val.AddComponent<TMP_InputField>();
				obj3.textViewport = component2;
				obj3.textComponent = (TMP_Text)(object)val5;
				obj3.placeholder = (Graphic)(object)val4;
				obj3.fontAsset = ((TMP_Text)val5).font;
				obj3.pointSize = 14f;
				obj3.characterLimit = 50;
				((Selectable)obj3).image = val2;
				Log.LogInfo((object)"[VS] Manual InputField created");
				return obj3;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[VS] Manual creation failed: ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
				}
				log.LogError(val6);
				return null;
			}
		}

		private static GameObject MakeUI(string name, Transform parent, int layer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.layer = layer;
			val.transform.SetParent(parent, false);
			if ((Object)(object)val.GetComponent<RectTransform>() == (Object)null)
			{
				val.AddComponent<RectTransform>();
			}
			if ((Object)(object)val.GetComponent<CanvasRenderer>() == (Object)null)
			{
				val.AddComponent<CanvasRenderer>();
			}
			return val;
		}

		private static void Stretch(RectTransform rt)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.offsetMin = Vector2.zero;
			rt.offsetMax = Vector2.zero;
		}

		private static void SetLayerRecursive(Transform t, int layer)
		{
			((Component)t).gameObject.layer = layer;
			for (int i = 0; i < t.childCount; i++)
			{
				SetLayerRecursive(t.GetChild(i), layer);
			}
		}

		private void WireClearButtons(Transform root, TMP_InputField field)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			bool flag = default(bool);
			for (int i = 0; i < root.childCount; i++)
			{
				Transform child = root.GetChild(i);
				Button component = ((Component)child).GetComponent<Button>();
				if ((Object)(object)component != (Object)null)
				{
					((UnityEventBase)component.onClick).RemoveAllListeners();
					TMP_InputField f = field;
					((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
					{
						f.text = "";
						Log.LogInfo((object)"[VS] Clear button clicked");
					}));
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] Rewired button '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)child).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					}
					log.LogInfo(val);
				}
				WireClearButtons(child, field);
			}
		}

		private void AdjustScrollArea()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00f4: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_vendor == (Object)null || _layoutAdjusted)
			{
				return;
			}
			ScrollRect inventoryScrollRect = _vendor.InventoryScrollRect;
			bool flag = default(bool);
			if ((Object)(object)inventoryScrollRect != (Object)null)
			{
				Transform transform = ((Component)inventoryScrollRect).transform;
				RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if ((Object)(object)val != (Object)null)
				{
					val.offsetMax = new Vector2(val.offsetMax.x, val.offsetMax.y - 34f);
					_layoutAdjusted = true;
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] ScrollRect shifted: offsetMax=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(val.offsetMax);
					}
					log.LogInfo(val2);
					return;
				}
			}
			RectTransform vendorInventoryArea = _vendor.VendorInventoryArea;
			if ((Object)(object)vendorInventoryArea != (Object)null)
			{
				vendorInventoryArea.offsetMax = new Vector2(vendorInventoryArea.offsetMax.x, vendorInventoryArea.offsetMax.y - 34f);
				_layoutAdjusted = true;
				ManualLogSource log2 = Log;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[VS] InvArea shifted: offsetMax=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector2>(vendorInventoryArea.offsetMax);
				}
				log2.LogInfo(val2);
			}
		}

		private void OnSearchChanged(string text)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			_currentFilter = text?.Trim() ?? "";
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[VS] OnSearchChanged: filter='");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_currentFilter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
			}
			log.LogInfo(val);
			ApplyFilter();
		}
	}
}