content: package kotlinx.coroutines.internal;
  
  import java.util.Iterator;
  import java.util.List;
  import java.util.ServiceLoader;
  import kotlin.Metadata;
  import kotlin.sequences.SequencesKt;
  import kotlinx.coroutines.MainCoroutineDispatcher;
  
  @Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bÀ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\b\u0010\u0007\u001a\u00020\u0006H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0005\u001a\u00020\u00068\u0006X\u0004¢\u0006\u0002\n\u0000¨\u0006\b"}, d2 = {"Lkotlinx/coroutines/internal/MainDispatcherLoader;", "", "()V", "FAST_SERVICE_LOADER_ENABLED", "", "dispatcher", "Lkotlinx/coroutines/MainCoroutineDispatcher;", "loadMainDispatcher", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
  /* compiled from: MainDispatchers.kt */
  public final class MainDispatcherLoader {
      private static final boolean FAST_SERVICE_LOADER_ENABLED = SystemPropsKt.systemProp("kotlinx.coroutines.fast.service.loader", true);
      public static final MainDispatcherLoader INSTANCE;
      public static final MainCoroutineDispatcher dispatcher;
  
      static {
          MainDispatcherLoader mainDispatcherLoader = new MainDispatcherLoader();
          INSTANCE = mainDispatcherLoader;
          dispatcher = mainDispatcherLoader.loadMainDispatcher();
      }
  
      private MainDispatcherLoader() {
      }
  
      private final MainCoroutineDispatcher loadMainDispatcher() {
          Object obj;
          try {
              List<MainDispatcherFactory> loadMainDispatcherFactory$kotlinx_coroutines_core = FAST_SERVICE_LOADER_ENABLED ? FastServiceLoader.INSTANCE.loadMainDispatcherFactory$kotlinx_coroutines_core() : SequencesKt.toList(SequencesKt.asSequence(ServiceLoader.load(MainDispatcherFactory.class, MainDispatcherFactory.class.getClassLoader()).iterator()));
              Iterator it = loadMainDispatcherFactory$kotlinx_coroutines_core.iterator();
              if (!it.hasNext()) {
                  obj = null;
              } else {
                  obj = it.next();
                  if (it.hasNext()) {
                      int loadPriority = ((MainDispatcherFactory) obj).getLoadPriority();
                      do {
                          Object next = it.next();
                          int loadPriority2 = ((MainDispatcherFactory) next).getLoadPriority();
                          if (loadPriority < loadPriority2) {
                              obj = next;
                              loadPriority = loadPriority2;
                          }
                      } while (it.hasNext());
                  }
              }
              MainDispatcherFactory mainDispatcherFactory = (MainDispatcherFactory) obj;
              MainCoroutineDispatcher tryCreateDispatcher = mainDispatcherFactory == null ? null : MainDispatchersKt.tryCreateDispatcher(mainDispatcherFactory, loadMainDispatcherFactory$kotlinx_coroutines_core);
              return tryCreateDispatcher == null ? MainDispatchersKt.createMissingDispatcher$default((Throwable) null, (String) null, 3, (Object) null) : tryCreateDispatcher;
          } catch (Throwable th) {
              return MainDispatchersKt.createMissingDispatcher$default(th, (String) null, 2, (Object) null);
          }
      }
  }
  