Decompiled source of SeedExplorer v1.0.3

MTSeedExplorer.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MTSeedExplorer.Automation;
using MTSeedExplorer.Core;
using MTSeedExplorer.HarmonyPatches;
using MTSeedExplorer.UI;
using Microsoft.CodeAnalysis;
using ShinyShoe;
using ShinyShoe.Loading;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MTSeedExplorer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+56e1e43aaaeb42c2b865014c71a1a53b084d054c")]
[assembly: AssemblyProduct("MTSeedExplorer")]
[assembly: AssemblyTitle("MTSeedExplorer")]
[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;
		}
	}
}
public static class CellAlignment
{
	private static void Align(GameObject cell, TextAnchor anchor)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		HorizontalLayoutGroup component = cell.GetComponent<HorizontalLayoutGroup>();
		if ((Object)(object)component != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)component);
		}
		VerticalLayoutGroup component2 = cell.GetComponent<VerticalLayoutGroup>();
		if ((Object)(object)component2 != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)component2);
		}
		GridLayoutGroup component3 = cell.GetComponent<GridLayoutGroup>();
		if ((Object)(object)component3 != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)component3);
		}
		HorizontalLayoutGroup val = cell.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val).childControlWidth = false;
		((HorizontalOrVerticalLayoutGroup)val).childControlHeight = false;
		((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false;
		((HorizontalOrVerticalLayoutGroup)val).spacing = 0f;
		((LayoutGroup)val).padding = new RectOffset(0, 0, 0, 0);
		((LayoutGroup)val).childAlignment = anchor;
	}

	public static void AlignTopLeft(GameObject cell)
	{
		Align(cell, (TextAnchor)0);
	}

	public static void AlignTopCenter(GameObject cell)
	{
		Align(cell, (TextAnchor)1);
	}

	public static void AlignTopRight(GameObject cell)
	{
		Align(cell, (TextAnchor)2);
	}

	public static void AlignMiddleLeft(GameObject cell)
	{
		Align(cell, (TextAnchor)3);
	}

	public static void AlignMiddleCenter(GameObject cell)
	{
		Align(cell, (TextAnchor)4);
	}

	public static void AlignMiddleRight(GameObject cell)
	{
		Align(cell, (TextAnchor)5);
	}

	public static void AlignBottomLeft(GameObject cell)
	{
		Align(cell, (TextAnchor)6);
	}

	public static void AlignBottomCenter(GameObject cell)
	{
		Align(cell, (TextAnchor)7);
	}

	public static void AlignBottomRight(GameObject cell)
	{
		Align(cell, (TextAnchor)8);
	}
}
namespace MTSeedExplorer
{
	[HarmonyPatch(typeof(RelicManager))]
	public static class RelicManagerPatches
	{
	}
	[BepInPlugin("MTSeedExplorer_628343be-325d-44b9-9d11-13f7934974ab", "MTSeedExplorer", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal sealed class PreloadDriver : MonoBehaviour
		{
			private void Update()
			{
				DriveSeedPreload();
				AutomationBridge.DrainActiveMainThreadQueue();
			}
		}

		internal static ManualLogSource Logger;

		private static AutomationBridge automationBridge;

		private static RunSetupScreen activeRunSetupScreen;

		private static string lastObservedSignature;

		private static int signatureStableFrames;

		private const int signatureStableFrameThreshold = 1;

		private const int seedsPerUpdate = 4;

		internal static bool IsRunSetupScreenActive => (Object)(object)activeRunSetupScreen != (Object)null && (Object)(object)((Component)activeRunSetupScreen).gameObject != (Object)null && ((Component)activeRunSetupScreen).gameObject.activeInHierarchy;

		internal static void Log(string message)
		{
			Logger.LogInfo((object)message);
		}

		internal static void LogError(string message)
		{
			Logger.LogError((object)message);
		}

		internal static void NotifyRunSetupScreenActive(RunSetupScreen screen)
		{
			activeRunSetupScreen = screen;
			lastObservedSignature = null;
			signatureStableFrames = 0;
			if ((Object)(object)screen != (Object)null && (Object)(object)((Component)screen).GetComponent<PreloadDriver>() == (Object)null)
			{
				((Component)screen).gameObject.AddComponent<PreloadDriver>();
				Log("PreloadDriver attached to RunSetupScreen; preload poller armed.");
			}
			else
			{
				Log("RunSetupScreen activated; preload poller already armed.");
			}
		}

		private void Awake()
		{
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "MTSeedExplorer_628343be-325d-44b9-9d11-13f7934974ab");
			Settings.Init(((BaseUnityPlugin)this).Config);
			if (automationBridge == null)
			{
				automationBridge = AutomationBridge.TryStart();
			}
		}

		private void Update()
		{
			automationBridge?.DrainMainThreadQueue();
			DriveSeedPreload();
		}

		private static void DriveSeedPreload()
		{
			if ((Object)(object)activeRunSetupScreen == (Object)null || (Object)(object)((Component)activeRunSetupScreen).gameObject == (Object)null || !((Component)activeRunSetupScreen).gameObject.activeInHierarchy)
			{
				return;
			}
			RunSetupContext runSetupContext = RunSetupContext.TryCapture(activeRunSetupScreen);
			if (runSetupContext == null)
			{
				return;
			}
			if (runSetupContext.Signature != lastObservedSignature)
			{
				lastObservedSignature = runSetupContext.Signature;
				signatureStableFrames = 0;
				return;
			}
			if (signatureStableFrames < 1)
			{
				signatureStableFrames++;
				if (signatureStableFrames < 1)
				{
					return;
				}
			}
			SeedExplorer orCreateInstance = SeedExplorer.GetOrCreateInstance(runSetupContext.Signature);
			if (orCreateInstance.PreloadContext == null || orCreateInstance.PreloadContext.Signature != runSetupContext.Signature)
			{
				Log("Beginning preload for context signature: " + runSetupContext.Signature);
				orCreateInstance.BeginPreload(runSetupContext, Math.Max(1, Settings.InitialSeedCount.Value));
			}
			for (int i = 0; i < 4; i++)
			{
				SeedExplorer.PreloadStatus status = orCreateInstance.Status;
				orCreateInstance.Tick();
				if (status != orCreateInstance.Status)
				{
					Log($"Preload status: {status} -> {orCreateInstance.Status} (results: {orCreateInstance.SeedResults.Count}/{orCreateInstance.TargetSeedCount})");
				}
				if (orCreateInstance.Status != SeedExplorer.PreloadStatus.Generating && orCreateInstance.Status != SeedExplorer.PreloadStatus.Populating)
				{
					break;
				}
			}
		}

		private void OnDestroy()
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)"MTSeedExplorer plugin object destroyed.");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MTSeedExplorer_628343be-325d-44b9-9d11-13f7934974ab";

		public const string PLUGIN_NAME = "MTSeedExplorer";

		public const string PLUGIN_VERSION = "1.0.2";
	}
	public static class Settings
	{
		public static ConfigEntry<int> SearchTimeoutSeconds;

		public static ConfigEntry<int> InitialSeedCount;

		public static ConfigEntry<bool> EnableDebugLogging;

		public static ConfigEntry<bool> EnableAutomationBridge;

		public static ConfigEntry<int> AutomationBridgePort;

		public static ConfigEntry<string> AutomationArtifactDirectory;

		public static void Init(ConfigFile config)
		{
			SearchTimeoutSeconds = config.Bind<int>("General", "SearchTimeoutSeconds", 60, "How long to search for a seed when given a filter.");
			InitialSeedCount = config.Bind<int>("General", "InitialSeedCount", 13, "How many seeds to display when first opening the mod.");
			EnableDebugLogging = config.Bind<bool>("General", "EnableDebugLogging", false, "Write debug logs to the console.");
			EnableAutomationBridge = config.Bind<bool>("Automation", "EnableAutomationBridge", false, "Enable the localhost-only debug automation bridge for UI smoke tests.");
			AutomationBridgePort = config.Bind<int>("Automation", "AutomationBridgePort", 59221, "Local TCP port used by the debug automation bridge.");
			AutomationArtifactDirectory = config.Bind<string>("Automation", "AutomationArtifactDirectory", "", "Directory where automation bridge screenshots should be written. Empty uses the current working directory.");
		}
	}
}
namespace MTSeedExplorer.UI
{
	internal sealed class ScrollEventForwarder : MonoBehaviour, IScrollHandler, IEventSystemHandler
	{
		public void OnScroll(PointerEventData eventData)
		{
			Transform parent = ((Component)this).transform.parent;
			if (!((Object)(object)parent == (Object)null))
			{
				ExecuteEvents.ExecuteHierarchy<IScrollHandler>(((Component)parent).gameObject, (BaseEventData)(object)eventData, ExecuteEvents.scrollHandler);
			}
		}
	}
	internal static class SeedExplorerCardPreviewPrefabs
	{
		internal enum RelicPreviewRole
		{
			Artifact,
			Enhancer,
			Any
		}

		private static CardUI cachedCardPrefab;

		private static string cachedCardSource;

		private static readonly Dictionary<string, RelicInfoUI> cachedRelicPrefabs = new Dictionary<string, RelicInfoUI>();

		private static readonly Dictionary<string, string> cachedRelicSources = new Dictionary<string, string>();

		private static bool artifactBackgroundPreloadStarted;

		private static bool artifactBackgroundPreloadCompleted;

		private static readonly List<string> attemptLog = new List<string>();

		internal static IReadOnlyList<string> AttemptLog => attemptLog;

		internal static bool IsArtifactBackgroundPreloadStarted => artifactBackgroundPreloadStarted;

		internal static bool IsArtifactBackgroundPreloadCompleted => artifactBackgroundPreloadCompleted;

		internal static bool IsArtifactBackgroundPreloadInProgress => artifactBackgroundPreloadStarted && !artifactBackgroundPreloadCompleted;

