package q1;

import androidx.compose.ui.focus.FocusTargetNode;
import com.google.firebase.crashlytics.internal.metadata.UserMetadata;
import j2.b1;
import j2.g0;
import j2.x0;
import l1.i;

/* loaded from: classes.dex */
public abstract class c {

    /* loaded from: classes.dex */
    public /* synthetic */ class a {

        /* renamed from: a, reason: collision with root package name */
        public static final /* synthetic */ int[] f33152a;

        static {
            int[] iArr = new int[m.values().length];
            try {
                iArr[m.Active.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[m.ActiveParent.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[m.Captured.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[m.Inactive.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            f33152a = iArr;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:118:0x009f, code lost:
    
        continue;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final l a(b bVar) {
        int a10 = b1.a(UserMetadata.MAX_ATTRIBUTE_SIZE);
        i.c P0 = bVar.P0();
        a1.b bVar2 = null;
        while (P0 != null) {
            if (P0 instanceof FocusTargetNode) {
                m o22 = ((FocusTargetNode) P0).o2();
                int i10 = a.f33152a[o22.ordinal()];
                if (i10 == 1 || i10 == 2 || i10 == 3) {
                    return o22;
                }
            } else if (((P0.J1() & a10) != 0) && (P0 instanceof j2.m)) {
                int i11 = 0;
                for (i.c i22 = ((j2.m) P0).i2(); i22 != null; i22 = i22.F1()) {
                    if ((i22.J1() & a10) != 0) {
                        i11++;
                        if (i11 == 1) {
                            P0 = i22;
                        } else {
                            if (bVar2 == null) {
                                bVar2 = new a1.b(new i.c[16], 0);
                            }
                            if (P0 != null) {
                                bVar2.c(P0);
                                P0 = null;
                            }
                            bVar2.c(i22);
                        }
                    }
                }
                if (i11 == 1) {
                }
            }
            P0 = j2.k.g(bVar2);
        }
        if (!bVar.P0().O1()) {
            throw new IllegalStateException("visitChildren called on an unattached node".toString());
        }
        a1.b bVar3 = new a1.b(new i.c[16], 0);
        i.c F1 = bVar.P0().F1();
        if (F1 == null) {
            j2.k.c(bVar3, bVar.P0());
        } else {
            bVar3.c(F1);
        }
        while (bVar3.t()) {
            i.c cVar = (i.c) bVar3.z(bVar3.q() - 1);
            if ((cVar.E1() & a10) == 0) {
                j2.k.c(bVar3, cVar);
            } else {
                while (true) {
                    if (cVar == null) {
                        break;
                    }
                    if ((cVar.J1() & a10) != 0) {
                        a1.b bVar4 = null;
                        while (cVar != null) {
                            if (cVar instanceof FocusTargetNode) {
                                m o23 = ((FocusTargetNode) cVar).o2();
                                int i12 = a.f33152a[o23.ordinal()];
                                if (i12 == 1 || i12 == 2 || i12 == 3) {
                                    return o23;
                                }
                            } else if (((cVar.J1() & a10) != 0) && (cVar instanceof j2.m)) {
                                int i13 = 0;
                                for (i.c i23 = ((j2.m) cVar).i2(); i23 != null; i23 = i23.F1()) {
                                    if ((i23.J1() & a10) != 0) {
                                        i13++;
                                        if (i13 == 1) {
                                            cVar = i23;
                                        } else {
                                            if (bVar4 == null) {
                                                bVar4 = new a1.b(new i.c[16], 0);
                                            }
                                            if (cVar != null) {
                                                bVar4.c(cVar);
                                                cVar = null;
                                            }
                                            bVar4.c(i23);
                                        }
                                    }
                                }
                                if (i13 == 1) {
                                }
                            }
                            cVar = j2.k.g(bVar4);
                        }
                    } else {
                        cVar = cVar.F1();
                    }
                }
            }
        }
        return m.Inactive;
    }

    public static final void b(b bVar) {
        j2.k.n(bVar).getFocusOwner().j(bVar);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r8v10 */
    /* JADX WARN: Type inference failed for: r8v11 */
    /* JADX WARN: Type inference failed for: r8v12 */
    /* JADX WARN: Type inference failed for: r8v13 */
    /* JADX WARN: Type inference failed for: r8v20 */
    /* JADX WARN: Type inference failed for: r8v21 */
    /* JADX WARN: Type inference failed for: r8v4 */
    /* JADX WARN: Type inference failed for: r8v5, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r8v7 */
    /* JADX WARN: Type inference failed for: r8v8, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r8v9, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r9v0 */
    /* JADX WARN: Type inference failed for: r9v1 */
    /* JADX WARN: Type inference failed for: r9v10 */
    /* JADX WARN: Type inference failed for: r9v11 */
    /* JADX WARN: Type inference failed for: r9v2 */
    /* JADX WARN: Type inference failed for: r9v3, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r9v4 */
    /* JADX WARN: Type inference failed for: r9v5 */
    /* JADX WARN: Type inference failed for: r9v6, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r9v8 */
    /* JADX WARN: Type inference failed for: r9v9 */
    public static final void c(FocusTargetNode focusTargetNode) {
        x0 k02;
        int a10 = b1.a(4096);
        int a11 = b1.a(UserMetadata.MAX_ATTRIBUTE_SIZE);
        i.c P0 = focusTargetNode.P0();
        int i10 = a10 | a11;
        if (!focusTargetNode.P0().O1()) {
            throw new IllegalStateException("visitAncestors called on an unattached node".toString());
        }
        i.c P02 = focusTargetNode.P0();
        g0 m10 = j2.k.m(focusTargetNode);
        while (m10 != null) {
            if ((m10.k0().k().E1() & i10) != 0) {
                while (P02 != null) {
                    if ((P02.J1() & i10) != 0) {
                        if (P02 != P0) {
                            if ((P02.J1() & a11) != 0) {
                                return;
                            }
                        }
                        if ((P02.J1() & a10) != 0) {
                            j2.m mVar = P02;
                            ?? r92 = 0;
                            while (mVar != 0) {
                                if (mVar instanceof b) {
                                    b bVar = (b) mVar;
                                    bVar.A1(a(bVar));
                                } else {
                                    if (((mVar.J1() & a10) != 0) && (mVar instanceof j2.m)) {
                                        i.c i22 = mVar.i2();
                                        int i11 = 0;
                                        mVar = mVar;
                                        r92 = r92;
                                        while (i22 != null) {
                                            if ((i22.J1() & a10) != 0) {
                                                i11++;
                                                r92 = r92;
                                                if (i11 == 1) {
                                                    mVar = i22;
                                                } else {
                                                    if (r92 == 0) {
                                                        r92 = new a1.b(new i.c[16], 0);
                                                    }
                                                    if (mVar != 0) {
                                                        r92.c(mVar);
                                                        mVar = 0;
                                                    }
                                                    r92.c(i22);
                                                }
                                            }
                                            i22 = i22.F1();
                                            mVar = mVar;
                                            r92 = r92;
                                        }
                                        if (i11 == 1) {
                                        }
                                    }
                                }
                                mVar = j2.k.g(r92);
                            }
                        }
                    }
                    P02 = P02.L1();
                }
            }
            m10 = m10.o0();
            P02 = (m10 == null || (k02 = m10.k0()) == null) ? null : k02.o();
        }
    }
}
