package o; import java.util.Iterator; import java.util.List; import java.util.ServiceLoader; import kotlinx.coroutines.internal.MainDispatcherFactory; /* loaded from: classes.dex */ public final class ggY { public static final gfJ a; private static final boolean c; private ggY() { } private static gfJ a() { List e; Object next; gfJ e2; try { if (c) { ggO ggo = ggO.b; e = ggO.a(); } else { e = C14964gdG.e(C14964gdG.b(ServiceLoader.load(MainDispatcherFactory.class, MainDispatcherFactory.class.getClassLoader()).iterator())); } Iterator it = e.iterator(); if (it.hasNext()) { next = it.next(); if (it.hasNext()) { int loadPriority = ((MainDispatcherFactory) next).getLoadPriority(); do { Object next2 = it.next(); int loadPriority2 = ((MainDispatcherFactory) next2).getLoadPriority(); if (loadPriority < loadPriority2) { next = next2; loadPriority = loadPriority2; } } while (it.hasNext()); } } else { next = null; } MainDispatcherFactory mainDispatcherFactory = (MainDispatcherFactory) next; return (mainDispatcherFactory == null || (e2 = C15114ghc.e(mainDispatcherFactory, e)) == null) ? new C15116ghe(null, null) : e2; } catch (Throwable th) { return new C15116ghe(th, null); } } static { new ggY(); String e = C15124ghm.e("kotlinx.coroutines.fast.service.loader"); c = e != null ? Boolean.parseBoolean(e) : true; a = a(); } }