package androidx.datastore.preferences.protobuf;

import com.google.android.gms.internal.ads.kc2;
import com.google.android.gms.internal.ads.lc2;
import com.google.android.gms.internal.measurement.e7;
import java.util.AbstractMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public final class d1 implements Iterator {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Iterator f2058d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ AbstractMap f2059e;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ d1(e7 e7Var) {
        this(e7Var, 2);
        this.f2055a = 2;
    }

    public final Iterator a() {
        int i10 = this.f2055a;
        AbstractMap abstractMap = this.f2059e;
        switch (i10) {
            case 0:
                if (this.f2058d == null) {
                    this.f2058d = ((f1) abstractMap).f2069b.entrySet().iterator();
                }
                return this.f2058d;
            default:
                if (this.f2058d != null) {
                    return this.f2058d;
                }
                ((com.google.crypto.tink.shaded.protobuf.d1) abstractMap).getClass();
                throw null;
        }
    }

    public final Map.Entry b() {
        int i10 = this.f2055a;
        AbstractMap abstractMap = this.f2059e;
        switch (i10) {
            case 0:
                this.f2057c = true;
                int i11 = this.f2056b + 1;
                this.f2056b = i11;
                f1 f1Var = (f1) abstractMap;
                return i11 < f1Var.f2068a.size() ? (Map.Entry) f1Var.f2068a.get(this.f2056b) : (Map.Entry) a().next();
            default:
                this.f2057c = true;
                int i12 = this.f2056b + 1;
                this.f2056b = i12;
                com.google.crypto.tink.shaded.protobuf.d1 d1Var = (com.google.crypto.tink.shaded.protobuf.d1) abstractMap;
                d1Var.getClass();
                if (i12 >= 0) {
                    return (Map.Entry) a().next();
                }
                d1Var.getClass();
                throw null;
        }
    }

    public final Iterator c() {
        int i10 = this.f2055a;
        AbstractMap abstractMap = this.f2059e;
        switch (i10) {
            case 1:
                if (this.f2058d == null) {
                    this.f2058d = ((kc2) abstractMap).f13221c.entrySet().iterator();
                }
                return this.f2058d;
            default:
                if (this.f2058d != null) {
                    return this.f2058d;
                }
                ((e7) abstractMap).getClass();
                throw null;
        }
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i10 = this.f2055a;
        AbstractMap abstractMap = this.f2059e;
        switch (i10) {
            case 0:
                f1 f1Var = (f1) abstractMap;
                return this.f2056b + 1 < f1Var.f2068a.size() || (!f1Var.f2069b.isEmpty() && a().hasNext());
            case 1:
                kc2 kc2Var = (kc2) abstractMap;
                return this.f2056b + 1 < kc2Var.f13220b || (!kc2Var.f13221c.isEmpty() && c().hasNext());
            case 2:
                int i11 = this.f2056b + 1;
                e7 e7Var = (e7) abstractMap;
                e7Var.getClass();
                if (i11 < 0) {
                    return true;
                }
                e7Var.getClass();
                throw null;
            default:
                int i12 = this.f2056b + 1;
                com.google.crypto.tink.shaded.protobuf.d1 d1Var = (com.google.crypto.tink.shaded.protobuf.d1) abstractMap;
                d1Var.getClass();
                if (i12 < 0) {
                    return true;
                }
                d1Var.getClass();
                throw null;
        }
    }

    @Override // java.util.Iterator
    public final /* synthetic */ Object next() {
        int i10 = this.f2055a;
        AbstractMap abstractMap = this.f2059e;
        switch (i10) {
            case 0:
                return b();
            case 1:
                this.f2057c = true;
                int i11 = this.f2056b + 1;
                this.f2056b = i11;
                kc2 kc2Var = (kc2) abstractMap;
                return i11 < kc2Var.f13220b ? (lc2) kc2Var.f13219a[i11] : (Map.Entry) c().next();
            case 2:
                this.f2057c = true;
                int i12 = this.f2056b + 1;
                this.f2056b = i12;
                e7 e7Var = (e7) abstractMap;
                e7Var.getClass();
                if (i12 >= 0) {
                    return (Map.Entry) c().next();
                }
                e7Var.getClass();
                throw null;
            default:
                return b();
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        int i10 = this.f2055a;
        AbstractMap abstractMap = this.f2059e;
        switch (i10) {
            case 0:
                if (!this.f2057c) {
                    throw new IllegalStateException("remove() was called before next()");
                }
                this.f2057c = false;
                f1 f1Var = (f1) abstractMap;
                int i11 = f1.f2067f;
                f1Var.b();
                if (this.f2056b >= f1Var.f2068a.size()) {
                    a().remove();
                    return;
                }
                int i12 = this.f2056b;
                this.f2056b = i12 - 1;
                f1Var.j(i12);
                return;
            case 1:
                if (!this.f2057c) {
                    throw new IllegalStateException("remove() was called before next()");
                }
                this.f2057c = false;
                kc2 kc2Var = (kc2) abstractMap;
                kc2Var.q();
                int i13 = this.f2056b;
                if (i13 >= kc2Var.f13220b) {
                    c().remove();
                    return;
                } else {
                    this.f2056b = i13 - 1;
                    kc2Var.o(i13);
                    return;
                }
            case 2:
                if (!this.f2057c) {
                    throw new IllegalStateException("remove() was called before next()");
                }
                this.f2057c = false;
                e7 e7Var = (e7) abstractMap;
                int i14 = e7.f20180a;
                e7Var.j();
                int i15 = this.f2056b;
                e7Var.getClass();
                if (i15 >= 0) {
                    c().remove();
                    return;
                } else {
                    this.f2056b = i15 - 1;
                    e7Var.i(i15);
                    return;
                }
            default:
                if (!this.f2057c) {
                    throw new IllegalStateException("remove() was called before next()");
                }
                this.f2057c = false;
                com.google.crypto.tink.shaded.protobuf.d1 d1Var = (com.google.crypto.tink.shaded.protobuf.d1) abstractMap;
                int i16 = com.google.crypto.tink.shaded.protobuf.d1.f23890a;
                d1Var.a();
                int i17 = this.f2056b;
                d1Var.getClass();
                if (i17 >= 0) {
                    a().remove();
                    return;
                } else {
                    this.f2056b = i17 - 1;
                    d1Var.d(i17);
                    return;
                }
        }
    }

    public /* synthetic */ d1(AbstractMap abstractMap, int i10) {
        this.f2055a = i10;
        this.f2059e = abstractMap;
        this.f2056b = -1;
    }

    public /* synthetic */ d1(kc2 kc2Var) {
        this.f2055a = 1;
        Objects.requireNonNull(kc2Var);
        this.f2059e = kc2Var;
        this.f2056b = -1;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ d1(f1 f1Var) {
        this(f1Var, 0);
        this.f2055a = 0;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ d1(com.google.crypto.tink.shaded.protobuf.d1 d1Var) {
        this(d1Var, 3);
        this.f2055a = 3;
    }
}
