package n0;

import C0.C0104e;
import F.C0161o;
import G0.InterfaceC0279y;
import I0.AbstractC0301k;
import I0.AbstractC0303l;
import I0.C0290e0;
import I0.F0;
import I0.H;
import I0.InterfaceC0297i;
import I0.InterfaceC0299j;
import I0.InterfaceC0314x;
import I0.n0;
import J0.AbstractC0391w0;
import J0.C0390w;
import android.os.Trace;
import androidx.compose.runtime.collection.MutableVector;
import i0.AbstractC2254r;
import o0.C2632c;
import y0.C3259a;
import y0.C3261c;
import y0.InterfaceC3260b;

/* JADX INFO: loaded from: classes.dex */
public final class E extends AbstractC2254r implements InterfaceC0297i, InterfaceC0314x, n0, H0.c, InterfaceC0299j {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final J4.e f21500b;

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

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

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

    public E(int i6, int i7, J4.e eVar) {
        i6 = (i7 & 1) != 0 ? 1 : i6;
        boolean z6 = (i7 & 2) == 0;
        eVar = (i7 & 4) != 0 ? null : eVar;
        this.f21499a = z6;
        this.f21500b = eVar;
        this.f21503e = i6;
    }

    public final boolean A0(int i6) {
        Trace.beginSection("FocusTransactions:requestFocus");
        try {
            boolean zT0 = v0().f21543a ? t0(i6) : AbstractC2603d.h(this, i6, new C0390w(i6, 4));
            Trace.endSection();
            return zT0;
        } catch (Throwable th) {
            Trace.endSection();
            throw th;
        }
    }

    @Override // I0.n0
    public final void c0() throws Throwable {
        z0();
    }

    @Override // i0.AbstractC2254r
    public final boolean getShouldAutoInvalidate() {
        return false;
    }

    @Override // i0.AbstractC2254r
    public final void onDetach() {
        int iOrdinal = y0().ordinal();
        if (iOrdinal != 0) {
            if (iOrdinal == 1) {
                m focusOwner = ((J0.A) AbstractC0303l.u(this)).getFocusOwner();
                E eF = AbstractC2603d.f(this);
                if (eF == null || !eF.f21499a) {
                    return;
                }
                o oVar = (o) focusOwner;
                oVar.f21530a.E();
                oVar.f21533d.a();
                return;
            }
            if (iOrdinal != 2) {
                if (iOrdinal != 3) {
                    throw new E3.v();
                }
                return;
            }
        }
        o oVar2 = (o) ((J0.A) AbstractC0303l.u(this)).getFocusOwner();
        oVar2.c(true, 8, false);
        if (this.f21499a) {
            oVar2.f21530a.E();
        }
        oVar2.f21533d.a();
    }

    @Override // i0.AbstractC2254r
    public final void onReset() {
        if (y0().b()) {
            ((o) ((J0.A) AbstractC0303l.u(this)).getFocusOwner()).c(true, 8, true);
        }
    }

