Decompiled source of Sideload v1.0.1

Sideload.dll

Decompiled 17 hours ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.WebSockets;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp.Dom;
using AngleSharp.Html.Parser;
using Esprima;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Input;
using Il2CppScheduleOne.UI.Phone;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using Jint;
using Jint.Native;
using Jint.Native.Function;
using Jint.Native.Object;
using Jint.Runtime;
using Jint.Runtime.Descriptors;
using Jint.Runtime.Interop;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Sideload;
using Sideload.Bundle;
using Sideload.Config;
using Sideload.Css;
using Sideload.Devtools.Cdp;
using Sideload.Dom;
using Sideload.Host;
using Sideload.Input;
using Sideload.Layout;
using Sideload.Model;
using Sideload.Net;
using Sideload.Paint;
using Sideload.Phone;
using Sideload.Script;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Sideload", "1.0.1", "DooDesch", "https://github.com/DooDesch-Mods/ScheduleOne-Sideload")]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DooDesch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © DooDesch")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+6974c626e698673232f2fb3ea70da64862741945")]
[assembly: AssemblyProduct("Sideload")]
[assembly: AssemblyTitle("Sideload")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Sideload
{
	public class Core : MelonMod
	{
		internal static Instance Log;

		public override void OnInitializeMelon()
		{
			Log = ((MelonBase)this).LoggerInstance;
			HostAllowlist.Log = delegate(string line)
			{
				Log.Warning(line);
			};
			PreloadRuntimeDependency("AngleSharp.dll");
			PreloadRuntimeDependency("Esprima.dll");
			PreloadRuntimeDependency("Jint.dll");
			try
			{
				((MelonBase)this).HarmonyInstance.PatchAll();
				Log.Msg("[Sideload] patches applied.");
			}
			catch (Exception ex)
			{
				Log.Error("[Sideload] PatchAll failed - no app will reach the phone: " + ex);
			}
			Preferences.Initialize();
			if (Preferences.DevTools)
			{
				CdpServer.Start(Preferences.DevToolsPort);
			}
		}

		public override void OnUpdate()
		{
			WebView.TickAll(Time.deltaTime);
			TurnInput.Tick();
			CdpServer.Pump();
		}

		public override void OnDeinitializeMelon()
		{
			CdpServer.Stop();
			ChromeLauncher.Close();
		}

		private static void PreloadRuntimeDependency(string fileName)
		{
			try
			{
				string text = Path.Combine(MelonEnvironment.UserLibsDirectory, fileName);
				if (!File.Exists(text))
				{
					string text2 = Path.Combine(Path.GetDirectoryName(typeof(Core).Assembly.Location) ?? MelonEnvironment.ModsDirectory, fileName);
					if (!File.Exists(text2))
					{
						Log.Warning("[Sideload] runtime dependency not found in UserLibs or next to the mod: " + fileName);
						return;
					}
					text = text2;
				}
				AssemblyName name = Assembly.LoadFrom(text).GetName();
				Log.Msg($"[Sideload] preloaded {name.Name} {name.Version}");
			}
			catch (Exception ex)
			{
				Log.Warning("[Sideload] preloading " + fileName + " failed: " + ex.Message);
			}
		}
	}
	internal sealed class AppRegistration
	{
		internal string Id;

		internal string Title;

		internal string IconLabel;

		internal string BundlePrefix;

		internal Assembly HostAssembly;

		internal AppBundle Bundle;

		internal Sprite IconSprite;

		internal bool Portrait;

		internal bool DeclaredPortrait;

		internal bool CanTurn;

		internal int Badge;

		internal Action OrientationChanged;

		internal bool Supports(bool portrait)
		{
			if (!CanTurn)
			{
				return DeclaredPortrait == portrait;
			}
			return true;
		}
	}
	internal static class Registry
	{
		private static readonly List<AppRegistration> _apps = new List<AppRegistration>();

		internal static IReadOnlyList<AppRegistration> Apps => _apps;

		internal static void RegisterApp(string id, string title, string iconLabel, string bundlePrefix, Assembly host)
		{
			if (string.IsNullOrWhiteSpace(id) || host == null)
			{
				return;
			}
			AppRegistration appRegistration = new AppRegistration
			{
				Id = id.Trim(),
				Title = (string.IsNullOrWhiteSpace(title) ? id : title),
				IconLabel = ((!string.IsNullOrWhiteSpace(iconLabel)) ? iconLabel : (string.IsNullOrWhiteSpace(title) ? id : title)),
				BundlePrefix = (bundlePrefix ?? ""),
				HostAssembly = host
			};
			appRegistration.Bundle = new AppBundle(appRegistration.Id, appRegistration.BundlePrefix, host);
			for (int i = 0; i < _apps.Count; i++)
			{
				if (string.Equals(_apps[i].Id, appRegistration.Id, StringComparison.OrdinalIgnoreCase))
				{
					_apps[i] = appRegistration;
					Instance log = Core.Log;
					if (log != null)
					{
						log.Warning("[Sideload] app '" + appRegistration.Id + "' registered twice; the later registration wins.");
					}
					return;
				}
			}
			_apps.Add(appRegistration);
			Instance log2 = Core.Log;
			if (log2 != null)
			{
				log2.Msg($"[Sideload] app registered: {appRegistration.Id} ('{appRegistration.Title}') from {host.GetName().Name}");
			}
		}

		internal static void DeclareOrientations(string appId, string orientations)
		{
			AppRegistration appRegistration = Find(appId);
			if (appRegistration == null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] orientation: no app '" + appId + "'.");
				}
				return;
			}
			OrientationSet orientationSet = OrientationSet.Parse(orientations);
			foreach (string item in orientationSet.Ignored)
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Warning($"[Sideload] '{appId}' declared orientation '{item}', which is neither 'portrait' " + "nor 'landscape' - ignored.");
				}
			}
			if (orientationSet.Declared)
			{
				appRegistration.DeclaredPortrait = orientationSet.Portrait;
				appRegistration.CanTurn = orientationSet.CanTurn;
				appRegistration.Portrait = orientationSet.Portrait;
			}
		}

		internal static void SetOrientation(string appId, string orientation)
		{
			AppRegistration appRegistration = Find(appId);
			if (appRegistration == null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] setOrientation: no app '" + appId + "'.");
				}
				return;
			}
			bool flag = string.Equals((orientation ?? "").Trim(), "portrait", StringComparison.OrdinalIgnoreCase);
			if (appRegistration.Portrait == flag)
			{
				return;
			}
			if (!appRegistration.Supports(flag))
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Warning($"[Sideload] '{appRegistration.Id}' was asked for {(flag ? "portrait" : "landscape")} but " + "only declared the other one - ignored. Declare both to allow turning: Apps.Register(...).Orientation(\"landscape\", \"portrait\").");
				}
			}
			else
			{
				appRegistration.Portrait = flag;
				appRegistration.OrientationChanged?.Invoke();
			}
		}

		internal static void SetBadge(string appId, int count)
		{
			AppRegistration appRegistration = Find(appId);
			if (appRegistration == null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] badge: no app '" + appId + "'.");
				}
			}
			else
			{
				appRegistration.Badge = Math.Max(0, count);
				LiveHost(appId)?.SetBadge(appRegistration.Badge);
			}
		}

		internal static void Notify(string appId, string title, string subtitle)
		{
			LiveHost(appId)?.Notify(title, subtitle);
		}

		internal static bool IsOnScreen(string appId)
		{
			return LiveHost(appId)?.IsShowing ?? false;
		}

		private static PhoneAppHost LiveHost(string appId)
		{
			IReadOnlyList<PhoneAppHost> hosts = HomeScreenPatch.Hosts;
			for (int i = 0; i < hosts.Count; i++)
			{
				if (string.Equals(hosts[i].Id, appId, StringComparison.OrdinalIgnoreCase) && hosts[i].IsAlive)
				{
					return hosts[i];
				}
			}
			return null;
		}

		internal static AppRegistration Find(string appId)
		{
			if (string.IsNullOrWhiteSpace(appId))
			{
				return null;
			}
			for (int i = 0; i < _apps.Count; i++)
			{
				if (string.Equals(_apps[i].Id, appId, StringComparison.OrdinalIgnoreCase))
				{
					return _apps[i];
				}
			}
			return null;
		}
	}
}
namespace Sideload.Script
{
	public sealed class Bridge
	{
		public sealed class JsStorage
		{
			private readonly string _path;

			private readonly Dictionary<string, string> _values = new Dictionary<string, string>(StringComparer.Ordinal);

			private bool _loaded;

			internal JsStorage(string appId)
			{
				string path = Path.Combine(MelonEnvironment.UserDataDirectory, "Sideload");
				_path = Path.Combine(path, Sanitise(appId) + ".json");
			}

			public string Get(string key, string fallback = "")
			{
				Load();
				if (key == null || !_values.TryGetValue(key, out var value))
				{
					return fallback;
				}
				return value;
			}

			public void Set(string key, string value)
			{
				if (!string.IsNullOrEmpty(key))
				{
					Load();
					_values[key] = value ?? "";
					Save();
				}
			}

			public void Remove(string key)
			{
				if (!string.IsNullOrEmpty(key))
				{
					Load();
					if (_values.Remove(key))
					{
						Save();
					}
				}
			}

			public void Clear()
			{
				Load();
				_values.Clear();
				Save();
			}

			private void Load()
			{
				if (_loaded)
				{
					return;
				}
				_loaded = true;
				try
				{
					if (!File.Exists(_path))
					{
						return;
					}
					foreach (KeyValuePair<string, string> item in MiniJson.ParseObject(File.ReadAllText(_path)))
					{
						_values[item.Key] = item.Value;
					}
				}
				catch (Exception ex)
				{
					Instance log = Core.Log;
					if (log != null)
					{
						log.Warning("[Sideload] storage read failed: " + ex.Message);
					}
				}
			}

			private void Save()
			{
				try
				{
					Directory.CreateDirectory(Path.GetDirectoryName(_path));
					File.WriteAllText(_path, MiniJson.WriteObject(_values));
				}
				catch (Exception ex)
				{
					Instance log = Core.Log;
					if (log != null)
					{
						log.Warning("[Sideload] storage write failed: " + ex.Message);
					}
				}
			}

			private static string Sanitise(string id)
			{
				StringBuilder stringBuilder = new StringBuilder(id?.Length ?? 0);
				string text = id ?? "app";
				foreach (char c in text)
				{
					stringBuilder.Append((char.IsLetterOrDigit(c) || c == '-' || c == '_') ? c : '-');
				}
				if (stringBuilder.Length != 0)
				{
					return stringBuilder.ToString();
				}
				return "app";
			}
		}

		private static readonly Dictionary<string, Func<string, string, string>> _handlers = new Dictionary<string, Func<string, string, string>>(StringComparer.OrdinalIgnoreCase);

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

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

		private readonly ScriptHost _host;

		private readonly string _appId;

		public JsStorage Storage { get; }

		public string AppId => _appId;

		public string Orientation
		{
			get
			{
				AppRegistration appRegistration = Registry.Find(_appId);
				if (appRegistration == null || !appRegistration.Portrait)
				{
					return "landscape";
				}
				return "portrait";
			}
		}

		internal Bridge(ScriptHost host, string appId)
		{
			_host = host;
			_appId = appId;
			Storage = new JsStorage(appId);
		}

		internal static void Handle(string appId, string name, Func<string, string, string> handler)
		{
			if (!string.IsNullOrWhiteSpace(name) && handler != null)
			{
				_handlers[Key(appId, name)] = handler;
			}
		}

		internal static void Emit(string appId, string name, string payload)
		{
			if (string.IsNullOrWhiteSpace(name) || !_subscribers.TryGetValue(name, out var value))
			{
				return;
			}
			Bridge[] array = value.ToArray();
			foreach (Bridge bridge in array)
			{
				if (appId == null || string.Equals(bridge._appId, appId, StringComparison.OrdinalIgnoreCase))
				{
					bridge.Deliver(name, payload ?? "");
				}
			}
		}

		private static string Key(string appId, string name)
		{
			return appId + "\0" + name.Trim();
		}

		public string Call(string name, string argument = "")
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				return "";
			}
			if (!_handlers.TryGetValue(Key(_appId, name), out var value) && !_handlers.TryGetValue(Key(null, name), out value))
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning($"[Sideload] {_appId}: s1.call('{name}') has no handler.");
				}
				return "";
			}
			try
			{
				return value(_appId, argument ?? "") ?? "";
			}
			catch (Exception ex)
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Error($"[Sideload] {_appId}: s1.call('{name}') threw: {ex.Message}");
				}
				return "";
			}
		}

		public void On(string name, JsValue handler)
		{
			if (!string.IsNullOrWhiteSpace(name) && !(handler == (JsValue)null) && JsValueExtensions.IsObject(handler))
			{
				if (!_listeners.TryGetValue(name, out var value))
				{
					value = (_listeners[name] = new List<JsValue>());
				}
				value.Add(handler);
				if (!_subscribers.TryGetValue(name, out var value2))
				{
					value2 = (_subscribers[name] = new List<Bridge>());
				}
				if (!value2.Contains(this))
				{
					value2.Add(this);
				}
			}
		}

		public void Log(params object[] args)
		{
			Instance log = Core.Log;
			if (log != null)
			{
				log.Msg("[" + _appId + "] " + string.Join(" ", Array.ConvertAll(args ?? Array.Empty<object>(), (object a) => a?.ToString() ?? "null")));
			}
		}

		public void SetOrientation(string orientation)
		{
			Registry.SetOrientation(_appId, orientation);
		}

		internal void Dispose()
		{
			foreach (KeyValuePair<string, List<Bridge>> subscriber in _subscribers)
			{
				subscriber.Value.Remove(this);
			}
			_listeners.Clear();
		}

		private void Deliver(string name, string payload)
		{
			if (!_listeners.TryGetValue(name, out var value))
			{
				return;
			}
			JsValue[] array = value.ToArray();
			foreach (JsValue val in array)
			{
				try
				{
					_host.Engine.Invoke(val, new object[1] { payload });
				}
				catch (Exception ex)
				{
					Instance log = Core.Log;
					if (log != null)
					{
						log.Error($"[Sideload] {_appId}: s1.on('{name}') handler failed: {ex.Message}");
					}
				}
			}
		}
	}
	public sealed class JsElement
	{
		private readonly ScriptHost _host;

		internal IElement Native { get; }

		public string TagName => Native.LocalName;

		public string Id
		{
			get
			{
				return Native.Id ?? "";
			}
			set
			{
				if (Set(Native.Id, value))
				{
					Native.Id = value;
					_host.MarkDirty();
				}
			}
		}

		public string ClassName
		{
			get
			{
				return Native.ClassName ?? "";
			}
			set
			{
				if (Set(Native.ClassName, value))
				{
					Native.ClassName = value;
					_host.MarkDirty();
				}
			}
		}

		public JsClassList ClassList => new JsClassList(_host, Native);

		public JsStyle Style => new JsStyle(_host, Native);

		public string TextContent
		{
			get
			{
				return ((INode)Native).TextContent ?? "";
			}
			set
			{
				if (Set(((INode)Native).TextContent, value))
				{
					((INode)Native).TextContent = value;
					_host.MarkDirty();
				}
			}
		}

		public string InnerHTML
		{
			get
			{
				return Native.InnerHtml ?? "";
			}
			set
			{
				if (!Set(Native.InnerHtml, value))
				{
					return;
				}
				foreach (IElement item in (IEnumerable<IElement>)((IParentNode)Native).Children)
				{
					_host.Forget(item);
				}
				Native.InnerHtml = value;
				_host.MarkDirty();
			}
		}

		public string Value
		{
			get
			{
				return Native.GetAttribute("value") ?? "";
			}
			set
			{
				if (Set(Native.GetAttribute("value"), value))
				{
					Native.SetAttribute("value", value ?? "");
					_host.MarkDirty();
				}
			}
		}

		public bool Disabled
		{
			get
			{
				return Native.HasAttribute("disabled");
			}
			set
			{
				if (value)
				{
					Native.SetAttribute("disabled", "");
				}
				else
				{
					Native.RemoveAttribute("disabled");
				}
				_host.MarkDirty();
			}
		}

		public JsElement ParentElement => _host.Wrap(((INode)Native).ParentElement);

		public JsValue Children
		{
			get
			{
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Expected O, but got Unknown
				List<JsValue> list = new List<JsValue>();
				foreach (IElement item in (IEnumerable<IElement>)((IParentNode)Native).Children)
				{
					list.Add(JsValue.FromObject(_host.Engine, (object)_host.Wrap(item)));
				}
				return (JsValue)new JsArray(_host.Engine, list.ToArray());
			}
		}

		internal JsElement(ScriptHost host, IElement element)
		{
			_host = host;
			Native = element;
		}

		public string GetAttribute(string name)
		{
			return Native.GetAttribute(name);
		}

		public void SetAttribute(string name, string value)
		{
			if (Set(Native.GetAttribute(name), value))
			{
				Native.SetAttribute(name, value ?? "");
				_host.MarkDirty();
			}
		}

		public void RemoveAttribute(string name)
		{
			if (Native.HasAttribute(name))
			{
				Native.RemoveAttribute(name);
				_host.MarkDirty();
			}
		}

		public bool HasAttribute(string name)
		{
			return Native.HasAttribute(name);
		}

		public JsElement QuerySelector(string selector)
		{
			return _host.Wrap(((IParentNode)Native).QuerySelector(selector));
		}

		public JsValue QuerySelectorAll(string selector)
		{
			return _host.WrapAll((IEnumerable<IElement>)((IParentNode)Native).QuerySelectorAll(selector));
		}

		public JsElement AppendChild(JsElement child)
		{
			if (child != null)
			{
				((INode)Native).AppendChild((INode)(object)child.Native);
				_host.MarkDirty();
			}
			return child;
		}

		public JsElement RemoveChild(JsElement child)
		{
			if (child == null)
			{
				return null;
			}
			((INode)Native).RemoveChild((INode)(object)child.Native);
			_host.Forget(child.Native);
			_host.MarkDirty();
			return child;
		}

		public JsElement InsertBefore(JsElement child, JsElement reference)
		{
			if (child == null)
			{
				return null;
			}
			((INode)Native).InsertBefore((INode)(object)child.Native, (INode)(object)reference?.Native);
			_host.MarkDirty();
			return child;
		}

		public void Remove()
		{
			((IChildNode)Native).Remove();
			_host.Forget(Native);
			_host.MarkDirty();
		}

		public void ReplaceChildren()
		{
			foreach (IElement item in (IEnumerable<IElement>)((IParentNode)Native).Children)
			{
				_host.Forget(item);
			}
			Native.InnerHtml = "";
			_host.MarkDirty();
		}

		public void AddEventListener(string type, JsValue handler)
		{
			_host.AddListener(Native, type, handler);
		}

		public void RemoveEventListener(string type, JsValue handler)
		{
			_host.RemoveListener(Native, type, handler);
		}

		public void Click()
		{
			_host.Dispatch(Native, "click");
		}

		public void Focus()
		{
			_host.RequestFocus(Native);
		}

		public void ScrollToEnd()
		{
			_host.RequestScrollToEnd(Native);
		}

		public override string ToString()
		{
			return "<" + Native.LocalName + ">";
		}

		private static bool Set(string current, string next)
		{
			return !string.Equals(current ?? "", next ?? "", StringComparison.Ordinal);
		}
	}
	public sealed class JsClassList
	{
		private readonly ScriptHost _host;

		private readonly IElement _element;

		public int Length => _element.ClassList.Length;

		internal JsClassList(ScriptHost host, IElement element)
		{
			_host = host;
			_element = element;
		}

		public bool Contains(string name)
		{
			return _element.ClassList.Contains(name);
		}

		public void Add(string name)
		{
			_element.ClassList.Add(new string[1] { name });
			_host.MarkDirty();
		}

		public void Remove(string name)
		{
			_element.ClassList.Remove(new string[1] { name });
			_host.MarkDirty();
		}

		public bool Toggle(string name)
		{
			bool flag = !_element.ClassList.Contains(name);
			if (flag)
			{
				_element.ClassList.Add(new string[1] { name });
			}
			else
			{
				_element.ClassList.Remove(new string[1] { name });
			}
			_host.MarkDirty();
			return flag;
		}
	}
	public sealed class JsStyle : ObjectInstance
	{
		private const string Attribute = "style";

		private readonly ScriptHost _host;

		private readonly IElement _element;

		internal JsStyle(ScriptHost host, IElement element)
			: base(host.Engine)
		{
			_host = host;
			_element = element;
		}

		public override JsValue Get(JsValue property, JsValue receiver)
		{
			string text = (JsValueExtensions.IsString(property) ? JsValueExtensions.AsString(property) : null);
			if (text == null)
			{
				return JsValue.Undefined;
			}
			if (text == "cssText")
			{
				return JsValue.op_Implicit(_element.GetAttribute("style") ?? "");
			}
			string text2 = Read(Kebab(text));
			if (text2 == null)
			{
				return JsValue.op_Implicit("");
			}
			return JsValue.op_Implicit(text2);
		}

		public override bool Set(JsValue property, JsValue value, JsValue receiver)
		{
			if (!JsValueExtensions.IsString(property))
			{
				return false;
			}
			string text = JsValueExtensions.AsString(property);
			string text2 = ((JsValueExtensions.IsNull(value) || JsValueExtensions.IsUndefined(value)) ? "" : ((object)value).ToString());
			string text3 = ((text == "cssText") ? null : Kebab(text));
			if (string.Equals(((text3 == null) ? _element.GetAttribute("style") : Read(text3)) ?? "", text2, StringComparison.Ordinal))
			{
				return true;
			}
			Write(text3, text2);
			_host.MarkDirty();
			return true;
		}

		public override bool HasProperty(JsValue property)
		{
			if (JsValueExtensions.IsString(property))
			{
				if (!(JsValueExtensions.AsString(property) == "cssText"))
				{
					return Read(Kebab(JsValueExtensions.AsString(property))) != null;
				}
				return true;
			}
			return false;
		}

		private string Read(string property)
		{
			foreach (Declaration item in CssParser.ParseDeclarations(_element.GetAttribute("style") ?? ""))
			{
				if (string.Equals(item.Property, property, StringComparison.OrdinalIgnoreCase))
				{
					return item.Value;
				}
			}
			return null;
		}

		private void Write(string property, string value)
		{
			if (property == null)
			{
				_element.SetAttribute("style", value);
				return;
			}
			List<string> list = new List<string>();
			foreach (Declaration item in CssParser.ParseDeclarations(_element.GetAttribute("style") ?? ""))
			{
				if (!string.Equals(item.Property, property, StringComparison.OrdinalIgnoreCase))
				{
					list.Add(item.Property + ": " + item.Value);
				}
			}
			if (!string.IsNullOrEmpty(value))
			{
				list.Add(property + ": " + value);
			}
			_element.SetAttribute("style", string.Join("; ", list));
		}

		private static string Kebab(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return name;
			}
			StringBuilder stringBuilder = new StringBuilder(name.Length + 4);
			foreach (char c in name)
			{
				if (char.IsUpper(c))
				{
					stringBuilder.Append('-');
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
				else
				{
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString();
		}
	}
	public sealed class JsDocument
	{
		private readonly ScriptHost _host;

		private readonly IDocument _document;

		public JsElement Body
		{
			get
			{
				ScriptHost host = _host;
				IElement body = (IElement)(object)_document.Body;
				return host.Wrap(body ?? _document.DocumentElement);
			}
		}

		internal JsDocument(ScriptHost host, IDocument document)
		{
			_host = host;
			_document = document;
		}

		public JsElement GetElementById(string id)
		{
			return _host.Wrap(((INonElementParentNode)_document).GetElementById(id));
		}

		public JsElement QuerySelector(string selector)
		{
			return _host.Wrap(((IParentNode)_document).QuerySelector(selector));
		}

		public JsValue QuerySelectorAll(string selector)
		{
			return _host.WrapAll((IEnumerable<IElement>)((IParentNode)_document).QuerySelectorAll(selector));
		}

		public JsElement CreateElement(string tag)
		{
			return _host.Wrap(_document.CreateElement(tag));
		}

		public void AddEventListener(string type, JsValue handler)
		{
			ScriptHost host = _host;
			IElement body = (IElement)(object)_document.Body;
			host.AddListener(body ?? _document.DocumentElement, type, handler);
		}
	}
	public sealed class JsEvent
	{
		public string Type { get; }

		public JsElement Target { get; }

		public JsElement CurrentTarget { get; internal set; }

		public string Value { get; internal set; } = "";

		public string Key { get; internal set; } = "";

		public string Source { get; internal set; } = "";

		public bool DefaultPrevented { get; private set; }

		internal bool PropagationStopped { get; private set; }

		internal JsEvent(string type, JsElement target)
		{
			Type = type;
			Target = target;
			CurrentTarget = target;
		}

		public void PreventDefault()
		{
			DefaultPrevented = true;
		}

		public void StopPropagation()
		{
			PropagationStopped = true;
		}
	}
	internal sealed class FetchApi
	{
		private const int MaxInFlight = 8;

		private const string ResponseFactory = "(function (status, statusText, url, headerLines, body, redirected) {\n  var map = {};\n  var lines = headerLines ? headerLines.split('\\n') : [];\n  for (var i = 0; i < lines.length; i++) {\n    var at = lines[i].indexOf(':');\n    if (at > 0) map[lines[i].substring(0, at).trim().toLowerCase()] = lines[i].substring(at + 1).trim();\n  }\n\n  return {\n    ok: status >= 200 && status < 300,\n    status: status,\n    statusText: statusText,\n    url: url,\n    redirected: redirected,\n    headers: {\n      get: function (name) { var k = String(name).toLowerCase(); return k in map ? map[k] : null; },\n      has: function (name) { return String(name).toLowerCase() in map; }\n    },\n    // Already-settled promises: the body was read before the page was handed the response, so these match the web's\n    // shape without ever being pending.\n    text: function () { return Promise.resolve(body); },\n    json: function () {\n      try { return Promise.resolve(JSON.parse(body)); }\n      catch (e) { return Promise.reject(e); }\n    }\n  };\n})";

		private const string Wrapper = "(function (call) {\n  return function fetch(url, init) {\n    return call(url === undefined || url === null ? '' : String(url), init);\n  };\n})";

		private readonly ConcurrentQueue<Action> _finished = new ConcurrentQueue<Action>();

		private readonly Engine _engine;

		private readonly Promises _promises;

		private readonly Action<string> _onError;

		private readonly string _appId;

		private JsValue _responseFactory;

		private int _inFlight;

		internal int Ready => _finished.Count;

		internal FetchApi(Engine engine, string appId, Promises promises, Action<string> onError)
		{
			_engine = engine;
			_appId = appId ?? "";
			_promises = promises;
			_onError = onError;
		}

		internal void Install()
		{
			_responseFactory = _engine.Evaluate("(function (status, statusText, url, headerLines, body, redirected) {\n  var map = {};\n  var lines = headerLines ? headerLines.split('\\n') : [];\n  for (var i = 0; i < lines.length; i++) {\n    var at = lines[i].indexOf(':');\n    if (at > 0) map[lines[i].substring(0, at).trim().toLowerCase()] = lines[i].substring(at + 1).trim();\n  }\n\n  return {\n    ok: status >= 200 && status < 300,\n    status: status,\n    statusText: statusText,\n    url: url,\n    redirected: redirected,\n    headers: {\n      get: function (name) { var k = String(name).toLowerCase(); return k in map ? map[k] : null; },\n      has: function (name) { return String(name).toLowerCase() in map; }\n    },\n    // Already-settled promises: the body was read before the page was handed the response, so these match the web's\n    // shape without ever being pending.\n    text: function () { return Promise.resolve(body); },\n    json: function () {\n      try { return Promise.resolve(JSON.parse(body)); }\n      catch (e) { return Promise.reject(e); }\n    }\n  };\n})", (string)null);
			JsValue val = JsValue.FromObject(_engine, (object)new Func<string, JsValue, JsValue>(Call));
			_engine.SetValue("fetch", _engine.Invoke(_engine.Evaluate("(function (call) {\n  return function fetch(url, init) {\n    return call(url === undefined || url === null ? '' : String(url), init);\n  };\n})", (string)null), new object[1] { val }));
		}

		internal void Settle()
		{
			Action result;
			while (_finished.TryDequeue(out result))
			{
				try
				{
					result();
				}
				catch (Exception ex)
				{
					_onError?.Invoke("settling a fetch failed: " + ex.Message);
				}
			}
		}

		private JsValue Call(string url, JsValue init)
		{
			Deferred deferred = _promises.Create();
			FetchCall fetchCall = new FetchCall
			{
				AppId = _appId
			};
			if (!Uri.TryCreate(url, UriKind.Absolute, out Uri result))
			{
				Later(delegate
				{
					deferred.Reject("fetch needs an absolute http(s) URL - got '" + Trim(url) + "'.");
				});
				return deferred.Promise;
			}
			fetchCall.Url = result;
			try
			{
				ReadInit(init, fetchCall);
			}
			catch (Exception ex)
			{
				Exception ex2 = ex;
				Exception e = ex2;
				Later(delegate
				{
					deferred.Reject("the second argument to fetch is not usable: " + e.Message);
				});
				return deferred.Promise;
			}
			if (!HostAllowlist.Allows(_appId, result, out var reason))
			{
				HostAllowlist.ReportOnce(_appId, result, reason);
				Later(delegate
				{
					deferred.Reject(reason);
				});
				return deferred.Promise;
			}
			if (_inFlight >= 8)
			{
				Later(delegate
				{
					deferred.Reject($"too many requests at once - this app already has {8} " + "fetches in flight. Wait for one to settle before starting another.");
				});
				return deferred.Promise;
			}
			_inFlight++;
			Fetcher.Send(fetchCall, delegate(FetchOutcome outcome)
			{
				_finished.Enqueue(delegate
				{
					_inFlight--;
					if (outcome.Failed)
					{
						deferred.Reject(outcome.Error);
					}
					else
					{
						deferred.Resolve(Response(outcome));
					}
				});
			});
			return deferred.Promise;
		}

		private void Later(Action settle)
		{
			_finished.Enqueue(settle);
		}

		private JsValue Response(FetchOutcome outcome)
		{
			return _engine.Invoke(_responseFactory, new object[6] { outcome.Status, outcome.StatusText, outcome.Url, outcome.HeaderLines, outcome.Body, outcome.Redirected });
		}

		private static void ReadInit(JsValue init, FetchCall call)
		{
			if (init == (JsValue)null || JsValueExtensions.IsUndefined(init) || JsValueExtensions.IsNull(init) || !JsValueExtensions.IsObject(init))
			{
				return;
			}
			ObjectInstance obj = JsValueExtensions.AsObject(init);
			JsValue val = ((JsValue)obj).Get(JsValue.op_Implicit("method"));
			if (!JsValueExtensions.IsUndefined(val) && !JsValueExtensions.IsNull(val))
			{
				call.Method = ((object)val).ToString();
			}
			JsValue val2 = ((JsValue)obj).Get(JsValue.op_Implicit("body"));
			if (!JsValueExtensions.IsUndefined(val2) && !JsValueExtensions.IsNull(val2))
			{
				call.Body = ((object)val2).ToString();
			}
			JsValue val3 = ((JsValue)obj).Get(JsValue.op_Implicit("timeout"));
			if (JsValueExtensions.IsNumber(val3))
			{
				call.TimeoutMs = (int)JsValueExtensions.AsNumber(val3);
			}
			JsValue val4 = ((JsValue)obj).Get(JsValue.op_Implicit("headers"));
			if (!JsValueExtensions.IsObject(val4))
			{
				return;
			}
			ObjectInstance val5 = JsValueExtensions.AsObject(val4);
			foreach (KeyValuePair<JsValue, PropertyDescriptor> ownProperty in val5.GetOwnProperties())
			{
				JsValue val6 = ((JsValue)val5).Get(ownProperty.Key);
				if (!JsValueExtensions.IsUndefined(val6) && !JsValueExtensions.IsNull(val6))
				{
					call.Headers.Add(new KeyValuePair<string, string>(((object)ownProperty.Key).ToString(), ((object)val6).ToString()));
				}
			}
		}

		private static string Trim(string url)
		{
			string text;
			if (url == null || url.Length <= 80)
			{
				text = url;
				if (text == null)
				{
					return "";
				}
			}
			else
			{
				text = url.Substring(0, 80) + "...";
			}
			return text;
		}
	}
	internal static class MiniJson
	{
		internal static string WriteObject(Dictionary<string, string> values)
		{
			if (values == null || values.Count == 0)
			{
				return "{}";
			}
			StringBuilder stringBuilder = new StringBuilder("{");
			bool flag = true;
			foreach (KeyValuePair<string, string> value in values)
			{
				if (!flag)
				{
					stringBuilder.Append(',');
				}
				flag = false;
				stringBuilder.Append('\n').Append("  ");
				Escape(stringBuilder, value.Key);
				stringBuilder.Append(": ");
				Escape(stringBuilder, value.Value);
			}
			return stringBuilder.Append("\n}").ToString();
		}

		internal static Dictionary<string, string> ParseObject(string json)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal);
			if (string.IsNullOrWhiteSpace(json))
			{
				return dictionary;
			}
			int i = 0;
			SkipWhitespace(json, ref i);
			if (i >= json.Length || json[i] != '{')
			{
				return dictionary;
			}
			i++;
			while (true)
			{
				SkipWhitespace(json, ref i);
				if (i >= json.Length || json[i] == '}')
				{
					break;
				}
				if (json[i] == ',')
				{
					i++;
					continue;
				}
				if (json[i] != '"')
				{
					break;
				}
				string key = ReadString(json, ref i);
				SkipWhitespace(json, ref i);
				if (i >= json.Length || json[i] != ':')
				{
					break;
				}
				i++;
				SkipWhitespace(json, ref i);
				if (i >= json.Length)
				{
					break;
				}
				dictionary[key] = ((json[i] == '"') ? ReadString(json, ref i) : ReadBareValue(json, ref i));
			}
			return dictionary;
		}

		private static void Escape(StringBuilder sb, string value)
		{
			sb.Append('"');
			string text = value ?? "";
			foreach (char c in text)
			{
				switch (c)
				{
				case '"':
					sb.Append("\\\"");
					continue;
				case '\\':
					sb.Append("\\\\");
					continue;
				case '\n':
					sb.Append("\\n");
					continue;
				case '\r':
					sb.Append("\\r");
					continue;
				case '\t':
					sb.Append("\\t");
					continue;
				}
				if (c < ' ')
				{
					StringBuilder stringBuilder = sb.Append("\\u");
					int num = c;
					stringBuilder.Append(num.ToString("x4"));
				}
				else
				{
					sb.Append(c);
				}
			}
			sb.Append('"');
		}

		private static string ReadString(string json, ref int i)
		{
			StringBuilder stringBuilder = new StringBuilder();
			i++;
			while (i < json.Length)
			{
				char c = json[i++];
				switch (c)
				{
				default:
					stringBuilder.Append(c);
					continue;
				case '\\':
				{
					if (i >= json.Length)
					{
						break;
					}
					char c2 = json[i++];
					switch (c2)
					{
					case 'n':
						stringBuilder.Append('\n');
						break;
					case 'r':
						stringBuilder.Append('\r');
						break;
					case 't':
						stringBuilder.Append('\t');
						break;
					case 'b':
						stringBuilder.Append('\b');
						break;
					case 'f':
						stringBuilder.Append('\f');
						break;
					case 'u':
					{
						if (i + 4 <= json.Length && int.TryParse(json.Substring(i, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result))
						{
							stringBuilder.Append((char)result);
							i += 4;
						}
						break;
					}
					default:
						stringBuilder.Append(c2);
						break;
					}
					continue;
				}
				case '"':
					break;
				}
				break;
			}
			return stringBuilder.ToString();
		}

		private static string ReadBareValue(string json, ref int i)
		{
			int num = i;
			while (i < json.Length && json[i] != ',' && json[i] != '}')
			{
				i++;
			}
			return json.Substring(num, i - num).Trim();
		}

		private static void SkipWhitespace(string json, ref int i)
		{
			while (i < json.Length && char.IsWhiteSpace(json[i]))
			{
				i++;
			}
		}
	}
	internal sealed class Promises
	{
		private const string Factory = "(function (report) {\n  var settle, fail;\n  var root = new Promise(function (ok, no) { settle = ok; fail = no; });\n\n  function watch(p) {\n    var chained = false;\n    var then = p.then.bind(p);\n\n    p.then    = function (ok, no) { chained = true; return watch(then(ok, no)); };\n    p.catch   = function (no)     { chained = true; return watch(then(undefined, no)); };\n    p.finally = function (fn)     { chained = true; return watch(then(\n                                      function (v) { fn(); return v; },\n                                      function (e) { fn(); throw e; })); };\n\n    then(undefined, function (err) {\n      if (!chained) report(String(err && err.message ? err.message : err));\n    });\n    return p;\n  }\n\n  return {\n    promise: watch(root),\n    resolve: settle,\n    reject: function (message) { fail(new Error(message)); }\n  };\n})";

		private readonly Engine _engine;

		private readonly JsValue _factory;

		private readonly JsValue _report;

		internal Promises(Engine engine, Action<string> onUnhandledRejection)
		{
			_engine = engine;
			_factory = engine.Evaluate("(function (report) {\n  var settle, fail;\n  var root = new Promise(function (ok, no) { settle = ok; fail = no; });\n\n  function watch(p) {\n    var chained = false;\n    var then = p.then.bind(p);\n\n    p.then    = function (ok, no) { chained = true; return watch(then(ok, no)); };\n    p.catch   = function (no)     { chained = true; return watch(then(undefined, no)); };\n    p.finally = function (fn)     { chained = true; return watch(then(\n                                      function (v) { fn(); return v; },\n                                      function (e) { fn(); throw e; })); };\n\n    then(undefined, function (err) {\n      if (!chained) report(String(err && err.message ? err.message : err));\n    });\n    return p;\n  }\n\n  return {\n    promise: watch(root),\n    resolve: settle,\n    reject: function (message) { fail(new Error(message)); }\n  };\n})", (string)null);
			_report = JsValue.FromObject(engine, (object)(Action<string>)delegate(string m)
			{
				onUnhandledRejection?.Invoke(m);
			});
		}

		internal Deferred Create()
		{
			ObjectInstance val = JsValueExtensions.AsObject(_engine.Invoke(_factory, new object[1] { _report }));
			return new Deferred(_engine, ((JsValue)val).Get(JsValue.op_Implicit("promise")), ((JsValue)val).Get(JsValue.op_Implicit("resolve")), ((JsValue)val).Get(JsValue.op_Implicit("reject")));
		}

		internal void Pump()
		{
			_engine.Constraints.Reset();
			_engine.Advanced.ProcessTasks();
		}
	}
	internal sealed class Deferred
	{
		private readonly Engine _engine;

		private readonly JsValue _resolve;

		private readonly JsValue _reject;

		internal JsValue Promise { get; }

		internal Deferred(Engine engine, JsValue promise, JsValue resolve, JsValue reject)
		{
			_engine = engine;
			Promise = promise;
			_resolve = resolve;
			_reject = reject;
		}

		internal void Resolve(JsValue value)
		{
			_engine.Invoke(_resolve, new object[1] { value ?? JsValue.Undefined });
		}

		internal void Reject(string message)
		{
			_engine.Invoke(_reject, new object[1] { message ?? "" });
		}
	}
	internal sealed class ScriptHost
	{
		private sealed class Timer
		{
			internal int Id;

			internal JsValue Callback;

			internal double Remaining;

			internal double Interval;

			internal bool Cancelled;
		}

		public sealed class Console
		{
			private readonly string _appId;

			internal Console(string appId)
			{
				_appId = appId;
			}

			public void Log(params object[] args)
			{
				Emit("log", args);
			}

			public void Info(params object[] args)
			{
				Emit("info", args);
			}

			public void Warn(params object[] args)
			{
				Emit("warn", args);
			}

			public void Error(params object[] args)
			{
				Emit("error", args);
			}

			private void Emit(string level, object[] args)
			{
				string text = Format(args);
				if (!(level == "warn"))
				{
					if (level == "error")
					{
						Instance log = Core.Log;
						if (log != null)
						{
							log.Error(text);
						}
					}
					else
					{
						Instance log2 = Core.Log;
						if (log2 != null)
						{
							log2.Msg(text);
						}
					}
				}
				else
				{
					Instance log3 = Core.Log;
					if (log3 != null)
					{
						log3.Warning(text);
					}
				}
				Diagnostics?.Invoke(_appId, level, args, text);
			}

			private string Format(object[] args)
			{
				if (args == null || args.Length == 0)
				{
					return "[" + _appId + "]";
				}
				return "[" + _appId + "] " + string.Join(" ", Array.ConvertAll(args, (object a) => a?.ToString() ?? "null"));
			}
		}

		private static readonly TimeSpan Budget = TimeSpan.FromMilliseconds(250.0);

		internal static Action<string, string, object[], string> Diagnostics;

		private readonly Dictionary<IElement, Dictionary<string, List<JsValue>>> _listeners = new Dictionary<IElement, Dictionary<string, List<JsValue>>>();

		private readonly Dictionary<IElement, JsElement> _wrappers = new Dictionary<IElement, JsElement>();

		private readonly List<Timer> _timers = new List<Timer>();

		private readonly string _appId;

		private Promises _promises;

		private FetchApi _fetch;

		private IDocument _document;

		private Bridge _bridge;

		private int _nextTimerId = 1;

		private bool _failed;

		internal Engine Engine { get; }

		internal Action OnDomChanged { get; }

		internal Action<IElement> OnFocusRequested { get; }

		internal Action<IElement> OnScrollToEnd { get; }

		internal bool Failed => _failed;

		internal string LastError { get; private set; } = "";

		internal ScriptHost(string appId, IDocument document, Action onDomChanged, Action<IElement> onFocusRequested, Action<IElement> onScrollToEnd)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			_appId = appId;
			_document = document;
			OnDomChanged = onDomChanged;
			OnFocusRequested = onFocusRequested;
			OnScrollToEnd = onScrollToEnd;
			Engine = new Engine((Action<Options>)delegate(Options options)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				ConstraintsOptionsExtensions.TimeoutInterval(options, Budget);
				ConstraintsOptionsExtensions.MaxStatements(options, 2000000);
				OptionsExtensions.LimitRecursion(options, 256);
				options.Strict = false;
				options.ExperimentalFeatures = (ExperimentalFeature)3;
				OptionsExtensions.SetTypeResolver(options, new TypeResolver
				{
					MemberNameCreator = BothCasings
				});
			});
			Bind();
		}

		internal void Rebound(IDocument document)
		{
			_document = document;
			_wrappers.Clear();
			Engine.SetValue<JsDocument>("document", new JsDocument(this, _document));
		}

		internal void Dispose()
		{
			_bridge?.Dispose();
			_listeners.Clear();
			_wrappers.Clear();
			_timers.Clear();
		}

		internal void Forget(IElement element)
		{
			if (element == null)
			{
				return;
			}
			_wrappers.Remove(element);
			_listeners.Remove(element);
			foreach (IElement item in (IEnumerable<IElement>)((IParentNode)element).Children)
			{
				Forget(item);
			}
		}

		internal void MarkDirty()
		{
			OnDomChanged?.Invoke();
		}

		internal void RequestFocus(IElement element)
		{
			OnFocusRequested?.Invoke(element);
		}

		internal void RequestScrollToEnd(IElement element)
		{
			OnScrollToEnd?.Invoke(element);
		}

		internal JsElement Wrap(IElement element)
		{
			if (element == null)
			{
				return null;
			}
			if (_wrappers.TryGetValue(element, out var value))
			{
				return value;
			}
			JsElement jsElement = new JsElement(this, element);
			_wrappers[element] = jsElement;
			return jsElement;
		}

		internal JsValue WrapAll(IEnumerable<IElement> elements)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			List<JsValue> list = new List<JsValue>();
			if (elements != null)
			{
				foreach (IElement element in elements)
				{
					list.Add(JsValue.FromObject(Engine, (object)Wrap(element)));
				}
			}
			return (JsValue)new JsArray(Engine, list.ToArray());
		}

		internal void Run(string source, string fileName)
		{
			if (string.IsNullOrWhiteSpace(source))
			{
				return;
			}
			WarnAboutAwaitedFetch(source, fileName);
			try
			{
				Engine.Execute(source, fileName);
				Instance log = Core.Log;
				if (log != null)
				{
					log.Msg($"[Sideload] {fileName} executed ({source.Length} chars).");
				}
			}
			catch (Exception e)
			{
				_failed = true;
				LastError = Describe(e);
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Error("[Sideload] " + fileName + " failed: " + LastError);
				}
				Diagnostics?.Invoke(_appId, "exception", null, fileName + ": " + LastError);
			}
		}

		private static void WarnAboutAwaitedFetch(string source, string fileName)
		{
			if (source.IndexOf("fetch(", StringComparison.Ordinal) >= 0 && Regex.IsMatch(source, "\bawait\b"))
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] " + fileName + " uses both `await` and `fetch(`. Awaiting a PENDING promise freezes the game on this engine - it blocks the main thread that would settle it. Use `fetch(url).then(res => ...)` instead. Awaiting an already-settled promise, such as `res.text()`, is safe.");
				}
			}
		}

		internal string Evaluate(string source, out bool failed)
		{
			failed = false;
			if (string.IsNullOrWhiteSpace(source))
			{
				return "";
			}
			try
			{
				JsValue val = Engine.Evaluate(source, (string)null);
				return JsValueExtensions.IsUndefined(val) ? "undefined" : Describe(val);
			}
			catch (Exception e)
			{
				failed = true;
				LastError = Describe(e);
				return LastError;
			}
		}

		private string Describe(JsValue value)
		{
			try
			{
				if (JsValueExtensions.IsNull(value))
				{
					return "null";
				}
				if (JsValueExtensions.IsString(value) || JsValueExtensions.IsNumber(value) || JsValueExtensions.IsBoolean(value))
				{
					return ((object)value).ToString();
				}
				JsValue val = JsValueExtensions.Call(Engine.Evaluate("JSON.stringify", (string)null), JsValue.Undefined, value);
				return JsValueExtensions.IsUndefined(val) ? ((object)value).ToString() : JsValueExtensions.AsString(val);
			}
			catch
			{
				return ((object)value).ToString();
			}
		}

		internal void AddListener(IElement element, string type, JsValue handler)
		{
			if (element != null && !string.IsNullOrEmpty(type) && !(handler == (JsValue)null) && JsValueExtensions.IsObject(handler))
			{
				if (!_listeners.TryGetValue(element, out var value))
				{
					value = (_listeners[element] = new Dictionary<string, List<JsValue>>(StringComparer.OrdinalIgnoreCase));
				}
				if (!value.TryGetValue(type, out var value2))
				{
					value2 = (value[type] = new List<JsValue>());
				}
				value2.Add(handler);
			}
		}

		internal void RemoveListener(IElement element, string type, JsValue handler)
		{
			if (element != null && !(handler == (JsValue)null) && _listeners.TryGetValue(element, out var value) && value.TryGetValue(type, out var value2))
			{
				value2.RemoveAll((JsValue h) => h == handler || object.Equals(h, handler));
			}
		}

		internal IEnumerable<IElement> ElementsListeningFor(string type)
		{
			foreach (KeyValuePair<IElement, Dictionary<string, List<JsValue>>> listener in _listeners)
			{
				if (listener.Value.TryGetValue(type, out var value) && value.Count > 0)
				{
					yield return listener.Key;
				}
			}
		}

		internal JsEvent Dispatch(IElement target, string type, string value = "", string key = "", string source = "")
		{
			JsEvent jsEvent = new JsEvent(type, Wrap(target))
			{
				Value = (value ?? ""),
				Key = (key ?? ""),
				Source = (source ?? "")
			};
			if (_failed || target == null)
			{
				return jsEvent;
			}
			for (IElement val = target; val != null; val = ((INode)val).ParentElement)
			{
				if (_listeners.TryGetValue(val, out var value2) && value2.TryGetValue(type, out var value3) && value3.Count > 0)
				{
					jsEvent.CurrentTarget = Wrap(val);
					JsValue[] array = value3.ToArray();
					foreach (JsValue callback in array)
					{
						Invoke(callback, type + " handler on <" + val.LocalName + ">", JsValue.FromObject(Engine, (object)jsEvent));
						if (jsEvent.PropagationStopped)
						{
							return jsEvent;
						}
					}
				}
			}
			return jsEvent;
		}

		internal void Tick(float deltaSeconds)
		{
			if (_failed)
			{
				return;
			}
			try
			{
				_fetch?.Settle();
			}
			catch (Exception e)
			{
				Report("settling a fetch", e);
			}
			try
			{
				_promises?.Pump();
			}
			catch (Exception e2)
			{
				Report("a pending promise", e2);
			}
			if (_timers.Count == 0)
			{
				return;
			}
			double num = (double)deltaSeconds * 1000.0;
			Timer[] array = _timers.ToArray();
			foreach (Timer timer in array)
			{
				if (timer.Cancelled)
				{
					continue;
				}
				timer.Remaining -= num;
				if (!(timer.Remaining > 0.0))
				{
					if (timer.Interval > 0.0)
					{
						timer.Remaining += timer.Interval;
					}
					else
					{
						timer.Cancelled = true;
					}
					Invoke(timer.Callback, $"timer {timer.Id}");
				}
			}
			_timers.RemoveAll((Timer t) => t.Cancelled);
		}

		private int AddTimer(JsValue callback, double delayMs, bool repeating)
		{
			if (callback == (JsValue)null || !JsValueExtensions.IsObject(callback))
			{
				return 0;
			}
			Timer timer = new Timer
			{
				Id = _nextTimerId++,
				Callback = callback,
				Remaining = Math.Max(delayMs, 0.0),
				Interval = (repeating ? Math.Max(delayMs, 16.0) : 0.0)
			};
			_timers.Add(timer);
			return timer.Id;
		}

		private void ClearTimer(double id)
		{
			foreach (Timer timer in _timers)
			{
				if (timer.Id == (int)id)
				{
					timer.Cancelled = true;
				}
			}
		}

		private void Invoke(JsValue callback, string what, params JsValue[] args)
		{
			try
			{
				Engine.Invoke(callback, (object[])args);
			}
			catch (Exception e)
			{
				LastError = Describe(e);
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] " + what + " failed: " + LastError);
				}
				Diagnostics?.Invoke(_appId, "exception", null, what + " failed: " + LastError);
			}
		}

		private void Report(string what, Exception e)
		{
			LastError = Describe(e);
			Fault(what + " failed: " + LastError);
		}

		private void Fault(string line)
		{
			Instance log = Core.Log;
			if (log != null)
			{
				log.Error("[Sideload] [" + _appId + "] " + line);
			}
			Diagnostics?.Invoke(_appId, "error", null, "[" + _appId + "] " + line);
		}

		private void Bind()
		{
			Engine.SetValue<JsDocument>("document", new JsDocument(this, _document));
			_bridge = new Bridge(this, _appId);
			Engine.SetValue<Bridge>("s1", _bridge);
			Engine.SetValue<Console>("console", new Console(_appId));
			_promises = new Promises(Engine, delegate(string message)
			{
				Fault("unhandled promise rejection: " + message);
			});
			_fetch = new FetchApi(Engine, _appId, _promises, delegate(string line)
			{
				Fault(line);
			});
			_fetch.Install();
			Engine.SetValue<Func<JsValue, double, int>>("setTimeout", (Func<JsValue, double, int>)((JsValue fn, double ms) => AddTimer(fn, ms, repeating: false)));
			Engine.SetValue<Func<JsValue, double, int>>("setInterval", (Func<JsValue, double, int>)((JsValue fn, double ms) => AddTimer(fn, ms, repeating: true)));
			Engine.SetValue<Action<double>>("clearTimeout", (Action<double>)ClearTimer);
			Engine.SetValue<Action<double>>("clearInterval", (Action<double>)ClearTimer);
		}

		private static IEnumerable<string> BothCasings(MemberInfo member)
		{
			string name = member.Name;
			if (!string.IsNullOrEmpty(name))
			{
				string camel = (char.IsUpper(name[0]) ? (char.ToLowerInvariant(name[0]) + name.Substring(1)) : name);
				yield return camel;
				if (camel != name)
				{
					yield return name;
				}
			}
		}

		private static string Describe(Exception e)
		{
			JavaScriptException ex = (JavaScriptException)(object)((e is JavaScriptException) ? e : null);
			if (ex != null)
			{
				return $"{((Exception)(object)ex).Message} ({((Location)ex.Location).Source}:{((Location)ex.Location).Start.Line}:{((Location)ex.Location).Start.Column})";
			}
			ParserException ex2 = (ParserException)(object)((e is ParserException) ? e : null);
			if (ex2 != null)
			{
				return "syntax error: " + ((Exception)(object)ex2).Message;
			}
			return e.ToString();
		}
	}
}
namespace Sideload.Phone
{
	internal static class AppIconSprite
	{
		private const int Fallback = 128;

