package androidx.navigation;

import M2.C0556x0;
import Y4.c0;
import java.util.List;
import java.util.ListIterator;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public abstract class X {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public C1139n f12730a;

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

    public abstract B a();

    public final C1139n b() {
        C1139n c1139n = this.f12730a;
        if (c1139n != null) {
            return c1139n;
        }
        throw new IllegalStateException("You cannot access the Navigator's state until the Navigator is attached");
    }

    public void d(List list, K k6) {
        R4.f fVar = new R4.f(new R4.g(R4.n.b0(AbstractC3251q.W(list), new C1143s(this, k6)), false, new C0556x0(28)));
        while (fVar.hasNext()) {
            b().f((C1137l) fVar.next());
        }
    }

    public void e(C1137l popUpTo, boolean z6) {
        kotlin.jvm.internal.o.h(popUpTo, "popUpTo");
        List list = (List) ((c0) b().f12775e.f8871a).getValue();
        if (!list.contains(popUpTo)) {
            throw new IllegalStateException(("popBackStack was called with " + popUpTo + " which does not exist in back stack " + list).toString());
        }
        ListIterator listIterator = list.listIterator(list.size());
        C1137l c1137l = null;
        while (f()) {
            c1137l = (C1137l) listIterator.previous();
            if (kotlin.jvm.internal.o.c(c1137l, popUpTo)) {
                break;
            }
        }
        if (c1137l != null) {
            b().c(c1137l, z6);
        }
    }

    public boolean f() {
        return true;
    }

    public B c(B b5) {
        return b5;
    }
}
