// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information. 

using System.Reactive.Disposables;

namespace System.Reactive.Linq.ObservableImpl
{
    #region [3,16]-ary

    /* The following code is generated by a T4 template. */

    #region Zip auto-generated code (10/2/2020 12:26:57 PM)

    internal sealed class Zip<T1, T2, T3, TResult> : Producer<TResult, Zip<T1, T2, T3, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly Func<T1, T2, T3, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, Func<T1, T2, T3, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;

            public _(Func<T1, T2, T3, TResult> resultSelector, IObserver<TResult> observer)
                : base(3, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3)
            {
                var disposables = new IDisposable[3];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly Func<T1, T2, T3, T4, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, Func<T1, T2, T3, T4, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;

            public _(Func<T1, T2, T3, T4, TResult> resultSelector, IObserver<TResult> observer)
                : base(4, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4)
            {
                var disposables = new IDisposable[4];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly Func<T1, T2, T3, T4, T5, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, Func<T1, T2, T3, T4, T5, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;

            public _(Func<T1, T2, T3, T4, T5, TResult> resultSelector, IObserver<TResult> observer)
                : base(5, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5)
            {
                var disposables = new IDisposable[5];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly Func<T1, T2, T3, T4, T5, T6, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, Func<T1, T2, T3, T4, T5, T6, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;

            public _(Func<T1, T2, T3, T4, T5, T6, TResult> resultSelector, IObserver<TResult> observer)
                : base(6, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6)
            {
                var disposables = new IDisposable[6];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, Func<T1, T2, T3, T4, T5, T6, T7, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, TResult> resultSelector, IObserver<TResult> observer)
                : base(7, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7)
            {
                var disposables = new IDisposable[7];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> resultSelector, IObserver<TResult> observer)
                : base(8, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8)
            {
                var disposables = new IDisposable[8];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> resultSelector, IObserver<TResult> observer)
                : base(9, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9)
            {
                var disposables = new IDisposable[9];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> resultSelector, IObserver<TResult> observer)
                : base(10, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10)
            {
                var disposables = new IDisposable[10];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly IObservable<T11> _source11;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _source11 = source11;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;
            private readonly ZipObserver<T11> _observer11;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> resultSelector, IObserver<TResult> observer)
                : base(11, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
                _observer11 = new ZipObserver<T11>(_gate, this, 10);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11)
            {
                var disposables = new IDisposable[11];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                disposables[10] = _observer11;
                Queues[10] = _observer11.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));
                _observer11.SetResource(source11.SubscribeSafe(_observer11));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue(), _observer11.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly IObservable<T11> _source11;
        private readonly IObservable<T12> _source12;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _source11 = source11;
            _source12 = source12;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;
            private readonly ZipObserver<T11> _observer11;
            private readonly ZipObserver<T12> _observer12;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> resultSelector, IObserver<TResult> observer)
                : base(12, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
                _observer11 = new ZipObserver<T11>(_gate, this, 10);
                _observer12 = new ZipObserver<T12>(_gate, this, 11);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12)
            {
                var disposables = new IDisposable[12];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                disposables[10] = _observer11;
                Queues[10] = _observer11.Values;

                disposables[11] = _observer12;
                Queues[11] = _observer12.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));
                _observer11.SetResource(source11.SubscribeSafe(_observer11));
                _observer12.SetResource(source12.SubscribeSafe(_observer12));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue(), _observer11.Values.Dequeue(), _observer12.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly IObservable<T11> _source11;
        private readonly IObservable<T12> _source12;
        private readonly IObservable<T13> _source13;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _source11 = source11;
            _source12 = source12;
            _source13 = source13;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;
            private readonly ZipObserver<T11> _observer11;
            private readonly ZipObserver<T12> _observer12;
            private readonly ZipObserver<T13> _observer13;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> resultSelector, IObserver<TResult> observer)
                : base(13, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
                _observer11 = new ZipObserver<T11>(_gate, this, 10);
                _observer12 = new ZipObserver<T12>(_gate, this, 11);
                _observer13 = new ZipObserver<T13>(_gate, this, 12);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13)
            {
                var disposables = new IDisposable[13];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                disposables[10] = _observer11;
                Queues[10] = _observer11.Values;

                disposables[11] = _observer12;
                Queues[11] = _observer12.Values;

                disposables[12] = _observer13;
                Queues[12] = _observer13.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));
                _observer11.SetResource(source11.SubscribeSafe(_observer11));
                _observer12.SetResource(source12.SubscribeSafe(_observer12));
                _observer13.SetResource(source13.SubscribeSafe(_observer13));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue(), _observer11.Values.Dequeue(), _observer12.Values.Dequeue(), _observer13.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly IObservable<T11> _source11;
        private readonly IObservable<T12> _source12;
        private readonly IObservable<T13> _source13;
        private readonly IObservable<T14> _source14;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, IObservable<T14> source14, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _source11 = source11;
            _source12 = source12;
            _source13 = source13;
            _source14 = source14;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;
            private readonly ZipObserver<T11> _observer11;
            private readonly ZipObserver<T12> _observer12;
            private readonly ZipObserver<T13> _observer13;
            private readonly ZipObserver<T14> _observer14;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> resultSelector, IObserver<TResult> observer)
                : base(14, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
                _observer11 = new ZipObserver<T11>(_gate, this, 10);
                _observer12 = new ZipObserver<T12>(_gate, this, 11);
                _observer13 = new ZipObserver<T13>(_gate, this, 12);
                _observer14 = new ZipObserver<T14>(_gate, this, 13);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, IObservable<T14> source14)
            {
                var disposables = new IDisposable[14];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                disposables[10] = _observer11;
                Queues[10] = _observer11.Values;

                disposables[11] = _observer12;
                Queues[11] = _observer12.Values;

                disposables[12] = _observer13;
                Queues[12] = _observer13.Values;

                disposables[13] = _observer14;
                Queues[13] = _observer14.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));
                _observer11.SetResource(source11.SubscribeSafe(_observer11));
                _observer12.SetResource(source12.SubscribeSafe(_observer12));
                _observer13.SetResource(source13.SubscribeSafe(_observer13));
                _observer14.SetResource(source14.SubscribeSafe(_observer14));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue(), _observer11.Values.Dequeue(), _observer12.Values.Dequeue(), _observer13.Values.Dequeue(), _observer14.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly IObservable<T11> _source11;
        private readonly IObservable<T12> _source12;
        private readonly IObservable<T13> _source13;
        private readonly IObservable<T14> _source14;
        private readonly IObservable<T15> _source15;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, IObservable<T14> source14, IObservable<T15> source15, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _source11 = source11;
            _source12 = source12;
            _source13 = source13;
            _source14 = source14;
            _source15 = source15;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14, _source15);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;
            private readonly ZipObserver<T11> _observer11;
            private readonly ZipObserver<T12> _observer12;
            private readonly ZipObserver<T13> _observer13;
            private readonly ZipObserver<T14> _observer14;
            private readonly ZipObserver<T15> _observer15;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> resultSelector, IObserver<TResult> observer)
                : base(15, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
                _observer11 = new ZipObserver<T11>(_gate, this, 10);
                _observer12 = new ZipObserver<T12>(_gate, this, 11);
                _observer13 = new ZipObserver<T13>(_gate, this, 12);
                _observer14 = new ZipObserver<T14>(_gate, this, 13);
                _observer15 = new ZipObserver<T15>(_gate, this, 14);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, IObservable<T14> source14, IObservable<T15> source15)
            {
                var disposables = new IDisposable[15];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                disposables[10] = _observer11;
                Queues[10] = _observer11.Values;

                disposables[11] = _observer12;
                Queues[11] = _observer12.Values;

                disposables[12] = _observer13;
                Queues[12] = _observer13.Values;

                disposables[13] = _observer14;
                Queues[13] = _observer14.Values;

                disposables[14] = _observer15;
                Queues[14] = _observer15.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));
                _observer11.SetResource(source11.SubscribeSafe(_observer11));
                _observer12.SetResource(source12.SubscribeSafe(_observer12));
                _observer13.SetResource(source13.SubscribeSafe(_observer13));
                _observer14.SetResource(source14.SubscribeSafe(_observer14));
                _observer15.SetResource(source15.SubscribeSafe(_observer15));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue(), _observer11.Values.Dequeue(), _observer12.Values.Dequeue(), _observer13.Values.Dequeue(), _observer14.Values.Dequeue(), _observer15.Values.Dequeue());
        }
    }

    internal sealed class Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> : Producer<TResult, Zip<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>._>
    {
        private readonly IObservable<T1> _source1;
        private readonly IObservable<T2> _source2;
        private readonly IObservable<T3> _source3;
        private readonly IObservable<T4> _source4;
        private readonly IObservable<T5> _source5;
        private readonly IObservable<T6> _source6;
        private readonly IObservable<T7> _source7;
        private readonly IObservable<T8> _source8;
        private readonly IObservable<T9> _source9;
        private readonly IObservable<T10> _source10;
        private readonly IObservable<T11> _source11;
        private readonly IObservable<T12> _source12;
        private readonly IObservable<T13> _source13;
        private readonly IObservable<T14> _source14;
        private readonly IObservable<T15> _source15;
        private readonly IObservable<T16> _source16;
        private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> _resultSelector;

        public Zip(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, IObservable<T14> source14, IObservable<T15> source15, IObservable<T16> source16, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> resultSelector)
        {
            _source1 = source1;
            _source2 = source2;
            _source3 = source3;
            _source4 = source4;
            _source5 = source5;
            _source6 = source6;
            _source7 = source7;
            _source8 = source8;
            _source9 = source9;
            _source10 = source10;
            _source11 = source11;
            _source12 = source12;
            _source13 = source13;
            _source14 = source14;
            _source15 = source15;
            _source16 = source16;
            _resultSelector = resultSelector;
        }

        protected override _ CreateSink(IObserver<TResult> observer) => new(_resultSelector, observer);

        protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14, _source15, _source16);

        internal sealed class _ : ZipSink<TResult>
        {
            private readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> _resultSelector;

            private readonly ZipObserver<T1> _observer1;
            private readonly ZipObserver<T2> _observer2;
            private readonly ZipObserver<T3> _observer3;
            private readonly ZipObserver<T4> _observer4;
            private readonly ZipObserver<T5> _observer5;
            private readonly ZipObserver<T6> _observer6;
            private readonly ZipObserver<T7> _observer7;
            private readonly ZipObserver<T8> _observer8;
            private readonly ZipObserver<T9> _observer9;
            private readonly ZipObserver<T10> _observer10;
            private readonly ZipObserver<T11> _observer11;
            private readonly ZipObserver<T12> _observer12;
            private readonly ZipObserver<T13> _observer13;
            private readonly ZipObserver<T14> _observer14;
            private readonly ZipObserver<T15> _observer15;
            private readonly ZipObserver<T16> _observer16;

            public _(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> resultSelector, IObserver<TResult> observer)
                : base(16, observer)
            {
                _resultSelector = resultSelector;

                _observer1 = new ZipObserver<T1>(_gate, this, 0);
                _observer2 = new ZipObserver<T2>(_gate, this, 1);
                _observer3 = new ZipObserver<T3>(_gate, this, 2);
                _observer4 = new ZipObserver<T4>(_gate, this, 3);
                _observer5 = new ZipObserver<T5>(_gate, this, 4);
                _observer6 = new ZipObserver<T6>(_gate, this, 5);
                _observer7 = new ZipObserver<T7>(_gate, this, 6);
                _observer8 = new ZipObserver<T8>(_gate, this, 7);
                _observer9 = new ZipObserver<T9>(_gate, this, 8);
                _observer10 = new ZipObserver<T10>(_gate, this, 9);
                _observer11 = new ZipObserver<T11>(_gate, this, 10);
                _observer12 = new ZipObserver<T12>(_gate, this, 11);
                _observer13 = new ZipObserver<T13>(_gate, this, 12);
                _observer14 = new ZipObserver<T14>(_gate, this, 13);
                _observer15 = new ZipObserver<T15>(_gate, this, 14);
                _observer16 = new ZipObserver<T16>(_gate, this, 15);
            }

            public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, IObservable<T8> source8, IObservable<T9> source9, IObservable<T10> source10, IObservable<T11> source11, IObservable<T12> source12, IObservable<T13> source13, IObservable<T14> source14, IObservable<T15> source15, IObservable<T16> source16)
            {
                var disposables = new IDisposable[16];

                disposables[0] = _observer1;
                Queues[0] = _observer1.Values;

                disposables[1] = _observer2;
                Queues[1] = _observer2.Values;

                disposables[2] = _observer3;
                Queues[2] = _observer3.Values;

                disposables[3] = _observer4;
                Queues[3] = _observer4.Values;

                disposables[4] = _observer5;
                Queues[4] = _observer5.Values;

                disposables[5] = _observer6;
                Queues[5] = _observer6.Values;

                disposables[6] = _observer7;
                Queues[6] = _observer7.Values;

                disposables[7] = _observer8;
                Queues[7] = _observer8.Values;

                disposables[8] = _observer9;
                Queues[8] = _observer9.Values;

                disposables[9] = _observer10;
                Queues[9] = _observer10.Values;

                disposables[10] = _observer11;
                Queues[10] = _observer11.Values;

                disposables[11] = _observer12;
                Queues[11] = _observer12.Values;

                disposables[12] = _observer13;
                Queues[12] = _observer13.Values;

                disposables[13] = _observer14;
                Queues[13] = _observer14.Values;

                disposables[14] = _observer15;
                Queues[14] = _observer15.Values;

                disposables[15] = _observer16;
                Queues[15] = _observer16.Values;

                _observer1.SetResource(source1.SubscribeSafe(_observer1));
                _observer2.SetResource(source2.SubscribeSafe(_observer2));
                _observer3.SetResource(source3.SubscribeSafe(_observer3));
                _observer4.SetResource(source4.SubscribeSafe(_observer4));
                _observer5.SetResource(source5.SubscribeSafe(_observer5));
                _observer6.SetResource(source6.SubscribeSafe(_observer6));
                _observer7.SetResource(source7.SubscribeSafe(_observer7));
                _observer8.SetResource(source8.SubscribeSafe(_observer8));
                _observer9.SetResource(source9.SubscribeSafe(_observer9));
                _observer10.SetResource(source10.SubscribeSafe(_observer10));
                _observer11.SetResource(source11.SubscribeSafe(_observer11));
                _observer12.SetResource(source12.SubscribeSafe(_observer12));
                _observer13.SetResource(source13.SubscribeSafe(_observer13));
                _observer14.SetResource(source14.SubscribeSafe(_observer14));
                _observer15.SetResource(source15.SubscribeSafe(_observer15));
                _observer16.SetResource(source16.SubscribeSafe(_observer16));

                SetUpstream(StableCompositeDisposable.CreateTrusted(disposables));
            }

            protected override TResult GetResult() => _resultSelector(_observer1.Values.Dequeue(), _observer2.Values.Dequeue(), _observer3.Values.Dequeue(), _observer4.Values.Dequeue(), _observer5.Values.Dequeue(), _observer6.Values.Dequeue(), _observer7.Values.Dequeue(), _observer8.Values.Dequeue(), _observer9.Values.Dequeue(), _observer10.Values.Dequeue(), _observer11.Values.Dequeue(), _observer12.Values.Dequeue(), _observer13.Values.Dequeue(), _observer14.Values.Dequeue(), _observer15.Values.Dequeue(), _observer16.Values.Dequeue());
        }
    }


    #endregion

    #endregion
}
