package B6;

import android.view.View;
import android.view.ViewGroup;
import java.util.Iterator;
import java.util.NoSuchElementException;
import n4.u0;

/* JADX INFO: loaded from: classes.dex */
public class b implements Iterator, Q6.a {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f1016q;

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

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final Object f1018s;

    public /* synthetic */ b(int i, Object obj) {
        this.f1016q = i;
        this.f1018s = obj;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        Iterator it;
        switch (this.f1016q) {
            case u0.f15495q /* 0 */:
                return this.f1017r < ((e) this.f1018s).a();
            case 1:
                return this.f1017r < ((ViewGroup) this.f1018s).getChildCount();
            case 2:
                return this.f1017r < ((Object[]) this.f1018s).length;
            case 3:
                break;
            default:
                return this.f1017r < ((q.j) this.f1018s).k();
        }
        while (true) {
            int i = this.f1017r;
            it = (Iterator) this.f1018s;
            if (i > 0 && it.hasNext()) {
                it.next();
                this.f1017r--;
            }
        }
        return it.hasNext();
    }

    @Override // java.util.Iterator
    public final Object next() {
        Iterator it;
        switch (this.f1016q) {
            case u0.f15495q /* 0 */:
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                int i = this.f1017r;
                this.f1017r = i + 1;
                return ((e) this.f1018s).get(i);
            case 1:
                int i5 = this.f1017r;
                this.f1017r = i5 + 1;
                View childAt = ((ViewGroup) this.f1018s).getChildAt(i5);
                if (childAt != null) {
                    return childAt;
                }
                throw new IndexOutOfBoundsException();
            case 2:
                try {
                    Object[] objArr = (Object[]) this.f1018s;
                    int i8 = this.f1017r;
                    this.f1017r = i8 + 1;
                    return objArr[i8];
                } catch (ArrayIndexOutOfBoundsException e8) {
                    this.f1017r--;
                    throw new NoSuchElementException(e8.getMessage());
                }
            case 3:
                break;
            default:
                int i9 = this.f1017r;
                this.f1017r = i9 + 1;
                return ((q.j) this.f1018s).l(i9);
        }
        while (true) {
            int i10 = this.f1017r;
            it = (Iterator) this.f1018s;
            if (i10 > 0 && it.hasNext()) {
                it.next();
                this.f1017r--;
            }
        }
        return it.next();
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.f1016q) {
            case u0.f15495q /* 0 */:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            case 1:
                int i = this.f1017r - 1;
                this.f1017r = i;
                ((ViewGroup) this.f1018s).removeViewAt(i);
                return;
            case 2:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            case 3:
                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(Object[] objArr) {
        this.f1016q = 2;
        P6.g.e(objArr, "array");
        this.f1018s = objArr;
    }

    public b(W6.b bVar) {
        this.f1016q = 3;
        this.f1018s = bVar.f7193a.iterator();
        this.f1017r = bVar.f7194b;
    }
}