		internal static Sprite For(AppRegistration reg)
		{
			if ((Object)(object)reg.IconSprite != (Object)null)
			{
				return reg.IconSprite;
			}
			reg.IconSprite = FromBundle(reg) ?? Generated(reg.Id);
			return reg.IconSprite;
		}

		private static Sprite FromBundle(AppRegistration reg)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			byte[] array = reg.Bundle?.ReadBytes("icon.png");
			if (array == null || array.Length == 0)
			{
				return null;
			}
			try
			{
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					filterMode = (FilterMode)1
				};
				if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array)))
				{
					Instance log = Core.Log;
					if (log != null)
					{
						log.Warning("[Sideload] '" + reg.Id + "' has an icon.png that is not a readable PNG.");
					}
					return null;
				}
				return Finish(val);
			}
			catch (Exception ex)
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Warning("[Sideload] loading icon.png for '" + reg.Id + "' failed: " + ex.Message);
				}
				return null;
			}
		}

		private static Sprite Generated(string id)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			Color32 val = FromHue((float)(Hash(id) % 360) / 360f);
			Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1
			};
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					val2.SetPixel(j, i, Color32.op_Implicit(Inside((float)j + 0.5f, (float)i + 0.5f, 26f) ? val : val3));
				}
			}
			val2.Apply();
			return Finish(val2);
		}

		private static bool Inside(float x, float y, float r)
		{
			float num = Mathf.Clamp(x, r, 128f - r);
			float num2 = Mathf.Clamp(y, r, 128f - r);
			float num3 = x - num;
			float num4 = y - num2;
			return num3 * num3 + num4 * num4 <= r * r;
		}

		private static Sprite Finish(Texture2D tex)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			((Object)tex).hideFlags = (HideFlags)32;
			Sprite val = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 100f);
			if ((Object)(object)val != (Object)null)
			{
				((Object)val).hideFlags = (HideFlags)32;
			}
			return val;
		}

		private static int Hash(string s)
		{
			int num = 17;
			string text = s ?? "";
			foreach (char c in text)
			{
				num = (num * 31 + c) & 0x7FFFFFF;
			}
			return num;
		}

		private static Color32 FromHue(float h)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return Color32.op_Implicit(Color.HSVToRGB(h, 0.62f, 0.86f));
		}
	}
	[HarmonyPatch(typeof(HomeScreen), "Start")]
	internal static class HomeScreenPatch
	{
		private static readonly List<PhoneAppHost> _hosts = new List<PhoneAppHost>();

		private static HomeScreen _home;

		internal static IReadOnlyList<PhoneAppHost> Hosts => _hosts;

		internal static void LogIconRow()
		{
			if ((Object)(object)_home == (Object)null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload/probe] no HomeScreen to inspect.");
				}
				return;
			}
			Transform appIconContainer = (Transform)(object)_home.appIconContainer;
			if ((Object)(object)appIconContainer == (Object)null)
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Warning("[Sideload/probe] HomeScreen exposes no icon container.");
				}
				return;
			}
			List<string> list = new List<string>();
			for (int i = 0; i < appIconContainer.childCount; i++)
			{
				list.Add(((Object)appIconContainer.GetChild(i)).name);
			}
			Instance log3 = Core.Log;
			if (log3 != null)
			{
				log3.Msg($"[Sideload/probe] real AppIcons: {appIconContainer.childCount} child(ren) -> {string.Join(", ", list)}");
			}
		}

		private static void Postfix(HomeScreen __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			_home = __instance;
			Scene activeScene = SceneManager.GetActiveScene();
			if (!string.Equals(((Scene)(ref activeScene)).name, "Main", StringComparison.OrdinalIgnoreCase))
			{
				return;
			}
			if (_hosts.Count > 0 && _hosts[0].IsAlive)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Msg("[Sideload] apps are already live on a phone - skipping this second HomeScreen.");
				}
				return;
			}
			_hosts.Clear();
			if (Registry.Apps.Count == 0)
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Msg("[Sideload] no apps registered - nothing to put on the phone.");
				}
				return;
			}
			foreach (AppRegistration app in Registry.Apps)
			{
				try
				{
					PhoneAppHost phoneAppHost = PhoneAppHost.Spawn(__instance, app);
					if (phoneAppHost != null)
					{
						_hosts.Add(phoneAppHost);
					}
				}
				catch (Exception value)
				{
					Instance log3 = Core.Log;
					if (log3 != null)
					{
						log3.Error($"[Sideload] spawning '{app.Id}' failed: {value}");
					}
				}
			}
			Instance log4 = Core.Log;
			if (log4 != null)
			{
				log4.Msg($"[Sideload] {_hosts.Count}/{Registry.Apps.Count} app(s) live on the phone.");
			}
		}
	}
	internal static class OrientationStore
	{
		private static readonly Dictionary<string, bool> _portraitById = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);

		private static bool _loaded;

		private static string Path => System.IO.Path.Combine(MelonEnvironment.UserDataDirectory, "Sideload", "orientation.json");

		internal static bool? Remembered(AppRegistration reg)
		{
			if (reg == null)
			{
				return null;
			}
			Load();
			if (!_portraitById.TryGetValue(reg.Id, out var value))
			{
				return null;
			}
			if (!reg.Supports(value))
			{
				return null;
			}
			return value;
		}

		internal static void Remember(string appId, bool portrait)
		{
			if (!string.IsNullOrWhiteSpace(appId))
			{
				Load();
				if (!_portraitById.TryGetValue(appId, out var value) || value != portrait)
				{
					_portraitById[appId] = portrait;
					Save();
				}
			}
		}

		private static void Load()
		{
			if (_loaded)
			{
				return;
			}
			_loaded = true;
			try
			{
				if (!File.Exists(Path))
				{
					return;
				}
				foreach (KeyValuePair<string, string> item in MiniJson.ParseObject(File.ReadAllText(Path)))
				{
					_portraitById[item.Key] = string.Equals(item.Value, "portrait", StringComparison.OrdinalIgnoreCase);
				}
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] remembered orientations unreadable (" + Path + "): " + ex.Message);
				}
			}
		}

		private static void Save()
		{
			try
			{
				Directory.CreateDirectory(System.IO.Path.GetDirectoryName(Path) ?? ".");
				Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal);
				foreach (KeyValuePair<string, bool> item in _portraitById)
				{
					dictionary[item.Key] = (item.Value ? "portrait" : "landscape");
				}
				File.WriteAllText(Path, MiniJson.WriteObject(dictionary));
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] could not write remembered orientations: " + ex.Message);
				}
			}
		}
	}
	internal sealed class PhoneAppHost
	{
		private readonly AppRegistration _reg;

		private GameObject _panel;

		private GameObject _container;

		private GameObject _icon;

		private WebView _view;

		private Transform _appsCanvas;

		private Transform _badge;

		private Text _badgeText;

		private Action _closeAppsHandler;

		private ExitDelegate _exitHandler;

		internal string Id => _reg.Id;

		internal bool IsOpen
		{
			get
			{
				if ((Object)(object)_panel != (Object)null && _panel.activeInHierarchy)
				{
					return (Object)(object)Phone.ActiveApp == (Object)(object)_panel;
				}
				return false;
			}
		}

		internal bool IsShowing
		{
			get
			{
				if (IsOpen && PlayerSingleton<Phone>.InstanceExists)
				{
					return PlayerSingleton<Phone>.Instance.IsOpen;
				}
				return false;
			}
		}

		internal bool IsAlive => (Object)(object)_panel != (Object)null;

		internal bool CanTurn => _reg.CanTurn;

		private PhoneAppHost(AppRegistration reg)
		{
			_reg = reg;
		}

		internal static PhoneAppHost Spawn(HomeScreen home, AppRegistration reg)
		{
			PhoneAppHost phoneAppHost = new PhoneAppHost(reg);
			if (!phoneAppHost.Build(home))
			{
				return null;
			}
			return phoneAppHost;
		}

		private bool Build(HomeScreen home)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (((Object)(object)((Component)home).transform.parent != (Object)null) ? ((Component)home).transform.parent.Find("AppsCanvas") : null);
			if ((Object)(object)val == (Object)null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] AppsCanvas not found - '" + _reg.Id + "' not spawned.");
				}
				return false;
			}
			string text = "Sideload_" + _reg.Id;
			Transform val2 = val.Find(text);
			if ((Object)(object)val2 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val2).gameObject);
			}
			_appsCanvas = val;
			bool? flag = OrientationStore.Remembered(_reg);
			if (flag.HasValue)
			{
				_reg.Portrait = flag.Value;
			}
			_panel = new GameObject(text);
			((Transform)_panel.AddComponent<RectTransform>()).SetParent(val, false);
			if (!ApplyOrientation())
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Error("[Sideload] no vanilla app panel to measure - '" + _reg.Id + "' not spawned.");
				}
				return false;
			}
			_container = new GameObject("Container");
			RectTransform val3 = _container.AddComponent<RectTransform>();
			((Transform)val3).SetParent(_panel.transform, false);
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.pivot = new Vector2(0.5f, 0.5f);
			val3.anchoredPosition = Vector2.zero;
			val3.sizeDelta = Vector2.zero;
			_view = WebView.Mount(val3, _reg.Bundle, _reg.Id);
			_reg.OrientationChanged = OnOrientationChanged;
			_panel.SetActive(true);
			_container.SetActive(false);
			SpawnIcon(home);
			SubscribeShellEvents();
			Instance log3 = Core.Log;
			if (log3 != null)
			{
				log3.Msg("[Sideload] '" + _reg.Id + "' spawned on the phone.");
			}
			return true;
		}

		private bool ApplyOrientation()
		{
			if ((Object)(object)_panel == (Object)null || (Object)(object)_appsCanvas == (Object)null)
			{
				return false;
			}
			Transform val = FindPanelTemplate(_appsCanvas, _reg.Portrait) ?? FindPanelTemplate(_appsCanvas, !_reg.Portrait);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			CopyRect(((Component)val).GetComponent<RectTransform>(), _panel.GetComponent<RectTransform>());
			return true;
		}

		private static Transform FindPanelTemplate(Transform appsCanvas, bool portrait)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < appsCanvas.childCount; i++)
			{
				Transform child = appsCanvas.GetChild(i);
				if (((Object)child).name.StartsWith("Sideload_", StringComparison.Ordinal))
				{
					continue;
				}
				RectTransform component = ((Component)child).GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null))
				{
					Rect rect = component.rect;
					if (!(((Rect)(ref rect)).width < 1f) && !(((Rect)(ref rect)).height < 1f) && ((Rect)(ref rect)).height > ((Rect)(ref rect)).width == portrait)
					{
						return child;
					}
				}
			}
			return null;
		}

		private void OnOrientationChanged()
		{
			try
			{
				if (ApplyOrientation())
				{
					OrientationStore.Remember(_reg.Id, _reg.Portrait);
					if (IsOpen && PlayerSingleton<Phone>.InstanceExists)
					{
						PlayerSingleton<Phone>.Instance.SetIsHorizontal(!_reg.Portrait);
						PlayerSingleton<Phone>.Instance.SetLookOffsetMultiplier(_reg.Portrait ? 1f : 0.6f);
					}
					Canvas.ForceUpdateCanvases();
					_view?.QueueResize();
				}
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] turning '" + _reg.Id + "' failed: " + ex.Message);
				}
			}
		}

		private static void CopyRect(RectTransform from, RectTransform to)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)from == (Object)null) && !((Object)(object)to == (Object)null))
			{
				to.anchorMin = from.anchorMin;
				to.anchorMax = from.anchorMax;
				to.pivot = from.pivot;
				to.anchoredPosition3D = from.anchoredPosition3D;
				to.sizeDelta = from.sizeDelta;
				((Transform)to).localScale = ((Transform)from).localScale;
				((Transform)to).localRotation = ((Transform)from).localRotation;
			}
		}

		private void SpawnIcon(HomeScreen home)
		{
			Transform appIconContainer = (Transform)(object)home.appIconContainer;
			GameObject appIconPrefab = home.appIconPrefab;
			if ((Object)(object)appIconContainer == (Object)null || (Object)(object)appIconPrefab == (Object)null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] HomeScreen exposes no icon prefab or container - '" + _reg.Id + "' has no home-screen icon.");
				}
				return;
			}
			string text = "SideloadIcon_" + _reg.Id;
			Transform val = appIconContainer.Find(text);
			if ((Object)(object)val != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
			}
			_icon = Object.Instantiate<GameObject>(appIconPrefab, appIconContainer);
			((Object)_icon).name = text;
			_icon.transform.SetAsLastSibling();
			_icon.SetActive(true);
			Dress(_icon.transform, AppIconSprite.For(_reg), _reg.IconLabel, _reg.Id);
			Button component = _icon.GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				((UnityEventBase)component.onClick).RemoveAllListeners();
				((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)Open));
			}
			else
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Warning("[Sideload] the icon prefab has no Button component - '" + _reg.Id + "' cannot be opened from the home screen.");
				}
			}
			UISelectable component2 = _icon.GetComponent<UISelectable>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)home.uiPanel != (Object)null)
			{
				home.uiPanel.AddSelectable(component2);
			}
			_badge = _icon.transform.Find("Notifications");
			object badgeText;
			if (!((Object)(object)_badge != (Object)null))
			{
				badgeText = null;
			}
			else
			{
				Transform obj = _badge.Find("Text");
				badgeText = ((obj != null) ? ((Component)obj).GetComponent<Text>() : null);
			}
			_badgeText = (Text)badgeText;
			if ((Object)(object)_badge == (Object)null)
			{
				Instance log3 = Core.Log;
				if (log3 != null)
				{
					log3.Warning("[Sideload] the icon prefab has no Notifications badge - '" + _reg.Id + "' cannot show a count.");
				}
			}
			ApplyBadge();
		}

		internal void SetBadge(int count)
		{
			_reg.Badge = Math.Max(0, count);
			ApplyBadge();
		}

		private void ApplyBadge()
		{
			if (!((Object)(object)_badge == (Object)null))
			{
				if ((Object)(object)_badgeText != (Object)null)
				{
					_badgeText.text = ((_reg.Badge > 99) ? "99+" : _reg.Badge.ToString());
				}
				((Component)_badge).gameObject.SetActive(_reg.Badge > 0);
			}
		}

		internal void Notify(string title, string subtitle)
		{
			try
			{
				if (Singleton<NotificationsManager>.InstanceExists)
				{
					Singleton<NotificationsManager>.Instance.SendNotification(title ?? "", subtitle ?? "", AppIconSprite.For(_reg), 5f, true);
				}
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] notification from '" + _reg.Id + "' failed: " + ex.Message);
				}
			}
		}

		private static void Dress(Transform icon, Sprite sprite, string caption, string appId)
		{
			Transform val = icon.Find("Mask/Image");
			Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : ((Component)icon).GetComponentInChildren<Image>(true));
			if ((Object)(object)val2 != (Object)null && (Object)(object)sprite != (Object)null)
			{
				val2.sprite = sprite;
			}
			else if ((Object)(object)val2 == (Object)null)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] no Image under the icon for '" + appId + "' - it keeps the prefab's picture.");
				}
			}
			if (!SetIconLabel(((Component)icon).gameObject, caption))
			{
				Instance log2 = Core.Log;
				if (log2 != null)
				{
					log2.Warning("[Sideload] no label found on the icon for '" + appId + "' - it stays unnamed.");
				}
			}
		}

		private static bool SetIconLabel(GameObject icon, string caption)
		{
			Transform val = icon.transform.Find("Label");
			if ((Object)(object)val != (Object)null)
			{
				Text component = ((Component)val).GetComponent<Text>();
				if ((Object)(object)component != (Object)null)
				{
					component.text = caption;
					return true;
				}
				TextMeshProUGUI component2 = ((Component)val).GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((TMP_Text)component2).text = caption;
					return true;
				}
			}
			foreach (Text componentsInChild in icon.GetComponentsInChildren<Text>(true))
			{
				if (!((Object)(object)((Component)componentsInChild).transform.parent != (Object)null) || !(((Object)((Component)componentsInChild).transform.parent).name == "Notifications"))
				{
					componentsInChild.text = caption;
					return true;
				}
			}
			using (IEnumerator<TextMeshProUGUI> enumerator2 = icon.GetComponentsInChildren<TextMeshProUGUI>(true).GetEnumerator())
			{
				if (enumerator2.MoveNext())
				{
					((TMP_Text)enumerator2.Current).text = caption;
					return true;
				}
			}
			return false;
		}

		private void SubscribeShellEvents()
		{
			if (PlayerSingleton<Phone>.InstanceExists)
			{
				_closeAppsHandler = Close;
				Phone instance = PlayerSingleton<Phone>.Instance;
				instance.closeApps += Action.op_Implicit(_closeAppsHandler);
				_exitHandler = DelegateSupport.ConvertDelegate<ExitDelegate>((Delegate)new Action<ExitAction>(OnExit));
				GameInput.RegisterExitListener(_exitHandler, 1);
			}
		}

		private void OnExit(ExitAction exit)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (exit.Used || !IsShowing)
			{
				return;
			}
			exit.Used = true;
			try
			{
				if (_view != null && _view.DispatchBack(((int)exit.exitType == 0) ? "rightClick" : "escape"))
				{
					return;
				}
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] the back handler of '" + _reg.Id + "' threw: " + ex.Message);
				}
			}
			Close();
		}

		internal void Turn()
		{
			Registry.SetOrientation(_reg.Id, _reg.Portrait ? "landscape" : "portrait");
		}

		internal void Open()
		{
			try
			{
				Phone instance = PlayerSingleton<Phone>.Instance;
				if ((Object)(object)Phone.ActiveApp != (Object)null && (Object)(object)Phone.ActiveApp != (Object)(object)_panel)
				{
					instance.RequestCloseApp();
				}
				SetOpen(open: true);
				Canvas.ForceUpdateCanvases();
				_view?.EnsureBuilt();
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] opening '" + _reg.Id + "' failed: " + ex.Message);
				}
			}
		}

		internal void Close()
		{
			try
			{
				if (IsOpen)
				{
					SetOpen(open: false);
				}
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Error("[Sideload] closing '" + _reg.Id + "' failed: " + ex.Message);
				}
			}
		}

		private void SetOpen(bool open)
		{
			if (!open || !((Object)(object)Phone.ActiveApp != (Object)null) || !((Object)(object)Phone.ActiveApp != (Object)(object)_panel))
			{
				if (PlayerSingleton<AppsCanvas>.InstanceExists)
				{
					PlayerSingleton<AppsCanvas>.Instance.SetIsOpen(open);
				}
				if (PlayerSingleton<HomeScreen>.InstanceExists)
				{
					PlayerSingleton<HomeScreen>.Instance.SetIsOpen(!open);
				}
				if (PlayerSingleton<Phone>.InstanceExists)
				{
					bool flag = open && !_reg.Portrait;
					PlayerSingleton<Phone>.Instance.SetIsHorizontal(flag);
					PlayerSingleton<Phone>.Instance.SetLookOffsetMultiplier(flag ? 0.6f : 1f);
				}
				Phone.ActiveApp = (open ? _panel : null);
				if ((Object)(object)_container != (Object)null)
				{
					_container.SetActive(open);
				}
			}
		}
	}
	internal static class TurnInput
	{
		internal static void Tick()
		{
			PhoneAppHost phoneAppHost = OpenTurnableApp();
			TurnPrompt.Show(phoneAppHost != null);
			if (phoneAppHost != null && !GameInput.IsTyping && Singleton<GameInput>.InstanceExists && (GameInput.GetButtonDown((ButtonCode)17) || GameInput.GetButtonDown((ButtonCode)18)))
			{
				phoneAppHost.Turn();
			}
		}

		private static PhoneAppHost OpenTurnableApp()
		{
			IReadOnlyList<PhoneAppHost> hosts = HomeScreenPatch.Hosts;
			for (int i = 0; i < hosts.Count; i++)
			{
				if (hosts[i].IsOpen && hosts[i].CanTurn)
				{
					return hosts[i];
				}
			}
			return null;
		}
	}
	internal static class TurnPrompt
	{
		private const string RowName = "SideloadTurnPrompt";

		private static GameObject _row;

		private static RectTransform _hostModule;

		private static bool _warned;

		internal static void Show(bool wanted)
		{
			RectTransform val = CurrentModule();
			if ((Object)(object)_row != (Object)null && (!wanted || (Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)_hostModule))
			{
				Remove();
			}
			if (!wanted || (Object)(object)val == (Object)null || (Object)(object)_row != (Object)null)
			{
				return;
			}
			try
			{
				Build(val);
			}
			catch (Exception ex)
			{
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] could not add the turn hint to the input prompts: " + ex.Message);
				}
				Remove();
			}
		}

		private static RectTransform CurrentModule()
		{
			if (!Singleton<InputPromptsCanvas>.InstanceExists)
			{
				return null;
			}
			InputPromptsCanvas instance = Singleton<InputPromptsCanvas>.Instance;
			if (!((Object)(object)instance.currentModule != (Object)null))
			{
				return instance.InputPromptsContainer;
			}
			return instance.currentModule;
		}

		private static void Remove()
		{
			if ((Object)(object)_row != (Object)null)
			{
				Object.Destroy((Object)(object)_row);
			}
			_row = null;
			_hostModule = null;
		}

		private static void Build(RectTransform module)
		{
			InputPrompt val = Template(module);
			if ((Object)(object)val == (Object)null)
			{
				WarnOnce("the input prompt strip has no line to copy");
				return;
			}
			InputActionReference val2 = FindAction("RotateLeft");
			InputActionReference val3 = FindAction("RotateRight");
			if ((Object)(object)val2 == (Object)null && (Object)(object)val3 == (Object)null)
			{
				WarnOnce("the rotate actions are not loaded");
				return;
			}
			_row = Object.Instantiate<GameObject>(((Component)val).gameObject, (Transform)(object)module);
			((Object)_row).name = "SideloadTurnPrompt";
			_row.transform.SetAsLastSibling();
			InputPrompt component = _row.GetComponent<InputPrompt>();
			if ((Object)(object)component == (Object)null)
			{
				WarnOnce("the copied line lost its InputPrompt component");
				Remove();
				return;
			}
			component.Actions.Clear();
			if ((Object)(object)val2 != (Object)null)
			{
				component.Actions.Add(val2);
			}
			if ((Object)(object)val3 != (Object)null)
			{
				component.Actions.Add(val3);
			}
			component.Label = "Rotate Phone";
			_row.SetActive(false);
			_row.SetActive(true);
			PlaceBelowTheRest(module, _row.GetComponent<RectTransform>());
			_hostModule = module;
		}

		private static void PlaceBelowTheRest(RectTransform module, RectTransform row)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)row == (Object)null)
			{
				return;
			}
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			for (int i = 0; i < ((Transform)module).childCount; i++)
			{
				Transform child = ((Transform)module).GetChild(i);
				if ((Object)(object)((Component)child).gameObject == (Object)(object)((Component)row).gameObject)
				{
					continue;
				}
				RectTransform component = ((Component)child).GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null))
				{
					float y = component.anchoredPosition.y;
					if (y < num)
					{
						num2 = num;
						num = y;
					}
					else if (y < num2)
					{
						num2 = y;
					}
				}
			}
			if (num == float.MaxValue)
			{
				return;
			}
			Rect rect;
			float num3;
			if (!(num2 < float.MaxValue))
			{
				rect = row.rect;
				num3 = Math.Abs(((Rect)(ref rect)).height);
			}
			else
			{
				num3 = Math.Abs(num2 - num);
			}
			float num4 = num3;
			if (num4 < 1f)
			{
				rect = row.rect;
				float num5;
				if (!(Math.Abs(((Rect)(ref rect)).height) < 1f))
				{
					rect = row.rect;
					num5 = Math.Abs(((Rect)(ref rect)).height);
				}
				else
				{
					num5 = 30f;
				}
				num4 = num5;
			}
			row.anchoredPosition = new Vector2(row.anchoredPosition.x, num - num4);
		}

		private static InputPrompt Template(RectTransform module)
		{
			foreach (InputPrompt componentsInChild in ((Component)module).GetComponentsInChildren<InputPrompt>(true))
			{
				if (((Object)((Component)componentsInChild).gameObject).name != "SideloadTurnPrompt")
				{
					return componentsInChild;
				}
			}
			return null;
		}

		private static InputActionReference FindAction(string actionName)
		{
			string value = "/" + actionName;
			foreach (InputActionReference item in Resources.FindObjectsOfTypeAll<InputActionReference>())
			{
				if (!((Object)(object)item == (Object)null))
				{
					string text = ((Object)item).name ?? "";
					if (text.EndsWith(value, StringComparison.OrdinalIgnoreCase) || text.Equals(actionName, StringComparison.OrdinalIgnoreCase))
					{
						return item;
					}
				}
			}
			return null;
		}

		private static void WarnOnce(string reason)
		{
			if (!_warned)
			{
				_warned = true;
				Instance log = Core.Log;
				if (log != null)
				{
					log.Warning("[Sideload] no turn hint in the key strip - " + reason + ". Turning still works.");
				}
			}
		}
	}
}
namespace Sideload.Paint
{
	internal static class BoxMaterial
	{
		private const string ResourceName = "Sideload.Assets.Bundles.sideload-ui";

