Decompiled source of LethalStreams v1.0.2

lethalstreams-lib/System.Reactive.dll

Decompiled 2 months ago
#define TRACE
using System;
using System.CodeDom.Compiler;
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.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Joins;
using System.Reactive.Linq;
using System.Reactive.Linq.ObservableImpl;
using System.Reactive.PlatformServices;
using System.Reactive.Subjects;
using System.Reactive.Threading.Tasks;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Runtime.Versioning;
using System.Security;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("5.0.0.1")]
[assembly: AssemblyInformationalVersion("5.0.0+103c252a0e")]
[assembly: InternalsVisibleTo("Tests.System.Reactive, PublicKey=00240000048000009400000006020000002400005253413100040000010001008f5cff058631087031f8350f30a36fa078027e5df2316b564352dc9eb7af7ce856016d3c5e9d058036fe73bb5c83987bd3fc0793fbe25d633cc4f37c2bd5f1d717cd2a81661bec08f0971dc6078e17bde372b89005e7738a0ebd501b896ca3e8315270ff64df7809dd912c372df61785a5085b3553b7872e39b1b1cc0ff5a6bc")]
[assembly: InternalsVisibleTo("Tests.System.Reactive.Uwp.DeviceRunner, PublicKey=00240000048000009400000006020000002400005253413100040000010001008f5cff058631087031f8350f30a36fa078027e5df2316b564352dc9eb7af7ce856016d3c5e9d058036fe73bb5c83987bd3fc0793fbe25d633cc4f37c2bd5f1d717cd2a81661bec08f0971dc6078e17bde372b89005e7738a0ebd501b896ca3e8315270ff64df7809dd912c372df61785a5085b3553b7872e39b1b1cc0ff5a6bc")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyMetadata("CommitHash", "103c252a0ec94eac753f353131ad95cc0be1b390")]
[assembly: AssemblyCompany(".NET Foundation and Contributors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors.")]
[assembly: AssemblyDescription("Reactive Extensions (Rx) for .NET")]
[assembly: AssemblyProduct("System.Reactive (netstandard2.0)")]
[assembly: AssemblyTitle("System.Reactive")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/reactive")]
[assembly: AssemblyVersion("5.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
[GeneratedCode("Nerdbank.GitVersioning.Tasks", "3.3.37.35081")]
[ExcludeFromCodeCoverage]
internal static class ThisAssembly
{
	internal const string AssemblyVersion = "5.0.0.0";

	internal const string AssemblyFileVersion = "5.0.0.1";

	internal const string AssemblyInformationalVersion = "5.0.0+103c252a0e";

	internal const string AssemblyName = "System.Reactive";

	internal const string AssemblyTitle = "System.Reactive";

	internal const string AssemblyConfiguration = "Release";

	internal const string GitCommitId = "103c252a0ec94eac753f353131ad95cc0be1b390";

	internal const string PublicKey = "00240000048000009400000006020000002400005253413100040000010001008f5cff058631087031f8350f30a36fa078027e5df2316b564352dc9eb7af7ce856016d3c5e9d058036fe73bb5c83987bd3fc0793fbe25d633cc4f37c2bd5f1d717cd2a81661bec08f0971dc6078e17bde372b89005e7738a0ebd501b896ca3e8315270ff64df7809dd912c372df61785a5085b3553b7872e39b1b1cc0ff5a6bc";

	internal const string PublicKeyToken = "94bc3704cddfc263";

	internal const bool IsPublicRelease = true;

	internal const bool IsPrerelease = false;

	internal static readonly DateTime GitCommitDate = new DateTime(637406212710000000L, DateTimeKind.Utc);

	internal const string RootNamespace = "System.Reactive";
}
namespace System
{
	public static class ObservableExtensions
	{
		public static IDisposable Subscribe<T>(this IObservable<T> source)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			return source.Subscribe(new AnonymousObserver<T>(Stubs<T>.Ignore, Stubs.Throw, Stubs.Nop));
		}

		public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			return source.Subscribe(new AnonymousObserver<T>(onNext, Stubs.Throw, Stubs.Nop));
		}

		public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onError == null)
			{
				throw new ArgumentNullException("onError");
			}
			return source.Subscribe(new AnonymousObserver<T>(onNext, onError, Stubs.Nop));
		}

		public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onCompleted == null)
			{
				throw new ArgumentNullException("onCompleted");
			}
			return source.Subscribe(new AnonymousObserver<T>(onNext, Stubs.Throw, onCompleted));
		}

		public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onError == null)
			{
				throw new ArgumentNullException("onError");
			}
			if (onCompleted == null)
			{
				throw new ArgumentNullException("onCompleted");
			}
			return source.Subscribe(new AnonymousObserver<T>(onNext, onError, onCompleted));
		}

		public static void Subscribe<T>(this IObservable<T> source, IObserver<T> observer, CancellationToken token)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			source.Subscribe_(observer, token);
		}

		public static void Subscribe<T>(this IObservable<T> source, CancellationToken token)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			source.Subscribe_(new AnonymousObserver<T>(Stubs<T>.Ignore, Stubs.Throw, Stubs.Nop), token);
		}

		public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, CancellationToken token)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			source.Subscribe_(new AnonymousObserver<T>(onNext, Stubs.Throw, Stubs.Nop), token);
		}

		public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, CancellationToken token)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onError == null)
			{
				throw new ArgumentNullException("onError");
			}
			source.Subscribe_(new AnonymousObserver<T>(onNext, onError, Stubs.Nop), token);
		}

		public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted, CancellationToken token)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onCompleted == null)
			{
				throw new ArgumentNullException("onCompleted");
			}
			source.Subscribe_(new AnonymousObserver<T>(onNext, Stubs.Throw, onCompleted), token);
		}

		public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted, CancellationToken token)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onError == null)
			{
				throw new ArgumentNullException("onError");
			}
			if (onCompleted == null)
			{
				throw new ArgumentNullException("onCompleted");
			}
			source.Subscribe_(new AnonymousObserver<T>(onNext, onError, onCompleted), token);
		}

		private static void Subscribe_<T>(this IObservable<T> source, IObserver<T> observer, CancellationToken token)
		{
			if (token.CanBeCanceled)
			{
				if (!token.IsCancellationRequested)
				{
					ISafeObserver<T> safeObserver = SafeObserver<T>.Wrap(observer);
					IDisposable state2 = source.Subscribe(safeObserver);
					safeObserver.SetResource(token.Register(delegate(object state)
					{
						((IDisposable)state).Dispose();
					}, state2));
				}
			}
			else
			{
				source.Subscribe(observer);
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static IDisposable SubscribeSafe<T>(this IObservable<T> source, IObserver<T> observer)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			if (source is ObservableBase<T>)
			{
				return source.Subscribe(observer);
			}
			if (source is IProducer<T> producer)
			{
				return producer.SubscribeRaw(observer, enableSafeguard: false);
			}
			IDisposable result = Disposable.Empty;
			try
			{
				result = source.Subscribe(observer);
			}
			catch (Exception error)
			{
				observer.OnError(error);
			}
			return result;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	public struct TaskObservableMethodBuilder<T>
	{
		internal sealed class TaskObservable : ITaskObservable<T>, IObservable<T>, ITaskObservableAwaiter<T>, INotifyCompletion
		{
			private readonly AsyncSubject<T>? _subject;

			private readonly T? _result;

			private readonly Exception? _exception;

			public bool IsCompleted => _subject?.IsCompleted ?? true;

			public TaskObservable()
			{
				_subject = new AsyncSubject<T>();
			}

			public TaskObservable(T result)
			{
				_result = result;
			}

			public TaskObservable(Exception exception)
			{
				_exception = exception;
			}

			public void SetResult(T result)
			{
				if (IsCompleted)
				{
					throw new InvalidOperationException();
				}
				_subject.OnNext(result);
				_subject.OnCompleted();
			}

			public void SetException(Exception exception)
			{
				if (IsCompleted)
				{
					throw new InvalidOperationException();
				}
				_subject.OnError(exception);
			}

			public IDisposable Subscribe(IObserver<T> observer)
			{
				if (_subject != null)
				{
					return _subject.Subscribe(observer);
				}
				if (_exception != null)
				{
					observer.OnError(_exception);
					return Disposable.Empty;
				}
				observer.OnNext(_result);
				return Disposable.Empty;
			}

			public ITaskObservableAwaiter<T> GetAwaiter()
			{
				return this;
			}

			public T GetResult()
			{
				if (_subject != null)
				{
					return _subject.GetResult();
				}
				_exception?.Throw();
				return _result;
			}

			public void OnCompleted(Action continuation)
			{
				if (_subject != null)
				{
					_subject.OnCompleted(continuation);
				}
				else
				{
					continuation();
				}
			}
		}

		private IAsyncStateMachine _stateMachine;

		private TaskObservable _inner;

		public ITaskObservable<T> Task => _inner ?? (_inner = new TaskObservable());

		public static TaskObservableMethodBuilder<T> Create()
		{
			return default(TaskObservableMethodBuilder<T>);
		}

		public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
		{
			if (stateMachine == null)
			{
				throw new ArgumentNullException("stateMachine");
			}
			stateMachine.MoveNext();
		}

		public void SetStateMachine(IAsyncStateMachine stateMachine)
		{
			if (_stateMachine != null)
			{
				throw new InvalidOperationException();
			}
			_stateMachine = stateMachine ?? throw new ArgumentNullException("stateMachine");
		}

		public void SetResult(T result)
		{
			if (_inner == null)
			{
				_inner = new TaskObservable(result);
			}
			else
			{
				_inner.SetResult(result);
			}
		}

		public void SetException(Exception exception)
		{
			if (exception == null)
			{
				throw new ArgumentNullException("exception");
			}
			if (_inner == null)
			{
				_inner = new TaskObservable(exception);
			}
			else
			{
				_inner.SetException(exception);
			}
		}

		public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			try
			{
				if (_stateMachine == null)
				{
					_ = Task;
					_stateMachine = stateMachine;
					_stateMachine.SetStateMachine(_stateMachine);
				}
				awaiter.OnCompleted(_stateMachine.MoveNext);
			}
			catch (Exception exception)
			{
				Rethrow(exception);
			}
		}

		[SecuritySafeCritical]
		public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			try
			{
				if (_stateMachine == null)
				{
					_ = Task;
					_stateMachine = stateMachine;
					_stateMachine.SetStateMachine(_stateMachine);
				}
				awaiter.UnsafeOnCompleted(_stateMachine.MoveNext);
			}
			catch (Exception exception)
			{
				Rethrow(exception);
			}
		}

		private static void Rethrow(Exception exception)
		{
			Scheduler.Default.Schedule(exception, delegate(Exception ex, Action<Exception> recurse)
			{
				ex.Throw();
			});
		}
	}
}
namespace System.Threading.Tasks
{
	internal static class TaskExtensions
	{
		public static Task ContinueWithState<TState>(this Task task, Action<Task, TState> continuationAction, TState state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions)
		{
			return task.ContinueWith(delegate(Task t, object tupleObject)
			{
				var (action, arg) = ((Action<Task, TState>, TState))tupleObject;
				action(t, arg);
			}, (continuationAction, state), cancellationToken, continuationOptions, TaskScheduler.Default);
		}

		public static Task ContinueWithState<TResult, TState>(this Task<TResult> task, Action<Task<TResult>, TState> continuationAction, TState state, CancellationToken cancellationToken)
		{
			return task.ContinueWith(delegate(Task<TResult> t, object tupleObject)
			{
				var (action, arg) = ((Action<Task<TResult>, TState>, TState))tupleObject;
				action(t, arg);
			}, (continuationAction, state), cancellationToken);
		}

		public static Task ContinueWithState<TResult, TState>(this Task<TResult> task, Action<Task<TResult>, TState> continuationAction, TState state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions)
		{
			return task.ContinueWith(delegate(Task<TResult> t, object tupleObject)
			{
				var (action, arg) = ((Action<Task<TResult>, TState>, TState))tupleObject;
				action(t, arg);
			}, (continuationAction, state), cancellationToken, continuationOptions, TaskScheduler.Default);
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace System.Reactive
{
	public sealed class AnonymousObservable<T> : ObservableBase<T>
	{
		private readonly Func<IObserver<T>, IDisposable> _subscribe;

		public AnonymousObservable(Func<IObserver<T>, IDisposable> subscribe)
		{
			_subscribe = subscribe ?? throw new ArgumentNullException("subscribe");
		}

		protected override IDisposable SubscribeCore(IObserver<T> observer)
		{
			return _subscribe(observer) ?? Disposable.Empty;
		}
	}
	public sealed class AnonymousObserver<T> : ObserverBase<T>
	{
		private readonly Action<T> _onNext;

		private readonly Action<Exception> _onError;

		private readonly Action _onCompleted;

		public AnonymousObserver(Action<T> onNext, Action<Exception> onError, Action onCompleted)
		{
			_onNext = onNext ?? throw new ArgumentNullException("onNext");
			_onError = onError ?? throw new ArgumentNullException("onError");
			_onCompleted = onCompleted ?? throw new ArgumentNullException("onCompleted");
		}

		public AnonymousObserver(Action<T> onNext)
			: this(onNext, Stubs.Throw, Stubs.Nop)
		{
		}

		public AnonymousObserver(Action<T> onNext, Action<Exception> onError)
			: this(onNext, onError, Stubs.Nop)
		{
		}

		public AnonymousObserver(Action<T> onNext, Action onCompleted)
			: this(onNext, Stubs.Throw, onCompleted)
		{
		}

		protected override void OnNextCore(T value)
		{
			_onNext(value);
		}

		protected override void OnErrorCore(Exception error)
		{
			_onError(error);
		}

		protected override void OnCompletedCore()
		{
			_onCompleted();
		}

		internal ISafeObserver<T> MakeSafe()
		{
			return new AnonymousSafeObserver<T>(_onNext, _onError, _onCompleted);
		}
	}
	internal sealed class AnonymousSafeObserver<T> : SafeObserver<T>
	{
		private readonly Action<T> _onNext;

		private readonly Action<Exception> _onError;

		private readonly Action _onCompleted;

		private int _isStopped;

		public AnonymousSafeObserver(Action<T> onNext, Action<Exception> onError, Action onCompleted)
		{
			_onNext = onNext;
			_onError = onError;
			_onCompleted = onCompleted;
		}

		public override void OnNext(T value)
		{
			if (_isStopped != 0)
			{
				return;
			}
			bool flag = false;
			try
			{
				_onNext(value);
				flag = true;
			}
			finally
			{
				if (!flag)
				{
					Dispose();
				}
			}
		}

		public override void OnError(Exception error)
		{
			if (Interlocked.Exchange(ref _isStopped, 1) == 0)
			{
				using (this)
				{
					_onError(error);
				}
			}
		}

		public override void OnCompleted()
		{
			if (Interlocked.Exchange(ref _isStopped, 1) == 0)
			{
				using (this)
				{
					_onCompleted();
				}
			}
		}
	}
	public class EventPattern<TEventArgs> : EventPattern<object, TEventArgs>
	{
		public EventPattern(object? sender, TEventArgs e)
			: base(sender, e)
		{
		}
	}
	public class EventPattern<TSender, TEventArgs> : IEquatable<EventPattern<TSender, TEventArgs>>, IEventPattern<TSender, TEventArgs>
	{
		public TSender? Sender { get; }

		public TEventArgs EventArgs { get; }

		public EventPattern(TSender? sender, TEventArgs e)
		{
			Sender = sender;
			EventArgs = e;
		}

		public void Deconstruct(out TSender sender, out TEventArgs e)
		{
			TSender sender2 = Sender;
			TEventArgs eventArgs = EventArgs;
			sender = sender2;
			e = eventArgs;
		}

		public bool Equals(EventPattern<TSender, TEventArgs>? other)
		{
			if ((object)other == null)
			{
				return false;
			}
			if ((object)this == other)
			{
				return true;
			}
			if (EqualityComparer<TSender>.Default.Equals(Sender, other.Sender))
			{
				return EqualityComparer<TEventArgs>.Default.Equals(EventArgs, other.EventArgs);
			}
			return false;
		}

		public override bool Equals(object? obj)
		{
			return Equals(obj as EventPattern<TSender, TEventArgs>);
		}

		public override int GetHashCode()
		{
			TSender sender = Sender;
			int num = ((sender != null) ? sender.GetHashCode() : 0);
			TEventArgs eventArgs = EventArgs;
			int num2 = ((eventArgs != null) ? eventArgs.GetHashCode() : 0);
			return (num << 5) + (num ^ num2);
		}

		public static bool operator ==(EventPattern<TSender, TEventArgs> first, EventPattern<TSender, TEventArgs> second)
		{
			return object.Equals(first, second);
		}

		public static bool operator !=(EventPattern<TSender, TEventArgs> first, EventPattern<TSender, TEventArgs> second)
		{
			return !object.Equals(first, second);
		}
	}
	internal sealed class EventPatternSource<TEventArgs> : EventPatternSourceBase<object, TEventArgs>, IEventPatternSource<TEventArgs>
	{
		event EventHandler<TEventArgs> IEventPatternSource<TEventArgs>.OnNext
		{
			add
			{
				EventHandler<TEventArgs> value2 = value;
				Add(value2, delegate(object? o, TEventArgs e)
				{
					value2(o, e);
				});
			}
			remove
			{
				Remove(value);
			}
		}

		public EventPatternSource(IObservable<EventPattern<object, TEventArgs>> source, Action<Action<object?, TEventArgs>, EventPattern<object, TEventArgs>> invokeHandler)
			: base(source, invokeHandler)
		{
		}
	}
	public abstract class EventPatternSourceBase<TSender, TEventArgs>
	{
		private sealed class Observer : ObserverBase<EventPattern<TSender, TEventArgs>>, ISafeObserver<EventPattern<TSender, TEventArgs>>, IObserver<EventPattern<TSender, TEventArgs>>, IDisposable
		{
			private bool _isDone;

			private bool _isAdded;

			private readonly Delegate _handler;

			private readonly object _gate = new object();

			private readonly Action<TSender?, TEventArgs> _invoke;

			private readonly EventPatternSourceBase<TSender, TEventArgs> _sourceBase;

			public Observer(EventPatternSourceBase<TSender, TEventArgs> sourceBase, Delegate handler, Action<TSender?, TEventArgs> invoke)
			{
				_handler = handler;
				_invoke = invoke;
				_sourceBase = sourceBase;
			}

			protected override void OnNextCore(EventPattern<TSender, TEventArgs> value)
			{
				_sourceBase._invokeHandler(_invoke, value);
			}

			protected override void OnErrorCore(Exception error)
			{
				Remove();
				error.Throw();
			}

			protected override void OnCompletedCore()
			{
				Remove();
			}

			private void Remove()
			{
				lock (_gate)
				{
					if (_isAdded)
					{
						_sourceBase.Remove(_handler);
					}
					else
					{
						_isDone = true;
					}
				}
			}

			public void SetResource(IDisposable resource)
			{
				lock (_gate)
				{
					if (!_isDone)
					{
						_sourceBase.Add(_handler, resource);
						_isAdded = true;
					}
				}
			}
		}

		private readonly IObservable<EventPattern<TSender, TEventArgs>> _source;

		private readonly Dictionary<Delegate, Stack<IDisposable>> _subscriptions;

		private readonly Action<Action<TSender?, TEventArgs>, EventPattern<TSender, TEventArgs>> _invokeHandler;

		protected EventPatternSourceBase(IObservable<EventPattern<TSender, TEventArgs>> source, Action<Action<TSender?, TEventArgs>, EventPattern<TSender, TEventArgs>> invokeHandler)
		{
			_source = source ?? throw new ArgumentNullException("source");
			_invokeHandler = invokeHandler ?? throw new ArgumentNullException("invokeHandler");
			_subscriptions = new Dictionary<Delegate, Stack<IDisposable>>();
		}

		protected void Add(Delegate handler, Action<TSender?, TEventArgs> invoke)
		{
			if ((object)handler == null)
			{
				throw new ArgumentNullException("handler");
			}
			if (invoke == null)
			{
				throw new ArgumentNullException("invoke");
			}
			Observer observer = new Observer(this, handler, invoke);
			observer.SetResource(_source.Subscribe(observer));
		}

		private void Add(Delegate handler, IDisposable disposable)
		{
			lock (_subscriptions)
			{
				if (!_subscriptions.TryGetValue(handler, out Stack<IDisposable> value))
				{
					value = (_subscriptions[handler] = new Stack<IDisposable>());
				}
				value.Push(disposable);
			}
		}

		protected void Remove(Delegate handler)
		{
			if ((object)handler == null)
			{
				throw new ArgumentNullException("handler");
			}
			IDisposable disposable = null;
			lock (_subscriptions)
			{
				if (_subscriptions.TryGetValue(handler, out Stack<IDisposable> value))
				{
					disposable = value.Pop();
					if (value.Count == 0)
					{
						_subscriptions.Remove(handler);
					}
				}
			}
			disposable?.Dispose();
		}
	}
	internal sealed class EventSource<T> : IEventSource<T>
	{
		private readonly IObservable<T> _source;

		private readonly Dictionary<Delegate, Stack<IDisposable>> _subscriptions;

		private readonly Action<Action<T>, T> _invokeHandler;

		public event Action<T> OnNext
		{
			add
			{
				Action<T> value2 = value;
				object gate = new object();
				bool isAdded = false;
				bool isDone = false;
				Action remove = delegate
				{
					lock (gate)
					{
						if (isAdded)
						{
							Remove(value2);
						}
						else
						{
							isDone = true;
						}
					}
				};
				IDisposable disposable = _source.Subscribe(delegate(T x)
				{
					_invokeHandler(value2, x);
				}, delegate(Exception ex)
				{
					remove();
					ex.Throw();
				}, remove);
				lock (gate)
				{
					if (!isDone)
					{
						Add(value2, disposable);
						isAdded = true;
					}
				}
			}
			remove
			{
				Remove(value);
			}
		}

		public EventSource(IObservable<T> source, Action<Action<T>, T> invokeHandler)
		{
			_source = source;
			_invokeHandler = invokeHandler;
			_subscriptions = new Dictionary<Delegate, Stack<IDisposable>>();
		}

		private void Add(Delegate handler, IDisposable disposable)
		{
			lock (_subscriptions)
			{
				if (!_subscriptions.TryGetValue(handler, out Stack<IDisposable> value))
				{
					value = (_subscriptions[handler] = new Stack<IDisposable>());
				}
				value.Push(disposable);
			}
		}

		private void Remove(Delegate handler)
		{
			IDisposable disposable = null;
			lock (_subscriptions)
			{
				Stack<IDisposable> value = new Stack<IDisposable>();
				if (_subscriptions.TryGetValue(handler, out value))
				{
					disposable = value.Pop();
					if (value.Count == 0)
					{
						_subscriptions.Remove(handler);
					}
				}
			}
			disposable?.Dispose();
		}
	}
	[Experimental]
	[AttributeUsage(AttributeTargets.All)]
	public sealed class ExperimentalAttribute : Attribute
	{
	}
	public interface IEventPattern<out TSender, out TEventArgs>
	{
		TSender? Sender { get; }

		TEventArgs EventArgs { get; }
	}
	public interface IEventPatternSource<TEventArgs>
	{
		event EventHandler<TEventArgs> OnNext;
	}
	public interface IEventSource<out T>
	{
		event Action<T> OnNext;
	}
	internal sealed class AnonymousEnumerable<T> : IEnumerable<T>, IEnumerable
	{
		private readonly Func<IEnumerator<T>> _getEnumerator;

		public AnonymousEnumerable(Func<IEnumerator<T>> getEnumerator)
		{
			_getEnumerator = getEnumerator;
		}

		public IEnumerator<T> GetEnumerator()
		{
			return _getEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return _getEnumerator();
		}
	}
	internal sealed class AsyncLockObserver<T> : ObserverBase<T>
	{
		private readonly AsyncLock _gate;

		private readonly IObserver<T> _observer;

		public AsyncLockObserver(IObserver<T> observer, AsyncLock gate)
		{
			_gate = gate;
			_observer = observer;
		}

		protected override void OnNextCore(T value)
		{
			_gate.Wait((_observer, value), delegate((IObserver<T> _observer, T value) tuple)
			{
				tuple._observer.OnNext(tuple.value);
			});
		}

		protected override void OnErrorCore(Exception exception)
		{
			_gate.Wait((_observer, exception), delegate((IObserver<T> _observer, Exception exception) tuple)
			{
				tuple._observer.OnError(tuple.exception);
			});
		}

		protected override void OnCompletedCore()
		{
			_gate.Wait(_observer, delegate(IObserver<T> closureObserver)
			{
				closureObserver.OnCompleted();
			});
		}
	}
	internal sealed class AutoDetachObserver<T> : ObserverBase<T>, ISafeObserver<T>, IObserver<T>, IDisposable
	{
		private readonly IObserver<T> _observer;

		private SingleAssignmentDisposableValue _disposable;

		public AutoDetachObserver(IObserver<T> observer)
		{
			_observer = observer;
		}

		public void SetResource(IDisposable resource)
		{
			_disposable.Disposable = resource;
		}

		protected override void OnNextCore(T value)
		{
			bool flag = false;
			try
			{
				_observer.OnNext(value);
				flag = true;
			}
			finally
			{
				if (!flag)
				{
					Dispose();
				}
			}
		}

		protected override void OnErrorCore(Exception exception)
		{
			try
			{
				_observer.OnError(exception);
			}
			finally
			{
				Dispose();
			}
		}

		protected override void OnCompletedCore()
		{
			try
			{
				_observer.OnCompleted();
			}
			finally
			{
				Dispose();
			}
		}

		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);
			if (disposing)
			{
				_disposable.Dispose();
			}
		}
	}
	internal sealed class BinaryObserver<TLeft, TRight> : IObserver<Either<Notification<TLeft>, Notification<TRight>>>
	{
		public IObserver<TLeft> LeftObserver { get; }

		public IObserver<TRight> RightObserver { get; }

		public BinaryObserver(IObserver<TLeft> leftObserver, IObserver<TRight> rightObserver)
		{
			LeftObserver = leftObserver;
			RightObserver = rightObserver;
		}

		public BinaryObserver(Action<Notification<TLeft>> left, Action<Notification<TRight>> right)
			: this(left.ToObserver(), right.ToObserver())
		{
		}

		void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnNext(Either<Notification<TLeft>, Notification<TRight>> value)
		{
			value.Switch(delegate(Notification<TLeft> left)
			{
				left.Accept(LeftObserver);
			}, delegate(Notification<TRight> right)
			{
				right.Accept(RightObserver);
			});
		}

		void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnError(Exception exception)
		{
		}

		void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnCompleted()
		{
		}
	}
	internal sealed class CheckedObserver<T> : IObserver<T>
	{
		private readonly IObserver<T> _observer;

		private int _state;

		private const int Idle = 0;

		private const int Busy = 1;

		private const int Done = 2;

		public CheckedObserver(IObserver<T> observer)
		{
			_observer = observer;
		}

		public void OnNext(T value)
		{
			CheckAccess();
			try
			{
				_observer.OnNext(value);
			}
			finally
			{
				Interlocked.Exchange(ref _state, 0);
			}
		}

		public void OnError(Exception error)
		{
			CheckAccess();
			try
			{
				_observer.OnError(error);
			}
			finally
			{
				Interlocked.Exchange(ref _state, 2);
			}
		}

		public void OnCompleted()
		{
			CheckAccess();
			try
			{
				_observer.OnCompleted();
			}
			finally
			{
				Interlocked.Exchange(ref _state, 2);
			}
		}

		private void CheckAccess()
		{
			switch (Interlocked.CompareExchange(ref _state, 1, 0))
			{
			case 1:
				throw new InvalidOperationException(Strings_Core.REENTRANCY_DETECTED);
			case 2:
				throw new InvalidOperationException(Strings_Core.OBSERVER_TERMINATED);
			}
		}
	}
	internal abstract class ConcatSink<TSource> : TailRecursiveSink<TSource>
	{
		protected ConcatSink(IObserver<TSource> observer)
			: base(observer)
		{
		}

		protected override IEnumerable<IObservable<TSource>>? Extract(IObservable<TSource> source)
		{
			return (source as IConcatenatable<TSource>)?.GetSources();
		}

		public override void OnCompleted()
		{
			Recurse();
		}
	}
	internal static class Constants_Core
	{
		private const string ObsoleteRefactoring = "This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies.";

		public const string ObsoleteSchedulerNewthread = "This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies. Please use NewThreadScheduler.Default to obtain an instance of this scheduler type.";

		public const string ObsoleteSchedulerTaskpool = "This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies. Please use TaskPoolScheduler.Default to obtain an instance of this scheduler type.";

		public const string ObsoleteSchedulerThreadpool = "This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies. Consider using Scheduler.Default to obtain the platform's most appropriate pool-based scheduler. In order to access a specific pool-based scheduler, please add a reference to the System.Reactive.PlatformServices assembly for your target platform and use the appropriate scheduler in the System.Reactive.Concurrency namespace.";