    public final boolean t0(int i6) {
        int iOrdinal = AbstractC2603d.x(this, i6).ordinal();
        if (iOrdinal == 0) {
            return AbstractC2603d.y(this);
        }
        if (iOrdinal == 1) {
            return false;
        }
        if (iOrdinal == 2) {
            return true;
        }
        if (iOrdinal == 3) {
            return false;
        }
        throw new E3.v();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r4v15 */
    public final void u0(C c6, C c7) {
        C0290e0 c0290e0;
        J4.e eVar;
        o oVar = (o) ((J0.A) AbstractC0303l.u(this)).getFocusOwner();
        E eG = oVar.g();
        if (!c6.equals(c7) && (eVar = this.f21500b) != null) {
            eVar.invoke(c6, c7);
        }
        AbstractC2254r node = getNode();
        if (!getNode().isAttached()) {
            F0.a.b("visitAncestors called on an unattached node");
        }
        AbstractC2254r node2 = getNode();
        H hT = AbstractC0303l.t(this);
        while (hT != null) {
            if ((((AbstractC2254r) hT.f2162J.f2365g).getAggregateChildKindSet$ui() & 5120) != 0) {
                while (node2 != null) {
                    if ((node2.getKindSet$ui() & 5120) != 0) {
                        if (node2 != node && (node2.getKindSet$ui() & 1024) != 0) {
                            return;
                        }
                        if ((node2.getKindSet$ui() & 4096) != 0) {
                            AbstractC2254r abstractC2254rE = node2;
                            MutableVector mutableVector = null;
                            while (abstractC2254rE != 0) {
                                if (abstractC2254rE instanceof InterfaceC2606g) {
                                    InterfaceC2606g interfaceC2606g = (InterfaceC2606g) abstractC2254rE;
                                    if (eG == oVar.g()) {
                                        interfaceC2606g.V(c7);
                                    }
                                } else if ((abstractC2254rE.getKindSet$ui() & 4096) != 0 && (abstractC2254rE instanceof AbstractC0301k)) {
                                    AbstractC2254r child$ui = ((AbstractC0301k) abstractC2254rE).f2431b;
                                    int i6 = 0;
                                    abstractC2254rE = abstractC2254rE;
                                    while (child$ui != null) {
                                        if ((child$ui.getKindSet$ui() & 4096) != 0) {
                                            i6++;
                                            if (i6 == 1) {
                                                abstractC2254rE = child$ui;
                                            } else {
                                                if (mutableVector == null) {
                                                    mutableVector = new MutableVector(new AbstractC2254r[16], 0);
                                                }
                                                if (abstractC2254rE != 0) {
                                                    mutableVector.add(abstractC2254rE);
                                                    abstractC2254rE = 0;
                                                }
                                                mutableVector.add(child$ui);
                                            }
                                        }
                                        child$ui = child$ui.getChild$ui();
                                        abstractC2254rE = abstractC2254rE;
                                    }
                                    if (i6 == 1) {
                                    }
                                }
                                abstractC2254rE = AbstractC0303l.e(mutableVector);
                            }
                        }
                    }
                    node2 = node2.getParent$ui();
                }
            }
            hT = hT.t();
            node2 = (hT == null || (c0290e0 = hT.f2162J) == null) ? null : (F0) c0290e0.f2364f;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r6v15 */
    public final t v0() {
        boolean z6;
        C0290e0 c0290e0;
        t tVar = new t();
        tVar.f21543a = true;
        x xVar = x.f21556b;
        tVar.f21544b = xVar;
        tVar.f21545c = xVar;
        tVar.f21546d = xVar;
        tVar.f21547e = xVar;
        tVar.f21548f = xVar;
        tVar.f21549g = xVar;
        tVar.f21550h = xVar;
        tVar.f21551i = xVar;
        tVar.f21552j = s.f21540b;
        tVar.f21553k = s.f21541c;
        tVar.l = p.f21538a;
        int i6 = this.f21503e;
        if (i6 == 1) {
            z6 = true;
        } else if (i6 == 0) {
            z6 = !(((C3259a) ((C3261c) ((InterfaceC3260b) AbstractC0303l.h(this, AbstractC0391w0.f3104m))).f26137a.getValue()).f26136a == 1);
        } else {
            if (i6 != 2) {
                throw new IllegalStateException("Unknown Focusability");
            }
            z6 = false;
        }
        tVar.f21543a = z6;
        AbstractC2254r node = getNode();
        if (!getNode().isAttached()) {
            F0.a.b("visitAncestors called on an unattached node");
        }
        AbstractC2254r node2 = getNode();
        H hT = AbstractC0303l.t(this);
        loop0: while (hT != null) {
            if ((((AbstractC2254r) hT.f2162J.f2365g).getAggregateChildKindSet$ui() & 3072) != 0) {
                while (node2 != null) {
                    if ((node2.getKindSet$ui() & 3072) != 0) {
                        if (node2 != node && (node2.getKindSet$ui() & 1024) != 0) {
                            break loop0;
                        }
                        if ((node2.getKindSet$ui() & 2048) != 0) {
                            AbstractC2254r abstractC2254rE = node2;
                            MutableVector mutableVector = null;
                            while (abstractC2254rE != 0) {
                                if (abstractC2254rE instanceof v) {
                                    ((v) abstractC2254rE).S(tVar);
                                } else if ((abstractC2254rE.getKindSet$ui() & 2048) != 0 && (abstractC2254rE instanceof AbstractC0301k)) {
                                    AbstractC2254r child$ui = ((AbstractC0301k) abstractC2254rE).f2431b;
                                    int i7 = 0;
                                    abstractC2254rE = abstractC2254rE;
                                    while (child$ui != null) {
                                        if ((child$ui.getKindSet$ui() & 2048) != 0) {
                                            i7++;
                                            if (i7 == 1) {
                                                abstractC2254rE = child$ui;
                                            } else {
                                                if (mutableVector == null) {
                                                    mutableVector = new MutableVector(new AbstractC2254r[16], 0);
                                                }
                                                if (abstractC2254rE != 0) {
                                                    mutableVector.add(abstractC2254rE);
                                                    abstractC2254rE = 0;
                                                }
                                                mutableVector.add(child$ui);
                                            }
                                        }
                                        child$ui = child$ui.getChild$ui();
                                        abstractC2254rE = abstractC2254rE;
                                    }
                                    if (i7 == 1) {
                                    }
                                }
                                abstractC2254rE = AbstractC0303l.e(mutableVector);
                            }
                        }
                    }
                    node2 = node2.getParent$ui();
                }
            }
            hT = hT.t();
            node2 = (hT == null || (c0290e0 = hT.f2162J) == null) ? null : (F0) c0290e0.f2364f;
        }
        return tVar;
    }

    public final C2632c w0(InterfaceC0279y interfaceC0279y) {
        C2632c c2632c = v0().l;
        return c2632c != p.f21538a ? interfaceC0279y == null ? c2632c : c2632c.i(interfaceC0279y.k(AbstractC0303l.s(this), 0L)) : interfaceC0279y != null ? interfaceC0279y.d0(AbstractC0303l.s(this), false) : m1.g.b(0L, W0.e.K(AbstractC0303l.s(this).f2000c));
    }

    public final C0161o x0() {
        C0290e0 c0290e0;
        Object obj;
        if (!getNode().isAttached()) {
            F0.a.b("visitAncestors called on an unattached node");
        }
        AbstractC2254r parent$ui = getNode().getParent$ui();
        H hT = AbstractC0303l.t(this);
        while (true) {
            if (hT == null) {
                break;
            }
            if ((((AbstractC2254r) hT.f2162J.f2365g).getAggregateChildKindSet$ui() & 8388640) != 0) {
                while (parent$ui != null) {
                    if ((parent$ui.getKindSet$ui() & 8388640) != 0) {
                        if ((parent$ui.getKindSet$ui() & 8388608) != 0) {
                            if (!(parent$ui instanceof C0161o)) {
                                if (parent$ui instanceof AbstractC0301k) {
                                    AbstractC2254r abstractC2254r = null;
                                    for (AbstractC2254r child$ui = ((AbstractC0301k) parent$ui).f2431b; child$ui != null; child$ui = child$ui.getChild$ui()) {
                                        if (child$ui instanceof C0161o) {
                                            abstractC2254r = child$ui;
                                        }
                                    }
                                    parent$ui = abstractC2254r;
                                } else {
                                    parent$ui = null;
                                }
                            }
                            C0161o c0161o = (C0161o) parent$ui;
                            if (c0161o != null) {
                                return c0161o;
                            }
                        } else if ((parent$ui.getKindSet$ui() & 32) != 0) {
                            if (parent$ui instanceof H0.c) {
                                obj = parent$ui;
                            } else if (parent$ui instanceof AbstractC0301k) {
                                obj = null;
                                for (AbstractC2254r child$ui2 = ((AbstractC0301k) parent$ui).f2431b; child$ui2 != null; child$ui2 = child$ui2.getChild$ui()) {
                                    if (child$ui2 instanceof H0.c) {
                                        obj = child$ui2;
                                    }
                                }
                            } else {
                                obj = null;
                            }
                            H0.c cVar = (H0.c) obj;
                            if (cVar != null) {
                                cVar.Q().getClass();
                            }
                        }
                    }
                    parent$ui = parent$ui.getParent$ui();
                }
            }
            hT = hT.t();
            parent$ui = (hT == null || (c0290e0 = hT.f2162J) == null) ? null : (F0) c0290e0.f2364f;
        }
        return null;
    }

    public final C y0() {
        C0290e0 c0290e0;
        if (!isAttached()) {
            return C.f21496c;
        }
        E eG = ((o) ((J0.A) AbstractC0303l.u(this)).getFocusOwner()).g();
        if (eG == null) {
            return C.f21496c;
        }
        if (this == eG) {
            return C.f21494a;
        }
        if (eG.isAttached()) {
            if (!eG.getNode().isAttached()) {
                F0.a.b("visitAncestors called on an unattached node");
            }
            AbstractC2254r parent$ui = eG.getNode().getParent$ui();
            H hT = AbstractC0303l.t(eG);
            while (hT != null) {
                if ((((AbstractC2254r) hT.f2162J.f2365g).getAggregateChildKindSet$ui() & 1024) != 0) {
                    while (parent$ui != null) {
                        if ((parent$ui.getKindSet$ui() & 1024) != 0) {
                            AbstractC2254r abstractC2254rE = parent$ui;
                            MutableVector mutableVector = null;
                            while (abstractC2254rE != null) {
                                if (abstractC2254rE instanceof E) {
                                    if (this == ((E) abstractC2254rE)) {
                                        return C.f21495b;
                                    }
                                } else if ((abstractC2254rE.getKindSet$ui() & 1024) != 0 && (abstractC2254rE instanceof AbstractC0301k)) {
                                    int i6 = 0;
                                    for (AbstractC2254r child$ui = ((AbstractC0301k) abstractC2254rE).f2431b; child$ui != null; child$ui = child$ui.getChild$ui()) {
                                        if ((child$ui.getKindSet$ui() & 1024) != 0) {
                                            i6++;
                                            if (i6 == 1) {
                                                abstractC2254rE = child$ui;
                                            } else {
                                                if (mutableVector == null) {
                                                    mutableVector = new MutableVector(new AbstractC2254r[16], 0);
                                                }
                                                if (abstractC2254rE != null) {
                                                    mutableVector.add(abstractC2254rE);
                                                    abstractC2254rE = null;
                                                }
                                                mutableVector.add(child$ui);
                                            }
                                        }
                                    }
                                    if (i6 == 1) {
                                    }
                                }
                                abstractC2254rE = AbstractC0303l.e(mutableVector);
                            }
                        }
                        parent$ui = parent$ui.getParent$ui();
                    }
                }
                hT = hT.t();
                parent$ui = (hT == null || (c0290e0 = hT.f2162J) == null) ? null : (F0) c0290e0.f2364f;
            }
        }
        return C.f21496c;
    }

    public final void z0() throws Throwable {
        int iOrdinal = y0().ordinal();
        if (iOrdinal != 0) {
            if (iOrdinal == 1) {
                return;
            }
            if (iOrdinal != 2) {
                if (iOrdinal != 3) {
                    throw new E3.v();
                }
                return;
            }
        }
        kotlin.jvm.internal.C c6 = new kotlin.jvm.internal.C();
        AbstractC0303l.p(this, new C0104e(12, c6, this));
        Object obj = c6.f20115a;
        if (obj == null) {
            kotlin.jvm.internal.o.n("focusProperties");
            throw null;
        }
        if (((q) obj).d()) {
            return;
        }
        ((o) ((J0.A) AbstractC0303l.u(this)).getFocusOwner()).c(true, 8, true);
    }

    @Override // I0.InterfaceC0314x
    public final void h0(InterfaceC0279y interfaceC0279y) {
    }
}
