package o;

import java.util.ArrayList;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class R50 {
    public final LP a;
    public final boolean b;
    public final C2420sK c;
    public final N50 d;
    public boolean e;
    public R50 f;
    public final int g;

    public R50(LP lp, boolean z, C2420sK c2420sK, N50 n50) {
        this.a = lp;
        this.b = z;
        this.c = c2420sK;
        this.d = n50;
        this.g = c2420sK.m;
    }

    public static /* synthetic */ List j(int i, R50 r50) {
        return r50.i((i & 1) != 0 ? !r50.b : false, (i & 2) == 0);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v10, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r2v11 */
    /* JADX WARN: Type inference failed for: r2v12, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r2v13, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v14 */
    /* JADX WARN: Type inference failed for: r2v15 */
    /* JADX WARN: Type inference failed for: r2v16 */
    /* JADX WARN: Type inference failed for: r2v17 */
    /* JADX WARN: Type inference failed for: r2v18 */
    /* JADX WARN: Type inference failed for: r2v19 */
    /* JADX WARN: Type inference failed for: r2v2 */
    /* JADX WARN: Type inference failed for: r2v3 */
    /* JADX WARN: Type inference failed for: r2v9 */
    /* JADX WARN: Type inference failed for: r6v0 */
    /* JADX WARN: Type inference failed for: r6v1 */
    /* JADX WARN: Type inference failed for: r6v10 */
    /* JADX WARN: Type inference failed for: r6v11 */
    /* JADX WARN: Type inference failed for: r6v2 */
    /* JADX WARN: Type inference failed for: r6v3, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r6v4 */
    /* JADX WARN: Type inference failed for: r6v5 */
    /* JADX WARN: Type inference failed for: r6v6, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r6v8 */
    /* JADX WARN: Type inference failed for: r6v9 */
    public final T00 a(AbstractC2239qS abstractC2239qS) {
        AbstractC0561Vq abstractC0561VqI;
        R50 r50L = l();
        if (r50L == null) {
            return T00.e;
        }
        LP lp = (LP) r50L.c.N.g;
        if ((lp.f209o & 8) != 0) {
            loop0: while (lp != null) {
                if ((lp.n & 8) != 0) {
                    abstractC0561VqI = lp;
                    ?? c1479iR = 0;
                    while (abstractC0561VqI != 0) {
                        if (abstractC0561VqI instanceof P50) {
                            if (abstractC0561VqI.k()) {
                                break loop0;
                            }
                        } else if ((abstractC0561VqI.n & 8) != 0 && (abstractC0561VqI instanceof AbstractC0561Vq)) {
                            LP lp2 = abstractC0561VqI.A;
                            int i = 0;
                            abstractC0561VqI = abstractC0561VqI;
                            c1479iR = c1479iR;
                            while (lp2 != null) {
                                if ((lp2.n & 8) != 0) {
                                    i++;
                                    c1479iR = c1479iR;
                                    if (i == 1) {
                                        abstractC0561VqI = lp2;
                                    } else {
                                        if (c1479iR == 0) {
                                            c1479iR = new C1479iR(new LP[16]);
                                        }
                                        if (abstractC0561VqI != 0) {
                                            c1479iR.b(abstractC0561VqI);
                                            abstractC0561VqI = 0;
                                        }
                                        c1479iR.b(lp2);
                                    }
                                }
                                lp2 = lp2.q;
                                abstractC0561VqI = abstractC0561VqI;
                                c1479iR = c1479iR;
                            }
                            if (i == 1) {
                            }
                        }
                        abstractC0561VqI = AbstractC2539te.i(c1479iR);
                    }
                }
                if ((lp.f209o & 8) == 0) {
                    break;
                }
                lp = lp.q;
            }
            abstractC0561VqI = 0;
        } else {
            abstractC0561VqI = 0;
        }
        P50 p50 = (P50) abstractC0561VqI;
        AbstractC2239qS abstractC2239qSQ = p50 != null ? AbstractC2539te.Q(p50, 8) : null;
        return abstractC2239qSQ == null ? r50L.a(abstractC2239qS) : abstractC2239qSQ.h(abstractC2239qS, true);
    }

    public final R50 b(C1065e30 c1065e30, OC oc) {
        N50 n50 = new N50();
        n50.n = false;
        n50.f250o = false;
        oc.g(n50);
        R50 r50 = new R50(new Q50(oc), false, new C2420sK(true, this.g + (c1065e30 != null ? 1000000000 : 2000000000)), n50);
        r50.e = true;
        r50.f = this;
        return r50;
    }

    public final void c(C2420sK c2420sK, ArrayList arrayList) {
        C1479iR c1479iRV = c2420sK.v();
        Object[] objArr = c1479iRV.l;
        int i = c1479iRV.n;
        for (int i2 = 0; i2 < i; i2++) {
            C2420sK c2420sK2 = (C2420sK) objArr[i2];
            if (c2420sK2.G() && !c2420sK2.X) {
                if (c2420sK2.N.j(8)) {
                    arrayList.add(YT.g(c2420sK2, this.b));
                } else {
                    c(c2420sK2, arrayList);
                }
            }
        }
    }

    public final AbstractC2239qS d() {
        AbstractC2239qS abstractC2239qSQ;
        if (!this.e) {
            P50 p50F = f();
            return (p50F == null || (abstractC2239qSQ = AbstractC2539te.Q(p50F, 8)) == null) ? (C2702vH) this.c.N.d : abstractC2239qSQ;
        }
        R50 r50L = l();
        if (r50L != null) {
            return r50L.d();
        }
        return null;
    }

    public final void e(ArrayList arrayList, ArrayList arrayList2) {
        q(arrayList, false);
        int size = arrayList.size();
        for (int size2 = arrayList.size(); size2 < size; size2++) {
            R50 r50 = (R50) arrayList.get(size2);
            if (r50.n()) {
                arrayList2.add(r50);
            } else if (!r50.d.f250o) {
                r50.e(arrayList, arrayList2);
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r6v12 */
    /* JADX WARN: Type inference failed for: r6v13, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r6v14, types: [o.P50] */
    /* JADX WARN: Type inference failed for: r6v15 */
    /* JADX WARN: Type inference failed for: r6v16, types: [o.LP] */
    /* JADX WARN: Type inference failed for: r6v17, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r6v18 */
    /* JADX WARN: Type inference failed for: r6v19 */
    /* JADX WARN: Type inference failed for: r6v20 */
    /* JADX WARN: Type inference failed for: r6v21 */
    /* JADX WARN: Type inference failed for: r6v22 */
    /* JADX WARN: Type inference failed for: r6v23 */
    /* JADX WARN: Type inference failed for: r7v12 */
    /* JADX WARN: Type inference failed for: r7v13 */
    /* JADX WARN: Type inference failed for: r7v14 */
    /* JADX WARN: Type inference failed for: r7v15, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r7v16 */
    /* JADX WARN: Type inference failed for: r7v17 */
    /* JADX WARN: Type inference failed for: r7v18, types: [o.iR] */
    /* JADX WARN: Type inference failed for: r7v20 */
    /* JADX WARN: Type inference failed for: r7v21 */
    /* JADX WARN: Type inference failed for: r7v22 */
    /* JADX WARN: Type inference failed for: r7v23 */
    public final P50 f() {
        LP lpI;
        boolean z = this.d.n;
        C2420sK c2420sK = this.c;
        Object obj = null;
        if (z) {
            LP lp = (LP) c2420sK.N.g;
            if ((lp.f209o & 8) != 0) {
                lpI = null;
                while (lp != null) {
                    if ((lp.n & 8) != 0) {
                        AbstractC0561Vq abstractC0561VqI = lp;
                        ?? c1479iR = 0;
                        while (abstractC0561VqI != 0) {
                            if (abstractC0561VqI instanceof P50) {
                                ?? r6 = (P50) abstractC0561VqI;
                                if (r6.k()) {
                                    if (r6.c0()) {
                                        return r6;
                                    }
                                    if (lpI == null) {
                                        lpI = r6;
                                    }
                                }
                            } else if ((abstractC0561VqI.n & 8) != 0 && (abstractC0561VqI instanceof AbstractC0561Vq)) {
                                LP lp2 = abstractC0561VqI.A;
                                int i = 0;
                                abstractC0561VqI = abstractC0561VqI;
                                c1479iR = c1479iR;
                                while (lp2 != null) {
                                    if ((lp2.n & 8) != 0) {
                                        i++;
                                        c1479iR = c1479iR;
                                        if (i == 1) {
                                            abstractC0561VqI = lp2;
                                        } else {
                                            if (c1479iR == 0) {
                                                c1479iR = new C1479iR(new LP[16]);
                                            }
                                            if (abstractC0561VqI != 0) {
                                                c1479iR.b(abstractC0561VqI);
                                                abstractC0561VqI = 0;
                                            }
                                            c1479iR.b(lp2);
                                        }
                                    }
                                    lp2 = lp2.q;
                                    abstractC0561VqI = abstractC0561VqI;
                                    c1479iR = c1479iR;
                                }
                                if (i == 1) {
                                }
                            }
                            abstractC0561VqI = AbstractC2539te.i(c1479iR);
                        }
                    }
                    if ((lp.f209o & 8) == 0) {
                        break;
                    }
                    lp = lp.q;
                }
                obj = lpI;
            }
        } else {
            LP lp3 = (LP) c2420sK.N.g;
            if ((lp3.f209o & 8) != 0) {
                loop3: while (lp3 != null) {
                    if ((lp3.n & 8) != 0) {
                        lpI = lp3;
                        C1479iR c1479iR2 = null;
                        while (lpI != null) {
                            if (lpI instanceof P50) {
                                if (((P50) lpI).k()) {
                                    obj = lpI;
                                }
                            } else if ((lpI.n & 8) != 0 && (lpI instanceof AbstractC0561Vq)) {
                                int i2 = 0;
                                for (LP lp4 = ((AbstractC0561Vq) lpI).A; lp4 != null; lp4 = lp4.q) {
                                    if ((lp4.n & 8) != 0) {
                                        i2++;
                                        if (i2 == 1) {
                                            lpI = lp4;
                                        } else {
                                            if (c1479iR2 == null) {
                                                c1479iR2 = new C1479iR(new LP[16]);
                                            }
                                            if (lpI != null) {
                                                c1479iR2.b(lpI);
                                                lpI = null;
                                            }
                                            c1479iR2.b(lp4);
                                        }
                                    }
                                }
                                if (i2 == 1) {
                                }
                            }
                            lpI = AbstractC2539te.i(c1479iR2);
                        }
                    }
                    if ((lp3.f209o & 8) == 0) {
                        break;
                    }
                    lp3 = lp3.q;
                }
            }
        }
        return (P50) obj;
    }

    public final T00 g() {
        AbstractC2239qS abstractC2239qSD = d();
        if (abstractC2239qSD != null) {
            if (!abstractC2239qSD.P0().y) {
                abstractC2239qSD = null;
            }
            if (abstractC2239qSD != null) {
                return AbstractC2841wm0.s(abstractC2239qSD).h(abstractC2239qSD, true);
            }
        }
        return T00.e;
    }

    public final T00 h() {
        AbstractC2239qS abstractC2239qSD = d();
        if (abstractC2239qSD != null) {
            if (!abstractC2239qSD.P0().y) {
                abstractC2239qSD = null;
            }
            if (abstractC2239qSD != null) {
                return AbstractC2841wm0.k(abstractC2239qSD);
            }
        }
        return T00.e;
    }

    public final List i(boolean z, boolean z2) {
        if (!z && this.d.f250o) {
            return C0332Mv.l;
        }
        ArrayList arrayList = new ArrayList();
        if (!n()) {
            return q(arrayList, z2);
        }
        ArrayList arrayList2 = new ArrayList();
        e(arrayList, arrayList2);
        return arrayList2;
    }

    public final N50 k() {
        boolean zN = n();
        N50 n50 = this.d;
        if (!zN) {
            return n50;
        }
        N50 n50A = n50.a();
        p(new ArrayList(), n50A);
        return n50A;
    }

    public final R50 l() {
        C2420sK c2420sKS;
        R50 r50 = this.f;
        if (r50 != null) {
            return r50;
        }
        C2420sK c2420sK = this.c;
        boolean z = this.b;
        if (z) {
            c2420sKS = c2420sK.s();
            while (c2420sKS != null) {
                N50 n50U = c2420sKS.u();
                if (n50U != null && n50U.n) {
                    break;
                }
                c2420sKS = c2420sKS.s();
            }
            c2420sKS = null;
        } else {
            c2420sKS = null;
        }
        if (c2420sKS == null) {
            C2420sK c2420sKS2 = c2420sK.s();
            while (true) {
                if (c2420sKS2 == null) {
                    c2420sKS = null;
                    break;
                }
                if (c2420sKS2.N.j(8)) {
                    c2420sKS = c2420sKS2;
                    break;
                }
                c2420sKS2 = c2420sKS2.s();
            }
        }
        if (c2420sKS == null) {
            return null;
        }
        return YT.g(c2420sKS, z);
    }

    public final N50 m() {
        return this.d;
    }

    public final boolean n() {
        return this.b && this.d.n;
    }

    public final boolean o() {
        if (this.e || !j(4, this).isEmpty()) {
            return false;
        }
        C2420sK c2420sKS = this.c.s();
        while (true) {
            if (c2420sKS == null) {
                c2420sKS = null;
                break;
            }
            N50 n50U = c2420sKS.u();
            if (n50U != null && n50U.n) {
                break;
            }
            c2420sKS = c2420sKS.s();
        }
        return c2420sKS == null;
    }

    public final void p(ArrayList arrayList, N50 n50) {
        if (this.d.f250o) {
            return;
        }
        q(arrayList, false);
        int size = arrayList.size();
        for (int size2 = arrayList.size(); size2 < size; size2++) {
            R50 r50 = (R50) arrayList.get(size2);
            if (!r50.n()) {
                n50.c(r50.d);
                r50.p(arrayList, n50);
            }
        }
    }

    public final List q(ArrayList arrayList, boolean z) {
        if (this.e) {
            return C0332Mv.l;
        }
        c(this.c, arrayList);
        if (z) {
            N50 n50 = this.d;
            ZQ zq = n50.l;
            Object objG = zq.g(W50.x);
            if (objG == null) {
                objG = null;
            }
            C1065e30 c1065e30 = (C1065e30) objG;
            if (c1065e30 != null && n50.n && !arrayList.isEmpty()) {
                arrayList.add(b(c1065e30, new C2769w(26, c1065e30)));
            }
            Z50 z50 = W50.a;
            if (zq.c(z50) && !arrayList.isEmpty() && n50.n) {
                Object objG2 = zq.g(z50);
                if (objG2 == null) {
                    objG2 = null;
                }
                List list = (List) objG2;
                String str = list != null ? (String) AbstractC3117zi.f0(list) : null;
                if (str != null) {
                    arrayList.add(0, b(null, new C2769w(27, str)));
                }
            }
        }
        return arrayList;
    }
}
