package androidx.core.view;

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

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

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

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

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

    public /* synthetic */ u1(Object obj, int i10) {
        this.f1831a = i10;
        this.f1833c = obj;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i10 = this.f1831a;
        Object obj = this.f1833c;
        switch (i10) {
            case 0:
                return this.f1832b < ((ViewGroup) obj).getChildCount();
            case 1:
                return this.f1832b < ((kotlin.collections.d) obj).size();
            case 2:
                return this.f1832b < ((Object[]) obj).length;
        }
        while (this.f1832b > 0) {
            Iterator it = (Iterator) obj;
            if (!it.hasNext()) {
                return ((Iterator) obj).hasNext();
            }
            it.next();
            this.f1832b--;
        }
        return ((Iterator) obj).hasNext();
    }

    @Override // java.util.Iterator
    public final Object next() {
        int i10 = this.f1831a;
        Object obj = this.f1833c;
        switch (i10) {
            case 0:
                int i11 = this.f1832b;
                this.f1832b = i11 + 1;
                View childAt = ((ViewGroup) obj).getChildAt(i11);
                if (childAt != null) {
                    return childAt;
                }
                throw new IndexOutOfBoundsException();
            case 1:
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                int i12 = this.f1832b;
                this.f1832b = i12 + 1;
                return ((kotlin.collections.d) obj).get(i12);
            case 2:
                try {
                    int i13 = this.f1832b;
                    this.f1832b = i13 + 1;
                    return ((Object[]) obj)[i13];
                } catch (ArrayIndexOutOfBoundsException e10) {
                    this.f1832b--;
                    throw new NoSuchElementException(e10.getMessage());
                }
        }
        while (this.f1832b > 0) {
            Iterator it = (Iterator) obj;
            if (!it.hasNext()) {
                return ((Iterator) obj).next();
            }
            it.next();
            this.f1832b--;
        }
        return ((Iterator) obj).next();
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.f1831a) {
            case 0:
                ViewGroup viewGroup = (ViewGroup) this.f1833c;
                int i10 = this.f1832b - 1;
                this.f1832b = i10;
                viewGroup.removeViewAt(i10);
                return;
            case 1:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            case 2:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            default:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
        }
    }

    public u1(Object[] objArr) {
        this.f1831a = 2;
        nb.g.i(objArr, "array");
        this.f1833c = objArr;
    }

    public u1(kotlin.sequences.b bVar) {
        this.f1831a = 3;
        this.f1833c = bVar.f29243a.iterator();
        this.f1832b = bVar.f29244b;
    }
}