		internal static bool TryGetCardPrefab(out CardUI prefab, out string source)
		{
			if ((Object)(object)cachedCardPrefab != (Object)null)
			{
				prefab = cachedCardPrefab;
				source = cachedCardSource ?? "";
				return true;
			}
			CardUI val = Object.FindObjectOfType<CardUI>(true);
			attemptLog.Add("FindObjectOfType<CardUI>: " + (((Object)(object)val != (Object)null) ? "found" : "null"));
			if ((Object)(object)val != (Object)null)
			{
				cachedCardPrefab = val;
				cachedCardSource = "FindObjectOfType<CardUI>";
				prefab = val;
				source = cachedCardSource;
				return true;
			}
			RewardDetailsUI val2 = Object.FindObjectOfType<RewardDetailsUI>(true);
			attemptLog.Add("FindObjectOfType<RewardDetailsUI>: " + (((Object)(object)val2 != (Object)null) ? "found" : "null"));
			if ((Object)(object)val2 != (Object)null)
			{
				CardUI val3 = ReflectField<CardUI>((object)val2, "cardUI");
				attemptLog.Add("RewardDetailsUI.cardUI: " + (((Object)(object)val3 != (Object)null) ? "found" : "null"));
				if ((Object)(object)val3 != (Object)null)
				{
					cachedCardPrefab = val3;
					cachedCardSource = "RewardDetailsUI.cardUI";
					prefab = val3;
					source = cachedCardSource;
					return true;
				}
			}
			CompendiumSectionCards val4 = Object.FindObjectOfType<CompendiumSectionCards>(true);
			attemptLog.Add("FindObjectOfType<CompendiumSectionCards>: " + (((Object)(object)val4 != (Object)null) ? "found" : "null"));
			if ((Object)(object)val4 != (Object)null)
			{
				CardUI val5 = ReflectField<CardUI>((object)val4, "cardPrefab");
				attemptLog.Add("CompendiumSectionCards.cardPrefab: " + (((Object)(object)val5 != (Object)null) ? "found" : "null"));
				if ((Object)(object)val5 != (Object)null)
				{
					cachedCardPrefab = val5;
					cachedCardSource = "CompendiumSectionCards.cardPrefab";
					prefab = val5;
					source = cachedCardSource;
					return true;
				}
			}
			CardUI[] array = Resources.FindObjectsOfTypeAll<CardUI>();
			attemptLog.Add("Resources.FindObjectsOfTypeAll<CardUI>: count=" + array.Length);
			CardUI[] array2 = array;
			foreach (CardUI val6 in array2)
			{
				if (!((Object)(object)val6 == (Object)null))
				{
					cachedCardPrefab = val6;
					cachedCardSource = "Resources.FindObjectsOfTypeAll<CardUI>";
					prefab = val6;
					source = cachedCardSource;
					return true;
				}
			}
			prefab = null;
			source = "";
			return false;
		}

		internal static bool TryGetRelicPrefab(out RelicInfoUI prefab, out string source)
		{
			return TryGetRelicPrefab(RelicPreviewRole.Any, out prefab, out source);
		}

		internal static bool TryGetRelicPrefab(RelicPreviewRole role, out RelicInfoUI prefab, out string source)
		{
			string key = role.ToString();
			if (cachedRelicPrefabs.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				prefab = value;
				source = (cachedRelicSources.TryGetValue(key, out var value2) ? value2 : "");
				return true;
			}
			if (role == RelicPreviewRole.Artifact && TryGetRelicDraftPrefab(out var prefab2, out var source2))
			{
				return CacheRelicPrefab(role, prefab2, source2, out prefab, out source);
			}
			RewardDetailsUI val = Object.FindObjectOfType<RewardDetailsUI>(true);
			attemptLog.Add("FindObjectOfType<RewardDetailsUI> for RelicInfoUI: " + (((Object)(object)val != (Object)null) ? "found" : "null"));
			if ((Object)(object)val != (Object)null)
			{
				string[] relicFieldPreference = GetRelicFieldPreference(role);
				foreach (string text in relicFieldPreference)
				{
					RelicInfoUI val2 = ReflectField<RelicInfoUI>((object)val, text);
					attemptLog.Add("RewardDetailsUI." + text + ": " + (((Object)(object)val2 != (Object)null) ? "found" : "null"));
					if ((Object)(object)val2 != (Object)null)
					{
						return CacheRelicPrefab(role, val2, "RewardDetailsUI." + text, out prefab, out source);
					}
				}
			}
			RelicInfoUI val3 = Object.FindObjectOfType<RelicInfoUI>(true);
			attemptLog.Add("FindObjectOfType<RelicInfoUI>: " + (((Object)(object)val3 != (Object)null) ? "found" : "null"));
			if ((Object)(object)val3 != (Object)null)
			{
				return CacheRelicPrefab(role, val3, "FindObjectOfType<RelicInfoUI>", out prefab, out source);
			}
			RelicInfoUI[] array = Resources.FindObjectsOfTypeAll<RelicInfoUI>();
			attemptLog.Add("Resources.FindObjectsOfTypeAll<RelicInfoUI>: count=" + array.Length);
			RelicInfoUI[] array2 = array;
			foreach (RelicInfoUI val4 in array2)
			{
				if (!((Object)(object)val4 == (Object)null))
				{
					return CacheRelicPrefab(role, val4, "Resources.FindObjectsOfTypeAll<RelicInfoUI>", out prefab, out source);
				}
			}
			prefab = null;
			source = "";
			return false;
		}

		private static bool TryGetRelicDraftPrefab(out RelicInfoUI prefab, out string source)
		{
			RelicDraftScreen[] array = Resources.FindObjectsOfTypeAll<RelicDraftScreen>();
			attemptLog.Add("Resources.FindObjectsOfTypeAll<RelicDraftScreen>: count=" + array.Length);
			RelicDraftScreen[] array2 = array;
			foreach (RelicDraftScreen val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				LayoutGroupReplacementElement val2 = ReflectField<LayoutGroupReplacementElement>((object)val, "itemLayout");
				attemptLog.Add("RelicDraftScreen.itemLayout: " + (((Object)(object)val2 != (Object)null) ? "found" : "null"));
				if (!((Object)(object)val2 == (Object)null))
				{
					RelicInfoUI componentInChildren = ((Component)val2).GetComponentInChildren<RelicInfoUI>(true);
					attemptLog.Add("RelicDraftScreen.itemLayout RelicInfoUI: " + (((Object)(object)componentInChildren != (Object)null) ? "found" : "null"));
					if ((Object)(object)componentInChildren != (Object)null)
					{
						prefab = componentInChildren;
						source = "RelicDraftScreen.itemLayout RelicInfoUI";
						return true;
					}
				}
			}
			prefab = null;
			source = "";
			return false;
		}

