package androidx.navigation;

import java.util.ArrayList;
import java.util.Iterator;
import n.e0;
import x4.AbstractC3250p;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public class E extends B implements Iterable, K4.a {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public static final /* synthetic */ int f12655q = 0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final e0 f12656m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f12657n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public String f12658o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public String f12659p;

    public E(G g6) {
        super(g6);
        this.f12656m = new e0(0);
    }

    @Override // androidx.navigation.B
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof E) || !super.equals(obj)) {
            return false;
        }
        e0 e0Var = this.f12656m;
        int iE = e0Var.e();
        E e6 = (E) obj;
        e0 e0Var2 = e6.f12656m;
        if (iE != e0Var2.e() || this.f12657n != e6.f12657n) {
            return false;
        }
        for (B b5 : (R4.a) R4.n.X(new F1.I(e0Var, 5))) {
            if (!b5.equals(e0Var2.b(b5.f12644f))) {
                return false;
            }
        }
        return true;
    }

    @Override // androidx.navigation.B
    public final C1150z h(C4.f fVar) {
        return m(fVar, false, this);
    }

    @Override // androidx.navigation.B
    public final int hashCode() {
        int iC = this.f12657n;
        e0 e0Var = this.f12656m;
        int iE = e0Var.e();
        for (int i6 = 0; i6 < iE; i6++) {
            iC = (((iC * 31) + e0Var.c(i6)) * 31) + ((B) e0Var.f(i6)).hashCode();
        }
        return iC;
    }

    @Override // java.lang.Iterable
    public final Iterator iterator() {
        return new D(this);
    }

    public final B k(String route, boolean z6) {
        Object next;
        E e6;
        kotlin.jvm.internal.o.h(route, "route");
        e0 e0Var = this.f12656m;
        kotlin.jvm.internal.o.h(e0Var, "<this>");
        Iterator it = ((R4.a) R4.n.X(new F1.I(e0Var, 5))).iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            B b5 = (B) next;
            if (S4.w.t0(b5.f12645j, route, false) || b5.j(route) != null) {
                break;
            }
        }
        B b6 = (B) next;
        if (b6 != null) {
            return b6;
        }
        if (!z6 || (e6 = this.f12640b) == null || S4.p.Q0(route)) {
            return null;
        }
        return e6.k(route, true);
    }

    public final B l(int i6, E e6, boolean z6, B b5) {
        e0 e0Var = this.f12656m;
        B bL = (B) e0Var.b(i6);
        if (b5 != null) {
            if (kotlin.jvm.internal.o.c(bL, b5) && kotlin.jvm.internal.o.c(bL.f12640b, b5.f12640b)) {
                return bL;
            }
            bL = null;
        } else if (bL != null) {
            return bL;
        }
        if (z6) {
            Iterator it = ((R4.a) R4.n.X(new F1.I(e0Var, 5))).iterator();
            while (true) {
                if (!it.hasNext()) {
                    bL = null;
                    break;
                }
                B b6 = (B) it.next();
                bL = (!(b6 instanceof E) || kotlin.jvm.internal.o.c(b6, e6)) ? null : ((E) b6).l(i6, this, true, b5);
                if (bL != null) {
                    break;
                }
            }
        }
        if (bL != null) {
            return bL;
        }
        E e7 = this.f12640b;
        if (e7 == null || e7.equals(e6)) {
            return null;
        }
        E e8 = this.f12640b;
        kotlin.jvm.internal.o.e(e8);
        return e8.l(i6, this, z6, b5);
    }

    public final C1150z m(C4.f fVar, boolean z6, E e6) {
        C1150z c1150zM;
        C1150z c1150zH = super.h(fVar);
        ArrayList arrayList = new ArrayList();
        D d6 = new D(this);
        while (true) {
            if (!d6.hasNext()) {
                break;
            }
            B b5 = (B) d6.next();
            c1150zM = kotlin.jvm.internal.o.c(b5, e6) ? null : b5.h(fVar);
            if (c1150zM != null) {
                arrayList.add(c1150zM);
            }
        }
        C1150z c1150z = (C1150z) AbstractC3251q.p0(arrayList);
        E e7 = this.f12640b;
        if (e7 != null && z6 && !e7.equals(e6)) {
            c1150zM = e7.m(fVar, true, this);
        }
        return (C1150z) AbstractC3251q.p0(AbstractC3250p.K(new C1150z[]{c1150zH, c1150z, c1150zM}));
    }

    public final C1150z n(String route, boolean z6, E e6) {
        C1150z c1150zN;
        kotlin.jvm.internal.o.h(route, "route");
        C1150z c1150zJ = j(route);
        ArrayList arrayList = new ArrayList();
        D d6 = new D(this);
        while (true) {
            if (!d6.hasNext()) {
                break;
            }
            B b5 = (B) d6.next();
            c1150zN = kotlin.jvm.internal.o.c(b5, e6) ? null : b5 instanceof E ? ((E) b5).n(route, false, this) : b5.j(route);
            if (c1150zN != null) {
                arrayList.add(c1150zN);
            }
        }
        C1150z c1150z = (C1150z) AbstractC3251q.p0(arrayList);
        E e7 = this.f12640b;
        if (e7 != null && z6 && !e7.equals(e6)) {
            c1150zN = e7.n(route, true, this);
        }
        return (C1150z) AbstractC3251q.p0(AbstractC3250p.K(new C1150z[]{c1150zJ, c1150z, c1150zN}));
    }

    @Override // androidx.navigation.B
    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.toString());
        String str = this.f12659p;
        B bK = (str == null || S4.p.Q0(str)) ? null : k(str, true);
        if (bK == null) {
            bK = l(this.f12657n, this, false, null);
        }
        sb.append(" startDestination=");
        if (bK == null) {
            String str2 = this.f12659p;
            if (str2 != null) {
                sb.append(str2);
            } else {
                String str3 = this.f12658o;
                if (str3 != null) {
                    sb.append(str3);
                } else {
                    sb.append("0x" + Integer.toHexString(this.f12657n));
                }
            }
        } else {
            sb.append("{");
            sb.append(bK.toString());
            sb.append("}");
        }
        String string = sb.toString();
        kotlin.jvm.internal.o.g(string, "sb.toString()");
        return string;
    }
}