		public const string ObsoleteSchedulerequired = "This instance property is no longer supported. Use CurrentThreadScheduler.IsScheduleRequired instead.";
	}
	internal static class Constants_Linq
	{
		public const string UseAsync = "This blocking operation is no longer supported. Instead, use the async version in combination with C# and Visual Basic async/await support. In case you need a blocking operation, use Wait or convert the resulting observable sequence to a Task object and block.";

		public const string UseTaskFromAsyncPattern = "This conversion is no longer supported. Replace use of the Begin/End asynchronous method pair with a new Task-based async method, and convert the result using ToObservable. If no Task-based async method is available, use Task.Factory.FromAsync to obtain a Task object.";
	}
	internal abstract class Either<TLeft, TRight>
	{
		public sealed class Left : Either<TLeft, TRight>, IEquatable<Left>
		{
			public TLeft Value { get; }

			public Left(TLeft value)
			{
				Value = value;
			}

			public override TResult Switch<TResult>(Func<TLeft, TResult> caseLeft, Func<TRight, TResult> caseRight)
			{
				return caseLeft(Value);
			}

			public override void Switch(Action<TLeft> caseLeft, Action<TRight> caseRight)
			{
				caseLeft(Value);
			}

			public bool Equals(Left? other)
			{
				if (other == this)
				{
					return true;
				}
				if (other == null)
				{
					return false;
				}
				return EqualityComparer<TLeft>.Default.Equals(Value, other.Value);
			}

			public override bool Equals(object? obj)
			{
				return Equals(obj as Either<TLeft, TRight>.Left);
			}

			public override int GetHashCode()
			{
				TLeft value = Value;
				if (value == null)
				{
					return 0;
				}
				return value.GetHashCode();
			}

			public override string ToString()
			{
				return string.Format(CultureInfo.CurrentCulture, "Left({0})", Value);
			}
		}

		public sealed class Right : Either<TLeft, TRight>, IEquatable<Right>
		{
			public TRight Value { get; }

			public Right(TRight value)
			{
				Value = value;
			}

			public override TResult Switch<TResult>(Func<TLeft, TResult> caseLeft, Func<TRight, TResult> caseRight)
			{
				return caseRight(Value);
			}

			public override void Switch(Action<TLeft> caseLeft, Action<TRight> caseRight)
			{
				caseRight(Value);
			}

			public bool Equals(Right? other)
			{
				if (other == this)
				{
					return true;
				}
				if (other == null)
				{
					return false;
				}
				return EqualityComparer<TRight>.Default.Equals(Value, other.Value);
			}

			public override bool Equals(object? obj)
			{
				return Equals(obj as Either<TLeft, TRight>.Right);
			}

			public override int GetHashCode()
			{
				TRight value = Value;
				if (value == null)
				{
					return 0;
				}
				return value.GetHashCode();
			}

			public override string ToString()
			{
				return string.Format(CultureInfo.CurrentCulture, "Right({0})", Value);
			}
		}

		private Either()
		{
		}

		public static Either<TLeft, TRight> CreateLeft(TLeft value)
		{
			return new Left(value);
		}

		public static Either<TLeft, TRight> CreateRight(TRight value)
		{
			return new Right(value);
		}

		public abstract TResult Switch<TResult>(Func<TLeft, TResult> caseLeft, Func<TRight, TResult> caseRight);

		public abstract void Switch(Action<TLeft> caseLeft, Action<TRight> caseRight);
	}
	internal static class ExceptionHelper
	{
		public static Exception Terminated { get; } = new EndOfStreamException("On[Error|Completed]");


		public static bool TrySetException(ref Exception? field, Exception ex)
		{
			return Interlocked.CompareExchange(ref field, ex, null) == null;
		}
	}
	internal static class ExceptionHelpers
	{
		private static readonly Lazy<IExceptionServices> Services = new Lazy<IExceptionServices>(Initialize);

		[DoesNotReturn]
		public static void Throw(this Exception exception)
		{
			Services.Value.Rethrow(exception);
		}

		private static IExceptionServices Initialize()
		{
			return PlatformEnlightenmentProvider.Current.GetService<IExceptionServices>(Array.Empty<object>()) ?? new DefaultExceptionServices();
		}
	}
	internal sealed class Grouping<TKey, TElement> : Dictionary<TKey, Subject<TElement>>
	{
		public Grouping(IEqualityComparer<TKey> comparer)
			: base(comparer)
		{
		}

		public Grouping(int capacity, IEqualityComparer<TKey> comparer)
			: base(capacity, comparer)
		{
		}
	}
	internal static class HalfSerializer
	{
		public static void ForwardOnNext<T>(ISink<T> sink, T item, ref int wip, ref Exception? error)
		{
			if (Interlocked.CompareExchange(ref wip, 1, 0) == 0)
			{
				sink.ForwardOnNext(item);
				if (Interlocked.Decrement(ref wip) != 0)
				{
					Exception ex = error;
					if (ex != ExceptionHelper.Terminated)
					{
						error = ExceptionHelper.Terminated;
						sink.ForwardOnError(ex);
					}
					else
					{
						sink.ForwardOnCompleted();
					}
				}
			}
			else if (error == null)
			{
				Trace.TraceWarning("OnNext called while another OnNext call was in progress on the same Observer.");
			}
		}

		public static void ForwardOnError<T>(ISink<T> sink, Exception ex, ref int wip, ref Exception? error)
		{
			if (ExceptionHelper.TrySetException(ref error, ex) && Interlocked.Increment(ref wip) == 1)
			{
				error = ExceptionHelper.Terminated;
				sink.ForwardOnError(ex);
			}
		}

		public static void ForwardOnCompleted<T>(ISink<T> sink, ref int wip, ref Exception? error)
		{
			if (ExceptionHelper.TrySetException(ref error, ExceptionHelper.Terminated) && Interlocked.Increment(ref wip) == 1)
			{
				sink.ForwardOnCompleted();
			}
		}
	}
	internal static class Helpers
	{
		public static bool All(this bool[] values)
		{
			for (int i = 0; i < values.Length; i++)
			{
				if (!values[i])
				{
					return false;
				}
			}
			return true;
		}

		public static bool AllExcept(this bool[] values, int index)
		{
			for (int i = 0; i < values.Length; i++)
			{
				if (i != index && !values[i])
				{
					return false;
				}
			}
			return true;
		}
	}
	internal interface IConcatenatable<out TSource>
	{
		IEnumerable<IObservable<TSource>> GetSources();
	}
	internal abstract class IdentitySink<T> : Sink<T, T>
	{
		protected IdentitySink(IObserver<T> observer)
			: base(observer)
		{
		}

		public override void OnNext(T value)
		{
			ForwardOnNext(value);
		}
	}
	internal interface IEvaluatableObservable<out T>
	{
		IObservable<T> Eval();
	}
	internal sealed class ImmutableList<T>
	{
		public static readonly ImmutableList<T> Empty = new ImmutableList<T>();

		private readonly T[] _data;

		public T[] Data => _data;

		private ImmutableList()
		{
			_data = Array.Empty<T>();
		}

		public ImmutableList(T[] data)
		{
			_data = data;
		}

		public ImmutableList<T> Add(T value)
		{
			T[] array = new T[_data.Length + 1];
			Array.Copy(_data, array, _data.Length);
			array[_data.Length] = value;
			return new ImmutableList<T>(array);
		}

		public ImmutableList<T> Remove(T value)
		{
			int num = Array.IndexOf(_data, value);
			if (num < 0)
			{
				return this;
			}
			int num2 = _data.Length;
			if (num2 == 1)
			{
				return Empty;
			}
			T[] array = new T[num2 - 1];
			Array.Copy(_data, 0, array, 0, num);
			Array.Copy(_data, num + 1, array, num, num2 - num - 1);
			return new ImmutableList<T>(array);
		}
	}
	internal interface ISafeObserver<in T> : IObserver<T>, IDisposable
	{
		void SetResource(IDisposable resource);
	}
	internal sealed class Lookup<K, E> : ILookup<K, E>, IEnumerable<IGrouping<K, E>>, IEnumerable
	{
		private sealed class Grouping : IGrouping<K, E>, IEnumerable<E>, IEnumerable
		{
			private readonly KeyValuePair<K, List<E>> _keyValuePair;

			public K Key
			{
				get
				{
					KeyValuePair<K, List<E>> keyValuePair = _keyValuePair;
					return keyValuePair.Key;
				}
			}

			public Grouping(KeyValuePair<K, List<E>> keyValuePair)
			{
				_keyValuePair = keyValuePair;
			}

			public IEnumerator<E> GetEnumerator()
			{
				KeyValuePair<K, List<E>> keyValuePair = _keyValuePair;
				return keyValuePair.Value.GetEnumerator();
			}

			IEnumerator IEnumerable.GetEnumerator()
			{
				return GetEnumerator();
			}
		}

		private readonly Dictionary<K, List<E>> _dictionary;

		public int Count => _dictionary.Count;

		public IEnumerable<E> this[K key]
		{
			get
			{
				if (!_dictionary.TryGetValue(key, out var value))
				{
					return Enumerable.Empty<E>();
				}
				return Hide(value);
			}
		}

		public Lookup(IEqualityComparer<K> comparer)
		{
			_dictionary = new Dictionary<K, List<E>>(comparer);
		}

		public void Add(K key, E element)
		{
			if (!_dictionary.TryGetValue(key, out var value))
			{
				value = (_dictionary[key] = new List<E>());
			}
			value.Add(element);
		}

		public bool Contains(K key)
		{
			return _dictionary.ContainsKey(key);
		}

		private static IEnumerable<E> Hide(List<E> elements)
		{
			return elements.Skip(0);
		}

