package kotlinx.coroutines.internal;

import d2.h1;
import java.util.List;

/* JADX INFO: compiled from: MainDispatchers.kt */
/* JADX INFO: loaded from: classes.dex */
public final class u {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static final boolean f5237a = true;

    private static final v a(Throwable th, String str) throws Throwable {
        if (f5237a) {
            return new v(th, str);
        }
        if (th != null) {
            throw th;
        }
        d();
        throw new k1.c();
    }

    static /* synthetic */ v b(Throwable th, String str, int i3, Object obj) {
        if ((i3 & 1) != 0) {
            th = null;
        }
        if ((i3 & 2) != 0) {
            str = null;
        }
        return a(th, str);
    }

    public static final boolean c(h1 h1Var) {
        return h1Var.j() instanceof v;
    }

    public static final Void d() {
        throw new IllegalStateException("Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' and ensure it has the same version as 'kotlinx-coroutines-core'");
    }

    public static final h1 e(r rVar, List<? extends r> list) {
        try {
            return rVar.createDispatcher(list);
        } catch (Throwable th) {
            return a(th, rVar.hintOnError());
        }
    }
}
