package B0;

import u0.C1579o;
import x0.AbstractC1709a;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final AbstractC0020g f879a;

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f883e = false;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f884f = false;

    public q0(AbstractC0020g abstractC0020g, AbstractC0020g abstractC0020g2, int i) {
        this.f879a = abstractC0020g;
        this.f880b = i;
        this.f881c = abstractC0020g2;
    }

    public static void b(AbstractC0020g abstractC0020g) {
        int i = abstractC0020g.f763x;
        if (i == 2) {
            AbstractC1709a.j(i == 2);
            abstractC0020g.f763x = 1;
            abstractC0020g.s();
        }
    }

    public static boolean h(AbstractC0020g abstractC0020g) {
        return abstractC0020g.f763x != 0;
    }

    public static void m(AbstractC0020g abstractC0020g, long j8) {
        abstractC0020g.D = true;
        if (abstractC0020g instanceof N0.e) {
            N0.e eVar = (N0.e) abstractC0020g;
            AbstractC1709a.j(eVar.D);
            eVar.f4393Z = j8;
        }
    }

    public final void a(AbstractC0020g abstractC0020g, C0026m c0026m) {
        AbstractC1709a.j(this.f879a == abstractC0020g || this.f881c == abstractC0020g);
        if (h(abstractC0020g)) {
            if (abstractC0020g == ((AbstractC0020g) c0026m.f848u)) {
                c0026m.f849v = null;
                c0026m.f848u = null;
                c0026m.f844q = true;
            }
            b(abstractC0020g);
            AbstractC1709a.j(abstractC0020g.f763x == 1);
            abstractC0020g.f758s.H();
            abstractC0020g.f763x = 0;
            abstractC0020g.f764y = null;
            abstractC0020g.f765z = null;
            abstractC0020g.D = false;
            abstractC0020g.m();
        }
    }

    public final int c() {
        boolean zH = h(this.f879a);
        AbstractC0020g abstractC0020g = this.f881c;
        return (zH ? 1 : 0) + ((abstractC0020g == null || !h(abstractC0020g)) ? 0 : 1);
    }

    public final AbstractC0020g d(V v7) {
        L0.c0 c0Var;
        if (v7 != null && (c0Var = v7.f665c[this.f880b]) != null) {
            AbstractC0020g abstractC0020g = this.f879a;
            if (abstractC0020g.f764y == c0Var) {
                return abstractC0020g;
            }
            AbstractC0020g abstractC0020g2 = this.f881c;
            if (abstractC0020g2 != null && abstractC0020g2.f764y == c0Var) {
                return abstractC0020g2;
            }
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x003a  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean e(V v7, AbstractC0020g abstractC0020g) {
        if (abstractC0020g != null) {
            L0.c0[] c0VarArr = v7.f665c;
            int i = this.f880b;
            L0.c0 c0Var = c0VarArr[i];
            L0.c0 c0Var2 = abstractC0020g.f764y;
            if (c0Var2 != null) {
                if (c0Var2 != c0Var) {
                    V v8 = v7.f674m;
                    if (v8 == null || v8.f665c[i] != abstractC0020g.f764y) {
                        return false;
                    }
                } else if (c0Var != null && !abstractC0020g.j()) {
                    V v9 = v7.f674m;
                    if (!v7.f669g.f684g || v9 == null || !v9.f667e || (!(abstractC0020g instanceof N0.e) && !(abstractC0020g instanceof J0.b) && abstractC0020g.f752C < v9.e())) {
                    }
                }
            }
        }
        return true;
    }

    public final boolean f() {
        int i = this.f882d;
        return i == 2 || i == 4 || i == 3;
    }

    public final boolean g() {
        int i = this.f882d;
        if (i == 0 || i == 2 || i == 4) {
            return h(this.f879a);
        }
        AbstractC0020g abstractC0020g = this.f881c;
        abstractC0020g.getClass();
        return abstractC0020g.f763x != 0;
    }

    public final boolean i(int i) {
        int i5 = this.f882d;
        boolean z8 = i5 == 2 || i5 == 4;
        int i8 = this.f880b;
        return (z8 && i == i8) || (i5 == 3 && i != i8);
    }

    public final void j(boolean z8) {
        if (z8) {
            if (this.f883e) {
                AbstractC0020g abstractC0020g = this.f879a;
                AbstractC1709a.j(abstractC0020g.f763x == 0);
                abstractC0020g.f758s.H();
                abstractC0020g.q();
                this.f883e = false;
                return;
            }
            return;
        }
        if (this.f884f) {
            AbstractC0020g abstractC0020g2 = this.f881c;
            abstractC0020g2.getClass();
            AbstractC1709a.j(abstractC0020g2.f763x == 0);
            abstractC0020g2.f758s.H();
            abstractC0020g2.q();
            this.f884f = false;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final int k(AbstractC0020g abstractC0020g, V v7, O0.v vVar, C0026m c0026m) {
        AbstractC0020g abstractC0020g2;
        int i;
        if (abstractC0020g == null || abstractC0020g.f763x == 0 || (abstractC0020g == (abstractC0020g2 = this.f879a) && ((i = this.f882d) == 2 || i == 4))) {
            return 1;
        }
        if (abstractC0020g == this.f881c && this.f882d == 3) {
            return 1;
        }
        L0.c0 c0Var = abstractC0020g.f764y;
        L0.c0[] c0VarArr = v7.f665c;
        int i5 = this.f880b;
        Object[] objArr = c0Var != c0VarArr[i5];
        boolean zB = vVar.b(i5);
        if (!zB || objArr != false) {
            if (!abstractC0020g.D) {
                O0.s sVar = vVar.f4911c[i5];
                int length = sVar != null ? sVar.length() : 0;
                C1579o[] c1579oArr = new C1579o[length];
                for (int i8 = 0; i8 < length; i8++) {
                    sVar.getClass();
                    c1579oArr[i8] = sVar.h(i8);
                }
                L0.c0 c0Var2 = v7.f665c[i5];
                c0Var2.getClass();
                abstractC0020g.w(c1579oArr, c0Var2, v7.e(), v7.f677p, v7.f669g.f678a);
                return 3;
            }
            if (!abstractC0020g.k()) {
                return 0;
            }
            a(abstractC0020g, c0026m);
            if (!zB || f()) {
                j(abstractC0020g == abstractC0020g2);
                return 1;
            }
        }
        return 1;
    }

    public final void l() {
        if (!h(this.f879a)) {
            j(true);
        }
        AbstractC0020g abstractC0020g = this.f881c;
        if (abstractC0020g == null || abstractC0020g.f763x != 0) {
            return;
        }
        j(false);
    }

    public final void n() {
        int i;
        AbstractC0020g abstractC0020g = this.f879a;
        int i5 = abstractC0020g.f763x;
        if (i5 == 1 && this.f882d != 4) {
            AbstractC1709a.j(i5 == 1);
            abstractC0020g.f763x = 2;
            abstractC0020g.r();
            return;
        }
        AbstractC0020g abstractC0020g2 = this.f881c;
        if (abstractC0020g2 == null || (i = abstractC0020g2.f763x) != 1 || this.f882d == 3) {
            return;
        }
        AbstractC1709a.j(i == 1);
        abstractC0020g2.f763x = 2;
        abstractC0020g2.r();
    }
}
