package androidx.navigation;

import java.util.LinkedHashMap;

/* JADX INFO: loaded from: classes.dex */
public final class Y {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final LinkedHashMap f12732b = new LinkedHashMap();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final LinkedHashMap f12733a = new LinkedHashMap();

    public final void a(X navigator) {
        kotlin.jvm.internal.o.h(navigator, "navigator");
        String strC = AbstractC1131f.c(navigator.getClass());
        if (strC.length() <= 0) {
            throw new IllegalArgumentException("navigator name cannot be an empty string");
        }
        LinkedHashMap linkedHashMap = this.f12733a;
        X x6 = (X) linkedHashMap.get(strC);
        if (kotlin.jvm.internal.o.c(x6, navigator)) {
            return;
        }
        boolean z6 = false;
        if (x6 != null && x6.f12731b) {
            z6 = true;
        }
        if (z6) {
            throw new IllegalStateException(("Navigator " + navigator + " is replacing an already attached " + x6).toString());
        }
        if (!navigator.f12731b) {
            return;
        }
        throw new IllegalStateException(("Navigator " + navigator + " is already attached to another NavController").toString());
    }

    public final X b(String name) {
        kotlin.jvm.internal.o.h(name, "name");
        if (name.length() <= 0) {
            throw new IllegalArgumentException("navigator name cannot be an empty string");
        }
        X x6 = (X) this.f12733a.get(name);
        if (x6 != null) {
            return x6;
        }
        throw new IllegalStateException(Z0.o.o("Could not find Navigator with name \"", name, "\". You must call NavController.addNavigator() for each navigation type."));
    }
}