		public IEnumerator<IGrouping<K, E>> GetEnumerator()
		{
			foreach (KeyValuePair<K, List<E>> item in _dictionary)
			{
				yield return new Grouping(item);
			}
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	internal sealed class Map<TKey, TValue>
	{
		private const int DefaultConcurrencyMultiplier = 4;

		private readonly ConcurrentDictionary<TKey, TValue> _map;

		private static int DefaultConcurrencyLevel => 4 * Environment.ProcessorCount;

		public IEnumerable<TValue> Values => _map.Values.ToArray();

		public Map(int? capacity, IEqualityComparer<TKey> comparer)
		{
			if (capacity.HasValue)
			{
				_map = new ConcurrentDictionary<TKey, TValue>(DefaultConcurrencyLevel, capacity.Value, comparer);
			}
			else
			{
				_map = new ConcurrentDictionary<TKey, TValue>(comparer);
			}
		}

		public TValue GetOrAdd(TKey key, Func<TValue> valueFactory, out bool added)
		{
			added = false;
			TValue val = default(TValue);
			bool flag = false;
			TValue value;
			while (!_map.TryGetValue(key, out value))
			{
				if (!flag)
				{
					val = valueFactory();
					flag = true;
				}
				if (_map.TryAdd(key, val))
				{
					added = true;
					return val;
				}
			}
			return value;
		}

		public bool Remove(TKey key)
		{
			TValue value;
			return _map.TryRemove(key, out value);
		}
	}
	internal sealed class NopObserver<T> : IObserver<T>
	{
		public static readonly IObserver<T> Instance = new NopObserver<T>();

		public void OnCompleted()
		{
		}

		public void OnError(Exception error)
		{
		}

		public void OnNext(T value)
		{
		}
	}
	internal sealed class PriorityQueue<T> where T : IComparable<T>
	{
		private struct IndexedItem : IComparable<IndexedItem>
		{
			public T Value;

			public long Id;

			public int CompareTo(IndexedItem other)
			{
				int num = Value.CompareTo(other.Value);
				if (num == 0)
				{
					num = Id.CompareTo(other.Id);
				}
				return num;
			}
		}

		private long _count = long.MinValue;

		private IndexedItem[] _items;

		private int _size;

		public int Count => _size;

		public PriorityQueue()
			: this(16)
		{
		}

		public PriorityQueue(int capacity)
		{
			_items = new IndexedItem[capacity];
			_size = 0;
		}

		private bool IsHigherPriority(int left, int right)
		{
			return _items[left].CompareTo(_items[right]) < 0;
		}

		private int Percolate(int index)
		{
			if (index >= _size || index < 0)
			{
				return index;
			}
			int num = (index - 1) / 2;
			while (num >= 0 && num != index && IsHigherPriority(index, num))
			{
				IndexedItem indexedItem = _items[index];
				_items[index] = _items[num];
				_items[num] = indexedItem;
				index = num;
				num = (index - 1) / 2;
			}
			return index;
		}

		private void Heapify(int index)
		{
			if (index >= _size || index < 0)
			{
				return;
			}
			while (true)
			{
				int num = 2 * index + 1;
				int num2 = 2 * index + 2;
				int num3 = index;
				if (num < _size && IsHigherPriority(num, num3))
				{
					num3 = num;
				}
				if (num2 < _size && IsHigherPriority(num2, num3))
				{
					num3 = num2;
				}
				if (num3 != index)
				{
					IndexedItem indexedItem = _items[index];
					_items[index] = _items[num3];
					_items[num3] = indexedItem;
					index = num3;
					continue;
				}
				break;
			}
		}

		public T Peek()
		{
			if (_size == 0)
			{
				throw new InvalidOperationException(Strings_Core.HEAP_EMPTY);
			}
			return _items[0].Value;
		}

		private void RemoveAt(int index)
		{
			_items[index] = _items[--_size];
			_items[_size] = default(IndexedItem);
			if (Percolate(index) == index)
			{
				Heapify(index);
			}
			if (_size < _items.Length / 4)
			{
				IndexedItem[] items = _items;
				_items = new IndexedItem[_items.Length / 2];
				Array.Copy(items, 0, _items, 0, _size);
			}
		}

		public T Dequeue()
		{
			T result = Peek();
			RemoveAt(0);
			return result;
		}

		public void Enqueue(T item)
		{
			if (_size >= _items.Length)
			{
				IndexedItem[] items = _items;
				_items = new IndexedItem[_items.Length * 2];
				Array.Copy(items, _items, items.Length);
			}
			int num = _size++;
			_items[num] = new IndexedItem
			{
				Value = item,
				Id = ++_count
			};
			Percolate(num);
		}

		public bool Remove(T item)
		{
			for (int i = 0; i < _size; i++)
			{
				if (EqualityComparer<T>.Default.Equals(_items[i].Value, item))
				{
					RemoveAt(i);
					return true;
				}
			}
			return false;
		}
	}
	internal interface IProducer<out TSource> : IObservable<TSource>
	{
		IDisposable SubscribeRaw(IObserver<TSource> observer, bool enableSafeguard);
	}
	internal abstract class BasicProducer<TSource> : IProducer<TSource>, IObservable<TSource>
	{
		public IDisposable Subscribe(IObserver<TSource> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return SubscribeRaw(observer, enableSafeguard: true);
		}

		public IDisposable SubscribeRaw(IObserver<TSource> observer, bool enableSafeguard)
		{
			ISafeObserver<TSource> safeObserver = null;
			if (enableSafeguard)
			{
				observer = (safeObserver = SafeObserver<TSource>.Wrap(observer));
			}
			IDisposable disposable;
			if (CurrentThreadScheduler.IsScheduleRequired)
			{
				SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable();
				CurrentThreadScheduler.Instance.ScheduleAction((this, singleAssignmentDisposable, observer), ((BasicProducer<TSource> @this, SingleAssignmentDisposable runAssignable, IObserver<TSource> observer) tuple) => tuple.runAssignable.Disposable = tuple.@this.Run(tuple.observer));
				disposable = singleAssignmentDisposable;
			}
			else
			{
				disposable = Run(observer);
			}
			safeObserver?.SetResource(disposable);
			return disposable;
		}

		protected abstract IDisposable Run(IObserver<TSource> observer);
	}
	internal abstract class Producer<TTarget, TSink> : IProducer<TTarget>, IObservable<TTarget> where TSink : IDisposable
	{
		public IDisposable Subscribe(IObserver<TTarget> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return SubscribeRaw(observer, enableSafeguard: true);
		}

		public IDisposable SubscribeRaw(IObserver<TTarget> observer, bool enableSafeguard)
		{
			ISafeObserver<TTarget> safeObserver = null;
			if (enableSafeguard)
			{
				observer = (safeObserver = SafeObserver<TTarget>.Wrap(observer));
			}
			TSink val = CreateSink(observer);
			safeObserver?.SetResource(val);
			if (CurrentThreadScheduler.IsScheduleRequired)
			{
				CurrentThreadScheduler.Instance.ScheduleAction((this, val), delegate((Producer<TTarget, TSink> @this, TSink sink) tuple)
				{
					tuple.@this.Run(tuple.sink);
				});
			}
			else
			{
				Run(val);
			}
			return val;
		}

		protected abstract void Run(TSink sink);

		protected abstract TSink CreateSink(IObserver<TTarget> observer);
	}
	internal static class ReflectionUtils
	{
		public static TDelegate CreateDelegate<TDelegate>(object o, MethodInfo method)
		{
			return (TDelegate)(object)method.CreateDelegate(typeof(TDelegate), o);
		}

		public static Delegate CreateDelegate(Type delegateType, object o, MethodInfo method)
		{
			return method.CreateDelegate(delegateType, o);
		}

		public static void GetEventMethods<TSender, TEventArgs>(Type targetType, object? target, string eventName, out MethodInfo addMethod, out MethodInfo removeMethod, out Type delegateType, out bool isWinRT)
		{
			EventInfo @event;
			if (target == null)
			{
				@event = targetType.GetEvent(eventName, BindingFlags.Static | BindingFlags.Public);
				if (@event == null)
				{
					throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.COULD_NOT_FIND_STATIC_EVENT, eventName, targetType.FullName));
				}
			}
			else
			{
				@event = targetType.GetEvent(eventName, BindingFlags.Instance | BindingFlags.Public);
				if (@event == null)
				{
					throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.COULD_NOT_FIND_INSTANCE_EVENT, eventName, targetType.FullName));
				}
			}
			MethodInfo addMethod2 = @event.GetAddMethod();
			if (addMethod2 == null)
			{
				throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_ADD_METHOD);
			}
			addMethod = addMethod2;
			MethodInfo removeMethod2 = @event.GetRemoveMethod();
			if (removeMethod2 == null)
			{
				throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_REMOVE_METHOD);
			}
			removeMethod = removeMethod2;
			ParameterInfo[] parameters = addMethod.GetParameters();
			if (parameters.Length != 1)
			{
				throw new InvalidOperationException(Strings_Linq.EVENT_ADD_METHOD_SHOULD_TAKE_ONE_PARAMETER);
			}
			ParameterInfo[] parameters2 = removeMethod.GetParameters();
			if (parameters2.Length != 1)
			{
				throw new InvalidOperationException(Strings_Linq.EVENT_REMOVE_METHOD_SHOULD_TAKE_ONE_PARAMETER);
			}
			isWinRT = false;
			if (addMethod.ReturnType == typeof(EventRegistrationToken))
			{
				isWinRT = true;
				if (parameters2[0].ParameterType != typeof(EventRegistrationToken))
				{
					throw new InvalidOperationException(Strings_Linq.EVENT_WINRT_REMOVE_METHOD_SHOULD_TAKE_ERT);
				}
			}
			delegateType = parameters[0].ParameterType;
			MethodInfo? method = delegateType.GetMethod("Invoke");
			ParameterInfo[] parameters3 = method.GetParameters();
			if (parameters3.Length != 2)
			{
				throw new InvalidOperationException(Strings_Linq.EVENT_PATTERN_REQUIRES_TWO_PARAMETERS);
			}
			if (!typeof(TSender).IsAssignableFrom(parameters3[0].ParameterType))
			{
				throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.EVENT_SENDER_NOT_ASSIGNABLE, typeof(TSender).FullName));
			}
			if (!typeof(TEventArgs).IsAssignableFrom(parameters3[1].ParameterType))
			{
				throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.EVENT_ARGS_NOT_ASSIGNABLE, typeof(TEventArgs).FullName));
			}
			if (method.ReturnType != typeof(void))
			{
				throw new InvalidOperationException(Strings_Linq.EVENT_MUST_RETURN_VOID);
			}
		}
	}
	internal abstract class SafeObserver<TSource> : ISafeObserver<TSource>, IObserver<TSource>, IDisposable
	{
		private sealed class WrappingSafeObserver : SafeObserver<TSource>
		{
			private readonly IObserver<TSource> _observer;

			public WrappingSafeObserver(IObserver<TSource> observer)
			{
				_observer = observer;
			}

			public override void OnNext(TSource value)
			{
				bool flag = false;
				try
				{
					_observer.OnNext(value);
					flag = true;
				}
				finally
				{
					if (!flag)
					{
						Dispose();
					}
				}
			}

			public override void OnError(Exception error)
			{
				using (this)
				{
					_observer.OnError(error);
				}
			}

			public override void OnCompleted()
			{
				using (this)
				{
					_observer.OnCompleted();
				}
			}
		}

		private SingleAssignmentDisposableValue _disposable;

		public static ISafeObserver<TSource> Wrap(IObserver<TSource> observer)
		{
			if (observer is AnonymousObserver<TSource> anonymousObserver)
			{
				return anonymousObserver.MakeSafe();
			}
			return new WrappingSafeObserver(observer);
		}

		public abstract void OnNext(TSource value);

		public abstract void OnError(Exception error);

		public abstract void OnCompleted();

		public void SetResource(IDisposable resource)
		{
			_disposable.Disposable = resource;
		}

		public void Dispose()
		{
			Dispose(disposing: true);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				_disposable.Dispose();
			}
		}
	}
	internal class ScheduledObserver<T> : ObserverBase<T>, IScheduledObserver<T>, IObserver<T>, IDisposable
	{
		private sealed class SemaphoreSlimRelease : IDisposable
		{
			private volatile SemaphoreSlim? _dispatcherEvent;

			public SemaphoreSlimRelease(SemaphoreSlim dispatcherEvent)
			{
				_dispatcherEvent = dispatcherEvent;
			}

			public void Dispose()
			{
				Interlocked.Exchange(ref _dispatcherEvent, null)?.Release();
			}
		}

		private int _state;

		private const int Stopped = 0;

		private const int Running = 1;

		private const int Pending = 2;

		private const int Faulted = 9;

		private readonly ConcurrentQueue<T> _queue = new ConcurrentQueue<T>();

		private bool _failed;

		private Exception? _error;

		private bool _completed;

		private readonly IObserver<T> _observer;

		private readonly IScheduler _scheduler;

		private readonly ISchedulerLongRunning? _longRunning;

		private SerialDisposableValue _disposable;

		private readonly object _dispatcherInitGate = new object();

		private readonly SemaphoreSlim? _dispatcherEvent;

		private readonly IDisposable? _dispatcherEventRelease;

		private IDisposable? _dispatcherJob;

		public ScheduledObserver(IScheduler scheduler, IObserver<T> observer)
		{
			_scheduler = scheduler;
			_observer = observer;
			_longRunning = _scheduler.AsLongRunning();
			if (_longRunning != null)
			{
				_dispatcherEvent = new SemaphoreSlim(0);
				_dispatcherEventRelease = new SemaphoreSlimRelease(_dispatcherEvent);
			}
		}

		private void EnsureDispatcher()
		{
			if (_dispatcherJob != null)
			{
				return;
			}
			lock (_dispatcherInitGate)
			{
				if (_dispatcherJob == null)
				{
					_dispatcherJob = _longRunning.ScheduleLongRunning(Dispatch);
					_disposable.Disposable = StableCompositeDisposable.Create(_dispatcherJob, _dispatcherEventRelease);
				}
			}
		}

		private void Dispatch(ICancelable cancel)
		{
			do
			{
				_dispatcherEvent.Wait();
				if (cancel.IsDisposed)
				{
					return;
				}
				T result;
				while (_queue.TryDequeue(out result))
				{
					try
					{
						_observer.OnNext(result);
					}
					catch
					{
						T result2;
						while (_queue.TryDequeue(out result2))
						{
						}
						throw;
					}
					_dispatcherEvent.Wait();
					if (cancel.IsDisposed)
					{
						return;
					}
				}
				if (_failed)
				{
					_observer.OnError(_error);
					Dispose();
					return;
				}
			}
			while (!_completed);
			_observer.OnCompleted();
			Dispose();
		}

		public void EnsureActive()
		{
			EnsureActive(1);
		}

		public void EnsureActive(int n)
		{
			if (_longRunning != null)
			{
				if (n > 0)
				{
					_dispatcherEvent.Release(n);
				}
				EnsureDispatcher();
			}
			else
			{
				EnsureActiveSlow();
			}
		}

		private void EnsureActiveSlow()
		{
			bool flag = false;
			do
			{
				IL_0002:
				switch (Interlocked.CompareExchange(ref _state, 1, 0))
				{
				default:
					goto IL_0002;
				case 0:
					flag = true;
					break;
				case 9:
					return;
				case 1:
					continue;
				case 2:
					break;
				}
				break;
			}
			while (Interlocked.CompareExchange(ref _state, 2, 1) != 1);
			if (flag)
			{
				_disposable.Disposable = _scheduler.Schedule<object>(null, Run);
			}
		}

		private void Run(object? state, Action<object?> recurse)
		{
			T result;
			while (!_queue.TryDequeue(out result))
			{
				if (_failed)
				{
					if (_queue.IsEmpty)
					{
						Interlocked.Exchange(ref _state, 0);
						_observer.OnError(_error);
						Dispose();
						return;
					}
				}
				else if (_completed)
				{
					if (_queue.IsEmpty)
					{
						Interlocked.Exchange(ref _state, 0);
						_observer.OnCompleted();
						Dispose();
						return;
					}
				}
				else
				{
					int num = Interlocked.CompareExchange(ref _state, 0, 1);
					if (num == 1 || num == 9)
					{
						return;
					}
					_state = 1;
				}
			}
			Interlocked.Exchange(ref _state, 1);
			try
			{
				_observer.OnNext(result);
			}
			catch
			{
				Interlocked.Exchange(ref _state, 9);
				T result2;
				while (_queue.TryDequeue(out result2))
				{
				}
				throw;
			}
			recurse(state);
		}

		protected override void OnNextCore(T value)
		{
			_queue.Enqueue(value);
		}

		protected override void OnErrorCore(Exception exception)
		{
			_error = exception;
			_failed = true;
		}

		protected override void OnCompletedCore()
		{
			_completed = true;
		}

		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);
			if (disposing)
			{
				_disposable.Dispose();
			}
		}
	}
	internal sealed class ObserveOnObserver<T> : ScheduledObserver<T>
	{
		private SingleAssignmentDisposableValue _run;

		public ObserveOnObserver(IScheduler scheduler, IObserver<T> observer)
			: base(scheduler, observer)
		{
		}

		public void Run(IObservable<T> source)
		{
			_run.Disposable = source.SubscribeSafe(this);
		}

		protected override void OnNextCore(T value)
		{
			base.OnNextCore(value);
			EnsureActive();
		}

		protected override void OnErrorCore(Exception exception)
		{
			base.OnErrorCore(exception);
			EnsureActive();
		}

		protected override void OnCompletedCore()
		{
			base.OnCompletedCore();
			EnsureActive();
		}

		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);
			if (disposing)
			{
				_run.Dispose();
			}
		}
	}
	internal interface IScheduledObserver<T> : IObserver<T>, IDisposable
	{
		void EnsureActive();

		void EnsureActive(int count);
	}
	internal sealed class ObserveOnObserverNew<T> : IdentitySink<T>
	{
		private readonly IScheduler _scheduler;

		private readonly ConcurrentQueue<T> _queue;

		private IDisposable? _task;

		private int _wip;

		private bool _done;

		private Exception? _error;

		private bool _disposed;

		private static readonly Func<IScheduler, ObserveOnObserverNew<T>, IDisposable> DrainShortRunningFunc = (IScheduler scheduler, ObserveOnObserverNew<T> self) => self.DrainShortRunning(scheduler);

		public ObserveOnObserverNew(IScheduler scheduler, IObserver<T> downstream)
			: base(downstream)
		{
			_scheduler = scheduler;
			_queue = new ConcurrentQueue<T>();
		}

		protected override void Dispose(bool disposing)
		{
			Volatile.Write(ref _disposed, value: true);
			base.Dispose(disposing);
			if (disposing)
			{
				Disposable.Dispose(ref _task);
				Clear(_queue);
			}
		}

		private static void Clear(ConcurrentQueue<T> q)
		{
			T result;
			while (q.TryDequeue(out result))
			{
			}
		}

		public override void OnCompleted()
		{
			Volatile.Write(ref _done, value: true);
			Schedule();
		}

		public override void OnError(Exception error)
		{
			_error = error;
			Volatile.Write(ref _done, value: true);
			Schedule();
		}

		public override void OnNext(T value)
		{
			_queue.Enqueue(value);
			Schedule();
		}

		private void Schedule()
		{
			if (Interlocked.Increment(ref _wip) == 1)
			{
				SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable();
				if (Disposable.TrySetMultiple(ref _task, singleAssignmentDisposable))
				{
					singleAssignmentDisposable.Disposable = _scheduler.Schedule(this, DrainShortRunningFunc);
				}
				if (Volatile.Read(ref _disposed))
				{
					Clear(_queue);
				}
			}
		}

		private IDisposable DrainShortRunning(IScheduler recursiveScheduler)
		{
			DrainStep(_queue);
			if (Interlocked.Decrement(ref _wip) != 0)
			{
				IDisposable value = recursiveScheduler.Schedule(this, DrainShortRunningFunc);
				Disposable.TrySetMultiple(ref _task, value);
			}
			return Disposable.Empty;
		}

		private void DrainStep(ConcurrentQueue<T> q)
		{
			if (Volatile.Read(ref _disposed))
			{
				Clear(q);
				return;
			}
			bool flag = Volatile.Read(ref _done);
			if (flag)
			{
				Exception error = _error;
				if (error != null)
				{
					Volatile.Write(ref _disposed, value: true);
					ForwardOnError(error);
					return;
				}
			}
			if (q.TryDequeue(out T result))
			{
				ForwardOnNext(result);
			}
			else if (flag)
			{
				Volatile.Write(ref _disposed, value: true);
				ForwardOnCompleted();
			}
		}
	}
	internal sealed class ObserveOnObserverLongRunning<TSource> : IdentitySink<TSource>
	{
		private readonly ISchedulerLongRunning _scheduler;

		private readonly ConcurrentQueue<TSource> _queue;

		private readonly object _suspendGuard;

		private long _wip;

		private bool _done;

		private Exception? _error;

		private bool _disposed;

		private int _runDrainOnce;

		private SingleAssignmentDisposableValue _drainTask;

		private static readonly Action<ObserveOnObserverLongRunning<TSource>, ICancelable> DrainLongRunning = delegate(ObserveOnObserverLongRunning<TSource> self, ICancelable cancelable)
		{
			self.Drain();
		};

		public ObserveOnObserverLongRunning(ISchedulerLongRunning scheduler, IObserver<TSource> observer)
			: base(observer)
		{
			_scheduler = scheduler;
			_queue = new ConcurrentQueue<TSource>();
			_suspendGuard = new object();
		}

		public override void OnCompleted()
		{
			Volatile.Write(ref _done, value: true);
			Schedule();
		}

		public override void OnError(Exception error)
		{
			_error = error;
			Volatile.Write(ref _done, value: true);
			Schedule();
		}

		public override void OnNext(TSource value)
		{
			_queue.Enqueue(value);
			Schedule();
		}

		private void Schedule()
		{
			if (Volatile.Read(ref _runDrainOnce) == 0 && Interlocked.CompareExchange(ref _runDrainOnce, 1, 0) == 0)
			{
				_drainTask.Disposable = _scheduler.ScheduleLongRunning(this, DrainLongRunning);
			}
			if (Interlocked.Increment(ref _wip) == 1)
			{
				lock (_suspendGuard)
				{
					Monitor.Pulse(_suspendGuard);
				}
			}
		}

		protected override void Dispose(bool disposing)
		{
			Volatile.Write(ref _disposed, value: true);
			lock (_suspendGuard)
			{
				Monitor.Pulse(_suspendGuard);
			}
			_drainTask.Dispose();
			base.Dispose(disposing);
		}

		private void Drain()
		{
			ConcurrentQueue<TSource> queue = _queue;
			while (true)
			{
				if (Volatile.Read(ref _disposed))
				{
					TSource result;
					while (queue.TryDequeue(out result))
					{
					}
					return;
				}
				bool num = Volatile.Read(ref _done);
				TSource result2;
				bool flag = queue.TryDequeue(out result2);
				if (num && !flag)
				{
					break;
				}
				if (flag)
				{
					ForwardOnNext(result2);
					if (Interlocked.Decrement(ref _wip) != 0L)
					{
						continue;
					}
				}
				if (Volatile.Read(ref _wip) != 0L || Volatile.Read(ref _disposed))
				{
					continue;
				}
				object suspendGuard = _suspendGuard;
				if (Monitor.TryEnter(suspendGuard))
				{
					if (Volatile.Read(ref _wip) == 0L && !Volatile.Read(ref _disposed))
					{
						Monitor.Wait(suspendGuard);
					}
					Monitor.Exit(suspendGuard);
				}
			}
			Exception error = _error;
			if (error != null)
			{
				ForwardOnError(error);
			}
			else
			{
				ForwardOnCompleted();
			}
		}
	}
	internal interface ISink<in TTarget>
	{
		void ForwardOnNext(TTarget value);

		void ForwardOnCompleted();

		void ForwardOnError(Exception error);
	}
	internal abstract class Sink<TTarget> : ISink<TTarget>, IDisposable
	{
		private SingleAssignmentDisposableValue _upstream;

		private volatile IObserver<TTarget> _observer;

		protected Sink(IObserver<TTarget> observer)
		{
			_observer = observer;
		}

		public void Dispose()
		{
			if (Interlocked.Exchange(ref _observer, NopObserver<TTarget>.Instance) != NopObserver<TTarget>.Instance)
			{
				Dispose(disposing: true);
			}
		}

		protected virtual void Dispose(bool disposing)
		{
			_upstream.Dispose();
		}

		public void ForwardOnNext(TTarget value)
		{
			_observer.OnNext(value);
		}

		public void ForwardOnCompleted()
		{
			_observer.OnCompleted();
			Dispose();
		}

		public void ForwardOnError(Exception error)
		{
			_observer.OnError(error);
			Dispose();
		}

		protected void SetUpstream(IDisposable upstream)
		{
			_upstream.Disposable = upstream;
		}

		protected void DisposeUpstream()
		{
			_upstream.Dispose();
		}
	}
	internal abstract class Sink<TSource, TTarget> : Sink<TTarget>, IObserver<TSource>
	{
		private sealed class @_ : IObserver<TTarget>
		{
			private readonly Sink<TSource, TTarget> _forward;

			public _(Sink<TSource, TTarget> forward)
			{
				_forward = forward;
			}

			public void OnNext(TTarget value)
			{
				_forward.ForwardOnNext(value);
			}

			public void OnError(Exception error)
			{
				_forward.ForwardOnError(error);
			}

			public void OnCompleted()
			{
				_forward.ForwardOnCompleted();
			}
		}

		protected Sink(IObserver<TTarget> observer)
			: base(observer)
		{
		}

		public virtual void Run(IObservable<TSource> source)
		{
			SetUpstream(source.SubscribeSafe(this));
		}

		public abstract void OnNext(TSource value);

		public virtual void OnError(Exception error)
		{
			ForwardOnError(error);
		}

		public virtual void OnCompleted()
		{
			ForwardOnCompleted();
		}

		public IObserver<TTarget> GetForwarder()
		{
			return new @_(this);
		}
	}
	internal static class Stubs<T>
	{
		public static readonly Action<T> Ignore = delegate
		{
		};

		public static readonly Func<T, T> I = (T _) => _;
	}
	internal static class Stubs
	{
		public static readonly Action Nop = delegate
		{
		};

		public static readonly Action<Exception> Throw = delegate(Exception ex)
		{
			ex.Throw();
		};
	}
	internal static class TimerStubs
	{
		public static readonly System.Threading.Timer Never = new System.Threading.Timer(delegate
		{
		});
	}
	internal sealed class SynchronizedObserver<T> : ObserverBase<T>
	{
		private readonly object _gate;

		private readonly IObserver<T> _observer;

		public SynchronizedObserver(IObserver<T> observer, object gate)
		{
			_gate = gate;
			_observer = observer;
		}

		protected override void OnNextCore(T value)
		{
			lock (_gate)
			{
				_observer.OnNext(value);
			}
		}

		protected override void OnErrorCore(Exception exception)
		{
			lock (_gate)
			{
				_observer.OnError(exception);
			}
		}

		protected override void OnCompletedCore()
		{
			lock (_gate)
			{
				_observer.OnCompleted();
			}
		}
	}
	internal abstract class TailRecursiveSink<TSource> : IdentitySink<TSource>
	{
		private readonly Stack<IEnumerator<IObservable<TSource>>> _stack = new Stack<IEnumerator<IObservable<TSource>>>();

		private bool _isDisposed;

		private int _trampoline;

		private IDisposable? _currentSubscription;

		protected TailRecursiveSink(IObserver<TSource> observer)
			: base(observer)
		{
		}

		public void Run(IEnumerable<IObservable<TSource>> sources)
		{
			if (TryGetEnumerator(sources, out IEnumerator<IObservable<TSource>> result))
			{
				_stack.Push(result);
				Drain();
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				DisposeAll();
			}
			base.Dispose(disposing);
		}

		private void Drain()
		{
			if (Interlocked.Increment(ref _trampoline) != 1)
			{
				return;
			}
			do
			{
				IL_000f:
				if (Volatile.Read(ref _isDisposed))
				{
					while (_stack.Count != 0)
					{
						_stack.Pop().Dispose();
					}
					Disposable.Dispose(ref _currentSubscription);
				}
				else if (_stack.Count != 0)
				{
					IEnumerator<IObservable<TSource>> enumerator = _stack.Peek();
					IObservable<TSource> source2 = null;
					try
					{
						if (enumerator.MoveNext())
						{
							source2 = enumerator.Current;
						}
					}
					catch (Exception error)
					{
						enumerator.Dispose();
						ForwardOnError(error);
						Volatile.Write(ref _isDisposed, value: true);
						goto IL_000f;
					}
					IObservable<TSource> observable;
					try
					{
						observable = Unpack<TSource>(source2);
					}
					catch (Exception error2)
					{
						if (!Fail(error2))
						{
							Volatile.Write(ref _isDisposed, value: true);
						}
						goto IL_000f;
					}
					if (observable == null)
					{
						_stack.Pop();
						enumerator.Dispose();
						goto IL_000f;
					}
					IEnumerable<IObservable<TSource>> enumerable = Extract(observable);
					if (enumerable != null)
					{
						if (TryGetEnumerator(enumerable, out IEnumerator<IObservable<TSource>> result))
						{
							_stack.Push(result);
						}
						else
						{
							Volatile.Write(ref _isDisposed, value: true);
						}
						goto IL_000f;
					}
					IDisposable ready = ReadyToken.Ready;
					if (Disposable.TrySetSingle(ref _currentSubscription, ready) != 0)
					{
						goto IL_000f;
					}
					IDisposable disposable = observable.SubscribeSafe(this);
					IDisposable disposable2 = Interlocked.CompareExchange(ref _currentSubscription, disposable, ready);
					if (disposable2 != ready)
					{
						disposable.Dispose();
						if (disposable2 == BooleanDisposable.True)
						{
							goto IL_000f;
						}
					}
				}
				else
				{
					Volatile.Write(ref _isDisposed, value: true);
					Done();
				}
			}
			while (Interlocked.Decrement(ref _trampoline) != 0);
			static IObservable<T>? Unpack<T>(IObservable<T>? source) where T : notnull
			{
				bool flag;
				do
				{
					flag = false;
					if (source is IEvaluatableObservable<T> evaluatableObservable)
					{
						source = evaluatableObservable.Eval();
						flag = true;
					}
				}
				while (flag);
				return source;
			}
		}

		private void DisposeAll()
		{
			Volatile.Write(ref _isDisposed, value: true);
			Drain();
		}

		protected void Recurse()
		{
			if (Disposable.TrySetSerial(ref _currentSubscription, null))
			{
				Drain();
			}
		}

		protected abstract IEnumerable<IObservable<TSource>>? Extract(IObservable<TSource> source);

		private bool TryGetEnumerator(IEnumerable<IObservable<TSource>> sources, [NotNullWhen(true)] out IEnumerator<IObservable<TSource>>? result)
		{
			try
			{
				result = sources.GetEnumerator();
				return true;
			}
			catch (Exception error)
			{
				ForwardOnError(error);
				result = null;
				return false;
			}
		}

		protected virtual void Done()
		{
			ForwardOnCompleted();
		}

		protected virtual bool Fail(Exception error)
		{
			ForwardOnError(error);
			return false;
		}
	}
	internal static class ReadyToken
	{
		private sealed class ReadyDisposable : IDisposable
		{
			public void Dispose()
			{
			}
		}

		internal static readonly IDisposable Ready = new ReadyDisposable();
	}
	public interface IObserver<in TValue, out TResult>
	{
		TResult OnNext(TValue value);

		TResult OnError(Exception exception);

		TResult OnCompleted();
	}
	[Experimental]
	public class ListObservable<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IObservable<object>
	{
		private readonly IDisposable _subscription;

		private readonly AsyncSubject<object> _subject = new AsyncSubject<object>();

		private readonly List<T> _results = new List<T>();

		public T Value
		{
			get
			{
				Wait();
				if (_results.Count == 0)
				{
					throw new InvalidOperationException(Strings_Linq.NO_ELEMENTS);
				}
				return _results[_results.Count - 1];
			}
		}

		public T this[int index]
		{
			get
			{
				Wait();
				return _results[index];
			}
			set
			{
				Wait();
				_results[index] = value;
			}
		}

		public int Count
		{
			get
			{
				Wait();
				return _results.Count;
			}
		}

		public bool IsReadOnly => false;

		public ListObservable(IObservable<T> source)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			_subscription = source.Subscribe(_results.Add, _subject.OnError, _subject.OnCompleted);
		}

		private void Wait()
		{
			_subject.DefaultIfEmpty().Wait();
		}

		public int IndexOf(T item)
		{
			Wait();
			return _results.IndexOf(item);
		}

		public void Insert(int index, T item)
		{
			Wait();
			_results.Insert(index, item);
		}

		public void RemoveAt(int index)
		{
			Wait();
			_results.RemoveAt(index);
		}

		public void Add(T item)
		{
			Wait();
			_results.Add(item);
		}

		public void Clear()
		{
			Wait();
			_results.Clear();
		}

		public bool Contains(T item)
		{
			Wait();
			return _results.Contains(item);
		}

		public void CopyTo(T[] array, int arrayIndex)
		{
			Wait();
			_results.CopyTo(array, arrayIndex);
		}

		public bool Remove(T item)
		{
			Wait();
			return _results.Remove(item);
		}

		public IEnumerator<T> GetEnumerator()
		{
			Wait();
			return _results.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		public IDisposable Subscribe(IObserver<object> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return StableCompositeDisposable.Create(_subscription, _subject.Subscribe(observer));
		}
	}
	[CompilerGenerated]
	internal class NamespaceDoc
	{
	}
	public enum NotificationKind
	{
		OnNext,
		OnError,
		OnCompleted
	}
	[Serializable]
	public abstract class Notification<T> : IEquatable<Notification<T>>
	{
		[Serializable]
		[DebuggerDisplay("OnNext({Value})")]
		internal sealed class OnNextNotification : Notification<T>
		{
			public override T Value { get; }

			public override Exception? Exception => null;

			public override bool HasValue => true;

			public override NotificationKind Kind => NotificationKind.OnNext;

			public OnNextNotification(T value)
			{
				Value = value;
			}

			public override int GetHashCode()
			{
				T value = Value;
				if (value == null)
				{
					return 0;
				}
				return value.GetHashCode();
			}

			public override bool Equals(Notification<T>? other)
			{
				if ((object)this == other)
				{
					return true;
				}
				if ((object)other == null)
				{
					return false;
				}
				if (other.Kind != 0)
				{
					return false;
				}
				return EqualityComparer<T>.Default.Equals(Value, other.Value);
			}

			public override string ToString()
			{
				return string.Format(CultureInfo.CurrentCulture, "OnNext({0})", Value);
			}

			public override void Accept(IObserver<T> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				observer.OnNext(Value);
			}

			public override TResult Accept<TResult>(IObserver<T, TResult> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				return observer.OnNext(Value);
			}

			public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				onNext(Value);
			}

			public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				return onNext(Value);
			}
		}

		[Serializable]
		[DebuggerDisplay("OnError({Exception})")]
		internal sealed class OnErrorNotification : Notification<T>
		{
			public override T Value
			{
				get
				{
					Exception.Throw();
					return default(T);
				}
			}

			public override Exception Exception { get; }

			public override bool HasValue => false;

			public override NotificationKind Kind => NotificationKind.OnError;

			public OnErrorNotification(Exception exception)
			{
				Exception = exception;
			}

			public override int GetHashCode()
			{
				return Exception.GetHashCode();
			}

			public override bool Equals(Notification<T>? other)
			{
				if ((object)this == other)
				{
					return true;
				}
				if ((object)other == null)
				{
					return false;
				}
				if (other.Kind != NotificationKind.OnError)
				{
					return false;
				}
				return object.Equals(Exception, other.Exception);
			}

			public override string ToString()
			{
				return string.Format(CultureInfo.CurrentCulture, "OnError({0})", Exception.GetType().FullName);
			}

			public override void Accept(IObserver<T> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				observer.OnError(Exception);
			}

			public override TResult Accept<TResult>(IObserver<T, TResult> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				return observer.OnError(Exception);
			}

			public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				onError(Exception);
			}

			public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				return onError(Exception);
			}
		}

		[Serializable]
		[DebuggerDisplay("OnCompleted()")]
		internal sealed class OnCompletedNotification : Notification<T>
		{
			internal static readonly Notification<T> Instance = new Notification<T>.OnCompletedNotification();

			public override T Value
			{
				get
				{
					throw new InvalidOperationException(Strings_Core.COMPLETED_NO_VALUE);
				}
			}

			public override Exception? Exception => null;

			public override bool HasValue => false;

			public override NotificationKind Kind => NotificationKind.OnCompleted;

			private OnCompletedNotification()
			{
			}

			public override int GetHashCode()
			{
				return typeof(T).GetHashCode() ^ 0x213E;
			}

			public override bool Equals(Notification<T>? other)
			{
				if ((object)this == other)
				{
					return true;
				}
				if ((object)other == null)
				{
					return false;
				}
				return other.Kind == NotificationKind.OnCompleted;
			}

			public override string ToString()
			{
				return "OnCompleted()";
			}

			public override void Accept(IObserver<T> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				observer.OnCompleted();
			}

			public override TResult Accept<TResult>(IObserver<T, TResult> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				return observer.OnCompleted();
			}

			public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				onCompleted();
			}

			public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				return onCompleted();
			}
		}

		private sealed class NotificationToObservable : ObservableBase<T>
		{
			private readonly IScheduler _scheduler;

			private readonly Notification<T> _parent;

			public NotificationToObservable(IScheduler scheduler, Notification<T> parent)
			{
				_scheduler = scheduler;
				_parent = parent;
			}

			protected override IDisposable SubscribeCore(IObserver<T> observer)
			{
				return _scheduler.ScheduleAction((_parent, observer), delegate((Notification<T> _parent, IObserver<T> observer) state)
				{
					var (notification, observer2) = state;
					notification.Accept(observer2);
					if (notification.Kind == NotificationKind.OnNext)
					{
						observer2.OnCompleted();
					}
				});
			}
		}

		public abstract T Value { get; }

		public abstract bool HasValue { get; }

		public abstract Exception? Exception { get; }

		public abstract NotificationKind Kind { get; }

		protected internal Notification()
		{
		}

		public abstract bool Equals(Notification<T>? other);

		public static bool operator ==(Notification<T> left, Notification<T> right)
		{
			if ((object)left == right)
			{
				return true;
			}
			if ((object)left == null || (object)right == null)
			{
				return false;
			}
			return left.Equals(right);
		}

		public static bool operator !=(Notification<T> left, Notification<T> right)
		{
			return !(left == right);
		}

		public override bool Equals(object? obj)
		{
			return Equals(obj as Notification<T>);
		}

		public abstract void Accept(IObserver<T> observer);

		public abstract TResult Accept<TResult>(IObserver<T, TResult> observer);

		public abstract void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted);

		public abstract TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted);

		public IObservable<T> ToObservable()
		{
			return ToObservable(ImmediateScheduler.Instance);
		}

		public IObservable<T> ToObservable(IScheduler scheduler)
		{
			if (scheduler == null)
			{
				throw new ArgumentNullException("scheduler");
			}
			return new NotificationToObservable(scheduler, this);
		}
	}
	public static class Notification
	{
		public static Notification<T> CreateOnNext<T>(T value)
		{
			return new Notification<T>.OnNextNotification(value);
		}

		public static Notification<T> CreateOnError<T>(Exception error)
		{
			if (error == null)
			{
				throw new ArgumentNullException("error");
			}
			return new Notification<T>.OnErrorNotification(error);
		}

		public static Notification<T> CreateOnCompleted<T>()
		{
			return Notification<T>.OnCompletedNotification.Instance;
		}
	}
	public abstract class ObservableBase<T> : IObservable<T>
	{
		public IDisposable Subscribe(IObserver<T> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			AutoDetachObserver<T> autoDetachObserver = new AutoDetachObserver<T>(observer);
			if (CurrentThreadScheduler.IsScheduleRequired)
			{
				((IScheduler)CurrentThreadScheduler.Instance).ScheduleAction(autoDetachObserver, (Action<AutoDetachObserver<T>>)ScheduledSubscribe);
			}
			else
			{
				try
				{
					autoDetachObserver.SetResource(SubscribeCore(autoDetachObserver));
				}
				catch (Exception error)
				{
					if (!autoDetachObserver.Fail(error))
					{
						throw;
					}
				}
			}
			return autoDetachObserver;
		}

		private void ScheduledSubscribe(AutoDetachObserver<T> autoDetachObserver)
		{
			try
			{
				autoDetachObserver.SetResource(SubscribeCore(autoDetachObserver));
			}
			catch (Exception error)
			{
				if (!autoDetachObserver.Fail(error))
				{
					throw;
				}
			}
		}

		protected abstract IDisposable SubscribeCore(IObserver<T> observer);
	}
	internal class ObservableQueryProvider : IQbservableProvider, IQueryProvider
	{
		private static MethodInfo? _staticAsQueryable;

		private static MethodInfo AsQueryable => _staticAsQueryable ?? (_staticAsQueryable = Qbservable.InfoOf((Expression<Func<object>>)(() => ((IEnumerable<object>)null).AsQueryable())).GetGenericMethodDefinition());

		public IQbservable<TResult> CreateQuery<TResult>(Expression expression)
		{
			if (expression == null)
			{
				throw new ArgumentNullException("expression");
			}
			if (!typeof(IObservable<TResult>).IsAssignableFrom(expression.Type))
			{
				throw new ArgumentException(Strings_Providers.INVALID_TREE_TYPE, "expression");
			}
			return new ObservableQuery<TResult>(expression);
		}

		IQueryable<TElement> IQueryProvider.CreateQuery<TElement>(Expression expression)
		{
			if (!(expression is MethodCallExpression methodCallExpression) || methodCallExpression.Method.DeclaringType != typeof(Qbservable) || methodCallExpression.Method.Name != "ToQueryable")
			{
				throw new ArgumentException(Strings_Providers.EXPECTED_TOQUERYABLE_METHODCALL, "expression");
			}
			Expression arg = methodCallExpression.Arguments[0];
			return Expression.Lambda<Func<IQueryable<TElement>>>(Expression.Call(AsQueryable.MakeGenericMethod(typeof(TElement)), Expression.Call(typeof(Observable).GetMethod("ToEnumerable").MakeGenericMethod(typeof(TElement)), arg)), Array.Empty<ParameterExpression>()).Compile()();
		}

		IQueryable IQueryProvider.CreateQuery(Expression expression)
		{
			throw new NotImplementedException();
		}

		TResult IQueryProvider.Execute<TResult>(Expression expression)
		{
			throw new NotImplementedException();
		}

		object IQueryProvider.Execute(Expression expression)
		{
			throw new NotImplementedException();
		}
	}
	internal class ObservableQuery
	{
		protected object? _source;

		protected Expression _expression;

		public object? Source => _source;

		public Expression Expression => _expression;

		public ObservableQuery(object source)
		{
			_source = source;
			_expression = System.Linq.Expressions.Expression.Constant(this);
		}

		public ObservableQuery(Expression expression)
		{
			_expression = expression;
		}
	}
	internal class ObservableQuery<TSource> : ObservableQuery, IQbservable<TSource>, IQbservable, IObservable<TSource>
	{
		private class ObservableRewriter : ExpressionVisitor
		{
			private class Lazy<T>
			{
				private readonly Func<T> _factory;

				private T? _value;

				private bool _initialized;

				public T Value
				{
					get
					{
						lock (_factory)
						{
							if (!_initialized)
							{
								_value = _factory();
								_initialized = true;
							}
						}
						return _value;
					}
				}

				public Lazy(Func<T> factory)
				{
					_factory = factory;
				}
			}

			private static readonly Lazy<ILookup<string, MethodInfo>> ObservableMethods = new Lazy<ILookup<string, MethodInfo>>(() => GetMethods(typeof(Observable)));

			protected override Expression VisitConstant(ConstantExpression node)
			{
				if (node.Value is ObservableQuery observableQuery)
				{
					object source = observableQuery.Source;
					if (source != null)
					{
						return System.Linq.Expressions.Expression.Constant(source);
					}
					return Visit(observableQuery.Expression);
				}
				return node;
			}

			protected override Expression VisitMethodCall(MethodCallExpression node)
			{
				MethodInfo method = node.Method;
				if (method.DeclaringType?.BaseType == typeof(QueryablePattern))
				{
					if (method.Name == "Then")
					{
						return System.Linq.Expressions.Expression.Call(Visit(node.Object), arguments: node.Arguments.Select((Expression arg) => Unquote(Visit(arg))).ToArray(), methodName: method.Name, typeArguments: method.GetGenericArguments());
					}
					if (method.Name == "And")
					{
						return System.Linq.Expressions.Expression.Call(Visit(node.Object), arguments: node.Arguments.Select((Expression arg) => Visit(arg)).ToArray(), methodName: method.Name, typeArguments: method.GetGenericArguments());
					}
				}
				else
				{
					IEnumerable<Expression> enumerable = node.Arguments.AsEnumerable();
					bool flag = false;
					ParameterInfo parameterInfo = method.GetParameters().FirstOrDefault();
					if (parameterInfo != null)
					{
						Type parameterType = parameterInfo.ParameterType;
						if (parameterType == typeof(IQbservableProvider))
						{
							flag = true;
							if (!(System.Linq.Expressions.Expression.Lambda<Func<IQbservableProvider>>(Visit(node.Arguments[0]), Array.Empty<ParameterExpression>()).Compile()() is ObservableQueryProvider))
							{
								return node;
							}
							enumerable = enumerable.Skip(1);
						}
						else if (typeof(IQbservable).IsAssignableFrom(parameterType))
						{
							flag = true;
						}
					}
					if (flag)
					{
						IList<Expression> arguments3 = VisitQbservableOperatorArguments(method, enumerable);
						return FindObservableMethod(method, arguments3);
					}
				}
				return base.VisitMethodCall(node);
			}

			protected override Expression VisitLambda<T>(Expression<T> node)
			{
				return node;
			}

			private IList<Expression> VisitQbservableOperatorArguments(MethodInfo method, IEnumerable<Expression> arguments)
			{
				if (method.Name == "When")
				{
					Expression expression = arguments.Last();
					if (expression.NodeType == ExpressionType.NewArrayInit)
					{
						NewArrayExpression newArrayExpression = (NewArrayExpression)expression;
						List<Expression> list = new List<Expression>();
						list.Add(System.Linq.Expressions.Expression.NewArrayInit(typeof(Plan<>).MakeGenericType(method.GetGenericArguments()[0]), newArrayExpression.Expressions.Select((Expression param) => Visit(param))));
						return list;
					}
				}
				return arguments.Select((Expression arg) => Visit(arg)).ToList();
			}

			private static MethodCallExpression FindObservableMethod(MethodInfo method, IList<Expression> arguments)
			{
				IList<Expression> arguments2 = arguments;
				Type type;
				ILookup<string, MethodInfo> lookup;
				if (method.DeclaringType == typeof(Qbservable))
				{
					type = typeof(Observable);
					lookup = ObservableMethods.Value;
				}
				else
				{
					type = method.DeclaringType;
					if (type.IsDefined(typeof(LocalQueryMethodImplementationTypeAttribute), inherit: false))
					{
						type = ((LocalQueryMethodImplementationTypeAttribute)type.GetCustomAttributes(typeof(LocalQueryMethodImplementationTypeAttribute), inherit: false)[0]).TargetType;
					}
					lookup = GetMethods(type);
				}
				Type[] typeArgs = (method.IsGenericMethod ? method.GetGenericArguments() : null);
				MethodInfo methodInfo = lookup[method.Name].FirstOrDefault((MethodInfo candidateMethod) => ArgsMatch(candidateMethod, arguments2, typeArgs));
				if (methodInfo == null)
				{
					throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Providers.NO_MATCHING_METHOD_FOUND, method.Name, type.Name));
				}
				if (typeArgs != null)
				{
					methodInfo = methodInfo.MakeGenericMethod(typeArgs);
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				int i = 0;
				for (int num = parameters.Length; i < num; i++)
				{
					arguments2[i] = Unquote(arguments2[i]);
				}
				return System.Linq.Expressions.Expression.Call(null, methodInfo, arguments2);
			}

			private static ILookup<string, MethodInfo> GetMethods(Type type)
			{
				return type.GetMethods(BindingFlags.Static | BindingFlags.Public).ToLookup((MethodInfo m) => m.Name);
			}

			private static bool ArgsMatch(MethodInfo method, IList<Expression> arguments, Type[]? typeArgs)
			{
				ParameterInfo[] parameters = method.GetParameters();
				if (parameters.Length != arguments.Count)
				{
					return false;
				}
				if (!method.IsGenericMethod && typeArgs != null && typeArgs.Length != 0)
				{
					return false;
				}
				if (method.IsGenericMethodDefinition)
				{
					if (typeArgs == null)
					{
						return false;
					}
					if (method.GetGenericArguments().Length != typeArgs.Length)
					{
						return false;
					}
					parameters = method.MakeGenericMethod(typeArgs).GetParameters();
				}
				int i = 0;
				for (int count = arguments.Count; i < count; i++)
				{
					Type parameterType = parameters[i].ParameterType;
					Expression expression = arguments[i];
					if (!parameterType.IsAssignableFrom(expression.Type))
					{
						expression = Unquote(expression);
						if (!parameterType.IsAssignableFrom(expression.Type))
						{
							return false;
						}
					}
				}
				return true;
			}

			private static Expression Unquote(Expression expression)
			{
				while (expression.NodeType == ExpressionType.Quote)
				{
					expression = ((UnaryExpression)expression).Operand;
				}
				return expression;
			}
		}

		public Type ElementType => typeof(TSource);

		public IQbservableProvider Provider => Qbservable.Provider;

		internal ObservableQuery(IObservable<TSource> source)
			: base(source)
		{
		}

		internal ObservableQuery(Expression expression)
			: base(expression)
		{
		}

		public IDisposable Subscribe(IObserver<TSource> observer)
		{
			if (_source == null)
			{
				Expression<Func<IObservable<TSource>>> expression = System.Linq.Expressions.Expression.Lambda<Func<IObservable<TSource>>>(new ObservableRewriter().Visit(_expression), Array.Empty<ParameterExpression>());
				_source = expression.Compile()();
			}
			return ((IObservable<TSource>)_source).Subscribe(observer);
		}

		public override string? ToString()
		{
			if (_expression is ConstantExpression constantExpression && constantExpression.Value == this)
			{
				if (_source != null)
				{
					return _source.ToString();
				}
				return "null";
			}
			return _expression.ToString();
		}
	}
	public static class Observer
	{
		private class AnonymousProgress<T> : IProgress<T>
		{
			private readonly Action<T> _progress;

			public AnonymousProgress(Action<T> progress)
			{
				_progress = progress;
			}

			public void Report(T value)
			{
				_progress(value);
			}
		}

		public static IObserver<T> ToObserver<T>(this Action<Notification<T>> handler)
		{
			Action<Notification<T>> handler2 = handler;
			if (handler2 == null)
			{
				throw new ArgumentNullException("handler");
			}
			return new AnonymousObserver<T>(delegate(T x)
			{
				handler2(Notification.CreateOnNext(x));
			}, delegate(Exception exception)
			{
				handler2(Notification.CreateOnError<T>(exception));
			}, delegate
			{
				handler2(Notification.CreateOnCompleted<T>());
			});
		}

		public static Action<Notification<T>> ToNotifier<T>(this IObserver<T> observer)
		{
			IObserver<T> observer2 = observer;
			if (observer2 == null)
			{
				throw new ArgumentNullException("observer");
			}
			return delegate(Notification<T> n)
			{
				n.Accept(observer2);
			};
		}

		public static IObserver<T> Create<T>(Action<T> onNext)
		{
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			return new AnonymousObserver<T>(onNext);
		}

		public static IObserver<T> Create<T>(Action<T> onNext, Action<Exception> onError)
		{
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onError == null)
			{
				throw new ArgumentNullException("onError");
			}
			return new AnonymousObserver<T>(onNext, onError);
		}

		public static IObserver<T> Create<T>(Action<T> onNext, Action onCompleted)
		{
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onCompleted == null)
			{
				throw new ArgumentNullException("onCompleted");
			}
			return new AnonymousObserver<T>(onNext, onCompleted);
		}

		public static IObserver<T> Create<T>(Action<T> onNext, Action<Exception> onError, Action onCompleted)
		{
			if (onNext == null)
			{
				throw new ArgumentNullException("onNext");
			}
			if (onError == null)
			{
				throw new ArgumentNullException("onError");
			}
			if (onCompleted == null)
			{
				throw new ArgumentNullException("onCompleted");
			}
			return new AnonymousObserver<T>(onNext, onError, onCompleted);
		}

		public static IObserver<T> AsObserver<T>(this IObserver<T> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return new AnonymousObserver<T>(observer.OnNext, observer.OnError, observer.OnCompleted);
		}

		public static IObserver<T> Checked<T>(this IObserver<T> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return new CheckedObserver<T>(observer);
		}

		public static IObserver<T> Synchronize<T>(IObserver<T> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return new SynchronizedObserver<T>(observer, new object());
		}

		public static IObserver<T> Synchronize<T>(IObserver<T> observer, bool preventReentrancy)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			if (preventReentrancy)
			{
				return new AsyncLockObserver<T>(observer, new AsyncLock());
			}
			return new SynchronizedObserver<T>(observer, new object());
		}

		public static IObserver<T> Synchronize<T>(IObserver<T> observer, object gate)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			if (gate == null)
			{
				throw new ArgumentNullException("gate");
			}
			return new SynchronizedObserver<T>(observer, gate);
		}

		public static IObserver<T> Synchronize<T>(IObserver<T> observer, AsyncLock asyncLock)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			if (asyncLock == null)
			{
				throw new ArgumentNullException("asyncLock");
			}
			return new AsyncLockObserver<T>(observer, asyncLock);
		}

		public static IObserver<T> NotifyOn<T>(this IObserver<T> observer, IScheduler scheduler)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			if (scheduler == null)
			{
				throw new ArgumentNullException("scheduler");
			}
			return new ObserveOnObserver<T>(scheduler, observer);
		}

		public static IObserver<T> NotifyOn<T>(this IObserver<T> observer, SynchronizationContext context)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			if (context == null)
			{
				throw new ArgumentNullException("context");
			}
			return new ObserveOnObserver<T>(new SynchronizationContextScheduler(context), observer);
		}

		public static IProgress<T> ToProgress<T>(this IObserver<T> observer)
		{
			if (observer == null)
			{
				throw new ArgumentNullException("observer");
			}
			return new AnonymousProgress<T>(observer.OnNex

lethalstreams-lib/System.Text.Encodings.Web.dll

Decompiled 2 months ago
using System;
using System.Buffers;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
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.Encodings.Web;
using System.Text.Unicode;
using System.Threading;
using FxResources.System.Text.Encodings.Web;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: CLSCompliant(true)]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: AssemblyDefaultAlias("System.Text.Encodings.Web")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Provides types for encoding and escaping strings for use in JavaScript, HyperText Markup Language (HTML), and uniform resource locators (URL).\r\n\r\nCommonly Used Types:\r\nSystem.Text.Encodings.Web.HtmlEncoder\r\nSystem.Text.Encodings.Web.UrlEncoder\r\nSystem.Text.Encodings.Web.JavaScriptEncoder")]
[assembly: AssemblyFileVersion("6.0.21.52210")]
[assembly: AssemblyInformationalVersion("6.0.0+4822e3c3aa77eb82b2fb33c9321f923cf11ddde6")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Text.Encodings.Web")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("6.0.0.0")]
[module: UnverifiableCode]
[module: System.Runtime.CompilerServices.NullablePublicOnly(false)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class NullablePublicOnlyAttribute : Attribute
	{
		public readonly bool IncludesInternals;

		public NullablePublicOnlyAttribute(bool P_0)
		{
			IncludesInternals = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = P_0;
		}
	}
}
namespace FxResources.System.Text.Encodings.Web
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class HexConverter
	{
		public enum Casing : uint
		{
			Upper = 0u,
			Lower = 8224u
		}

		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 void ToBytesBuffer(byte value, Span<byte> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
		{
			uint num = (uint)(((value & 0xF0) << 4) + (value & 0xF) - 35209);
			uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
			buffer[startingIndex + 1] = (byte)num2;
			buffer[startingIndex] = (byte)(num2 >> 8);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void ToCharsBuffer(byte value, Span<char> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
		{
			uint num = (uint)(((value & 0xF0) << 4) + (value & 0xF) - 35209);
			uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
			buffer[startingIndex + 1] = (char)(num2 & 0xFFu);
			buffer[startingIndex] = (char)(num2 >> 8);
		}

		public static void EncodeToUtf16(ReadOnlySpan<byte> bytes, Span<char> chars, Casing casing = Casing.Upper)
		{
			for (int i = 0; i < bytes.Length; i++)
			{
				ToCharsBuffer(bytes[i], chars, i * 2, casing);
			}
		}

		public static string ToString(ReadOnlySpan<byte> bytes, Casing casing = Casing.Upper)
		{
			Span<char> span = default(Span<char>);
			if (bytes.Length > 16)
			{
				char[] array = new char[bytes.Length * 2];
				span = array.AsSpan();
			}
			else
			{
				span = stackalloc char[bytes.Length * 2];
			}
			int num = 0;
			ReadOnlySpan<byte> readOnlySpan = bytes;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				byte value = readOnlySpan[i];
				ToCharsBuffer(value, span, num, casing);
				num += 2;
			}
			return span.ToString();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static char ToCharUpper(int value)
		{
			value &= 0xF;
			value += 48;
			if (value > 57)
			{
				value += 7;
			}
			return (char)value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static char ToCharLower(int value)
		{
			value &= 0xF;
			value += 48;
			if (value > 57)
			{
				value += 39;
			}
			return (char)value;
		}

		public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes)
		{
			int charsProcessed;
			return TryDecodeFromUtf16(chars, bytes, out charsProcessed);
		}

		public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes, out int charsProcessed)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			while (num2 < bytes.Length)
			{
				num3 = FromChar(chars[num + 1]);
				num4 = FromChar(chars[num]);
				if ((num3 | num4) == 255)
				{
					break;
				}
				bytes[num2++] = (byte)((num4 << 4) | num3);
				num += 2;
			}
			if (num3 == 255)
			{
				num++;
			}
			charsProcessed = num;
			return (num3 | num4) != 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromChar(int c)
		{
			if (c < CharToHexLookup.Length)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromUpperChar(int c)
		{
			if (c <= 71)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromLowerChar(int c)
		{
			switch (c)
			{
			case 48:
			case 49:
			case 50:
			case 51:
			case 52:
			case 53:
			case 54:
			case 55:
			case 56:
			case 57:
				return c - 48;
			case 97:
			case 98:
			case 99:
			case 100:
			case 101:
			case 102:
				return c - 97 + 10;
			default:
				return 255;
			}
		}

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

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexUpperChar(int c)
		{
			if ((uint)(c - 48) > 9u)
			{
				return (uint)(c - 65) <= 5u;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexLowerChar(int c)
		{
			if ((uint)(c - 48) > 9u)
			{
				return (uint)(c - 97) <= 5u;
			}
			return true;
		}
	}
	internal static class SR
	{
		private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled;

		private static ResourceManager s_resourceManager;

		internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR)));

		internal static string TextEncoderDoesNotImplementMaxOutputCharsPerInputChar => GetResourceString("TextEncoderDoesNotImplementMaxOutputCharsPerInputChar");

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

		internal static string GetResourceString(string resourceKey)
		{
			if (UsingResourceKeys())
			{
				return resourceKey;
			}
			string result = null;
			try
			{
				result = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			return result;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string resourceString = GetResourceString(resourceKey);
			if (!(resourceKey == resourceString) && resourceString != null)
			{
				return resourceString;
			}
			return defaultString;
		}

		internal static string Format(string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(resourceFormat, p1);
		}

		internal static string Format(string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(resourceFormat, p1, p2);
		}

		internal static string Format(string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(resourceFormat, p1, p2, p3);
		}

		internal static string Format(string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(resourceFormat, args);
			}
			return resourceFormat;
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(provider, resourceFormat, p1);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(provider, resourceFormat, p1, p2);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(provider, resourceFormat, p1, p2, p3);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(provider, resourceFormat, args);
			}
			return resourceFormat;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace System.Numerics
{
	internal static class BitOperations
	{
		private static ReadOnlySpan<byte> Log2DeBruijn => new byte[32]
		{
			0, 9, 1, 10, 13, 21, 2, 29, 11, 14,
			16, 18, 22, 25, 3, 30, 8, 12, 20, 28,
			15, 17, 24, 7, 19, 27, 23, 6, 26, 5,
			4, 31
		};

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int Log2(uint value)
		{
			return Log2SoftwareFallback(value | 1u);
		}

		private static int Log2SoftwareFallback(uint value)
		{
			value |= value >> 1;
			value |= value >> 2;
			value |= value >> 4;
			value |= value >> 8;
			value |= value >> 16;
			return System.Runtime.CompilerServices.Unsafe.AddByteOffset<byte>(ref MemoryMarshal.GetReference(Log2DeBruijn), (IntPtr)(nint)(value * 130329821 >> 27));
		}
	}
}
namespace System.Text
{
	internal static class UnicodeDebug
	{
		[Conditional("DEBUG")]
		internal static void AssertIsBmpCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsBmpCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsHighSurrogateCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsHighSurrogateCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsLowSurrogateCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsLowSurrogateCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsValidCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsValidCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsValidScalar(uint scalarValue)
		{
			System.Text.UnicodeUtility.IsValidUnicodeScalar(scalarValue);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsValidSupplementaryPlaneScalar(uint scalarValue)
		{
			if (System.Text.UnicodeUtility.IsValidUnicodeScalar(scalarValue))
			{
				System.Text.UnicodeUtility.IsBmpCodePoint(scalarValue);
			}
		}

		private static string ToHexString(uint codePoint)
		{
			return FormattableString.Invariant($"U+{codePoint:X4}");
		}
	}
	internal static class UnicodeUtility
	{
		public const uint ReplacementChar = 65533u;

		public static int GetPlane(uint codePoint)
		{
			return (int)(codePoint >> 16);
		}

		public static uint GetScalarFromUtf16SurrogatePair(uint highSurrogateCodePoint, uint lowSurrogateCodePoint)
		{
			return (highSurrogateCodePoint << 10) + lowSurrogateCodePoint - 56613888;
		}

		public static int GetUtf16SequenceLength(uint value)
		{
			value -= 65536;
			value += 33554432;
			value >>= 24;
			return (int)value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void GetUtf16SurrogatesFromSupplementaryPlaneScalar(uint value, out char highSurrogateCodePoint, out char lowSurrogateCodePoint)
		{
			highSurrogateCodePoint = (char)(value + 56557568 >> 10);
			lowSurrogateCodePoint = (char)((value & 0x3FF) + 56320);
		}

		public static int GetUtf8SequenceLength(uint value)
		{
			int num = (int)(value - 2048) >> 31;
			value ^= 0xF800u;
			value -= 63616;
			value += 67108864;
			value >>= 24;
			return (int)value + num * 2;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsAsciiCodePoint(uint value)
		{
			return value <= 127;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsBmpCodePoint(uint value)
		{
			return value <= 65535;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHighSurrogateCodePoint(uint value)
		{
			return IsInRangeInclusive(value, 55296u, 56319u);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsInRangeInclusive(uint value, uint lowerBound, uint upperBound)
		{
			return value - lowerBound <= upperBound - lowerBound;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLowSurrogateCodePoint(uint value)
		{
			return IsInRangeInclusive(value, 56320u, 57343u);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsSurrogateCodePoint(uint value)
		{
			return IsInRangeInclusive(value, 55296u, 57343u);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsValidCodePoint(uint codePoint)
		{
			return codePoint <= 1114111;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsValidUnicodeScalar(uint value)
		{
			return ((value - 1114112) ^ 0xD800) >= 4293855232u;
		}
	}
	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 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.AsSpan().CopyTo(_chars.Slice(index));
				_pos += length;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Append(char c)
		{
			int pos = _pos;
			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.AsSpan().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)
		{
			int pos = _pos;
			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(ReadOnlySpan<char> value)
		{
			int pos = _pos;
			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)
		{
			char[] array = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)(_chars.Length * 2)));
			_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);
			}
		}
	}
	internal readonly struct Rune
	{
		private const int MaxUtf16CharsPerRune = 2;

		private const char HighSurrogateStart = '\ud800';

		private const char LowSurrogateStart = '\udc00';

		private const int HighSurrogateRange = 1023;

		private readonly uint _value;

		public bool IsAscii => System.Text.UnicodeUtility.IsAsciiCodePoint(_value);

		public bool IsBmp => System.Text.UnicodeUtility.IsBmpCodePoint(_value);

		public static Rune ReplacementChar => UnsafeCreate(65533u);

		public int Utf16SequenceLength => System.Text.UnicodeUtility.GetUtf16SequenceLength(_value);

		public int Value => (int)_value;

		public Rune(uint value)
		{
			if (!System.Text.UnicodeUtility.IsValidUnicodeScalar(value))
			{
				ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value);
			}
			_value = value;
		}

		public Rune(int value)
			: this((uint)value)
		{
		}

		private Rune(uint scalarValue, bool unused)
		{
			_value = scalarValue;
		}

		public static bool operator ==(Rune left, Rune right)
		{
			return left._value == right._value;
		}

		public static bool operator !=(Rune left, Rune right)
		{
			return left._value != right._value;
		}

		public static bool IsControl(Rune value)
		{
			return ((value._value + 1) & 0xFFFFFF7Fu) <= 32;
		}

		public static OperationStatus DecodeFromUtf16(ReadOnlySpan<char> source, out Rune result, out int charsConsumed)
		{
			if (!source.IsEmpty)
			{
				char c = source[0];
				if (TryCreate(c, out result))
				{
					charsConsumed = 1;
					return OperationStatus.Done;
				}
				if (1u < (uint)source.Length)
				{
					char lowSurrogate = source[1];
					if (TryCreate(c, lowSurrogate, out result))
					{
						charsConsumed = 2;
						return OperationStatus.Done;
					}
				}
				else if (char.IsHighSurrogate(c))
				{
					goto IL_004c;
				}
				charsConsumed = 1;
				result = ReplacementChar;
				return OperationStatus.InvalidData;
			}
			goto IL_004c;
			IL_004c:
			charsConsumed = source.Length;
			result = ReplacementChar;
			return OperationStatus.NeedMoreData;
		}

		public static OperationStatus DecodeFromUtf8(ReadOnlySpan<byte> source, out Rune result, out int bytesConsumed)
		{
			int num = 0;
			uint num2;
			if ((uint)num < (uint)source.Length)
			{
				num2 = source[num];
				if (System.Text.UnicodeUtility.IsAsciiCodePoint(num2))
				{
					goto IL_0021;
				}
				if (System.Text.UnicodeUtility.IsInRangeInclusive(num2, 194u, 244u))
				{
					num2 = num2 - 194 << 6;
					num++;
					if ((uint)num >= (uint)source.Length)
					{
						goto IL_0163;
					}
					int num3 = (sbyte)source[num];
					if (num3 < -64)
					{
						num2 += (uint)num3;
						num2 += 128;
						num2 += 128;
						if (num2 < 2048)
						{
							goto IL_0021;
						}
						if (System.Text.UnicodeUtility.IsInRangeInclusive(num2, 2080u, 3343u) && !System.Text.UnicodeUtility.IsInRangeInclusive(num2, 2912u, 2943u) && !System.Text.UnicodeUtility.IsInRangeInclusive(num2, 3072u, 3087u))
						{
							num++;
							if ((uint)num >= (uint)source.Length)
							{
								goto IL_0163;
							}
							num3 = (sbyte)source[num];
							if (num3 < -64)
							{
								num2 <<= 6;
								num2 += (uint)num3;
								num2 += 128;
								num2 -= 131072;
								if (num2 > 65535)
								{
									num++;
									if ((uint)num >= (uint)source.Length)
									{
										goto IL_0163;
									}
									num3 = (sbyte)source[num];
									if (num3 >= -64)
									{
										goto IL_0153;
									}
									num2 <<= 6;
									num2 += (uint)num3;
									num2 += 128;
									num2 -= 4194304;
								}
								goto IL_0021;
							}
						}
					}
				}
				else
				{
					num = 1;
				}
				goto IL_0153;
			}
			goto IL_0163;
			IL_0021:
			bytesConsumed = num + 1;
			result = UnsafeCreate(num2);
			return OperationStatus.Done;
			IL_0153:
			bytesConsumed = num;
			result = ReplacementChar;
			return OperationStatus.InvalidData;
			IL_0163:
			bytesConsumed = num;
			result = ReplacementChar;
			return OperationStatus.NeedMoreData;
		}

		public override bool Equals([NotNullWhen(true)] object obj)
		{
			if (obj is Rune other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Rune other)
		{
			return this == other;
		}

		public override int GetHashCode()
		{
			return Value;
		}

		public static bool TryCreate(char ch, out Rune result)
		{
			if (!System.Text.UnicodeUtility.IsSurrogateCodePoint(ch))
			{
				result = UnsafeCreate(ch);
				return true;
			}
			result = default(Rune);
			return false;
		}

		public static bool TryCreate(char highSurrogate, char lowSurrogate, out Rune result)
		{
			uint num = (uint)(highSurrogate - 55296);
			uint num2 = (uint)(lowSurrogate - 56320);
			if ((num | num2) <= 1023)
			{
				result = UnsafeCreate((uint)((int)(num << 10) + (lowSurrogate - 56320) + 65536));
				return true;
			}
			result = default(Rune);
			return false;
		}

		public bool TryEncodeToUtf16(Span<char> destination, out int charsWritten)
		{
			if (destination.Length >= 1)
			{
				if (IsBmp)
				{
					destination[0] = (char)_value;
					charsWritten = 1;
					return true;
				}
				if (destination.Length >= 2)
				{
					System.Text.UnicodeUtility.GetUtf16SurrogatesFromSupplementaryPlaneScalar(_value, out destination[0], out destination[1]);
					charsWritten = 2;
					return true;
				}
			}
			charsWritten = 0;
			return false;
		}

		public bool TryEncodeToUtf8(Span<byte> destination, out int bytesWritten)
		{
			if (destination.Length >= 1)
			{
				if (IsAscii)
				{
					destination[0] = (byte)_value;
					bytesWritten = 1;
					return true;
				}
				if (destination.Length >= 2)
				{
					if (_value <= 2047)
					{
						destination[0] = (byte)(_value + 12288 >> 6);
						destination[1] = (byte)((_value & 0x3F) + 128);
						bytesWritten = 2;
						return true;
					}
					if (destination.Length >= 3)
					{
						if (_value <= 65535)
						{
							destination[0] = (byte)(_value + 917504 >> 12);
							destination[1] = (byte)(((_value & 0xFC0) >> 6) + 128);
							destination[2] = (byte)((_value & 0x3F) + 128);
							bytesWritten = 3;
							return true;
						}
						if (destination.Length >= 4)
						{
							destination[0] = (byte)(_value + 62914560 >> 18);
							destination[1] = (byte)(((_value & 0x3F000) >> 12) + 128);
							destination[2] = (byte)(((_value & 0xFC0) >> 6) + 128);
							destination[3] = (byte)((_value & 0x3F) + 128);
							bytesWritten = 4;
							return true;
						}
					}
				}
			}
			bytesWritten = 0;
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static Rune UnsafeCreate(uint scalarValue)
		{
			return new Rune(scalarValue, unused: false);
		}
	}
}
namespace System.Text.Unicode
{
	internal static class UnicodeHelpers
	{
		internal const int UNICODE_LAST_CODEPOINT = 1114111;

		private static ReadOnlySpan<byte> DefinedCharsBitmapSpan => new byte[8192]
		{
			0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 127, 0, 0, 0, 0,
			254, 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, 252, 240, 215, 255, 255, 251, 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, 254, 255, 255, 255,
			127, 254, 255, 255, 255, 255, 255, 231, 254, 255,
			255, 255, 255, 255, 255, 0, 255, 255, 255, 135,
			31, 0, 255, 255, 255, 223, 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, 191, 255, 255, 255, 255,
			255, 255, 255, 231, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 3, 0, 255, 255,
			255, 255, 255, 255, 255, 231, 255, 255, 255, 255,
			255, 63, 255, 127, 255, 255, 255, 79, 255, 7,
			0, 0, 0, 0, 0, 0, 255, 255, 223, 255,
			255, 0, 248, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 239, 159, 249, 255, 255, 253,
			197, 243, 159, 121, 128, 176, 207, 255, 255, 127,
			238, 135, 249, 255, 255, 253, 109, 211, 135, 57,
			2, 94, 192, 255, 127, 0, 238, 191, 251, 255,
			255, 253, 237, 243, 191, 59, 1, 0, 207, 255,
			3, 254, 238, 159, 249, 255, 255, 253, 237, 243,
			159, 57, 224, 176, 207, 255, 255, 0, 236, 199,
			61, 214, 24, 199, 255, 195, 199, 61, 129, 0,
			192, 255, 255, 7, 255, 223, 253, 255, 255, 253,
			255, 227, 223, 61, 96, 7, 207, 255, 128, 255,
			255, 223, 253, 255, 255, 253, 239, 243, 223, 61,
			96, 64, 207, 255, 6, 0, 255, 223, 253, 255,
			255, 255, 255, 255, 223, 253, 240, 255, 207, 255,
			255, 255, 238, 255, 127, 252, 255, 255, 251, 47,
			127, 132, 95, 255, 192, 255, 28, 0, 254, 255,
			255, 255, 255, 255, 255, 135, 255, 255, 255, 15,
			0, 0, 0, 0, 214, 247, 255, 255, 175, 255,
			255, 63, 95, 63, 255, 243, 0, 0, 0, 0,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 254,
			255, 255, 255, 31, 254, 255, 255, 255, 255, 254,
			255, 255, 255, 223, 255, 223, 255, 7, 0, 0,
			0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 191, 32, 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, 61, 127, 61, 255, 255,
			255, 255, 255, 61, 255, 255, 255, 255, 61, 127,
			61, 255, 127, 255, 255, 255, 255, 255, 255, 255,
			61, 255, 255, 255, 255, 255, 255, 255, 255, 231,
			255, 255, 255, 31, 255, 255, 255, 3, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 63, 63,
			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,
			254, 255, 255, 31, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 1, 255, 223, 31, 0,
			255, 255, 127, 0, 255, 255, 15, 0, 255, 223,
			13, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 63, 255, 3, 255, 3, 255, 127,
			255, 3, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 1, 255, 255, 255, 255, 255, 7,
			255, 255, 255, 255, 255, 255, 255, 255, 63, 0,
			255, 255, 255, 127, 255, 15, 255, 15, 241, 255,
			255, 255, 255, 63, 31, 0, 255, 255, 255, 255,
			255, 15, 255, 255, 255, 3, 255, 199, 255, 255,
			255, 255, 255, 255, 255, 207, 255, 255, 255, 255,
			255, 255, 255, 127, 255, 255, 255, 159, 255, 3,
			255, 3, 255, 63, 255, 255, 1, 0, 0, 0,
			0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 15, 255, 255, 255, 255, 255, 31,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 15, 240, 255, 255, 255, 255,
			255, 255, 255, 248, 255, 227, 255, 255, 255, 255,
			255, 255, 255, 1, 255, 255, 255, 255, 255, 231,
			255, 0, 255, 255, 255, 255, 255, 7, 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, 251,
			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, 63, 63, 255, 255, 255, 255,
			63, 63, 255, 170, 255, 255, 255, 63, 255, 255,
			255, 255, 255, 255, 223, 255, 223, 255, 207, 239,
			255, 255, 220, 127, 0, 248, 255, 255, 255, 124,
			255, 255, 255, 255, 255, 127, 223, 255, 243, 255,
			255, 127, 255, 31, 255, 255, 255, 255, 0, 0,
			255, 255, 255, 255, 1, 0, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 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, 127, 0, 0, 0,
			255, 7, 0, 0, 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, 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,
			207, 255, 255, 255, 191, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 127, 255, 255, 255, 255, 255, 127,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 15, 254,
			255, 255, 255, 255, 191, 32, 255, 255, 255, 255,
			255, 255, 255, 128, 1, 128, 255, 255, 127, 0,
			127, 127, 127, 127, 127, 127, 127, 127, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 7, 0, 0, 0, 0, 0, 255, 255,
			255, 251, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 15, 0, 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,
			63, 0, 0, 0, 255, 15, 254, 255, 255, 255,
			255, 255, 255, 255, 254, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 127, 254, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 224, 255,
			255, 255, 255, 255, 254, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 127, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 15, 0, 255, 255,
			255, 255, 255, 127, 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, 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,
			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, 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, 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, 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, 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, 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, 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, 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, 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, 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,
			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, 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, 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, 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, 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, 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, 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, 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, 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, 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,
			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, 31,
			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, 31, 255, 255, 255, 255,
			255, 255, 127, 0, 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, 15, 0, 0,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 252, 7,
			0, 0, 0, 0, 224, 255, 255, 255, 255, 255,
			255, 31, 255, 3, 255, 255, 255, 255, 255, 255,
			255, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			63, 192, 255, 3, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 15, 128,
			255, 255, 255, 31, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 191, 255, 195, 255, 255, 255, 127,
			255, 255, 255, 255, 255, 255, 127, 0, 255, 63,
			255, 243, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 7, 0, 0, 248, 255, 255,
			127, 0, 126, 126, 126, 0, 127, 127, 255, 255,
			255, 255, 255, 255, 255, 15, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 63, 255, 3, 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, 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,
			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, 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, 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, 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, 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, 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, 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, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			15, 0, 255, 255, 127, 248, 255, 255, 255, 255,
			255, 15, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 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, 63, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 3, 0, 0,
			0, 0, 127, 0, 248, 224, 255, 255, 127, 95,
			219, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 3, 0, 248, 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, 0, 255, 255, 255, 255,
			255, 255, 255, 255, 252, 255, 255, 255, 255, 255,
			255, 0, 0, 0, 0, 0, 255, 63, 255, 255,
			255, 3, 255, 255, 255, 255, 255, 255, 247, 255,
			127, 15, 223, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 31,
			254, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 127, 252, 252, 252, 28, 127, 127,
			0, 62
		};

		internal static ReadOnlySpan<byte> GetDefinedBmpCodePointsBitmapLittleEndian()
		{
			return DefinedCharsBitmapSpan;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void GetUtf16SurrogatePairFromAstralScalarValue(uint scalar, out char highSurrogate, out char lowSurrogate)
		{
			highSurrogate = (char)(scalar + 56557568 >> 10);
			lowSurrogate = (char)((scalar & 0x3FF) + 56320);
		}

		internal static int GetUtf8RepresentationForScalarValue(uint scalar)
		{
			if (scalar <= 127)
			{
				return (byte)scalar;
			}
			if (scalar <= 2047)
			{
				byte b = (byte)(0xC0u | (scalar >> 6));
				byte b2 = (byte)(0x80u | (scalar & 0x3Fu));
				return (b2 << 8) | b;
			}
			if (scalar <= 65535)
			{
				byte b3 = (byte)(0xE0u | (scalar >> 12));
				byte b4 = (byte)(0x80u | ((scalar >> 6) & 0x3Fu));
				byte b5 = (byte)(0x80u | (scalar & 0x3Fu));
				return (((b5 << 8) | b4) << 8) | b3;
			}
			byte b6 = (byte)(0xF0u | (scalar >> 18));
			byte b7 = (byte)(0x80u | ((scalar >> 12) & 0x3Fu));
			byte b8 = (byte)(0x80u | ((scalar >> 6) & 0x3Fu));
			byte b9 = (byte)(0x80u | (scalar & 0x3Fu));
			return (((((b9 << 8) | b8) << 8) | b7) << 8) | b6;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool IsSupplementaryCodePoint(int scalar)
		{
			return (scalar & -65536) != 0;
		}
	}
	public sealed class UnicodeRange
	{
		public int FirstCodePoint { get; private set; }

		public int Length { get; private set; }

		public UnicodeRange(int firstCodePoint, int length)
		{
			if (firstCodePoint < 0 || firstCodePoint > 65535)
			{
				throw new ArgumentOutOfRangeException("firstCodePoint");
			}
			if (length < 0 || (long)firstCodePoint + (long)length > 65536)
			{
				throw new ArgumentOutOfRangeException("length");
			}
			FirstCodePoint = firstCodePoint;
			Length = length;
		}

		public static UnicodeRange Create(char firstCharacter, char lastCharacter)
		{
			if (lastCharacter < firstCharacter)
			{
				throw new ArgumentOutOfRangeException("lastCharacter");
			}
			return new UnicodeRange(firstCharacter, 1 + (lastCharacter - firstCharacter));
		}
	}
	public static class UnicodeRanges
	{
		private static UnicodeRange _none;

		private static UnicodeRange _all;

		private static UnicodeRange _u0000;

		private static UnicodeRange _u0080;

		private static UnicodeRange _u0100;

		private static UnicodeRange _u0180;

		private static UnicodeRange _u0250;

		private static UnicodeRange _u02B0;

		private static UnicodeRange _u0300;

		private static UnicodeRange _u0370;

		private static UnicodeRange _u0400;

		private static UnicodeRange _u0500;

		private static UnicodeRange _u0530;

		private static UnicodeRange _u0590;

		private static UnicodeRange _u0600;

		private static UnicodeRange _u0700;

		private static UnicodeRange _u0750;

		private static UnicodeRange _u0780;

		private static UnicodeRange _u07C0;

		private static UnicodeRange _u0800;

		private static UnicodeRange _u0840;

		private static UnicodeRange _u0860;

		private static UnicodeRange _u08A0;

		private static UnicodeRange _u0900;

		private static UnicodeRange _u0980;

		private static UnicodeRange _u0A00;

		private static UnicodeRange _u0A80;

		private static UnicodeRange _u0B00;

		private static UnicodeRange _u0B80;

		private static UnicodeRange _u0C00;

		private static UnicodeRange _u0C80;

		private static UnicodeRange _u0D00;

		private static UnicodeRange _u0D80;

		private static UnicodeRange _u0E00;

		private static UnicodeRange _u0E80;

		private static UnicodeRange _u0F00;

		private static UnicodeRange _u1000;

		private static UnicodeRange _u10A0;

		private static UnicodeRange _u1100;

		private static UnicodeRange _u1200;

		private static UnicodeRange _u1380;

		private static UnicodeRange _u13A0;

		private static UnicodeRange _u1400;

		private static UnicodeRange _u1680;

		private static UnicodeRange _u16A0;

		private static UnicodeRange _u1700;

		private static UnicodeRange _u1720;

		private static UnicodeRange _u1740;

		private static UnicodeRange _u1760;

		private static UnicodeRange _u1780;

		private static UnicodeRange _u1800;

		private static UnicodeRange _u18B0;

		private static UnicodeRange _u1900;

		private static UnicodeRange _u1950;

		private static UnicodeRange _u1980;

		private static UnicodeRange _u19E0;

		private static UnicodeRange _u1A00;

		private static UnicodeRange _u1A20;

		private static UnicodeRange _u1AB0;

		private static UnicodeRange _u1B00;

		private static UnicodeRange _u1B80;

		private static UnicodeRange _u1BC0;

		private static UnicodeRange _u1C00;

		private static UnicodeRange _u1C50;

		private static UnicodeRange _u1C80;

		private static UnicodeRange _u1C90;

		private static UnicodeRange _u1CC0;

		private static UnicodeRange _u1CD0;

		private static UnicodeRange _u1D00;

		private static UnicodeRange _u1D80;

		private static UnicodeRange _u1DC0;

		private static UnicodeRange _u1E00;

		private static UnicodeRange _u1F00;

		private static UnicodeRange _u2000;

		private static UnicodeRange _u2070;

		private static UnicodeRange _u20A0;

		private static UnicodeRange _u20D0;

		private static UnicodeRange _u2100;

		private static UnicodeRange _u2150;

		private static UnicodeRange _u2190;

		private static UnicodeRange _u2200;

		private static UnicodeRange _u2300;

		private static UnicodeRange _u2400;

		private static UnicodeRange _u2440;

		private static UnicodeRange _u2460;

		private static UnicodeRange _u2500;

		private static UnicodeRange _u2580;

		private static UnicodeRange _u25A0;

		private static UnicodeRange _u2600;

		private static UnicodeRange _u2700;

		private static UnicodeRange _u27C0;

		private static UnicodeRange _u27F0;

		private static UnicodeRange _u2800;

		private static UnicodeRange _u2900;

		private static UnicodeRange _u2980;

		private static UnicodeRange _u2A00;

		private static UnicodeRange _u2B00;

		private static UnicodeRange _u2C00;

		private static UnicodeRange _u2C60;

		private static UnicodeRange _u2C80;

		private static UnicodeRange _u2D00;

		private static UnicodeRange _u2D30;

		private static UnicodeRange _u2D80;

		private static UnicodeRange _u2DE0;

		private static UnicodeRange _u2E00;

		private static UnicodeRange _u2E80;

		private static UnicodeRange _u2F00;

		private static UnicodeRange _u2FF0;

		private static UnicodeRange _u3000;

		private static UnicodeRange _u3040;

		private static UnicodeRange _u30A0;

		private static UnicodeRange _u3100;

		private static UnicodeRange _u3130;

		private static UnicodeRange _u3190;

		private static UnicodeRange _u31A0;

		private static UnicodeRange _u31C0;

		private static UnicodeRange _u31F0;

		private static UnicodeRange _u3200;

		private static UnicodeRange _u3300;

		private static UnicodeRange _u3400;

		private static UnicodeRange _u4DC0;

		private static UnicodeRange _u4E00;

		private static UnicodeRange _uA000;

		private static UnicodeRange _uA490;

		private static UnicodeRange _uA4D0;

		private static UnicodeRange _uA500;

		private static UnicodeRange _uA640;

		private static UnicodeRange _uA6A0;

		private static UnicodeRange _uA700;

		private static UnicodeRange _uA720;

		private static UnicodeRange _uA800;

		private static UnicodeRange _uA830;

		private static UnicodeRange _uA840;

		private static UnicodeRange _uA880;

		private static UnicodeRange _uA8E0;

		private static UnicodeRange _uA900;

		private static UnicodeRange _uA930;

		private static UnicodeRange _uA960;

		private static UnicodeRange _uA980;

		private static UnicodeRange _uA9E0;

		private static UnicodeRange _uAA00;

		private static UnicodeRange _uAA60;

		private static UnicodeRange _uAA80;

		private static UnicodeRange _uAAE0;

		private static UnicodeRange _uAB00;

		private static UnicodeRange _uAB30;

		private static UnicodeRange _uAB70;

		private static UnicodeRange _uABC0;

		private static UnicodeRange _uAC00;

		private static UnicodeRange _uD7B0;

		private static UnicodeRange _uF900;

		private static UnicodeRange _uFB00;

		private static UnicodeRange _uFB50;

		private static UnicodeRange _uFE00;

		private static UnicodeRange _uFE10;

		private static UnicodeRange _uFE20;

		private static UnicodeRange _uFE30;

		private static UnicodeRange _uFE50;

		private static UnicodeRange _uFE70;

		private static UnicodeRange _uFF00;

		private static UnicodeRange _uFFF0;

		public static UnicodeRange None => _none ?? CreateEmptyRange(ref _none);

		public static UnicodeRange All => _all ?? CreateRange(ref _all, '\0', '\uffff');

		public static UnicodeRange BasicLatin => _u0000 ?? CreateRange(ref _u0000, '\0', '\u007f');

		public static UnicodeRange Latin1Supplement => _u0080 ?? CreateRange(ref _u0080, '\u0080', 'ÿ');

		public static UnicodeRange LatinExtendedA => _u0100 ?? CreateRange(ref _u0100, 'Ā', 'ſ');

		public static UnicodeRange LatinExtendedB => _u0180 ?? CreateRange(ref _u0180, 'ƀ', 'ɏ');

		public static UnicodeRange IpaExtensions => _u0250 ?? CreateRange(ref _u0250, 'ɐ', 'ʯ');

		public static UnicodeRange SpacingModifierLetters => _u02B0 ?? CreateRange(ref _u02B0, 'ʰ', '\u02ff');

		public static UnicodeRange CombiningDiacriticalMarks => _u0300 ?? CreateRange(ref _u0300, '\u0300', '\u036f');

		public static UnicodeRange GreekandCoptic => _u0370 ?? CreateRange(ref _u0370, 'Ͱ', 'Ͽ');

		public static UnicodeRange Cyrillic => _u0400 ?? CreateRange(ref _u0400, 'Ѐ', 'ӿ');

		public static UnicodeRange CyrillicSupplement => _u0500 ?? CreateRange(ref _u0500, 'Ԁ', 'ԯ');

		public static UnicodeRange Armenian => _u0530 ?? CreateRange(ref _u0530, '\u0530', '֏');

		public static UnicodeRange Hebrew => _u0590 ?? CreateRange(ref _u0590, '\u0590', '\u05ff');

		public static UnicodeRange Arabic => _u0600 ?? CreateRange(ref _u0600, '\u0600', 'ۿ');

		public static UnicodeRange Syriac => _u0700 ?? CreateRange(ref _u0700, '܀', 'ݏ');

		public static UnicodeRange ArabicSupplement => _u0750 ?? CreateRange(ref _u0750, 'ݐ', 'ݿ');

		public static UnicodeRange Thaana => _u0780 ?? CreateRange(ref _u0780, 'ހ', '\u07bf');

		public static UnicodeRange NKo => _u07C0 ?? CreateRange(ref _u07C0, '߀', '߿');

		public static UnicodeRange Samaritan => _u0800 ?? CreateRange(ref _u0800, 'ࠀ', '\u083f');

		public static UnicodeRange Mandaic => _u0840 ?? CreateRange(ref _u0840, 'ࡀ', '\u085f');

		public static UnicodeRange SyriacSupplement => _u0860 ?? CreateRange(ref _u0860, 'ࡠ', '\u086f');

		public static UnicodeRange ArabicExtendedA => _u08A0 ?? CreateRange(ref _u08A0, 'ࢠ', '\u08ff');

		public static UnicodeRange Devanagari => _u0900 ?? CreateRange(ref _u0900, '\u0900', 'ॿ');

		public static UnicodeRange Bengali => _u0980 ?? CreateRange(ref _u0980, 'ঀ', '\u09ff');

		public static UnicodeRange Gurmukhi => _u0A00 ?? CreateRange(ref _u0A00, '\u0a00', '\u0a7f');

		public static UnicodeRange Gujarati => _u0A80 ?? CreateRange(ref _u0A80, '\u0a80', '\u0aff');

		public static UnicodeRange Oriya => _u0B00 ?? CreateRange(ref _u0B00, '\u0b00', '\u0b7f');

		public static UnicodeRange Tamil => _u0B80 ?? CreateRange(ref _u0B80, '\u0b80', '\u0bff');

		public static UnicodeRange Telugu => _u0C00 ?? CreateRange(ref _u0C00, '\u0c00', '౿');

		public static UnicodeRange Kannada => _u0C80 ?? CreateRange(ref _u0C80, 'ಀ', '\u0cff');

		public static UnicodeRange Malayalam => _u0D00 ?? CreateRange(ref _u0D00, '\u0d00', 'ൿ');

		public static UnicodeRange Sinhala => _u0D80 ?? CreateRange(ref _u0D80, '\u0d80', '\u0dff');

		public static UnicodeRange Thai => _u0E00 ?? CreateRange(ref _u0E00, '\u0e00', '\u0e7f');

		public static UnicodeRange Lao => _u0E80 ?? CreateRange(ref _u0E80, '\u0e80', '\u0eff');

		public static UnicodeRange Tibetan => _u0F00 ?? CreateRange(ref _u0F00, 'ༀ', '\u0fff');

		public static UnicodeRange Myanmar => _u1000 ?? CreateRange(ref _u1000, 'က', '႟');

		public static UnicodeRange Georgian => _u10A0 ?? CreateRange(ref _u10A0, 'Ⴀ', 'ჿ');

		public static UnicodeRange HangulJamo => _u1100 ?? CreateRange(ref _u1100, 'ᄀ', 'ᇿ');

		public static UnicodeRange Ethiopic => _u1200 ?? CreateRange(ref _u1200, 'ሀ', '\u137f');

		public static UnicodeRange EthiopicSupplement => _u1380 ?? CreateRange(ref _u1380, 'ᎀ', '\u139f');

		public static UnicodeRange Cherokee => _u13A0 ?? CreateRange(ref _u13A0, 'Ꭰ', '\u13ff');

		public static UnicodeRange UnifiedCanadianAboriginalSyllabics => _u1400 ?? CreateRange(ref _u1400, '᐀', 'ᙿ');

		public static UnicodeRange Ogham => _u1680 ?? CreateRange(ref _u1680, '\u1680', '\u169f');

		public static UnicodeRange Runic => _u16A0 ?? CreateRange(ref _u16A0, 'ᚠ', '\u16ff');

		public static UnicodeRange Tagalog => _u1700 ?? CreateRange(ref _u1700, 'ᜀ', '\u171f');

		public static UnicodeRange Hanunoo => _u1720 ?? CreateRange(ref _u1720, 'ᜠ', '\u173f');

		public static UnicodeRange Buhid => _u1740 ?? CreateRange(ref _u1740, 'ᝀ', '\u175f');

		public static UnicodeRange Tagbanwa => _u1760 ?? CreateRange(ref _u1760, 'ᝠ', '\u177f');

		public static UnicodeRange Khmer => _u1780 ?? CreateRange(ref _u1780, 'ក', '\u17ff');

		public static UnicodeRange Mongolian => _u1800 ?? CreateRange(ref _u1800, '᠀', '\u18af');

		public static UnicodeRange UnifiedCanadianAboriginalSyllabicsExtended => _u18B0 ?? CreateRange(ref _u18B0, 'ᢰ', '\u18ff');

		public static UnicodeRange Limbu => _u1900 ?? CreateRange(ref _u1900, 'ᤀ', '᥏');

		public static UnicodeRange TaiLe => _u1950 ?? CreateRange(ref _u1950, 'ᥐ', '\u197f');

		public static UnicodeRange NewTaiLue => _u1980 ?? CreateRange(ref _u1980, 'ᦀ', '᧟');

		public static UnicodeRange KhmerSymbols => _u19E0 ?? CreateRange(ref _u19E0, '᧠', '᧿');

		public static UnicodeRange Buginese => _u1A00 ?? CreateRange(ref _u1A00, 'ᨀ', '᨟');

		public static UnicodeRange TaiTham => _u1A20 ?? CreateRange(ref _u1A20, 'ᨠ', '\u1aaf');

		public static UnicodeRange CombiningDiacriticalMarksExtended => _u1AB0 ?? CreateRange(ref _u1AB0, '\u1ab0', '\u1aff');

		public static UnicodeRange Balinese => _u1B00 ?? CreateRange(ref _u1B00, '\u1b00', '\u1b7f');

		public static UnicodeRange Sundanese => _u1B80 ?? CreateRange(ref _u1B80, '\u1b80', 'ᮿ');

		public static UnicodeRange Batak => _u1BC0 ?? CreateRange(ref _u1BC0, 'ᯀ', '᯿');

		public static UnicodeRange Lepcha => _u1C00 ?? CreateRange(ref _u1C00, 'ᰀ', 'ᱏ');

		public static UnicodeRange OlChiki => _u1C50 ?? CreateRange(ref _u1C50, '᱐', '᱿');

		public static UnicodeRange CyrillicExtendedC => _u1C80 ?? CreateRange(ref _u1C80, 'ᲀ', '\u1c8f');

		public static UnicodeRange GeorgianExtended => _u1C90 ?? CreateRange(ref _u1C90, 'Ა', 'Ჿ');

		public static UnicodeRange SundaneseSupplement => _u1CC0 ?? CreateRange(ref _u1CC0, '᳀', '\u1ccf');

		public static UnicodeRange VedicExtensions => _u1CD0 ?? CreateRange(ref _u1CD0, '\u1cd0', '\u1cff');

		public static UnicodeRange PhoneticExtensions => _u1D00 ?? CreateRange(ref _u1D00, 'ᴀ', 'ᵿ');

		public static UnicodeRange PhoneticExtensionsSupplement => _u1D80 ?? CreateRange(ref _u1D80, 'ᶀ', 'ᶿ');

		public static UnicodeRange CombiningDiacriticalMarksSupplement => _u1DC0 ?? CreateRange(ref _u1DC0, '\u1dc0', '\u1dff');

		public static UnicodeRange LatinExtendedAdditional => _u1E00 ?? CreateRange(ref _u1E00, 'Ḁ', 'ỿ');

		public static UnicodeRange GreekExtended => _u1F00 ?? CreateRange(ref _u1F00, 'ἀ', '\u1fff');

		public static UnicodeRange GeneralPunctuation => _u2000 ?? CreateRange(ref _u2000, '\u2000', '\u206f');

		public static UnicodeRange SuperscriptsandSubscripts => _u2070 ?? CreateRange(ref _u2070, '⁰', '\u209f');

		public static UnicodeRange CurrencySymbols => _u20A0 ?? CreateRange(ref _u20A0, '₠', '\u20cf');

		public static UnicodeRange CombiningDiacriticalMarksforSymbols => _u20D0 ?? CreateRange(ref _u20D0, '\u20d0', '\u20ff');

		public static UnicodeRange LetterlikeSymbols => _u2100 ?? CreateRange(ref _u2100, '℀', '⅏');

		public static UnicodeRange NumberForms => _u2150 ?? CreateRange(ref _u2150, '⅐', '\u218f');

		public static UnicodeRange Arrows => _u2190 ?? CreateRange(ref _u2190, '←', '⇿');

		public static UnicodeRange MathematicalOperators => _u2200 ?? CreateRange(ref _u2200, '∀', '⋿');

		public static UnicodeRange MiscellaneousTechnical => _u2300 ?? CreateRange(ref _u2300, '⌀', '⏿');

		public static UnicodeRange ControlPictures => _u2400 ?? CreateRange(ref _u2400, '␀', '\u243f');

		public static UnicodeRange OpticalCharacterRecognition => _u2440 ?? CreateRange(ref _u2440, '⑀', '\u245f');

		public static UnicodeRange EnclosedAlphanumerics => _u2460 ?? CreateRange(ref _u2460, '①', '⓿');

		public static UnicodeRange BoxDrawing => _u2500 ?? CreateRange(ref _u2500, '─', '╿');

		public static UnicodeRange BlockElements => _u2580 ?? CreateRange(ref _u2580, '▀', '▟');

		public static UnicodeRange GeometricShapes => _u25A0 ?? CreateRange(ref _u25A0, '■', '◿');

		public static UnicodeRange MiscellaneousSymbols => _u2600 ?? CreateRange(ref _u2600, '☀', '⛿');

		public static UnicodeRange Dingbats => _u2700 ?? CreateRange(ref _u2700, '✀', '➿');

		public static UnicodeRange MiscellaneousMathematicalSymbolsA => _u27C0 ?? CreateRange(ref _u27C0, '⟀', '⟯');

		public static UnicodeRange SupplementalArrowsA => _u27F0 ?? CreateRange(ref _u27F0, '⟰', '⟿');

		public static UnicodeRange BraillePatterns => _u2800 ?? CreateRange(ref _u2800, '⠀', '⣿');

		public static UnicodeRange SupplementalArrowsB => _u2900 ?? CreateRange(ref _u2900, '⤀', '⥿');

		public static UnicodeRange MiscellaneousMathematicalSymbolsB => _u2980 ?? CreateRange(ref _u2980, '⦀', '⧿');

		public static UnicodeRange SupplementalMathematicalOperators => _u2A00 ?? CreateRange(ref _u2A00, '⨀', '⫿');

		public static UnicodeRange MiscellaneousSymbolsandArrows => _u2B00 ?? CreateRange(ref _u2B00, '⬀', '⯿');

		public static UnicodeRange Glagolitic => _u2C00 ?? CreateRange(ref _u2C00, 'Ⰰ', '\u2c5f');

		public static UnicodeRange LatinExtendedC => _u2C60 ?? CreateRange(ref _u2C60, 'Ⱡ', 'Ɀ');

		public static UnicodeRange Coptic => _u2C80 ?? CreateRange(ref _u2C80, 'Ⲁ', '⳿');

		public static UnicodeRange GeorgianSupplement => _u2D00 ?? CreateRange(ref _u2D00, 'ⴀ', '\u2d2f');

		public static UnicodeRange Tifinagh => _u2D30 ?? CreateRange(ref _u2D30, 'ⴰ', '\u2d7f');

		public static UnicodeRange EthiopicExtended => _u2D80 ?? CreateRange(ref _u2D80, 'ⶀ', '\u2ddf');

		public static UnicodeRange CyrillicExtendedA => _u2DE0 ?? CreateRange(ref _u2DE0, '\u2de0', '\u2dff');

		public static UnicodeRange SupplementalPunctuation => _u2E00 ?? CreateRange(ref _u2E00, '⸀', '\u2e7f');

		public static UnicodeRange CjkRadicalsSupplement => _u2E80 ?? CreateRange(ref _u2E80, '⺀', '\u2eff');

		public static UnicodeRange KangxiRadicals => _u2F00 ?? CreateRange(ref _u2F00, '⼀', '\u2fdf');

		public static UnicodeRange IdeographicDescriptionCharacters => _u2FF0 ?? CreateRange(ref _u2FF0, '⿰', '\u2fff');

		public static UnicodeRange CjkSymbolsandPunctuation => _u3000 ?? CreateRange(ref _u3000, '\u3000', '〿');

		public static UnicodeRange Hiragana => _u3040 ?? CreateRange(ref _u3040, '\u3040', 'ゟ');

		public static UnicodeRange Katakana => _u30A0 ?? CreateRange(ref _u30A0, '゠', 'ヿ');

		public static UnicodeRange Bopomofo => _u3100 ?? CreateRange(ref _u3100, '\u3100', 'ㄯ');

		public static UnicodeRange HangulCompatibilityJamo => _u3130 ?? CreateRange(ref _u3130, '\u3130', '\u318f');

		public static UnicodeRange Kanbun => _u3190 ?? CreateRange(ref _u3190, '㆐', '㆟');

		public static UnicodeRange BopomofoExtended => _u31A0 ?? CreateRange(ref _u31A0, 'ㆠ', 'ㆿ');

		public static UnicodeRange CjkStrokes => _u31C0 ?? CreateRange(ref _u31C0, '㇀', '\u31ef');

		public static UnicodeRange KatakanaPhoneticExtensions => _u31F0 ?? CreateRange(ref _u31F0, 'ㇰ', 'ㇿ');

		public static UnicodeRange EnclosedCjkLettersandMonths => _u3200 ?? CreateRange(ref _u3200, '㈀', '㋿');

		public static UnicodeRange CjkCompatibility => _u3300 ?? CreateRange(ref _u3300, '㌀', '㏿');

		public static UnicodeRange CjkUnifiedIdeographsExtensionA => _u3400 ?? CreateRange(ref _u3400, '㐀', '䶿');

		public static UnicodeRange YijingHexagramSymbols => _u4DC0 ?? CreateRange(ref _u4DC0, '䷀', '䷿');

		public static UnicodeRange CjkUnifiedIdeographs => _u4E00 ?? CreateRange(ref _u4E00, '一', '\u9fff');

		public static UnicodeRange YiSyllables => _uA000 ?? CreateRange(ref _uA000, 'ꀀ', '\ua48f');

		public static UnicodeRange YiRadicals => _uA490 ?? CreateRange(ref _uA490, '꒐', '\ua4cf');

		public static UnicodeRange Lisu => _uA4D0 ?? CreateRange(ref _uA4D0, 'ꓐ', '꓿');

		public static UnicodeRange Vai => _uA500 ?? CreateRange(ref _uA500, 'ꔀ', '\ua63f');

		public static UnicodeRange CyrillicExtendedB => _uA640 ?? CreateRange(ref _uA640, 'Ꙁ', '\ua69f');

		public static UnicodeRange Bamum => _uA6A0 ?? CreateRange(ref _uA6A0, 'ꚠ', '\ua6ff');

		public static UnicodeRange ModifierToneLetters => _uA700 ?? CreateRange(ref _uA700, '\ua700', 'ꜟ');

		public static UnicodeRange LatinExtendedD => _uA720 ?? CreateRange(ref _uA720, '\ua720', 'ꟿ');

		public static UnicodeRange SylotiNagri => _uA800 ?? CreateRange(ref _uA800, 'ꠀ', '\ua82f');

		public static UnicodeRange CommonIndicNumberForms => _uA830 ?? CreateRange(ref _uA830, '꠰', '\ua83f');

		public static UnicodeRange Phagspa => _uA840 ?? CreateRange(ref _uA840, 'ꡀ', '\ua87f');

		public static UnicodeRange Saurashtra => _uA880 ?? CreateRange(ref _uA880, '\ua880', '\ua8df');

		public static UnicodeRange DevanagariExtended => _uA8E0 ?? CreateRange(ref _uA8E0, '\ua8e0', '\ua8ff');

		public static UnicodeRange KayahLi => _uA900 ?? CreateRange(ref _uA900, '꤀', '꤯');

		public static UnicodeRange Rejang => _uA930 ?? CreateRange(ref _uA930, 'ꤰ', '꥟');

		public static UnicodeRange HangulJamoExtendedA => _uA960 ?? CreateRange(ref _uA960, 'ꥠ', '\ua97f');

		public static UnicodeRange Javanese => _uA980 ?? CreateRange(ref _uA980, '\ua980', '꧟');

		public static UnicodeRange MyanmarExtendedB => _uA9E0 ?? CreateRange(ref _uA9E0, 'ꧠ', '\ua9ff');

		public static UnicodeRange Cham => _uAA00 ?? CreateRange(ref _uAA00, 'ꨀ', '꩟');

		public static UnicodeRange MyanmarExtendedA => _uAA60 ?? CreateRange(ref _uAA60, 'ꩠ', 'ꩿ');

		public static UnicodeRange TaiViet => _uAA80 ?? CreateRange(ref _uAA80, 'ꪀ', '꫟');

		public static UnicodeRange MeeteiMayekExtensions => _uAAE0 ?? CreateRange(ref _uAAE0, 'ꫠ', '\uaaff');

		public static UnicodeRange EthiopicExtendedA => _uAB00 ?? CreateRange(ref _uAB00, '\uab00', '\uab2f');

		public static UnicodeRange LatinExtendedE => _uAB30 ?? CreateRange(ref _uAB30, 'ꬰ', '\uab6f');

		public static UnicodeRange CherokeeSupplement => _uAB70 ?? CreateRange(ref _uAB70, 'ꭰ', 'ꮿ');

		public static UnicodeRange MeeteiMayek => _uABC0 ?? CreateRange(ref _uABC0, 'ꯀ', '\uabff');

		public static UnicodeRange HangulSyllables => _uAC00 ?? CreateRange(ref _uAC00, '가', '\ud7af');

		public static UnicodeRange HangulJamoExtendedB => _uD7B0 ?? CreateRange(ref _uD7B0, 'ힰ', '\ud7ff');

		public static UnicodeRange CjkCompatibilityIdeographs => _uF900 ?? CreateRange(ref _uF900, '豈', '\ufaff');

		public static UnicodeRange AlphabeticPresentationForms => _uFB00 ?? CreateRange(ref _uFB00, 'ff', 'ﭏ');

		public static UnicodeRange ArabicPresentationFormsA => _uFB50 ?? CreateRange(ref _uFB50, 'ﭐ', '\ufdff');

		public static UnicodeRange VariationSelectors => _uFE00 ?? CreateRange(ref _uFE00, '\ufe00', '\ufe0f');

		public static UnicodeRange VerticalForms => _uFE10 ?? CreateRange(ref _uFE10, '︐', '\ufe1f');

		public static UnicodeRange CombiningHalfMarks => _uFE20 ?? CreateRange(ref _uFE20, '\ufe20', '\ufe2f');

		public static UnicodeRange CjkCompatibilityForms => _uFE30 ?? CreateRange(ref _uFE30, '︰', '\ufe4f');

		public static UnicodeRange SmallFormVariants => _uFE50 ?? CreateRange(ref _uFE50, '﹐', '\ufe6f');

		public static UnicodeRange ArabicPresentationFormsB => _uFE70 ?? CreateRange(ref _uFE70, 'ﹰ', '\ufeff');

		public static UnicodeRange HalfwidthandFullwidthForms => _uFF00 ?? CreateRange(ref _uFF00, '\uff00', '\uffef');

		public static UnicodeRange Specials => _uFFF0 ?? CreateRange(ref _uFFF0, '\ufff0', '\uffff');

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static UnicodeRange CreateEmptyRange([NotNull] ref UnicodeRange range)
		{
			Volatile.Write(ref range, new UnicodeRange(0, 0));
			return range;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static UnicodeRange CreateRange([NotNull] ref UnicodeRange range, char first, char last)
		{
			Volatile.Write(ref range, UnicodeRange.Create(first, last));
			return range;
		}
	}
}
namespace System.Text.Encodings.Web
{
	internal struct AsciiByteMap
	{
		private const int BufferSize = 128;

		private unsafe fixed byte Buffer[128];

		internal unsafe void InsertAsciiChar(char key, byte value)
		{
			if (key < '\u0080')
			{
				Buffer[(uint)key] = value;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal unsafe readonly bool TryLookup(Rune key, out byte value)
		{
			if (key.IsAscii)
			{
				byte b = Buffer[(uint)key.Value];
				if (b != 0)
				{
					value = b;
					return true;
				}
			}
			value = 0;
			return false;
		}
	}
	internal struct AllowedBmpCodePointsBitmap
	{
		private const int BitmapLengthInDWords = 2048;

		private unsafe fixed uint Bitmap[2048];

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe void AllowChar(char value)
		{
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			ref uint reference = ref Bitmap[(ulong)index];
			reference |= (uint)(1 << offset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe void ForbidChar(char value)
		{
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			ref uint reference = ref Bitmap[(ulong)index];
			reference &= (uint)(~(1 << offset));
		}

		public void ForbidHtmlCharacters()
		{
			ForbidChar('<');
			ForbidChar('>');
			ForbidChar('&');
			ForbidChar('\'');
			ForbidChar('"');
			ForbidChar('+');
		}

		public unsafe void ForbidUndefinedCharacters()
		{
			fixed (uint* pointer = Bitmap)
			{
				ReadOnlySpan<byte> definedBmpCodePointsBitmapLittleEndian = UnicodeHelpers.GetDefinedBmpCodePointsBitmapLittleEndian();
				Span<uint> span = new Span<uint>(pointer, 2048);
				for (int i = 0; i < span.Length; i++)
				{
					span[i] &= BinaryPrimitives.ReadUInt32LittleEndian(definedBmpCodePointsBitmapLittleEndian.Slice(i * 4));
				}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe readonly bool IsCharAllowed(char value)
		{
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			if ((Bitmap[(ulong)index] & (uint)(1 << offset)) != 0)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe readonly bool IsCodePointAllowed(uint value)
		{
			if (!System.Text.UnicodeUtility.IsBmpCodePoint(value))
			{
				return false;
			}
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			if ((Bitmap[(ulong)index] & (uint)(1 << offset)) != 0)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void _GetIndexAndOffset(uint value, out nuint index, out int offset)
		{
			index = value >> 5;
			offset = (int)(value & 0x1F);
		}
	}
	internal sealed class OptimizedInboxTextEncoder
	{
		[StructLayout(LayoutKind.Explicit)]
		private struct AllowedAsciiCodePoints
		{
			[FieldOffset(0)]
			private unsafe fixed byte AsBytes[16];

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			internal unsafe readonly bool IsAllowedAsciiCodePoint(uint codePoint)
			{
				if (codePoint > 127)
				{
					return false;
				}
				uint num = AsBytes[codePoint & 0xF];
				if ((num & (uint)(1 << (int)(codePoint 

LethalStreams.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.WebSockets;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalStreams.Patches;
using LethalStreams.Streamlabs;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SocketIOClient;
using SocketIOClient.Messages;
using SocketIOClient.Transport;
using SocketIOClient.UriConverters;
using TMPro;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("0x16c3")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod for your Twitch donations to integrate with the game")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("LethalStreams")]
[assembly: AssemblyTitle("LethalStreams")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class SocketIOUnity : SocketIO
{
	public enum UnityThreadScope
	{
		Update,
		LateUpdate,
		FixedUpdate
	}

	public UnityThreadScope unityThreadScope;

	public SocketIOUnity(string uri, UnityThreadScope unityThreadScope = UnityThreadScope.Update)
		: base(uri)
	{
		CommonInit(unityThreadScope);
	}

	public SocketIOUnity(Uri uri, UnityThreadScope unityThreadScope = UnityThreadScope.Update)
		: base(uri)
	{
		CommonInit(unityThreadScope);
	}

	public SocketIOUnity(string uri, SocketIOOptions options, UnityThreadScope unityThreadScope = UnityThreadScope.Update)
		: base(uri, options)
	{
		CommonInit(unityThreadScope);
	}

	public SocketIOUnity(Uri uri, SocketIOOptions options, UnityThreadScope unityThreadScope = UnityThreadScope.Update)
		: base(uri, options)
	{
		CommonInit(unityThreadScope);
	}

	private void CommonInit(UnityThreadScope unityThreadScope)
	{
		UnityThread.initUnityThread();
		this.unityThreadScope = unityThreadScope;
	}

	public void OnUnityThread(string eventName, Action<SocketIOResponse> callback)
	{
		On(eventName, delegate(SocketIOResponse res)
		{
			ExecuteInUnityThread(delegate
			{
				callback(res);
			});
		});
	}

	public void OnAnyInUnityThread(OnAnyHandler handler)
	{
		OnAny(delegate(string name, SocketIOResponse response)
		{
			ExecuteInUnityThread(delegate
			{
				handler(name, response);
			});
		});
	}

	public async Task EmitStringAsJSONAsync(string eventName, string json)
	{
		EventMessage eventMessage = new EventMessage
		{
			Namespace = base.Namespace,
			Event = eventName
		};
		if (!string.IsNullOrEmpty(json))
		{
			eventMessage.Json = "[" + json + "]";
		}
		await _transport.SendAsync(eventMessage, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public void EmitStringAsJSON(string eventName, string json)
	{
		EmitStringAsJSONAsync(eventName, json).ContinueWith(delegate
		{
		});
	}

	public void Connect()
	{
		ConnectAsync().ContinueWith(delegate
		{
		});
	}

	public void Disconnect()
	{
		DisconnectAsync().ContinueWith(delegate
		{
		});
	}

	private void ExecuteInUnityThread(Action action)
	{
		switch (unityThreadScope)
		{
		case UnityThreadScope.LateUpdate:
			UnityThread.executeInLateUpdate(action);
			break;
		case UnityThreadScope.FixedUpdate:
			UnityThread.executeInFixedUpdate(action);
			break;
		default:
			UnityThread.executeInUpdate(action);
			break;
		}
	}
}
public class UnityThread : MonoBehaviour
{
	private static UnityThread instance = null;

	private static List<Action> actionQueuesUpdateFunc = new List<Action>();

	private List<Action> actionCopiedQueueUpdateFunc = new List<Action>();

	private static volatile bool noActionQueueToExecuteUpdateFunc = true;

	private static List<Action> actionQueuesLateUpdateFunc = new List<Action>();

	private List<Action> actionCopiedQueueLateUpdateFunc = new List<Action>();

	private static volatile bool noActionQueueToExecuteLateUpdateFunc = true;

	private static List<Action> actionQueuesFixedUpdateFunc = new List<Action>();

	private List<Action> actionCopiedQueueFixedUpdateFunc = new List<Action>();

	private static volatile bool noActionQueueToExecuteFixedUpdateFunc = true;

	public static void initUnityThread(bool visible = false)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		if (!((Object)(object)instance != (Object)null) && Application.isPlaying)
		{
			GameObject val = new GameObject("MainThreadExecuter");
			if (!visible)
			{
				((Object)val).hideFlags = (HideFlags)61;
			}
			Object.DontDestroyOnLoad((Object)(object)val);
			instance = val.AddComponent<UnityThread>();
		}
	}

	public void Awake()
	{
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
	}

	public static void executeCoroutine(IEnumerator action)
	{
		if ((Object)(object)instance != (Object)null)
		{
			executeInUpdate(delegate
			{
				((MonoBehaviour)instance).StartCoroutine(action);
			});
		}
	}

	public static void executeInUpdate(Action action)
	{
		if (action == null)
		{
			throw new ArgumentNullException("action");
		}
		lock (actionQueuesUpdateFunc)
		{
			actionQueuesUpdateFunc.Add(action);
			noActionQueueToExecuteUpdateFunc = false;
		}
	}

	public void Update()
	{
		if (!noActionQueueToExecuteUpdateFunc)
		{
			actionCopiedQueueUpdateFunc.Clear();
			lock (actionQueuesUpdateFunc)
			{
				actionCopiedQueueUpdateFunc.AddRange(actionQueuesUpdateFunc);
				actionQueuesUpdateFunc.Clear();
				noActionQueueToExecuteUpdateFunc = true;
			}
			for (int i = 0; i < actionCopiedQueueUpdateFunc.Count; i++)
			{
				actionCopiedQueueUpdateFunc[i]();
			}
		}
	}

	public static void executeInLateUpdate(Action action)
	{
		if (action == null)
		{
			throw new ArgumentNullException("action");
		}
		lock (actionQueuesLateUpdateFunc)
		{
			actionQueuesLateUpdateFunc.Add(action);
			noActionQueueToExecuteLateUpdateFunc = false;
		}
	}

	public void LateUpdate()
	{
		if (!noActionQueueToExecuteLateUpdateFunc)
		{
			actionCopiedQueueLateUpdateFunc.Clear();
			lock (actionQueuesLateUpdateFunc)
			{
				actionCopiedQueueLateUpdateFunc.AddRange(actionQueuesLateUpdateFunc);
				actionQueuesLateUpdateFunc.Clear();
				noActionQueueToExecuteLateUpdateFunc = true;
			}
			for (int i = 0; i < actionCopiedQueueLateUpdateFunc.Count; i++)
			{
				actionCopiedQueueLateUpdateFunc[i]();
			}
		}
	}

	public static void executeInFixedUpdate(Action action)
	{
		if (action == null)
		{
			throw new ArgumentNullException("action");
		}
		lock (actionQueuesFixedUpdateFunc)
		{
			actionQueuesFixedUpdateFunc.Add(action);
			noActionQueueToExecuteFixedUpdateFunc = false;
		}
	}

	public void FixedUpdate()
	{
		if (!noActionQueueToExecuteFixedUpdateFunc)
		{
			actionCopiedQueueFixedUpdateFunc.Clear();
			lock (actionQueuesFixedUpdateFunc)
			{
				actionCopiedQueueFixedUpdateFunc.AddRange(actionQueuesFixedUpdateFunc);
				actionQueuesFixedUpdateFunc.Clear();
				noActionQueueToExecuteFixedUpdateFunc = true;
			}
			for (int i = 0; i < actionCopiedQueueFixedUpdateFunc.Count; i++)
			{
				actionCopiedQueueFixedUpdateFunc[i]();
			}
		}
	}

	public void OnDisable()
	{
		if ((Object)(object)instance == (Object)(object)this)
		{
			instance = null;
		}
	}
}
namespace SocketIOClient
{
	public class DisconnectReason
	{
		public static string IOServerDisconnect = "io server disconnect";

		public static string IOClientDisconnect = "io client disconnect";

		public static string PingTimeout = "ping timeout";

		public static string TransportClose = "transport close";

		public static string TransportError = "transport error";
	}
	public delegate void OnAnyHandler(string eventName, SocketIOResponse response);
	public delegate void OnOpenedHandler(string sid, int pingInterval, int pingTimeout);
	public delegate void OnAck(int packetId, List<JObject> array);
	public delegate void OnBinaryAck(int packetId, int totalCount, List<JObject> array);
	public delegate void OnBinaryReceived(int packetId, int totalCount, string eventName, List<JObject> array);
	public delegate void OnDisconnected();
	public delegate void OnError(string error);
	public delegate void OnEventReceived(int packetId, string eventName, List<JObject> array);
	public delegate void OnOpened(string sid, int pingInterval, int pingTimeout);
	public delegate void OnPing();
	public delegate void OnPong();
	public class SocketIO : IDisposable
	{
		private Uri _serverUri;

		private IClientWebSocket _clientWebsocket;

		public BaseTransport _transport;

		private List<Type> _expectedExceptions;

		private int _packetId;

		private bool _isConnectCoreRunning;

		private Uri _realServerUri;

		private Exception _connectCoreException;

		private Dictionary<int, Action<SocketIOResponse>> _ackHandlers;

		private List<OnAnyHandler> _onAnyHandlers;

		private Dictionary<string, Action<SocketIOResponse>> _eventHandlers;

		private CancellationTokenSource _connectionTokenSource;

		private double _reconnectionDelay;

		public Uri ServerUri
		{
			get
			{
				return _serverUri;
			}
			set
			{
				if (_serverUri != value)
				{
					_serverUri = value;
					if (value != null && value.AbsolutePath != "/")
					{
						Namespace = value.AbsolutePath;
					}
				}
			}
		}

		public string Id { get; set; }

		public string Namespace { get; private set; }

		public bool Connected { get; private set; }

		public int Attempts { get; private set; }

		public bool Disconnected => !Connected;

		public SocketIOOptions Options { get; }

		public IUriConverter UriConverter { get; set; }

		public HttpClient HttpClient { get; set; }

		public Func<IClientWebSocket> ClientWebSocketProvider { get; set; }

		public event EventHandler OnConnected;

		public event EventHandler<string> OnError;

		public event EventHandler<string> OnDisconnected;

		public event EventHandler<int> OnReconnected;

		public event EventHandler<int> OnReconnectAttempt;

		public event EventHandler<Exception> OnReconnectError;

		public event EventHandler OnReconnectFailed;

		public event EventHandler OnPing;

		public event EventHandler<TimeSpan> OnPong;

		public event EventHandler OnEvent;

		public SocketIO(string uri)
			: this(new Uri(uri))
		{
		}

		public SocketIO(Uri uri)
			: this(uri, new SocketIOOptions())
		{
		}

		public SocketIO(string uri, SocketIOOptions options)
			: this(new Uri(uri), options)
		{
		}

		public SocketIO(Uri uri, SocketIOOptions options)
		{
			ServerUri = uri ?? throw new ArgumentNullException("uri");
			Options = options ?? throw new ArgumentNullException("options");
			Initialize();
		}

		private void Initialize()
		{
			_packetId = -1;
			_ackHandlers = new Dictionary<int, Action<SocketIOResponse>>();
			_eventHandlers = new Dictionary<string, Action<SocketIOResponse>>();
			_onAnyHandlers = new List<OnAnyHandler>();
			UriConverter = new UriConverter();
			HttpClient = new HttpClient();
			ClientWebSocketProvider = () => new SystemNetWebSocketsClientWebSocket(Options.EIO);
			_expectedExceptions = new List<Type>
			{
				typeof(TimeoutException),
				typeof(WebSocketException),
				typeof(HttpRequestException),
				typeof(OperationCanceledException),
				typeof(TaskCanceledException)
			};
		}

		private async Task CreateTransportAsync()
		{
			SocketIOOptions options = Options;
			options.Transport = await GetProtocolAsync();
			if (Options.Transport == TransportProtocol.Polling)
			{
				_transport = new HttpTransport(pollingHandler: (Options.EIO != 3) ? ((HttpPollingHandler)new Eio4HttpPollingHandler(HttpClient)) : ((HttpPollingHandler)new Eio3HttpPollingHandler(HttpClient)), http: HttpClient, options: Options);
			}
			else
			{
				_clientWebsocket = ClientWebSocketProvider();
				_transport = new WebSocketTransport(_clientWebsocket, Options);
			}
			_transport.Namespace = Namespace;
			SetHeaders();
		}

		private void SetHeaders()
		{
			if (Options.ExtraHeaders == null)
			{
				return;
			}
			foreach (KeyValuePair<string, string> extraHeader in Options.ExtraHeaders)
			{
				_transport.AddHeader(extraHeader.Key, extraHeader.Value);
			}
		}

		private void SyncExceptionToMain(Exception e)
		{
			_connectCoreException = e;
			_isConnectCoreRunning = false;
		}

		private void ConnectCore()
		{
			DisposeForReconnect();
			_reconnectionDelay = Options.ReconnectionDelay;
			_connectionTokenSource = new CancellationTokenSource();
			CancellationToken cct = _connectionTokenSource.Token;
			_isConnectCoreRunning = true;
			_connectCoreException = null;
			Task.Factory.StartNew((Func<Task>)async delegate
			{
				while (true)
				{
					_clientWebsocket?.Dispose();
					_transport?.Dispose();
					CreateTransportAsync().Wait();
					_realServerUri = UriConverter.GetServerUri(Options.Transport == TransportProtocol.WebSocket, ServerUri, Options.EIO, Options.Path, Options.Query);
					try
					{
						if (!cct.IsCancellationRequested)
						{
							if (Attempts > 0)
							{
								this.OnReconnectAttempt?.Invoke(this, Attempts);
							}
							CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(Options.ConnectionTimeout);
							ObservableExtensions.Subscribe<IMessage>((IObservable<IMessage>)_transport, (Action<IMessage>)OnMessageReceived, (Action<Exception>)OnErrorReceived);
							await _transport.ConnectAsync(_realServerUri, cancellationTokenSource.Token).ConfigureAwait(continueOnCapturedContext: false);
						}
					}
					catch (Exception ex)
					{
						if (!_expectedExceptions.Contains(ex.GetType()))
						{
							SyncExceptionToMain(ex);
							throw;
						}
						if (!Options.Reconnection)
						{
							SyncExceptionToMain(ex);
							throw;
						}
						if (Attempts > 0)
						{
							this.OnReconnectError?.Invoke(this, ex);
						}
						int attempts = Attempts;
						Attempts = attempts + 1;
						if (Attempts <= Options.ReconnectionAttempts)
						{
							if (_reconnectionDelay < (double)Options.ReconnectionDelayMax)
							{
								_reconnectionDelay += 2.0 * Options.RandomizationFactor;
							}
							if (_reconnectionDelay > (double)Options.ReconnectionDelayMax)
							{
								_reconnectionDelay = Options.ReconnectionDelayMax;
							}
							await Task.Delay((int)_reconnectionDelay).ConfigureAwait(continueOnCapturedContext: false);
							continue;
						}
						this.OnReconnectFailed?.Invoke(this, EventArgs.Empty);
					}
					break;
				}
				_isConnectCoreRunning = false;
			});
		}

		private async Task<TransportProtocol> GetProtocolAsync()
		{
			if (Options.Transport == TransportProtocol.Polling && Options.AutoUpgrade)
			{
				Uri serverUri = UriConverter.GetServerUri(ws: false, ServerUri, Options.EIO, Options.Path, Options.Query);
				try
				{
					if ((await HttpClient.GetStringAsync(serverUri)).Contains("websocket"))
					{
						return TransportProtocol.WebSocket;
					}
				}
				catch
				{
				}
			}
			return Options.Transport;
		}

		public async Task ConnectAsync()
		{
			ConnectCore();
			while (_isConnectCoreRunning)
			{
				await Task.Delay(20);
			}
			if (_connectCoreException != null)
			{
				throw _connectCoreException;
			}
		}

		private void PingHandler()
		{
			this.OnPing?.Invoke(this, EventArgs.Empty);
		}

		private void PongHandler(PongMessage msg)
		{
			this.OnPong?.Invoke(this, msg.Duration);
		}

		private void ConnectedHandler(ConnectedMessage msg)
		{
			Id = msg.Sid;
			Connected = true;
			this.OnConnected?.Invoke(this, EventArgs.Empty);
			if (Attempts > 0)
			{
				this.OnReconnected?.Invoke(this, Attempts);
			}
			Attempts = 0;
		}

		private void DisconnectedHandler()
		{
			InvokeDisconnect(DisconnectReason.IOServerDisconnect);
		}

		private void EventMessageHandler(EventMessage m)
		{
			SocketIOResponse socketIOResponse = new SocketIOResponse(m.JsonElements, this)
			{
				PacketId = m.Id
			};
			foreach (OnAnyHandler onAnyHandler in _onAnyHandlers)
			{
				try
				{
					onAnyHandler(m.Event, socketIOResponse);
				}
				catch (Exception)
				{
				}
			}
			if (_eventHandlers.ContainsKey(m.Event))
			{
				try
				{
					_eventHandlers[m.Event](socketIOResponse);
				}
				catch (Exception)
				{
				}
			}
		}

		private void AckMessageHandler(ClientAckMessage m)
		{
			if (_ackHandlers.ContainsKey(m.Id))
			{
				SocketIOResponse obj = new SocketIOResponse(m.JsonElements, this);
				try
				{
					_ackHandlers[m.Id](obj);
				}
				finally
				{
					_ackHandlers.Remove(m.Id);
				}
			}
		}

		private void ErrorMessageHandler(ErrorMessage msg)
		{
			this.OnError?.Invoke(this, msg.Message);
		}

		private void BinaryMessageHandler(BinaryMessage msg)
		{
			if (_eventHandlers.ContainsKey(msg.Event))
			{
				try
				{
					SocketIOResponse socketIOResponse = new SocketIOResponse(msg.JsonElements, this)
					{
						PacketId = msg.Id
					};
					socketIOResponse.InComingBytes.AddRange(msg.IncomingBytes);
					_eventHandlers[msg.Event](socketIOResponse);
				}
				catch (Exception)
				{
				}
			}
		}

		private void BinaryAckMessageHandler(ClientBinaryAckMessage msg)
		{
			if (_ackHandlers.ContainsKey(msg.Id))
			{
				try
				{
					SocketIOResponse socketIOResponse = new SocketIOResponse(msg.JsonElements, this)
					{
						PacketId = msg.Id
					};
					socketIOResponse.InComingBytes.AddRange(msg.IncomingBytes);
					_ackHandlers[msg.Id](socketIOResponse);
				}
				catch (Exception)
				{
				}
			}
		}

		private void OnErrorReceived(Exception ex)
		{
			InvokeDisconnect(DisconnectReason.TransportClose);
		}

		private void OnMessageReceived(IMessage msg)
		{
			try
			{
				switch (msg.Type)
				{
				case MessageType.Ping:
					PingHandler();
					break;
				case MessageType.Pong:
					PongHandler(msg as PongMessage);
					break;
				case MessageType.Connected:
					ConnectedHandler(msg as ConnectedMessage);
					break;
				case MessageType.Disconnected:
					DisconnectedHandler();
					break;
				case MessageType.EventMessage:
					EventMessageHandler(msg as EventMessage);
					break;
				case MessageType.AckMessage:
					AckMessageHandler(msg as ClientAckMessage);
					break;
				case MessageType.ErrorMessage:
					ErrorMessageHandler(msg as ErrorMessage);
					break;
				case MessageType.BinaryMessage:
					BinaryMessageHandler(msg as BinaryMessage);
					break;
				case MessageType.BinaryAckMessage:
					BinaryAckMessageHandler(msg as ClientBinaryAckMessage);
					break;
				}
			}
			catch (Exception)
			{
			}
		}

		public async Task DisconnectAsync()
		{
			if (Connected)
			{
				DisconnectedMessage msg = new DisconnectedMessage
				{
					Namespace = Namespace
				};
				try
				{
					await _transport.SendAsync(msg, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
				}
				catch (Exception)
				{
				}
				InvokeDisconnect(DisconnectReason.IOClientDisconnect);
			}
		}

		public void On(string eventName, Action<SocketIOResponse> callback)
		{
			if (_eventHandlers.ContainsKey(eventName))
			{
				_eventHandlers.Remove(eventName);
			}
			_eventHandlers.Add(eventName, callback);
		}

		public void Off(string eventName)
		{
			if (_eventHandlers.ContainsKey(eventName))
			{
				_eventHandlers.Remove(eventName);
			}
		}

		public void OnAny(OnAnyHandler handler)
		{
			if (handler != null)
			{
				_onAnyHandlers.Add(handler);
			}
		}

		public void PrependAny(OnAnyHandler handler)
		{
			if (handler != null)
			{
				_onAnyHandlers.Insert(0, handler);
			}
		}

		public void OffAny(OnAnyHandler handler)
		{
			if (handler != null)
			{
				_onAnyHandlers.Remove(handler);
			}
		}

		private async void InvokeDisconnect(string reason)
		{
			if (Connected)
			{
				Connected = false;
				this.OnDisconnected?.Invoke(this, reason);
				try
				{
					await _transport.DisconnectAsync(CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
				}
				catch
				{
				}
				if (reason != DisconnectReason.IOServerDisconnect && reason != DisconnectReason.IOClientDisconnect && Options.Reconnection)
				{
					ConnectCore();
				}
			}
		}

		public void AddExpectedException(Type type)
		{
			if (!_expectedExceptions.Contains(type))
			{
				_expectedExceptions.Add(type);
			}
		}

		private void DisposeForReconnect()
		{
			_packetId = -1;
			_ackHandlers.Clear();
			if (_connectionTokenSource != null)
			{
				_connectionTokenSource.Cancel();
				_connectionTokenSource.Dispose();
			}
		}

		public void Dispose()
		{
			HttpClient.Dispose();
			_transport.Dispose();
			_ackHandlers.Clear();
			_onAnyHandlers.Clear();
			_eventHandlers.Clear();
			_connectionTokenSource.Cancel();
			_connectionTokenSource.Dispose();
		}
	}
	public sealed class SocketIOOptions
	{
		private double _randomizationFactor;

		public string Path { get; set; }

		public TimeSpan ConnectionTimeout { get; set; }

		public IEnumerable<KeyValuePair<string, string>> Query { get; set; }

		public bool Reconnection { get; set; }

		public double ReconnectionDelay { get; set; }

		public int ReconnectionDelayMax { get; set; }

		public int ReconnectionAttempts { get; set; }

		public double RandomizationFactor
		{
			get
			{
				return _randomizationFactor;
			}
			set
			{
				if (value >= 0.0 && value <= 1.0)
				{
					_randomizationFactor = value;
					return;
				}
				throw new ArgumentException("RandomizationFactor should be greater than or equal to 0.0, and less than 1.0.");
			}
		}

		public Dictionary<string, string> ExtraHeaders { get; set; }

		public TransportProtocol Transport { get; set; }

		public int EIO { get; set; }

		public bool AutoUpgrade { get; set; }

		public object Auth { get; set; }

		public SocketIOOptions()
		{
			RandomizationFactor = 0.5;
			ReconnectionDelay = 1000.0;
			ReconnectionDelayMax = 5000;
			ReconnectionAttempts = int.MaxValue;
			Path = "/socket.io";
			ConnectionTimeout = TimeSpan.FromSeconds(20.0);
			Reconnection = true;
			Transport = TransportProtocol.Polling;
			EIO = 4;
			AutoUpgrade = true;
		}
	}
	public class SocketIOResponse
	{
		private readonly IList<JObject> _array;

		public List<byte[]> InComingBytes { get; }

		public SocketIO SocketIO { get; }

		public int PacketId { get; set; }

		public int Count => _array.Count;

		public SocketIOResponse(IList<JObject> array, SocketIO socket)
		{
			_array = array;
			InComingBytes = new List<byte[]>();
			SocketIO = socket;
			PacketId = -1;
		}

		public JObject GetValue(int index = 0)
		{
			return _array[index];
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append('[');
			foreach (JObject item in _array)
			{
				stringBuilder.Append(((object)item).ToString());
				if (_array.IndexOf(item) < _array.Count - 1)
				{
					stringBuilder.Append(',');
				}
			}
			stringBuilder.Append(']');
			return stringBuilder.ToString();
		}
	}
}
namespace SocketIOClient.UriConverters
{
	public interface IUriConverter
	{
		Uri GetServerUri(bool ws, Uri serverUri, int eio, string path, IEnumerable<KeyValuePair<string, string>> queryParams);
	}
	public class UriConverter : IUriConverter
	{
		public Uri GetServerUri(bool ws, Uri serverUri, int eio, string path, IEnumerable<KeyValuePair<string, string>> queryParams)
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (serverUri.Scheme == "https" || serverUri.Scheme == "wss")
			{
				stringBuilder.Append(ws ? "wss://" : "https://");
			}
			else
			{
				if (!(serverUri.Scheme == "http") && !(serverUri.Scheme == "ws"))
				{
					throw new ArgumentException("Only supports 'http, https, ws, wss' protocol");
				}
				stringBuilder.Append(ws ? "ws://" : "http://");
			}
			stringBuilder.Append(serverUri.Host);
			if (!serverUri.IsDefaultPort)
			{
				stringBuilder.Append(":").Append(serverUri.Port);
			}
			if (string.IsNullOrEmpty(path))
			{
				stringBuilder.Append("/socket.io");
			}
			else
			{
				stringBuilder.Append(path);
			}
			stringBuilder.Append("/?EIO=").Append(eio).Append("&transport=")
				.Append(ws ? "websocket" : "polling");
			if (queryParams != null)
			{
				foreach (KeyValuePair<string, string> queryParam in queryParams)
				{
					stringBuilder.Append('&').Append(queryParam.Key).Append('=')
						.Append(queryParam.Value);
				}
			}
			return new Uri(stringBuilder.ToString());
		}
	}
}
namespace SocketIOClient.Transport
{
	public abstract class BaseTransport : IObserver<string>, IObserver<byte[]>, IObservable<IMessage>, IDisposable
	{
		private DateTime _pingTime;

		private readonly Queue<IMessage> _messageQueue;

		protected SocketIOOptions Options { get; }

		protected Subject<IMessage> MessageSubject { get; }

		protected CancellationTokenSource PingTokenSource { get; private set; }

		protected OpenedMessage OpenedMessage { get; private set; }

		public string Namespace { get; set; }

		public IUriConverter UriConverter { get; set; }

		public BaseTransport(SocketIOOptions options)
		{
			Options = options;
			MessageSubject = new Subject<IMessage>();
			UriConverter = new UriConverter();
			_messageQueue = new Queue<IMessage>();
		}

		public async Task SendAsync(IMessage msg, CancellationToken cancellationToken)
		{
			msg.Eio = Options.EIO;
			msg.Protocol = Options.Transport;
			Payload payload = new Payload
			{
				Text = msg.Write()
			};
			if (msg.OutgoingBytes != null)
			{
				payload.Bytes = msg.OutgoingBytes;
			}
			await SendAsync(payload, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}

		protected virtual async Task OpenAsync(OpenedMessage msg)
		{
			OpenedMessage = msg;
			if (Options.EIO == 3 && string.IsNullOrEmpty(Namespace))
			{
				return;
			}
			ConnectedMessage connectMsg = new ConnectedMessage
			{
				Namespace = Namespace,
				Eio = Options.EIO,
				Query = Options.Query
			};
			if (Options.EIO == 4 && Options.Auth != null)
			{
				connectMsg.AuthJsonStr = JsonConvert.SerializeObject((object)new object[1] { Options.Auth }).TrimStart('[').TrimEnd(']');
			}
			for (int i = 1; i <= 3; i++)
			{
				try
				{
					await SendAsync(connectMsg, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
					break;
				}
				catch (Exception error)
				{
					if (i != 3)
					{
						await Task.Delay(TimeSpan.FromMilliseconds(Math.Pow(2.0, i) * 100.0));
					}
					else
					{
						OnError(error);
					}
				}
			}
		}

		private void StartPing(CancellationToken cancellationToken)
		{
			Task.Factory.StartNew((Func<Task>)async delegate
			{
				while (!cancellationToken.IsCancellationRequested)
				{
					await Task.Delay(OpenedMessage.PingInterval);
					if (cancellationToken.IsCancellationRequested)
					{
						break;
					}
					try
					{
						PingMessage ping = new PingMessage();
						await SendAsync(ping, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
						_pingTime = DateTime.Now;
						((SubjectBase<IMessage>)(object)MessageSubject).OnNext((IMessage)ping);
					}
					catch (Exception ex)
					{
						((SubjectBase<IMessage>)(object)MessageSubject).OnError(ex);
						break;
					}
				}
			}, TaskCreationOptions.LongRunning);
		}

		public abstract Task ConnectAsync(Uri uri, CancellationToken cancellationToken);

		public abstract Task DisconnectAsync(CancellationToken cancellationToken);

		public abstract void AddHeader(string key, string val);

		public virtual void Dispose()
		{
			((SubjectBase<IMessage>)(object)MessageSubject).Dispose();
			_messageQueue.Clear();
			if (PingTokenSource != null)
			{
				PingTokenSource.Cancel();
				PingTokenSource.Dispose();
			}
		}

		public abstract Task SendAsync(Payload payload, CancellationToken cancellationToken);

		public void OnCompleted()
		{
			throw new NotImplementedException();
		}

		public void OnError(Exception error)
		{
			((SubjectBase<IMessage>)(object)MessageSubject).OnError(error);
		}

		public void OnNext(string text)
		{
			IMessage message = MessageFactory.CreateMessage(Options.EIO, text);
			if (message == null)
			{
				return;
			}
			if (message.BinaryCount > 0)
			{
				message.IncomingBytes = new List<byte[]>(message.BinaryCount);
				_messageQueue.Enqueue(message);
				return;
			}
			if (message.Type == MessageType.Opened)
			{
				OpenAsync(message as OpenedMessage).ConfigureAwait(continueOnCapturedContext: false);
			}
			if (Options.EIO == 3)
			{
				if (message.Type == MessageType.Connected)
				{
					ConnectedMessage connectedMessage = message as ConnectedMessage;
					connectedMessage.Sid = OpenedMessage.Sid;
					if ((!string.IsNullOrEmpty(Namespace) || !string.IsNullOrEmpty(connectedMessage.Namespace)) && !(connectedMessage.Namespace == Namespace))
					{
						return;
					}
					if (PingTokenSource != null)
					{
						PingTokenSource.Cancel();
					}
					PingTokenSource = new CancellationTokenSource();
					StartPing(PingTokenSource.Token);
				}
				else if (message.Type == MessageType.Pong)
				{
					(message as PongMessage).Duration = DateTime.Now - _pingTime;
				}
			}
			((SubjectBase<IMessage>)(object)MessageSubject).OnNext(message);
			if (message.Type != MessageType.Ping)
			{
				return;
			}
			_pingTime = DateTime.Now;
			try
			{
				SendAsync(new PongMessage(), CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
				((SubjectBase<IMessage>)(object)MessageSubject).OnNext((IMessage)new PongMessage
				{
					Eio = Options.EIO,
					Protocol = Options.Transport,
					Duration = DateTime.Now - _pingTime
				});
			}
			catch (Exception error)
			{
				OnError(error);
			}
		}

		public void OnNext(byte[] bytes)
		{
			if (_messageQueue.Count > 0)
			{
				IMessage message = _messageQueue.Peek();
				message.IncomingBytes.Add(bytes);
				if (message.IncomingBytes.Count == message.BinaryCount)
				{
					((SubjectBase<IMessage>)(object)MessageSubject).OnNext(message);
					_messageQueue.Dequeue();
				}
			}
		}

		public IDisposable Subscribe(IObserver<IMessage> observer)
		{
			return ((SubjectBase<IMessage>)(object)MessageSubject).Subscribe(observer);
		}
	}
	public class Eio3HttpPollingHandler : HttpPollingHandler
	{
		public Eio3HttpPollingHandler(HttpClient httpClient)
			: base(httpClient)
		{
		}

		public override async Task PostAsync(string uri, IEnumerable<byte[]> bytes, CancellationToken cancellationToken)
		{
			List<byte> list = new List<byte>();
			foreach (byte[] @byte in bytes)
			{
				list.Add(1);
				IEnumerable<byte> collection = from x in SplitInt(@byte.Length + 1)
					select (byte)x;
				list.AddRange(collection);
				list.Add(byte.MaxValue);
				list.Add(4);
				list.AddRange(@byte);
			}
			ByteArrayContent byteArrayContent = new ByteArrayContent(list.ToArray());
			byteArrayContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
			await base.HttpClient.PostAsync(AppendRandom(uri), byteArrayContent, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}

		private List<int> SplitInt(int number)
		{
			List<int> list = new List<int>();
			while (number > 0)
			{
				list.Add(number % 10);
				number /= 10;
			}
			list.Reverse();
			return list;
		}

		protected override void ProduceText(string text)
		{
			int num = 0;
			do
			{
				int num2 = text.IndexOf(':', num);
				if (num2 != -1 && int.TryParse(text.Substring(num, num2 - num), out var result))
				{
					string text2 = text.Substring(num2 + 1, result);
					((SubjectBase<string>)(object)base.TextSubject).OnNext(text2);
					num = num2 + result + 1;
					continue;
				}
				break;
			}
			while (num < text.Length);
		}

		public override Task PostAsync(string uri, string content, CancellationToken cancellationToken)
		{
			content = content.Length + ":" + content;
			return base.PostAsync(uri, content, cancellationToken);
		}
	}
	public class Eio4HttpPollingHandler : HttpPollingHandler
	{
		private const char Separator = '\u001e';

		public Eio4HttpPollingHandler(HttpClient httpClient)
			: base(httpClient)
		{
		}

		public override async Task PostAsync(string uri, IEnumerable<byte[]> bytes, CancellationToken cancellationToken)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (byte[] @byte in bytes)
			{
				stringBuilder.Append('b').Append(Convert.ToBase64String(@byte)).Append('\u001e');
			}
			if (stringBuilder.Length != 0)
			{
				string content = stringBuilder.ToString().TrimEnd('\u001e');
				await PostAsync(uri, content, cancellationToken);
			}
		}

		protected override void ProduceText(string text)
		{
			string[] array = text.Split(new char[1] { '\u001e' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string text2 in array)
			{
				if (text2[0] == 'b')
				{
					byte[] array2 = Convert.FromBase64String(text2.Substring(1));
					((SubjectBase<byte[]>)(object)base.BytesSubject).OnNext(array2);
				}
				else
				{
					((SubjectBase<string>)(object)base.TextSubject).OnNext(text2);
				}
			}
		}
	}
	public abstract class HttpPollingHandler : IHttpPollingHandler, IDisposable
	{
		protected HttpClient HttpClient { get; }

		protected Subject<string> TextSubject { get; }

		protected Subject<byte[]> BytesSubject { get; }

		public IObservable<string> TextObservable { get; }

		public IObservable<byte[]> BytesObservable { get; }

		public HttpPollingHandler(HttpClient httpClient)
		{
			HttpClient = httpClient;
			TextSubject = new Subject<string>();
			BytesSubject = new Subject<byte[]>();
			TextObservable = Observable.AsObservable<string>((IObservable<string>)TextSubject);
			BytesObservable = Observable.AsObservable<byte[]>((IObservable<byte[]>)BytesSubject);
		}

		protected string AppendRandom(string uri)
		{
			return uri + "&t=" + DateTimeOffset.Now.ToUnixTimeSeconds();
		}

		public async Task GetAsync(string uri, CancellationToken cancellationToken)
		{
			HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, AppendRandom(uri));
			HttpResponseMessage httpResponseMessage = await HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (!httpResponseMessage.IsSuccessStatusCode)
			{
				throw new HttpRequestException($"Response status code does not indicate success: {httpResponseMessage.StatusCode}");
			}
			await ProduceMessageAsync(httpResponseMessage).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task SendAsync(HttpRequestMessage req, CancellationToken cancellationToken)
		{
			HttpResponseMessage httpResponseMessage = await HttpClient.SendAsync(req, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (!httpResponseMessage.IsSuccessStatusCode)
			{
				throw new HttpRequestException($"Response status code does not indicate success: {httpResponseMessage.StatusCode}");
			}
			await ProduceMessageAsync(httpResponseMessage).ConfigureAwait(continueOnCapturedContext: false);
		}

		public virtual async Task PostAsync(string uri, string content, CancellationToken cancellationToken)
		{
			StringContent content2 = new StringContent(content);
			await ProduceMessageAsync(await HttpClient.PostAsync(AppendRandom(uri), content2, cancellationToken).ConfigureAwait(continueOnCapturedContext: false)).ConfigureAwait(continueOnCapturedContext: false);
		}

		public abstract Task PostAsync(string uri, IEnumerable<byte[]> bytes, CancellationToken cancellationToken);

		private async Task ProduceMessageAsync(HttpResponseMessage resMsg)
		{
			if (resMsg.Content.Headers.ContentType.MediaType == "application/octet-stream")
			{
				ProduceBytes(await resMsg.Content.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext: false));
			}
			else
			{
				ProduceText(await resMsg.Content.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false));
			}
		}

		protected abstract void ProduceText(string text);

		private void ProduceBytes(byte[] bytes)
		{
			int num = 0;
			while (bytes.Length > num + 4)
			{
				byte b = bytes[num];
				StringBuilder stringBuilder = new StringBuilder();
				for (num++; bytes[num] != byte.MaxValue; num++)
				{
					stringBuilder.Append(bytes[num]);
				}
				num++;
				int num2 = int.Parse(stringBuilder.ToString());
				switch (b)
				{
				case 0:
				{
					byte[] array2 = new byte[num2];
					Buffer.BlockCopy(bytes, num, array2, 0, array2.Length);
					((SubjectBase<string>)(object)TextSubject).OnNext(Encoding.UTF8.GetString(array2));
					break;
				}
				case 1:
				{
					byte[] array = new byte[num2 - 1];
					Buffer.BlockCopy(bytes, num + 1, array, 0, array.Length);
					((SubjectBase<byte[]>)(object)BytesSubject).OnNext(array);
					break;
				}
				}
				num += num2;
			}
		}

		public void Dispose()
		{
			((SubjectBase<string>)(object)TextSubject).Dispose();
			((SubjectBase<byte[]>)(object)BytesSubject).Dispose();
		}
	}
	public class HttpTransport : BaseTransport
	{
		private string _httpUri;

		private CancellationTokenSource _pollingTokenSource;

		private readonly HttpClient _http;

		private readonly IHttpPollingHandler _httpPollingHandler;

		public HttpTransport(HttpClient http, IHttpPollingHandler pollingHandler, SocketIOOptions options)
			: base(options)
		{
			_http = http;
			_httpPollingHandler = pollingHandler;
			_httpPollingHandler.TextObservable.Subscribe(this);
			_httpPollingHandler.BytesObservable.Subscribe(this);
		}

		private void StartPolling(CancellationToken cancellationToken)
		{
			Task.Factory.StartNew((Func<Task>)async delegate
			{
				int retry = 0;
				while (!cancellationToken.IsCancellationRequested)
				{
					if (!_httpUri.Contains("&sid="))
					{
						await Task.Delay(20);
					}
					else
					{
						try
						{
							await _httpPollingHandler.GetAsync(_httpUri, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
						}
						catch (Exception ex)
						{
							retry++;
							if (retry >= 3)
							{
								((SubjectBase<IMessage>)(object)base.MessageSubject).OnError(ex);
								break;
							}
							await Task.Delay(100 * (int)Math.Pow(2.0, retry));
						}
					}
				}
			}, TaskCreationOptions.LongRunning);
		}

		public override async Task ConnectAsync(Uri uri, CancellationToken cancellationToken)
		{
			HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, uri);
			_httpUri = uri.ToString();
			await _httpPollingHandler.SendAsync(req, new CancellationTokenSource(base.Options.ConnectionTimeout).Token).ConfigureAwait(continueOnCapturedContext: false);
			if (_pollingTokenSource != null)
			{
				_pollingTokenSource.Cancel();
			}
			_pollingTokenSource = new CancellationTokenSource();
			StartPolling(_pollingTokenSource.Token);
		}

		public override Task DisconnectAsync(CancellationToken cancellationToken)
		{
			_pollingTokenSource.Cancel();
			if (base.PingTokenSource != null)
			{
				base.PingTokenSource.Cancel();
			}
			return Task.CompletedTask;
		}

		public override void AddHeader(string key, string val)
		{
			_http.DefaultRequestHeaders.Add(key, val);
		}

		public override void Dispose()
		{
			base.Dispose();
			_httpPollingHandler.Dispose();
		}

		public override async Task SendAsync(Payload payload, CancellationToken cancellationToken)
		{
			await _httpPollingHandler.PostAsync(_httpUri, payload.Text, cancellationToken);
			if (payload.Bytes != null && payload.Bytes.Count > 0)
			{
				await _httpPollingHandler.PostAsync(_httpUri, payload.Bytes, cancellationToken);
			}
		}

		protected override async Task OpenAsync(OpenedMessage msg)
		{
			_httpUri = _httpUri + "&sid=" + msg.Sid;
			await base.OpenAsync(msg);
		}
	}
	public interface IClientWebSocket : IDisposable
	{
		IObservable<string> TextObservable { get; }

		IObservable<byte[]> BytesObservable { get; }

		Task ConnectAsync(Uri uri, CancellationToken cancellationToken);

		Task DisconnectAsync(CancellationToken cancellationToken);

		Task SendAsync(byte[] bytes, TransportMessageType type, bool endOfMessage, CancellationToken cancellationToken);

		void AddHeader(string key, string val);
	}
	public interface IHttpPollingHandler : IDisposable
	{
		IObservable<string> TextObservable { get; }

		IObservable<byte[]> BytesObservable { get; }

		Task GetAsync(string uri, CancellationToken cancellationToken);

		Task SendAsync(HttpRequestMessage req, CancellationToken cancellationToken);

		Task PostAsync(string uri, string content, CancellationToken cancellationToken);

		Task PostAsync(string uri, IEnumerable<byte[]> bytes, CancellationToken cancellationToken);
	}
	public class Payload
	{
		public string Text { get; set; }

		public List<byte[]> Bytes { get; set; }
	}
	public class SystemNetWebSocketsClientWebSocket : IClientWebSocket, IDisposable
	{
		private const int ReceiveChunkSize = 8192;

		private readonly int _eio;

		private readonly ClientWebSocket _ws;

		private readonly Subject<string> _textSubject;

		private readonly Subject<byte[]> _bytesSubject;

		private readonly CancellationTokenSource _listenCancellation;

		private readonly SemaphoreSlim _sendLock;

		public IObservable<string> TextObservable { get; }

		public IObservable<byte[]> BytesObservable { get; }

		public SystemNetWebSocketsClientWebSocket(int eio)
		{
			_eio = eio;
			_textSubject = new Subject<string>();
			_bytesSubject = new Subject<byte[]>();
			TextObservable = Observable.AsObservable<string>((IObservable<string>)_textSubject);
			BytesObservable = Observable.AsObservable<byte[]>((IObservable<byte[]>)_bytesSubject);
			_ws = new ClientWebSocket();
			_listenCancellation = new CancellationTokenSource();
			_sendLock = new SemaphoreSlim(1, 1);
		}

		private void Listen()
		{
			Task.Factory.StartNew((Func<Task>)async delegate
			{
				while (!_listenCancellation.IsCancellationRequested)
				{
					byte[] buffer = new byte[8192];
					int count = 0;
					WebSocketReceiveResult result = null;
					while (_ws.State == WebSocketState.Open)
					{
						byte[] subBuffer = new byte[8192];
						try
						{
							result = await _ws.ReceiveAsync(new ArraySegment<byte>(subBuffer), CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
							if (buffer.Length - count < result.Count)
							{
								Array.Resize(ref buffer, buffer.Length + result.Count);
							}
							Buffer.BlockCopy(subBuffer, 0, buffer, count, result.Count);
							count += result.Count;
							if (result.EndOfMessage)
							{
								break;
							}
						}
						catch (Exception ex)
						{
							((SubjectBase<string>)(object)_textSubject).OnError(ex);
							break;
						}
					}
					if (result == null)
					{
						break;
					}
					switch (result.MessageType)
					{
					case WebSocketMessageType.Text:
					{
						string @string = Encoding.UTF8.GetString(buffer, 0, count);
						((SubjectBase<string>)(object)_textSubject).OnNext(@string);
						break;
					}
					case WebSocketMessageType.Binary:
					{
						byte[] array;
						if (_eio == 3)
						{
							array = new byte[count - 1];
							Buffer.BlockCopy(buffer, 1, array, 0, array.Length);
						}
						else
						{
							array = new byte[count];
							Buffer.BlockCopy(buffer, 0, array, 0, array.Length);
						}
						((SubjectBase<byte[]>)(object)_bytesSubject).OnNext(array);
						break;
					}
					case WebSocketMessageType.Close:
						((SubjectBase<string>)(object)_textSubject).OnError((Exception)new WebSocketException("Received a Close message"));
						break;
					}
				}
			});
		}

		public async Task ConnectAsync(Uri uri, CancellationToken cancellationToken)
		{
			await _ws.ConnectAsync(uri, cancellationToken);
			Listen();
		}

		public async Task DisconnectAsync(CancellationToken cancellationToken)
		{
			await _ws.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, cancellationToken);
		}

		public async Task SendAsync(byte[] bytes, TransportMessageType type, bool endOfMessage, CancellationToken cancellationToken)
		{
			WebSocketMessageType messageType = WebSocketMessageType.Text;
			if (type == TransportMessageType.Binary)
			{
				messageType = WebSocketMessageType.Binary;
			}
			await _ws.SendAsync(new ArraySegment<byte>(bytes), messageType, endOfMessage, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}

		public void AddHeader(string key, string val)
		{
			_ws.Options.SetRequestHeader(key, val);
		}

		public void Dispose()
		{
			((SubjectBase<string>)(object)_textSubject).Dispose();
			((SubjectBase<byte[]>)(object)_bytesSubject).Dispose();
			_ws.Dispose();
		}
	}
	public enum TransportMessageType
	{
		Text,
		Binary
	}
	public enum TransportProtocol
	{
		Polling,
		WebSocket
	}
	public class WebSocketTransport : BaseTransport
	{
		private const int ReceiveChunkSize = 8192;

		private const int SendChunkSize = 8192;

		private readonly IClientWebSocket _ws;

		private readonly SemaphoreSlim _sendLock;

		public WebSocketTransport(IClientWebSocket ws, SocketIOOptions options)
			: base(options)
		{
			_ws = ws;
			_sendLock = new SemaphoreSlim(1, 1);
			_ws.TextObservable.Subscribe(this);
			_ws.BytesObservable.Subscribe(this);
		}

		private async Task SendAsync(TransportMessageType type, byte[] bytes, CancellationToken cancellationToken)
		{
			_ = 1;
			try
			{
				await _sendLock.WaitAsync().ConfigureAwait(continueOnCapturedContext: false);
				if (type == TransportMessageType.Binary && base.Options.EIO == 3)
				{
					byte[] array = new byte[bytes.Length + 1];
					array[0] = 4;
					Buffer.BlockCopy(bytes, 0, array, 1, bytes.Length);
					bytes = array;
				}
				int pages = (int)Math.Ceiling((double)bytes.Length * 1.0 / 8192.0);
				for (int i = 0; i < pages; i++)
				{
					int num = i * 8192;
					int num2 = 8192;
					if (num + num2 > bytes.Length)
					{
						num2 = bytes.Length - num;
					}
					byte[] array2 = new byte[num2];
					Buffer.BlockCopy(bytes, num, array2, 0, array2.Length);
					bool endOfMessage = pages - 1 == i;
					await _ws.SendAsync(array2, type, endOfMessage, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}
			}
			finally
			{
				_sendLock.Release();
			}
		}

		public override async Task ConnectAsync(Uri uri, CancellationToken cancellationToken)
		{
			await _ws.ConnectAsync(uri, cancellationToken);
		}

		public override async Task DisconnectAsync(CancellationToken cancellationToken)
		{
			await _ws.DisconnectAsync(cancellationToken);
		}

		public override async Task SendAsync(Payload payload, CancellationToken cancellationToken)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(payload.Text);
			await SendAsync(TransportMessageType.Text, bytes, cancellationToken);
			if (payload.Bytes == null)
			{
				return;
			}
			foreach (byte[] @byte in payload.Bytes)
			{
				await SendAsync(TransportMessageType.Binary, @byte, cancellationToken);
			}
		}

		public override void AddHeader(string key, string val)
		{
			_ws.AddHeader(key, val);
		}

		public override void Dispose()
		{
			base.Dispose();
			_sendLock.Dispose();
		}
	}
}
namespace SocketIOClient.Messages
{
	public class BinaryMessage : IMessage
	{
		public MessageType Type => MessageType.BinaryMessage;

		public string Namespace { get; set; }

		public string Event { get; set; }

		public int Id { get; set; }

		public List<JObject> JsonElements { get; set; }

		public string Json { get; set; }

		public int BinaryCount { get; set; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public void Read(string msg)
		{
			int num = msg.IndexOf('-');
			BinaryCount = int.Parse(msg.Substring(0, num));
			int num2 = msg.IndexOf('[');
			int num3 = msg.LastIndexOf(',', num2);
			if (num3 > -1)
			{
				Namespace = msg.Substring(num + 1, num3 - num - 1);
				int num4 = num2 - num3 - 1;
				if (num4 > 0)
				{
					Id = int.Parse(msg.Substring(num3 + 1, num4));
				}
			}
			else
			{
				int num5 = num2 - num - 1;
				if (num5 > 0)
				{
					Id = int.Parse(msg.Substring(num + 1, num5));
				}
			}
			msg.Substring(num2);
			JArray obj = JArray.Parse(((object)((JToken)JObject.Parse(msg)).Root).ToString());
			int num6 = -1;
			foreach (JToken item2 in obj)
			{
				num6++;
				if (num6 == 0)
				{
					Event = Extensions.Value<string>((IEnumerable<JToken>)item2);
					JsonElements = new List<JObject>();
				}
				else
				{
					JObject item = JObject.Parse(((object)item2).ToString());
					JsonElements.Add(item);
				}
			}
		}

		public string Write()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("45").Append(OutgoingBytes.Count).Append('-');
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			if (string.IsNullOrEmpty(Json))
			{
				stringBuilder.Append("[\"").Append(Event).Append("\"]");
			}
			else
			{
				string value = Json.Insert(1, "\"" + Event + "\",");
				stringBuilder.Append(value);
			}
			return stringBuilder.ToString();
		}
	}
	public class ClientAckMessage : IMessage
	{
		public MessageType Type => MessageType.AckMessage;

		public string Namespace { get; set; }

		public string Event { get; set; }

		public List<JObject> JsonElements { get; set; }

		public string Json { get; set; }

		public int Id { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
			int num = msg.IndexOf('[');
			int num2 = msg.LastIndexOf(',', num);
			if (num2 > -1)
			{
				string text = msg.Substring(0, num);
				Namespace = text.Substring(0, num2);
				Id = int.Parse(text.Substring(num2 + 1));
			}
			else
			{
				Id = int.Parse(msg.Substring(0, num));
			}
			msg = msg.Substring(num);
			JToken root = ((JToken)JObject.Parse(msg)).Root;
			JsonElements = new List<JObject>();
			foreach (JToken item in JArray.Parse(((object)root).ToString()))
			{
				JsonElements.Add(Extensions.Value<JObject>((IEnumerable<JToken>)item));
			}
		}

		public string Write()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("42");
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			stringBuilder.Append(Id);
			if (string.IsNullOrEmpty(Json))
			{
				stringBuilder.Append("[\"").Append(Event).Append("\"]");
			}
			else
			{
				string value = Json.Insert(1, "\"" + Event + "\",");
				stringBuilder.Append(value);
			}
			return stringBuilder.ToString();
		}
	}
	public class ClientBinaryAckMessage : IMessage
	{
		public MessageType Type => MessageType.BinaryAckMessage;

		public string Namespace { get; set; }

		public string Event { get; set; }

		public List<JObject> JsonElements { get; set; }

		public string Json { get; set; }

		public int Id { get; set; }

		public int BinaryCount { get; set; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public void Read(string msg)
		{
			int num = msg.IndexOf('-');
			BinaryCount = int.Parse(msg.Substring(0, num));
			int num2 = msg.IndexOf('[');
			int num3 = msg.LastIndexOf(',', num2);
			if (num3 > -1)
			{
				Namespace = msg.Substring(num + 1, num3 - num - 1);
				Id = int.Parse(msg.Substring(num3 + 1, num2 - num3 - 1));
			}
			else
			{
				Id = int.Parse(msg.Substring(num + 1, num2 - num - 1));
			}
			JToken root = ((JToken)JObject.Parse(msg.Substring(num2))).Root;
			JsonElements = new List<JObject>();
			foreach (JToken item in JArray.Parse(((object)root).ToString()))
			{
				JsonElements.Add(Extensions.Value<JObject>((IEnumerable<JToken>)item));
			}
		}

		public string Write()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("45").Append(OutgoingBytes.Count).Append('-');
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			stringBuilder.Append(Id);
			if (string.IsNullOrEmpty(Json))
			{
				stringBuilder.Append("[\"").Append(Event).Append("\"]");
			}
			else
			{
				string value = Json.Insert(1, "\"" + Event + "\",");
				stringBuilder.Append(value);
			}
			return stringBuilder.ToString();
		}
	}
	public class ConnectedMessage : IMessage
	{
		public MessageType Type => MessageType.Connected;

		public string Namespace { get; set; }

		public string Sid { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public IEnumerable<KeyValuePair<string, string>> Query { get; set; }

		public string AuthJsonStr { get; set; }

		public void Read(string msg)
		{
			if (Eio == 3)
			{
				Eio3Read(msg);
			}
			else
			{
				Eio4Read(msg);
			}
		}

		public string Write()
		{
			if (Eio == 3)
			{
				return Eio3Write();
			}
			return Eio4Write();
		}

		public void Eio4Read(string msg)
		{
			int num = msg.IndexOf('{');
			if (num > 0)
			{
				Namespace = msg.Substring(0, num - 1);
				msg = msg.Substring(num);
			}
			else
			{
				Namespace = string.Empty;
			}
			JToken root = ((JToken)JObject.Parse(msg)).Root;
			Sid = root.Value<string>((object)"sid");
		}

		public string Eio4Write()
		{
			StringBuilder stringBuilder = new StringBuilder("40");
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			stringBuilder.Append(AuthJsonStr);
			return stringBuilder.ToString();
		}

		public void Eio3Read(string msg)
		{
			if (msg.Length < 2)
			{
				return;
			}
			int num = msg.IndexOf('/');
			if (num != -1)
			{
				int num2 = msg.IndexOf('?', num);
				if (num2 == -1)
				{
					num2 = msg.IndexOf(',', num);
				}
				if (num2 == -1)
				{
					num2 = msg.Length;
				}
				Namespace = msg.Substring(num, num2);
			}
		}

		public string Eio3Write()
		{
			if (string.IsNullOrEmpty(Namespace))
			{
				return string.Empty;
			}
			StringBuilder stringBuilder = new StringBuilder("40");
			stringBuilder.Append(Namespace);
			if (Query != null)
			{
				int num = -1;
				foreach (KeyValuePair<string, string> item in Query)
				{
					num++;
					if (num == 0)
					{
						stringBuilder.Append('?');
					}
					else
					{
						stringBuilder.Append('&');
					}
					stringBuilder.Append(item.Key).Append('=').Append(item.Value);
				}
			}
			stringBuilder.Append(',');
			return stringBuilder.ToString();
		}
	}
	public class DisconnectedMessage : IMessage
	{
		public MessageType Type => MessageType.Disconnected;

		public string Namespace { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
			Namespace = msg.TrimEnd(',');
		}

		public string Write()
		{
			if (string.IsNullOrEmpty(Namespace))
			{
				return "41";
			}
			return "41" + Namespace + ",";
		}
	}
	public class ErrorMessage : IMessage
	{
		public MessageType Type => MessageType.ErrorMessage;

		public string Message { get; set; }

		public string Namespace { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
			if (Eio == 3)
			{
				Message = msg.Trim('"');
				return;
			}
			int num = msg.IndexOf('{');
			if (num > 0)
			{
				Namespace = msg.Substring(0, num - 1);
				msg = msg.Substring(num);
			}
			JObject val = JObject.Parse(msg);
			Message = ((JToken)val).Root.Value<string>((object)"message");
		}

		public string Write()
		{
			throw new NotImplementedException();
		}
	}
	public class EventMessage : IMessage
	{
		public MessageType Type => MessageType.EventMessage;

		public string Namespace { get; set; }

		public string Event { get; set; }

		public int Id { get; set; }

		public List<JObject> JsonElements { get; set; }

		public string Json { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
			msg = msg.Replace("\n", "\\n").Replace("\r", "\\r");
			msg = msg.Replace("\0", "");
			JToken root = ((JToken)JArray.Parse(msg)).Root;
			Event = ((object)root[(object)0]).ToString();
			JsonElements = new List<JObject>();
			for (int i = 1; i < ((IEnumerable<JToken>)root).Count(); i++)
			{
				JsonElements.Add(Extensions.Value<JObject>((IEnumerable<JToken>)root[(object)i]));
			}
		}

		public string Write()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("42");
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			if (string.IsNullOrEmpty(Json))
			{
				stringBuilder.Append("[\"").Append(Event).Append("\"]");
			}
			else
			{
				string value = Json.Insert(1, "\"" + Event + "\",");
				stringBuilder.Append(value);
			}
			return stringBuilder.ToString();
		}
	}
	public interface IMessage
	{
		MessageType Type { get; }

		List<byte[]> OutgoingBytes { get; set; }

		List<byte[]> IncomingBytes { get; set; }

		int BinaryCount { get; }

		int Eio { get; set; }

		TransportProtocol Protocol { get; set; }

		void Read(string msg);

		string Write();
	}
	public static class MessageFactory
	{
		private static IMessage CreateMessage(MessageType type)
		{
			return type switch
			{
				MessageType.Opened => new OpenedMessage(), 
				MessageType.Ping => new PingMessage(), 
				MessageType.Pong => new PongMessage(), 
				MessageType.Connected => new ConnectedMessage(), 
				MessageType.Disconnected => new DisconnectedMessage(), 
				MessageType.EventMessage => new EventMessage(), 
				MessageType.AckMessage => new ClientAckMessage(), 
				MessageType.ErrorMessage => new ErrorMessage(), 
				MessageType.BinaryMessage => new BinaryMessage(), 
				MessageType.BinaryAckMessage => new ClientBinaryAckMessage(), 
				_ => null, 
			};
		}

		public static IMessage CreateMessage(int eio, string msg)
		{
			foreach (MessageType value in Enum.GetValues(typeof(MessageType)))
			{
				int num = (int)value;
				string text = num.ToString();
				if (!msg.StartsWith(text))
				{
					continue;
				}
				IMessage message = CreateMessage(value);
				if (message != null)
				{
					message.Eio = eio;
					try
					{
						message.Read(msg.Substring(text.Length));
					}
					catch (Exception)
					{
					}
					return message;
				}
			}
			return null;
		}

		public static OpenedMessage CreateOpenedMessage(string msg)
		{
			OpenedMessage openedMessage = new OpenedMessage();
			if (msg[0] == '0')
			{
				openedMessage.Eio = 4;
				openedMessage.Read(msg.Substring(1));
			}
			else
			{
				openedMessage.Eio = 3;
				int num = msg.IndexOf(':');
				openedMessage.Read(msg.Substring(num + 2));
			}
			return openedMessage;
		}
	}
	public enum MessageType
	{
		Opened = 0,
		Ping = 2,
		Pong = 3,
		Connected = 40,
		Disconnected = 41,
		EventMessage = 42,
		AckMessage = 43,
		ErrorMessage = 44,
		BinaryMessage = 45,
		BinaryAckMessage = 46
	}
	public class OpenedMessage : IMessage
	{
		public MessageType Type => MessageType.Opened;

		public string Sid { get; set; }

		public string Namespace { get; set; }

		public List<string> Upgrades { get; private set; }

		public int PingInterval { get; private set; }

		public int PingTimeout { get; private set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
			JToken root = ((JToken)JObject.Parse(msg)).Root;
			Sid = Extensions.Value<string>((IEnumerable<JToken>)root.SelectToken("sid"));
			PingInterval = Extensions.Value<int>((IEnumerable<JToken>)root.SelectToken("pingInterval"));
			PingTimeout = Extensions.Value<int>((IEnumerable<JToken>)root.SelectToken("pingTimeout"));
			Upgrades = new List<string>();
			foreach (JToken item in JArray.Parse(((object)root.SelectToken("upgrades")).ToString()))
			{
				Upgrades.Add(Extensions.Value<string>((IEnumerable<JToken>)item));
			}
		}

		public string Write()
		{
			throw new NotImplementedException();
		}
	}
	public class PingMessage : IMessage
	{
		public MessageType Type => MessageType.Ping;

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
		}

		public string Write()
		{
			return "2";
		}
	}
	public class PongMessage : IMessage
	{
		public MessageType Type => MessageType.Pong;

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public TimeSpan Duration { get; set; }

		public void Read(string msg)
		{
		}

		public string Write()
		{
			return "3";
		}
	}
	public class ServerAckMessage : IMessage
	{
		public MessageType Type => MessageType.AckMessage;

		public string Namespace { get; set; }

		public string Json { get; set; }

		public int Id { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public void Read(string msg)
		{
		}

		public string Write()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("43");
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			stringBuilder.Append(Id);
			if (string.IsNullOrEmpty(Json))
			{
				stringBuilder.Append("[]");
			}
			else
			{
				stringBuilder.Append(Json);
			}
			return stringBuilder.ToString();
		}
	}
	public class ServerBinaryAckMessage : IMessage
	{
		public MessageType Type => MessageType.BinaryAckMessage;

		public string Namespace { get; set; }

		public List<JObject> JsonElements { get; set; }

		public string Json { get; set; }

		public int Id { get; set; }

		public int BinaryCount { get; }

		public int Eio { get; set; }

		public TransportProtocol Protocol { get; set; }

		public List<byte[]> OutgoingBytes { get; set; }

		public List<byte[]> IncomingBytes { get; set; }

		public void Read(string msg)
		{
		}

		public string Write()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("46").Append(OutgoingBytes.Count).Append('-');
			if (!string.IsNullOrEmpty(Namespace))
			{
				stringBuilder.Append(Namespace).Append(',');
			}
			stringBuilder.Append(Id);
			if (string.IsNullOrEmpty(Json))
			{
				stringBuilder.Append("[]");
			}
			else
			{
				stringBuilder.Append(Json);
			}
			return stringBuilder.ToString();
		}
	}
}
namespace LethalStreams
{
	[BepInPlugin("LethalStreams", "LethalStreams", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("LethalStreams");

		private static Plugin _instance;

		private SocketManager _socketManager;

		public bool IsClient => _socketManager.isClient;

		public static ConfigEntry<string> StreamlabsToken { get; set; }

		public static ConfigEntry<int> MaxCharacters { get; set; }

		public static ConfigEntry<bool> SpawnTransmitter { get; set; }

		public static ConfigEntry<int> MinDonationAmount { get; set; }

		public static ConfigEntry<string> DonationPrefix { get; set; }

		public static ConfigEntry<int> MaxSanityBitMin { get; set; }

		public static ConfigEntry<int> MaxSanityBitMax { get; set; }

		public static ConfigEntry<int> Rotate180BitMin { get; set; }

		public static ConfigEntry<int> Rotate180BitMax { get; set; }

		public static ConfigEntry<int> StaminaDrainBitMin { get; set; }

		public static ConfigEntry<int> StaminaDrainBitMax { get; set; }

		public static ConfigEntry<int> FlashlightDrainBitMin { get; set; }

		public static ConfigEntry<int> FlashlightDrainBitMax { get; set; }

		public static ConfigEntry<bool> PlayAirhornSub { get; set; }

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)this);
			StreamlabsToken = ((BaseUnityPlugin)this).Config.Bind<string>("General", "StreamlabsToken", "", "Streamlabs Socket API token (leave empty for client mode)");
			MaxCharacters = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxMessageLength", 30, "The maximum of characters that can be displayed on donation messages");
			SpawnTransmitter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SpawnTransmitter", true, "Spawn a signal transmitter if it doesn't exist");
			MinDonationAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinDonationAmount", 50, "Minimum donation amount to trigger a message");
			DonationPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DonationPrefix", "say:", "Prefix to trigger a donation message");
			MaxSanityBitMin = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "MaxSanityBitMin", 10, "Minimum bits to set max sanity");
			MaxSanityBitMax = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "MaxSanityBitMax", 49, "Maximum bits to set max sanity");
			Rotate180BitMin = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "Rotate180BitMin", 50, "Minimum bits to rotate 180");
			Rotate180BitMax = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "Rotate180BitMax", 99, "Maximum bits to rotate 180");
			StaminaDrainBitMin = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "StaminaDrainBitMin", 100, "Minimum bits to drain stamina");
			StaminaDrainBitMax = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "StaminaDrainBitMax", 149, "Maximum bits to drain stamina");
			FlashlightDrainBitMin = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "FlashlightDrainBitMin", 150, "Minimum bits to drain flashlight");
			FlashlightDrainBitMax = ((BaseUnityPlugin)this).Config.Bind<int>("Bits", "FlashlightDrainBitMax", 99999, "Maximum bits to drain flashlight");
			PlayAirhornSub = ((BaseUnityPlugin)this).Config.Bind<bool>("Bits", "PlayAirhornSub", true, "Play airhorn sound on sub");
			CustomLogger.Initialize("LethalStreams");
			StartOfRoundPatched.Spawn();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			CustomLogger.Log("Patched network types");
			CustomLogger.Log("Setting up streamlabs client");
			_socketManager = SocketManager.Spawn();
			_socketManager.Setup();
			if (!IsClient)
			{
				_socketManager.socket.OnAnyInUnityThread(delegate(string name, SocketIOResponse response)
				{
					//IL_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: Expected O, but got Unknown
					JObject val;
					string text;
					try
					{
						JObject value = response.GetValue();
						val = (JObject)((JArray)value.GetValue("message"))[0];
						text = ((object)value.GetValue("type")).ToString();
					}
					catch (Exception)
					{
						CustomLogger.LogInfo("failed to parse event, ignoring");
						return;
					}
					if ((from x in Enum.GetNames(typeof(StreamEventType))
						select x.ToLower()).ToList().Contains(text))
					{
						StreamEventType streamEventType = (StreamEventType)Enum.Parse(typeof(StreamEventType), text, ignoreCase: true);
						CustomLogger.Log("Received " + streamEventType.ToString() + " event");
						switch (streamEventType)
						{
						case StreamEventType.Donation:
							StreamEvent.OnStreamDonation(((JToken)val).ToObject<Donation>());
							break;
						case StreamEventType.Subscription:
							StreamEvent.OnStreamSubscription(((JToken)val).ToObject<Subscription>());
							break;
						case StreamEventType.Bits:
							StreamEvent.OnStreamBits(((JToken)val).ToObject<Bits>());
							break;
						default:
							throw new ArgumentOutOfRangeException();
						case StreamEventType.Follow:
							break;
						}
					}
				});
			}
			_harmony.PatchAll();
			CustomLogger.LogInfo("Plugin LethalStreams loaded");
		}
	}
	internal static class CustomLogger
	{
		internal static ManualLogSource logSource;

		public static void Initialize(string modGUID)
		{
			logSource = Logger.CreateLogSource(modGUID);
		}

		public static void Log(object message)
		{
			logSource.LogInfo(message);
		}

		public static void LogError(object message)
		{
			logSource.LogError(message);
		}

		public static void LogWarning(object message)
		{
			logSource.LogWarning(message);
		}

		public static void LogInfo(object message)
		{
			logSource.LogInfo(message);
		}
	}
	public class SocketManager : MonoBehaviour
	{
		public SocketIOUnity socket;

		public bool isClient;

		public static SocketManager Instance { get; private set; }

		public static bool IsLoaded { get; private set; }

		public void Awake()
		{
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)this);
			IsLoaded = true;
		}

		public static SocketManager Spawn()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return new GameObject("SocketManager").AddComponent<SocketManager>();
		}

		public void Setup()
		{
			if (Plugin.StreamlabsToken.Value == "")
			{
				isClient = true;
				CustomLogger.Log("Using client mode");
				Object.Destroy((Object)(object)this);
				return;
			}
			Uri uri = new Uri("https://sockets.streamlabs.com");
			socket = new SocketIOUnity(uri, new SocketIOOptions
			{
				Query = new Dictionary<string, string> { 
				{
					"token",
					Plugin.StreamlabsToken.Value
				} },
				EIO = 4,
				Transport = TransportProtocol.WebSocket
			});
			socket.OnConnected += delegate
			{
				CustomLogger.Log("Connected");
				Debug.Log((object)"connected");
			};
			socket.Connect();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalStreams";

		public const string PLUGIN_NAME = "LethalStreams";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace LethalStreams.Streamlabs
{
	public class StreamEvent
	{
		public static PlayerControllerBPatched FindUsernameInMessage(List<PlayerControllerBPatched> playerList, string message)
		{
			return playerList.FirstOrDefault((PlayerControllerBPatched player) => message.IndexOf(player._original.playerUsername, StringComparison.OrdinalIgnoreCase) >= 0);
		}

		public static void OnStreamDonation(Donation donate)
		{
			CustomLogger.Log("Donation received: " + donate.message + " - " + donate.amount + " - " + donate.from);
			if (donate.amount >= Plugin.MinDonationAmount.Value)
			{
				int num = donate.message.IndexOf(Plugin.DonationPrefix.Value, StringComparison.Ordinal);
				if (num > 0)
				{
					string text = donate.message.Substring(num + Plugin.DonationPrefix.Value.Length);
					text = text.Trim();
					text = ((text.Length < Plugin.MaxCharacters.Value) ? text : text.Substring(0, Plugin.MaxCharacters.Value));
					CustomLogger.Log("Transmitting message: " + text);
					HUDManagerNetworkPatched.Instance.UseSignalTranslatorServerRpc(text);
				}
			}
		}

		public static void OnStreamBits(Bits bits)
		{
			CustomLogger.Log("Bits received: " + bits.message + " - " + bits.amount + " - " + bits.name);
			PlayerControllerBPatched playerControllerBPatched = FindUsernameInMessage(PlayerControllerBPatched.GetAllPlayers(), bits.message);
			string playerUsername = PlayerControllerBPatched.GetLocalPlayer()._original.playerUsername;
			if ((Object)(object)playerControllerBPatched != (Object)null)
			{
				playerUsername = playerControllerBPatched._original.playerUsername;
			}
			CustomLogger.Log(playerUsername);
			if (InRange(bits.amount, Plugin.FlashlightDrainBitMin.Value, Plugin.FlashlightDrainBitMax.Value))
			{
				HUDManagerNetworkPatched.Instance.DrainFlashlightBatteryServerRpc(playerUsername);
			}
			else if (InRange(bits.amount, Plugin.StaminaDrainBitMin.Value, Plugin.StaminaDrainBitMax.Value))
			{
				HUDManagerNetworkPatched.Instance.DrainStaminaServerRpc(playerUsername);
			}
			else if (InRange(bits.amount, Plugin.Rotate180BitMin.Value, Plugin.Rotate180BitMax.Value))
			{
				HUDManagerNetworkPatched.Instance.Rotate180ServerRpc(playerUsername);
			}
			else if (InRange(bits.amount, Plugin.MaxSanityBitMin.Value, Plugin.MaxSanityBitMax.Value))
			{
				HUDManagerNetworkPatched.Instance.SetMaxSanityServerRpc(playerUsername);
			}
			static bool InRange(int amount, int rangeMin, int rangeMax)
			{
				if (amount >= rangeMin)
				{
					return amount <= rangeMax;
				}
				return false;
			}
		}

		public static void OnStreamSubscription(Subscription sub)
		{
			CustomLogger.Log("Subscription received: " + sub.message + " - " + sub.name + " - " + sub.months);
			PlayerControllerBPatched playerControllerBPatched = FindUsernameInMessage(PlayerControllerBPatched.GetAllPlayers(), sub.message);
			string playerUsername = PlayerControllerBPatched.GetLocalPlayer()._original.playerUsername;
			if ((Object)(object)playerControllerBPatched != (Object)null)
			{
				playerUsername = playerControllerBPatched._original.playerUsername;
			}
			CustomLogger.Log(playerUsername);
			if (Plugin.PlayAirhornSub.Value)
			{
				HUDManagerNetworkPatched.Instance.MakeAirHornNoiseServerRpc(playerUsername);
			}
		}
	}
	public enum StreamEventType
	{
		Donation,
		Subscription,
		Follow,
		Host,
		Bits,
		Raid
	}
	public static class StreamEventTypeExtensions
	{
		public static string ToString(this StreamEventType eventType)
		{
			return eventType.ToString().ToLower();
		}
	}
	public class Donation : StreamEvent
	{
		public int id { get; set; }

		public string name { get; set; }

		public int amount { get; set; }

		public string formattedAmount { get; set; }

		public string message { get; set; }

		public string currency { get; set; }

		public string from { get; set; }
	}
	public class Follow : StreamEvent
	{
		public string name { get; set; }
	}
	public class Subscription : StreamEvent
	{
		public string name { get; set; }

		public string months { get; set; }

		public string message { get; set; }
	}
	public class Host : StreamEvent
	{
		public string name { get; set; }

		public string viewers { get; set; }

		public string type { get; set; }
	}
	public class Bits : StreamEvent
	{
		public string name { get; set; }

		public int amount { get; set; }

		public string message { get; set; }

		public string SanitizedMessage()
		{
			string text = message;
			string text2 = "cheer" + amount;
			if (text.Contains(text2))
			{
				text = text.Replace(text2, "");
			}
			return text;
		}
	}
	public class Raid : StreamEvent
	{
		public string name { get; set; }

		public string viewers { get; set; }
	}
}
namespace LethalStreams.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager), "Start")]
	public class GameNetworkManagerOriginal
	{
		private static void Prefix(GameNetworkManager __instance)
		{
			HUDManagerNetworkPatched.Register(__instance);
		}
	}
	public class GameNetworkManagerPatched : MonoBehaviour
	{
		public GameNetworkManager _original;

		public static GameNetworkManagerPatched Instance { get; private set; }

		public static void Spawn(GameNetworkManager __instance)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new GameObject("GameNetworkManagerPatched").AddComponent<GameNetworkManagerPatched>();
			CustomLogger.LogInfo("Spawned GameNetworkManagerPatched.");
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Instance = this;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Start")]
	public class HUDManagerOriginal
	{
		private static void Postfix(HUDManager __instance)
		{
			HUDManagerNetworkPatched.Instance._original = __instance;
			CustomLogger.LogInfo("Captured HUDManager instance.");
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Update")]
	public class HUDManagerOriginalBackup
	{
		private static void Postfix(HUDManager __instance)
		{
			if (Object.op_Implicit((Object)(object)HUDManagerNetworkPatched.Instance) && !((Object)(object)HUDManagerNetworkPatched.Instance._original == (Object)(object)__instance))
			{
				HUDManagerNetworkPatched.Instance._original = __instance;
				CustomLogger.LogInfo("Captured HUDManager instance using backup call.");
			}
		}
	}
	public class HUDManagerNetworkPatched : NetworkBehaviour
	{
		public HUDManager _original;

		public static GameObject networkPrefab;

		public static HUDManagerNetworkPatched Instance { get; private set; }

		public static void Register(GameNetworkManager gameNetworkManager)
		{
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalstreams")).LoadAsset<GameObject>("Assets/NetworkPrefab.prefab");
				networkPrefab.AddComponent<HUDManagerNetworkPatched>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				CustomLogger.LogInfo("Registered HUDManagerNetworkPatched.");
			}
		}

		public static void Spawn()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
			CustomLogger.LogInfo("Spawned HUDManagerNetworkPatched.");
		}

		public override void OnNetworkSpawn()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				HUDManagerNetworkPatched instance = Instance;
				if (instance != null)
				{
					((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ServerRpc]
		public void DrainFlashlightBatteryServerRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(988541123u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 988541123u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && NetworkManager.Singleton.IsServer)
			{
				DrainFlashlightBatteryClientRpc(username);
			}
		}

		[ClientRpc]
		public void DrainFlashlightBatteryClientRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1238729071u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1238729071u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				CustomLogger.Log("DrainFlashlightBatteryClientRpc");
				PlayerControllerBPatched currentPlayer = PlayerControllerBPatched.GetCurrentPlayer(username);
				if (!((Object)(object)currentPlayer == (Object)null))
				{
					currentPlayer.DrainFlashlightBattery();
				}
			}
		}

		[ServerRpc]
		public void DrainStaminaServerRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1870841891u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1870841891u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && NetworkManager.Singleton.IsServer)
			{
				DrainStaminaClientRpc(username);
			}
		}

		[ClientRpc]
		public void DrainStaminaClientRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3550139813u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3550139813u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				CustomLogger.Log("DrainStaminaClientRpc");
				PlayerControllerBPatched currentPlayer = PlayerControllerBPatched.GetCurrentPlayer(username);
				if (!((Object)(object)currentPlayer == (Object)null))
				{
					currentPlayer.DrainStamina();
				}
			}
		}

		[ServerRpc]
		public void SetMaxSanityServerRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2424814417u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2424814417u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && NetworkManager.Singleton.IsServer)
			{
				SetMaxSanityClientRpc(username);
			}
		}

		[ClientRpc]
		public void SetMaxSanityClientRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4108053027u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4108053027u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				CustomLogger.Log("SetMaxSanityClientRpc");
				PlayerControllerBPatched currentPlayer = PlayerControllerBPatched.GetCurrentPlayer(username);
				if (!((Object)(object)currentPlayer == (Object)null))
				{
					currentPlayer.SetMaxSanity();
				}
			}
		}

		[ServerRpc]
		public void Rotate180ServerRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1295710622u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1295710622u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && NetworkManager.Singleton.IsServer)
			{
				Rotate180ClientRpc(username);
			}
		}

		[ClientRpc]
		public void Rotate180ClientRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2123301264u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2123301264u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				CustomLogger.Log("Rotate180ClientRpc");
				PlayerControllerBPatched currentPlayer = PlayerControllerBPatched.GetCurrentPlayer(username);
				if (!((Object)(object)currentPlayer == (Object)null))
				{
					currentPlayer.Rotate180();
				}
			}
		}

		[ServerRpc]
		public void MakeAirHornNoiseServerRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2913937792u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2913937792u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && NetworkManager.Singleton.IsServer)
			{
				MakeAirHornNoiseClientRpc(username);
			}
		}

		[ClientRpc]
		public void MakeAirHornNoiseClientRpc(string username = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3674339135u, val, (RpcDelivery)0);
				bool flag = username != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(username, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3674339135u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				CustomLogger.Log("MakeAirHornNoiseClientRpc");
				AudioClip val3 = ((IEnumerable<AudioClip>)Resources.FindObjectsOfTypeAll<AudioClip>()).FirstOrDefault((Func<AudioClip, bool>)((AudioClip x) => ((Object)x).name == "AirHorn1"));
				PlayerControllerBPatched currentPlayer = PlayerControllerBPatched.GetCurrentPlayer(username);
				if (!((Object)(object)currentPlayer == (Object)null))
				{
					currentPlayer._original.itemAudio.PlayOneShot(val3);
				}
			}
		}

		[ServerRpc]
		public void UseSignalTranslatorServerRpc(string signalMessage)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((Networ