package v;

import d5.AbstractC0844a;
import java.util.HashSet;
import java.util.Iterator;
import n4.u0;
import u.AbstractC1563h;

/* JADX INFO: loaded from: classes.dex */
public final class c {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final d f17868b;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public u.i f17873g;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public HashSet f17867a = null;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f17871e = 0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f17872f = -1;

    public c(d dVar, int i) {
        this.f17868b = dVar;
        this.f17869c = i;
    }

    public final void a(c cVar, int i) {
        b(cVar, i, -1, false);
    }

    public final boolean b(c cVar, int i, int i5, boolean z8) {
        if (cVar == null) {
            h();
            return true;
        }
        if (!z8 && !g(cVar)) {
            return false;
        }
        this.f17870d = cVar;
        if (cVar.f17867a == null) {
            cVar.f17867a = new HashSet();
        }
        this.f17870d.f17867a.add(this);
        if (i > 0) {
            this.f17871e = i;
        } else {
            this.f17871e = 0;
        }
        this.f17872f = i5;
        return true;
    }

    public final int c() {
        c cVar;
        if (this.f17868b.f17893V == 8) {
            return 0;
        }
        int i = this.f17872f;
        return (i <= -1 || (cVar = this.f17870d) == null || cVar.f17868b.f17893V != 8) ? this.f17871e : i;
    }

    public final c d() {
        int i = this.f17869c;
        int iC = AbstractC1563h.c(i);
        d dVar = this.f17868b;
        switch (iC) {
            case u0.f15495q /* 0 */:
            case 5:
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                return null;
            case 1:
                return dVar.f17924z;
            case 2:
                return dVar.f17874A;
            case 3:
                return dVar.f17922x;
            case 4:
                return dVar.f17923y;
            default:
                throw new AssertionError(AbstractC0844a.y(i));
        }
    }

    public final boolean e() {
        HashSet hashSet = this.f17867a;
        if (hashSet == null) {
            return false;
        }
        Iterator it = hashSet.iterator();
        while (it.hasNext()) {
            if (((c) it.next()).d().f()) {
                return true;
            }
        }
        return false;
    }

    public final boolean f() {
        return this.f17870d != null;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:45:0x005e A[RETURN] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean g(c cVar) {
        if (cVar != null) {
            int i = this.f17869c;
            d dVar = cVar.f17868b;
            int i5 = cVar.f17869c;
            if (i5 != i) {
                switch (AbstractC1563h.c(i)) {
                    case u0.f15495q /* 0 */:
                    case 5:
                    case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                    case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                        break;
                    case 1:
                    case 3:
                        boolean z8 = i5 == 2 || i5 == 4;
                        if (!(dVar instanceof h)) {
                            return z8;
                        }
                        if (z8 || i5 == 8) {
                        }
                        break;
                    case 2:
                    case 4:
                        boolean z9 = i5 == 3 || i5 == 5;
                        if (!(dVar instanceof h)) {
                            return z9;
                        }
                        if (z9 || i5 == 9) {
                        }
                        break;
                    case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                        if (i5 == 6 || i5 == 8 || i5 == 9) {
                        }
                        break;
                    default:
                        throw new AssertionError(AbstractC0844a.y(i));
                }
            } else if (i != 6 || (dVar.f17921w && this.f17868b.f17921w)) {
                return true;
            }
        }
        return false;
    }

    public final void h() {
        HashSet hashSet;
        c cVar = this.f17870d;
        if (cVar != null && (hashSet = cVar.f17867a) != null) {
            hashSet.remove(this);
        }
        this.f17870d = null;
        this.f17871e = 0;
        this.f17872f = -1;
    }

    public final void i() {
        u.i iVar = this.f17873g;
        if (iVar == null) {
            this.f17873g = new u.i(1);
        } else {
            iVar.c();
        }
    }

    public final String toString() {
        return this.f17868b.f17894W + ":" + AbstractC0844a.y(this.f17869c);
    }
}
