package j2;

import android.os.Bundle;
import android.os.Parcelable;
import androidx.navigation.C1137l;
import androidx.navigation.C1138m;
import androidx.navigation.H;
import androidx.navigation.X;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import x4.AbstractC3229F;
import x4.AbstractC3252r;
import x4.C3249o;

/* JADX INFO: renamed from: j2.q, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C2339q extends kotlin.jvm.internal.p implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final C2339q f19510a = new C2339q(2);

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        Bundle bundle;
        H h5 = (H) obj2;
        h5.getClass();
        ArrayList<String> arrayList = new ArrayList<>();
        Bundle bundle2 = new Bundle();
        for (Map.Entry entry : AbstractC3229F.G(h5.f12688v.f12733a).entrySet()) {
            ((X) entry.getValue()).getClass();
        }
        if (arrayList.isEmpty()) {
            bundle = null;
        } else {
            bundle = new Bundle();
            bundle2.putStringArrayList("android-support-nav:controller:navigatorState:names", arrayList);
            bundle.putBundle("android-support-nav:controller:navigatorState", bundle2);
        }
        C3249o c3249o = h5.f12674g;
        if (!c3249o.isEmpty()) {
            if (bundle == null) {
                bundle = new Bundle();
            }
            Parcelable[] parcelableArr = new Parcelable[c3249o.size()];
            Iterator<E> it = c3249o.iterator();
            int i6 = 0;
            while (it.hasNext()) {
                parcelableArr[i6] = new C1138m((C1137l) it.next());
                i6++;
            }
            bundle.putParcelableArray("android-support-nav:controller:backStack", parcelableArr);
        }
        LinkedHashMap linkedHashMap = h5.f12679m;
        if (!linkedHashMap.isEmpty()) {
            if (bundle == null) {
                bundle = new Bundle();
            }
            int[] iArr = new int[linkedHashMap.size()];
            ArrayList<String> arrayList2 = new ArrayList<>();
            int i7 = 0;
            for (Map.Entry entry2 : linkedHashMap.entrySet()) {
                int iIntValue = ((Number) entry2.getKey()).intValue();
                String str = (String) entry2.getValue();
                iArr[i7] = iIntValue;
                arrayList2.add(str);
                i7++;
            }
            bundle.putIntArray("android-support-nav:controller:backStackDestIds", iArr);
            bundle.putStringArrayList("android-support-nav:controller:backStackIds", arrayList2);
        }
        LinkedHashMap linkedHashMap2 = h5.f12680n;
        if (!linkedHashMap2.isEmpty()) {
            if (bundle == null) {
                bundle = new Bundle();
            }
            ArrayList<String> arrayList3 = new ArrayList<>();
            for (Map.Entry entry3 : linkedHashMap2.entrySet()) {
                String str2 = (String) entry3.getKey();
                C3249o c3249o2 = (C3249o) entry3.getValue();
                arrayList3.add(str2);
                Parcelable[] parcelableArr2 = new Parcelable[c3249o2.size()];
                int i8 = 0;
                for (Object obj3 : c3249o2) {
                    int i9 = i8 + 1;
                    if (i8 < 0) {
                        AbstractC3252r.F();
                        throw null;
                    }
                    parcelableArr2[i8] = (C1138m) obj3;
                    i8 = i9;
                }
                bundle.putParcelableArray(A0.a.n("android-support-nav:controller:backStackStates:", str2), parcelableArr2);
            }
            bundle.putStringArrayList("android-support-nav:controller:backStackStates", arrayList3);
        }
        if (h5.f12673f) {
            if (bundle == null) {
                bundle = new Bundle();
            }
            bundle.putBoolean("android-support-nav:controller:deepLinkHandled", h5.f12673f);
        }
        return bundle;
    }
}
