package R4;

import java.util.Iterator;
import java.util.NoSuchElementException;
import x4.AbstractC3252r;
import x4.C3225B;

/* JADX INFO: loaded from: classes3.dex */
public final class b implements Iterator, K4.a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f6085a = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f6086b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Iterator f6087c;

    public b(Iterator iterator) {
        kotlin.jvm.internal.o.h(iterator, "iterator");
        this.f6087c = iterator;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        Iterator it;
        switch (this.f6085a) {
            case 0:
                break;
            case 1:
                return this.f6086b > 0 && this.f6087c.hasNext();
            default:
                return this.f6087c.hasNext();
        }
        while (true) {
            int i6 = this.f6086b;
            it = this.f6087c;
            if (i6 > 0 && it.hasNext()) {
                it.next();
                this.f6086b--;
            }
        }
        return it.hasNext();
    }

    @Override // java.util.Iterator
    public final Object next() {
        Iterator it;
        switch (this.f6085a) {
            case 0:
                break;
            case 1:
                int i6 = this.f6086b;
                if (i6 == 0) {
                    throw new NoSuchElementException();
                }
                this.f6086b = i6 - 1;
                return this.f6087c.next();
            default:
                int i7 = this.f6086b;
                this.f6086b = i7 + 1;
                if (i7 >= 0) {
                    return new C3225B(i7, this.f6087c.next());
                }
                AbstractC3252r.F();
                throw null;
        }
        while (true) {
            int i8 = this.f6086b;
            it = this.f6087c;
            if (i8 > 0 && it.hasNext()) {
                it.next();
                this.f6086b--;
            }
        }
        return it.next();
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.f6085a) {
            case 0:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            case 1:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            default:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
        }
    }

    public b(c cVar, byte b5) {
        this.f6086b = cVar.f6090c;
        this.f6087c = cVar.f6089b.iterator();
    }

    public b(c cVar) {
        this.f6087c = cVar.f6089b.iterator();
        this.f6086b = cVar.f6090c;
    }
}
