package androidx.lifecycle; import android.app.Application; import java.lang.reflect.InvocationTargetException; /* loaded from: classes.dex */ public class v { /* renamed from: a, reason: collision with root package name */ private final b f2128a; /* renamed from: b, reason: collision with root package name */ private final w f2129b; public static class a extends d { /* renamed from: c, reason: collision with root package name */ private static a f2130c; /* renamed from: b, reason: collision with root package name */ private Application f2131b; public a(Application application) { this.f2131b = application; } public static a c(Application application) { if (f2130c == null) { f2130c = new a(application); } return f2130c; } @Override // androidx.lifecycle.v.d, androidx.lifecycle.v.b public u a(Class cls) { if (!androidx.lifecycle.a.class.isAssignableFrom(cls)) { return super.a(cls); } try { return (u) cls.getConstructor(Application.class).newInstance(this.f2131b); } catch (IllegalAccessException e10) { throw new RuntimeException("Cannot create an instance of " + cls, e10); } catch (InstantiationException e11) { throw new RuntimeException("Cannot create an instance of " + cls, e11); } catch (NoSuchMethodException e12) { throw new RuntimeException("Cannot create an instance of " + cls, e12); } catch (InvocationTargetException e13) { throw new RuntimeException("Cannot create an instance of " + cls, e13); } } } public interface b { u a(Class cls); } static abstract class c extends e implements b { c() { } public abstract u c(String str, Class cls); } public static class d implements b { /* renamed from: a, reason: collision with root package name */ private static d f2132a; static d b() { if (f2132a == null) { f2132a = new d(); } return f2132a; } @Override // androidx.lifecycle.v.b public u a(Class cls) { try { return (u) cls.newInstance(); } catch (IllegalAccessException e10) { throw new RuntimeException("Cannot create an instance of " + cls, e10); } catch (InstantiationException e11) { throw new RuntimeException("Cannot create an instance of " + cls, e11); } } } static class e { e() { } abstract void b(u uVar); } public v(w wVar, b bVar) { this.f2128a = bVar; this.f2129b = wVar; } public u a(Class cls) { String canonicalName = cls.getCanonicalName(); if (canonicalName == null) { throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels"); } return b("androidx.lifecycle.ViewModelProvider.DefaultKey:" + canonicalName, cls); } public u b(String str, Class cls) { u b10 = this.f2129b.b(str); if (cls.isInstance(b10)) { Object obj = this.f2128a; if (obj instanceof e) { ((e) obj).b(b10); } return b10; } b bVar = this.f2128a; u c10 = bVar instanceof c ? ((c) bVar).c(str, cls) : bVar.a(cls); this.f2129b.d(str, c10); return c10; } }