package androidx.lifecycle;

import android.app.Application;
import d0.a;
import java.util.Objects;

/* JADX INFO: compiled from: ViewModelProvider.kt */
/* JADX INFO: loaded from: classes.dex */
public class a0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final c0 f2545a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final b f2546b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final d0.a f2547c;

    /* JADX INFO: compiled from: ViewModelProvider.kt */
    public static class a extends c {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public static final a.b<Application> f2548b;

        /* JADX INFO: renamed from: androidx.lifecycle.a0$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: ViewModelProvider.kt */
        public static final class C0034a {

            /* JADX INFO: renamed from: androidx.lifecycle.a0$a$a$a, reason: collision with other inner class name */
            /* JADX INFO: compiled from: ViewModelProvider.kt */
            private static final class C0035a implements a.b<Application> {

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

                private C0035a() {
                }
            }

            private C0034a() {
            }

            public /* synthetic */ C0034a(w1.e eVar) {
                this();
            }
        }

        static {
            new C0034a(null);
            f2548b = C0034a.C0035a.f2549a;
        }
    }

    /* JADX INFO: compiled from: ViewModelProvider.kt */
    public interface b {

        /* JADX INFO: compiled from: ViewModelProvider.kt */
        public static final class a {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            static final /* synthetic */ a f2550a = new a();

            private a() {
            }
        }

        static {
            a aVar = a.f2550a;
        }

        default <T extends z> T a(Class<T> cls) {
            w1.g.e(cls, "modelClass");
            throw new UnsupportedOperationException("Factory.create(String) is unsupported.  This Factory requires `CreationExtras` to be passed into `create` method.");
        }

        default <T extends z> T b(Class<T> cls, d0.a aVar) {
            w1.g.e(cls, "modelClass");
            w1.g.e(aVar, "extras");
            return (T) a(cls);
        }
    }

    /* JADX INFO: compiled from: ViewModelProvider.kt */
    public static class c implements b {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final a.b<String> f2551a;

        /* JADX INFO: compiled from: ViewModelProvider.kt */
        public static final class a {

            /* JADX INFO: renamed from: androidx.lifecycle.a0$c$a$a, reason: collision with other inner class name */
            /* JADX INFO: compiled from: ViewModelProvider.kt */
            private static final class C0036a implements a.b<String> {

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

                private C0036a() {
                }
            }

            private a() {
            }

            public /* synthetic */ a(w1.e eVar) {
                this();
            }
        }

        static {
            new a(null);
            f2551a = a.C0036a.f2552a;
        }
    }

    /* JADX INFO: compiled from: ViewModelProvider.kt */
    public static class d {
        public void a(z zVar) {
            w1.g.e(zVar, "viewModel");
        }
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public a0(c0 c0Var, b bVar) {
        this(c0Var, bVar, null, 4, null);
        w1.g.e(c0Var, "store");
        w1.g.e(bVar, "factory");
    }

    public a0(c0 c0Var, b bVar, d0.a aVar) {
        w1.g.e(c0Var, "store");
        w1.g.e(bVar, "factory");
        w1.g.e(aVar, "defaultCreationExtras");
        this.f2545a = c0Var;
        this.f2546b = bVar;
        this.f2547c = aVar;
    }

    public <T extends z> T a(Class<T> cls) {
        w1.g.e(cls, "modelClass");
        String canonicalName = cls.getCanonicalName();
        if (canonicalName == null) {
            throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels");
        }
        return (T) b("androidx.lifecycle.ViewModelProvider.DefaultKey:" + canonicalName, cls);
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    public <T extends z> T b(String str, Class<T> cls) {
        T t2;
        w1.g.e(str, "key");
        w1.g.e(cls, "modelClass");
        T t3 = (T) this.f2545a.b(str);
        if (!cls.isInstance(t3)) {
            d0.d dVar = new d0.d(this.f2547c);
            dVar.b(c.f2551a, str);
            try {
                t2 = (T) this.f2546b.b(cls, dVar);
            } catch (AbstractMethodError unused) {
                t2 = (T) this.f2546b.a(cls);
            }
            this.f2545a.d(str, t2);
            return t2;
        }
        Object obj = this.f2546b;
        d dVar2 = obj instanceof d ? (d) obj : null;
        if (dVar2 != null) {
            w1.g.d(t3, "viewModel");
            dVar2.a(t3);
        }
        Objects.requireNonNull(t3, "null cannot be cast to non-null type T of androidx.lifecycle.ViewModelProvider.get");
        return t3;
    }

    public /* synthetic */ a0(c0 c0Var, b bVar, d0.a aVar, int i3, w1.e eVar) {
        this(c0Var, bVar, (i3 & 4) != 0 ? a.C0058a.f4455b : aVar);
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public a0(d0 d0Var, b bVar) {
        w1.g.e(d0Var, "owner");
        w1.g.e(bVar, "factory");
        c0 c0VarI = d0Var.i();
        w1.g.d(c0VarI, "owner.viewModelStore");
        this(c0VarI, bVar, b0.a(d0Var));
    }
}