		private static bool _tried;

		private static Material _material;

		internal static bool Available => (Object)(object)Get() != (Object)null;

		internal static Material Get()
		{
			//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_0132: Expected O, but got Unknown
			if (_tried)
			{
				return _material;
			}
			_tried = true;
			try
			{
				byte[] array = ReadEmbedded("Sideload.Assets.Bundles.sideload-ui");
				if (array == null)
				{
					Instance log = Core.Log;
					if (log != null)
					{
						log.Warning("[Sideload] UI shader bundle not embedded - boxes will be flat fills.");
					}
					return null;
				}
				Il2CppAssetBundle val = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
				if (val == null)
				{
					Instance log2 = Core.Log;
					if (log2 != null)
					{
						log2.Warning("[Sideload] UI shader bundle failed to load - boxes will be flat fills.");
					}
					return null;
				}
				Shader val2 = val.LoadAsset<Shader>("Assets/SideloadBox.shader");
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val.LoadAsset<Shader>("SideloadBox");
				}
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val.LoadAsset<Shader>("Sideload/Box");
				}
				if ((Object)(object)val2 == (Object)null)
				{
					Il2CppReferenceArray<Shader> val3 = val.LoadAllAssets<Shader>();
					if (val3 != null && ((Il2CppArrayBase<Shader>)(object)val3).Length > 0)
					{
						val2 = ((Il2CppArrayBase<Shader>)(object)val3)[0];
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					Instance log3 = Core.Log;
					if (log3 != null)
					{
						log3.Warning("[Sideload] UI shader not found in bundle - boxes will be flat fills.");
					}
					return null;
				}
				if (!val2.isSupported)
				{
					Instance log4 = Core.Log;
					if (log4 != null)
					{
						log4.Warning("[Sideload] UI shader '" + ((Object)val2).name + "' is not supported here - boxes will be flat fills.");
					}
					return null;
				}
				_material = new Material(val2)
				{
					name = "SideloadBox"
				};
				Instance log5 = Core.Log;
				if (log5 != null)
				{
					log5.Msg("[Sideload] UI shader loaded: " + ((Object)val2).name);
				}
			}
			catch (Exception ex)
			{
				Instance log6 = Core.Log;
				if (log6 != null)
				{
					log6.Warning("[Sideload] UI shader load failed: " + ex.Message);
				}
				_material = null;
			}
			return _material;
		}

		internal static Material CreateClipped(Vector4 clipRect)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			Material val = Get();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val)
			{
				name = "SideloadBox (clipped)"
			};
			val2.EnableKeyword("UNITY_UI_CLIP_RECT");
			val2.SetVector("_ClipRect", clipRect);
			Instance log = Core.Log;
			if (log != null)
			{
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(54, 4);
				defaultInterpolatedStringHandler.AppendLiteral("[Sideload/clip] material '");
				defaultInterpolatedStringHandler.AppendFormatted(((Object)val2).name);
				defaultInterpolatedStringHandler.AppendLiteral("' shader='");
				Shader shader = val2.shader;
				defaultInterpolatedStringHandler.AppendFormatted((shader != null) ? ((Object)shader).name : null);
				defaultInterpolatedStringHandler.AppendLiteral("' ");
				defaultInterpolatedStringHandler.AppendLiteral("supported=");
				Shader shader2 = val2.shader;
				defaultInterpolatedStringHandler.AppendFormatted((shader2 != null) ? new bool?(shader2.isSupported) : ((bool?)null));
				defaultInterpolatedStringHandler.AppendLiteral(" rect=");
				defaultInterpolatedStringHandler.AppendFormatted<Vector4>(clipRect);
				log.Msg(defaultInterpolatedStringHandler.ToStringAndClear());
			}
			return val2;
		}

		private static byte[] ReadEmbedded(string name)
		{
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				int num;
				for (int i = 0; i < array.Length; i += num)
				{
					num = stream.Read(array, i, array.Length - i);
					if (num <= 0)
					{
						break;
					}
				}
				return array;
			}
			catch
			{
				return null;
			}
		}
	}
	internal struct BoxVisual
	{
		internal Color FillTL;

		internal Color FillTR;

		internal Color FillBR;

		internal Color FillBL;

		internal float RadiusTL;

		internal float RadiusTR;

		internal float RadiusBR;

		internal float RadiusBL;

		internal float BorderWidth;

		internal float EdgeTop;

		internal float EdgeRight;

		internal float EdgeBottom;

		internal float EdgeLeft;

		internal Color BorderColor;

		internal bool HasShadow;

		internal float ShadowOffsetX;

		internal float ShadowOffsetY;

		internal float ShadowBlur;

		internal Color ShadowColor;

		internal static BoxVisual Solid(Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			return new BoxVisual
			{
				FillTL = color,
				FillTR = color,
				FillBR = color,
				FillBL = color,
				BorderColor = new Color(0f, 0f, 0f, 0f),
				ShadowColor = new Color(0f, 0f, 0f, 0f)
			};
		}
	}
	internal static class BoxRenderer
	{
		private const AdditionalCanvasShaderChannels RequiredChannels = (AdditionalCanvasShaderChannels)31;

		private static readonly Dictionary<int, (int Owner, Mesh Mesh)> _meshes = new Dictionary<int, (int, Mesh)>();

		private static readonly HashSet<int> _touched = new HashSet<int>();

		private static bool _collecting;

		private static int _owner;

		internal static Rect? ActiveClip;

		internal static void EnsureCanvasChannels(Transform anyChild)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)anyChild == (Object)null)
			{
				return;
			}
			Canvas componentInParent = ((Component)anyChild).GetComponentInParent<Canvas>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return;
			}
			Canvas val = (((Object)(object)componentInParent.rootCanvas != (Object)null) ? componentInParent.rootCanvas : componentInParent);
			if ((val.additionalShaderChannels & 0x1F) != 31)
			{
				val.additionalShaderChannels = (AdditionalCanvasShaderChannels)(val.additionalShaderChannels | 0x1F);
				Instance log = Core.Log;
				if (log != null)
				{
					log.Msg("[Sideload] enabled extra vertex channels on canvas '" + ((Object)val).name + "'.");
				}
			}
		}

		internal static void Paint(RectTransform rt, BoxVisual visual, float width, float height)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_0180: 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_0199: 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_01a4: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rt == (Object)null)
			{
				return;
			}
			Material val = BoxMaterial.Get();
			if ((Object)(object)val == (Object)null)
			{
				PaintFlat(rt, visual);
				return;
			}
			EnsureCanvasChannels((Transform)(object)rt);
			CanvasRenderer val2 = ((Component)rt).GetComponent<CanvasRenderer>();
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((Component)rt).gameObject.AddComponent<CanvasRenderer>();
			}
			int num = ((!visual.HasShadow) ? 1 : 2);
			if (visual.EdgeTop > 0f)
			{
				num++;
			}
			if (visual.EdgeBottom > 0f)
			{
				num++;
			}
			if (visual.EdgeLeft > 0f)
			{
				num++;
			}
			if (visual.EdgeRight > 0f)
			{
				num++;
			}
			int num2 = num * 4;
			Vector3[] array = (Vector3[])(object)new Vector3[num2];
			Color32[] array2 = (Color32[])(object)new Color32[num2];
			Vector2[] array3 = (Vector2[])(object)new Vector2[num2];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num2];
			Vector2[] array5 = (Vector2[])(object)new Vector2[num2];
			Vector2[] array6 = (Vector2[])(object)new Vector2[num2];
			Vector3[] array7 = (Vector3[])(object)new Vector3[num2];
			Vector4[] array8 = (Vector4[])(object)new Vector4[num2];
			int[] array9 = new int[num * 6];
			Vector2 pivot = rt.pivot;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor((0.5f - pivot.x) * width, (0.5f - pivot.y) * height);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(width * 0.5f, height * 0.5f);
			Vector4 radii = default(Vector4);
			((Vector4)(ref radii))..ctor(visual.RadiusTL, visual.RadiusTR, visual.RadiusBR, visual.RadiusBL);
			int v = 0;
			int t = 0;
			if (visual.HasShadow)
			{
				float num3 = visual.ShadowBlur + 2f;
				Vector2 centre = val3 + new Vector2(visual.ShadowOffsetX, 0f - visual.ShadowOffsetY);
				Color shadowColor = visual.ShadowColor;
				EmitQuad(array, array2, array3, array4, array5, array6, array7, array8, array9, ref v, ref t, centre, val4 + new Vector2(num3, num3), val4, radii, shadowColor, shadowColor, shadowColor, shadowColor, 0f, Mathf.Max(visual.ShadowBlur, 0.5f), new Color(0f, 0f, 0f, 0f));
			}
			EmitQuad(array, array2, array3, array4, array5, array6, array7, array8, array9, ref v, ref t, val3, val4, val4, radii, visual.FillTL, visual.FillTR, visual.FillBR, visual.FillBL, visual.BorderWidth, 0f, visual.BorderColor);
			Color borderColor = visual.BorderColor;
			EmitEdge(array, array2, array3, array4, array5, array6, array7, array8, array9, ref v, ref t, val3 + new Vector2(0f, val4.y - visual.EdgeTop * 0.5f), new Vector2(val4.x, visual.EdgeTop * 0.5f), visual.EdgeTop, borderColor);
			EmitEdge(array, array2, array3, array4, array5, array6, array7, array8, array9, ref v, ref t, val3 - new Vector2(0f, val4.y - visual.EdgeBottom * 0.5f), new Vector2(val4.x, visual.EdgeBottom * 0.5f), visual.EdgeBottom, borderColor);
			EmitEdge(array, array2, array3, array4, array5, array6, array7, array8, array9, ref v, ref t, val3 - new Vector2(val4.x - visual.EdgeLeft * 0.5f, 0f), new Vector2(visual.EdgeLeft * 0.5f, val4.y), visual.EdgeLeft, borderColor);
			EmitEdge(array, array2, array3, array4, array5, array6, array7, array8, array9, ref v, ref t, val3 + new Vector2(val4.x - visual.EdgeRight * 0.5f, 0f), new Vector2(visual.EdgeRight * 0.5f, val4.y), visual.EdgeRight, borderColor);
			Mesh val5 = MeshFor(((Component)rt).gameObject);
			val5.Clear();
			val5.vertices = Il2CppStructArray<Vector3>.op_Implicit(array);
			val5.colors32 = Il2CppStructArray<Color32>.op_Implicit(array2);
			val5.uv = Il2CppStructArray<Vector2>.op_Implicit(array3);
			val5.uv2 = Il2CppStructArray<Vector2>.op_Implicit(array4);
	

UserLibs/Esprima.dll

