package o;

import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class FD implements Iterator, InterfaceC2989yJ {
    public final /* synthetic */ int l;
    public int m;
    public Object n;

    /* renamed from: o, reason: collision with root package name */
    public final Object f116o;

    public FD(Object obj, Map map) {
        this.l = 2;
        this.n = obj;
        this.f116o = map;
    }

    /* JADX WARN: Type inference failed for: r0v2, types: [java.lang.Object, o.OC] */
    public void a() {
        GD gd = (GD) this.f116o;
        Object objA = this.m == -2 ? ((NC) gd.b).a() : gd.c.g(this.n);
        this.n = objA;
        this.m = objA == null ? 0 : 1;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        switch (this.l) {
            case 0:
                if (this.m < 0) {
                    a();
                }
                return this.m == 1;
            case 1:
                return ((G60) this.n).hasNext();
            default:
                return this.m < ((Map) this.f116o).size();
        }
    }

    @Override // java.util.Iterator
    public final Object next() {
        switch (this.l) {
            case 0:
                if (this.m < 0) {
                    a();
                }
                if (this.m == 0) {
                    throw new NoSuchElementException();
                }
                Object obj = this.n;
                this.m = -1;
                return obj;
            case 1:
                return ((G60) this.n).next();
            default:
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                Object obj2 = this.n;
                this.m++;
                Object obj3 = ((Map) this.f116o).get(obj2);
                if (obj3 != null) {
                    this.n = ((FL) obj3).b;
                    return obj2;
                }
                throw new ConcurrentModificationException("Hash code of an element (" + obj2 + ") has changed after it was added to the persistent set.");
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.l) {
            case 0:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            case 1:
                int i = this.m;
                if (i != -1) {
                    ((C0904cR) this.f116o).m.l(i);
                    this.m = -1;
                    return;
                }
                return;
            default:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
        }
    }

    public FD(GD gd) {
        this.l = 0;
        this.f116o = gd;
        this.m = -2;
    }

    public FD(C0904cR c0904cR) {
        this.l = 1;
        this.f116o = c0904cR;
        this.m = -1;
        this.n = AbstractC2461sm0.C(new C0809bR(c0904cR, this, null));
    }
}
