package androidx.navigation;

import android.os.Bundle;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import n2.AbstractC2612c;
import x4.AbstractC3229F;

/* JADX INFO: loaded from: classes.dex */
@W("navigation")
public class G extends X {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Y f12663c;

    public G(Y navigatorProvider) {
        kotlin.jvm.internal.o.h(navigatorProvider, "navigatorProvider");
        this.f12663c = navigatorProvider;
    }

    @Override // androidx.navigation.X
    public final void d(List list, K k6) {
        Iterator it = list.iterator();
        while (it.hasNext()) {
            C1137l c1137l = (C1137l) it.next();
            B b5 = c1137l.f12757b;
            kotlin.jvm.internal.o.f(b5, "null cannot be cast to non-null type androidx.navigation.NavGraph");
            E e6 = (E) b5;
            kotlin.jvm.internal.C c6 = new kotlin.jvm.internal.C();
            c6.f20115a = c1137l.a();
            int i6 = e6.f12657n;
            String str = e6.f12659p;
            if (i6 == 0 && str == null) {
                StringBuilder sb = new StringBuilder("no start destination defined via app:startDestination for ");
                int i7 = e6.f12644f;
                sb.append(i7 != 0 ? String.valueOf(i7) : "the root navigation");
                throw new IllegalStateException(sb.toString().toString());
            }
            B bK = str != null ? e6.k(str, false) : (B) e6.f12656m.b(i6);
            if (bK == null) {
                if (e6.f12658o == null) {
                    String strValueOf = e6.f12659p;
                    if (strValueOf == null) {
                        strValueOf = String.valueOf(e6.f12657n);
                    }
                    e6.f12658o = strValueOf;
                }
                String str2 = e6.f12658o;
                kotlin.jvm.internal.o.e(str2);
                throw new IllegalArgumentException(Z0.o.o("navigation destination ", str2, " is not a direct child of this NavGraph"));
            }
            if (str != null) {
                if (!str.equals(bK.f12645j)) {
                    C1150z c1150zJ = bK.j(str);
                    Bundle bundle = c1150zJ != null ? c1150zJ.f12816b : null;
                    if (bundle != null && !bundle.isEmpty()) {
                        Bundle bundle2 = new Bundle();
                        bundle2.putAll(bundle);
                        Bundle bundle3 = (Bundle) c6.f20115a;
                        if (bundle3 != null) {
                            bundle2.putAll(bundle3);
                        }
                        c6.f20115a = bundle2;
                    }
                }
                LinkedHashMap linkedHashMap = bK.f12643e;
                if (AbstractC3229F.G(linkedHashMap).isEmpty()) {
                    continue;
                } else {
                    ArrayList arrayListD = AbstractC1131f.d(AbstractC3229F.G(linkedHashMap), new C1143s(1, c6));
                    if (!arrayListD.isEmpty()) {
                        throw new IllegalArgumentException(("Cannot navigate to startDestination " + bK + ". Missing required arguments [" + arrayListD + ']').toString());
                    }
                }
            }
            X xB = this.f12663c.b(bK.f12639a);
            C1139n c1139nB = b();
            Bundle bundleG = bK.g((Bundle) c6.f20115a);
            H h5 = c1139nB.f12778h;
            xB.d(AbstractC2612c.q(C1134i.j(h5.f12668a, bK, bundleG, h5.i(), h5.f12682p)), k6);
        }
    }

    @Override // androidx.navigation.X
    /* JADX INFO: renamed from: g, reason: merged with bridge method [inline-methods] */
    public E a() {
        return new E(this);
    }
}