Decompiled 17 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using Esprima.Ast;
using Esprima.Ast.Jsx;
using Esprima.Utils;
using Esprima.Utils.Jsx;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Esprima.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
[assembly: InternalsVisibleTo("Esprima.Benchmark, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sebastien Ros")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Sebastien Ros")]
[assembly: AssemblyDescription("Standard-compliant ECMAScript 2022 parser (also known as JavaScript).")]
[assembly: AssemblyFileVersion("3.0.5.0")]
[assembly: AssemblyInformationalVersion("3.0.5+4661614f09d4bb476a552f8dae82a5887060d570")]
[assembly: AssemblyProduct("Esprima")]
[assembly: AssemblyTitle("Esprima .NET")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/sebastienros/esprima-dotnet")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: SkipLocalsInit]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace System
{
	internal static class HexConverter
	{
		public static ReadOnlySpan<byte> CharToHexLookup => new byte[256]
		{
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 0, 1,
			2, 3, 4, 5, 6, 7, 8, 9, 255, 255,
			255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
			15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 10, 11, 12,
			13, 14, 15, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255
		};

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexChar(int c)
		{
			if (IntPtr.Size == 8)
			{
				ulong num = (uint)(c - 48);
				long num2 = -17875860044349952L << (int)num;
				ulong num3 = num - 64;
				return (long)((ulong)num2 & num3) < 0L;
			}
			return FromChar(c) != 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromChar(int c)
		{
			if (c < CharToHexLookup.Length)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
namespace Esprima
{
	internal struct ArrayList<T> : IReadOnlyList<T>, IEnumerable<T>, IEnumerable, IReadOnlyCollection<T>
	{
		public struct Enumerator : IEnumerator<T>, IEnumerator, IDisposable
		{
			private readonly T[]? _items;

			private readonly int _count;

			private int _index;

			private T? _current;

			public T Current => _current;

			object? IEnumerator.Current
			{
				get
				{
					if (_index == 0 || _index == _count + 1)
					{
						EsprimaExceptionHelper.ThrowInvalidOperationException<T>();
					}
					return Current;
				}
			}

			internal Enumerator(T[]? items, int count)
			{
				this = default(Enumerator);
				_index = 0;
				_items = items;
				_count = count;
			}

			public void Dispose()
			{
			}

			public bool MoveNext()
			{
				if (_index < _count)
				{
					_current = _items[_index];
					_index++;
					return true;
				}
				return MoveNextRare();
			}

			private bool MoveNextRare()
			{
				_index = _count + 1;
				_current = default(T);
				return false;
			}

			public void Reset()
			{
				_index = 0;
				_current = default(T);
			}
		}

		private const int MinAllocatedCount = 4;

		private T[]? _items;

		private int _count;

		public int Capacity
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				T[]? items = _items;
				if (items == null)
				{
					return 0;
				}
				return items.Length;
			}
			set
			{
				if (value < _count)
				{
					EsprimaExceptionHelper.ThrowArgumentOutOfRangeException("value", value);
					return;
				}
				T[]? items = _items;
				if (value == ((items != null) ? items.Length : 0))
				{
					return;
				}
				if (value > 0)
				{
					T[] array = new T[value];
					if (_count > 0)
					{
						Array.Copy(_items, 0, array, 0, _count);
					}
					_items = array;
				}
				else
				{
					_items = null;
				}
			}
		}

		public int Count
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return _count;
			}
		}

		public T this[int index]
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if ((uint)index < (uint)_count)
				{
					return _items[index];
				}
				return EsprimaExceptionHelper.ThrowIndexOutOfRangeException<T>();
			}
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			set
			{
				if ((uint)index < (uint)_count)
				{
					_items[index] = value;
				}
				else
				{
					EsprimaExceptionHelper.ThrowIndexOutOfRangeException<T>();
				}
			}
		}

		public ArrayList(int initialCapacity)
		{
			if (initialCapacity < 0)
			{
				ThrowInvalidInitialCapacity();
			}
			_items = ((initialCapacity > 0) ? new T[initialCapacity] : null);
			_count = 0;
			[MethodImpl(MethodImplOptions.NoInlining)]
			static void ThrowInvalidInitialCapacity()
			{
				EsprimaExceptionHelper.ThrowArgumentException("Invalid initial capacity", "initialCapacity");
			}
		}

		internal ArrayList(T[] items)
		{
			_items = items;
			_count = items.Length;
		}

		[Conditional("DEBUG")]
		private void AssertUnchanged()
		{
		}

		[Conditional("DEBUG")]
		private void OnChanged()
		{
		}

		public void AddRange(ReadOnlySpan<T> items)
		{
			int length = items.Length;
			if (length != 0)
			{
				int count = _count;
				int num = count + length;
				if (Capacity < num)
				{
					Array.Resize(ref _items, Math.Max(num, 4));
				}
				items.CopyTo(_items.AsSpan(count, length));
				_count = num;
			}
		}

		public void AddRange<TSource>(ArrayList<TSource> list) where TSource : class, T
		{
			T[] items = (T[])(object)list._items;
			AddRange(new ReadOnlySpan<T>(items, 0, list._count));
		}

		public void Add(T item)
		{
			int capacity = Capacity;
			if (_count == capacity)
			{
				Array.Resize(ref _items, Math.Max(capacity * 2, 4));
			}
			_items[_count] = item;
			_count++;
		}

		public void Clear()
		{
			if (_count > 0)
			{
				Array.Clear(_items, 0, _count);
				_count = 0;
			}
		}

		public void Insert(int index, T item)
		{
			if ((uint)index > (uint)_count)
			{
				EsprimaExceptionHelper.ThrowIndexOutOfRangeException<T>();
			}
			int capacity = Capacity;
			if (_count == capacity)
			{
				Array.Resize(ref _items, Math.Max(capacity * 2, 4));
			}
			Array.Copy(_items, index, _items, index + 1, Count - index);
			_items[index] = item;
			_count++;
		}

		public void RemoveAt(int index)
		{
			if ((uint)index >= (uint)_count)
			{
				EsprimaExceptionHelper.ThrowIndexOutOfRangeException<T>();
			}
			_count--;
			if (index < _count)
			{
				Array.Copy(_items, index + 1, _items, index, Count - index);
			}
			_items[_count] = default(T);
		}

		public void Sort(IComparer<T>? comparer = null)
		{
			if (_count > 1)
			{
				Array.Sort(_items, 0, _count, comparer);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Push(T item)
		{
			Add(item);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public T Pop()
		{
			int index = _count - 1;
			T result = this[index];
			RemoveAt(index);
			return result;
		}

		public void Yield(out T[]? items, out int count)
		{
			items = _items;
			count = _count;
			this = default(ArrayList<T>);
		}

		public void TrimExcess(int threshold = 4)
		{
			if (Capacity - _count > threshold)
			{
				Capacity = _count;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span<T> AsSpan()
		{
			return new Span<T>(_items, 0, _count);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlySpan<T> AsReadOnlySpan()
		{
			return new ReadOnlySpan<T>(_items, 0, _count);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public T[] ToArray()
		{
			return AsReadOnlySpan().ToArray();
		}

		public Enumerator GetEnumerator()
		{
			return new Enumerator(_items, _count);
		}

		IEnumerator<T> IEnumerable<T>.GetEnumerator()
		{
			return GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	internal static class ArrayList
	{
		public static ArrayList<T> Create<T>(in NodeList<T> source) where T : Node
		{
			return new ArrayList<T>(source.ToArray());
		}

		public static void AddRange<T>(this ref ArrayList<T> destination, in NodeList<T> source) where T : Node
		{
			foreach (T item in source)
			{
				destination.Add(item);
			}
		}
	}
	[Flags]
	internal enum CharacterMask : byte
	{
		None = 0,
		WhiteSpace = 1,
		IdentifierStart = 2,
		IdentifierPart = 4
	}
	public static class Character
	{
		internal const int UnicodeLastCodePoint = 1114111;

		internal static readonly Func<char, bool> IsDecimalDigitFunc = IsDecimalDigit;

		internal static readonly Func<char, bool> IsHexDigitFunc = IsHexDigit;

		internal static readonly Func<char, bool> IsOctalDigitFunc = IsOctalDigit;

		private static readonly int[] s_identifierStartAstralRanges = new int[281]
		{
			16777217, 16780546, 16787459, 16792580, 16793349, 16797702, 16809991, 16859144, 16941065, 16949258,
			16973835, 16985356, 16994317, 17006604, 17014798, 17025039, 17027344, 17039377, 17084430, 17094670,
			17104914, 17117203, 17133588, 17136645, 17140757, 17142788, 17143572, 17146629, 17150741, 17152772,
			17170454, 17252375, 17260559, 17268760, 17270553, 17281562, 17301528, 17303552, 17304091, 17315588,
			17316864, 17317660, 17326108, 17334301, 17358851, 17363972, 17367063, 17375234, 17399838, 17415684,
			17432576, 17436703, 17437984, 17438985, 17457161, 17465353, 17481743, 17484065, 17498146, 17514519,
			17522691, 17530915, 17563684, 17596453, 17612837, 17629198, 17727513, 17739780, 17760265, 17770240,
			17772567, 17788963, 17805350, 17817628, 17826568, 17854724, 17855744, 17859367, 17879080, 17892110,
			17908736, 17909504, 17911849, 17921536, 17924906, 17940767, 17947136, 17947648, 17956899, 17961768,
			17972996, 17989653, 17991680, 17992223, 17993477, 17997611, 18001964, 18023695, 18026244, 18027287,
			18033173, 18035204, 18035984, 18038016, 18042880, 18046224, 18087944, 18106143, 18112288, 18120746,
			18138116, 18138880, 18186284, 18208799, 18219050, 18236416, 18251821, 18266112, 18284590, 18300949,
			18350107, 18391087, 18415375, 18417920, 18418703, 18420996, 18421808, 18431744, 18432256, 18456591,
			18459185, 18473216, 18473728, 18481152, 18483986, 18496000, 18501632, 18504754, 18521344, 18526244,
			18612250, 18614835, 18628608, 18641420, 18677781, 18679812, 18680589, 18695680, 18702360, 18704132,
			18704907, 18716672, 18800643, 18809344, 18809908, 18813493, 18853888, 18874422, 19136567, 19169336,
			19894329, 19923002, 20201752, 21233723, 23593020, 23740445, 23752765, 23777292, 23789610, 23805983,
			23814950, 23821571, 24002607, 24051774, 24072192, 24089396, 24109060, 24109824, 24117311, 25690176,
			26017818, 28307487, 28308757, 28310788, 28311617, 28389888, 28397600, 28398848, 28402719, 28405826,
			29098051, 29126708, 29130778, 29134891, 30670916, 30692933, 30711300, 30712320, 30713092, 30714143,
			30715393, 30718720, 30719253, 30721350, 30738207, 30739727, 30742037, 30744097, 30751519, 30752784,
			30754304, 30755349, 30757447, 30844968, 30851624, 30858269, 30866472, 30873117, 30881320, 30887965,
			30896168, 30902813, 30911016, 30917647, 31391773, 31401240, 31469640, 31522855, 31536917, 31542784,
			31625228, 31637531, 31772705, 31973397, 31975455, 31976708, 31977477, 31981641, 32047178, 32066304,
			32374815, 32376110, 32383236, 32384000, 32384768, 32385323, 32388127, 32389376, 32389888, 32391680,
			32392960, 32393472, 32393984, 32394528, 32395524, 32396288, 32397056, 32397568, 32398080, 32398592,
			32399104, 32399620, 32400384, 32401183, 32402453, 32404511, 32405791, 32407040, 32407595, 32410443,
			32416032, 32417040, 32418635, 33554508, 44499021, 45563982, 45621327, 47099984, 49807441, 50331730,
			51597395
		};

		private static readonly int[] s_identifierPartAstralRanges = new int[340]
		{
			16777217, 16780546, 16787459, 16792580, 16793349, 16797702, 16809991, 16859144, 16907520, 16941065,
			16949258, 16965632, 16973835, 16985356, 16994349, 17006604, 17014798, 17025039, 17027344, 17039377,
			17080363, 17084430, 17094670, 17104914, 17117203, 17133588, 17136645, 17140757, 17142788, 17143572,
			17146629, 17150741, 17152772, 17170454, 17252375, 17260559, 17268760, 17270553, 17281562, 17301528,
			17303552, 17304091, 17315588, 17316864, 17317660, 17326108, 17334301, 17358851, 17363972, 17367063,
			17375234, 17399838, 17415684, 17432607, 17433860, 17435663, 17437984, 17438985, 17446944, 17448704,
			17457161, 17465353, 17481743, 17484044, 17498146, 17514519, 17522691, 17530915, 17563684, 17596453,
			17612837, 17629202, 17641515, 17727513, 17738500, 17739780, 17759499, 17770240, 17772628, 17788951,
			17805350, 17817628, 17825861, 17851989, 17858390, 17875456, 17879080, 17887275, 17891336, 17905195,
			17908767, 17911822, 17921536, 17924183, 17942815, 17944116, 17947648, 17956899, 17961779, 17972767,
			17989653, 17991680, 17992223, 17993477, 17997611, 18002008, 18018347, 18022431, 18023695, 18026244,
			18027287, 18033173, 18035204, 18035984, 18037547, 18040580, 18041632, 18042880, 18044672, 18046229,
			18048533, 18051088, 18087998, 18108459, 18112031, 18120793, 18138880, 18141227, 18186274, 18200602,
			18208792, 18219078, 18236416, 18239531, 18251866, 18268203, 18284590, 18291973, 18296875, 18300949,
			18350168, 18391131, 18415375, 18417920, 18418703, 18420996, 18421772, 18429700, 18430746, 18436139,
			18456591, 18459186, 18471439, 18473732, 18481244, 18499328, 18501723, 18521344, 18526244, 18612250,
			18614823, 18626586, 18632747, 18641420, 18649623, 18655494, 18677781, 18679812, 18680603, 18692608,
			18693124, 18693914, 18698283, 18702360, 18704132, 18704947, 18714628, 18715416, 18718763, 18800668,
			18808907, 18813533, 18824720, 18829355, 18853888, 18874422, 19136567, 19169336, 19894329, 19923002,
			20201495, 21233723, 23593020, 23740445, 23748651, 23752765, 23773227, 23777292, 23785488, 23789662,
			23805983, 23810091, 23814950, 23821571, 24002607, 24051774, 24072026, 24088395, 24109060, 24109828,
			24113156, 24117311, 25690176, 26017818, 28307487, 28308757, 28310788, 28311617, 28389888, 28397600,
			28398848, 28402719, 28405826, 29098051, 29126708, 29130778, 29134891, 29138180, 30343218, 30355484,
			30500112, 30502168, 30505743, 30508309, 30517791, 30556704, 30670916, 30692933, 30711300, 30712320,
			30713092, 30714143, 30715393, 30718720, 30719253, 30721350, 30738207, 30739727, 30742037, 30744097,
			30751519, 30752784, 30754304, 30755349, 30757447, 30844968, 30851624, 30858269, 30866472, 30873117,
			30881320, 30887965, 30896168, 30902813, 30911016, 30917647, 30920287, 31064158, 31079263, 31094016,
			31097856, 31103760, 31105285, 31391773, 31401240, 31457301, 31459403, 31464213, 31466244, 31467024,
			31469640, 31493888, 31522855, 31535110, 31539243, 31542784, 31625245, 31637600, 31772697, 31973397,
			31975455, 31976708, 31977477, 31981641, 32034837, 32047201, 32067627, 32374815, 32376110, 32383236,
			32384000, 32384768, 32385323, 32388127, 32389376, 32389888, 32391680, 32392960, 32393472, 32393984,
			32394528, 32395524, 32396288, 32397056, 32397568, 32398080, 32398592, 32399104, 32399620, 32400384,
			32401183, 32402453, 32404511, 32405791, 32407040, 32407595, 32410443, 32416032, 32417040, 32418635,
			33288235, 33554508, 44499021, 45563982, 45621327, 47099984, 49807441, 50331730, 51597395, 234946658
		};

		private static readonly int[] s_rangeLengthLookup = new int[99]
		{
			0, 11, 25, 18, 1, 14, 13, 122, 52, 28,
			48, 31, 29, 37, 35, 7, 4, 157, 39, 51,
			10, 6, 310, 21, 5, 41, 8, 43, 22, 30,
			55, 3, 2, 27, 53, 17, 72, 50, 20, 44,
			24, 34, 47, 9, 46, 42, 26, 63, 23, 38,
			45, 36, 12, 33, 921, 110, 195, 96, 1071, 582,
			568, 78, 74, 6135, 1237, 290, 395, 106, 84, 70,
			64, 339, 61, 196, 67, 16, 42719, 4153, 221, 5761,
			7472, 541, 4938, 4191, 32, 15, 59, 68, 58, 69,
			56, 73, 62, 40, 54, 49, 57, 75, 239
		};

		private static ReadOnlySpan<byte> s_characterData => new byte[32768]
		{
			0, 0, 0, 0, 16, 16, 1, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 1, 0, 6, 0,
			0, 0, 0, 0, 68, 68, 68, 68, 68, 0,
			0, 0, 96, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 6, 6, 96, 96, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 6, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			1, 0, 0, 0, 0, 6, 0, 0, 0, 0,
			96, 64, 0, 6, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 6, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 6, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 0, 0, 102, 102, 102, 102, 102,
			102, 0, 0, 0, 0, 0, 0, 0, 102, 102,
			6, 0, 0, 0, 6, 6, 0, 0, 0, 0,
			0, 0, 0, 0, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			102, 102, 6, 102, 0, 102, 102, 96, 0, 0,
			0, 70, 102, 6, 6, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 96, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 96, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 64, 68, 68,
			0, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 96, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 6, 96, 0, 0, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 6, 0,
			0, 0, 64, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 64, 64, 4, 68, 64,
			0, 0, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 6, 0, 96,
			102, 6, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 68, 68, 68, 68,
			68, 4, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 70, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 0, 0, 102, 100, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 96, 68, 68, 68, 4, 64,
			68, 68, 100, 70, 4, 68, 68, 102, 68, 68,
			68, 68, 68, 102, 6, 96, 0, 0, 0, 0,
			0, 0, 0, 0, 70, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 4, 96, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 68,
			68, 68, 68, 68, 100, 0, 0, 0, 0, 0,
			0, 0, 68, 68, 68, 68, 68, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 70, 68, 68, 68, 68, 102, 0,
			0, 6, 64, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 68, 68, 70, 68, 68,
			68, 68, 70, 68, 70, 68, 68, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 70, 68,
			0, 0, 102, 102, 102, 102, 102, 6, 0, 0,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 96, 102, 102, 6, 0, 0, 0, 0,
			68, 68, 68, 68, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 64, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 68, 100, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 70, 68, 68, 68, 102, 102, 102, 102,
			102, 68, 0, 68, 68, 68, 68, 68, 96, 102,
			102, 102, 102, 102, 102, 102, 70, 68, 96, 102,
			102, 102, 6, 96, 6, 96, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 6, 102, 102, 102,
			6, 6, 0, 102, 102, 0, 100, 68, 68, 68,
			4, 64, 4, 64, 68, 6, 0, 0, 0, 64,
			0, 0, 102, 96, 102, 68, 0, 68, 68, 68,
			68, 68, 102, 0, 0, 0, 0, 0, 6, 4,
			64, 68, 96, 102, 102, 6, 0, 96, 6, 96,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			6, 102, 102, 102, 6, 102, 96, 6, 102, 0,
			4, 68, 68, 4, 0, 64, 4, 64, 68, 0,
			64, 0, 0, 0, 96, 102, 6, 6, 0, 0,
			0, 68, 68, 68, 68, 68, 68, 102, 70, 0,
			0, 0, 0, 0, 64, 68, 96, 102, 102, 102,
			102, 96, 102, 96, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 6, 102, 102, 102, 6, 102,
			96, 102, 102, 0, 100, 68, 68, 68, 68, 64,
			68, 64, 68, 0, 6, 0, 0, 0, 0, 0,
			0, 0, 102, 68, 0, 68, 68, 68, 68, 68,
			0, 0, 0, 0, 96, 68, 68, 68, 64, 68,
			96, 102, 102, 102, 6, 96, 6, 96, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 6, 102,
			102, 102, 6, 102, 96, 102, 102, 0, 100, 68,
			68, 68, 4, 64, 4, 64, 68, 0, 0, 0,
			64, 68, 0, 0, 102, 96, 102, 68, 0, 68,
			68, 68, 68, 68, 96, 0, 0, 0, 0, 0,
			0, 0, 0, 100, 96, 102, 102, 6, 0, 102,
			6, 102, 102, 0, 96, 6, 6, 102, 0, 96,
			6, 0, 102, 6, 0, 102, 102, 102, 102, 102,
			102, 0, 0, 68, 68, 4, 0, 68, 4, 68,
			68, 0, 6, 0, 0, 64, 0, 0, 0, 0,
			0, 0, 0, 68, 68, 68, 68, 68, 0, 0,
			0, 0, 0, 0, 0, 0, 68, 68, 100, 102,
			102, 102, 6, 102, 6, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 6, 102, 102, 102,
			102, 102, 102, 102, 102, 0, 100, 68, 68, 68,
			4, 68, 4, 68, 68, 0, 0, 0, 64, 4,
			102, 6, 96, 0, 102, 68, 0, 68, 68, 68,
			68, 68, 0, 0, 0, 0, 0, 0, 0, 0,
			70, 68, 96, 102, 102, 102, 6, 102, 6, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			6, 102, 102, 102, 102, 102, 96, 102, 102, 0,
			100, 68, 68, 68, 4, 68, 4, 68, 68, 0,
			0, 0, 64, 4, 0, 0, 96, 6, 102, 68,
			0, 68, 68, 68, 68, 68, 96, 70, 0, 0,
			0, 0, 0, 0, 68, 68, 102, 102, 102, 102,
			6, 102, 6, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 70, 100, 68, 68, 68, 4, 68,
			4, 68, 68, 6, 0, 0, 102, 70, 0, 0,
			0, 96, 102, 68, 0, 68, 68, 68, 68, 68,
			0, 0, 0, 0, 0, 102, 102, 102, 64, 68,
			96, 102, 102, 102, 102, 102, 102, 102, 102, 6,
			0, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 96, 102, 102, 102, 102, 96, 0,
			102, 102, 102, 6, 0, 4, 0, 64, 68, 68,
			4, 4, 68, 68, 68, 68, 0, 0, 0, 68,
			68, 68, 68, 68, 0, 68, 0, 0, 0, 0,
			0, 0, 96, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 70, 102, 68, 68,
			68, 4, 0, 0, 102, 102, 102, 70, 68, 68,
			68, 4, 68, 68, 68, 68, 68, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 96, 6, 6, 102,
			102, 6, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 96, 96, 102, 102, 102, 102,
			70, 102, 68, 68, 68, 68, 100, 0, 102, 102,
			6, 6, 68, 68, 68, 4, 68, 68, 68, 68,
			68, 0, 102, 102, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			6, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 68, 0, 0, 0, 68, 68, 68, 68,
			68, 0, 0, 0, 0, 0, 64, 64, 64, 0,
			0, 68, 102, 102, 102, 102, 96, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 6, 0, 64, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 4, 68, 102, 102,
			70, 68, 68, 68, 68, 68, 64, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 4, 0, 0, 0, 0, 4,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 70,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 100,
			68, 68, 68, 68, 68, 0, 0, 0, 102, 102,
			102, 68, 68, 102, 102, 68, 100, 68, 100, 70,
			68, 68, 68, 102, 70, 68, 100, 102, 102, 102,
			102, 102, 102, 68, 68, 68, 68, 68, 68, 70,
			68, 68, 68, 68, 68, 68, 68, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 96, 0, 0,
			96, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 6, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			6, 102, 102, 0, 102, 102, 102, 6, 6, 102,
			102, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 6, 102, 102, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 6, 102, 102, 0, 102, 102, 102, 6,
			6, 102, 102, 0, 102, 102, 102, 102, 102, 102,
			102, 6, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			6, 102, 102, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 6, 64, 68,
			0, 0, 0, 0, 64, 68, 68, 68, 68, 0,
			0, 0, 0, 0, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 0, 0, 0, 0, 0, 0,
			0, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 0, 102, 102, 102, 0,
			96, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			6, 96, 102, 102, 102, 102, 102, 102, 102, 102,
			97, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 6, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 6, 0, 102, 102, 102, 102, 102,
			6, 0, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 68, 68, 0, 0, 0, 0, 96,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 68,
			4, 0, 0, 0, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 68, 0, 0, 0, 0,
			0, 0, 102, 102, 102, 102, 102, 102, 6, 102,
			6, 68, 0, 0, 0, 0, 0, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			0, 96, 0, 0, 70, 0, 68, 68, 68, 68,
			68, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 64, 68, 64,
			68, 68, 68, 68, 68, 0, 0, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 6, 0, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 70, 6, 0, 0,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 0, 0, 0, 0, 0,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 6, 68, 68, 68, 68,
			68, 68, 0, 0, 68, 68, 68, 68, 68, 68,
			0, 0, 0, 0, 0, 68, 68, 68, 68, 68,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 0, 102, 102, 6, 0,
			0, 0, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 0, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 0, 0, 0, 68, 68, 68, 68, 68, 4,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 70,
			68, 68, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			70, 68, 68, 68, 68, 4, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			4, 64, 68, 68, 68, 68, 68, 0, 0, 0,
			68, 68, 68, 68, 68, 0, 0, 0, 0, 0,
			0, 96, 0, 0, 0, 0, 68, 68, 68, 68,
			68, 68, 68, 64, 68, 68, 68, 68, 68, 68,
			68, 4, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 68, 68, 100, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 68, 68, 68, 68, 68, 68, 68, 68,
			100, 102, 102, 102, 6, 0, 68, 68, 68, 68,
			68, 0, 0, 0, 0, 0, 0, 0, 0, 64,
			68, 68, 68, 68, 0, 0, 0, 0, 0, 0,
			68, 100, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 70, 68, 68, 68,
			68, 68, 68, 102, 68, 68, 68, 68, 68, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 68, 68, 68, 68, 68, 68, 68, 0, 0,
			0, 0, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 0, 0, 0, 0, 68, 68, 68, 68,
			68, 0, 96, 102, 68, 68, 68, 68, 68, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 0, 102, 102,
			102, 102, 6, 0, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 6, 96, 102,
			0, 0, 0, 0, 0, 0, 0, 0, 68, 4,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			100, 102, 70, 102, 102, 102, 100, 70, 68, 6,
			0, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 0,
			102, 102, 102, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 0, 102, 102, 102, 0, 102, 102,
			102, 102, 96, 96, 96, 96, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 6, 102,
			102, 102, 6, 6, 0, 102, 6, 102, 102, 102,
			6, 0, 102, 102, 0, 102, 102, 102, 0, 0,
			102, 102, 102, 102, 102, 102, 6, 0, 0, 102,
			6, 102, 102, 102, 6, 0, 17, 17, 17, 17,
			17, 1, 68, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
			0, 0, 0, 0, 0, 0, 0, 64, 4, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 4, 0,
			0, 0, 0, 16, 0, 0, 0, 0, 0, 0,
			0, 0, 96, 0, 0, 0, 0, 0, 0, 96,
			0, 0, 0, 0, 0, 0, 0, 0, 102, 102,
			102, 102, 102, 102, 6, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			68, 68, 68, 68, 68, 68, 4, 0, 64, 0,
			64, 68, 68, 68, 68, 68, 4, 0, 0, 0,
			0, 0, 0, 0, 0, 6, 0, 96, 0, 102,
			102, 102, 102, 102, 96, 0, 102, 102, 102, 0,
			0, 0, 6, 6, 6, 102, 102, 102, 102, 102,
			102, 102, 102, 0, 102, 102, 0, 0, 96, 102,
			102, 0, 0, 6, 0, 0, 0, 0, 0, 0,
			0, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 6, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 6, 0, 0, 96,
			102, 70, 68, 102, 0, 0, 0, 0, 0, 0,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 96,
			0, 0, 96, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 0, 0, 0, 96, 0, 0, 0, 0,
			0, 0, 0, 64, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 6, 0, 0, 0, 0,
			102, 102, 102, 6, 102, 102, 102, 6, 102, 102,
			102, 6, 102, 102, 102, 6, 102, 102, 102, 6,
			102, 102, 102, 6, 102, 102, 102, 6, 102, 102,
			102, 6, 68, 68, 68, 68, 68, 68, 68, 68,
			68, 68, 68, 68, 68, 68, 68, 68, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 1, 0, 96, 102, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			96, 102, 102, 102, 102, 68, 68, 68, 96, 102,
			102, 0, 102, 102, 6, 0, 96, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 6,
			64, 100, 102, 102, 96, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 6,
			102, 102, 0, 0, 96, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 96, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 6, 0, 0, 0, 0, 0, 0,
			0, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 102, 102, 102, 102, 102, 102, 102, 102,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
			102, 102, 102, 102, 102, 10

UserLibs/Jint.dll

Decompiled 17 hours ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Esprima;
using Esprima.Ast;
using Esprima.Utils;
using Jint.Collections;
using Jint.Constraints;
using Jint.Extensions;
using Jint.Native;
using Jint.Native.AggregateError;
using Jint.Native.Array;
using Jint.Native.ArrayBuffer;
using Jint.Native.AsyncFunction;
using Jint.Native.BigInt;
using Jint.Native.Boolean;
using Jint.Native.DataView;
using Jint.Native.Date;
using Jint.Native.Error;
using Jint.Native.FinalizationRegistry;
using Jint.Native.Function;
using Jint.Native.Generator;
using Jint.Native.Global;
using Jint.Native.Intl;
using Jint.Native.Iterator;
using Jint.Native.Json;
using Jint.Native.Map;
using Jint.Native.Math;
using Jint.Native.Number;
using Jint.Native.Number.Dtoa;
using Jint.Native.Object;
using Jint.Native.Promise;
using Jint.Native.Proxy;
using Jint.Native.Reflect;
using Jint.Native.RegExp;
using Jint.Native.Set;
using Jint.Native.ShadowRealm;
using Jint.Native.SharedArrayBuffer;
using Jint.Native.String;
using Jint.Native.Symbol;
using Jint.Native.TypedArray;
using Jint.Native.WeakMap;
using Jint.Native.WeakRef;
using Jint.Native.WeakSet;
using Jint.Pooling;
using Jint.Runtime;
using Jint.Runtime.CallStack;
using Jint.Runtime.Debugger;
using Jint.Runtime.Descriptors;
using Jint.Runtime.Descriptors.Specialized;
using Jint.Runtime.Environments;
using Jint.Runtime.Interop;
using Jint.Runtime.Interop.Reflection;
using Jint.Runtime.Interpreter;
using Jint.Runtime.Interpreter.Expressions;
using Jint.Runtime.Interpreter.Statements;
using Jint.Runtime.Modules;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Jint.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
[assembly: InternalsVisibleTo("Jint.Tests.Test262, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
[assembly: InternalsVisibleTo("Jint.Benchmark, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Sebastien Ros")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Sebastien Ros")]
[assembly: AssemblyDescription("Javascript interpreter for .NET.")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: AssemblyInformationalVersion("3.1.5+6cb44564e35d18646604dedb002170be1fd941d9")]
[assembly: AssemblyProduct("Jint")]
[assembly: AssemblyTitle("Jint")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/sebastienros/jint")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.1.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: SkipLocalsInit]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	internal sealed class ScopedRefAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")]
	internal sealed class ObsoletedOSPlatformAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public ObsoletedOSPlatformAttribute(string platformName)
		{
		}

		public ObsoletedOSPlatformAttribute(string platformName, string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices2
{
	[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	[Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")]
	internal sealed class InlineArrayAttribute : Attribute
	{
		public int Length { get; }

		public InlineArrayAttribute(int length)
		{
			Length = length;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	[Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")]
	internal sealed class DisableRuntimeMarshallingAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")]
	internal sealed class UnsafeAccessorAttribute : Attribute
	{
		public UnsafeAccessorKind Kind { get; }

		public string? Name { get; set; }

		public UnsafeAccessorAttribute(UnsafeAccessorKind kind)
		{
			Kind = kind;
		}
	}
	internal enum UnsafeAccessorKind
	{
		Constructor,
		Method,
		StaticMethod,
		Field,
		StaticField
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")]
	internal sealed class RequiresDynamicCodeAttribute : Attribute
	{
		public string Message { get; }

		public string? Url { get; set; }

		public RequiresDynamicCodeAttribute(string message)
		{
			Message = message;
		}
	}
}
namespace System.Text
{
	internal ref struct ValueStringBuilder
	{
		private char[]? _arrayToReturnToPool;

		private Span<char> _chars;

		private int _pos;

		public int Length
		{
			get
			{
				return _pos;
			}
			set
			{
				_pos = value;
			}
		}

		public int Capacity => _chars.Length;

		public ref char this[int index] => ref _chars[index];

		public Span<char> RawChars => _chars;

		public ValueStringBuilder(Span<char> initialBuffer)
		{
			_arrayToReturnToPool = null;
			_chars = initialBuffer;
			_pos = 0;
		}

		public ValueStringBuilder(int initialCapacity)
		{
			_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity);
			_chars = _arrayToReturnToPool;
			_pos = 0;
		}

		public void EnsureCapacity(int capacity)
		{
			if ((uint)capacity > (uint)_chars.Length)
			{
				Grow(capacity - _pos);
			}
		}

		public ref char GetPinnableReference()
		{
			return ref MemoryMarshal.GetReference(_chars);
		}

		public ref char GetPinnableReference(bool terminate)
		{
			if (terminate)
			{
				EnsureCapacity(Length + 1);
				_chars[Length] = '\0';
			}
			return ref MemoryMarshal.GetReference(_chars);
		}

		public override string ToString()
		{
			string result = _chars.Slice(0, _pos).ToString();
			Dispose();
			return result;
		}

		public ReadOnlySpan<char> AsSpan(bool terminate)
		{
			if (terminate)
			{
				EnsureCapacity(Length + 1);
				_chars[Length] = '\0';
			}
			return _chars.Slice(0, _pos);
		}

		public ReadOnlySpan<char> AsSpan()
		{
			return _chars.Slice(0, _pos);
		}

		public ReadOnlySpan<char> AsSpan(int start)
		{
			return _chars.Slice(start, _pos - start);
		}

		public ReadOnlySpan<char> AsSpan(int start, int length)
		{
			return _chars.Slice(start, length);
		}

		public void Reverse()
		{
			_chars.Slice(0, _pos).Reverse();
		}

		public bool TryCopyTo(Span<char> destination, out int charsWritten)
		{
			if (_chars.Slice(0, _pos).TryCopyTo(destination))
			{
				charsWritten = _pos;
				Dispose();
				return true;
			}
			charsWritten = 0;
			Dispose();
			return false;
		}

		public void Insert(int index, char value, int count)
		{
			if (_pos > _chars.Length - count)
			{
				Grow(count);
			}
			int length = _pos - index;
			_chars.Slice(index, length).CopyTo(_chars.Slice(index + count));
			_chars.Slice(index, count).Fill(value);
			_pos += count;
		}

		public void Insert(int index, string? s)
		{
			if (s != null)
			{
				int length = s.Length;
				if (_pos > _chars.Length - length)
				{
					Grow(length);
				}
				int length2 = _pos - index;
				_chars.Slice(index, length2).CopyTo(_chars.Slice(index + length));
				s.CopyTo(_chars.Slice(index));
				_pos += length;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Append(char c)
		{
			int pos = _pos;
			Span<char> chars = _chars;
			if ((uint)pos < (uint)chars.Length)
			{
				chars[pos] = c;
				_pos = pos + 1;
			}
			else
			{
				GrowAndAppend(c);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Append(string? s)
		{
			if (s != null)
			{
				int pos = _pos;
				if (s.Length == 1 && (uint)pos < (uint)_chars.Length)
				{
					_chars[pos] = s[0];
					_pos = pos + 1;
				}
				else
				{
					AppendSlow(s);
				}
			}
		}

		private void AppendSlow(string s)
		{
			int pos = _pos;
			if (pos > _chars.Length - s.Length)
			{
				Grow(s.Length);
			}
			s.CopyTo(_chars.Slice(pos));
			_pos += s.Length;
		}

		public void Append(char c, int count)
		{
			if (_pos > _chars.Length - count)
			{
				Grow(count);
			}
			Span<char> span = _chars.Slice(_pos, count);
			for (int i = 0; i < span.Length; i++)
			{
				span[i] = c;
			}
			_pos += count;
		}

		public unsafe void Append(char* value, int length)
		{
			if (_pos > _chars.Length - length)
			{
				Grow(length);
			}
			Span<char> span = _chars.Slice(_pos, length);
			for (int i = 0; i < span.Length; i++)
			{
				span[i] = *(value++);
			}
			_pos += length;
		}

		public void Append(scoped ReadOnlySpan<char> value)
		{
			if (_pos > _chars.Length - value.Length)
			{
				Grow(value.Length);
			}
			value.CopyTo(_chars.Slice(_pos));
			_pos += value.Length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span<char> AppendSpan(int length)
		{
			int pos = _pos;
			if (pos > _chars.Length - length)
			{
				Grow(length);
			}
			_pos = pos + length;
			return _chars.Slice(pos, length);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void GrowAndAppend(char c)
		{
			Grow(1);
			Append(c);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void Grow(int additionalCapacityBeyondPos)
		{
			int minimumLength = (int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), Math.Min((uint)(_chars.Length * 2), 2147483591u));
			char[] array = ArrayPool<char>.Shared.Rent(minimumLength);
			_chars.Slice(0, _pos).CopyTo(array);
			char[] arrayToReturnToPool = _arrayToReturnToPool;
			_chars = (_arrayToReturnToPool = array);
			if (arrayToReturnToPool != null)
			{
				ArrayPool<char>.Shared.Return(arrayToReturnToPool);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Dispose()
		{
			char[] arrayToReturnToPool = _arrayToReturnToPool;
			this = default(System.Text.ValueStringBuilder);
			if (arrayToReturnToPool != null)
			{
				ArrayPool<char>.Shared.Return(arrayToReturnToPool);
			}
		}
	}
}
namespace System.Buffers
{
	internal static class SearchValues
	{
		internal static SearchValues<char> Create(string input)
		{
			return new SearchValues<char>(input.AsSpan());
		}

		internal static SearchValues<char> Create(ReadOnlySpan<char> input)
		{
			return new SearchValues<char>(input);
		}
	}
	internal sealed class SearchValues<T>
	{
		private readonly bool[] _data;

		private readonly char _min;

		private readonly char _max;

		internal SearchValues(ReadOnlySpan<char> input)
		{
			_min = '\uffff';
			_max = '\0';
			ReadOnlySpan<char> readOnlySpan = input;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				char val = readOnlySpan[i];
				_min = (char)Math.Min(_min, val);
				_max = (char)Math.Max(_max, val);
			}
			_data = new bool[_max - _min + 1];
			readOnlySpan = input;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				char c = readOnlySpan[i];
				_data[c - _min] = true;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool Contains(char c)
		{
			uint num = (uint)(c - _min);
			bool[] data = _data;
			if (num < data.Length)
			{
				return data[num];
			}
			return false;
		}
	}
}
namespace Jint
{
	internal sealed class Agent
	{
		private readonly List<JsValue> _keptAlive = new List<JsValue>();

		public void AddToKeptObjects(JsValue target)
		{
			_keptAlive.Add(target);
		}

		public void ClearKeptObjects()
		{
			_keptAlive.Clear();
		}
	}
	public static class AstExtensions
	{
		internal readonly record struct Record(JsValue Key, ScriptFunction Closure);

		private sealed class MinimalSyntaxElement : SyntaxElement
		{
			public MinimalSyntaxElement(in Location location)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				base.Location = location;
			}
		}

		private sealed class PrivateIdentifierValidator : AstVisitor
		{
			private readonly Realm _realm;

			private HashSet<PrivateIdentifier>? _privateNames;

			public PrivateIdentifierValidator(Realm realm, HashSet<PrivateIdentifier>? privateNames)
			{
				_realm = realm;
				_privateNames = privateNames;
			}

			protected override object VisitPrivateIdentifier(PrivateIdentifier privateIdentifier)
			{
				if (_privateNames == null || !_privateNames.Contains(privateIdentifier))
				{
					Throw(_realm, privateIdentifier);
				}
				return privateIdentifier;
			}

			protected override object VisitClassBody(ClassBody classBody)
			{
				HashSet<PrivateIdentifier> privateNames = _privateNames;
				_privateNames = new HashSet<PrivateIdentifier>(PrivateIdentifierNameComparer._instance);
				((Node)(object)classBody).PrivateBoundIdentifiers(_privateNames);
				((AstVisitor)this).VisitClassBody(classBody);
				_privateNames = privateNames;
				return classBody;
			}

			[MethodImpl(MethodImplOptions.NoInlining)]
			private static void Throw(Realm r, PrivateIdentifier id)
			{
				ExceptionHelper.ThrowSyntaxError(r, "Private field '#" + id.Name + "' must be declared in an enclosing class");
			}
		}

		public static JsValue GetKey<T>(this T property, Engine engine) where T : IProperty
		{
			return ((IProperty)property).Key.GetKey(engine, ((IProperty)property).Computed);
		}

		public static JsValue GetKey(this Expression expression, Engine engine, bool resolveComputed = false)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			JsValue jsValue = expression.TryGetKey<Expression>(engine, resolveComputed);
			if ((object)jsValue != null)
			{
				return TypeConverter.ToPropertyKey(jsValue);
			}
			ExceptionHelper.ThrowArgumentException("Unable to extract correct key, node type: " + ((object)((Node)expression).Type/*cast due to .constrained prefix*/).ToString());
			return JsValue.Undefined;
		}

		internal static JsValue TryGetKey<T>(this T property, Engine engine) where T : IProperty
		{
			return ((IProperty)property).Key.TryGetKey<Expression>(engine, ((IProperty)property).Computed);
		}

		internal static JsValue TryGetKey<T>(this T expression, Engine engine, bool resolveComputed) where T : Expression
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			object obj = expression;
			Literal val = (Literal)((obj is Literal) ? obj : null);
			if (val != null)
			{
				return ((int)val.TokenType == 5) ? JsValue.Null : ((JsValue)LiteralKeyToString(val));
			}
			if (!resolveComputed)
			{
				object obj2 = expression;
				Identifier val2 = (Identifier)((obj2 is Identifier) ? obj2 : null);
				if (val2 != null)
				{
					return val2.Name;
				}
			}
			object obj3 = expression;
			PrivateIdentifier val3 = (PrivateIdentifier)((obj3 is PrivateIdentifier) ? obj3 : null);
			if (val3 != null)
			{
				return engine.ExecutionContext.PrivateEnvironment.Names[val3];
			}
			if (resolveComputed)
			{
				return TryGetComputedPropertyKey(expression, engine);
			}
			return JsValue.Undefined;
		}

		private static JsValue TryGetComputedPropertyKey<T>(T expression, Engine engine) where T : Expression
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			Nodes type = ((Node)(object)expression).Type;
			if ((int)type <= 16)
			{
				if ((int)type <= 7)
				{
					if (type - 3 <= 1 || (int)type == 7)
					{
						goto IL_0053;
					}
				}
				else if ((int)type == 10 || (int)type == 16)
				{
					goto IL_0053;
				}
			}
			else if ((int)type <= 43)
			{
				if (type - 31 <= 1 || type - 42 <= 1)
				{
					goto IL_0053;
				}
			}
			else if ((int)type == 63 || type - 67 <= 1 || (int)type == 73)
			{
				goto IL_0053;
			}
			bool flag = false;
			goto IL_0059;
			IL_0053:
			flag = true;
			goto IL_0059;
			IL_0059:
			if (flag)
			{
				EvaluationContext activeEvaluationContext = engine._activeEvaluationContext;
				return JintExpression.Build((Expression)(object)expression).GetValue(activeEvaluationContext);
			}
			return JsValue.Undefined;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool IsFunctionDefinition<T>(this T node) where T : Node
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			Nodes type = ((Node)node).Type;
			if ((int)type == 3 || (int)type == 15 || (int)type == 31)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool IsConstantDeclaration(this Declaration d)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			VariableDeclaration val = (VariableDeclaration)(object)((d is VariableDeclaration) ? d : null);
			if (val != null)
			{
				return (int)val.Kind == 2;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool HasName<T>(this T node) where T : Node
		{
			if (!node.IsFunctionDefinition())
			{
				return false;
			}
			object obj = node;
			object obj2 = ((obj is IFunction) ? obj : null);
			if (((obj2 != null) ? ((IFunction)obj2).Id : null) != null)
			{
				return true;
			}
			object obj3 = node;
			object obj4 = ((obj3 is ClassExpression) ? obj3 : null);
			if (((obj4 != null) ? ((ClassExpression)obj4).Id : null) != null)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool IsAnonymousFunctionDefinition<T>(this T node) where T : Node
		{
			if (!node.IsFunctionDefinition())
			{
				return false;
			}
			if (node.HasName())
			{
				return false;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool IsOptional<T>(this T node) where T : Expression
		{
			object obj = node;
			MemberExpression val = (MemberExpression)((obj is MemberExpression) ? obj : null);
			if (val != null)
			{
				if (val.Optional)
				{
					goto IL_0030;
				}
			}
			else
			{
				object obj2 = node;
				CallExpression val2 = (CallExpression)((obj2 is CallExpression) ? obj2 : null);
				if (val2 != null && val2.Optional)
				{
					goto IL_0030;
				}
			}
			return false;
			IL_0030:
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static string LiteralKeyToString(Literal literal)
		{
			if (literal.Value is double num)
			{
				return TypeConverter.ToString(num);
			}
			return (literal.Value as string) ?? Convert.ToString(literal.Value, null) ?? "";
		}

		internal static void GetBoundNames(this VariableDeclaration variableDeclaration, List<Key> target)
		{
			ref NodeList<VariableDeclarator> declarations = variableDeclaration.Declarations;
			for (int i = 0; i < declarations.Count; i++)
			{
				declarations[i].Id.GetBoundNames(target);
			}
		}

		internal static void GetBoundNames(this Node? parameter, List<Key> target)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			if (parameter == null || (int)parameter.Type == 41)
			{
				return;
			}
			Identifier val = (Identifier)(object)((parameter is Identifier) ? parameter : null);
			if (val != null)
			{
				target.Add(val.Name);
				return;
			}
			VariableDeclaration val2 = (VariableDeclaration)(object)((parameter is VariableDeclaration) ? parameter : null);
			if (val2 != null)
			{
				val2.GetBoundNames(target);
				return;
			}
			while (true)
			{
				Identifier val3 = (Identifier)(object)((parameter is Identifier) ? parameter : null);
				if (val3 != null)
				{
					target.Add(val3.Name);
					return;
				}
				RestElement val4 = (RestElement)(object)((parameter is RestElement) ? parameter : null);
				if (val4 != null)
				{
					parameter = val4.Argument;
					continue;
				}
				ArrayPattern val5 = (ArrayPattern)(object)((parameter is ArrayPattern) ? parameter : null);
				if (val5 != null)
				{
					ref NodeList<Node> elements = val5.Elements;
					for (int i = 0; i < elements.Count; i++)
					{
						elements[i].GetBoundNames(target);
					}
					return;
				}
				ObjectPattern val6 = (ObjectPattern)(object)((parameter is ObjectPattern) ? parameter : null);
				if (val6 != null)
				{
					ref NodeList<Node> properties = val6.Properties;
					for (int j = 0; j < properties.Count; j++)
					{
						Node val7 = properties[j];
						Property val8 = (Property)(object)((val7 is Property) ? val7 : null);
						if (val8 != null)
						{
							val8.Value.GetBoundNames(target);
						}
						else
						{
							((Node?)(RestElement)val7).GetBoundNames(target);
						}
					}
					return;
				}
				AssignmentPattern val9 = (AssignmentPattern)(object)((parameter is AssignmentPattern) ? parameter : null);
				if (val9 == null)
				{
					break;
				}
				parameter = val9.Left;
			}
			ClassDeclaration val10 = (ClassDeclaration)(object)((parameter is ClassDeclaration) ? parameter : null);
			if (val10 != null)
			{
				Identifier id = val10.Id;
				string text = ((id != null) ? id.Name : null);
				if (text != null)
				{
					target.Add(text);
				}
			}
		}

		internal static void PrivateBoundIdentifiers(this Node parameter, HashSet<PrivateIdentifier> target)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((int)parameter.Type == 49)
			{
				target.Add((PrivateIdentifier)parameter);
				return;
			}
			Nodes type = parameter.Type;
			if (((int)type == 0 || (int)type == 45 || (int)type == 52) ? true : false)
			{
				Expression key = ((ClassProperty)parameter).Key;
				PrivateIdentifier val = (PrivateIdentifier)(object)((key is PrivateIdentifier) ? key : null);
				if (val != null)
				{
					target.Add(val);
				}
			}
			else if ((int)parameter.Type == 13)
			{
				ref NodeList<ClassElement> body = ((ClassBody)parameter).Body;
				for (int i = 0; i < body.Count; i++)
				{
					((Node)(object)body[i]).PrivateBoundIdentifiers(target);
				}
			}
		}

		internal static void BindingInitialization(this Node? expression, EvaluationContext context, JsValue value, Jint.Runtime.Environments.Environment env)
		{
			Identifier val = (Identifier)(object)((expression is Identifier) ? expression : null);
			if (val != null)
			{
				((DeclarativeEnvironment)env).CreateMutableBindingAndInitialize(val.Name, canBeDeleted: false, value);
				return;
			}
			BindingPattern val2 = (BindingPattern)(object)((expression is BindingPattern) ? expression : null);
			if (val2 != null)
			{
				DestructuringPatternAssignmentExpression.ProcessPatterns(context, val2, value, env);
			}
		}

		internal static Record DefineMethod<T>(this T m, ObjectInstance obj, ObjectInstance? functionPrototype = null) where T : IProperty
		{
			Engine engine = obj.Engine;
			JsValue key = TypeConverter.ToPropertyKey(m.GetKey(engine));
			Intrinsics intrinsics = engine.Realm.Intrinsics;
			Jint.Runtime.Environments.ExecutionContext executionContext = engine.ExecutionContext;
			Jint.Runtime.Environments.Environment lexicalEnvironment = executionContext.LexicalEnvironment;
			PrivateEnvironment privateEnvironment = executionContext.PrivateEnvironment;
			ObjectInstance functionPrototype2 = functionPrototype ?? intrinsics.Function.PrototypeObject;
			Node value = ((IProperty)m).Value;
			Node obj2 = ((value is IFunction) ? value : null);
			if (obj2 == null)
			{
				ExceptionHelper.ThrowSyntaxError(engine.Realm);
			}
			JintFunctionDefinition jintFunctionDefinition = new JintFunctionDefinition((IFunction)(object)obj2);
			ScriptFunction scriptFunction = intrinsics.Function.OrdinaryFunctionCreate(functionPrototype2, jintFunctionDefinition, jintFunctionDefinition.ThisMode, lexicalEnvironment, privateEnvironment);
			scriptFunction.MakeMethod(obj);
			return new Record(key, scriptFunction);
		}

		internal unsafe static void GetImportEntries(this ImportDeclaration import, List<ImportEntry> importEntries, HashSet<ModuleRequest> requestedModules)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			string stringValue = import.Source.StringValue;
			NodeList<ImportDeclarationSpecifier> specifiers = Unsafe.Read<NodeList<ImportDeclarationSpecifier>>((void*)import.Specifiers);
			ModuleImportAttribute[] attributes = GetAttributes(import.Attributes);
			requestedModules.Add(new ModuleRequest(stringValue, attributes));
			Enumerator<ImportDeclarationSpecifier> enumerator = specifiers.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ImportDeclarationSpecifier current = enumerator.Current;
					ImportNamespaceSpecifier val = (ImportNamespaceSpecifier)(object)((current is ImportNamespaceSpecifier) ? current : null);
					if (val == null)
					{
						ImportSpecifier val2 = (ImportSpecifier)(object)((current is ImportSpecifier) ? current : null);
						if (val2 == null)
						{
							ImportDefaultSpecifier val3 = (ImportDefaultSpecifier)(object)((current is ImportDefaultSpecifier) ? current : null);
							if (val3 != null)
							{
								importEntries.Add(new ImportEntry(new ModuleRequest(stringValue, attributes), "default", ((Expression)(object)((ImportDeclarationSpecifier)val3).Local).GetModuleKey()));
							}
						}
						else
						{
							importEntries.Add(new ImportEntry(new ModuleRequest(stringValue, attributes), val2.Imported.GetModuleKey(), ((Expression)(object)((ImportDeclarationSpecifier)val2).Local).GetModuleKey()));
						}
					}
					else
					{
						importEntries.Add(new ImportEntry(new ModuleRequest(stringValue, attributes), "*", ((Expression)(object)((ImportDeclarationSpecifier)val).Local).GetModuleKey()));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static ModuleImportAttribute[] GetAttributes(in NodeList<ImportAttribute> importAttributes)
		{
			if (importAttributes.Count == 0)
			{
				return Array.Empty<ModuleImportAttribute>();
			}
			ModuleImportAttribute[] array = new ModuleImportAttribute[importAttributes.Count];
			for (int i = 0; i < importAttributes.Count; i++)
			{
				ImportAttribute val = importAttributes[i];
				array[i] = new ModuleImportAttribute(((object)val.Key).ToString(), val.Value.StringValue);
			}
			return array;
		}

		internal static void GetExportEntries(this ExportDeclaration export, List<ExportEntry> exportEntries, HashSet<ModuleRequest> requestedModules)
		{
			ExportDefaultDeclaration val = (ExportDefaultDeclaration)(object)((export is ExportDefaultDeclaration) ? export : null);
			if (val == null)
			{
				ExportAllDeclaration val2 = (ExportAllDeclaration)(object)((export is ExportAllDeclaration) ? export : null);
				if (val2 == null)
				{
					ExportNamedDeclaration val3 = (ExportNamedDeclaration)(object)((export is ExportNamedDeclaration) ? export : null);
					if (val3 == null)
					{
						return;
					}
					ref NodeList<ExportSpecifier> specifiers = val3.Specifiers;
					if (specifiers.Count == 0)
					{
						ModuleRequest? obj;
						if (val3.Source == null)
						{
							obj = null;
						}
						else
						{
							Literal source = val3.Source;
							obj = new ModuleRequest((source != null) ? source.StringValue : null, Array.Empty<ModuleImportAttribute>());
						}
						ModuleRequest? moduleRequest = obj;
						GetExportEntries(defaultExport: false, (StatementListItem)(object)val3.Declaration, exportEntries, moduleRequest);
					}
					else
					{
						for (int i = 0; i < specifiers.Count; i++)
						{
							ExportSpecifier val4 = specifiers[i];
							if (val3.Source != null)
							{
								exportEntries.Add(new ExportEntry(val4.Exported.GetModuleKey(), new ModuleRequest(val3.Source.StringValue, Array.Empty<ModuleImportAttribute>()), val4.Local.GetModuleKey(), null));
							}
							else
							{
								exportEntries.Add(new ExportEntry(val4.Exported.GetModuleKey(), null, null, val4.Local.GetModuleKey()));
							}
						}
					}
					if (val3.Source != null)
					{
						requestedModules.Add(new ModuleRequest(val3.Source.StringValue, Array.Empty<ModuleImportAttribute>()));
					}
				}
				else
				{
					requestedModules.Add(new ModuleRequest(val2.Source.StringValue, Array.Empty<ModuleImportAttribute>()));
					Expression exported = val2.Exported;
					exportEntries.Add(new ExportEntry((exported != null) ? exported.GetModuleKey() : null, new ModuleRequest(val2.Source.StringValue, Array.Empty<ModuleImportAttribute>()), "*", null));
				}
			}
			else
			{
				GetExportEntries(defaultExport: true, val.Declaration, exportEntries);
			}
		}

		private static void GetExportEntries(bool defaultExport, StatementListItem declaration, List<ExportEntry> exportEntries, ModuleRequest? moduleRequest = null)
		{
			List<Key> exportNames = GetExportNames(declaration);
			if (exportNames.Count == 0)
			{
				if (defaultExport)
				{
					exportEntries.Add(new ExportEntry("default", null, null, "*default*"));
				}
				return;
			}
			for (int i = 0; i < exportNames.Count; i++)
			{
				Key key = exportNames[i];
				string exportName = (defaultExport ? "default" : key.Name);
				exportEntries.Add(new ExportEntry(exportName, moduleRequest, null, key));
			}
		}

		private static List<Key> GetExportNames(StatementListItem declaration)
		{
			List<Key> list = new List<Key>();
			FunctionDeclaration val = (FunctionDeclaration)(object)((declaration is FunctionDeclaration) ? declaration : null);
			if (val == null)
			{
				ClassDeclaration val2 = (ClassDeclaration)(object)((declaration is ClassDeclaration) ? declaration : null);
				if (val2 == null)
				{
					((VariableDeclaration)(object)((declaration is VariableDeclaration) ? declaration : null))?.GetBoundNames(list);
				}
				else
				{
					Identifier id = val2.Id;
					string text = ((id != null) ? id.Name : null);
					if (text != null)
					{
						list.Add(text);
					}
				}
			}
			else
			{
				Identifier id2 = val.Id;
				string text2 = ((id2 != null) ? id2.Name : null);
				if (text2 != null)
				{
					list.Add(text2);
				}
			}
			return list;
		}

		private static string GetModuleKey(this Expression expression)
		{
			Expression obj = ((expression is Identifier) ? expression : null);
			return ((obj != null) ? ((Identifier)obj).Name : null) ?? ((Literal)((expression is Literal) ? expression : null)).StringValue;
		}

		internal static SyntaxElement CreateLocationNode(in Location location)
		{
			return (SyntaxElement)(object)new MinimalSyntaxElement(in location);
		}

		internal static void AllPrivateIdentifiersValid(this Script script, Realm realm, HashSet<PrivateIdentifier>? privateIdentifiers)
		{
			((AstVisitor)new PrivateIdentifierValidator(realm, privateIdentifiers)).Visit((Node)(object)script);
		}
	}
	public static class ConstraintsOptionsExtensions
	{
		public static Options MaxStatements(this Options options, int maxStatements = 0)
		{
			options.WithoutConstraint((Constraint x) => x is MaxStatementsConstraint);
			if (maxStatements > 0 && maxStatements < int.MaxValue)
			{
				options.Constraint(new MaxStatementsConstraint(maxStatements));
			}
			return options;
		}

		public static Options LimitMemory(this Options options, long memoryLimit)
		{
			options.WithoutConstraint((Constraint x) => x is MemoryLimitConstraint);
			if (memoryLimit > 0 && memoryLimit < int.MaxValue)
			{
				options.Constraint(new MemoryLimitConstraint(memoryLimit));
			}
			return options;
		}

		public static Options TimeoutInterval(this Options options, TimeSpan timeoutInterval)
		{
			if (timeoutInterval > TimeSpan.Zero && timeoutInterval < TimeSpan.MaxValue)
			{
				options.Constraint(new TimeConstraint(timeoutInterval));
			}
			return options;
		}

		public static Options CancellationToken(this Options options, CancellationToken cancellationToken)
		{
			options.WithoutConstraint((Constraint x) => x is CancellationConstraint);
			if (cancellationToken != default(CancellationToken))
			{
				options.Constraint(new CancellationConstraint(cancellationToken));
			}
			return options;
		}
	}
	public enum DeclarationBindingType
	{
		GlobalCode,
		FunctionCode,
		EvalCode
	}
	[DebuggerTypeProxy(typeof(EngineDebugView))]
	public sealed class Engine : IDisposable
	{
		public class AdvancedOperations
		{
			private readonly Engine _engine;

			public string StackTrace
			{
				get
				{
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					SyntaxElement lastSyntaxElement = _engine._lastSyntaxElement;
					if (lastSyntaxElement == null)
					{
						return string.Empty;
					}
					return _engine.CallStack.BuildCallStackString(lastSyntaxElement.Location);
				}
			}

			internal AdvancedOperations(Engine engine)
			{
				_engine = engine;
			}

			public void ResetCallStack()
			{
				_engine.ResetCallStack();
			}

			public void ProcessTasks()
			{
				_engine.RunAvailableContinuations();
			}

			public ManualPromise RegisterPromise()
			{
				return _engine.RegisterPromise();
			}
		}

		private sealed class AstAnalyzer
		{
			private static readonly bool _canCompileNegativeLookaroundAssertions;

			private readonly IPreparationOptions<IParsingOptions> _preparationOptions;

			private readonly Dictionary<string, Jint.Runtime.Environments.Environment.BindingName> _bindingNames = new Dictionary<string, Jint.Runtime.Environments.Environment.BindingName>(StringComparer.Ordinal);

			private readonly Dictionary<string, Regex> _regexes = new Dictionary<string, Regex>(StringComparer.Ordinal);

			public AstAnalyzer(IPreparationOptions<IParsingOptions> preparationOptions)
			{
				_preparationOptions = preparationOptions;
			}

			public void NodeVisitor(Node node)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Invalid comparison between Unknown and I4
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Invalid comparison between Unknown and I4
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Invalid comparison between Unknown and I4
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Invalid comparison between Unknown and I4
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Invalid comparison between Unknown and I4
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Invalid comparison between Unknown and I4
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Invalid comparison between Unknown and I4
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Invalid comparison between Unknown and I4
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d5: Expected O, but got Unknown
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Invalid comparison between Unknown and I4
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Invalid comparison between Unknown and I4
				//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b7: Expected O, but got Unknown
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Invalid comparison between Unknown and I4
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Expected O, but got Unknown
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Expected O, but got Unknown
				//IL_0208: Unknown result type (might be due to invalid IL or missing references)
				//IL_020f: Expected O, but got Unknown
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0201: Expected O, but got Unknown
				//IL_0221: Unknown result type (might be due to invalid IL or missing references)
				//IL_0228: Invalid comparison between Unknown and I4
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Invalid comparison between Unknown and I4
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: Invalid comparison between Unknown and I4
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Expected O, but got Unknown
				//IL_012a: 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)
				Nodes type = node.Type;
				if ((int)type <= 32)
				{
					if ((int)type <= 7)
					{
						if ((int)type != 3)
						{
							if ((int)type != 7)
							{
								return;
							}
							BinaryExpression val = (BinaryExpression)node;
							if (!_preparationOptions.FoldConstants || (int)val.Operator == 19 || (int)val.Operator == 20 || val == null)
							{
								return;
							}
							Expression left = val.Left;
							Literal val2 = (Literal)(object)((left is Literal) ? left : null);
							if (val2 == null)
							{
								return;
							}
							Expression right = val.Right;
							Literal val3 = (Literal)(object)((right is Literal) ? right : null);
							if (val3 == null)
							{
								return;
							}
							JsValue? jsValue = JintLiteralExpression.ConvertToJsValue(val2);
							JsValue jsValue2 = JintLiteralExpression.ConvertToJsValue(val3);
							if ((object)jsValue == null || (object)jsValue2 == null)
							{
								return;
							}
							try
							{
								JintExpression jintExpression = JintBinaryExpression.Build(val);
								EvaluationContext context = new EvaluationContext();
								((SyntaxElement)node).AssociatedData = new JintConstantExpression((Expression)(object)val, (JsValue)jintExpression.EvaluateWithoutNodeTracking(context));
								return;
							}
							catch
							{
								return;
							}
						}
					}
					else if (type - 30 > 1)
					{
						if ((int)type == 32)
						{
							Identifier val4 = (Identifier)node;
							string name = val4.Name;
							if (!_bindingNames.TryGetValue(name, out Jint.Runtime.Environments.Environment.BindingName value))
							{
								value = (_bindingNames[name] = new Jint.Runtime.Environments.Environment.BindingName(JsString.CachedCreate(name)));
							}
							((SyntaxElement)node).AssociatedData = new JintIdentifierExpression(val4, value);
						}
						return;
					}
					IFunction function = (IFunction)node;
					((SyntaxElement)node).AssociatedData = JintFunctionDefinition.BuildState(function);
				}
				else if ((int)type <= 43)
				{
					if ((int)type != 41)
					{
						if ((int)type == 43)
						{
							((SyntaxElement)node).AssociatedData = JintMemberExpression.InitializeDeterminedProperty((MemberExpression)node, cache: true);
						}
						return;
					}
					Literal val5 = (Literal)node;
					JsValue jsValue3 = JintLiteralExpression.ConvertToJsValue(val5);
					((SyntaxElement)node).AssociatedData = (((object)jsValue3 != null) ? new JintConstantExpression((Expression)(object)val5, jsValue3) : null);
					if (((SyntaxElement)node).AssociatedData != null || (int)val5.TokenType != 9 || _canCompileNegativeLookaroundAssertions || _preparationOptions.ParsingOptions.CompileRegex == false)
					{
						return;
					}
					RegExpLiteral val6 = (RegExpLiteral)val5;
					RegExpParseResult parseResult = val6.ParseResult;
					if (!((RegExpParseResult)(ref parseResult)).Success || !((Literal)val6).Raw.Contains("(?!"))
					{
						return;
					}
					if (!_regexes.TryGetValue(((Literal)val6).Raw, out Regex value2))
					{
						value2 = ((RegExpParseResult)(ref parseResult)).Regex;
						if ((value2.Options & RegexOptions.Compiled) != RegexOptions.None)
						{
							value2 = new Regex(value2.ToString(), value2.Options & ~RegexOptions.Compiled, value2.MatchTimeout);
						}
						_regexes[((Literal)val6).Raw] = value2;
					}
					((SyntaxElement)val6).AssociatedData = value2;
				}
				else if ((int)type != 50)
				{
					if ((int)type != 54)
					{
						if ((int)type == 67)
						{
							((SyntaxElement)node).AssociatedData = JintUnaryExpression.BuildConstantExpression((UnaryExpression)node);
						}
						return;
					}
					ReturnStatement val7 = (ReturnStatement)node;
					Expression argument = val7.Argument;
					Literal val8 = (Literal)(object)((argument is Literal) ? argument : null);
					if (val8 != null)
					{
						JsValue jsValue4 = JintLiteralExpression.ConvertToJsValue(val8);
						if ((object)jsValue4 != null)
						{
							((SyntaxElement)node).AssociatedData = new ConstantStatement((Statement)(object)val7, CompletionType.Return, jsValue4);
						}
					}
				}
				else
				{
					((SyntaxElement)node).AssociatedData = new CachedHoistingScope((Program)node);
				}
			}

			static AstAnalyzer()
			{
				int? num = typeof(Regex).Assembly.GetName().Version?.Major;
				bool flag;
				if (num.HasValue)
				{
					int valueOrDefault = num.GetValueOrDefault();
					if ((uint)(valueOrDefault - 7) > 1u)
					{
						flag = false;
						goto IL_0050;
					}
				}
				flag = true;
				goto IL_0050;
				IL_0050:
				_canCompileNegativeLookaroundAssertions = !flag;
			}
		}

		public class ConstraintOperations
		{
			private readonly Engine _engine;

			internal ConstraintOperations(Engine engine)
			{
				_engine = engine;
			}

			public void Check()
			{
				Constraint[] constraints = _engine._constraints;
				for (int i = 0; i < constraints.Length; i++)
				{
					constraints[i].Check();
				}
			}

			public T? Find<T>() where T : Constraint
			{
				Constraint[] constraints = _engine._constraints;
				foreach (Constraint constraint in constraints)
				{
					if (constraint.GetType() == typeof(T))
					{
						return (T)constraint;
					}
				}
				return null;
			}

			public void Reset()
			{
				Constraint[] constraints = _engine._constraints;
				for (int i = 0; i < constraints.Length; i++)
				{
					constraints[i].Reset();
				}
			}
		}

		internal readonly record struct ClrPropertyDescriptorFactoriesKey(Type Type, Key PropertyName);

		[DebuggerDisplay("Engine")]
		private sealed class EngineDebugView
		{
			private readonly Engine _engine;

			public ObjectInstance Globals => _engine.Realm.GlobalObject;

			public Options Options => _engine.Options;

			public Jint.Runtime.Environments.Environment VariableEnvironment => _engine.ExecutionContext.VariableEnvironment;

			public Jint.Runtime.Environments.Environment LexicalEnvironment => _engine.ExecutionContext.LexicalEnvironment;

			public EngineDebugView(Engine engine)
			{
				_engine = engine;
			}
		}

		public class ModuleOperations
		{
			private readonly Engine _engine;

			private readonly Dictionary<string, Jint.Runtime.Modules.Module> _modules = new Dictionary<string, Jint.Runtime.Modules.Module>(StringComparer.Ordinal);

			private readonly Dictionary<string, ModuleBuilder> _builders = new Dictionary<string, ModuleBuilder>(StringComparer.Ordinal);

			internal IModuleLoader ModuleLoader { get; }

			public ModuleOperations(Engine engine, IModuleLoader moduleLoader)
			{
				ModuleLoader = moduleLoader;
				_engine = engine;
			}

			internal Jint.Runtime.Modules.Module Load(string? referencingModuleLocation, ModuleRequest request)
			{
				_ = request.Specifier;
				ResolvedSpecifier resolvedSpecifier = ModuleLoader.Resolve(referencingModuleLocation, request);
				if (_modules.TryGetValue(resolvedSpecifier.Key, out Jint.Runtime.Modules.Module value))
				{
					return value;
				}
				value = ((!_builders.TryGetValue(resolvedSpecifier.Key, out ModuleBuilder value2)) ? LoadFromModuleLoader(resolvedSpecifier) : LoadFromBuilder(resolvedSpecifier.Key, value2, resolvedSpecifier));
				if (value is SourceTextModule sourceTextModule)
				{
					_engine.Debugger.OnBeforeEvaluate((Program)(object)sourceTextModule._source);
				}
				return value;
			}

			private BuilderModule LoadFromBuilder(string specifier, ModuleBuilder moduleBuilder, ResolvedSpecifier moduleResolution)
			{
				Prepared<Module> source = moduleBuilder.Parse();
				BuilderModule builderModule = new BuilderModule(_engine, _engine.Realm, in source, ((SyntaxElement)source.Program).Location.Source, async: false);
				_modules[moduleResolution.Key] = builderModule;
				moduleBuilder.BindExportedValues(builderModule);
				_builders.Remove(specifier);
				return builderModule;
			}

			private Jint.Runtime.Modules.Module LoadFromModuleLoader(ResolvedSpecifier moduleResolution)
			{
				Jint.Runtime.Modules.Module module = ModuleLoader.LoadModule(_engine, moduleResolution);
				_modules[moduleResolution.Key] = module;
				return module;
			}

			public void Add(string specifier, string code)
			{
				ModuleBuilder moduleBuilder = new ModuleBuilder(_engine, specifier);
				moduleBuilder.AddSource(code);
				Add(specifier, moduleBuilder);
			}

			public void Add(string specifier, Action<ModuleBuilder> buildModule)
			{
				ModuleBuilder moduleBuilder = new ModuleBuilder(_engine, specifier);
				buildModule(moduleBuilder);
				Add(specifier, moduleBuilder);
			}

			public void Add(string specifier, ModuleBuilder moduleBuilder)
			{
				_builders.Add(specifier, moduleBuilder);
			}

			public ObjectInstance Import(string specifier)
			{
				return Import(specifier, null);
			}

			internal ObjectInstance Import(string specifier, string? referencingModuleLocation)
			{
				return Import(new ModuleRequest(specifier, Array.Empty<ModuleImportAttribute>()), referencingModuleLocation);
			}

			internal ObjectInstance Import(ModuleRequest request, string? referencingModuleLocation)
			{
				ResolvedSpecifier resolvedSpecifier = ModuleLoader.Resolve(referencingModuleLocation, request);
				if (!_modules.TryGetValue(resolvedSpecifier.Key, out Jint.Runtime.Modules.Module value))
				{
					value = Load(referencingModuleLocation, request);
				}
				CyclicModule cyclicModule = value as CyclicModule;
				if ((object)cyclicModule == null)
				{
					LinkModule(request.Specifier, value);
					EvaluateModule(request.Specifier, value);
				}
				else if (cyclicModule.Status == ModuleStatus.Unlinked)
				{
					LinkModule(request.Specifier, cyclicModule);
					if (cyclicModule.Status == ModuleStatus.Linked)
					{
						_engine.ExecuteWithConstraints(strict: true, () => EvaluateModule(request.Specifier, cyclicModule));
					}
					if (cyclicModule.Status != ModuleStatus.Evaluated)
					{
						ExceptionHelper.ThrowNotSupportedException($"Error while evaluating module: Module is in an invalid state: '{cyclicModule.Status}'");
					}
				}
				_engine.RunAvailableContinuations();
				return Jint.Runtime.Modules.Module.GetModuleNamespace(value);
			}

			private static void LinkModule(string specifier, Jint.Runtime.Modules.Module module)
			{
				module.Link();
			}

			private JsValue EvaluateModule(string specifier, Jint.Runtime.Modules.Module module)
			{
				//IL_00bb: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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)
				bool flag = _engine._activeEvaluationContext == null;
				Engine engine = _engine;
				if (engine._activeEvaluationContext == null)
				{
					engine._activeEvaluationContext = new EvaluationContext(_engine);
				}
				JsValue jsValue;
				try
				{
					jsValue = module.Evaluate();
				}
				finally
				{
					if (flag)
					{
						_engine._activeEvaluationContext = null;
					}
				}
				if (!(jsValue is JsPromise jsPromise))
				{
					ExceptionHelper.ThrowInvalidOperationException($"Error while evaluating module: Module evaluation did not return a promise: {jsValue.Type}");
				}
				else if (jsPromise.State == PromiseState.Rejected)
				{
					SyntaxElement val = AstExtensions.CreateLocationNode((module is CyclicModule cyclicModule) ? cyclicModule.AbnormalCompletionLocation : Location.From(default(Position), default(Position), (string)null));
					ExceptionHelper.ThrowJavaScriptException(_engine, jsPromise.Value, in val.Location);
				}
				else if (jsPromise.State != PromiseState.Fulfilled)
				{
					ExceptionHelper.ThrowInvalidOperationException($"Error while evaluating module: Module evaluation did not return a fulfilled promise: {jsPromise.State}");
				}
				return jsValue;
			}
		}

		private static readonly Options _defaultEngineOptions = new Options();

		private readonly ParserOptions _defaultParserOptions;

		private readonly JavaScriptParser _defaultParser;

		private readonly ExecutionContextStack _executionContexts;

		private JsValue _completionValue = JsValue.Undefined;

		internal EvaluationContext? _activeEvaluationContext;

		internal ErrorDispatchInfo? _error;

		private readonly EventLoop _eventLoop = new EventLoop();

		private readonly Agent _agent = new Agent();

		private DebugHandler? _debugger;

		internal readonly IObjectConverter[]? _objectConverters;

		internal readonly Constraint[] _constraints;

		internal readonly bool _isDebugMode;

		internal readonly bool _isStrict;

		internal readonly IReferenceResolver _referenceResolver;

		internal readonly ReferencePool _referencePool;

		internal readonly ArgumentsInstancePool _argumentsInstancePool;

		internal readonly JsValueArrayPool _jsValueArrayPool;

		internal readonly ExtensionMethodCache _extensionMethods;

		internal readonly Dictionary<string, Type?> TypeCache = new Dictionary<string, Type>(StringComparer.Ordinal);

		internal Dictionary<Type, TypeReference>? _typeReferences;

		internal ConditionalWeakTable<object, ObjectInstance>? _objectWrapperCache;

		internal readonly JintCallStack CallStack;

		internal readonly StackGuard _stackGuard;

		internal Intrinsics _originalIntrinsics;

		internal Host _host;

		internal Dictionary<ClrPropertyDescriptorFactoriesKey, ReflectionAccessor> _reflectionAccessors = new Dictionary<ClrPropertyDescriptorFactoriesKey, ReflectionAccessor>();

		internal Realm? _realmInConstruction;

		internal SyntaxElement? _lastSyntaxElement;

		internal const bool FoldConstantsOnPrepareByDefault = true;

		internal static readonly ParserOptions BaseParserOptions;

		public AdvancedOperations Advanced { get; }

		public ConstraintOperations Constraints { get; }

		public ITypeConverter TypeConverter { get; internal set; }

		internal ref readonly Jint.Runtime.Environments.ExecutionContext ExecutionContext
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return ref _executionContexts.Peek();
			}
		}

		internal Realm Realm => _realmInConstruction ?? ExecutionContext.Realm;

		public Intrinsics Intrinsics => Realm.Intrinsics;

		public ObjectInstance Global => Realm.GlobalObject;

		internal GlobalSymbolRegistry GlobalSymbolRegistry { get; } = new GlobalSymbolRegistry();

		internal long CurrentMemoryUsage { get; private set; }

		internal Options Options
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			private set; }

		public DebugHandler Debugger => _debugger ?? (_debugger = new DebugHandler(this, Options.Debugger.InitialStepMode));

		public ModuleOperations Modules { get; internal set; }

		public static Prepared<Script> PrepareScript(string code, string? source = null, bool strict = false, ScriptPreparationOptions? options = null)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if ((object)options == null)
			{
				options = ScriptPreparationOptions.Default;
			}
			AstAnalyzer astAnalyzer = new AstAnalyzer(options);
			ParserOptions parserOptions = options.GetParserOptions();
			ParserOptions obj = parserOptions.<Clone>$();
			obj.set_OnNodeCreated((Action<Node>)astAnalyzer.NodeVisitor);
			return new Prepared<Script>(new JavaScriptParser(obj).ParseScript(code, source, strict), parserOptions);
		}

		public static Prepared<Module> PrepareModule(string code, string? source = null, ModulePreparationOptions? options = null)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if ((object)options == null)
			{
				options = ModulePreparationOptions.Default;
			}
			AstAnalyzer astAnalyzer = new AstAnalyzer(options);
			ParserOptions parserOptions = options.GetParserOptions();
			ParserOptions obj = parserOptions.<Clone>$();
			obj.set_OnNodeCreated((Action<Node>)astAnalyzer.NodeVisitor);
			return new Prepared<Module>(new JavaScriptParser(obj).ParseModule(code, source), parserOptions);
		}

		public Engine()
			: this(null, null)
		{
		}

		public Engine(Action<Options>? options)
			: this(null, (options != null) ? ((Action<Engine, Options>)delegate(Engine _, Options opts)
			{
				options(opts);
			}) : null)
		{
		}

		public Engine(Options options)
			: this(options, null)
		{
		}

		public Engine(Action<Engine, Options> options)
			: this(null, options)
		{
		}

		private Engine(Options? options, Action<Engine, Options>? configure)
		{
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			Advanced = new AdvancedOperations(this);
			Constraints = new ConstraintOperations(this);
			TypeConverter = new DefaultTypeConverter(this);
			_executionContexts = new ExecutionContextStack(2);
			Options = options ?? ((configure != null) ? new Options() : _defaultEngineOptions);
			configure?.Invoke(this, Options);
			_extensionMethods = ExtensionMethodCache.Build(Options.Interop.ExtensionMethodTypes);
			Reset();
			_isDebugMode = Options.Debugger.Enabled;
			_isStrict = Options.Strict;
			_objectConverters = ((Options.Interop.ObjectConverters.Count > 0) ? Options.Interop.ObjectConverters.ToArray() : null);
			_constraints = Options.Constraints.Constraints.ToArray();
			_referenceResolver = Options.ReferenceResolver;
			_referencePool = new ReferencePool();
			_argumentsInstancePool = new ArgumentsInstancePool(this);
			_jsValueArrayPool = new JsValueArrayPool();
			Options.Apply(this);
			CallStack = new JintCallStack(Options.Constraints.MaxRecursionDepth >= 0);
			_stackGuard = new StackGuard(this);
			_defaultParserOptions = ScriptParsingOptions.Default.GetParserOptions(Options);
			_defaultParser = new JavaScriptParser(_defaultParserOptions);
		}

		private void Reset()
		{
			_host = Options.Host.Factory(this);
			_host.Initialize(this);
		}

		internal ParserOptions GetActiveParserOptions()
		{
			return _executionContexts?.GetActiveParserOptions() ?? _defaultParserOptions;
		}

		internal JavaScriptParser GetParserFor(ScriptParsingOptions parsingOptions, out ParserOptions parserOptions)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if ((object)parsingOptions == ScriptParsingOptions.Default)
			{
				parserOptions = _defaultParserOptions;
				return _defaultParser;
			}
			parserOptions = parsingOptions.GetParserOptions(Options);
			return new JavaScriptParser(parserOptions);
		}

		internal JavaScriptParser GetParserFor(ParserOptions parserOptions)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			if (parserOptions != _defaultParserOptions)
			{
				return new JavaScriptParser(parserOptions);
			}
			return _defaultParser;
		}

		internal void EnterExecutionContext(Jint.Runtime.Environments.Environment lexicalEnvironment, Jint.Runtime.Environments.Environment variableEnvironment, Realm realm, PrivateEnvironment? privateEnvironment)
		{
			Jint.Runtime.Environments.ExecutionContext context = new Jint.Runtime.Environments.ExecutionContext(null, lexicalEnvironment, variableEnvironment, privateEnvironment, realm);
			_executionContexts.Push(in context);
		}

		internal void EnterExecutionContext(in Jint.Runtime.Environments.ExecutionContext context)
		{
			_executionContexts.Push(in context);
		}

		public Engine SetValue(string name, Delegate value)
		{
			Realm.GlobalObject.FastSetProperty(name, new PropertyDescriptor(new DelegateWrapper(this, value), PropertyFlag.NonEnumerable));
			return this;
		}

		public Engine SetValue(string name, string? value)
		{
			return SetValue(name, (value == null) ? JsValue.Null : JsString.Create(value));
		}

		public Engine SetValue(string name, double value)
		{
			return SetValue(name, (JsValue)JsNumber.Create(value));
		}

		public Engine SetValue(string name, int value)
		{
			return SetValue(name, (JsValue)JsNumber.Create(value));
		}

		public Engine SetValue(string name, bool value)
		{
			return SetValue(name, (JsValue)(value ? JsBoolean.True : JsBoolean.False));
		}

		public Engine SetValue(string name, JsValue value)
		{
			Realm.GlobalObject.Set(name, value);
			return this;
		}

		public Engine SetValue(string name, object? obj)
		{
			JsValue value = ((obj is Type type) ? TypeReference.CreateTypeReference(this, type) : JsValue.FromObject(this, obj));
			return SetValue(name, value);
		}

		public Engine SetValue(string name, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicEvents)] Type type)
		{
			return SetValue(name, TypeReference.CreateTypeReference(this, type));
		}

		public Engine SetValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicEvents)] T>(string name, T? obj)
		{
			if (!(obj is Type type))
			{
				return SetValue(name, JsValue.FromObject(this, obj));
			}
			return SetValue(name, type);
		}

		internal void LeaveExecutionContext()
		{
			_executionContexts.Pop();
		}

		internal void ResetConstraints()
		{
			Constraint[] constraints = _constraints;
			for (int i = 0; i < constraints.Length; i++)
			{
				constraints[i].Reset();
			}
		}

		internal void ResetCallStack()
		{
			CallStack.Clear();
		}

		public JsValue Evaluate(string code, string? source = null)
		{
			Script program = _defaultParser.ParseScript(code, source ?? "<anonymous>", _isStrict);
			return Evaluate(new Prepared<Script>(program, _defaultParserOptions));
		}

		public JsValue Evaluate(string code, ScriptParsingOptions parsingOptions)
		{
			return Evaluate(code, "<anonymous>", parsingOptions);
		}

		public JsValue Evaluate(string code, string source, ScriptParsingOptions parsingOptions)
		{
			ParserOptions parserOptions;
			Script program = GetParserFor(parsingOptions, out parserOptions).ParseScript(code, source, _isStrict);
			return Evaluate(new Prepared<Script>(program, parserOptions));
		}

		public JsValue Evaluate(in Prepared<Script> preparedScript)
		{
			return Execute(in preparedScript)._completionValue;
		}

		public Engine Execute(string code, string? source = null)
		{
			Script program = _defaultParser.ParseScript(code, source ?? "<anonymous>", _isStrict);
			return Execute(new Prepared<Script>(program, _defaultParserOptions));
		}

		public Engine Execute(string code, ScriptParsingOptions parsingOptions)
		{
			return Execute(code, "<anonymous>", parsingOptions);
		}

		public Engine Execute(string code, string source, ScriptParsingOptions parsingOptions)
		{
			ParserOptions parserOptions;
			Script program = GetParserFor(parsingOptions, out parserOptions).ParseScript(code, source, _isStrict);
			return Execute(new Prepared<Script>(program, parserOptions));
		}

		public Engine Execute(in Prepared<Script> preparedScript)
		{
			if (!preparedScript.IsValid)
			{
				ExceptionHelper.ThrowInvalidPreparedScriptArgumentException("preparedScript");
			}
			Script script = preparedScript.Program;
			ParserOptions parserOptions = preparedScript.ParserOptions;
			bool strict = _isStrict || ((Program)script).Strict;
			ExecuteWithConstraints(strict, () => ScriptEvaluation(new ScriptRecord(Realm, script, ((SyntaxElement)script).Location.Source), parserOptions));
			return this;
		}

		private Engine ScriptEvaluation(ScriptRecord scriptRecord, ParserOptions parserOptions)
		{
			Debugger.OnBeforeEvaluate((Program)(object)scriptRecord.EcmaScriptCode);
			GlobalEnvironment globalEnv = Realm.GlobalEnv;
			EnterExecutionContext(new Jint.Runtime.Environments.ExecutionContext(scriptRecord, globalEnv, globalEnv, null, Realm, null, null, parserOptions));
			try
			{
				Script ecmaScriptCode = scriptRecord.EcmaScriptCode;
				GlobalDeclarationInstantiation(ecmaScriptCode, globalEnv);
				JintStatementList jintStatementList = new JintStatementList(null, ((Program)ecmaScriptCode).Body);
				Completion completion;
				try
				{
					completion = jintStatementList.Execute(_activeEvaluationContext);
				}
				catch
				{
					ResetCallStack();
					throw;
				}
				if (completion.Type == CompletionType.Throw)
				{
					JavaScriptException ex = new JavaScriptException(completion.GetValueOrDefault()).SetJavaScriptCallstack(this, in completion.Location);
					ResetCallStack();
					throw ex;
				}
				_completionValue = completion.GetValueOrDefault();
				RunAvailableContinuations();
				return this;
			}
			finally
			{
				LeaveExecutionContext();
			}
		}

		internal ManualPromise RegisterPromise()
		{
			JsPromise obj = new JsPromise(this)
			{
				_prototype = Realm.Intrinsics.Promise.PrototypeObject
			};
			var (settle, settle2) = obj.CreateResolvingFunctions();
			return new ManualPromise(Reject: SettleWith(settle2), Promise: obj, Resolve: SettleWith(settle));
			Action<JsValue> SettleWith(Function function3)
			{
				return delegate(JsValue value)
				{
					function3.Call(JsValue.Undefined, new JsValue[1] { value });
					RunAvailableContinuations();
				};
			}
		}

		internal void AddToEventLoop(Action continuation)
		{
			_eventLoop.Events.Enqueue(continuation);
		}

		internal void AddToKeptObjects(JsValue target)
		{
			_agent.AddToKeptObjects(target);
		}

		internal void RunAvailableContinuations()
		{
			Queue<Action> events = _eventLoop.Events;
			if (events.Count != 0)
			{
				DoProcessEventLoop(events);
			}
		}

		private static void DoProcessEventLoop(Queue<Action> queue)
		{
			while (queue.Count != 0)
			{
				queue.Dequeue()();
			}
		}

		internal void RunBeforeExecuteStatementChecks(StatementListItem? statement)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			Constraint[] constraints = _constraints;
			for (int i = 0; i < constraints.Length; i++)
			{
				constraints[i].Check();
			}
			if (_isDebugMode && statement != null && (int)((Node)statement).Type != 8)
			{
				Debugger.OnStep((Node)(object)statement);
			}
		}

		internal JsValue GetValue(object value)
		{
			return GetValue(value, returnReferenceToPool: false);
		}

		internal JsValue GetValue(object value, bool returnReferenceToPool)
		{
			if (value is JsValue result)
			{
				return result;
			}
			if (!(value is Reference reference))
			{
				return ((Completion)value).Value;
			}
			return GetValue(reference, returnReferenceToPool);
		}

		internal JsValue GetValue(Reference reference, bool returnReferenceToPool)
		{
			JsValue value = reference.Base;
			if (value.IsUndefined())
			{
				if (_referenceResolver.TryUnresolvableReference(this, reference, out JsValue value2))
				{
					return value2;
				}
				ExceptionHelper.ThrowReferenceError(Realm, reference);
			}
			if ((value._type & InternalTypes.ObjectEnvironmentRecord) == 0 && _referenceResolver.TryPropertyReference(this, reference, ref value))
			{
				return value;
			}
			if (reference.IsPropertyReference)
			{
				JsValue referencedName = reference.ReferencedName;
				if (returnReferenceToPool)
				{
					_referencePool.Return(reference);
				}
				if (value.IsObject())
				{
					ObjectInstance objectInstance = Jint.Runtime.TypeConverter.ToObject(Realm, value);
					if (reference.IsPrivateReference)
					{
						return objectInstance.PrivateGet((PrivateName)reference.ReferencedName);
					}
					reference.EvaluateAndCachePropertyKey();
					return objectInstance.Get(reference.ReferencedName, reference.ThisValue);
				}
				ObjectInstance o = null;
				if ((referencedName._type & (InternalTypes.String | InternalTypes.Integer)) != InternalTypes.Empty && value is JsString s && TryHandleStringValue(referencedName, s, ref o, out JsValue jsValue))
				{
					return jsValue;
				}
				if ((object)o == null)
				{
					o = Jint.Runtime.TypeConverter.ToObject(Realm, value);
				}
				if (reference.IsPrivateReference)
				{
					return o.PrivateGet((PrivateName)reference.ReferencedName);
				}
				return o.Get(referencedName, reference.ThisValue);
			}
			JsValue bindingValue = ((Jint.Runtime.Environments.Environment)value).GetBindingValue(reference.ReferencedName.ToString(), reference.Strict);
			if (returnReferenceToPool)
			{
				_referencePool.Return(reference);
			}
			return bindingValue;
		}

		private bool TryHandleStringValue(JsValue property, JsString s, ref ObjectInstance? o, out JsValue jsValue)
		{
			if (CommonProperties.Length.Equals(property))
			{
				jsValue = JsNumber.Create((uint)s.Length);
				return true;
			}
			if (property is JsNumber value && value.IsInteger())
			{
				int num = value.AsInteger();
				if (num < 0 || num >= s.Length)
				{
					jsValue = JsValue.Undefined;
					return true;
				}
				jsValue = JsString.Create(s[num]);
				return true;
			}
			if (property is JsString { Length: >0 } jsString && char.IsLower(jsString[0]))
			{
				o = Realm.Intrinsics.String.PrototypeObject;
			}
			jsValue = JsValue.Undefined;
			return false;
		}

		internal void PutValue(Reference reference, JsValue value)
		{
			JsValue referencedName = reference.ReferencedName;
			if (reference.IsUnresolvableReference)
			{
				if (reference.Strict && referencedName != CommonProperties.Arguments)
				{
					ExceptionHelper.ThrowReferenceError(Realm, reference);
				}
				Realm.GlobalObject.Set(referencedName, value, throwOnError: false);
			}
			else if (reference.IsPropertyReference)
			{
				ObjectInstance objectInstance = Jint.Runtime.TypeConverter.ToObject(Realm, reference.Base);
				if (reference.IsPrivateReference)
				{
					objectInstance.PrivateSet((PrivateName)referencedName, value);
					return;
				}
				reference.EvaluateAndCachePropertyKey();
				if (!objectInstance.Set(reference.ReferencedName, value, reference.ThisValue) && reference.Strict)
				{
					ExceptionHelper.ThrowTypeError(Realm, "Cannot assign to read only property '" + referencedName?.ToString() + "' of " + objectInstance);
				}
			}
			else
			{
				((Jint.Runtime.Environments.Environment)reference.Base).SetMutableBinding(Jint.Runtime.TypeConverter.ToString(referencedName), value, reference.Strict);
			}
		}

		public JsValue Invoke(string propertyName, params object?[] arguments)
		{
			return Invoke(propertyName, null, arguments);
		}

		public JsValue Invoke(string propertyName, object? thisObj, object?[] arguments)
		{
			JsValue value = GetValue(propertyName);
			return Invoke(value, thisObj, arguments);
		}

		public JsValue Invoke(JsValue value, params object?[] arguments)
		{
			return Invoke(value, null, arguments);
		}

		public JsValue Invoke(JsValue value, object? thisObj, object?[] arguments)
		{
			ICallable callable = value as ICallable;
			if (callable == null)
			{
				ExceptionHelper.ThrowJavaScriptException(Realm.Intrinsics.TypeError, "Can only invoke functions");
			}
			return ExecuteWithConstraints(Options.Strict, DoInvoke);
			JsValue DoInvoke()
			{
				JsValue[] array = _jsValueArrayPool.RentArray(arguments.Length);
				for (int i = 0; i < arguments.Length; i++)
				{
					array[i] = JsValue.FromObject(this, arguments[i]);
				}
				JsValue thisObject = JsValue.FromObject(this, thisObj);
				JsValue result;
				if (callable is Function function)
				{
					JintCallStack callStack = CallStack;
					callStack.Push(function, null, in ExecutionContext);
					try
					{
						result = function.Call(thisObject, array);
					}
					finally
					{
						if (callStack.Count > 0)
						{
							callStack.Pop();
						}
					}
				}
				else
				{
					result = callable.Call(thisObject, array);
				}
				_jsValueArrayPool.ReturnArray(array);
				return result;
			}
		}

		internal T ExecuteWithConstraints<T>(bool strict, Func<T> callback)
		{
			ResetConstraints();
			bool flag = _activeEvaluationContext == null;
			if (_activeEvaluationContext == null)
			{
				_activeEvaluationContext = new EvaluationContext(this);
			}
			try
			{
				using (new StrictModeScope(strict))
				{
					return callback();
				}
			}
			finally
			{
				if (flag)
				{
					_activeEvaluationContext = null;
				}
				ResetConstraints();
				_agent.ClearKeptObjects();
			}
		}

		internal JsValue Invoke(JsValue v, JsValue p, JsValue[] arguments)
		{
			bool flag = _activeEvaluationContext == null;
			if (_activeEvaluationContext == null)
			{
				_activeEvaluationContext = new EvaluationContext(this);
			}
			try
			{
				ICallable obj = GetV(v, p) as ICallable;
				if (obj == null)
				{
					ExceptionHelper.ThrowTypeErrorNoEngine("Can only invoke functions");
				}
				return obj.Call(v, arguments);
			}
			finally
			{
				if (flag)
				{
					_activeEvaluationContext = null;
				}
			}
		}

		private JsValue GetV(JsValue v, JsValue p)
		{
			return Jint.Runtime.TypeConverter.ToObject(Realm, v).Get(p);
		}

		public JsValue GetValue(string propertyName)
		{
			return GetValue(Realm.GlobalObject, new JsString(propertyName));
		}

		internal SyntaxElement GetLastSyntaxElement()
		{
			return _lastSyntaxElement;
		}

		public JsValue GetValue(JsValue scope, JsValue property)
		{
			Reference reference = _referencePool.Rent(scope, property, _isStrict, null);
			JsValue value = GetValue(reference, returnReferenceToPool: false);
			_referencePool.Return(reference);
			return value;
		}

		internal Reference ResolveBinding(string name, Jint.Runtime.Environments.Environment? env = null)
		{
			if ((object)env == null)
			{
				env = ExecutionContext.LexicalEnvironment;
			}
			return GetIdentifierReference(env, name, StrictModeScope.IsStrictModeCode);
		}

		private static Reference GetIdentifierReference(Jint.Runtime.Environments.Environment? env, string name, bool strict)
		{
			if ((object)env == null)
			{
				return new Reference(JsValue.Undefined, name, strict);
			}
			if (env.HasBinding(name))
			{
				return new Reference(env, name, strict);
			}
			return GetIdentifierReference(env._outerEnv, name, strict);
		}

		internal JsValue GetNewTarget(Jint.Runtime.Environments.Environment? thisEnvironment = null)
		{
			if ((object)thisEnvironment == null)
			{
				thisEnvironment = ExecutionContext.GetThisEnvironment();
			}
			return thisEnvironment.NewTarget ?? JsValue.Undefined;
		}

		internal JsValue ResolveThisBinding()
		{
			return ExecutionContext.GetThisEnvironment().GetThisBinding();
		}

		private void GlobalDeclarationInstantiation(Script script, GlobalEnvironment env)
		{
			HoistingScope hoistingScope = ((Program)(object)script).GetHoistingScope();
			List<FunctionDeclaration> functionDeclarations = hoistingScope._functionDeclarations;
			List<JintFunctionDefinition> list = new List<JintFunctionDefinition>();
			HashSet<Key> hashSet = new HashSet<Key>();
			List<Key> list2 = new List<Key>();
			Realm realm = Realm;
			if (functionDeclarations != null)
			{
				for (int num = functionDeclarations.Count - 1; num >= 0; num--)
				{
					FunctionDeclaration val = functionDeclarations[num];
					Key key = val.Id.Name;
					if (!hashSet.Contains(key))
					{
						if (!env.CanDeclareGlobalFunction(key))
						{
							ExceptionHelper.ThrowTypeError(realm, "Cannot declare global function " + key);
						}
						hashSet.Add(key);
						list.Add(new JintFunctionDefinition((IFunction)(object)val));
					}
				}
			}
			List<Key> varNames = ((Program)(object)script).GetVarNames(hoistingScope);
			for (int i = 0; i < varNames.Count; i++)
			{
				Key key2 = varNames[i];
				if (env.HasLexicalDeclaration(key2))
				{
					ExceptionHelper.ThrowSyntaxError(realm, $"Identifier '{key2}' has already been declared");
				}
				if (!hashSet.Contains(key2))
				{
					if (!env.CanDeclareGlobalVar(key2))
					{
						ExceptionHelper.ThrowTypeError(realm);
					}
					list2.Add(key2);
				}
			}
			PrivateEnvironment privateEnv = null;
			List<CachedHoistingScope.CachedLexicalName> lexNames = ((Program)(object)script).GetLexNames(hoistingScope);
			for (int j = 0; j < lexNames.Count; j++)
			{
				var (key4, flag2) = (CachedHoistingScope.CachedLexicalName)(ref lexNames[j]);
				if (env.HasLexicalDeclaration(key4) || env.HasRestrictedGlobalProperty(key4))
				{
					ExceptionHelper.ThrowSyntaxError(realm, $"Identifier '{key4}' has already been declared");
				}
				if (flag2)
				{
					env.CreateImmutableBinding(key4);
				}
				else
				{
					env.CreateMutableBinding(key4);
				}
			}
			for (int num2 = list.Count - 1; num2 > -1; num2--)
			{
				JintFunctionDefinition jintFunctionDefinition = list[num2];
				Key key5 = jintFunctionDefinition.Name;
				if (env.HasLexicalDeclaration(key5))
				{
					ExceptionHelper.ThrowSyntaxError(realm, $"Identifier '{key5}' has already been declared");
				}
				Function value = realm.Intrinsics.Function.InstantiateFunctionObject(jintFunctionDefinition, env, privateEnv);
				env.CreateGlobalFunctionBinding(key5, value, canBeDeleted: false);
			}
			env.CreateGlobalVarBindings(list2, canBeDeleted: false);
		}

		internal JsArguments? FunctionDeclarationInstantiation(Function function, JsValue[] argumentsList)
		{
			Jint.Runtime.Environments.ExecutionContext executionContext = ExecutionContext;
			JintFunctionDefinition functionDefinition = function._functionDefinition;
			FunctionEnvironment functionEnvironment = (FunctionEnvironment)ExecutionContext.LexicalEnvironment;
			bool flag = _isStrict || StrictModeScope.IsStrictModeCode;
			JintFunctionDefinition.State state = functionDefinition.Initialize();
			Key[] parameterNames = state.ParameterNames;
			bool hasDuplicates = state.HasDuplicates;
			bool isSimpleParameterList = state.IsSimpleParameterList;
			bool hasParameterExpressions = state.HasParameterExpressions;
			int num;
			object obj;
			if (isSimpleParameterList)
			{
				num = ((!state.HasDuplicates) ? 1 : 0);
				if (num != 0)
				{
					obj = argumentsList;
					goto IL_0077;
				}
			}
			else
			{
				num = 0;
			}
			obj = null;
			goto IL_0077;
			IL_0077:
			JsValue[] arguments = (JsValue[])obj;
			functionEnvironment.InitializeParameters(parameterNames, hasDuplicates, arguments);
			JsArguments jsArguments = null;
			if (state.ArgumentsObjectNeeded || _isDebugMode)
			{
				jsArguments = ((!flag && isSimpleParameterList) ? CreateMappedArgumentsObject(function, parameterNames, argumentsList, functionEnvironment, state.HasRestParameter) : CreateUnmappedArgumentsObject(argumentsList));
				if (flag)
				{
					functionEnvironment.CreateImmutableBindingAndInitialize(KnownKeys.Arguments, strict: false, jsArguments);
				}
				else
				{
					functionEnvironment.CreateMutableBindingAndInitialize(KnownKeys.Arguments, canBeDeleted: false, jsArguments);
				}
			}
			if (num == 0)
			{
				functionEnvironment.AddFunctionParameters(_activeEvaluationContext, functionDefinition.Function, argumentsList);
			}
			Jint.Runtime.Environments.Environment environment;
			if (!hasParameterExpressions)
			{
				List<JintFunctionDefinition.State.VariableValuePair> varsToInitialize = state.VarsToInitialize;
				for (int i = 0; i < varsToInitialize.Count; i++)
				{
					functionEnvironment.CreateMutableBindingAndInitialize(varsToInitialize[i].Name, canBeDeleted: false, JsValue.Undefined);
				}
				environment = functionEnvironment;
			}
			else
			{
				DeclarativeEnvironment declarativeEnvironment = JintEnvironment.NewDeclarativeEnvironment(this, functionEnvironment);
				environment = declarativeEnvironment;
				UpdateVariableEnvironment(environment);
				List<JintFunctionDefinition.State.VariableValuePair> varsToInitialize2 = state.VarsToInitialize;
				for (int j = 0; j < varsToInitialize2.Count; j++)
				{
					JintFunctionDefinition.State.VariableValuePair variableValuePair = varsToInitialize2[j];
					JsValue value = variableValuePair.InitialValue ?? functionEnvironment.GetBindingValue(variableValuePair.Name, strict: false);
					declarativeEnvironment.CreateMutableBindingAndInitialize(variableValuePair.Name, canBeDeleted: false, value);
				}
			}
			Jint.Runtime.Environments.Environment environment2 = (flag ? environment : JintEnvironment.NewDeclarativeEnvironment(this, environment));
			UpdateLexicalEnvironment(environment2);
			if (state.LexicalDeclarations.Length != 0)
			{
				JintFunctionDefinition.State.LexicalVariableDeclaration[] lexicalDeclarations = state.LexicalDeclarations;
				for (int k = 0; k < lexicalDeclarations.Length; k++)
				{
					JintFunctionDefinition.State.LexicalVariableDeclaration lexicalVariableDeclaration = lexicalDeclarations[k];
					for (int l = 0; l < lexicalVariableDeclaration.BoundNames.Count; l++)
					{
						Key name = lexicalVariableDeclaration.BoundNames[l];
						if (lexicalVariableDeclaration.IsConstantDeclaration)
						{
							environment2.CreateImmutableBinding(name);
						}
						else
						{
							environment2.CreateMutableBinding(name);
						}
					}
				}
			}
			if (state.FunctionsToInitialize != null)
			{
				PrivateEnvironment privateEnvironment = executionContext.PrivateEnvironment;
				Realm realm = Realm;
				foreach (FunctionDeclaration item in state.FunctionsToInitialize)
				{
					JintFunctionDefinition jintFunctionDefinition = new JintFunctionDefinition((IFunction)(object)item);
					string name2 = jintFunctionDefinition.Name;
					Function value2 = realm.Intrinsics.Function.InstantiateFunctionObject(jintFunctionDefinition, environment2, privateEnvironment);
					environment.SetMutableBinding(name2, value2, strict: false);
				}
			}
			return jsArguments;
		}

		private JsArguments CreateMappedArgumentsObject(Function func, Key[] formals, JsValue[] argumentsList, DeclarativeEnvironment envRec, bool hasRestParameter)
		{
			return _argumentsInstancePool.Rent(func, formals, argumentsList, envRec, hasRestParameter);
		}

		private JsArguments CreateUnmappedArgumentsObject(JsValue[] argumentsList)
		{
			return _argumentsInstancePool.Rent(argumentsList);
		}

		internal void EvalDeclarationInstantiation(Script script, Jint.Runtime.Environments.Environment varEnv, Jint.Runtime.Environments.Environment lexEnv, PrivateEnvironment? privateEnv, bool strict)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			HoistingScope programLevelDeclarations = HoistingScope.GetProgramLevelDeclarations((Program)(object)script);
			DeclarativeEnvironment declarativeEnvironment = (DeclarativeEnvironment)lexEnv;
			Realm realm = Realm;
			if (!strict && programLevelDeclarations._variablesDeclarations != null)
			{
				if (varEnv is GlobalEnvironment globalEnvironment)
				{
					ref readonly List<VariableDeclaration> variablesDeclarations = ref programLevelDeclarations._variablesDeclarations;
					for (int i = 0; i < variablesDeclarations.Count; i++)
					{
						Identifier val = (Identifier)((NodeList<VariableDeclarator>)variablesDeclarations[i].Declarations)[0].Id;
						if (globalEnvironment.HasLexicalDeclaration(val.Name))
						{
							ExceptionHelper.ThrowSyntaxError(realm, "Identifier '" + val.Name + "' has already been declared");
						}
					}
				}
				Jint.Runtime.Environments.Environment environment = lexEnv;
				while ((object)environment != varEnv)
				{
					Jint.Runtime.Environments.Environment environment2 = environment;
					if (!(environment2 is ObjectEnvironment))
					{
						ref readonly List<VariableDeclaration> variablesDeclarations2 = ref programLevelDeclarations._variablesDeclarations;
						for (int j = 0; j < variablesDeclarations2.Count; j++)
						{
							Identifier val2 = (Identifier)((NodeList<VariableDeclarator>)variablesDeclarations2[j].Declarations)[0].Id;
							if (environment2.HasBinding(val2.Name))
							{
								ExceptionHelper.ThrowSyntaxError(realm);
							}
						}
					}
					environment = environment._outerEnv;
				}
			}
			HashSet<PrivateIdentifier> hashSet = null;
			for (PrivateEnvironment privateEnvironment = privateEnv; privateEnvironment != null; privateEnvironment = privateEnvironment.OuterPrivateEnvironment)
			{
				foreach (KeyValuePair<PrivateIdentifier, PrivateName> name3 in privateEnvironment.Names)
				{
					if (hashSet == null)
					{
						hashSet = new HashSet<PrivateIdentifier>(PrivateIdentifierNameComparer._instance);
					}
					hashSet.Add(name3.Key);
				}
			}
			script.AllPrivateIdentifiersValid(realm, hashSet);
			List<FunctionDeclaration> functionDeclarations = programLevelDeclarations._functionDeclarations;
			LinkedList<JintFunctionDefinition> linkedList = new LinkedList<JintFunctionDefinition>();
			HashSet<Key> hashSet2 = new HashSet<Key>();
			if (functionDeclarations != null)
			{
				for (int num = functionDeclarations.Count - 1; num >= 0; num--)
				{
					FunctionDeclaration val3 = functionDeclarations[num];
					Key key = val3.Id.Name;
					if (!hashSet2.Contains(key))
					{
						if (varEnv is GlobalEnvironment globalEnvironment2 && !globalEnvironment2.CanDeclareGlobalFunction(key))
						{
							ExceptionHelper.ThrowTypeError(realm);
						}
						hashSet2.Add(key);
						linkedList.AddFirst(new JintFunctionDefinition((IFunction)(object)val3));
					}
				}
			}
			List<Key> list = new List<Key>();
			List<Key> list2 = new List<Key>();
			List<VariableDeclaration> variablesDeclarations3 = programLevelDeclarations._variablesDeclarations;
			int? num2 = variablesDeclarations3?.Count;
			for (int k = 0; k < num2; k++)
			{
				VariableDeclaration variableDeclaration = variablesDeclarations3[k];
				list.Clear();
				variableDeclaration.GetBoundNames(list);
				for (int l = 0; l < list.Count; l++)
				{
					Key key2 = list[l];
					if (!hashSet2.Contains(key2))
					{
						if (varEnv is GlobalEnvironment globalEnvironment3 && !globalEnvironment3.CanDeclareGlobalFunction(key2))
						{
							ExceptionHelper.ThrowTypeError(realm);
						}
						list2.Add(key2);
					}
				}
			}
			List<Declaration> lexicalDeclarations = programLevelDeclarations._lexicalDeclarations;
			int? num3 = lexicalDeclarations?.Count;
			for (int m = 0; m < num3; m++)
			{
				list.Clear();
				Declaration val4 = lexicalDeclarations[m];
				((Node?)(object)val4).GetBoundNames(list);
				for (int n = 0; n < list.Count; n++)
				{
					Key name = list[n];
					if (val4.IsConstantDeclaration())
					{
						declarativeEnvironment.CreateImmutableBinding(name);
					}
					else
					{
						declarativeEnvironment.CreateMutableBinding(name);
					}
				}
			}
			foreach (JintFunctionDefinition item in linkedList)
			{
				Function value = realm.Intrinsics.Function.InstantiateFunctionObject(item, lexEnv, privateEnv);
				if (varEnv is GlobalEnvironment globalEnvironment4)
				{
					globalEnvironment4.CreateGlobalFunctionBinding(item.Name, value, canBeDeleted: true);
					continue;
				}
				Key name2 = item.Name;
				if (!varEnv.HasBinding(name2))
				{
					varEnv.CreateMutableBinding(name2, canBeDeleted: true);
					varEnv.InitializeBinding(name2, value);
				}
				else
				{
					varEnv.SetMutableBinding(name2, value, strict: false);
				}
			}
			foreach (Key item2 in list2)
			{
				if (varEnv is GlobalEnvironment globalEnvironment5)
				{
					globalEnvironment5.CreateGlobalVarBinding(item2, canBeDeleted: true);
				}
				else if (!varEnv.HasBinding(item2))
				{
					varEnv.CreateMutableBinding(item2, canBeDeleted: true);
					varEnv.InitializeBinding(item2, JsValue.Undefined);
				}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal void UpdateLexicalEnvironment(Jint.Runtime.Environments.Environment newEnv)
		{
			_executionContexts.ReplaceTopLexicalEnvironment(newEnv);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal void UpdateVariableEnvironment(Jint.Runtime.Environments.Environment newEnv)
		{
			_executionContexts.ReplaceTopVariableEnvironment(newEnv);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal void UpdatePrivateEnvironment(PrivateEnvironment? newEnv)
		{
			_executionContexts.ReplaceTopPrivateEnvironment(newEnv);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ref readonly Jint.Runtime.Environments.ExecutionContext UpdateGenerator(GeneratorInstance generator)
		{
			return ref _executionContexts.ReplaceTopGenerator(generator);
		}

		public JsValue Call(string callableName, params JsValue[] arguments)
		{
			JsValue callable = Evaluate(callableName);
			return Call(callable, arguments);
		}

		public JsValue Call(JsValue callable, params JsValue[] arguments)
		{
			return Call(callable, JsValue.Undefined, arguments);
		}

		public JsValue Call(JsValue callable, JsValue thisObject, JsValue[] arguments)
		{
			return ExecuteWithConstraints(Options.Strict, Callback);
			JsValue Callback()
			{
				if (!callable.IsCallable)
				{
					ExceptionHelper.ThrowArgumentException(callable?.ToString() + " is not callable");
				}
				return Call((ICallable)callable, thisObject, arguments, null);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal JsValue Call(ICallable callable, JsValue thisObject, JsValue[] arguments, JintExpression? expression)
		{
			if (callable is Function function)
			{
				return Call(function, thisObject, arguments, expression);
			}
			return callable.Call(thisObject, arguments);
		}

		public ObjectInstance Construct(string constructorName, params JsValue[] arguments)
		{
			JsValue constructor = Evaluate(constructorName);
			return Construct(constructor, arguments);
		}

		public ObjectInstance Construct(JsValue constructor, params JsValue[] arguments)
		{
			return ExecuteWithConstraints(Options.Strict, Callback);
			ObjectInstance Callback()
			{
				if (!constructor.IsConstructor)
				{
					ExceptionHelper.ThrowArgumentException(constructor?.ToString() + " is not a constructor");
				}
				return Construct(constructor, arguments, constructor, null);
			}
		}

		internal ObjectInstance Construct(JsValue constructor, JsValue[] arguments, JsValue newTarget, JintExpression? expression)
		{
			if (constructor is Function function)
			{
				return Construct(function, arguments, newTarget, expression);
			}
			return ((IConstructor)constructor).Construct(arguments, newTarget);
		}

		internal JsValue Call(Function function, JsValue thisObject)
		{
			return Call(function, thisObject, Arguments.Empty, null);
		}

		internal JsValue Call(Function function, JsValue thisObject, JsValue[] arguments, JintExpression? expression)
		{
			if (CallStack.Push(function, expression, in ExecutionContext) > Options.Constraints.MaxRecursionDepth)
			{
				ExceptionHelper.ThrowRecursionDepthOverflowException(CallStack);
			}
			try
			{
				return function.Call(thisObject, arguments);
			}
			finally
			{
				if (CallStack.Count > 0)
				{
					CallStack.Pop();
				}
			}
		}

		private ObjectInstance Construct(Function function, JsValue[] arguments, JsValue newTarget, JintExpression? expression)
		{
			if (CallStack.Push(function, expression, in ExecutionContext) > Options.Constraints.MaxRecursionDepth)
			{
				ExceptionHelper.ThrowRecursionDepthOverflowException(CallStack);
			}
			try
			{
				return ((IConstructor)function).Construct(arguments, newTarget);
			}
			finally
			{
				CallStack.Pop();
			}
		}

		internal void SignalError(ErrorDispatchInfo error)
		{
			_error = error;
		}

		internal void RegisterTypeReference(TypeReference reference)
		{
			if (_typeReferences == null)
			{
				_typeReferences = new Dictionary<Type, TypeReference>();
			}
			_typeReferences[reference.ReferenceType] = reference;
		}

		internal ref readonly Jint.Runtime.Environments.ExecutionContext GetExecutionContext(int fromTop)
		{
			return ref _executionContexts.Peek(fromTop);
		}

		public void Dispose()
		{
			if (_objectWrapperCache != null)
			{
				_objectWrapperCache.Clear();
			}
		}

		internal IScriptOrModule? GetActiveScriptOrModule()
		{
			return _executionContexts?.GetActiveScriptOrModule();
		}

		static Engine()
		{
			ParserOptions obj = ParserOptions.Default.<Clone>$();
			obj.set_Tolerant(true);
			obj.set_MaxAssignmentDepth(500);
			BaseParserOptions = obj;
		}
	}
	internal sealed class CachedHoistingScope
	{
		[StructLayout(LayoutKind.Auto)]
		internal readonly record struct CachedLexicalName(Key Name, bool Constant);

		public HoistingScope Scope { get; }

		public List<Key> VarNames { get; }

		public List<CachedLexicalName> LexNames { get; }

		public CachedHoistingScope(Program program)
		{
			Scope = HoistingScope.GetProgramLevelDeclarations(program);
			VarNames = new List<Key>();
			GatherVarNames(Scope, VarNames);
			LexNames = new List<CachedLexicalName>();
			GatherLexNames(Scope, LexNames);
		}

		internal static void GatherVarNames(HoistingScope scope, List<Key> boundNames)
		{
			List<VariableDeclaration> variablesDeclarations = scope._variablesDeclarations;
			if (variablesDeclarations != null)
			{
				for (int i = 0; i < variablesDeclarations.Count; i++)
				{
					variablesDeclarations[i].GetBoundNames(boundNames);
				}
			}
		}

		internal static void GatherLexNames(HoistingScope scope, List<CachedLexicalName> boundNames)
		{
			List<Declarati

UserLibs/AngleSharp.dll

Decompiled 17 hours ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp.Attributes;
using AngleSharp.Browser;
using AngleSharp.Browser.Dom;
using AngleSharp.Browser.Dom.Events;
using AngleSharp.Common;
using AngleSharp.Css;
using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser;
using AngleSharp.Dom;
using AngleSharp.Dom.Events;
using AngleSharp.Html;
using AngleSharp.Html.Construction;
using AngleSharp.Html.Dom;
using AngleSharp.Html.Dom.Events;
using AngleSharp.Html.Forms;
using AngleSharp.Html.Forms.Submitters;
using AngleSharp.Html.Forms.Submitters.Json;
using AngleSharp.Html.InputTypes;
using AngleSharp.Html.LinkRels;
using AngleSharp.Html.Parser;
using AngleSharp.Html.Parser.Tokens;
using AngleSharp.Html.Parser.Tokens.Struct;
using AngleSharp.Io;
using AngleSharp.Io.Dom;
using AngleSharp.Io.Processors;
using AngleSharp.Mathml;
using AngleSharp.Mathml.Dom;
using AngleSharp.Media;
using AngleSharp.Media.Dom;
using AngleSharp.Scripting;
using AngleSharp.Svg;
using AngleSharp.Svg.Dom;
using AngleSharp.Text;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCopyright("Copyright © AngleSharp, 2013-2024")]
[assembly: ComVisible(false)]
[assembly: InternalsVisibleTo("AngleSharp.Core.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001adf274fa2b375134e8e4558d606f1a0f96f5cd0c6b99970f7cce9887477209d7c29f814e2508d8bd2526e99e8cd273bd1158a3984f1ea74830ec5329a77c6ff201a15edeb8b36ab046abd1bce211fe8dbb076d7d806f46b15bfda44def04ead0669971e96c5f666c9eda677f28824fff7aa90d32929ed91d529a7a41699893")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AngleSharp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("AngleSharp is the ultimate angle brackets parser library. It parses HTML5, CSS3, and XML to construct a DOM based on the official W3C specification.")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+6aa79f6f5ea9201af122ec112faa244081cdd493")]
[assembly: AssemblyProduct("AngleSharp")]
[assembly: AssemblyTitle("AngleSharp")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AngleSharp/AngleSharp")]
[assembly: AssemblyVersion("1.1.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AngleSharp
{
	public sealed class BrowsingContext : EventTarget, IBrowsingContext, IEventTarget, IDisposable
	{
		private readonly IEnumerable<object> _originalServices;

		private readonly List<object> _services;

		private readonly Sandboxes _security;

		private readonly IBrowsingContext? _parent;

		private readonly IDocument? _creator;

		private readonly IHistory? _history;

		private readonly Dictionary<string, WeakReference<IBrowsingContext>> _children;

		public IDocument? Active { get; set; }

		public IDocument? Creator => _creator;

		public IEnumerable<object> OriginalServices => _originalServices;

		public IWindow? Current => Active?.DefaultView;

		public IBrowsingContext? Parent => _parent;

		public IHistory? SessionHistory => _history;

		public Sandboxes Security => _security;

		public BrowsingContext(IConfiguration? configuration = null)
			: this((configuration ?? Configuration.Default).Services, Sandboxes.None)
		{
		}

		private BrowsingContext(Sandboxes security)
		{
			_services = new List<object>();
			_originalServices = _services;
			_security = security;
			_children = new Dictionary<string, WeakReference<IBrowsingContext>>();
		}

		internal BrowsingContext(IEnumerable<object> services, Sandboxes security)
			: this(security)
		{
			_services.AddRange(services);
			_originalServices = services;
			_history = GetService<IHistory>();
		}

		internal BrowsingContext(IBrowsingContext parent, Sandboxes security)
			: this(parent.OriginalServices, security)
		{
			_parent = parent;
			_creator = _parent.Active;
		}

		public T? GetService<T>() where T : class
		{
			int count = _services.Count;
			int num = 0;
			while (num < count)
			{
				object obj = _services[num];
				T val = obj as T;
				if (val == null)
				{
					if (!(obj is Func<IBrowsingContext, T> func))
					{
						num++;
						continue;
					}
					val = func(this);
					_services[num] = val;
				}
				return val;
			}
			return null;
		}

		public IEnumerable<T> GetServices<T>() where T : class
		{
			int count = _services.Count;
			for (int i = 0; i < count; i++)
			{
				object obj = _services[i];
				T val = obj as T;
				if (val == null)
				{
					if (!(obj is Func<IBrowsingContext, T> func))
					{
						continue;
					}
					val = func(this);
					_services[i] = val;
				}
				yield return val;
			}
		}

		public IBrowsingContext CreateChild(string? name, Sandboxes security)
		{
			BrowsingContext browsingContext = new BrowsingContext(this, security);
			if (name != null && name.Length > 0)
			{
				_children[name] = new WeakReference<IBrowsingContext>(browsingContext);
			}
			return browsingContext;
		}

		public IBrowsingContext? FindChild(string name)
		{
			IBrowsingContext target = null;
			if (!string.IsNullOrEmpty(name) && _children.TryGetValue(name, out WeakReference<IBrowsingContext> value))
			{
				value.TryGetTarget(out target);
			}
			return target;
		}

		public static IBrowsingContext New(IConfiguration? configuration = null)
		{
			if (configuration == null)
			{
				configuration = Configuration.Default;
			}
			return new BrowsingContext(configuration.Services, Sandboxes.None);
		}

		public static IBrowsingContext NewFrom<TService>(TService instance)
		{
			return new BrowsingContext(Configuration.Default.WithOnly(instance).Services, Sandboxes.None);
		}

		void IDisposable.Dispose()
		{
			Active?.Dispose();
			Active = null;
		}
	}
	public static class BrowsingContextExtensions
	{
		public static Task<IDocument> OpenNewAsync(this IBrowsingContext context, string? url = null, CancellationToken cancellation = default(CancellationToken))
		{
			return context.OpenAsync(delegate(VirtualResponse m)
			{
				m.Address(url ?? "http://localhost/");
			}, cancellation);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, IResponse response, CancellationToken cancel = default(CancellationToken))
		{
			response = response ?? throw new ArgumentNullException("response");
			if (context == null)
			{
				context = BrowsingContext.New();
			}
			Encoding defaultEncoding = context.GetDefaultEncoding();
			IDocumentFactory factory = context.GetFactory<IDocumentFactory>();
			CreateDocumentOptions options = new CreateDocumentOptions(response, defaultEncoding);
			return factory.CreateAsync(context, options, cancel);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, DocumentRequest request, CancellationToken cancel = default(CancellationToken))
		{
			request = request ?? throw new ArgumentNullException("request");
			if (context == null)
			{
				context = BrowsingContext.New();
			}
			return context.NavigateToAsync(request, cancel);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, Url url, CancellationToken cancel = default(CancellationToken))
		{
			url = url ?? throw new ArgumentNullException("url");
			return context.OpenAsync(DocumentRequest.Get(url, null, context?.Active?.DocumentUri), cancel);
		}

		public static async Task<IDocument> OpenAsync(this IBrowsingContext context, Action<VirtualResponse> request, CancellationToken cancel = default(CancellationToken))
		{
			request = request ?? throw new ArgumentNullException("request");
			using IResponse response = VirtualResponse.Create(request);
			return await context.OpenAsync(response, cancel).ConfigureAwait(continueOnCapturedContext: false);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, string address, CancellationToken cancellation = default(CancellationToken))
		{
			address = address ?? throw new ArgumentNullException("address");
			return context.OpenAsync(Url.Create(address), cancellation);
		}

		internal static Task<IDocument> NavigateToAsync(this IBrowsingContext context, DocumentRequest request, CancellationToken cancel = default(CancellationToken))
		{
			return context.GetNavigationHandler(request.Target)?.NavigateAsync(request, cancel) ?? Task.FromResult<IDocument>(null);
		}

		public static void NavigateTo(this IBrowsingContext context, IDocument document)
		{
			context.SessionHistory?.PushState(document, document.Title, document.Url);
			context.Active = document;
		}

		public static INavigationHandler? GetNavigationHandler(this IBrowsingContext context, Url url)
		{
			return context.GetServices<INavigationHandler>().FirstOrDefault((INavigationHandler m) => m.SupportsProtocol(url.Scheme));
		}

		public static Encoding GetDefaultEncoding(this IBrowsingContext context)
		{
			IEncodingProvider? provider = context.GetProvider<IEncodingProvider>();
			string language = context.GetLanguage();
			return provider?.Suggest(language) ?? Encoding.UTF8;
		}

		public static CultureInfo GetCulture(this IBrowsingContext context)
		{
			return context.GetService<CultureInfo>() ?? CultureInfo.CurrentUICulture;
		}

		public static CultureInfo GetCultureFrom(this IBrowsingContext context, string language)
		{
			try
			{
				return new CultureInfo(language);
			}
			catch (CultureNotFoundException ex)
			{
				context.TrackError(ex);
				return context.GetCulture();
			}
		}

		public static string GetLanguage(this IBrowsingContext context)
		{
			return context.GetCulture().Name;
		}

		public static TFactory GetFactory<TFactory>(this IBrowsingContext context) where TFactory : class
		{
			return context.GetServices<TFactory>().Single();
		}

		public static TProvider? GetProvider<TProvider>(this IBrowsingContext context) where TProvider : class
		{
			return context.GetServices<TProvider>().SingleOrDefault();
		}

		public static IResourceService<TResource>? GetResourceService<TResource>(this IBrowsingContext context, string type) where TResource : IResourceInfo
		{
			foreach (IResourceService<TResource> service in context.GetServices<IResourceService<TResource>>())
			{
				if (service.SupportsType(type))
				{
					return service;
				}
			}
			return null;
		}

		public static string GetCookie(this IBrowsingContext context, Url url)
		{
			return context.GetProvider<ICookieProvider>()?.GetCookie(url) ?? string.Empty;
		}

		public static void SetCookie(this IBrowsingContext context, Url url, string value)
		{
			context.GetProvider<ICookieProvider>()?.SetCookie(url, value);
		}

		public static ISpellCheckService? GetSpellCheck(this IBrowsingContext context, string language)
		{
			ISpellCheckService spellCheckService = null;
			IEnumerable<ISpellCheckService> services = context.GetServices<ISpellCheckService>();
			CultureInfo cultureFrom = context.GetCultureFrom(language);
			string twoLetterISOLanguageName = cultureFrom.TwoLetterISOLanguageName;
			foreach (ISpellCheckService item in services)
			{
				CultureInfo culture = item.Culture;
				if (culture != null)
				{
					string twoLetterISOLanguageName2 = culture.TwoLetterISOLanguageName;
					if (culture.Equals(cultureFrom))
					{
						return item;
					}
					if (spellCheckService == null && twoLetterISOLanguageName2.Is(twoLetterISOLanguageName))
					{
						spellCheckService = item;
					}
				}
			}
			return spellCheckService;
		}

		public static IStylingService? GetCssStyling(this IBrowsingContext context)
		{
			return context.GetStyling(MimeTypeNames.Css);
		}

		public static IStylingService? GetStyling(this IBrowsingContext context, string type)
		{
			foreach (IStylingService service in context.GetServices<IStylingService>())
			{
				if (service.SupportsType(type))
				{
					return service;
				}
			}
			return null;
		}

		public static bool IsScripting(this IBrowsingContext context)
		{
			return context.GetServices<IScriptingService>().Any();
		}

		public static IScriptingService? GetJsScripting(this IBrowsingContext context)
		{
			return context.GetScripting(MimeTypeNames.DefaultJavaScript);
		}

		public static IScriptingService? GetScripting(this IBrowsingContext context, string type)
		{
			foreach (IScriptingService service in context.GetServices<IScriptingService>())
			{
				if (service.SupportsType(type))
				{
					return service;
				}
			}
			return null;
		}

		public static ICommand? GetCommand(this IBrowsingContext context, string commandId)
		{
			return context.GetProvider<ICommandProvider>()?.GetCommand(commandId);
		}

		public static void TrackError(this IBrowsingContext context, Exception ex)
		{
			AngleSharp.Browser.Dom.Events.TrackEvent eventData = new AngleSharp.Browser.Dom.Events.TrackEvent("error", ex);
			context.Fire(eventData);
		}

		public static Task InteractAsync<T>(this IBrowsingContext context, string eventName, T data)
		{
			InteractivityEvent<T> interactivityEvent = new InteractivityEvent<T>(eventName, data);
			context.Fire(interactivityEvent);
			return interactivityEvent.Result ?? Task.FromResult(result: false);
		}

		public static IBrowsingContext ResolveTargetContext(this IBrowsingContext context, string? target)
		{
			bool flag = false;
			IBrowsingContext browsingContext = context;
			if (target != null && target.Length > 0)
			{
				browsingContext = context.FindChildFor(target);
				flag = browsingContext == null;
			}
			if (flag)
			{
				browsingContext = context.CreateChildFor(target);
			}
			return browsingContext;
		}

		public static IBrowsingContext CreateChildFor(this IBrowsingContext context, string? target)
		{
			Sandboxes security = Sandboxes.None;
			if (target == "_blank")
			{
				target = null;
			}
			return context.CreateChild(target, security);
		}

		public static IBrowsingContext? FindChildFor(this IBrowsingContext context, string target)
		{
			if (!string.IsNullOrEmpty(target))
			{
				switch (target)
				{
				case "_self":
					break;
				case "_parent":
					return context.Parent ?? context;
				case "_top":
					return context;
				default:
					return context.FindChild(target);
				}
			}
			return context;
		}

		public static IEnumerable<Task> GetDownloads<T>(this IBrowsingContext context) where T : INode
		{
			IResourceLoader service = context.GetService<IResourceLoader>();
			if (service == null)
			{
				return Array.Empty<Task>();
			}
			return from m in service.GetDownloads()
				where m.Source is T
				select m.Task;
		}
	}
	public class Configuration : IConfiguration
	{
		private readonly IEnumerable<object> _services;

		public static IConfiguration Default => new Configuration();

		public IEnumerable<object> Services => _services;

		private static T Instance<T>(T instance)
		{
			return instance;
		}

		private static Func<IBrowsingContext, T> Creator<T>(Func<IBrowsingContext, T> creator)
		{
			return creator;
		}

		public Configuration(IEnumerable<object>? services = null)
		{
			_services = services ?? new object[17]
			{
				Instance((IElementFactory<Document, HtmlElement>)new HtmlElementFactory()),
				Instance((IElementFactory<Document, MathElement>)new MathElementFactory()),
				Instance((IElementFactory<Document, SvgElement>)new SvgElementFactory()),
				Instance((IEventFactory)new DefaultEventFactory()),
				Instance((IInputTypeFactory)new DefaultInputTypeFactory()),
				Instance((IAttributeSelectorFactory)new DefaultAttributeSelectorFactory()),
				Instance((IPseudoElementSelectorFactory)new DefaultPseudoElementSelectorFactory()),
				Instance((IPseudoClassSelectorFactory)new DefaultPseudoClassSelectorFactory()),
				Instance((ILinkRelationFactory)new DefaultLinkRelationFactory()),
				Instance((IDocumentFactory)new DefaultDocumentFactory()),
				Instance((IAttributeObserver)new DefaultAttributeObserver()),
				Instance((IMetaHandler)new EncodingMetaHandler()),
				Instance((IHtmlEncoder)new DefaultHtmlEncoder()),
				Creator((Func<IBrowsingContext, ICssSelectorParser>)((IBrowsingContext ctx) => new CssSelectorParser(ctx))),
				Creator((Func<IBrowsingContext, IHtmlParser>)((IBrowsingContext ctx) => new HtmlParser(ctx))),
				Creator((Func<IBrowsingContext, INavigationHandler>)((IBrowsingContext ctx) => new DefaultNavigationHandler(ctx))),
				Creator((Func<IBrowsingContext, IHtmlElementConstructionFactory>)((IBrowsingContext ctx) => new HtmlDomConstructionFactory(ctx)))
			};
		}
	}
	public static class ConfigurationExtensions
	{
		public static IConfiguration With(this IConfiguration configuration, object service)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			service = service ?? throw new ArgumentNullException("service");
			return new Configuration(configuration.Services.Concat(service));
		}

		public static IConfiguration WithOnly<TService>(this IConfiguration configuration, TService service)
		{
			if (service == null)
			{
				throw new ArgumentNullException("service");
			}
			return configuration.Without<TService>().With(service);
		}

		public static IConfiguration WithOnly<TService>(this IConfiguration configuration, Func<IBrowsingContext, TService> creator)
		{
			creator = creator ?? throw new ArgumentNullException("creator");
			return configuration.Without<TService>().With(creator);
		}

		public static IConfiguration Without(this IConfiguration configuration, object service)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			service = service ?? throw new ArgumentNullException("service");
			return new Configuration(configuration.Services.Except(service));
		}

		public static IConfiguration With(this IConfiguration configuration, IEnumerable<object> services)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			services = services ?? throw new ArgumentNullException("services");
			return new Configuration(services.Concat(configuration.Services));
		}

		public static IConfiguration Without(this IConfiguration configuration, IEnumerable<object> services)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			services = services ?? throw new ArgumentNullException("services");
			return new Configuration(configuration.Services.Except(services));
		}

		public static IConfiguration With<TService>(this IConfiguration configuration, Func<IBrowsingContext, TService> creator)
		{
			creator = creator ?? throw new ArgumentNullException("creator");
			return configuration.With((object)creator);
		}

		public static IConfiguration Without<TService>(this IConfiguration configuration)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			IEnumerable<object> services = configuration.Services.OfType<TService>().Cast<object>();
			IEnumerable<Func<IBrowsingContext, TService>> services2 = configuration.Services.OfType<Func<IBrowsingContext, TService>>();
			return configuration.Without(services).Without(services2);
		}

		public static bool Has<TService>(this IConfiguration configuration)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			if (!configuration.Services.OfType<TService>().Any())
			{
				return configuration.Services.OfType<Func<IBrowsingContext, TService>>().Any();
			}
			return true;
		}

		public static IConfiguration WithDefaultLoader(this IConfiguration configuration, LoaderOptions? setup = null)
		{
			LoaderOptions config = setup ?? new LoaderOptions();
			if (!configuration.Has<IRequester>())
			{
				configuration = configuration.With(new DefaultHttpRequester());
			}
			if (!config.IsNavigationDisabled)
			{
				configuration = configuration.With((Func<IBrowsingContext, IDocumentLoader>)((IBrowsingContext ctx) => new DefaultDocumentLoader(ctx, config.Filter)));
			}
			if (config.IsResourceLoadingEnabled)
			{
				configuration = configuration.With((Func<IBrowsingContext, IResourceLoader>)((IBrowsingContext ctx) => new DefaultResourceLoader(ctx, config.Filter)));
			}
			return configuration;
		}

		public static IConfiguration WithCulture(this IConfiguration configuration, string name)
		{
			CultureInfo culture = new CultureInfo(name);
			return configuration.WithCulture(culture);
		}

		public static IConfiguration WithCulture(this IConfiguration configuration, CultureInfo culture)
		{
			return configuration.With(culture);
		}

		public static IConfiguration WithMetaRefresh(this IConfiguration configuration, Predicate<Url>? shouldRefresh = null)
		{
			RefreshMetaHandler service = new RefreshMetaHandler(shouldRefresh);
			return configuration.With(service);
		}

		public static IConfiguration WithLocaleBasedEncoding(this IConfiguration configuration)
		{
			LocaleEncodingProvider service = new LocaleEncodingProvider();
			return configuration.With(service);
		}

		public static IConfiguration WithDefaultCookies(this IConfiguration configuration)
		{
			MemoryCookieProvider service = new MemoryCookieProvider();
			return configuration.With(service);
		}
	}
	public static class FormatExtensions
	{
		public static string ToCss(this IStyleFormattable style)
		{
			return style.ToCss(CssStyleFormatter.Instance);
		}

		public static string ToCss(this IStyleFormattable style, IStyleFormatter formatter)
		{
			StringBuilder sb = StringBuilderPool.Obtain();
			using (StringWriter writer = new StringWriter(sb))
			{
				style.ToCss(writer, formatter);
			}
			return sb.ToPool();
		}

		public static void ToCss(this IStyleFormattable style, TextWriter writer)
		{
			style.ToCss(writer, CssStyleFormatter.Instance);
		}

		public static Task ToCssAsync(this IStyleFormattable style, TextWriter writer)
		{
			return writer.WriteAsync(style.ToCss());
		}

		public static async Task ToCssAsync(this IStyleFormattable style, Stream stream)
		{
			using StreamWriter writer = new StreamWriter(stream);
			await style.ToCssAsync(writer).ConfigureAwait(continueOnCapturedContext: false);
		}

		public static string ToHtml(this IMarkupFormattable markup)
		{
			return markup.ToHtml(HtmlMarkupFormatter.Instance);
		}

		public static string ToHtml(this IMarkupFormattable markup, IMarkupFormatter formatter)
		{
			StringBuilder sb = StringBuilderPool.Obtain();
			using (StringWriter writer = new StringWriter(sb))
			{
				markup.ToHtml(writer, formatter);
			}
			return sb.ToPool();
		}

		public static void ToHtml(this IMarkupFormattable markup, TextWriter writer)
		{
			markup.ToHtml(writer, HtmlMarkupFormatter.Instance);
		}

		public static string Minify(this IMarkupFormattable markup)
		{
			return markup.ToHtml(new MinifyMarkupFormatter());
		}

		public static string Prettify(this IMarkupFormattable markup)
		{
			return markup.ToHtml(new PrettyMarkupFormatter());
		}

		public static Task ToHtmlAsync(this IMarkupFormattable markup, TextWriter writer)
		{
			return writer.WriteAsync(markup.ToHtml());
		}

		public static async Task ToHtmlAsync(this IMarkupFormattable markup, Stream stream)
		{
			using StreamWriter writer = new StreamWriter(stream);
			await markup.ToHtmlAsync(writer).ConfigureAwait(continueOnCapturedContext: false);
		}
	}
	public interface IBrowsingContext : IEventTarget, IDisposable
	{
		IWindow? Current { get; }

		IDocument? Active { get; set; }

		IHistory? SessionHistory { get; }

		Sandboxes Security { get; }

		IBrowsingContext? Parent { get; }

		IDocument? Creator { get; }

		IEnumerable<object> OriginalServices { get; }

		T? GetService<T>() where T : class;

		IEnumerable<T> GetServices<T>() where T : class;

		IBrowsingContext CreateChild(string? name, Sandboxes security);

		IBrowsingContext? FindChild(string name);
	}
	public interface IConfiguration
	{
		IEnumerable<object> Services { get; }
	}
	public interface IMarkupFormattable
	{
		void ToHtml(TextWriter writer, IMarkupFormatter formatter);
	}
	public interface IMarkupFormatter
	{
		string Text(ICharacterData text);

		string LiteralText(ICharacterData text);

		string Comment(IComment comment);

		string Processing(IProcessingInstruction processing);

		string Doctype(IDocumentType doctype);

		string OpenTag(IElement element, bool selfClosing);

		string CloseTag(IElement element, bool selfClosing);
	}
	public interface IStyleFormattable
	{
		void ToCss(TextWriter writer, IStyleFormatter formatter);
	}
	public interface IStyleFormatter
	{
		string Sheet(IEnumerable<IStyleFormattable> rules);

		string Declaration(string name, string value, bool important);

		string BlockDeclarations(IEnumerable<IStyleFormattable> declarations);

		string Rule(string name, string value);

		string Rule(string name, string prelude, string rules);

		string BlockRules(IEnumerable<IStyleFormattable> rules);

		string Comment(string data);
	}
}
namespace AngleSharp.Xhtml
{
	public class XhtmlMarkupFormatter : IMarkupFormatter
	{
		public static readonly IMarkupFormatter Instance = new XhtmlMarkupFormatter();

		private readonly bool _emptyTagsToSelfClosing;

		public bool IsSelfClosingEmptyTags => _emptyTagsToSelfClosing;

		public XhtmlMarkupFormatter()
			: this(emptyTagsToSelfClosing: true)
		{
		}

		public XhtmlMarkupFormatter(bool emptyTagsToSelfClosing)
		{
			_emptyTagsToSelfClosing = emptyTagsToSelfClosing;
		}

		public virtual string CloseTag(IElement element, bool selfClosing)
		{
			string prefix = element.Prefix;
			string localName = element.LocalName;
			string text = ((!string.IsNullOrEmpty(prefix)) ? (prefix + ":" + localName) : localName);
			if (!selfClosing && (!_emptyTagsToSelfClosing || element.HasChildNodes))
			{
				return "</" + text + ">";
			}
			return string.Empty;
		}

		public virtual string Comment(IComment comment)
		{
			return "<!--" + comment.Data + "-->";
		}

		public virtual string Doctype(IDocumentType doctype)
		{
			string publicIdentifier = doctype.PublicIdentifier;
			string systemIdentifier = doctype.SystemIdentifier;
			string text = ((string.IsNullOrEmpty(publicIdentifier) && string.IsNullOrEmpty(systemIdentifier)) ? string.Empty : (" " + (string.IsNullOrEmpty(publicIdentifier) ? ("SYSTEM \"" + systemIdentifier + "\"") : ("PUBLIC \"" + publicIdentifier + "\" \"" + systemIdentifier + "\""))));
			return "<!DOCTYPE " + doctype.Name + text + ">";
		}

		public virtual string OpenTag(IElement element, bool selfClosing)
		{
			string prefix = element.Prefix;
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			stringBuilder.Append('<');
			if (!string.IsNullOrEmpty(prefix))
			{
				stringBuilder.Append(prefix).Append(':');
			}
			stringBuilder.Append(element.LocalName);
			foreach (IAttr attribute in element.Attributes)
			{
				stringBuilder.Append(' ').Append(Attribute(attribute));
			}
			if (selfClosing || (_emptyTagsToSelfClosing && !element.HasChildNodes))
			{
				stringBuilder.Append(" /");
			}
			stringBuilder.Append('>');
			return stringBuilder.ToPool();
		}

		public virtual string Processing(IProcessingInstruction processing)
		{
			string text = processing.Target + " " + processing.Data;
			return "<?" + text + "?>";
		}

		public virtual string LiteralText(ICharacterData text)
		{
			return text.Data;
		}

		public virtual string Text(ICharacterData text)
		{
			return EscapeText(text.Data);
		}

		protected virtual string Attribute(IAttr attribute)
		{
			string namespaceUri = attribute.NamespaceUri;
			string localName = attribute.LocalName;
			string value = attribute.Value;
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			if (string.IsNullOrEmpty(namespaceUri))
			{
				stringBuilder.Append(localName);
			}
			else if (namespaceUri.Is(NamespaceNames.XmlUri))
			{
				stringBuilder.Append(NamespaceNames.XmlPrefix).Append(':').Append(localName);
			}
			else if (namespaceUri.Is(NamespaceNames.XLinkUri))
			{
				stringBuilder.Append(NamespaceNames.XLinkPrefix).Append(':').Append(localName);
			}
			else if (namespaceUri.Is(NamespaceNames.XmlNsUri))
			{
				stringBuilder.Append(XmlNamespaceLocalName(localName));
			}
			else
			{
				stringBuilder.Append(attribute.Name);
			}
			stringBuilder.Append('=').Append('"');
			for (int i = 0; i < value.Length; i++)
			{
				switch (value[i])
				{
				case '&':
					stringBuilder.Append("&amp;");
					break;
				case '\u00a0':
					stringBuilder.Append("&#160;");
					break;
				case '<':
					stringBuilder.Append("&lt;");
					break;
				case '"':
					stringBuilder.Append("&quot;");
					break;
				default:
					stringBuilder.Append(value[i]);
					break;
				}
			}
			return stringBuilder.Append('"').ToPool();
		}

		public static string EscapeText(string content)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			for (int i = 0; i < content.Length; i++)
			{
				switch (content[i])
				{
				case '&':
					stringBuilder.Append("&amp;");
					break;
				case '\u00a0':
					stringBuilder.Append("&#160;");
					break;
				case '>':
					stringBuilder.Append("&gt;");
					break;
				case '<':
					stringBuilder.Append("&lt;");
					break;
				default:
					stringBuilder.Append(content[i]);
					break;
				}
			}
			return stringBuilder.ToPool();
		}

		public static string XmlNamespaceLocalName(string localName)
		{
			if (localName.Is(NamespaceNames.XmlNsPrefix))
			{
				return localName;
			}
			return NamespaceNames.XmlNsPrefix + ':' + localName;
		}
	}
}
namespace AngleSharp.Text
{
	public sealed class CharArrayTextSource : IReadOnlyTextSource, IDisposable
	{
		private int _index;

		private string? _content;

		private readonly char[] _array;

		private readonly ReadOnlyMemory<char> _memory;

		private readonly int _length;

		public string Text => _content ?? (_content = new string(_array, 0, _length));

		public char this[int index] => _array[index];

		public int Length => _length;

		public Encoding CurrentEncoding
		{
			get
			{
				return TextEncoding.Utf8;
			}
			set
			{
			}
		}

		public int Index
		{
			get
			{
				return _index;
			}
			set
			{
				_index = value;
			}
		}

		public CharArrayTextSource(char[] array, int length)
		{
			_array = array;
			_length = length;
			_memory = array.AsMemory(0, length);
		}

		public void Dispose()
		{
		}

		public char ReadCharacter()
		{
			if (_index < _length)
			{
				return _array[_index++];
			}
			_index++;
			return '\uffff';
		}

		public string ReadCharacters(int characters)
		{
			return ReadMemory(characters).ToString();
		}

		public StringOrMemory ReadMemory(int characters)
		{
			int index = _index;
			if (index + characters <= _length)
			{
				_index += characters;
				return _memory.Slice(index, characters);
			}
			_index += characters;
			characters = Math.Min(characters, _length - index);
			return _memory.Slice(index, characters);
		}

		public Task PrefetchAsync(int length, CancellationToken cancellationToken)
		{
			return Task.CompletedTask;
		}

		public Task PrefetchAllAsync(CancellationToken cancellationToken)
		{
			return Task.CompletedTask;
		}

		public bool TryGetContentLength(out int length)
		{
			length = _length;
			return true;
		}
	}
	public static class CharExtensions
	{
		public static int FromHex(this char c)
		{
			if (!c.IsDigit())
			{
				return c - (c.IsLowercaseAscii() ? 87 : 55);
			}
			return c - 48;
		}

		public static string ToHex(this byte num)
		{
			Span<char> span = stackalloc char[2];
			int num2 = num >> 4;
			span[0] = (char)(num2 + ((num2 < 10) ? 48 : 55));
			num2 = num - 16 * num2;
			span[1] = (char)(num2 + ((num2 < 10) ? 48 : 55));
			return span.ToString();
		}

		public static string ToHex(this char character)
		{
			int num = character;
			return num.ToString("x");
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsInRange(this char c, int lower, int upper)
		{
			if (c >= lower)
			{
				return c <= upper;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNormalQueryCharacter(this char c)
		{
			if (c.IsInRange(33, 126) && c != '"' && c != '`' && c != '#' && c != '<')
			{
				return c != '>';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNormalPathCharacter(this char c)
		{
			if (c.IsInRange(32, 126) && c != '"' && c != '`' && c != '#' && c != '<' && c != '>' && c != ' ')
			{
				return c != '?';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsUppercaseAscii(this char c)
		{
			if (c >= 'A')
			{
				return c <= 'Z';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLowercaseAscii(this char c)
		{
			if (c >= 'a')
			{
				return c <= 'z';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsAlphanumericAscii(this char c)
		{
			if (!c.IsDigit() && !c.IsUppercaseAscii())
			{
				return c.IsLowercaseAscii();
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHex(this char c)
		{
			if (!c.IsDigit() && (c < 'A' || c > 'F'))
			{
				if (c >= 'a')
				{
					return c <= 'f';
				}
				return false;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNonAscii(this char c)
		{
			if (c != '\uffff')
			{
				return c >= '\u0080';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNonPrintable(this char c)
		{
			if ((c < '\0' || c > '\b') && (c < '\u000e' || c > '\u001f'))
			{
				if (c >= '\u007f')
				{
					return c <= '\u009f';
				}
				return false;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLetter(this char c)
		{
			if (!c.IsUppercaseAscii())
			{
				return c.IsLowercaseAscii();
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsName(this char c)
		{
			if (!c.IsNonAscii() && !c.IsLetter() && c != '_' && c != '-')
			{
				return c.IsDigit();
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsCustomElementName(this char c)
		{
			if (c != '_' && c != '-' && c != '.' && !c.IsDigit() && !c.IsLowercaseAscii() && c != '·' && !c.IsInRange(192, 214) && !c.IsInRange(216, 246) && !c.IsInRange(248, 893) && !c.IsInRange(895, 8191) && !c.IsInRange(8204, 8205) && !c.IsInRange(8255, 8256) && !c.IsInRange(8304, 8591) && !c.IsInRange(11264, 12271) && !c.IsInRange(12289, 55295) && !c.IsInRange(63744, 64975) && !c.IsInRange(65008, 65533))
			{
				return c.IsInRange(65536, 2031615);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNameStart(this char c)
		{
			if (!c.IsNonAscii() && !c.IsUppercaseAscii() && !c.IsLowercaseAscii())
			{
				return c == '_';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLineBreak(this char c)
		{
			if (c != '\n')
			{
				return c == '\r';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsSpaceCharacter(this char c)
		{
			if (c != ' ' && c != '\t' && c != '\n' && c != '\r')
			{
				return c == '\f';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsWhiteSpaceCharacter(this char c)
		{
			if (!c.IsInRange(9, 13) && c != ' ' && c != '\u0085' && c != '\u00a0' && c != '\u1680' && c != '\u180e' && !c.IsInRange(8192, 8202) && c != '\u2028' && c != '\u2029' && c != '\u202f' && c != '\u205f')
			{
				return c == '\u3000';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsDigit(this char c)
		{
			if (c >= '0')
			{
				return c <= '9';
			}
			return false;
		}

		public static bool IsUrlCodePoint(this char c)
		{
			if (!c.IsAlphanumericAscii() && c != '!' && c != '$' && c != '&' && c != '\'' && c != '(' && c != ')' && c != '*' && c != '+' && c != '-' && c != ',' && c != '.' && c != '/' && c != ':' && c != ';' && c != '=' && c != '?' && c != '@' && c != '_' && c != '~' && !c.IsInRange(160, 55295) && !c.IsInRange(57344, 64975) && !c.IsInRange(65008, 65533) && !c.IsInRange(65536, 131069) && !c.IsInRange(131072, 196605) && !c.IsInRange(196608, 262141) && !c.IsInRange(262144, 327677) && !c.IsInRange(327680, 393213) && !c.IsInRange(393216, 458749) && !c.IsInRange(458752, 524285) && !c.IsInRange(524288, 589821) && !c.IsInRange(589824, 655357) && !c.IsInRange(655360, 720893) && !c.IsInRange(720896, 786429) && !c.IsInRange(786432, 851965) && !c.IsInRange(851968, 917501) && !c.IsInRange(917504, 983037) && !c.IsInRange(983040, 1048573))
			{
				return c.IsInRange(1048576, 1114109);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsInvalid(this int c)
		{
			if (c != 0 && c <= 1114111)
			{
				if (c > 55296)
				{
					return c < 57343;
				}
				return false;
			}
			return true;
		}
	}
	public interface ITextSource : IReadOnlyTextSource, IDisposable
	{
		void InsertText(string content);
	}
	public interface IReadOnlyTextSource : IDisposable
	{
		string Text { get; }

		int Length { get; }

		Encoding CurrentEncoding { get; set; }

		int Index { get; set; }

		char this[int index] { get; }

		char ReadCharacter();

		string ReadCharacters(int characters);

		StringOrMemory ReadMemory(int characters);

		Task PrefetchAsync(int length, CancellationToken cancellationToken);

		Task PrefetchAllAsync(CancellationToken cancellationToken);

		bool TryGetContentLength(out int length);
	}
	public static class Punycode
	{
		private const int PunycodeBase = 36;

		private const int Tmin = 1;

		private const int Tmax = 26;

		private static readonly string acePrefix = "xn--";

		private static readonly char[] possibleDots = new char[4] { '.', '。', '.', '。' };

		public static IDictionary<char, char> Symbols = new Dictionary<char, char>
		{
			{ '。', '.' },
			{ '.', '.' },
			{ 'G', 'g' },
			{ 'o', 'o' },
			{ 'c', 'c' },
			{ 'X', 'x' },
			{ '0', '0' },
			{ '1', '1' },
			{ '2', '2' },
			{ '5', '5' },
			{ '⁰', '0' },
			{ '¹', '1' },
			{ '²', '2' },
			{ '³', '3' },
			{ '⁴', '4' },
			{ '⁵', '5' },
			{ '⁶', '6' },
			{ '⁷', '7' },
			{ '⁸', '8' },
			{ '⁹', '9' },
			{ '₀', '0' },
			{ '₁', '1' },
			{ '₂', '2' },
			{ '₃', '3' },
			{ '₄', '4' },
			{ '₅', '5' },
			{ '₆', '6' },
			{ '₇', '7' },
			{ '₈', '8' },
			{ '₉', '9' },
			{ 'ᵃ', 'a' },
			{ 'ᵇ', 'b' },
			{ 'ᶜ', 'c' },
			{ 'ᵈ', 'd' },
			{ 'ᵉ', 'e' },
			{ 'ᶠ', 'f' },
			{ 'ᵍ', 'g' },
			{ 'ʰ', 'h' },
			{ 'ⁱ', 'i' },
			{ 'ʲ', 'j' },
			{ 'ᵏ', 'k' },
			{ 'ˡ', 'l' },
			{ 'ᵐ', 'm' },
			{ 'ⁿ', 'n' },
			{ 'ᵒ', 'o' },
			{ 'ᵖ', 'p' },
			{ 'ʳ', 'r' },
			{ 'ˢ', 's' },
			{ 'ᵗ', 't' },
			{ 'ᵘ', 'u' },
			{ 'ᵛ', 'v' },
			{ 'ʷ', 'w' },
			{ 'ˣ', 'x' },
			{ 'ʸ', 'y' },
			{ 'ᶻ', 'z' },
			{ 'ᴬ', 'A' },
			{ 'ᴮ', 'B' },
			{ 'ᴰ', 'D' },
			{ 'ᴱ', 'E' },
			{ 'ᴳ', 'G' },
			{ 'ᴴ', 'H' },
			{ 'ᴵ', 'I' },
			{ 'ᴶ', 'J' },
			{ 'ᴷ', 'K' },
			{ 'ᴸ', 'L' },
			{ 'ᴹ', 'M' },
			{ 'ᴺ', 'N' },
			{ 'ᴼ', 'O' },
			{ 'ᴾ', 'P' },
			{ 'ᴿ', 'R' },
			{ 'ᵀ', 'T' },
			{ 'ᵁ', 'U' },
			{ 'ⱽ', 'V' },
			{ 'ᵂ', 'W' }
		};

		public static string Encode(string text)
		{
			if (text.Length == 0)
			{
				return text;
			}
			StringBuilder stringBuilder = new StringBuilder(text.Length);
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			while (num < text.Length)
			{
				num = text.IndexOfAny(possibleDots, num2);
				if (num < 0)
				{
					num = text.Length;
				}
				if (num == num2)
				{
					break;
				}
				stringBuilder.Append(acePrefix);
				int num4 = 0;
				int num5 = 0;
				for (num4 = num2; num4 < num; num4++)
				{
					if (text[num4] < '\u0080')
					{
						stringBuilder.Append(EncodeBasic(text[num4]));
						num5++;
					}
					else if (char.IsSurrogatePair(text, num4))
					{
						num4++;
					}
				}
				int num6 = num5;
				if (num6 == num - num2)
				{
					stringBuilder.Remove(num3, acePrefix.Length);
				}
				else
				{
					if (text.Length - num2 >= acePrefix.Length && text.Substring(num2, acePrefix.Length).Isi(acePrefix))
					{
						break;
					}
					int num7 = 0;
					if (num6 > 0)
					{
						stringBuilder.Append('-');
					}
					int num8 = 128;
					int num9 = 0;
					int num10 = 72;
					while (num5 < num - num2)
					{
						int num11 = 0;
						int num12 = 0;
						int num13 = 0;
						num12 = 134217727;
						for (num11 = num2; num11 < num; num11 += ((!IsSupplementary(num13)) ? 1 : 2))
						{
							num13 = char.ConvertToUtf32(text, num11);
							if (num13 >= num8 && num13 < num12)
							{
								num12 = num13;
							}
						}
						num9 += (num12 - num8) * (num5 - num7 + 1);
						num8 = num12;
						for (num11 = num2; num11 < num; num11 += ((!IsSupplementary(num13)) ? 1 : 2))
						{
							num13 = char.ConvertToUtf32(text, num11);
							if (num13 < num8)
							{
								num9++;
							}
							else
							{
								if (num13 != num8)
								{
									continue;
								}
								int num14 = num9;
								int num15 = 36;
								while (true)
								{
									int num16 = ((num15 <= num10) ? 1 : ((num15 >= num10 + 26) ? 26 : (num15 - num10)));
									if (num14 < num16)
									{
										break;
									}
									stringBuilder.Append(EncodeDigit(num16 + (num14 - num16) % (36 - num16)));
									num14 = (num14 - num16) / (36 - num16);
									num15 += 36;
								}
								stringBuilder.Append(EncodeDigit(num14));
								num10 = AdaptChar(num9, num5 - num7 + 1, num5 == num6);
								num9 = 0;
								num5++;
								if (IsSupplementary(num12))
								{
									num5++;
									num7++;
								}
							}
						}
						num9++;
						num8++;
					}
				}
				if (stringBuilder.Length - num3 > 63)
				{
					throw new ArgumentException();
				}
				if (num != text.Length)
				{
					stringBuilder.Append(possibleDots[0]);
				}
				num2 = num + 1;
				num3 = stringBuilder.Length;
			}
			int num17 = ((!IsDot(text[text.Length - 1])) ? 1 : 0);
			int num18 = 255 - num17;
			if (stringBuilder.Length > num18)
			{
				stringBuilder.Remove(num18, stringBuilder.Length - num18);
			}
			return stringBuilder.ToString();
		}

		private static bool IsSupplementary(int test)
		{
			return test >= 65536;
		}

		private static bool IsDot(char c)
		{
			for (int i = 0; i < possibleDots.Length; i++)
			{
				if (possibleDots[i] == c)
				{
					return true;
				}
			}
			return false;
		}

		private static char EncodeDigit(int digit)
		{
			if (digit > 25)
			{
				return (char)(digit + 22);
			}
			return (char)(digit + 97);
		}

		private static char EncodeBasic(char character)
		{
			if (char.IsUpper(character))
			{
				character = (char)(character + 32);
			}
			return character;
		}

		private static int AdaptChar(int delta, int numPoints, bool firstTime)
		{
			uint num = 0u;
			delta = (firstTime ? (delta / 700) : (delta / 2));
			delta += delta / numPoints;
			num = 0u;
			while (delta > 455)
			{
				delta /= 35;
				num += 36;
			}
			return (int)(num + 36 * delta / (delta + 38));
		}
	}
	public sealed class ReadOnlyMemoryTextSource : IReadOnlyTextSource, IDisposable
	{
		private int _index;

		private string? _content;

		private readonly ReadOnlyMemory<char> _memory;

		private readonly int _length;

		public string Text => _content ?? (_content = _memory.Span.ToString());

		public char this[int index]
		{
			get
			{
				if (_content == null)
				{
					return _memory.Span[index];
				}
				return _content[index];
			}
		}

		public int Length => _length;

		public Encoding CurrentEncoding
		{
			get
			{
				return TextEncoding.Utf8;
			}
			set
			{
			}
		}

		public int Index
		{
			get
			{
				return _index;
			}
			set
			{
				_index = value;
			}
		}

		public ReadOnlyMemoryTextSource(ReadOnlyMemory<char> memory)
		{
			_memory = memory;
			_length = memory.Length;
		}

		public ReadOnlyMemoryTextSource(string str)
		{
			_content = str;
			_memory = str.AsMemory();
			_length = _memory.Length;
		}

		public void Dispose()
		{
		}

		public char ReadCharacter()
		{
			if (_index < _length)
			{
				return _memory.Span[_index++];
			}
			_index++;
			return '\uffff';
		}

		public string ReadCharacters(int characters)
		{
			return ReadMemory(characters).ToString();
		}

		public StringOrMemory ReadMemory(int characters)
		{
			int index = _index;
			if (index + characters <= _length)
			{
				_index += characters;
				return _memory.Slice(index, characters);
			}
			_index += characters;
			characters = Math.Min(characters, _length - index);
			return _memory.Slice(index, characters);
		}

		public Task PrefetchAsync(int length, CancellationToken cancellationToken)
		{
			return Task.CompletedTask;
		}

		public Task PrefetchAllAsync(CancellationToken cancellationToken)
		{
			return Task.CompletedTask;
		}

		public bool TryGetContentLength(out int length)
		{
			length = _length;
			return true;
		}
	}
	public static class StringBuilderPool
	{
		private static readonly Stack<StringBuilder> _builder = new Stack<StringBuilder>();

		private static readonly object _lock = new object();

		private static int _count = 4;

		private static int _limit = 85000;

		public static int MaxCount
		{
			get
			{
				return _count;
			}
			set
			{
				_count = Math.Max(1, value);
			}
		}

		public static int SizeLimit
		{
			get
			{
				return _limit;
			}
			set
			{
				_limit = Math.Max(1024, value);
			}
		}

		public static StringBuilder Obtain()
		{
			lock (_lock)
			{
				if (_builder.Count == 0)
				{
					return new StringBuilder(1024);
				}
				return _builder.Pop().Clear();
			}
		}

		public static string ToPool(this StringBuilder sb)
		{
			string result = sb.ToString();
			sb.ReturnToPool();
			return result;
		}

		internal static void ReturnToPool(this StringBuilder sb)
		{
			lock (_lock)
			{
				int count = _builder.Count;
				if (sb.Capacity <= _limit)
				{
					if (count == _count)
					{
						DropMinimum(sb);
					}
					else if (count < Math.Min(2, _count) || _builder.Peek().Capacity < sb.Capacity)
					{
						_builder.Push(sb);
					}
				}
			}
		}

		private static void DropMinimum(StringBuilder sb)
		{
			int capacity = sb.Capacity;
			StringBuilder[] instances = _builder.ToArray();
			int num = FindIndex(instances, capacity);
			if (num > -1)
			{
				RebuildPool(sb, instances, num);
			}
		}

		private static void RebuildPool(StringBuilder sb, StringBuilder[] instances, int index)
		{
			_builder.Clear();
			int num = instances.Length - 1;
			while (num > index)
			{
				_builder.Push(instances[num--]);
			}
			while (num > 0)
			{
				_builder.Push(instances[--num]);
			}
			_builder.Push(sb);
		}

		private static int FindIndex(StringBuilder[] instances, int minimum)
		{
			int result = -1;
			for (int i = 0; i < instances.Length; i++)
			{
				int capacity = instances[i].Capacity;
				if (capacity < minimum)
				{
					minimum = capacity;
					result = i;
				}
			}
			return result;
		}
	}
	public static class StringExtensions
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Has([NotNullWhen(true)] this string? value, char chr, int index = 0)
		{
			if (value != null && value.Length > index)
			{
				return value[index] == chr;
			}
			return false;
		}

		internal static string GetCompatiblity(this QuirksMode mode)
		{
			string result = "CSS1Compat";
			string text = mode.ToString();
			if (text != null)
			{
				FieldInfo field = typeof(QuirksMode).GetField(text);
				if (field != null)
				{
					DomDescriptionAttribute customAttribute = field.GetCustomAttribute<DomDescriptionAttribute>();
					if (customAttribute != null)
					{
						result = customAttribute.Description;
					}
				}
			}
			return result;
		}

		public static StringOrMemory HtmlLower(this StringOrMemory value)
		{
			int length = value.Length;
			for (int i = 0; i < length; i++)
			{
				if (value[i].IsUppercaseAscii())
				{
					if (length < 128)
					{
						Span<char> result = stackalloc char[length];
						return Slow(value, i, result);
					}
					char[] array = ArrayPool<char>.Shared.Rent(length);
					Span<char> result2 = array.AsSpan(0, length);
					string text = Slow(value, i, result2);
					ArrayPool<char>.Shared.Return(array);
					return text;
				}
			}
			return value;
			static string Slow(StringOrMemory stringOrMemory, int num, Span<char> span)
			{
				for (int j = 0; j < num; j++)
				{
					span[j] = stringOrMemory[j];
				}
				char c = stringOrMemory[num];
				span[num] = char.ToLowerInvariant(c);
				for (int k = num + 1; k < stringOrMemory.Length; k++)
				{
					c = stringOrMemory[k];
					if (c.IsUppercaseAscii())
					{
						c = char.ToLowerInvariant(c);
					}
					span[k] = c;
				}
				return span.ToString();
			}
		}

		public static string HtmlLower(this string value)
		{
			return new StringOrMemory(value).HtmlLower().ToString();
		}

		public static Sandboxes ParseSecuritySettings(this string value, bool allowFullscreen = false)
		{
			string[] list = value.SplitSpaces();
			Sandboxes sandboxes = Sandboxes.Navigation | Sandboxes.Plugins | Sandboxes.DocumentDomain;
			if (!list.Contains("allow-popups", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.AuxiliaryNavigation;
			}
			if (!list.Contains("allow-top-navigation", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.TopLevelNavigation;
			}
			if (!list.Contains("allow-same-origin", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Origin;
			}
			if (!list.Contains("allow-forms", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Forms;
			}
			if (!list.Contains("allow-pointer-lock", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.PointerLock;
			}
			if (!list.Contains("allow-scripts", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Scripts;
				sandboxes |= Sandboxes.AutomaticFeatures;
			}
			if (!list.Contains("allow-presentation", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Presentation;
			}
			if (!allowFullscreen)
			{
				sandboxes |= Sandboxes.Fullscreen;
			}
			return sandboxes;
		}

		public static T ToEnum<T>(this string? value, T defaultValue) where T : struct, Enum
		{
			if (!string.IsNullOrEmpty(value) && Enum.TryParse<T>(value, ignoreCase: true, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static double ToDouble(this string? value, double defaultValue = 0.0)
		{
			if (!string.IsNullOrEmpty(value) && double.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static int ToInteger(this string? value, int defaultValue = 0)
		{
			if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static uint ToInteger(this string? value, uint defaultValue = 0u)
		{
			if (!string.IsNullOrEmpty(value) && uint.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static bool ToBoolean(this string? value, bool defaultValue = false)
		{
			if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static string ReplaceFirst(this string text, string search, string replace)
		{
			int num = text.IndexOf(search);
			if (num < 0)
			{
				return text;
			}
			return text.Substring(0, num) + replace + text.Substring(num + search.Length);
		}

		public static string CollapseAndStrip(this string str)
		{
			if (str.Length == 0)
			{
				return str;
			}
			char[] array = ArrayPool<char>.Shared.Rent(str.Length);
			bool flag = true;
			int num = 0;
			int length = str.Length;
			for (int i = 0; i < length; i++)
			{
				if (str[i].IsSpaceCharacter())
				{
					if (!flag)
					{
						flag = true;
						array[num++] = ' ';
					}
				}
				else
				{
					flag = false;
					array[num++] = str[i];
				}
			}
			if (flag && num > 0)
			{
				num--;
			}
			string result = new string(array, 0, num);
			ArrayPool<char>.Shared.Return(array);
			return result;
		}

		public static string Collapse(this string str)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			bool flag = false;
			int length = str.Length;
			for (int i = 0; i < length; i++)
			{
				if (str[i].IsSpaceCharacter())
				{
					if (!flag)
					{
						stringBuilder.Append(' ');
						flag = true;
					}
				}
				else
				{
					flag = false;
					stringBuilder.Append(str[i]);
				}
			}
			return stringBuilder.ToPool();
		}

		public static bool Contains(this string[] list, string element, StringComparison comparison = StringComparison.Ordinal)
		{
			int num = list.Length;
			for (int i = 0; i < num; i++)
			{
				if (list[i].Equals(element, comparison))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsCustomElement(this string tag)
		{
			if (tag.IndexOf('-') != -1 && !TagNames.DisallowedCustomElementNames.Contains(tag))
			{
				int length = tag.Length;
				for (int i = 0; i < length; i++)
				{
					if (!tag[i].IsCustomElementName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		public static bool IsCustomElement(this StringOrMemory tag)
		{
			if (tag.Memory.Span.IndexOf('-') != -1 && !TagNames.DisallowedCustomElementNames.Contains(tag))
			{
				int length = tag.Length;
				for (int i = 0; i < length; i++)
				{
					if (!tag[i].IsCustomElementName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is(this string? current, string? other)
		{
			return string.Equals(current, other, StringComparison.Ordinal);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is(this string? current, StringOrMemory other)
		{
			return other.Memory.Span.SequenceEqual(current.AsSpan());
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is(this Span<char> current, string? other)
		{
			if (other == null)
			{
				return false;
			}
			return current.SequenceEqual(other.AsSpan());
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is(this ReadOnlySpan<char> current, ReadOnlyMemory<char> other)
		{
			return current.SequenceEqual(other.Span);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is(this ReadOnlySpan<char> current, ReadOnlySpan<char> other)
		{
			return current.SequenceEqual(other);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this string? current, string? other)
		{
			return string.Equals(current, other, StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this string? current, StringOrMemory other)
		{
			return MemoryExtensions.Equals(current.AsSpan(), other.Memory.Span, StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this Span<char> current, string? other)
		{
			if (other == null)
			{
				return false;
			}
			return MemoryExtensions.Equals(current, other.AsSpan(), StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this Span<char> current, ReadOnlySpan<char> other)
		{
			return MemoryExtensions.Equals(current, other, StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this Span<char> current, ReadOnlyMemory<char> other)
		{
			return MemoryExtensions.Equals(current, other.Span, StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this ReadOnlySpan<char> current, string? other)
		{
			if (other == null)
			{
				return false;
			}
			return MemoryExtensions.Equals(current, other.AsSpan(), StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string? element, string item1, string item2)
		{
			if (!element.Is(item1))
			{
				return element.Is(item2);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string element, string item1, string item2, string item3)
		{
			if (!element.Is(item1) && !element.Is(item2))
			{
				return element.Is(item3);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string element, string item1, string item2, string item3, string item4)
		{
			if (!element.Is(item1) && !element.Is(item2) && !element.Is(item3))
			{
				return element.Is(item4);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string element, string item1, string item2, string item3, string item4, string item5)
		{
			if (!element.Is(item1) && !element.Is(item2) && !element.Is(item3) && !element.Is(item4))
			{
				return element.Is(item5);
			}
			return true;
		}

		public static string StripLineBreaks(this string str)
		{
			char[] array = str.ToCharArray();
			int num = 0;
			int num2 = array.Length;
			int num3 = 0;
			while (num3 < num2)
			{
				array[num3] = array[num3 + num];
				if (array[num3].IsLineBreak())
				{
					num++;
					num2--;
				}
				else
				{
					num3++;
				}
			}
			return new string(array, 0, num2);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static string StripLeadingTrailingSpaces(this string str)
		{
			int i = 0;
			int num = str.Length - 1;
			for (; i < str.Length && str[i].IsSpaceCharacter(); i++)
			{
			}
			while (num > i && str[num].IsSpaceCharacter())
			{
				num--;
			}
			return str.Substring(i, 1 + num - i);
		}

		public static string[] SplitWithoutTrimming(this string str, char c)
		{
			List<string> list = new List<string>();
			int num = 0;
			int length = str.Length;
			for (int i = 0; i < length; i++)
			{
				if (str[i] == c)
				{
					if (i > num)
					{
						list.Add(str.Substring(num, i - num));
					}
					num = i + 1;
				}
			}
			if (length > num)
			{
				list.Add(str.Substring(num, length - num));
			}
			return list.ToArray();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static string[] SplitCommas(this string str)
		{
			return str.SplitWithTrimming(',');
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool HasHyphen(this string str, string value, StringComparison comparison = StringComparison.Ordinal)
		{
			if (!string.Equals(str, value, comparison))
			{
				if (str.Length > value.Length && str.StartsWith(value, comparison))
				{
					return str[value.Length] == '-';
				}
				return false;
			}
			return true;
		}

		public static string[] SplitSpaces(this string str)
		{
			List<string> list = new List<string>();
			char[] array = ArrayPool<char>.Shared.Rent(str.Length);
			int num = 0;
			for (int i = 0; i <= str.Length; i++)
			{
				if (i == str.Length || str[i].IsSpaceCharacter())
				{
					if (num > 0)
					{
						string text = new string(array, 0, num).StripLeadingTrailingSpaces();
						if (text.Length != 0)
						{
							list.Add(text);
						}
						num = 0;
					}
				}
				else
				{
					array[num] = str[i];
					num++;
				}
			}
			ArrayPool<char>.Shared.Return(array);
			return list.ToArray();
		}

		public static string[] SplitWithTrimming(this string str, char ch)
		{
			List<string> list = new List<string>();
			char[] array = ArrayPool<char>.Shared.Rent(str.Length);
			int num = 0;
			for (int i = 0; i <= str.Length; i++)
			{
				if (i == str.Length || str[i] == ch)
				{
					if (num > 0)
					{
						string text = new string(array, 0, num).StripLeadingTrailingSpaces();
						if (text.Length != 0)
						{
							list.Add(text);
						}
						num = 0;
					}
				}
				else
				{
					array[num] = str[i];
					num++;
				}
			}
			ArrayPool<char>.Shared.Return(array);
			return list.ToArray();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromHex(this string s)
		{
			return int.Parse(s, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromDec(this string s)
		{
			return int.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static string HtmlEncode(this string value, Encoding encoding)
		{
			return value;
		}

		public static string CssString(this string value)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			stringBuilder.Append('"');
			if (!string.IsNullOrEmpty(value))
			{
				int length = value.Length;
				for (int i = 0; i < length; i++)
				{
					char c = value[i];
					switch (c)
					{
					case '\0':
						stringBuilder.ReturnToPool();
						throw new DomException(DomError.InvalidCharacter);
					case '"':
					case '\\':
						stringBuilder.Append('\\').Append(c);
						continue;
					}
					if (c.IsInRange(1, 31) || c == '{')
					{
						stringBuilder.Append('\\').Append(c.ToHex()).Append((i + 1 != length) ? " " : "");
					}
					else
					{
						stringBuilder.Append(c);
					}
				}
			}
			stringBuilder.Append('"');
			return stringBuilder.ToPool();
		}

		public static string CssFunction(this string value, string argument)
		{
			return value + "(" + argument + ")";
		}

		public static string UrlEncode(this byte[] content)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			int num = content.Length;
			for (int i = 0; i < num; i++)
			{
				char c = (char)content[i];
				switch (c)
				{
				case ' ':
					stringBuilder.Append('+');
					break;
				default:
					if (!c.IsAlphanumericAscii())
					{
						stringBuilder.Append('%').Append(content[i].ToString("X2"));
						break;
					}
					goto case '*';
				case '*':
				case '-':
				case '.':
				case '_':
				case '~':
					stringBuilder.Append(c);
					break;
				}
			}
			return stringBuilder.ToPool();
		}

		public static byte[] UrlDecode(this string value)
		{
			MemoryStream memoryStream = new MemoryStream();
			int length = value.Length;
			for (int i = 0; i < length; i++)
			{
				char c = value[i];
				switch (c)
				{
				case '+':
				{
					byte value4 = 32;
					memoryStream.WriteByte(value4);
					break;
				}
				case '%':
				{
					if (i + 2 >= length)
					{
						throw new FormatException();
					}
					byte value3 = (byte)(16 * value[++i].FromHex() + value[++i].FromHex());
					memoryStream.WriteByte(value3);
					break;
				}
				default:
				{
					byte value2 = (byte)c;
					memoryStream.WriteByte(value2);
					break;
				}
				}
			}
			return memoryStream.ToArray();
		}

		public static string NormalizeLineEndings(this string value)
		{
			if (!string.IsNullOrEmpty(value))
			{
				StringBuilder stringBuilder = StringBuilderPool.Obtain();
				bool flag = false;
				int length = value.Length;
				for (int i = 0; i < length; i++)
				{
					char c = value[i];
					bool flag2 = c == '\n';
					if (flag && !flag2)
					{
						stringBuilder.Append('\n');
					}
					else if (!flag && flag2)
					{
						stringBuilder.Append('\r');
					}
					flag = c == '\r';
					stringBuilder.Append(c);
				}
				if (flag)
				{
					stringBuilder.Append('\n');
				}
				return stringBuilder.ToPool();
			}
			return value;
		}

		public static string? ToEncodingType(this string? encType)
		{
			if (!encType.Isi(MimeTypeNames.Plain) && !encType.Isi(MimeTypeNames.MultipartForm) && !encType.Isi(MimeTypeNames.ApplicationJson))
			{
				return null;
			}
			return encType?.ToLowerInvariant();
		}

		public static string? ToFormMethod(this string? method)
		{
			if (!method.Isi(FormMethodNames.Get) && !method.Isi(FormMethodNames.Post) && !method.Isi(FormMethodNames.Dialog))
			{
				return null;
			}
			return method?.ToLowerInvariant();
		}
	}
	public sealed class StringSource
	{
		private readonly string _content;

		private readonly int _last;

		private int _index;

		private char _current;

		public char Current => _current;

		public bool IsDone => _current == '\uffff';

		public int Index => _index;

		public string Content => _content;

		public StringSource(string content)
		{
			_content = content ?? string.Empty;
			_last = _content.Length - 1;
			_index = 0;
			_current = ((_last == -1) ? '\uffff' : content[0]);
		}

		public char Next()
		{
			if (_index == _last)
			{
				_current = '\uffff';
				_index = _content.Length;
			}
			else if (_index < _content.Length)
			{
				_current = _content[++_index];
			}
			return _current;
		}

		public char Back()
		{
			if (_index > 0)
			{
				_current = _content[--_index];
			}
			return _current;
		}
	}
	public static class StringSourceExtensions
	{
		public static char SkipSpaces(this StringSource source)
		{
			char c = source.Current;
			while (c.IsSpaceCharacter())
			{
				c = source.Next();
			}
			return c;
		}

		public static char Next(this StringSource source, int n)
		{
			for (int i = 0; i < n; i++)
			{
				source.Next();
			}
			return source.Current;
		}

		public static char Back(this StringSource source, int n)
		{
			for (int i = 0; i < n; i++)
			{
				source.Back();
			}
			return source.Current;
		}

		public static char Peek(this StringSource source)
		{
			char result = source.Next();
			source.Back();
			return result;
		}
	}
	public sealed class StringTextSource : IReadOnlyTextSource, IDisposable
	{
		private readonly string _string;

		private readonly ReadOnlyMemory<char> _memory;

		private readonly int _length;

		private int _index;

		public string Text => _string;

		public char this[int index] => _string[index];

		public int Length => _length;

		public Encoding CurrentEncoding
		{
			get
			{
				return TextEncoding.Utf8;
			}
			set
			{
			}
		}

		public int Index
		{
			get
			{
				return _index;
			}
			set
			{
				_index = value;
			}
		}

		public StringTextSource(string source)
		{
			_string = source;
			_length = source.Length;
			_memory = source.AsMemory();
		}

		public void Dispose()
		{
		}

		public char ReadCharacter()
		{
			if (_index < _length)
			{
				return _string[_index++];
			}
			_index++;
			return '\uffff';
		}

		public string ReadCharacters(int characters)
		{
			return ReadMemory(characters).ToString();
		}

		public StringOrMemory ReadMemory(int characters)
		{
			int index = _index;
			if (index + characters <= _length)
			{
				_index += characters;
				return _memory.Slice(index, characters);
			}
			_index += characters;
			characters = Math.Min(characters, _length - index);
			return _memory.Slice(index, characters);
		}

		public Task PrefetchAsync(int length, CancellationToken cancellationToken)
		{
			return Task.CompletedTask;
		}

		public Task PrefetchAllAsync(CancellationToken cancellationToken)
		{
			return Task.CompletedTask;
		}

		public bool TryGetContentLength(out int length)
		{
			length = _length;
			return true;
		}
	}
	public static class Symbols
	{
		public const char EndOfFile = '\uffff';

		public const char Tilde = '~';

		public const char Pipe = '|';

		public const char Null = '\0';

		public const char Ampersand = '&';

		public const char Num = '#';

		public const char Dollar = '$';

		public const char Semicolon = ';';

		public const char Asterisk = '*';

		public const char Equality = '=';

		public const char Plus = '+';

		public const char Minus = '-';

		public const char Comma = ',';

		public const char Dot = '.';

		public const char Accent = '^';

		public const char At = '@';

		public const char LessThan = '<';

		public const char GreaterThan = '>';

		public const char SingleQuote = '\'';

		public const char DoubleQuote = '"';

		public const char CurvedQuote = '`';

		public const char QuestionMark = '?';

		public const char Tab = '\t';

		public const char LineFeed = '\n';

		public const char CarriageReturn = '\r';

		public const char FormFeed = '\f';

		public const char Space = ' ';

		public const char Solidus = '/';

		public const char NoBreakSpace = '\u00a0';

		public const char ReverseSolidus = '\\';

		public const char Colon = ':';

		public const char ExclamationMark = '!';

		public const char Replacement = '\ufffd';

		public const char Underscore = '_';

		public const char RoundBracketOpen = '(';

		public const char RoundBracketClose = ')';

		public const char SquareBracketOpen = '[';

		public const char SquareBracketClose = ']';

		public const char CurlyBracketOpen = '{';

		public const char CurlyBracketClose = '}';

		public const char Percent = '%';

		public const int MaximumCodepoint = 1114111;
	}
	public static class TextEncoding
	{
		public static readonly Encoding Utf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

		public static readonly Encoding Utf16Be = new UnicodeEncoding(bigEndian: true, byteOrderMark: false);

		public static readonly Encoding Utf16Le = new UnicodeEncoding(bigEndian: false, byteOrderMark: false);

		public static readonly Encoding Utf32Le = GetEncoding("UTF-32LE");

		public static readonly Encoding Utf32Be = GetEncoding("UTF-32BE");

		public static readonly Encoding Gb18030 = GetEncoding("GB18030");

		public static readonly Encoding Big5 = GetEncoding("big5");

		public static readonly Encoding Windows874 = GetEncoding("windows-874");

		public static readonly Encoding Windows1250 = GetEncoding("windows-1250");

		public static readonly Encoding Windows1251 = GetEncoding("windows-1251");

		public static readonly Encoding Windows1252 = GetEncoding("windows-1252");

		public static readonly Encoding Windows1253 = GetEncoding("windows-1253");

		public static readonly Encoding Windows1254 = GetEncoding("windows-1254");

		public static readonly Encoding Windows1255 = GetEncoding("windows-1255");

		public static readonly Encoding Windows1256 = GetEncoding("windows-1256");

		public static readonly Encoding Windows1257 = GetEncoding("windows-1257");

		public static readonly Encoding Windows1258 = GetEncoding("windows-1258");

		public static readonly Encoding Latin2 = GetEncoding("iso-8859-2");

		public static readonly Encoding Latin3 = GetEncoding("iso-8859-3");

		public static readonly Encoding Latin4 = GetEncoding("iso-8859-4");

		public static readonly Encoding Latin5 = GetEncoding("iso-8859-5");

		public static readonly Encoding Latin13 = GetEncoding("iso-8859-13");

		public static readonly Encoding UsAscii = GetEncoding("us-ascii");

		public static readonly Encoding Korean = GetEncoding("ks_c_5601-1987");

		private static readonly Dictionary<string, Encoding> encodings = CreateEncodings();

		public static bool IsUnicode(this Encoding encoding)
		{
			if (encoding != Utf16Be)
			{
				return encoding == Utf16Le;
			}
			return true;
		}

		public static Encoding? Parse(string content)
		{
			string charset = string.Empty;
			int num = 0;
			for (int i = num; i < content.Length - 7; i++)
			{
				if (content.Substring(i).StartsWith(AttributeNames.Charset, StringComparison.OrdinalIgnoreCase))
				{
					num = i + 7;
					break;
				}
			}
			if (num > 0 && num < content.Length)
			{
				for (int j = num; j < content.Length - 1 && content[j].IsSpaceCharacter(); j++)
				{
					num++;
				}
				if (content[num] != '=')
				{
					return Parse(content.Substring(num));
				}
				num++;
				for (int k = num; k < content.Length && content[k].IsSpaceCharacter(); k++)
				{
					num++;
				}
				if (num < content.Length)
				{
					if (content[num] == '"')
					{
						content = content.Substring(num + 1);
						int num2 = content.IndexOf('"');
						if (num2 != -1)
						{
							charset = content.Substring(0, num2);
						}
					}
					else if (content[num] == '\'')
					{
						content = content.Substring(num + 1);
						int num3 = content.IndexOf('\'');
						if (num3 != -1)
						{
							charset = content.Substring(0, num3);
						}
					}
					else
					{
						content = content.Substring(num);
						int num4 = 0;
						for (int l = 0; l < content.Length && !content[l].IsSpaceCharacter() && content[l] != ';'; l++)
						{
							num4++;
						}
						charset = content.Substring(0, num4);
					}
				}
			}
			if (!IsSupported(charset))
			{
				return null;
			}
			return Resolve(charset);
		}

		public static bool IsSupported(string charset)
		{
			return encodings.ContainsKey(charset);
		}

		public static Encoding Resolve(string? charset)
		{
			if (charset != null && encodings.TryGetValue(charset, out Encoding value))
			{
				return value;
			}
			return Utf8;
		}

		private static Encoding GetEncoding(string name, Encoding? fallback = null)
		{
			try
			{
				return Encoding.GetEncoding(name);
			}
			catch (Exception)
			{
				return fallback ?? Utf8;
			}
		}

		private static Dictionary<string, Encoding> CreateEncodings()
		{
			Dictionary<string, Encoding> obj = new Dictionary<string, Encoding>(StringComparer.OrdinalIgnoreCase)
			{
				{ "unicode-1-1-utf-8", Utf8 },
				{ "utf-8", Utf8 },
				{ "utf8", Utf8 },
				{ "utf-16be", Utf16Be },
				{ "utf-16", Utf16Le },
				{ "utf-16le", Utf16Le },
				{ "dos-874", Windows874 },
				{ "iso-8859-11", Windows874 },
				{ "iso8859-11", Windows874 },
				{ "iso885911", Windows874 },
				{ "tis-620", Windows874 },
				{ "windows-874", Windows874 },
				{ "cp1250", Windows1250 },
				{ "windows-1250", Windows1250 },
				{ "x-cp1250", Windows1250 },
				{ "cp1251", Windows1251 },
				{ "windows-1251", Windows1251 },
				{ "x-cp1251", Windows1251 },
				{ "x-user-defined", Windows1252 },
				{ "ansi_x3.4-1968", Windows1252 },
				{ "ascii", Windows1252 },
				{ "cp1252", Windows1252 },
				{ "cp819", Windows1252 },
				{ "csisolatin1", Windows1252 },
				{ "ibm819", Windows1252 },
				{ "iso-8859-1", Windows1252 },
				{ "iso-ir-100", Windows1252 },
				{ "iso8859-1", Windows1252 },
				{ "iso88591", Windows1252 },
				{ "iso_8859-1", Windows1252 },
				{ "iso_8859-1:1987", Windows1252 },
				{ "l1", Windows1252 },
				{ "latin1", Windows1252 },
				{ "us-ascii", Windows1252 },
				{ "windows-1252", Windows1252 },
				{ "x-cp1252", Windows1252 },
				{ "cp1253", Windows1253 },
				{ "windows-1253", Windows1253 },
				{ "x-cp1253", Windows1253 },
				{ "cp1254", Windows1254 },
				{ "csisolatin5", Windows1254 },
				{ "iso-8859-9", Windows1254 },
				{ "iso-ir-148", Windows1254 },
				{ "iso8859-9", Windows1254 },
				{ "iso88599", Windows1254 },
				{ "iso_8859-9", Windows1254 },
				{ "iso_8859-9:1989", Windows1254 },
				{ "l5", Windows1254 },
				{ "latin5", Windows1254 },
				{ "windows-1254", Windows1254 },
				{ "x-cp1254", Windows1254 },
				{ "cp1255", Windows1255 },
				{ "windows-1255", Windows1255 },
				{ "x-cp1255", Windows1255 },
				{ "cp1256", Windows1256 },
				{ "windows-1256", Windows1256 },
				{ "x-cp1256", Windows1256 },
				{ "cp1257", Windows1257 },
				{ "windows-1257", Windows1257 },
				{ "x-cp1257", Windows1257 },
				{ "cp1258", Windows1258 },
				{ "windows-1258", Windows1258 },
				{ "x-cp1258", Windows1258 }
			};
			Encoding encoding = GetEncoding("macintosh");
			obj.Add("csmacintosh", encoding);
			obj.Add("mac", encoding);
			obj.Add("macintosh", encoding);
			obj.Add("x-mac-roman", encoding);
			Encoding encoding2 = GetEncoding("x-mac-cyrillic");
			obj.Add("x-mac-cyrillic", encoding2);
			obj.Add("x-mac-ukrainian", encoding2);
			Encoding encoding3 = GetEncoding("cp866");
			obj.Add("866", encoding3);
			obj.Add("cp866", encoding3);
			obj.Add("csibm866", encoding3);
			obj.Add("ibm866", encoding3);
			obj.Add("csisolatin2", Latin2);
			obj.Add("iso-8859-2", Latin2);
			obj.Add("iso-ir-101", Latin2);
			obj.Add("iso8859-2", Latin2);
			obj.Add("iso88592", Latin2);
			obj.Add("iso_8859-2", Latin2);
			obj.Add("iso_8859-2:1987", Latin2);
			obj.Add("l2", Latin2);
			obj.Add("latin2", Latin2);
			obj.Add("csisolatin3", Latin3);
			obj.Add("iso-8859-3", Latin3);
			obj.Add("iso-ir-109", Latin3);
			obj.Add("iso8859-3", Latin3);
			obj.Add("iso88593", Latin3);
			obj.Add("iso_8859-3", Latin3);
			obj.Add("iso_8859-3:1988", Latin3);
			obj.Add("l3", Latin3);
			obj.Add("latin3", Latin3);
			obj.Add("csisolatin4", Latin4);
			obj.Add("iso-8859-4", Latin4);
			obj.Add("iso-ir-110", Latin4);
			obj.Add("iso8859-4", Latin4);
			obj.Add("iso88594", Latin4);
			obj.Add("iso_8859-4", Latin4);
			obj.Add("iso_8859-4:1988", Latin4);
			obj.Add("l4", Latin4);
			obj.Add("latin4", Latin4);
			obj.Add("csisolatincyrillic", Latin5);
			obj.Add("cyrillic", Latin5);
			obj.Add("iso-8859-5", Latin5);
			obj.Add("iso-ir-144", Latin5);
			obj.Add("iso8859-5", Latin5);
			obj.Add("iso88595", Latin5);
			obj.Add("iso_8859-5", Latin5);
			obj.Add("iso_8859-5:1988", Latin5);
			Encoding encoding4 = GetEncoding("iso-8859-6");
			obj.Add("arabic", encoding4);
			obj.Add("asmo-708", encoding4);
			obj.Add("csiso88596e", encoding4);
			obj.Add("csiso88596i", encoding4);
			obj.Add("csisolatinarabic", encoding4);
			obj.Add("ecma-114", encoding4);
			obj.Add("iso-8859-6", encoding4);
			obj.Add("iso-8859-6-e", encoding4);
			obj.Add("iso-8859-6-i", encoding4);
			obj.Add("iso-ir-127", encoding4);
			obj.Add("iso8859-6", encoding4);
			obj.Add("iso88596", encoding4);
			obj.Add("iso_8859-6", encoding4);
			obj.Add("iso_8859-6:1987", encoding4);
			Encoding encoding5 = GetEncoding("iso-8859-7");
			obj.Add("csisolatingreek", encoding5);
			obj.Add("ecma-118", encoding5);
			obj.Add("elot_928", encoding5);
			obj.Add("greek", encoding5);
			obj.Add("greek8", encoding5);
			obj.Add("iso-8859-7", encoding5);
			obj.Add("iso-ir-126", encoding5);
			obj.Add("iso8859-7", encoding5);
			obj.Add("iso88597", encoding5);
			obj.Add("iso_8859-7", encoding5);
			obj.Add("iso_8859-7:1987", encoding5);
			obj.Add("sun_eu_greek", encoding5);
			Encoding encoding6 = GetEncoding("iso-8859-8");
			obj.Add("csiso88598e", encoding6);
			obj.Add("csisolatinhebrew", encoding6);
			obj.Add("hebrew", encoding6);
			obj.Add("iso-8859-8", encoding6);
			obj.Add("iso-8859-8-e", encoding6);
			obj.Add("iso-ir-138", encoding6);
			obj.Add("iso8859-8", encoding6);
			obj.Add("iso88598", encoding6);
			obj.Add("iso_8859-8", encoding6);
			obj.Add("iso_8859-8:1988", encoding6);
			obj.Add("visual", encoding6);
			Encoding encoding7 = GetEncoding("iso-8859-8-i");
			obj.Add("csiso88598i", encoding7);
			obj.Add("iso-8859-8-i", encoding7);
			obj.Add("logical", encoding7);
			Encoding encoding8 = GetEncoding("iso-8859-13");
			obj.Add("iso-8859-13", encoding8);
			obj.Add("iso8859-13", encoding8);
			obj.Add("iso885913", encoding8);
			Encoding encoding9 = GetEncoding("iso-8859-15");
			obj.Add("csisolatin9", encoding9);
			obj.Add("iso-8859-15", encoding9);
			obj.Add("iso8859-15", encoding9);
			obj.Add("iso885915", encoding9);
			obj.Add("iso_8859-15", encoding9);
			obj.Add("l9", encoding9);
			Encoding encoding10 = GetEncoding("koi8-r");
			obj.Add("cskoi8r", encoding10);
			obj.Add("koi", encoding10);
			obj.Add("koi8", encoding10);
			obj.Add("koi8-r", encoding10);
			obj.Add("koi8_r", encoding10);
			obj.Add("koi8-u", GetEncoding("koi8-u"));
			Encoding encoding11 = GetEncoding("GB18030", GetEncoding("x-cp20936"));
			obj.Add("chinese", encoding11);
			obj.Add("csgb2312", encoding11);
			obj.Add("csiso58gb231280", encoding11);
			obj.Add("gb2312", encoding11);
			obj.Add("gb_2312", encoding11);
			obj.Add("gb_2312-80", encoding11);
			obj.Add("gbk", encoding11);
			obj.Add("iso-ir-58", encoding11);
			obj.Add("x-gbk", encoding11);
			obj.Add("hz-gb-2312", GetEncoding("hz-gb-2312"));
			obj.Add("gb18030", Gb18030);
			Encoding encoding12 = GetEncoding("x-cp50227");
			obj.Add("x-cp50227", encoding12);
			obj.Add("iso-22-cn", encoding12);
			obj.Add("big5", Big5);
			obj.Add("big5-hkscs", Big5);
			obj.Add("cn-big5", Big5);
			obj.Add("csbig5", Big5);
			obj.Add("x-x-big5", Big5);
			Encoding encoding13 = GetEncoding("iso-2022-jp");
			obj.Add("csiso2022jp", encoding13);
			obj.Add("iso-2022-jp", encoding13);
			Encoding encoding14 = GetEncoding("iso-2022-kr");
			obj.Add("csiso2022kr", encoding14);
			obj.Add("iso-2022-kr", encoding14);
			Encoding encoding15 = GetEncoding("iso-2022-cn");
			obj.Add("iso-2022-cn", encoding15);
			obj.Add("iso-2022-cn-ext", encoding15);
			obj.Add("shift_jis", GetEncoding("shift_jis"));
			Encoding encoding16 = GetEncoding("euc-jp");
			obj.Add("euc-jp", encoding16);
			Encoding encoding17 = GetEncoding("euc-kr");
			obj.Add("euc-kr", encoding17);
			return obj;
		}
	}
	public readonly struct TextPosition : IEquatable<TextPosition>, IComparable<TextPosition>
	{
		public static readonly TextPosition Empty;

		private readonly ushort _line;

		private readonly ushort _column;

		private readonly int _position;

		public int Line => _line;

		public int Column => _column;

		public int Position => _position;

		public int Index => _position - 1;

		public TextPosition(ushort line, ushort column, int position)
		{
			_line = line;
			_column = column;
			_position = position;
		}

		public TextPosition Shift(int columns)
		{
			return new TextPosition(_line, (ushort)(_column + columns), _position + columns);
		}

		public TextPosition After(char chr)
		{
			ushort num = _line;
			ushort num2 = _column;
			if (chr == '\n')
			{
				num++;
				num2 = 0;
			}
			return new TextPosition(num, ++num2, _position + 1);
		}

		public TextPosition After(string str)
		{
			ushort num = _line;
			ushort num2 = _column;
			for (int i = 0; i < str.Length; i++)
			{
				if (str[i] == '\n')
				{
					num++;
					num2 = 0;
				}
				num2++;
			}
			return new TextPosition(num, num2, _position + str.Length);
		}

		public override string ToString()
		{
			return $"Ln {_line}, Col {_column}, Pos {_position}";
		}

		public override int GetHashCode()
		{
			return _position ^ ((_line | _column) + _line);
		}

		public override bool Equals(object? obj)
		{
			if (obj is TextPosition other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(TextPosition other)
		{
			if (_position == other._position && _column == other._column)
			{
				return _line == other._line;
			}
			return false;
		}

		public static bool operator >(TextPosition a, TextPosition b)
		{
			return a._position > b._position;
		}

		public static bool operator <(TextPosition a, TextPosition b)
		{
			return a._position < b._position;
		}

		public int CompareTo(TextPosition other)
		{
			if (!Equals(other))
			{
				if (!(this > other))
				{
					return -1;
				}
				return 1;
			}
			return 0;
		}
	}
	[DebuggerStepThrough]
	public readonly struct TextRange : IEquatable<TextRange>, IComparable<TextRange>
	{
		private readonly TextPosition _start;

		private readonly TextPosition _end;

		public TextPosition Start => _start;

		public TextPosition End => _end;

		public TextRange(TextPosition start, TextPosition end)
		{
			_start = start;
			_end = end;
		}

		public override string ToString()
		{
			return $"({_start}) -- ({_end})";
		}

		public override int GetHashCode()
		{
			return _end.GetHashCode() ^ _start.GetHashCode();
		}

		public override bool Equals(object? obj)
		{
			if (obj is TextRange other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(TextRange other)
		{
			if (_start.Equals(other._start))
			{
				return _end.Equals(other._end);
			}
			return false;
		}

		public static bool operator >(TextRange a, TextRange b)
		{
			return a._start > b._end;
		}

		public static bool operator <(TextRange a, TextRange b)
		{
			return a._end < b._start;
		}

		public int CompareTo(TextRange other)
		{
			if (this > other)
			{
				return 1;
			}
			if (other > this)
			{
				return -1;
			}
			return 0;
		}
	}
	public sealed class TextSource : ITextSource, IReadOnlyTextSource, IDisposable
	{
		private readonly WritableTextSource _writableSource;

		private readonly IReadOnlyTextSource _readOnlyTextSource;

		public string Text => _readOnlyTextSource.Text;

		public int Length => _readOnlyTextSource.Length;

		public Encoding CurrentEncoding
		{
			get
			{
				return _readOnlyTextSource.CurrentEncoding;
			}
			set
			{
				if (_writableSource != null)
				{
					_writableSource.CurrentEncoding = value;
				}
			}
		}

		public int Index
		{
			get
			{
				return _readOnlyTextSource.Index;
			}
			set
			{
				_readOnlyTextSource.Index = value;
			}
		}

		public char this[int index] => _readOnlyTextSource[index];

		public TextSource(string source)
		{
			_writableSource = new WritableTextSource(source);
			_readOnlyTextSource = _writableSource;
		}

		public TextSource(Stream baseStream, Encoding encoding = null)
		{
			_writableSource = new WritableTextSource(baseStream, encoding);
			_readOnlyTextSource = _writableSource;
		}

		public TextSource(ReadOnlyMemoryTextSource source)
		{
			_writableSource = null;
			_readOnlyTextSource = source;
		}

		public TextSource(CharArrayTextSource source)
		{
			_writableSource = null;
			_readOnlyTextSource = source;
		}

		public TextSource(StringTextSource source)
		{
			_writableSource = null;
			_readOnlyTextSource = source;
		}

		public char ReadCharacter()
		{
			return _readOnlyTextSource.ReadCharacter();
		}

		public string ReadCharacters(int characters)
		{
			return _readOnlyTextSource.ReadCharacters(characters);
		}

		public StringOrMemory ReadMemory(int characters)
		{
			return _readOnlyTextSource.ReadMemory(characters);
		}

		public Task PrefetchAsync(int length, CancellationToken cancellationToken)
		{
			return _readOnlyTextSource.PrefetchAsync(length, cancellationToken);
		}

		public Task PrefetchAllAsync(CancellationToken cancellationToken)
		{
			return _readOnlyTextSource.PrefetchAllAsync(cancellationToken);
		}

		public bool TryGetContentLength(out int length)
		{
			return _readOnlyTextSource.TryGetContentLength(out length);
		}

		public void InsertText(string content)
		{
			if (_writableSource == null)
			{
				throw new InvalidOperationException("Cannot insert text into a read-only text source.");
			}
			_writableSource.InsertText(content);
		}

		public void Dispose()
		{
			_readOnlyTextSource.Dispose();
		}

		public IReadOnlyTextSource GetUnderlyingTextSource()
		{
			return _readOnlyTextSource;
		}
	}
	public class TextView
	{
		private readonly TextSource _source;

		private readonly TextRange _range;

		public TextRange Range => _range;

		public string Text
		{
			get
			{
				int num = Math.Max(_range.Start.Position - 1, 0);
				int num2 = _range.End.Position + 1 - _range.Start.Position;
				string text = _source.Text;
				if (num + num2 > text.Length)
				{
					num2 = text.Length - num;
				}
				return text.Substring(num, num2);
			}
		}

		public TextView(TextSource source, TextRange range)
		{
			_source = source;
			_range = range;
		}
	}
	internal sealed class WritableTextSource : ITextSource, IReadOnlyTextSource, IDisposable
	{
		private enum EncodingConfidence : byte
		{
			Tentative,
			Certain,
			Irrelevant
		}

		private const int BufferSize = 4096;

		private readonly Stream _baseStream;

		private readonly MemoryStream _raw;

		private readonly byte[] _buffer;

		private readonly char[] _chars;

		private StringBuilder _content;

		private EncodingConfidence _confidence;

		private bool _finished;

		private Encoding _encoding;

		private Decoder _decoder;

		private int _index;

		[MemberNotNull("_content")]
		public string Text
		{
			[MemberNotNull("_content")]
			get
			{
				return _content.ToString();
			}
		}

		public char this[int index] => Replace(_content[index]);

		public int Length => _content.Length;

		public Encoding CurrentEncoding
		{
			get
			{
				return _encoding;
			}
			set
			{
				if (_confidence != EncodingConfidence.Tentative)
				{
					return;
				}
				if (_encoding.IsUnicode())
				{
					_confidence = EncodingConfidence.Certain;
					return;
				}
				if (value.IsUnicode())
				{
					value = TextEncoding.Utf8;
				}
				if (value == _encoding)
				{
					_confidence = EncodingConfidence.Certain;
					return;
				}
				_encoding = value;
				_decoder = value.GetDecoder();
				byte[] array = _raw.ToArray();
				char[] array2 = new char[_encoding.GetMaxCharCount(array.Length)];
				int chars = _decoder.GetChars(array, 0, array.Length, array2, 0);
				string text = new string(array2, 0, chars);
				int num = Math.Min(_index, text.Length);
				if (text.Substring(0, num).Is(_content.ToString(0, num)))
				{
					_confidence = EncodingConfidence.Certain;
					_content.Remove(num, _content.Length - num);
					_content.Append(text.Substring(num));
					return;
				}
				_index = 0;
				_content.Clear().Append(text);
				throw new NotSupportedException();
			}
		}

		public int Index
		{
			get
			{
				return _index;
			}
			set
			{
				_index = value;
			}
		}

		private WritableTextSource(Encoding encoding, bool allocateBuffers)
		{
			if (allocateBuffers)
			{
				_buffer = new byte[4096];
				_chars = new char[4097];
			}
			_raw = new MemoryStream();
			_index = 0;
			_encoding = encoding ?? TextEncoding.Utf8;
			_decoder = _encoding.GetDecoder();
		}

		public WritableTextSource(string source)
			: this(null, TextEncoding.Utf8)
		{
			_finished = true;
			_content.Append(source);
			_confidence = EncodingConfidence.Irrelevant;
		}

		public WritableTextSource(Stream baseStream, Encoding encoding = null)
			: this(encoding, baseStream != null)
		{
			_baseStream = baseStream;
			_content = StringBuilderPool.Obtain();
			_confidence = EncodingConfidence.Tentative;
		}

		public void Dispose()
		{
			if (_content != null)
			{
				_raw.Dispose();
				_content.Clear().ReturnToPool();
				_content = null;
			}
		}

		public char ReadCharacter()
		{
			if (_index < _content.Length)
			{
				return Replace(_content[_index++]);
			}
			ExpandBuffer(4096L);
			int num = _index++;
			if (num >= _content.Length)
			{
				return '\uffff';
			}
			return Replace(_content[num]);
		}

		public string ReadCharacters(int characters)
		{
			int index = _index;
			if (index + characters <= _content.Length)
			{
				_index += characters;
				return _content.ToString(index, characters);
			}
			ExpandBuffer(Math.Max(4096, characters));
			_index += characters;
			characters = Math.Min(characters, _content.Length - index);
			return _content.ToString(index, characters);
		}

		public StringOrMemory ReadMemory(int characters)
		{
			return new StringOrMemory(ReadCharacters(characters));
		}

		public Task PrefetchAsync(int length, CancellationToken cancellationToken)
		{
			return ExpandBufferAsync(length, cancellationToken);
		}

		public async Task PrefetchAllAsync(CancellationToken cancellationToken)
		{
			if (_baseStream != null && _content.Length == 0)
			{
				await DetectByteOrderMarkAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			while (!_finished)
			{
				await ReadIntoBufferAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		public bool TryGetContentLength(out int length)
		{
			length = 0;
			return false;
		}

		public void InsertText(string content)
		{
			if (_index >= 0 && _index < _content.Length)
			{
				_content.Insert(_index, content);
			}
			else
			{
				_content.Append(content);
			}
			_index += content.Length;
		}

		private static char Replace(char c)
		{
			if (c != '\uffff')
			{
				return c;
			}
			return '\ufffd';
		}

		private async Task DetectByteOrderMarkAsync(CancellationToken cancellationToken)
		{
			int num = await _baseStream.ReadAsync(_buffer, 0, 4096).ConfigureAwait(continueOnCapturedContext: false);
			int num2 = 0;
			if (num > 2 && _buffer[0] == 239 && _buffer[1] == 187 && _buffer[2] == 191)
			{
				_encoding = TextEncoding.Utf8;
				num2 = 3;
			}
			else if (num > 3 && _buffer[0] == byte.MaxValue && _buffer[1] == 254 && _buffer[2] == 0 && _buffer[3] == 0)
			{
				_encoding = TextEncoding.Utf32Le;
				num2 = 4;
			}
			else if (num > 3 && _buffer[0] == 0 && _buffer[1] == 0 && _buffer[2] == 254 && _buffer[3] == byte.MaxValue)
			{
				_encoding = TextEncoding.Utf32Be;
				num2 = 4;
			}
			else if (num > 1 && _buffer[0] == 254 && _buffer[1] == byte.MaxValue)
			{
				_encoding = TextEncoding.Utf16Be;
				num2 = 2;
			}
			else if (num > 1 && _buffer[0] == byte.MaxValue && _buffer[1] == 254)
			{
				_encoding = TextEncoding.Utf16Le;
				num2 = 2;
			}
			else if (num > 3 && _buffer[0] == 132 && _buffer[1] == 49 && _buffer[2] == 149 && _buffer[3] == 51)
			{
				_encoding = TextEncoding.Gb18030;
				num2 = 4;
			}
			if (num2 > 0)
			{
				num -= num2;
				Array.Copy(_buffer, num2, _buffer, 0, num);
				_decoder = _encoding.GetDecoder();
				_confidence = EncodingConfidence.Certain;
			}
			AppendContentFromBuffer(num);
		}

		private async Task ExpandBufferAsync(long size, CancellationToken cancellationToken)
		{
			if (!_finished && _content.Length == 0)
			{
				await DetectByteOrderMarkAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			while (!_finished && size + _index > _content.Length)
			{
				await ReadIntoBufferAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		private async Task ReadIntoBufferAsync(CancellationToken cancellationToken)
		{
			AppendContentFromBuffer(await _baseStream.ReadAsync(_buffer, 0, 4096, cancellationToken).ConfigureAwait(continueOnCapturedContext: false));
		}

		private void ExpandBuffer(long size)
		{
			if (!_finished && _content.Length == 0)
			{
				DetectByteOrderMarkAsync(CancellationToken.None).Wait();
			}
			while (!_finished && size + _index > _content.Length)
			{
				ReadIntoBuffer();
			}
		}

		private void ReadIntoBuffer()
		{
			int size = _baseStream.Read(_buffer, 0, 4096);
			AppendContentFromBuffer(size);
		}

		private void AppendContentFromBuffer(int size)
		{
			_finished = size == 0;
			int chars = _decoder.GetChars(_buffer, 0, size, _chars, 0);
			if (_confidence != EncodingConfidence.Certain)
			{
				_raw.Write(_buffer, 0, size);
			}
			_content.Append(_chars, 0, chars);
		}
	}
	public static class XmlExtensions
	{
		public static bool IsPubidChar(this char c)
		{
			if (!c.IsAlphanumericAscii() && c != '-' && c != '\'' && c != '+' && c != ',' && c != '.' && c != '/' && c != ':' && c != '?' && c != '=' && c != '!' && c != '*' && c != '#' && c != '@' && c != '$' && c != '_' && c != '(' && c != ')' && c != ';' && c != '%')
			{
				return c.IsSpaceCharacter();
			}
			return true;
		}

		public static bool IsXmlNameStart(this char c)
		{
			if (!c.IsLetter() && c != ':' && c != '_' && !c.IsInRange(192, 214) && !c.IsInRange(216, 246) && !c.IsInRange(248, 767) && !c.IsInRange(880, 893) && !c.IsInRange(895, 8191) && !c.IsInRange(8204, 8205) && !c.IsInRange(8304, 8591) && !c.IsInRange(11264, 12271) && !c.IsInRange(12289, 55295) && !c.IsInRange(63744, 64975) && !c.IsInRange(65008, 65533))
			{
				return c.IsInRange(65536, 983039);
			}
			return true;
		}

		public static bool IsXmlName(this char c)
		{
			if (!c.IsXmlNameStart() && !c.IsDigit() && c != '-' && c != '.' && c != '·' && !c.IsInRange(768, 879))
			{
				return c.IsInRange(8255, 8256);
			}
			return true;
		}

		public static bool IsXmlName(this string str)
		{
			return new StringOrMemory(str).IsXmlName();
		}

		public static bool IsXmlName(this StringOrMemory str)
		{
			if (str.Length > 0 && str[0].IsXmlNameStart())
			{
				for (int i = 1; i < str.Length; i++)
				{
					if (!str[i].IsXmlName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		public static bool IsQualifiedName(this string str)
		{
			return new StringOrMemory(str).IsQualifiedName();
		}

		public static bool IsQualifiedName(this StringOrMemory str)
		{
			int num = str.Memory.Span.IndexOf(':');
			if (num == -1)
			{
				return str.IsXmlName();
			}
			if (num > 0 && str[0].IsXmlNameStart())
			{
				for (int i = 1; i < num; i++)
				{
					if (!str[i].IsXmlName())
					{
						return false;
					}
				}
				num++;
			}
			if (str.Length > num && str[num++].IsXmlNameStart())
			{
				for (int j = num; j < str.Length; j++)
				{
					if (str[j] == ':' || !str[j].IsXmlName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		public static bool IsXmlChar(this char chr)
		{
			if (chr != '\t' && chr != '\n' && chr != '\r' && (chr < ' ' || chr > '\ud7ff'))
			{
				if (chr >= '\ue000')
				{
					return chr <= '\ufffd';
				}
				return false;
			}
			return true;
		}

		public static bool IsValidAsCharRef(this int chr)
		{
			if (chr != 9 && chr != 10 && chr != 13 && (chr < 32 || chr > 55295) && (chr < 57344 || chr > 65533))
			{
				if (chr >= 65536)
				{
					return chr <= 1114111;
				}
				return false;
			}
			return true;
		}
	}
}
namespace AngleSharp.Svg
{
	internal sealed class SvgElementFactory : IElementFactory<Document, SvgElement>
	{
		private delegate SvgElement Creator(Document owner, string? prefix);

		private readonly Dictionary<string, Creator> creators = new Dictionary<string, Creator>(StringComparer.OrdinalIgnoreCase)
		{
			{
				TagNames.Svg,
				(Document document, string? prefix) => new SvgSvgElement(document, prefix)
			},
			{
				TagNames.Circle,
				(Document document, string? prefix) => new SvgCircleElement(document, prefix)
			},
			{
				TagNames.Desc,
				(Document document, string? prefix) => new SvgDescElement(document, prefix)
			},
			{
				TagNames.ForeignObject,
				(Document document, string? prefix) => new SvgForeignObjectElement(document, prefix)
			},
			{
				TagNames.Title,
				(Document document, string? prefix) => new SvgTitleElement(document, prefix)
			}
		};

		internal static readonly SvgElementFactory Instance = new SvgElementFactory();

		public SvgElement Create(Document document, string localName, string? prefix = null, NodeFlags flags = NodeFlags.None)
		{
			if (creators.TryGetValue(localName, out Creator value))
			{
				return value(document, prefix);
			}
			return new SvgElement(document, localName, prefix, flags);
		}
	}
}
namespace AngleSharp.Svg.Dom
{
	internal sealed class SvgCircleElement : SvgElement, ISvgCircleElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgCircleElement(Document owner, string? prefix = null)
			: base(owner, TagNames.Circle, prefix)
		{
		}
	}
	internal sealed class SvgDescElement : SvgElement, ISvgDescriptionElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgDescElement(Document owner, string? prefix = null)
			: base(owner, TagNames.Desc, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTip)
		{
		}
	}
	public class SvgElement : Element, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IConstructableSvgElement, IConstructableElement, IConstructableNode
	{
		public SvgElement(Document owner, string name, string? prefix = null, NodeFlags flags = NodeFlags.None)
			: base(owner, name, prefix, NamespaceNames.SvgUri, flags | NodeFlags.SvgMember)
		{
		}

		public override IElement ParseSubtree(string html)
		{
			return this.ParseHtmlSubtree(html);
		}

		public override Node Clone(Document owner, bool deep)
		{
			SvgElement svgElement = base.Context.GetFactory<IElementFactory<Document, SvgElement>>().Create(owner, base.LocalName, base.Prefix);
			CloneElement(svgElement, owner, deep);
			return svgElement;
		}
	}
	internal sealed class SvgForeignObjectElement : SvgElement, ISvgForeignObjectElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgForeignObjectElement(Document owner, string? prefix = null)
			: base(owner, TagNames.ForeignObject, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTip)
		{
		}
	}
	internal sealed class SvgSvgElement : SvgElement, ISvgSvgElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildN