package v4;

import android.app.Activity;
import android.view.View;
import java.lang.ref.WeakReference;

/* loaded from: classes.dex */
public final class y {

    /* renamed from: a, reason: collision with root package name */
    public static final y f39243a = new y();

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final a f39244p = new a();

        a() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final View invoke(View it) {
            kotlin.jvm.internal.t.g(it, "it");
            Object parent = it.getParent();
            if (parent instanceof View) {
                return (View) parent;
            }
            return null;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class b extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final b f39245p = new b();

        b() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final j invoke(View it) {
            kotlin.jvm.internal.t.g(it, "it");
            return y.f39243a.e(it);
        }
    }

    private y() {
    }

    public static final j b(Activity activity, int i10) {
        kotlin.jvm.internal.t.g(activity, "activity");
        View f10 = androidx.core.app.a.f(activity, i10);
        kotlin.jvm.internal.t.f(f10, "requireViewById<View>(activity, viewId)");
        j d10 = f39243a.d(f10);
        if (d10 != null) {
            return d10;
        }
        throw new IllegalStateException("Activity " + activity + " does not have a NavController set on " + i10);
    }

    public static final j c(View view) {
        kotlin.jvm.internal.t.g(view, "view");
        j d10 = f39243a.d(view);
        if (d10 != null) {
            return d10;
        }
        throw new IllegalStateException("View " + view + " does not have a NavController set");
    }

    private final j d(View view) {
        rp.h i10;
        rp.h y10;
        Object r10;
        i10 = rp.n.i(view, a.f39244p);
        y10 = rp.p.y(i10, b.f39245p);
        r10 = rp.p.r(y10);
        return (j) r10;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final j e(View view) {
        Object tag = view.getTag(d0.f39036a);
        if (tag instanceof WeakReference) {
            return (j) ((WeakReference) tag).get();
        }
        if (tag instanceof j) {
            return (j) tag;
        }
        return null;
    }

    public static final void f(View view, j jVar) {
        kotlin.jvm.internal.t.g(view, "view");
        view.setTag(d0.f39036a, jVar);
    }
}