		internal static bool TryGetCardDraftBgItemPrefab(out CardDraftBgItem prefab, out string source)
		{
			CardDraftBgItem val = Object.FindObjectOfType<CardDraftBgItem>(true);
			attemptLog.Add("FindObjectOfType<CardDraftBgItem>: " + (((Object)(object)val != (Object)null) ? "found" : "null"));
			if ((Object)(object)val != (Object)null)
			{
				prefab = val;
				source = "FindObjectOfType<CardDraftBgItem>";
				return true;
			}
			CardDraftBgItem[] array = Resources.FindObjectsOfTypeAll<CardDraftBgItem>();
			attemptLog.Add("Resources.FindObjectsOfTypeAll<CardDraftBgItem>: count=" + array.Length);
			CardDraftBgItem[] array2 = array;
			foreach (CardDraftBgItem val2 in array2)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					prefab = val2;
					source = "Resources.FindObjectsOfTypeAll<CardDraftBgItem>";
					return true;
				}
			}
			prefab = null;
			source = "";
			return false;
		}

		internal static void PreloadArtifactBackgroundTemplates()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			if (artifactBackgroundPreloadCompleted || artifactBackgroundPreloadStarted)
			{
				return;
			}
			if (Resources.FindObjectsOfTypeAll<CardDraftBgItem>().Length != 0)
			{
				artifactBackgroundPreloadStarted = true;
				artifactBackgroundPreloadCompleted = true;
				return;
			}
			try
			{
				artifactBackgroundPreloadStarted = true;
				LoadingScreen.AddTask((LoadingTask)new PreloadAdditiveScreen((ScreenName)4, (Action)delegate
				{
					artifactBackgroundPreloadCompleted = true;
				}), true);
			}
			catch (Exception ex)
			{
				attemptLog.Add("PreloadAdditiveScreen(RelicChoice) failed: " + ex.Message);
				Plugin.LogError("Artifact background template preload failed: " + ex);
				artifactBackgroundPreloadCompleted = true;
			}
		}

		private static string[] GetRelicFieldPreference(RelicPreviewRole role)
		{
			return role switch
			{
				RelicPreviewRole.Enhancer => new string[4] { "upgradeUI", "relicUI", "sinRelicUI", "mutatorUI" }, 
				RelicPreviewRole.Artifact => new string[4] { "relicUI", "upgradeUI", "sinRelicUI", "mutatorUI" }, 
				_ => new string[4] { "relicUI", "upgradeUI", "sinRelicUI", "mutatorUI" }, 
			};
		}

		private static bool CacheRelicPrefab(RelicPreviewRole role, RelicInfoUI value, string valueSource, out RelicInfoUI prefab, out string source)
		{
			string key = role.ToString();
			cachedRelicPrefabs[key] = value;
			cachedRelicSources[key] = valueSource;
			prefab = value;
			source = valueSource;
			return true;
		}

		private static T ReflectField<T>(object target, string fieldName) where T : Object
		{
			if (target == null)
			{
				return default(T);
			}
			try
			{
				FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field == null)
				{
					return default(T);
				}
				object value = field.GetValue(target);
				return (T)((value is T) ? value : null);
			}
			catch (Exception ex)
			{
				attemptLog.Add("Reflection failed on " + fieldName + ": " + ex.Message);
				return default(T);
			}
		}
	}
	public class SeedExplorerDialog : MonoBehaviour
	{
		internal sealed class DropdownAutomationState
		{
			internal string Id { get; }

			internal bool Present { get; }

			internal bool Expanded { get; }

			internal int OptionCount { get; }

			internal int SelectedIndex { get; }

			internal string SelectedValue { get; }

			internal List<string> Options { get; }

			internal DropdownAutomationState(string id, bool present, bool expanded, int optionCount, int selectedIndex, string selectedValue, List<string> options)
			{
				Id = id;
				Present = present;
				Expanded = expanded;
				OptionCount = optionCount;
				SelectedIndex = selectedIndex;
				SelectedValue = selectedValue;
				Options = options;
			}
		}

		internal sealed class ResultRowAutomationState
		{
			internal int Index { get; }

			internal SeedExplorer.SeedResult Result { get; }

			internal ResultRowAutomationState(int index, SeedExplorer.SeedResult result)
			{
				Index = index;
				Result = result;
			}
		}

		internal sealed class ScrollAutomationState
		{
			internal float VerticalNormalizedPosition;

			internal int RowCount;

			internal float ContentHeight;

			internal float ViewportHeight;

			internal float ScrollableHeight;
		}

		internal sealed class ResultCellClickAutomationState
		{
			internal int RowIndex;

			internal string Column;

			internal string TargetObjectName;

			internal string HandlerObjectName;

			internal bool DialogOpen;

			internal int? ChosenSeed;
		}

		private GameUISelectableDropdown Card1Dropdown;

		private GameUISelectableDropdown Card2Dropdown;

		private GameUISelectableDropdown Card3Dropdown;

		private GameUISelectableDropdown ArtifactDropdown;

		private GameUISelectableDropdown UpgradeDropdown;

		private Transform dropdownRow;

		private RectTransform contentRT;

		private SeedExplorer seedExplorer;

		private ScreenDialog dialog;

		internal ScrollRect scrollRect;

		private TextMeshProUGUI title;

		private TextMeshProUGUI warning;

		private TextMeshProUGUI dialogChosenSeedLabel;

		private SeedExplorerHoverPreview hoverPreview;

		private bool isInitialized = false;

		private bool _userOpened;

		private long lastRenderedPreloadVersion = -1L;

		private bool dropdownsBuilt;

		private readonly Dictionary<string, GameUISelectableDropdown> automationDropdowns = new Dictionary<string, GameUISelectableDropdown>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<string, List<string>> automationDropdownOptions = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<string, int> automationDropdownSelectedIndexes = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<(int row, string columnId), (string text, SeedExplorerHoverPreview.PreviewKind kind)> resultCellHoverRegistry = new Dictionary<(int, string), (string, SeedExplorerHoverPreview.PreviewKind)>();

		private readonly Dictionary<(int row, string columnId), GameObject> resultCellLabelObjects = new Dictionary<(int, string), GameObject>();

		public static SeedExplorerDialog Instantiate(RunSetupScreen runSetupScreen)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			MutatorSelectionDialog val = (MutatorSelectionDialog)AccessTools.Field(typeof(RunSetupScreen), "mutatorSelectionDialog").GetValue(runSetupScreen);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent.parent);
			Object.DestroyImmediate((Object)(object)val2.GetComponent<MutatorSelectionDialog>());
			SeedExplorerDialog seedExplorerDialog = val2.AddComponent<SeedExplorerDialog>();
			seedExplorerDialog.dialog = val2.GetComponentInChildren<ScreenDialog>(true);
			((ScreenTransition)seedExplorerDialog.dialog).SetActive(false, val2, (Action)null, (Action)null);
			return seedExplorerDialog;
		}

		private void Awake()
		{
			Init();
		}

		private void OnEnable()
		{
		}

		private void OnDisable()
		{
			Close();
		}

		private void Update()
		{
			if (!((Object)(object)dialog == (Object)null) && ((Component)dialog).gameObject.activeInHierarchy && seedExplorer != null && seedExplorer.PreloadVersion != lastRenderedPreloadVersion)
			{
				lastRenderedPreloadVersion = seedExplorer.PreloadVersion;
				if (!dropdownsBuilt && seedExplorer.PrimaryCardPool.Count > 0)
				{
					RelabelDropdowns();
					dropdownsBuilt = true;
				}
				BuildResultsTable();
			}
		}

		public void Open(string key = "")
		{
			DoOpen(key);
		}

		private void DoOpen(string key)
		{
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			seedExplorer = SeedExplorer.GetOrCreateInstance(key);
			if (seedExplorer.PrimaryCardPool.Count == 0 || seedExplorer.SeedResults.Count == 0)
			{
				Plugin.Log($"Choose Seed clicked while preload status={seedExplorer.Status} pools={seedExplorer.PrimaryCardPool.Count} seeds={seedExplorer.SeedResults.Count}; finishing on main thread.");
				if (seedExplorer.PreloadContext == null)
				{
					seedExplorer.ExploreSeeds();
				}
				else
				{
					while ((seedExplorer.PrimaryCardPool.Count == 0 || seedExplorer.SeedResults.Count == 0) && seedExplorer.Status != SeedExplorer.PreloadStatus.Faulted)
					{
						seedExplorer.Tick();
					}
				}
			}
			((ScreenTransition)dialog).SetActive(true, ((Component)this).gameObject, (Action)null, (Action)null);
			dropdownsBuilt = false;
			lastRenderedPreloadVersion = -1L;
			UpdateDialogChosenSeedLabel();
			BuildResultsTable();
			RelabelDropdowns();
			dropdownsBuilt = true;
			lastRenderedPreloadVersion = seedExplorer.PreloadVersion;
			LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)dropdownRow).GetComponent<RectTransform>());
			GameUISelectableDropdown[] array = (GameUISelectableDropdown[])(object)new GameUISelectableDropdown[5] { Card1Dropdown, Card2Dropdown, Card3Dropdown, ArtifactDropdown, UpgradeDropdown };
			GameUISelectableDropdown[] array2 = array;
			foreach (GameUISelectableDropdown val in array2)
			{
				Transform obj = ((Component)val).transform.Find("Value");
				RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.anchorMin = new Vector2(0f, 0f);
					val2.anchorMax = new Vector2(1f, 1f);
					val2.offsetMin = new Vector2(4f, val2.offsetMin.y);
					val2.offsetMax = new Vector2(-4f, val2.offsetMax.y);
				}
			}
			if ((Object)(object)scrollRect != (Object)null)
			{
				scrollRect.verticalNormalizedPosition = 1f;
				LayoutRebuilder.ForceRebuildLayoutImmediate(scrollRect.content);
			}
		}

		private static void MakeDropdownScrollable(GameUISelectableDropdown dd, float maxHeightPx)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			object? obj = typeof(GameUISelectableDropdown).GetField("dropdownList", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(dd);
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = val.GetComponent<RectTransform>();
				Transform parent = val.transform.parent;
				Rect rect = component.rect;
				float num = Mathf.Min(((Rect)(ref rect)).height, maxHeightPx);
				GameObject val2 = new GameObject("DropdownViewport", new Type[4]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Mask),
					typeof(ScrollRect)
				});
				val2.transform.SetParent(parent, false);
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = component.anchorMin;
				component2.anchorMax = component.anchorMax;
				component2.pivot = component.pivot;
				component2.anchoredPosition = component.anchoredPosition;
				component2.sizeDelta = new Vector2(component.sizeDelta.x, num);
				Image component3 = val2.GetComponent<Image>();
				((Graphic)component3).color = new Color(1f, 1f, 1f, 0f);
				Mask component4 = val2.GetComponent<Mask>();
				component4.showMaskGraphic = false;
				val.transform.SetParent(val2.transform, false);
				RectTransform component5 = val.GetComponent<RectTransform>();
				component5.anchorMin = new Vector2(0f, 1f);
				component5.anchorMax = new Vector2(1f, 1f);
				component5.pivot = new Vector2(0.5f, 1f);
				component5.anchoredPosition = Vector2.zero;
				ScrollRect component6 = val2.GetComponent<ScrollRect>();
				component6.content = component5;
				component6.viewport = component2;
				component6.horizontal = false;
				component6.vertical = true;
				component6.scrollSensitivity = 20f;
				ScrollRect componentInChildren = ((Component)((Component)dd).transform.root).GetComponentInChildren<ScrollRect>(true);
				if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.verticalScrollbar != (Object)null)
				{
					GameObject val3 = Object.Instantiate<GameObject>(((Component)componentInChildren.verticalScrollbar).gameObject, val2.transform, false);
					Scrollbar component7 = val3.GetComponent<Scrollbar>();
					component6.verticalScrollbar = component7;
					component6.verticalScrollbarVisibility = (ScrollbarVisibility)1;
				}
				val2.transform.SetSiblingIndex(parent.childCount - 1);
				LayoutRebuilder.ForceRebuildLayoutImmediate(component2);
			}
		}

		private void Init()
		{
			if (!isInitialized)
			{
				isInitialized = true;
				scrollRect = ((Component)dialog).GetComponentInChildren<ScrollRect>(true);
				((Component)scrollRect).transform.SetParent((Transform)null, false);
				SetupDialogHeader();
				SetupDialogBody();
				RectTransform component = ((Component)((Component)dialog).transform.Find("Content")).GetComponent<RectTransform>();
				if (hoverPreview == null)
				{
					hoverPreview = new SeedExplorerHoverPreview(((Component)dialog).transform);
				}
				SeedExplorerHoverPreview.PreloadCardArt();
				SeedExplorerCardPreviewPrefabs.PreloadArtifactBackgroundTemplates();
				LayoutRebuilder.ForceRebuildLayoutImmediate(component);
			}
		}

		private void SetupDialogBody()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)dialog).transform.Find("Content");
			GameObject val2 = new GameObject("Body", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val, false);
			LayoutElement val3 = val2.AddComponent<LayoutElement>();
			val3.flexibleHeight = 1f;
			val3.minHeight = 0f;
			((Component)scrollRect).transform.SetParent(val2.transform, false);
			RectTransform component = ((Component)scrollRect).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			scrollRect.vertical = true;
			scrollRect.horizontal = false;
			scrollRect.scrollSensitivity = 30f;
			RectTransform viewport = scrollRect.viewport;
			((Object)((Component)viewport).gameObject).name = SeedExplorerUiAutomationIds.ResultsViewportObjectName;
			if ((Object)(object)((Component)viewport).gameObject.GetComponent<ScrollEventForwarder>() == (Object)null)
			{
				((Component)viewport).gameObject.AddComponent<ScrollEventForwarder>();
			}
			contentRT = ((Component)((Transform)viewport).Find("Mutator layout")).GetComponent<RectTransform>();
			scrollRect.content = contentRT;
			contentRT.anchorMin = new Vector2(0f, 1f);
			contentRT.anchorMax = new Vector2(1f, 1f);
			contentRT.pivot = new Vector2(0.5f, 1f);
			contentRT.anchoredPosition = Vector2.zero;
			contentRT.sizeDelta = Vector2.zero;
			LayoutGroup[] components = ((Component)contentRT).GetComponents<LayoutGroup>();
			foreach (LayoutGroup val4 in components)
			{
				Object.DestroyImmediate((Object)(object)val4);
			}
			VerticalLayoutGroup val5 = ((Component)contentRT).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val5).spacing = 1f;
			((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false;
			ContentSizeFitter val6 = ((Component)contentRT).GetComponent<ContentSizeFitter>() ?? ((Component)contentRT).gameObject.AddComponent<ContentSizeFitter>();
			val6.horizontalFit = (FitMode)0;
			val6.verticalFit = (FitMode)2;
			LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)dialog).GetComponentInChildren<ScrollRect>(true).content);
		}

		private void BuildResultsTable()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_0203: 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_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Expected O, but got Unknown
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Expected O, but got Unknown
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Expected O, but got Unknown
			List<Transform> list = new List<Transform>();
			foreach (Transform item2 in (Transform)contentRT)
			{
				Transform item = item2;
				list.Add(item);
			}
			foreach (Transform item3 in list)
			{
				Object.DestroyImmediate((Object)(object)((Component)item3).gameObject);
			}
			resultCellHoverRegistry.Clear();
			resultCellLabelObjects.Clear();
			Color val2 = default(Color);
			for (int i = 0; i < seedExplorer.SeedResultsFiltered.Count; i++)
			{
				SeedExplorer.SeedResult seedResult = seedExplorer.SeedResultsFiltered[i];
				string[] array = new string[3] { seedResult.Card1, seedResult.Card2, seedResult.Card3 };
				GameObject val = new GameObject(SeedExplorerUiAutomationIds.ResultRowObjectName(i), new Type[1] { typeof(RectTransform) });
				val.transform.SetParent((Transform)(object)contentRT, false);
				Image bg = val.AddComponent<Image>();
				bool flag = seedExplorer.SelectedSeedResult != null && seedResult.Seed == seedExplorer.SelectedSeedResult.Seed;
				((Color)(ref val2))..ctor(1f, 0.8f, 0.4f, 0.25f);
				Color hoverColor = new Color(1f, 1f, 1f, 0.2f);
				Color val3 = (flag ? val2 : Color.clear);
				((Graphic)bg).color = val3;
				val.AddComponent<ScrollEventForwarder>();
				EventTrigger val4 = val.AddComponent<EventTrigger>();
				Color restColorCaptured = val3;
				Entry val5 = new Entry
				{
					eventID = (EventTriggerType)0
				};
				((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)bg).color = hoverColor;
				});
				val4.triggers.Add(val5);
				Entry val6 = new Entry
				{
					eventID = (EventTriggerType)1
				};
				((UnityEvent<BaseEventData>)(object)val6.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)bg).color = restColorCaptured;
				});
				val4.triggers.Add(val6);
				int rowIndex = i;
				Entry val7 = new Entry
				{
					eventID = (EventTriggerType)4
				};
				((UnityEvent<BaseEventData>)(object)val7.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					SelectResultRowForRun(rowIndex);
				});
				val4.triggers.Add(val7);
				ContentSizeFitter val8 = val.AddComponent<ContentSizeFitter>();
				val8.horizontalFit = (FitMode)0;
				val8.verticalFit = (FitMode)2;
				HorizontalLayoutGroup val9 = val.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)val9).spacing = 4f;
				((HorizontalOrVerticalLayoutGroup)val9).childControlWidth = false;
				((HorizontalOrVerticalLayoutGroup)val9).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)val9).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)val9).childForceExpandHeight = false;
				((LayoutGroup)val9).childAlignment = (TextAnchor)4;
				string[] array2 = new string[3] { "primary", "secondary", "unit" };
				SeedExplorerHoverPreview.PreviewKind[] array3 = new SeedExplorerHoverPreview.PreviewKind[3]
				{
					SeedExplorerHoverPreview.PreviewKind.PrimaryCard,
					SeedExplorerHoverPreview.PreviewKind.SecondaryCard,
					SeedExplorerHoverPreview.PreviewKind.UnitCard
				};
				for (int j = 0; j < 3; j++)
				{
					GameObject val10 = new GameObject($"Cell_{j + 1}", new Type[1] { typeof(RectTransform) });
					val10.transform.SetParent(val.transform, false);
					LayoutElement val11 = val10.AddComponent<LayoutElement>();
					val11.flexibleWidth = 1f;
					val11.minWidth = 0f;
					string text = ((j < array.Length) ? array[j] : "");
					TextMeshProUGUI val12 = CreateResultCellLabel(val10.transform, rowIndex, array2[j], text, array3[j]);
					LayoutRebuilder.ForceRebuildLayoutImmediate(((TMP_Text)val12).rectTransform);
					val11.minHeight = 30f;
					val11.preferredHeight = 30f;
				}
				float num = 61f;
				GameObject val13 = new GameObject("ArtifactCell", new Type[1] { typeof(RectTransform) });
				val13.transform.SetParent(val.transform, false);
				LayoutElement val14 = val13.AddComponent<LayoutElement>();
				val14.flexibleWidth = 1f;
				val14.minWidth = 0f;
				val14.minHeight = num;
				val14.preferredHeight = num;
				VerticalLayoutGroup val15 = val13.AddComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)val15).spacing = 1f;
				((HorizontalOrVerticalLayoutGroup)val15).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)val15).childControlHeight = false;
				((HorizontalOrVerticalLayoutGroup)val15).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)val15).childForceExpandHeight = false;
				ContentSizeFitter val16 = val13.AddComponent<ContentSizeFitter>();
				val16.horizontalFit = (FitMode)0;
				val16.verticalFit = (FitMode)2;
				string[] array4 = new string[2] { "artifact1", "artifact2" };
				string[] array5 = new string[2] { seedResult.Artifact1, seedResult.Artifact2 };
				for (int k = 0; k < array5.Length; k++)
				{
					CreateResultCellLabel(val13.transform, rowIndex, array4[k], array5[k], SeedExplorerHoverPreview.PreviewKind.Artifact);
				}
				GameObject val17 = new GameObject("UpgradeCell", new Type[1] { typeof(RectTransform) });
				val17.transform.SetParent(val.transform, false);
				LayoutElement val18 = val17.AddComponent<LayoutElement>();
				val18.flexibleWidth = 1f;
				val18.minWidth = 0f;
				val18.minHeight = num;
				val18.preferredHeight = num;
				VerticalLayoutGroup val19 = val17.AddComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)val19).spacing = 1f;
				((HorizontalOrVerticalLayoutGroup)val19).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)val19).childControlHeight = false;
				((HorizontalOrVerticalLayoutGroup)val19).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)val19).childForceExpandHeight = false;
				ContentSizeFitter val20 = val17.AddComponent<ContentSizeFitter>();
				val20.horizontalFit = (FitMode)0;
				val20.verticalFit = (FitMode)2;
				string[] array6 = new string[2] { "upgrade1", "upgrade2" };
				string[] array7 = new string[2] { seedResult.Upgrade1, seedResult.Upgrade2 };
				for (int l = 0; l < array7.Length; l++)
				{
					CreateResultCellLabel(val17.transform, rowIndex, array6[l], array7[l], SeedExplorerHoverPreview.PreviewKind.ChampionUpgrade);
				}
			}
		}

		private TextMeshProUGUI CreateResultCellLabel(Transform parent, int rowIndex, string columnId, string text, SeedExplorerHoverPreview.PreviewKind kind)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			string text2 = SeedExplorerUiAutomationIds.NormalizeResultColumnId(columnId);
			GameObject val = new GameObject(SeedExplorerUiAutomationIds.ResultCellLabelObjectName(rowIndex, text2), new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = text ?? "";
			((TMP_Text)val2).fontSize = 20f;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((Graphic)val2).raycastTarget = true;
			ContentSizeFitter val3 = val.AddComponent<ContentSizeFitter>();
			val3.horizontalFit = (FitMode)2;
			val3.verticalFit = (FitMode)2;
			resultCellHoverRegistry[(rowIndex, text2)] = (((TMP_Text)val2).text, kind);
			resultCellLabelObjects[(rowIndex, text2)] = val;
			val.AddComponent<ScrollEventForwarder>();
			if (!string.IsNullOrEmpty(((TMP_Text)val2).text))
			{
				EventTrigger val4 = val.AddComponent<EventTrigger>();
				string capturedText = ((TMP_Text)val2).text;
				SeedExplorerHoverPreview.PreviewKind capturedKind = kind;
				int capturedRowIndex = rowIndex;
				Entry val5 = new Entry
				{
					eventID = (EventTriggerType)0
				};
				((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					if (hoverPreview != null)
					{
						hoverPreview.Show(capturedKind, capturedText);
					}
				});
				val4.triggers.Add(val5);
				Entry val6 = new Entry
				{
					eventID = (EventTriggerType)1
				};
				((UnityEvent<BaseEventData>)(object)val6.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					if (hoverPreview != null)
					{
						hoverPreview.Hide();
					}
				});
				val4.triggers.Add(val6);
				Entry val7 = new Entry
				{
					eventID = (EventTriggerType)4
				};
				((UnityEvent<BaseEventData>)(object)val7.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					SelectResultRowForRun(capturedRowIndex);
				});
				val4.triggers.Add(val7);
			}
			return val2;
		}

		private void SetupDialogHeader()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Expected O, but got Unknown
			Transform val = ((Component)dialog).transform.Find("Content");
			Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<HorizontalLayoutGroup>());
			Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<VerticalLayoutGroup>());
			List<Transform> list = new List<Transform>();
			foreach (Transform item2 in val)
			{
				Transform item = item2;
				list.Add(item);
			}
			foreach (Transform item3 in list)
			{
				Object.DestroyImmediate((Object)(object)((Component)item3).gameObject);
			}
			VerticalLayoutGroup val2 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 0f;
			((LayoutGroup)val2).padding = new RectOffset(0, 0, 0, 0);
			((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = Vector2.zero;
			GameObject val3 = new GameObject("Header", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(((Component)val).transform, false);
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(0.5f, 1f);
			component2.anchoredPosition = Vector2.zero;
			component2.sizeDelta = Vector2.zero;
			VerticalLayoutGroup val4 = val3.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val4).spacing = 4f;
			((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
			ContentSizeFitter val5 = val3.AddComponent<ContentSizeFitter>();
			val5.horizontalFit = (FitMode)0;
			val5.verticalFit = (FitMode)2;
			int[] array = new int[3] { 2, 5, 5 };
			List<Transform> list2 = new List<Transform>();
			for (int i = 0; i < 3; i++)
			{
				List<Transform> list3 = new List<Transform>();
				GameObject val6 = new GameObject($"Row{i + 1}", new Type[1] { typeof(RectTransform) });
				val6.transform.SetParent(val3.transform, false);
				ContentSizeFitter val7 = val6.AddComponent<ContentSizeFitter>();
				val7.horizontalFit = (FitMode)0;
				val7.verticalFit = (FitMode)2;
				HorizontalLayoutGroup val8 = val6.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)val8).spacing = 4f;
				((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)val8).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false;
				((LayoutGroup)val8).childAlignment = (TextAnchor)4;
				for (int j = 0; j < array[i]; j++)
				{
					GameObject val9 = new GameObject($"Cell{i + 1}_{j + 1}", new Type[1] { typeof(RectTransform) });
					val9.transform.SetParent(val6.transform, false);
					LayoutElement val10 = val9.AddComponent<LayoutElement>();
					val10.flexibleWidth = 1f;
					val10.minWidth = 0f;
					list3.Add(val9.transform);
				}
				list2.Add(val6.transform);
			}
			SetupInstructionsAndToggle(((IEnumerable)list2[0]).Cast<Transform>().ToList());
			SetupDropdownTitles(((IEnumerable)list2[1]).Cast<Transform>().ToList());
			dropdownRow = list2[2];
			SetupDropdowns(dropdownRow);
			component2 = val3.GetComponent<RectTransform>();
			LayoutRebuilder.ForceRebuildLayoutImmediate(component2);
			LayoutElement val11 = val3.gameObject.AddComponent<LayoutElement>();
			val11.preferredHeight = LayoutUtility.GetPreferredHeight(component2);
			val11.flexibleHeight = 0f;
		}

		private void SetupInstructionsAndToggle(List<Transform> cells)
		{
			LabelCell(cells[0], "Choose starting seed.");
			dialogChosenSeedLabel = LabelCell(cells[1], "", SeedExplorerUiAutomationIds.DialogChosenSeedLabelObjectName);
			UpdateDialogChosenSeedLabel();
		}

		private void UpdateDialogChosenSeedLabel()
		{
			if (!((Object)(object)dialogChosenSeedLabel == (Object)null))
			{
				int? num = seedExplorer?.SelectedSeedResult?.Seed;
				((TMP_Text)dialogChosenSeedLabel).text = (num.HasValue ? ("Currently chosen: " + num.Value.ToString("X8")) : "");
			}
		}

		private void SetupToggle(Transform target)
		{
			SettingsDialog val = Object.FindObjectOfType<SettingsDialog>(true);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("Unable to find SettingsDialog");
			}
			Transform val2 = ((Component)val).transform.Find("Content/Content/Audio Section/Background mute toggle/Background mute toggle input");
			if ((Object)(object)val2 == (Object)null)
			{
				throw new Exception("Unable to find toggle button to copy.");
			}
			GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, target, false);
			((Object)val3).name = ((Object)target).name + " toggle";
			RectTransform component = val3.GetComponent<RectTransform>();
		}

		public void Close()
		{
			if (hoverPreview != null)
			{
				hoverPreview.Hide();
			}
			((ScreenTransition)dialog).SetActive(false, ((Component)this).gameObject, (Action)null, (Action)null);
			SoundManager.PlaySfxSignal.Dispatch("UI_Cancel");
			((Behaviour)this).enabled = false;
			isInitialized = false;
		}

		internal bool ApplyScreenInput(CoreInputControlMapping mapping, IGameUIComponent triggeredUI, Controls triggeredMappingID)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Component)this).gameObject.activeSelf)
			{
				return false;
			}
			if (triggeredUI == null && InputHelper.IsClickInput(triggeredMappingID, mapping))
			{
				Close();
				return true;
			}
			return true;
		}

		internal bool IsOpenForAutomation()
		{
			return (Object)(object)dialog != (Object)null && ((Component)dialog).gameObject.activeInHierarchy;
		}

		internal List<DropdownAutomationState> GetDropdownAutomationStates()
		{
			return SeedExplorerUiAutomationIds.DropdownIds.Select(GetDropdownAutomationState).ToList();
		}

		internal DropdownAutomationState GetDropdownAutomationState(string id)
		{
			id = NormalizeAutomationDropdownId(id);
			GameUISelectableDropdown dropdownForAutomation = GetDropdownForAutomation(id);
			GameObject val = (((Object)(object)dropdownForAutomation != (Object)null) ? GetDropdownList(dropdownForAutomation) : null);
			bool present = (Object)(object)dropdownForAutomation != (Object)null && ((Component)dropdownForAutomation).gameObject.activeInHierarchy;
			bool expanded = (Object)(object)val != (Object)null && val.activeInHierarchy;
			List<string> dropdownOptionsForAutomation = GetDropdownOptionsForAutomation(id);
			int optionCount = ((dropdownOptionsForAutomation.Count > 0) ? dropdownOptionsForAutomation.Count : (((Object)(object)val != (Object)null) ? ((IEnumerable)val.transform).Cast<Transform>().Count((Transform t) => ((Object)t).name.StartsWith("Dropdown entry", StringComparison.OrdinalIgnoreCase)) : 0));
			int value;
			int num = (automationDropdownSelectedIndexes.TryGetValue(id, out value) ? value : (-1));
			string selectedValue = ((num >= 0 && num < dropdownOptionsForAutomation.Count) ? dropdownOptionsForAutomation[num] : "");
			return new DropdownAutomationState(id, present, expanded, optionCount, num, selectedValue, dropdownOptionsForAutomation);
		}

		internal DropdownAutomationState ClickDropdownForAutomation(string id)
		{
			id = NormalizeAutomationDropdownId(id);
			GameUISelectableDropdown dropdownForAutomation = GetDropdownForAutomation(id);
			if ((Object)(object)dropdownForAutomation == (Object)null)
			{
				throw new InvalidOperationException("Seed Explorer dropdown was not found: " + id);
			}
			CoreInputControlMapping val = null;
			if ((Object)(object)InputManager.Inst != (Object)null)
			{
				((CoreInput)InputManager.Inst).TryGetSignaledInputMapping(MappingID.op_Implicit((Enum)(object)(Controls)19), ref val);
			}
			dropdownForAutomation.ApplyScreenInput(val, (IGameUIComponent)(object)dropdownForAutomation, (Controls)19);
			return GetDropdownAutomationState(id);
		}

		internal DropdownAutomationState SelectDropdownOptionForAutomation(string id, int? requestedIndex, string requestedValue)
		{
			id = NormalizeAutomationDropdownId(id);
			GameUISelectableDropdown dropdownForAutomation = GetDropdownForAutomation(id);
			if ((Object)(object)dropdownForAutomation == (Object)null)
			{
				throw new InvalidOperationException("Seed Explorer dropdown was not found: " + id);
			}
			List<string> dropdownOptionsForAutomation = GetDropdownOptionsForAutomation(id);
			if (dropdownOptionsForAutomation.Count == 0)
			{
				throw new InvalidOperationException("Seed Explorer dropdown has no automation options: " + id);
			}
			int num;
			if (requestedIndex.HasValue)
			{
				num = requestedIndex.Value;
			}
			else
			{
				if (string.IsNullOrWhiteSpace(requestedValue))
				{
					throw new InvalidOperationException("Dropdown selection requires either an index or value.");
				}
				num = dropdownOptionsForAutomation.FindIndex((string option) => string.Equals(option, requestedValue, StringComparison.Ordinal));
			}
			if (num < 0 || num >= dropdownOptionsForAutomation.Count)
			{
				throw new ArgumentOutOfRangeException("requestedIndex", $"Dropdown option index {num} was outside the option range for {id}.");
			}
			string optionName = dropdownOptionsForAutomation[num];
			dropdownForAutomation.SetIndex(num);
			ApplyDropdownSelection(id, GetFilterTypeForAutomation(id), num, optionName);
			return GetDropdownAutomationState(id);
		}

		internal List<ResultRowAutomationState> GetResultRowsForAutomation()
		{
			EnsureSeedExplorerForAutomation();
			return seedExplorer.SeedResultsFiltered.Select((SeedExplorer.SeedResult result, int index) => new ResultRowAutomationState(index, result)).ToList();
		}

		internal ResultRowAutomationState ClickResultRowForAutomation(int index)
		{
			EnsureSeedExplorerForAutomation();
			SelectResultRowForRun(index);
			return new ResultRowAutomationState(index, seedExplorer.SeedResultsFiltered[index]);
		}

		internal ScrollAutomationState GetScrollStateForAutomation()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			ScrollAutomationState scrollAutomationState = new ScrollAutomationState
			{
				RowCount = (((Object)(object)contentRT != (Object)null) ? ((Transform)contentRT).childCount : 0)
			};
			if ((Object)(object)scrollRect != (Object)null)
			{
				scrollAutomationState.VerticalNormalizedPosition = scrollRect.verticalNormalizedPosition;
				Rect rect;
				if ((Object)(object)scrollRect.viewport != (Object)null)
				{
					rect = scrollRect.viewport.rect;
					scrollAutomationState.ViewportHeight = ((Rect)(ref rect)).height;
				}
				if ((Object)(object)scrollRect.content != (Object)null)
				{
					rect = scrollRect.content.rect;
					scrollAutomationState.ContentHeight = ((Rect)(ref rect)).height;
				}
				scrollAutomationState.ScrollableHeight = Mathf.Max(0f, scrollAutomationState.ContentHeight - scrollAutomationState.ViewportHeight);
			}
			return scrollAutomationState;
		}

		internal ScrollAutomationState DispatchScrollForAutomation(int rowIndex, float delta)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			if ((Object)(object)scrollRect == (Object)null || (Object)(object)contentRT == (Object)null)
			{
				return GetScrollStateForAutomation();
			}
			GameObject val = ((rowIndex >= 0 && rowIndex < ((Transform)contentRT).childCount) ? ((Component)((Transform)contentRT).GetChild(rowIndex)).gameObject : (((Object)(object)scrollRect.viewport != (Object)null) ? ((Component)scrollRect.viewport).gameObject : ((Component)scrollRect).gameObject));
			PointerEventData val2 = new PointerEventData(EventSystem.current)
			{
				scrollDelta = new Vector2(0f, delta)
			};
			ExecuteEvents.ExecuteHierarchy<IScrollHandler>(val, (BaseEventData)(object)val2, ExecuteEvents.scrollHandler);
			if ((Object)(object)scrollRect.content != (Object)null)
			{
				LayoutRebuilder.ForceRebuildLayoutImmediate(scrollRect.content);
			}
			return GetScrollStateForAutomation();
		}

		internal int GetHighlightedRowIndexForAutomation()
		{
			if (seedExplorer == null || seedExplorer.SelectedSeedResult == null)
			{
				return -1;
			}
			int seed = seedExplorer.SelectedSeedResult.Seed;
			for (int i = 0; i < seedExplorer.SeedResultsFiltered.Count; i++)
			{
				if (seedExplorer.SeedResultsFiltered[i].Seed == seed)
				{
					return i;
				}
			}
			return -1;
		}

		internal string GetDialogChosenSeedLabelText()
		{
			return ((Object)(object)dialogChosenSeedLabel != (Object)null) ? ((TMP_Text)dialogChosenSeedLabel).text : "";
		}

		private void SelectResultRowForRun(int index)
		{
			EnsureSeedExplorerForAutomation();
			if (index < 0 || index >= seedExplorer.SeedResultsFiltered.Count)
			{
				throw new ArgumentOutOfRangeException("index", $"Seed result index {index} was outside the filtered result range.");
			}
			seedExplorer.StartRun(index);
			SeedExplorerFooterButton.RefreshChosenSeedLabel();
			UpdateDialogChosenSeedLabel();
			BuildResultsTable();
		}

		private void EnsureSeedExplorerForAutomation()
		{
			if (seedExplorer == null)
			{
				throw new InvalidOperationException("Seed Explorer has not been opened.");
			}
		}

		private GameUISelectableDropdown GetDropdownForAutomation(string id)
		{
			if (!SeedExplorerUiAutomationIds.IsDropdownId(id))
			{
				return null;
			}
			if (automationDropdowns.TryGetValue(id, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			string expectedName = SeedExplorerUiAutomationIds.DropdownObjectName(id);
			return ((IEnumerable<GameUISelectableDropdown>)((Component)this).GetComponentsInChildren<GameUISelectableDropdown>(true)).FirstOrDefault((Func<GameUISelectableDropdown, bool>)((GameUISelectableDropdown x) => string.Equals(((Object)x).name, expectedName, StringComparison.OrdinalIgnoreCase)));
		}

		private static string NormalizeAutomationDropdownId(string id)
		{
			return (id ?? "").Trim().ToLowerInvariant();
		}

		private List<string> GetDropdownOptionsForAutomation(string id)
		{
			id = NormalizeAutomationDropdownId(id);
			List<string> value;
			return automationDropdownOptions.TryGetValue(id, out value) ? value.ToList() : new List<string>();
		}

		private void StoreDropdownOptionsForAutomation(string id, List<string> options)
		{
			id = NormalizeAutomationDropdownId(id);
			automationDropdownOptions[id] = options.ToList();
			UpdateAutomationDropdownSelection(id, 0, (options.Count > 0) ? options[0] : "");
		}

		private void UpdateAutomationDropdownSelection(string id, int index, string optionName)
		{
			id = NormalizeAutomationDropdownId(id);
			if (index < 0 && automationDropdownOptions.TryGetValue(id, out var value))
			{
				index = value.FindIndex((string option) => string.Equals(option, optionName, StringComparison.Ordinal));
			}
			automationDropdownSelectedIndexes[id] = index;
		}

		private static SeedExplorer.FilterType GetFilterTypeForAutomation(string id)
		{
			id = NormalizeAutomationDropdownId(id);
			return id switch
			{
				"primarycard" => SeedExplorer.FilterType.PrimaryCard, 
				"secondarycard" => SeedExplorer.FilterType.SecondaryCard, 
				"unitcard" => SeedExplorer.FilterType.UnitCard, 
				"artifact" => SeedExplorer.FilterType.Artifact, 
				"upgrade" => SeedExplorer.FilterType.Upgrade, 
				_ => throw new InvalidOperationException("Unknown Seed Explorer dropdown id: " + id), 
			};
		}

		private void SetupDropdownTitles(List<Transform> cells)
		{
			LabelCell(cells[0], "Primary");
			LabelCell(cells[1], "Secondary");
			LabelCell(cells[2], "Unit");
			LabelCell(cells[3], "Artifact");
			LabelCell(cells[4], "Upgrade");
		}

		private void LabelCell(Transform cell, string text)
		{
			LabelCell(cell, text, "Label");
		}

		private TextMeshProUGUI LabelCell(Transform cell, string text, string objectName)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GameObject val = new GameObject(objectName ?? "Label", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(cell, false);
			LayoutElement val2 = ((Component)cell).gameObject.AddComponent<LayoutElement>();
			val2.flexibleWidth = 1f;
			val2.minWidth = 0f;
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).text = text;
			((TMP_Text)val3).fontSize = 24f;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
			ContentSizeFitter val4 = val.AddComponent<ContentSizeFitter>();
			val4.horizontalFit = (FitMode)2;
			val4.verticalFit = (FitMode)2;
			LayoutRebuilder.ForceRebuildLayoutImmediate(((TMP_Text)val3).rectTransform);
			float preferredHeight = LayoutUtility.GetPreferredHeight(((TMP_Text)val3).rectTransform);
			val2.minHeight = 30f;
			val2.preferredHeight = 30f;
			return val3;
		}

		private void DestroyAllChildren(Transform t)
		{
			IEnumerable<GameObject> enumerable = from x in ((Component)t).GetComponentsInChildren<Transform>(true)
				where (Object)(object)x != (Object)(object)t
				select ((Component)x).gameObject;
			foreach (GameObject item in enumerable)
			{
				Object.DestroyImmediate((Object)(object)item);
			}
		}

		private void RelabelDropdowns()
		{
			LabelDropdown(Card1Dropdown, "primarycard", seedExplorer.PrimaryCardPool);
			LabelDropdown(Card2Dropdown, "secondarycard", seedExplorer.SecondaryCardPool);
			LabelDropdown(Card3Dropdown, "unitcard", seedExplorer.UnitCardPool);
			LabelDropdown(ArtifactDropdown, "artifact", seedExplorer.ArtifactPool);
			LabelDropdown(UpgradeDropdown, "upgrade", seedExplorer.UpgradePool);
		}

		private void SetupDropdowns(Transform row)
		{
			List<Transform> list = ((IEnumerable)row).Cast<Transform>().ToList();
			automationDropdowns.Clear();
			automationDropdownOptions.Clear();
			automationDropdownSelectedIndexes.Clear();
			foreach (Transform item in list)
			{
				DestroyAllChildren(item);
				LayoutElement val = ((Component)item).GetComponent<LayoutElement>() ?? ((Component)item).gameObject.AddComponent<LayoutElement>();
				val.minHeight = 70f;
				val.preferredHeight = 70f;
			}
			Card1Dropdown = CreateDropdown(list[0], seedExplorer.PrimaryCardPool, "primarycard");
			Card2Dropdown = CreateDropdown(list[1], seedExplorer.SecondaryCardPool, "secondarycard");
			Card3Dropdown = CreateDropdown(list[2], seedExplorer.UnitCardPool, "unitcard");
			ArtifactDropdown = CreateDropdown(list[3], seedExplorer.ArtifactPool, "artifact");
			UpgradeDropdown = CreateDropdown(list[4], seedExplorer.UpgradePool, "upgrade");
			RegisterAutomationDropdown("primarycard", Card1Dropdown);
			RegisterAutomationDropdown("secondarycard", Card2Dropdown);
			RegisterAutomationDropdown("unitcard", Card3Dropdown);
			RegisterAutomationDropdown("artifact", ArtifactDropdown);
			RegisterAutomationDropdown("upgrade", UpgradeDropdown);
			RelabelDropdowns();
			SetupDropdownButtonListeners(Card1Dropdown);
			SetupDropdownButtonListeners(Card2Dropdown);
			SetupDropdownButtonListeners(Card3Dropdown);
			SetupDropdownButtonListeners(ArtifactDropdown);
			SetupDropdownButtonListeners(UpgradeDropdown);
			Card1Dropdown.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
			{
				ApplyDropdownSelection("primarycard", SeedExplorer.FilterType.PrimaryCard, index, optionName);
			});
			Card2Dropdown.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
			{
				ApplyDropdownSelection("secondarycard", SeedExplorer.FilterType.SecondaryCard, index, optionName);
			});
			Card3Dropdown.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
			{
				ApplyDropdownSelection("unitcard", SeedExplorer.FilterType.UnitCard, index, optionName);
			});
			ArtifactDropdown.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
			{
				ApplyDropdownSelection("artifact", SeedExplorer.FilterType.Artifact, index, optionName);
			});
			UpgradeDropdown.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
			{
				ApplyDropdownSelection("upgrade", SeedExplorer.FilterType.Upgrade, index, optionName);
			});
			list.ForEach(delegate(Transform c)
			{
				((Component)c).gameObject.SetActive(true);
			});
		}

		private void ApplyDropdownSelection(string automationId, SeedExplorer.FilterType filterType, int index, string optionName)
		{
			automationId = NormalizeAutomationDropdownId(automationId);
			UpdateAutomationDropdownSelection(automationId, index, optionName);
			seedExplorer.UpdateFilter(filterType, optionName);
			BuildResultsTable();
			ResetResultsScrollForAutomation();
		}

		private void ResetResultsScrollForAutomation()
		{
			if (!((Object)(object)scrollRect == (Object)null))
			{
				scrollRect.verticalNormalizedPosition = 1f;
				LayoutRebuilder.ForceRebuildLayoutImmediate(scrollRect.content);
			}
		}

		private static GameObject GetDropdownList(GameUISelectableDropdown dd)
		{
			object? obj = typeof(GameUISelectableDropdown).GetField("dropdownList", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(dd);
			return (GameObject)((obj is GameObject) ? obj : null);
		}

		private static void SetDropdownListAutomationName(GameUISelectableDropdown dd, string automationId)
		{
			GameObject dropdownList = GetDropdownList(dd);
			if ((Object)(object)dropdownList != (Object)null)
			{
				((Object)dropdownList).name = SeedExplorerUiAutomationIds.DropdownListObjectName(automationId);
			}
		}

		private static void ShrinkDropdownEntries(GameUISelectableDropdown dd, float entryHeight)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			GameObject dropdownList = GetDropdownList(dd);
			if ((Object)(object)dropdownList == (Object)null)
			{
				return;
			}
			foreach (Transform item in dropdownList.transform)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith("Dropdown entry"))
				{
					RectTransform component = ((Component)val).GetComponent<RectTransform>();
					component.SetSizeWithCurrentAnchors((Axis)1, entryHeight);
					LayoutElement val2 = ((Component)val).GetComponent<LayoutElement>() ?? ((Component)val).gameObject.AddComponent<LayoutElement>();
					val2.minHeight = entryHeight;
					val2.preferredHeight = entryHeight;
					val2.flexibleHeight = 0f;
				}
			}
		}

		private static void ExpandDropdownEntryWidths(GameUISelectableDropdown dd)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_008f: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			GameObject dropdownList = GetDropdownList(dd);
			if ((Object)(object)dropdownList == (Object)null)
			{
				return;
			}
			VerticalLayoutGroup component = dropdownList.GetComponent<VerticalLayoutGroup>();
			if ((Object)(object)component != (Object)null)
			{
				((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = true;
			}
			foreach (Transform item in dropdownList.transform)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith("Dropdown entry"))
				{
					RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
					component2.anchorMin = new Vector2(0f, component2.anchorMin.y);
					component2.anchorMax = new Vector2(1f, component2.anchorMax.y);
					component2.offsetMin = new Vector2(0f, component2.offsetMin.y);
					component2.offsetMax = new Vector2(0f, component2.offsetMax.y);
					LayoutElement val2 = ((Component)val).GetComponent<LayoutElement>() ?? ((Component)val).gameObject.AddComponent<LayoutElement>();
					val2.minWidth = 0f;
					val2.flexibleWidth = 1f;
				}
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(dropdownList.GetComponent<RectTransform>());
		}

		private void DumpDropdownLayout(GameUISelectableDropdown dd)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)dd).GetComponent<RectTransform>();
			LayoutElement component2 = ((Component)dd).GetComponent<LayoutElement>();
			ContentSizeFitter component3 = ((Component)dd).GetComponent<ContentSizeFitter>();
			Debug.Log((object)("––– Dump root of " + ((Object)dd).name + " –––"));
			Debug.Log((object)$"RT anchors [{component.anchorMin} → {component.anchorMax}] offsets [{component.offsetMin} → {component.offsetMax}] sizeDelta {component.sizeDelta}");
			Debug.Log((object)(((Object)(object)component2 != (Object)null) ? $"LE minW:{component2.minWidth}, prefW:{component2.preferredWidth}, flexW:{component2.flexibleWidth}" : "no root LE"));
			Debug.Log((object)(((Object)(object)component3 != (Object)null) ? $"CSF H:{component3.horizontalFit}, V:{component3.verticalFit}" : "no root CSF"));
			foreach (Transform item in ((Component)dd).transform)
			{
				Transform val = item;
				RectTransform component4 = ((Component)val).GetComponent<RectTransform>();
				LayoutElement component5 = ((Component)val).GetComponent<LayoutElement>();
				ContentSizeFitter component6 = ((Component)val).GetComponent<ContentSizeFitter>();
				Debug.Log((object)("  • Child '" + ((Object)val).name + "'"));
				Debug.Log((object)$"    RT anchors [{component4.anchorMin} → {component4.anchorMax}] offsets [{component4.offsetMin} → {component4.offsetMax}] sizeDelta {component4.sizeDelta}");
				Debug.Log((object)(((Object)(object)component5 != (Object)null) ? $"    LE minW:{component5.minWidth}, prefW:{component5.preferredWidth}, flexW:{component5.flexibleWidth}" : "    no LE"));
				Debug.Log((object)(((Object)(object)component6 != (Object)null) ? $"    CSF H:{component6.horizontalFit}, V:{component6.verticalFit}" : "    no CSF"));
			}
		}

		private void DumpHierarchy(Transform t, string indent = "")
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			RectTransform component = ((Component)t).GetComponent<RectTransform>();
			LayoutElement component2 = ((Component)t).GetComponent<LayoutElement>();
			ContentSizeFitter component3 = ((Component)t).GetComponent<ContentSizeFitter>();
			Debug.Log((object)($"{indent}{((Object)t).name} ─ anchors [{component.anchorMin}->{component.anchorMax}] " + $"offsets [{component.offsetMin}->{component.offsetMax}] sizeDelta {component.sizeDelta}  " + (((Object)(object)component2 != (Object)null) ? $"LE(minW:{component2.minWidth},flexW:{component2.flexibleWidth}) " : "") + (((Object)(object)component3 != (Object)null) ? $"CSF(H:{component3.horizontalFit},V:{component3.verticalFit})" : "")));
			foreach (Transform item in t)
			{
				Transform t2 = item;
				DumpHierarchy(t2, indent + "  ");
			}
		}

		private void DumpFullDropdown(GameUISelectableDropdown dd)
		{
			FieldInfo field = typeof(GameUISelectableDropdown).GetField("dropdownList", BindingFlags.Instance | BindingFlags.NonPublic);
			object? value = field.GetValue(dd);
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"dropdownList NULL");
				return;
			}
			Debug.Log((object)("─── FULL HIERARCHY for " + ((Object)dd).name + ".dropdownList ───"));
			DumpHierarchy(val.transform);
		}

		private static void CloneScrollRectForDropdown(GameUISelectableDropdown dd, ScrollRect templateScrollRect)
		{
			//IL_00be: 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)
			object? obj = typeof(GameUISelectableDropdown).GetField("dropdownList", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(dd);
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)templateScrollRect).gameObject, val.transform.parent, false);
				ScrollRect component = val2.GetComponent<ScrollRect>();
				if ((Object)(object)component.content != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)component.content).gameObject);
				}
				RectTransform viewport = component.viewport;
				val.transform.SetParent((Transform)(object)viewport, false);
				component.content = val.GetComponent<RectTransform>();
				RectTransform component2 = val.GetComponent<RectTransform>();
				float num = (float)Screen.height * 0.4f;
				Rect rect = component2.rect;
				component2.SetSizeWithCurrentAnchors((Axis)1, Mathf.Min(((Rect)(ref rect)).height, num));
				LayoutRebuilder.ForceRebuildLayoutImmediate(component.content);
			}
		}

		private void LabelDropdown(GameUISelectableDropdown dropdown, string automationId, List<string> options)
		{
			if ((Object)(object)dropdown == (Object)null)
			{
				throw new InvalidOperationException("Unable to label missing Seed Explorer dropdown: " + automationId);
			}
			((Object)dropdown).name = SeedExplorerUiAutomationIds.DropdownObjectName(automationId);
			List<string> list = options.OrderBy((string x) => x).Prepend("<any>").ToList();
			StoreDropdownOptionsForAutomation(automationId, list);
			dropdown.SetOptions(list);
			SetDropdownListAutomationName(dropdown, automationId);
			TextMeshProUGUI[] componentsInChildren = ((Component)dropdown).GetComponentsInChildren<TextMeshProUGUI>(true);
			foreach (TextMeshProUGUI val in componentsInChildren)
			{
				((TMP_Text)val).fontSize = 14f;
			}
			ShrinkDropdownEntries(dropdown, 15f);
			ExpandDropdownEntryWidths(dropdown);
			int num = ResolveDropdownRestoreIndex(automationId, list);
			dropdown.SetIndex(num);
			string optionName = ((num >= 0 && num < list.Count) ? list[num] : "<any>");
			UpdateAutomationDropdownSelection(automationId, num, optionName);
			AttachHoverPreviewHandlers(dropdown, automationId, list);
		}

		private void AttachHoverPreviewHandlers(GameUISelectableDropdown dropdown, string automationId, List<string> options)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			if (hoverPreview == null)
			{
				return;
			}
			GameObject dropdownList = GetDropdownList(dropdown);
			if ((Object)(object)dropdownList == (Object)null)
			{
				return;
			}
			SeedExplorerHoverPreview.PreviewKind kind = GetPreviewKindForAutomation(automationId);
			int num = 0;
			foreach (Transform item in dropdownList.transform)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith("Dropdown entry", StringComparison.Ordinal))
				{
					int num2 = num;
					int num3 = num2;
					if (num3 >= options.Count)
					{
						break;
					}
					string optionName = options[num3];
					EventTrigger val2 = ((Component)val).gameObject.GetComponent<EventTrigger>() ?? ((Component)val).gameObject.AddComponent<EventTrigger>();
					Entry val3 = new Entry
					{
						eventID = (EventTriggerType)0
					};
					((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)delegate
					{
						hoverPreview.Show(kind, optionName);
					});
					val2.triggers.Add(val3);
					Entry val4 = new Entry
					{
						eventID = (EventTriggerType)1
					};
					((UnityEvent<BaseEventData>)(object)val4.callback).AddListener((UnityAction<BaseEventData>)delegate
					{
						hoverPreview.Hide();
					});
					val2.triggers.Add(val4);
					num++;
				}
			}
		}

		private static SeedExplorerHoverPreview.PreviewKind GetPreviewKindForAutomation(string automationId)
		{
			return NormalizeAutomationDropdownId(automationId) switch
			{
				"primarycard" => SeedExplorerHoverPreview.PreviewKind.PrimaryCard, 
				"secondarycard" => SeedExplorerHoverPreview.PreviewKind.SecondaryCard, 
				"unitcard" => SeedExplorerHoverPreview.PreviewKind.UnitCard, 
				"artifact" => SeedExplorerHoverPreview.PreviewKind.Artifact, 
				"upgrade" => SeedExplorerHoverPreview.PreviewKind.ChampionUpgrade, 
				_ => SeedExplorerHoverPreview.PreviewKind.None, 
			};
		}

		internal SeedExplorerHoverPreview.State HoverDropdownOptionForAutomation(string automationId, int optionIndex)
		{
			EnsureSeedExplorerForAutomation();
			if (hoverPreview == null)
			{
				throw new InvalidOperationException("Hover preview panel was not initialized.");
			}
			string text = NormalizeAutomationDropdownId(automationId);
			List<string> dropdownOptionsForAutomation = GetDropdownOptionsForAutomation(text);
			if (optionIndex < 0 || optionIndex >= dropdownOptionsForAutomation.Count)
			{
				throw new ArgumentOutOfRangeException("optionIndex", $"Hover option index {optionIndex} was outside the option range for {text}.");
			}
			hoverPreview.Show(GetPreviewKindForAutomation(text), dropdownOptionsForAutomation[optionIndex]);
			return hoverPreview.CurrentState;
		}

		internal SeedExplorerHoverPreview.State GetHoverPreviewStateForAutomation()
		{
			return (hoverPreview != null) ? hoverPreview.CurrentState : new SeedExplorerHoverPreview.State();
		}

		internal SeedExplorerHoverPreview.State HoverResultCellForAutomation(int rowIndex, string columnId)
		{
			EnsureSeedExplorerForAutomation();
			if (hoverPreview == null)
			{
				throw new InvalidOperationException("Hover preview panel was not initialized.");
			}
			string text = SeedExplorerUiAutomationIds.NormalizeResultColumnId(columnId);
			if (!SeedExplorerUiAutomationIds.IsResultColumnId(text))
			{
				throw new ArgumentException("Unknown result column id: '" + columnId + "'. Expected one of: " + string.Join(", ", SeedExplorerUiAutomationIds.ResultColumnIds), "columnId");
			}
			if (!resultCellHoverRegistry.TryGetValue((rowIndex, text), out (string, SeedExplorerHoverPreview.PreviewKind) value))
			{
				throw new ArgumentOutOfRangeException("rowIndex", "No registered result cell for row " + rowIndex + " column '" + text + "'. Available rows: 0.." + Math.Max(0, (resultCellHoverRegistry.Count == 0) ? (-1) : resultCellHoverRegistry.Keys.Max(((int row, string columnId) k) => k.row)));
			}
			hoverPreview.Show(value.Item2, value.Item1);
			return hoverPreview.CurrentState;
		}

		internal ResultCellClickAutomationState DispatchClickOnResultCellForAutomation(int rowIndex, string columnId)
		{
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			EnsureSeedExplorerForAutomation();
			string text = SeedExplorerUiAutomationIds.NormalizeResultColumnId(columnId);
			if (!SeedExplorerUiAutomationIds.IsResultColumnId(text))
			{
				throw new ArgumentException("Unknown result column id: '" + columnId + "'. Expected one of: " + string.Join(", ", SeedExplorerUiAutomationIds.ResultColumnIds), "columnId");
			}
			if (!resultCellLabelObjects.TryGetValue((rowIndex, text), out var value) || (Object)(object)value == (Object)null)
			{
				throw new ArgumentOutOfRangeException("rowIndex", "No registered result cell GameObject for row " + rowIndex + " column '" + text + "'. Available rows: 0.." + Math.Max(0, (resultCellLabelObjects.Count == 0) ? (-1) : resultCellLabelObjects.Keys.Max(((int row, string columnId) k) => k.row)));
			}
			string name = ((Object)value).name;
			EventSystem current = EventSystem.current;
			PointerEventData val = new PointerEventData(current)
			{
				button = (InputButton)0,
				clickCount = 1,
				clickTime = Time.unscaledTime,
				position = RectTransformUtility.WorldToScreenPoint((Camera)null, value.transform.position)
			};
			val.pointerPress = value;
			val.rawPointerPress = value;
			RaycastResult pointerCurrentRaycast = default(RaycastResult);
			((RaycastResult)(ref pointerCurrentRaycast)).gameObject = value;
			val.pointerCurrentRaycast = pointerCurrentRaycast;
			val.pointerPressRaycast = val.pointerCurrentRaycast;
			GameObject eventHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(value);
			string handlerObjectName = "";
			if ((Object)(object)eventHandler != (Object)null)
			{
				try
				{
					handlerObjectName = ((Object)eventHandler).name;
				}
				catch (MissingReferenceException)
				{
					handlerObjectName = "<destroyed>";
				}
				try
				{
					ExecuteEvents.Execute<IPointerClickHandler>(eventHandler, (BaseEventData)(object)val, ExecuteEvents.pointerClickHandler);
				}
				catch (Exception ex)
				{
					Plugin.LogError("DispatchClickOnResultCellForAutomation: Execute threw " + ex.GetType().Name + ": " + ex.Message + "\n" + ex.StackTrace);
					throw;
				}
			}
			int? chosenSeed = null;
			if (seedExplorer != null && seedExplorer.SelectedSeedResult != null)
			{
				chosenSeed = seedExplorer.SelectedSeedResult.Seed;
			}
			return new ResultCellClickAutomationState
			{
				RowIndex = rowIndex,
				Column = text,
				TargetObjectName = name,
				HandlerObjectName = handlerObjectName,
				DialogOpen = IsOpenForAutomation(),
				ChosenSeed = chosenSeed
			};
		}

		private int ResolveDropdownRestoreIndex(string automationId, List<string> options)
		{
			if (seedExplorer == null || seedExplorer.Filter == null || options == null || options.Count == 0)
			{
				return 0;
			}
			string persisted;
			switch (NormalizeAutomationDropdownId(automationId))
			{
			case "primarycard":
				persisted = seedExplorer.Filter.PrimaryCard;
				break;
			case "secondarycard":
				persisted = seedExplorer.Filter.SecondaryCard;
				break;
			case "unitcard":
				persisted = seedExplorer.Filter.UnitCard;
				break;
			case "artifact":
				persisted = seedExplorer.Filter.Artifact;
				break;
			case "upgrade":
				persisted = seedExplorer.Filter.Upgrade;
				break;
			default:
				persisted = null;
				break;
			}
			if (string.IsNullOrEmpty(persisted))
			{
				return 0;
			}
			int num = options.FindIndex((string option) => string.Equals(option, persisted, StringComparison.Ordinal));
			return (num >= 0) ? num : 0;
		}

		private GameUISelectableDropdown CreateDropdown(Transform target, List<string> options, string automationId)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Expected O, but got Unknown
			GameUISelectableDropdown val = Object.FindObjectOfType<GameUISelectableDropdown>(true);
			GameUISelectableDropdown dropdown = Object.Instantiate<GameUISelectableDropdown>(val);
			((Object)target).name = SeedExplorerUiAutomationIds.DropdownCellObjectName(automationId);
			((Object)dropdown).name = SeedExplorerUiAutomationIds.DropdownObjectName(automationId);
			((Component)dropdown).transform.SetParent(target, false);
			RectTransform component = ((Component)dropdown).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			Object.DestroyImmediate((Object)(object)((Component)dropdown).GetComponent<ContentSizeFitter>());
			Object.DestroyImmediate((Object)(object)((Component)dropdown).GetComponent<LayoutElement>());
			Transform obj = ((Component)dropdown).transform.Find("Bg");
			RectTransform val2 = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				Image component2 = ((Component)val2).GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.type = (Type)1;
					component2.preserveAspect = false;
				}
			}
			LayoutElement val3 = ((Component)dropdown).gameObject.AddComponent<LayoutElement>();
			val3.minWidth = 0f;
			val3.flexibleWidth = 1f;
			val3.minHeight = 70f;
			val3.preferredHeight = 70f;
			Transform obj2 = ((Component)dropdown).transform.Find("Value");
			RectTransform val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<RectTransform>() : null);
			if ((Object)(object)val4 != (Object)null)
			{
				val4.anchorMin = new Vector2(0f, 0f);
				val4.anchorMax = new Vector2(1f, 1f);
				val4.offsetMin = new Vector2(8f, val4.offsetMin.y);
				val4.offsetMax = new Vector2(-24f, val4.offsetMax.y);
			}
			Transform obj3 = ((Component)dropdown).transform.Find("Bg");
			Image val5 = ((obj3 != null) ? ((Component)obj3).GetComponent<Image>() : null);
			if ((Object)(object)val5 != (Object)null)
			{
				val5.preserveAspect = false;
				val5.type = (Type)1;
			}
			((UnityEvent)((Button)dropdown).onClick).AddListener((UnityAction)delegate
			{
				CoreInputControlMapping val6 = default(CoreInputControlMapping);
				((CoreInput)InputManager.Inst).TryGetSignaledInputMapping(MappingID.op_Implicit((Enum)(object)(Controls)19), ref val6);
				dropdown.ApplyScreenInput(val6, (IGameUIComponent)(object)dropdown, (Controls)19);
			});
			return dropdown;
		}

		private void RegisterAutomationDropdown(string id, GameUISelectableDropdown dropdown)
		{
			automationDropdowns[NormalizeAutomationDropdownId(id)] = dropdown;
		}

		private void DumpDropdownAncestors(GameUISelectableDropdown dd)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("── Ancestor chain for " + ((Object)dd).name + " ──"));
			Transform val = ((Component)dd).transform;
			while ((Object)(object)val != (Object)null)
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				LayoutElement component2 = ((Component)val).GetComponent<LayoutElement>();
				HorizontalLayoutGroup component3 = ((Component)val).GetComponent<HorizontalLayoutGroup>();
				VerticalLayoutGroup component4 = ((Component)val).GetComponent<VerticalLayoutGroup>();
				ContentSizeFitter component5 = ((Component)val).GetComponent<ContentSizeFitter>();
				string text = $"{((Object)val).name} | RT anchors[{component.anchorMin}->{component.anchorMax}] offs[{component.offsetMin}->{component.offsetMax}] sizeDelta{component.sizeDelta}";
				if ((Object)(object)component2 != (Object)null)
				{
					text += $"  LE(minW:{component2.minWidth},flexW:{component2.flexibleWidth})";
				}
				if ((Object)(object)component3 != (Object)null)
				{
					text += $"  HLG(childControlW:{((HorizontalOrVerticalLayoutGroup)component3).childControlWidth},forceExpandW:{((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth})";
				}
				if ((Object)(object)component4 != (Object)null)
				{
					text += $"  VLG(childControlW:{((HorizontalOrVerticalLayoutGroup)component4).childControlWidth},forceExpandW:{((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth})";
				}
				if ((Object)(object)component5 != (Object)null)
				{
					text += $"  CSF(H:{component5.horizontalFit},V:{component5.verticalFit})";
				}
				Debug.Log((object)text);
				val = val.parent;
			}
		}

		private void SetupDropdownButtonListeners(GameUISelectableDropdown targetDropdown)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			GameUISelectableButton[] componentsInChildren = ((Component)targetDropdown).GetComponentsInChildren<GameUISelectableButton>(true);
			foreach (GameUISelectableButton button in componentsInChildren)
			{
				if (!((Object)(object)button == (Object)(object)targetDropdown))
				{
					((UnityEvent)((Button)button).onClick).AddListener((UnityAction)delegate
					{
						CoreInputControlMapping val = default(CoreInputControlMapping);
						((CoreInput)InputManager.Inst).TryGetSignaledInputMapping(MappingID.op_Implicit((Enum)(object)(Controls)19), ref val);
						targetDropdown.ApplyScreenInput(val, (IGameUIComponent)(object)button, (Controls)19);
					});
				}
			}
		}
	}
	public class SeedExplorerFooterButton : GameUISelectableButton
	{
		public static TextMeshProUGUI ChosenSeedLabel { get; private set; }

		public static string FormatChosenSeedLabel(int? seed)
		{
			if (!seed.HasValue)
			{
				return "";
			}
			return "Chosen Seed: " + seed.Value.ToString("X8");
		}

		public static void RefreshChosenSeedLabel()
		{
			if (!((Object)(object)ChosenSeedLabel == (Object)null))
			{
				int? seed = SeedExplorer.Instance?.SelectedSeedResult?.Seed;
				((TMP_Text)ChosenSeedLabel).text = FormatChosenSeedLabel(seed);
			}
		}

		public static GameUISelectableButton Instantiate(RunSetupScreen runSetupScreen)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			UIFooter val = Object.FindObjectOfType<UIFooter>();
			Transform val2 = ((Component)val).transform.Find("Swap Champion Button");
			Transform val3 = Object.Instantiate<Transform>(val2, ((Component)val).transform);
			((Object)val3).name = SeedExplorerUiAutomationIds.ChooseSeedButtonObjectName;
			((TMP_Text)((Component)val3.Find("Label")).GetComponent<TextMeshProUGUI>()).text = "Choose Seed";
			GameUISelectableButton component = ((Component)val3).GetComponent<GameUISelectableButton>();
			((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate
			{
				RunSetupContext runSetupContext = RunSetupContext.TryCapture(runSetupScreen);
				string key = ((runSetupContext != null) ? runSetupContext.Signature : "unknown-context");
				SeedExplorerDialog seedExplorerDialog = ModRegistry.GetSeedExplorerDialog(runSetupScreen);
				if ((Object)(object)seedExplorerDialog != (Object)null)
				{
					seedExplorerDialog.Open(key);
				}
			});
			EnsureChosenSeedLabel(val);
			RefreshChosenSeedLabel();
			return component;
		}

		private static void EnsureChosenSeedLabel(UIFooter uiFooter)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ChosenSeedLabel != (Object)null) || !((Object)(object)((Component)ChosenSeedLabel).gameObject != (Object)null))
			{
				GameObject val = new GameObject(SeedExplorerUiAutomationIds.ChosenSeedFooterLabelObjectName, new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(((Component)uiFooter).transform, false);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(1f, 0f);
				component.anchorMax = new Vector2(1f, 0f);
				component.pivot = new Vector2(1f, 0f);
				component.anchoredPosition = new Vector2(-24f, 12f);
				component.sizeDelta = new Vector2(420f, 28