package o;

import android.app.Application;
import java.lang.reflect.InvocationTargetException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.ek0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1125ek0 extends C1317gk0 {
    public static C1125ek0 c;
    public static final C2616uQ d = new C2616uQ(24);
    public final Application b;

    public C1125ek0(Application application) {
        this.b = application;
    }

    public static AbstractC0934ck0 d(Class cls, Application application) {
        if (!AbstractC0784b6.class.isAssignableFrom(cls)) {
            return C2887xC.m(cls);
        }
        try {
            return (AbstractC0934ck0) cls.getConstructor(Application.class).newInstance(application);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Cannot create an instance of " + cls, e);
        } catch (InstantiationException e2) {
            throw new RuntimeException("Cannot create an instance of " + cls, e2);
        } catch (NoSuchMethodException e3) {
            throw new RuntimeException("Cannot create an instance of " + cls, e3);
        } catch (InvocationTargetException e4) {
            throw new RuntimeException("Cannot create an instance of " + cls, e4);
        }
    }

    @Override // o.C1317gk0, o.InterfaceC1221fk0
    public final AbstractC0934ck0 a(Class cls) {
        Application application = this.b;
        if (application != null) {
            return d(cls, application);
        }
        throw new UnsupportedOperationException("AndroidViewModelFactory constructed with empty constructor works only with create(modelClass: Class<T>, extras: CreationExtras).");
    }

    @Override // o.C1317gk0, o.InterfaceC1221fk0
    public final AbstractC0934ck0 c(Class cls, FQ fq) {
        if (this.b != null) {
            return a(cls);
        }
        Application application = (Application) fq.a.get(d);
        if (application != null) {
            return d(cls, application);
        }
        if (AbstractC0784b6.class.isAssignableFrom(cls)) {
            throw new IllegalArgumentException("CreationExtras must have an application by `APPLICATION_KEY`");
        }
        return C2887xC.m(cls);
    }
}
