package com.google.protobuf;

import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.NoSuchElementException;

/* JADX INFO: loaded from: classes3.dex */
public final class H0 implements Iterator {

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

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

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

    public H0(x5.r rVar, x5.x xVar) {
        this.f14188b = rVar;
        this.f14189c = xVar;
    }

    public C1318m a() {
        C1318m c1318m;
        C1318m c1318m2 = (C1318m) this.f14189c;
        if (c1318m2 == null) {
            throw new NoSuchElementException();
        }
        do {
            ArrayDeque arrayDeque = (ArrayDeque) this.f14188b;
            if (arrayDeque == null || arrayDeque.isEmpty()) {
                c1318m = null;
                break;
            }
            AbstractC1320n abstractC1320n = ((I0) arrayDeque.pop()).f14195f;
            while (abstractC1320n instanceof I0) {
                I0 i02 = (I0) abstractC1320n;
                arrayDeque.push(i02);
                abstractC1320n = i02.f14194e;
            }
            c1318m = (C1318m) abstractC1320n;
        } while (c1318m.isEmpty());
        this.f14189c = c1318m;
        return c1318m2;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        switch (this.f14187a) {
            case 0:
                if (((C1318m) this.f14189c) != null) {
                }
                break;
            default:
                x5.r rVar = (x5.r) this.f14188b;
                if (rVar == null || rVar == ((x5.x) this.f14189c)) {
                }
                break;
        }
        return false;
    }

    @Override // java.util.Iterator
    public final Object next() {
        switch (this.f14187a) {
            case 0:
                return a();
            default:
                x5.r rVar = (x5.r) this.f14188b;
                this.f14188b = rVar.f26085e;
                return rVar;
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.f14187a) {
            case 0:
                throw new UnsupportedOperationException();
            default:
                throw new UnsupportedOperationException("remove");
        }
    }

    public H0(AbstractC1320n abstractC1320n) {
        if (abstractC1320n instanceof I0) {
            I0 i02 = (I0) abstractC1320n;
            ArrayDeque arrayDeque = new ArrayDeque(i02.f14197k);
            this.f14188b = arrayDeque;
            arrayDeque.push(i02);
            AbstractC1320n abstractC1320n2 = i02.f14194e;
            while (abstractC1320n2 instanceof I0) {
                I0 i03 = (I0) abstractC1320n2;
                ((ArrayDeque) this.f14188b).push(i03);
                abstractC1320n2 = i03.f14194e;
            }
            this.f14189c = (C1318m) abstractC1320n2;
            return;
        }
        this.f14188b = null;
        this.f14189c = (C1318m) abstractC1320n;
    }
}
