package s.coroutines;

import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.o;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
import s.coroutines.Job;
import s.coroutines.internal.LockFreeLinkedListNode;
import s.coroutines.internal.OpDescriptor;
import s.coroutines.internal.Symbol;
import s.coroutines.internal.i;

/* JADX INFO: renamed from: s.a.i1, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000è\u0001\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0003\n\u0000\n\u0002\u0010 \n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0017\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u0001\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\b\n\u0002\b\u0010\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0012\b\u0017\u0018\u00002\u00020X2\u00020\u00172\u00020\u007f2\u00030Ã\u0001:\u0006Ò\u0001Ó\u0001Ô\u0001B\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0001¢\u0006\u0004\b\u0003\u0010\u0004J'\u0010\u000b\u001a\u00020\u00012\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tH\u0002¢\u0006\u0004\b\u000b\u0010\fJ%\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u000e\u001a\u00020\r2\f\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\r0\u000fH\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u0019\u0010\u0015\u001a\u00020\u00112\b\u0010\u0014\u001a\u0004\u0018\u00010\u0005H\u0014¢\u0006\u0004\b\u0015\u0010\u0016J\u0015\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u0018\u001a\u00020\u0017¢\u0006\u0004\b\u001a\u0010\u001bJ\u0015\u0010\u001e\u001a\u0004\u0018\u00010\u0005H\u0080@ø\u0001\u0000¢\u0006\u0004\b\u001c\u0010\u001dJ\u0015\u0010\u001f\u001a\u0004\u0018\u00010\u0005H\u0082@ø\u0001\u0000¢\u0006\u0004\b\u001f\u0010\u001dJ\u0019\u0010!\u001a\u00020\u00012\b\u0010 \u001a\u0004\u0018\u00010\rH\u0017¢\u0006\u0004\b!\u0010\"J\u001f\u0010!\u001a\u00020\u00112\u000e\u0010 \u001a\n\u0018\u00010#j\u0004\u0018\u0001`$H\u0016¢\u0006\u0004\b!\u0010%J\u0017\u0010&\u001a\u00020\u00012\b\u0010 \u001a\u0004\u0018\u00010\r¢\u0006\u0004\b&\u0010\"J\u0019\u0010)\u001a\u00020\u00012\b\u0010 \u001a\u0004\u0018\u00010\u0005H\u0000¢\u0006\u0004\b'\u0010(J\u0017\u0010*\u001a\u00020\u00112\u0006\u0010 \u001a\u00020\rH\u0016¢\u0006\u0004\b*\u0010+J\u001b\u0010,\u001a\u0004\u0018\u00010\u00052\b\u0010 \u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0004\b,\u0010-J\u0017\u0010.\u001a\u00020\u00012\u0006\u0010 \u001a\u00020\rH\u0002¢\u0006\u0004\b.\u0010\"J\u000f\u00100\u001a\u00020/H\u0014¢\u0006\u0004\b0\u00101J\u0017\u00102\u001a\u00020\u00012\u0006\u0010 \u001a\u00020\rH\u0016¢\u0006\u0004\b2\u0010\"J!\u00105\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u0002032\b\u00104\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0004\b5\u00106J)\u0010;\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u0002072\u0006\u00109\u001a\u0002082\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0004\b;\u0010<J\u0019\u0010=\u001a\u00020\r2\b\u0010 \u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0004\b=\u0010>J(\u0010C\u001a\u00020@2\n\b\u0002\u0010?\u001a\u0004\u0018\u00010/2\n\b\u0002\u0010 \u001a\u0004\u0018\u00010\rH\u0080\b¢\u0006\u0004\bA\u0010BJ#\u0010D\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0014\u001a\u0002072\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0004\bD\u0010EJ\u0019\u0010F\u001a\u0004\u0018\u0001082\u0006\u0010\u0014\u001a\u000203H\u0002¢\u0006\u0004\bF\u0010GJ\u0011\u0010H\u001a\u00060#j\u0002`$¢\u0006\u0004\bH\u0010IJ\u0013\u0010J\u001a\u00060#j\u0002`$H\u0016¢\u0006\u0004\bJ\u0010IJ\u0011\u0010M\u001a\u0004\u0018\u00010\u0005H\u0000¢\u0006\u0004\bK\u0010LJ\u000f\u0010N\u001a\u0004\u0018\u00010\r¢\u0006\u0004\bN\u0010OJ'\u0010P\u001a\u0004\u0018\u00010\r2\u0006\u0010\u0014\u001a\u0002072\f\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\r0\u000fH\u0002¢\u0006\u0004\bP\u0010QJ\u0019\u0010R\u001a\u0004\u0018\u00010\u00072\u0006\u0010\u0014\u001a\u000203H\u0002¢\u0006\u0004\bR\u0010SJ\u0017\u0010U\u001a\u00020\u00012\u0006\u0010T\u001a\u00020\rH\u0014¢\u0006\u0004\bU\u0010\"J\u0017\u0010W\u001a\u00020\u00112\u0006\u0010T\u001a\u00020\rH\u0010¢\u0006\u0004\bV\u0010+J\u0019\u0010Z\u001a\u00020\u00112\b\u0010Y\u001a\u0004\u0018\u00010XH\u0004¢\u0006\u0004\bZ\u0010[JF\u0010d\u001a\u00020c2\u0006\u0010\\\u001a\u00020\u00012\u0006\u0010]\u001a\u00020\u00012'\u0010b\u001a#\u0012\u0015\u0012\u0013\u0018\u00010\r¢\u0006\f\b_\u0012\b\b`\u0012\u0004\b\b( \u0012\u0004\u0012\u00020\u00110^j\u0002`a¢\u0006\u0004\bd\u0010eJ6\u0010d\u001a\u00020c2'\u0010b\u001a#\u0012\u0015\u0012\u0013\u0018\u00010\r¢\u0006\f\b_\u0012\b\b`\u0012\u0004\b\b( \u0012\u0004\u0012\u00020\u00110^j\u0002`a¢\u0006\u0004\bd\u0010fJ\u0013\u0010g\u001a\u00020\u0011H\u0086@ø\u0001\u0000¢\u0006\u0004\bg\u0010\u001dJ\u000f\u0010h\u001a\u00020\u0001H\u0002¢\u0006\u0004\bh\u0010iJ\u0013\u0010j\u001a\u00020\u0011H\u0082@ø\u0001\u0000¢\u0006\u0004\bj\u0010\u001dJ&\u0010m\u001a\u00020l2\u0014\u0010k\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\u0005\u0012\u0004\u0012\u00020\u00110^H\u0082\b¢\u0006\u0004\bm\u0010nJ\u001b\u0010o\u001a\u0004\u0018\u00010\u00052\b\u0010 \u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0004\bo\u0010-J\u0019\u0010q\u001a\u00020\u00012\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0000¢\u0006\u0004\bp\u0010(J\u001b\u0010s\u001a\u0004\u0018\u00010\u00052\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0000¢\u0006\u0004\br\u0010-J@\u0010t\u001a\u00020\t2'\u0010b\u001a#\u0012\u0015\u0012\u0013\u0018\u00010\r¢\u0006\f\b_\u0012\b\b`\u0012\u0004\b\b( \u0012\u0004\u0012\u00020\u00110^j\u0002`a2\u0006\u0010\\\u001a\u00020\u0001H\u0002¢\u0006\u0004\bt\u0010uJ\u000f\u0010w\u001a\u00020/H\u0010¢\u0006\u0004\bv\u00101J\u001f\u0010x\u001a\u00020\u00112\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010 \u001a\u00020\rH\u0002¢\u0006\u0004\bx\u0010yJ.\u0010{\u001a\u00020\u0011\"\n\b\u0000\u0010z\u0018\u0001*\u00020\t2\u0006\u0010\b\u001a\u00020\u00072\b\u0010 \u001a\u0004\u0018\u00010\rH\u0082\b¢\u0006\u0004\b{\u0010yJ\u0019\u0010\\\u001a\u00020\u00112\b\u0010 \u001a\u0004\u0018\u00010\rH\u0014¢\u0006\u0004\b\\\u0010+J\u0019\u0010|\u001a\u00020\u00112\b\u0010\u0014\u001a\u0004\u0018\u00010\u0005H\u0014¢\u0006\u0004\b|\u0010\u0016J\u000f\u0010}\u001a\u00020\u0011H\u0014¢\u0006\u0004\b}\u0010~J\u0019\u0010\u0081\u0001\u001a\u00020\u00112\u0007\u0010\u0080\u0001\u001a\u00020\u007f¢\u0006\u0006\b\u0081\u0001\u0010\u0082\u0001J\u001b\u0010\u0084\u0001\u001a\u00020\u00112\u0007\u0010\u0014\u001a\u00030\u0083\u0001H\u0002¢\u0006\u0006\b\u0084\u0001\u0010\u0085\u0001J\u001a\u0010\u0086\u0001\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u00020\tH\u0002¢\u0006\u0006\b\u0086\u0001\u0010\u0087\u0001JI\u0010\u008c\u0001\u001a\u00020\u0011\"\u0005\b\u0000\u0010\u0088\u00012\u000e\u0010\u008a\u0001\u001a\t\u0012\u0004\u0012\u00028\u00000\u0089\u00012\u001d\u0010k\u001a\u0019\b\u0001\u0012\u000b\u0012\t\u0012\u0004\u0012\u00028\u00000\u008b\u0001\u0012\u0006\u0012\u0004\u0018\u00010\u00050^ø\u0001\u0000¢\u0006\u0006\b\u008c\u0001\u0010\u008d\u0001JX\u0010\u0091\u0001\u001a\u00020\u0011\"\u0004\b\u0000\u0010z\"\u0005\b\u0001\u0010\u0088\u00012\u000e\u0010\u008a\u0001\u001a\t\u0012\u0004\u0012\u00028\u00010\u0089\u00012$\u0010k\u001a \b\u0001\u0012\u0004\u0012\u00028\u0000\u0012\u000b\u0012\t\u0012\u0004\u0012\u00028\u00010\u008b\u0001\u0012\u0006\u0012\u0004\u0018\u00010\u00050\u008e\u0001H\u0000ø\u0001\u0000¢\u0006\u0006\b\u008f\u0001\u0010\u0090\u0001J\u001a\u0010\u0093\u0001\u001a\u00020\u00112\u0006\u0010\n\u001a\u00020\tH\u0000¢\u0006\u0006\b\u0092\u0001\u0010\u0087\u0001JX\u0010\u0095\u0001\u001a\u00020\u0011\"\u0004\b\u0000\u0010z\"\u0005\b\u0001\u0010\u0088\u00012\u000e\u0010\u008a\u0001\u001a\t\u0012\u0004\u0012\u00028\u00010\u0089\u00012$\u0010k\u001a \b\u0001\u0012\u0004\u0012\u00028\u0000\u0012\u000b\u0012\t\u0012\u0004\u0012\u00028\u00010\u008b\u0001\u0012\u0006\u0012\u0004\u0018\u00010\u00050\u008e\u0001H\u0000ø\u0001\u0000¢\u0006\u0006\b\u0094\u0001\u0010\u0090\u0001J\u000f\u0010\u0096\u0001\u001a\u00020\u0001¢\u0006\u0005\b\u0096\u0001\u0010iJ\u001d\u0010\u0098\u0001\u001a\u00030\u0097\u00012\b\u0010\u0014\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0006\b\u0098\u0001\u0010\u0099\u0001J\u001c\u0010\u009a\u0001\u001a\u00020/2\b\u0010\u0014\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0006\b\u009a\u0001\u0010\u009b\u0001J\u0011\u0010\u009c\u0001\u001a\u00020/H\u0007¢\u0006\u0005\b\u009c\u0001\u00101J\u0011\u0010\u009d\u0001\u001a\u00020/H\u0016¢\u0006\u0005\b\u009d\u0001\u00101J$\u0010\u009e\u0001\u001a\u00020\u00012\u0006\u0010\u0014\u001a\u0002032\b\u00104\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0006\b\u009e\u0001\u0010\u009f\u0001J\"\u0010 \u0001\u001a\u00020\u00012\u0006\u0010\u0014\u001a\u0002032\u0006\u0010\u000e\u001a\u00020\rH\u0002¢\u0006\u0006\b \u0001\u0010¡\u0001J(\u0010¢\u0001\u001a\u0004\u0018\u00010\u00052\b\u0010\u0014\u001a\u0004\u0018\u00010\u00052\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0006\b¢\u0001\u0010£\u0001J&\u0010¤\u0001\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0014\u001a\u0002032\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0002¢\u0006\u0006\b¤\u0001\u0010¥\u0001J-\u0010¦\u0001\u001a\u00020\u00012\u0006\u0010\u0014\u001a\u0002072\u0006\u0010\u0018\u001a\u0002082\b\u0010:\u001a\u0004\u0018\u00010\u0005H\u0082\u0010¢\u0006\u0006\b¦\u0001\u0010§\u0001J\u0019\u0010©\u0001\u001a\u0004\u0018\u000108*\u00030¨\u0001H\u0002¢\u0006\u0006\b©\u0001\u0010ª\u0001J\u001f\u0010«\u0001\u001a\u00020\u0011*\u00020\u00072\b\u0010 \u001a\u0004\u0018\u00010\rH\u0002¢\u0006\u0005\b«\u0001\u0010yJ&\u0010¬\u0001\u001a\u00060#j\u0002`$*\u00020\r2\n\b\u0002\u0010?\u001a\u0004\u0018\u00010/H\u0004¢\u0006\u0006\b¬\u0001\u0010\u00ad\u0001R\u001b\u0010±\u0001\u001a\t\u0012\u0004\u0012\u00020X0®\u00018F¢\u0006\b\u001a\u0006\b¯\u0001\u0010°\u0001R\u0018\u0010³\u0001\u001a\u0004\u0018\u00010\r8DX\u0084\u0004¢\u0006\u0007\u001a\u0005\b²\u0001\u0010OR\u0016\u0010µ\u0001\u001a\u00020\u00018DX\u0084\u0004¢\u0006\u0007\u001a\u0005\b´\u0001\u0010iR\u0016\u0010·\u0001\u001a\u00020\u00018PX\u0090\u0004¢\u0006\u0007\u001a\u0005\b¶\u0001\u0010iR\u0016\u0010¸\u0001\u001a\u00020\u00018VX\u0096\u0004¢\u0006\u0007\u001a\u0005\b¸\u0001\u0010iR\u0013\u0010¹\u0001\u001a\u00020\u00018F¢\u0006\u0007\u001a\u0005\b¹\u0001\u0010iR\u0013\u0010º\u0001\u001a\u00020\u00018F¢\u0006\u0007\u001a\u0005\bº\u0001\u0010iR\u0013\u0010»\u0001\u001a\u00020\u00018F¢\u0006\u0007\u001a\u0005\b»\u0001\u0010iR\u0016\u0010¼\u0001\u001a\u00020\u00018TX\u0094\u0004¢\u0006\u0007\u001a\u0005\b¼\u0001\u0010iR\u0019\u0010À\u0001\u001a\u0007\u0012\u0002\b\u00030½\u00018F¢\u0006\b\u001a\u0006\b¾\u0001\u0010¿\u0001R\u0016\u0010Â\u0001\u001a\u00020\u00018PX\u0090\u0004¢\u0006\u0007\u001a\u0005\bÁ\u0001\u0010iR\u0015\u0010Æ\u0001\u001a\u00030Ã\u00018F¢\u0006\b\u001a\u0006\bÄ\u0001\u0010Å\u0001R.\u0010Ì\u0001\u001a\u0004\u0018\u00010\u00192\t\u0010Ç\u0001\u001a\u0004\u0018\u00010\u00198@@@X\u0080\u000e¢\u0006\u0010\u001a\u0006\bÈ\u0001\u0010É\u0001\"\u0006\bÊ\u0001\u0010Ë\u0001R\u0017\u0010\u0014\u001a\u0004\u0018\u00010\u00058@X\u0080\u0004¢\u0006\u0007\u001a\u0005\bÍ\u0001\u0010LR\u001e\u0010Ï\u0001\u001a\u0004\u0018\u00010\r*\u0004\u0018\u00010\u00058BX\u0082\u0004¢\u0006\u0007\u001a\u0005\bÎ\u0001\u0010>R\u001b\u0010Ð\u0001\u001a\u00020\u0001*\u0002038BX\u0082\u0004¢\u0006\b\u001a\u0006\bÐ\u0001\u0010Ñ\u0001\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006Õ\u0001"}, d2 = {"Lkotlinx/coroutines/JobSupport;", "", "active", "<init>", "(Z)V", "", "expect", "Lkotlinx/coroutines/NodeList;", "list", "Lkotlinx/coroutines/JobNode;", "node", "addLastAtomic", "(Ljava/lang/Object;Lkotlinx/coroutines/NodeList;Lkotlinx/coroutines/JobNode;)Z", "", "rootCause", "", "exceptions", "", "addSuppressedExceptions", "(Ljava/lang/Throwable;Ljava/util/List;)V", "state", "afterCompletion", "(Ljava/lang/Object;)V", "Lkotlinx/coroutines/ChildJob;", "child", "Lkotlinx/coroutines/ChildHandle;", "attachChild", "(Lkotlinx/coroutines/ChildJob;)Lkotlinx/coroutines/ChildHandle;", "awaitInternal$kotlinx_coroutines_core", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "awaitInternal", "awaitSuspend", "cause", "cancel", "(Ljava/lang/Throwable;)Z", "Ljava/util/concurrent/CancellationException;", "Lkotlinx/coroutines/CancellationException;", "(Ljava/util/concurrent/CancellationException;)V", "cancelCoroutine", "cancelImpl$kotlinx_coroutines_core", "(Ljava/lang/Object;)Z", "cancelImpl", "cancelInternal", "(Ljava/lang/Throwable;)V", "cancelMakeCompleting", "(Ljava/lang/Object;)Ljava/lang/Object;", "cancelParent", "", "cancellationExceptionMessage", "()Ljava/lang/String;", "childCancelled", "Lkotlinx/coroutines/Incomplete;", "update", "completeStateFinalization", "(Lkotlinx/coroutines/Incomplete;Ljava/lang/Object;)V", "Lkotlinx/coroutines/JobSupport$Finishing;", "Lkotlinx/coroutines/ChildHandleNode;", "lastChild", "proposedUpdate", "continueCompleting", "(Lkotlinx/coroutines/JobSupport$Finishing;Lkotlinx/coroutines/ChildHandleNode;Ljava/lang/Object;)V", "createCauseException", "(Ljava/lang/Object;)Ljava/lang/Throwable;", "message", "Lkotlinx/coroutines/JobCancellationException;", "defaultCancellationException$kotlinx_coroutines_core", "(Ljava/lang/String;Ljava/lang/Throwable;)Lkotlinx/coroutines/JobCancellationException;", "defaultCancellationException", "finalizeFinishingState", "(Lkotlinx/coroutines/JobSupport$Finishing;Ljava/lang/Object;)Ljava/lang/Object;", "firstChild", "(Lkotlinx/coroutines/Incomplete;)Lkotlinx/coroutines/ChildHandleNode;", "getCancellationException", "()Ljava/util/concurrent/CancellationException;", "getChildJobCancellationCause", "getCompletedInternal$kotlinx_coroutines_core", "()Ljava/lang/Object;", "getCompletedInternal", "getCompletionExceptionOrNull", "()Ljava/lang/Throwable;", "getFinalRootCause", "(Lkotlinx/coroutines/JobSupport$Finishing;Ljava/util/List;)Ljava/lang/Throwable;", "getOrPromoteCancellingList", "(Lkotlinx/coroutines/Incomplete;)Lkotlinx/coroutines/NodeList;", "exception", "handleJobException", "handleOnCompletionException$kotlinx_coroutines_core", "handleOnCompletionException", "Lkotlinx/coroutines/Job;", "parent", "initParentJob", "(Lkotlinx/coroutines/Job;)V", "onCancelling", "invokeImmediately", "Lkotlin/Function1;", "Lkotlin/ParameterName;", "name", "Lkotlinx/coroutines/CompletionHandler;", "handler", "Lkotlinx/coroutines/DisposableHandle;", "invokeOnCompletion", "(ZZLkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/DisposableHandle;", "(Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/DisposableHandle;", "join", "joinInternal", "()Z", "joinSuspend", "block", "", "loopOnState", "(Lkotlin/jvm/functions/Function1;)Ljava/lang/Void;", "makeCancelling", "makeCompleting$kotlinx_coroutines_core", "makeCompleting", "makeCompletingOnce$kotlinx_coroutines_core", "makeCompletingOnce", "makeNode", "(Lkotlin/jvm/functions/Function1;Z)Lkotlinx/coroutines/JobNode;", "nameString$kotlinx_coroutines_core", "nameString", "notifyCancelling", "(Lkotlinx/coroutines/NodeList;Ljava/lang/Throwable;)V", "T", "notifyHandlers", "onCompletionInternal", "onStart", "()V", "Lkotlinx/coroutines/ParentJob;", "parentJob", "parentCancelled", "(Lkotlinx/coroutines/ParentJob;)V", "Lkotlinx/coroutines/Empty;", "promoteEmptyToNodeList", "(Lkotlinx/coroutines/Empty;)V", "promoteSingleToNodeList", "(Lkotlinx/coroutines/JobNode;)V", "R", "Lkotlinx/coroutines/selects/SelectInstance;", "select", "Lkotlin/coroutines/Continuation;", "registerSelectClause0", "(Lkotlinx/coroutines/selects/SelectInstance;Lkotlin/jvm/functions/Function1;)V", "Lkotlin/Function2;", "registerSelectClause1Internal$kotlinx_coroutines_core", "(Lkotlinx/coroutines/selects/SelectInstance;Lkotlin/jvm/functions/Function2;)V", "registerSelectClause1Internal", "removeNode$kotlinx_coroutines_core", "removeNode", "selectAwaitCompletion$kotlinx_coroutines_core", "selectAwaitCompletion", "start", "", "startInternal", "(Ljava/lang/Object;)I", "stateString", "(Ljava/lang/Object;)Ljava/lang/String;", "toDebugString", "toString", "tryFinalizeSimpleState", "(Lkotlinx/coroutines/Incomplete;Ljava/lang/Object;)Z", "tryMakeCancelling", "(Lkotlinx/coroutines/Incomplete;Ljava/lang/Throwable;)Z", "tryMakeCompleting", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "tryMakeCompletingSlowPath", "(Lkotlinx/coroutines/Incomplete;Ljava/lang/Object;)Ljava/lang/Object;", "tryWaitForChild", "(Lkotlinx/coroutines/JobSupport$Finishing;Lkotlinx/coroutines/ChildHandleNode;Ljava/lang/Object;)Z", "Lkotlinx/coroutines/internal/LockFreeLinkedListNode;", "nextChild", "(Lkotlinx/coroutines/internal/LockFreeLinkedListNode;)Lkotlinx/coroutines/ChildHandleNode;", "notifyCompletion", "toCancellationException", "(Ljava/lang/Throwable;Ljava/lang/String;)Ljava/util/concurrent/CancellationException;", "Lkotlin/sequences/Sequence;", "getChildren", "()Lkotlin/sequences/Sequence;", "children", "getCompletionCause", "completionCause", "getCompletionCauseHandled", "completionCauseHandled", "getHandlesException$kotlinx_coroutines_core", "handlesException", "isActive", "isCancelled", "isCompleted", "isCompletedExceptionally", "isScopedCoroutine", "Lkotlin/coroutines/CoroutineContext$Key;", "getKey", "()Lkotlin/coroutines/CoroutineContext$Key;", "key", "getOnCancelComplete$kotlinx_coroutines_core", "onCancelComplete", "Lkotlinx/coroutines/selects/SelectClause0;", "getOnJoin", "()Lkotlinx/coroutines/selects/SelectClause0;", "onJoin", "value", "getParentHandle$kotlinx_coroutines_core", "()Lkotlinx/coroutines/ChildHandle;", "setParentHandle$kotlinx_coroutines_core", "(Lkotlinx/coroutines/ChildHandle;)V", "parentHandle", "getState$kotlinx_coroutines_core", "getExceptionOrNull", "exceptionOrNull", "isCancelling", "(Lkotlinx/coroutines/Incomplete;)Z", "AwaitContinuation", "ChildCompletion", "Finishing", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
public class JobSupport implements Job, ChildJob, ParentJob {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f9436f = AtomicReferenceFieldUpdater.newUpdater(JobSupport.class, Object.class, "_state");
    private volatile /* synthetic */ Object _parentHandle;
    private volatile /* synthetic */ Object _state;

    /* JADX INFO: renamed from: s.a.i1$a */
    @Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\b\u0002\u0018\u00002\u00020\u0001B'\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\b\u0010\b\u001a\u0004\u0018\u00010\t¢\u0006\u0002\u0010\nJ\u0013\u0010\u000b\u001a\u00020\f2\b\u0010\r\u001a\u0004\u0018\u00010\u000eH\u0096\u0002R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000f"}, d2 = {"Lkotlinx/coroutines/JobSupport$ChildCompletion;", "Lkotlinx/coroutines/JobNode;", "parent", "Lkotlinx/coroutines/JobSupport;", "state", "Lkotlinx/coroutines/JobSupport$Finishing;", "child", "Lkotlinx/coroutines/ChildHandleNode;", "proposedUpdate", "", "(Lkotlinx/coroutines/JobSupport;Lkotlinx/coroutines/JobSupport$Finishing;Lkotlinx/coroutines/ChildHandleNode;Ljava/lang/Object;)V", "invoke", "", "cause", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class a extends JobNode {

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public final JobSupport f9437p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public final b f9438q;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        public final ChildHandleNode f9439r;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        public final Object f9440s;

        public a(JobSupport jobSupport, b bVar, ChildHandleNode childHandleNode, Object obj) {
            this.f9437p = jobSupport;
            this.f9438q = bVar;
            this.f9439r = childHandleNode;
            this.f9440s = obj;
        }

        @Override // kotlin.jvm.functions.Function1
        public /* bridge */ /* synthetic */ Unit invoke(Throwable th) {
            m(th);
            return Unit.a;
        }

        @Override // s.coroutines.CompletionHandlerBase
        public void m(Throwable th) {
            JobSupport jobSupport = this.f9437p;
            b bVar = this.f9438q;
            ChildHandleNode childHandleNode = this.f9439r;
            Object obj = this.f9440s;
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = JobSupport.f9436f;
            ChildHandleNode childHandleNodeK = jobSupport.K(childHandleNode);
            if (childHandleNodeK == null || !jobSupport.S(bVar, childHandleNodeK, obj)) {
                jobSupport.k(jobSupport.w(bVar, obj));
            }
        }
    }

    /* JADX INFO: renamed from: s.a.i1$b */
    @Metadata(d1 = {"\u0000L\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u0000\n\u0002\b\u0013\n\u0002\u0018\u0002\n\u0002\u0018\u0002\b\u0002\u0018\u00002\u00060\u0018j\u0002`,2\u00020-B!\u0012\u0006\u0010\u0002\u001a\u00020\u0001\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\b\u0010\u0006\u001a\u0004\u0018\u00010\u0005¢\u0006\u0004\b\u0007\u0010\bJ\u0015\u0010\u000b\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\u0005¢\u0006\u0004\b\u000b\u0010\fJ\u001f\u0010\u000f\u001a\u0012\u0012\u0004\u0012\u00020\u00050\rj\b\u0012\u0004\u0012\u00020\u0005`\u000eH\u0002¢\u0006\u0004\b\u000f\u0010\u0010J\u001d\u0010\u0013\u001a\b\u0012\u0004\u0012\u00020\u00050\u00122\b\u0010\u0011\u001a\u0004\u0018\u00010\u0005¢\u0006\u0004\b\u0013\u0010\u0014J\u000f\u0010\u0016\u001a\u00020\u0015H\u0016¢\u0006\u0004\b\u0016\u0010\u0017R(\u0010\u001e\u001a\u0004\u0018\u00010\u00182\b\u0010\u0019\u001a\u0004\u0018\u00010\u00188B@BX\u0082\u000e¢\u0006\f\u001a\u0004\b\u001a\u0010\u001b\"\u0004\b\u001c\u0010\u001dR\u0014\u0010\u001f\u001a\u00020\u00038VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u001f\u0010 R\u0011\u0010!\u001a\u00020\u00038F¢\u0006\u0006\u001a\u0004\b!\u0010 R$\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0019\u001a\u00020\u00038F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b\u0004\u0010 \"\u0004\b\"\u0010#R\u0011\u0010$\u001a\u00020\u00038F¢\u0006\u0006\u001a\u0004\b$\u0010 R\u001a\u0010\u0002\u001a\u00020\u00018\u0016X\u0096\u0004¢\u0006\f\n\u0004\b\u0002\u0010%\u001a\u0004\b&\u0010'R(\u0010\u0006\u001a\u0004\u0018\u00010\u00052\b\u0010\u0019\u001a\u0004\u0018\u00010\u00058F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b(\u0010)\"\u0004\b*\u0010\f¨\u0006+"}, d2 = {"Lkotlinx/coroutines/JobSupport$Finishing;", "Lkotlinx/coroutines/NodeList;", "list", "", "isCompleting", "", "rootCause", "<init>", "(Lkotlinx/coroutines/NodeList;ZLjava/lang/Throwable;)V", "exception", "", "addExceptionLocked", "(Ljava/lang/Throwable;)V", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "allocateList", "()Ljava/util/ArrayList;", "proposedException", "", "sealLocked", "(Ljava/lang/Throwable;)Ljava/util/List;", "", "toString", "()Ljava/lang/String;", "", "value", "getExceptionsHolder", "()Ljava/lang/Object;", "setExceptionsHolder", "(Ljava/lang/Object;)V", "exceptionsHolder", "isActive", "()Z", "isCancelling", "setCompleting", "(Z)V", "isSealed", "Lkotlinx/coroutines/NodeList;", "getList", "()Lkotlinx/coroutines/NodeList;", "getRootCause", "()Ljava/lang/Throwable;", "setRootCause", "kotlinx-coroutines-core", "Lkotlinx/coroutines/internal/SynchronizedObject;", "Lkotlinx/coroutines/Incomplete;"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class b implements Incomplete {
        private volatile /* synthetic */ Object _exceptionsHolder = null;
        private volatile /* synthetic */ int _isCompleting;
        private volatile /* synthetic */ Object _rootCause;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final NodeList f9441f;

        public b(NodeList nodeList, boolean z2, Throwable th) {
            this.f9441f = nodeList;
            this._isCompleting = z2 ? 1 : 0;
            this._rootCause = th;
        }

        @Override // s.coroutines.Incomplete
        /* JADX INFO: renamed from: a, reason: from getter */
        public NodeList getF9491f() {
            return this.f9441f;
        }

        /* JADX WARN: Multi-variable type inference failed */
        public final void b(Throwable th) {
            Throwable th2 = (Throwable) this._rootCause;
            if (th2 == null) {
                this._rootCause = th;
                return;
            }
            if (th == th2) {
                return;
            }
            Object obj = this._exceptionsHolder;
            if (obj == null) {
                this._exceptionsHolder = th;
                return;
            }
            if (obj instanceof Throwable) {
                if (th == obj) {
                    return;
                }
                ArrayList<Throwable> arrayListC = c();
                arrayListC.add(obj);
                arrayListC.add(th);
                this._exceptionsHolder = arrayListC;
                return;
            }
            if (obj instanceof ArrayList) {
                ((ArrayList) obj).add(th);
                return;
            }
            throw new IllegalStateException(("State is " + obj).toString());
        }

        public final ArrayList<Throwable> c() {
            return new ArrayList<>(4);
        }

        public final Throwable d() {
            return (Throwable) this._rootCause;
        }

        public final boolean e() {
            return ((Throwable) this._rootCause) != null;
        }

        /* JADX WARN: Type inference failed for: r0v0, types: [boolean, int] */
        public final boolean f() {
            return this._isCompleting;
        }

        public final boolean g() {
            return this._exceptionsHolder == j1.f9449e;
        }

        public final List<Throwable> h(Throwable th) {
            ArrayList arrayListC;
            Object obj = this._exceptionsHolder;
            if (obj == null) {
                arrayListC = c();
            } else if (obj instanceof Throwable) {
                ArrayList arrayListC2 = c();
                arrayListC2.add(obj);
                arrayListC = arrayListC2;
            } else {
                if (!(obj instanceof ArrayList)) {
                    throw new IllegalStateException(("State is " + obj).toString());
                }
                arrayListC = (ArrayList) obj;
            }
            Throwable th2 = (Throwable) this._rootCause;
            if (th2 != null) {
                arrayListC.add(0, th2);
            }
            if (th != null && !o.a(th, th2)) {
                arrayListC.add(th);
            }
            this._exceptionsHolder = j1.f9449e;
            return arrayListC;
        }

        public final void i(boolean z2) {
            this._isCompleting = z2 ? 1 : 0;
        }

        @Override // s.coroutines.Incomplete
        /* JADX INFO: renamed from: isActive */
        public boolean getF9465f() {
            return ((Throwable) this._rootCause) == null;
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r1v2, types: [boolean, int] */
        public String toString() {
            StringBuilder sbF = g.a.a.a.a.F("Finishing[cancelling=");
            sbF.append(e());
            sbF.append(", completing=");
            sbF.append((boolean) this._isCompleting);
            sbF.append(", rootCause=");
            sbF.append((Throwable) this._rootCause);
            sbF.append(", exceptions=");
            sbF.append(this._exceptionsHolder);
            sbF.append(", list=");
            sbF.append(this.f9441f);
            sbF.append(AbstractJsonLexerKt.END_LIST);
            return sbF.toString();
        }
    }

    /* JADX INFO: renamed from: s.a.i1$c */
    @Metadata(d1 = {"\u0000\u001b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0016\u0010\u0002\u001a\u0004\u0018\u00010\u00032\n\u0010\u0004\u001a\u00060\u0005j\u0002`\u0006H\u0016¨\u0006\u0007¸\u0006\u0000"}, d2 = {"kotlinx/coroutines/internal/LockFreeLinkedListNode$makeCondAddOp$1", "Lkotlinx/coroutines/internal/LockFreeLinkedListNode$CondAddOp;", "prepare", "", "affected", "Lkotlinx/coroutines/internal/LockFreeLinkedListNode;", "Lkotlinx/coroutines/internal/Node;", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class c extends LockFreeLinkedListNode.a {

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public final /* synthetic */ JobSupport f9442d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public final /* synthetic */ Object f9443e;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public c(LockFreeLinkedListNode lockFreeLinkedListNode, JobSupport jobSupport, Object obj) {
            super(lockFreeLinkedListNode);
            this.f9442d = jobSupport;
            this.f9443e = obj;
        }

        @Override // s.coroutines.internal.AtomicOp
        public Object c(LockFreeLinkedListNode lockFreeLinkedListNode) {
            if (this.f9442d.D() == this.f9443e) {
                return null;
            }
            return i.a;
        }
    }

    public JobSupport(boolean z2) {
        this._state = z2 ? j1.f9451g : j1.f9450f;
        this._parentHandle = null;
    }

    public boolean A() {
        return false;
    }

    public final NodeList B(Incomplete incomplete) {
        NodeList f9441f = incomplete.getF9491f();
        if (f9441f != null) {
            return f9441f;
        }
        if (incomplete instanceof Empty) {
            return new NodeList();
        }
        if (incomplete instanceof JobNode) {
            O((JobNode) incomplete);
            return null;
        }
        throw new IllegalStateException(("State should have list: " + incomplete).toString());
    }

    public final ChildHandle C() {
        return (ChildHandle) this._parentHandle;
    }

    public final Object D() {
        while (true) {
            Object obj = this._state;
            if (!(obj instanceof OpDescriptor)) {
                return obj;
            }
            ((OpDescriptor) obj).a(this);
        }
    }

    public boolean E(Throwable th) {
        return false;
    }

    public void F(Throwable th) throws Throwable {
        throw th;
    }

    public final void G(Job job) {
        if (job == null) {
            this._parentHandle = NonDisposableHandle.f9458f;
            return;
        }
        job.start();
        ChildHandle childHandleX = job.x(this);
        this._parentHandle = childHandleX;
        if (isCompleted()) {
            childHandleX.b();
            this._parentHandle = NonDisposableHandle.f9458f;
        }
    }

    public boolean H() {
        return this instanceof BlockingCoroutine;
    }

    public final Object I(Object obj) throws Throwable {
        Object objR;
        do {
            objR = R(D(), obj);
            if (objR == j1.a) {
                String str = "Job " + this + " is already complete or completing, but is being completed with " + obj;
                CompletedExceptionally completedExceptionally = obj instanceof CompletedExceptionally ? (CompletedExceptionally) obj : null;
                throw new IllegalStateException(str, completedExceptionally != null ? completedExceptionally.f9464b : null);
            }
        } while (objR == j1.f9447c);
        return objR;
    }

    public String J() {
        return getClass().getSimpleName();
    }

    public final ChildHandleNode K(LockFreeLinkedListNode lockFreeLinkedListNode) {
        while (lockFreeLinkedListNode.k()) {
            lockFreeLinkedListNode = lockFreeLinkedListNode.j();
        }
        while (true) {
            lockFreeLinkedListNode = lockFreeLinkedListNode.i();
            if (!lockFreeLinkedListNode.k()) {
                if (lockFreeLinkedListNode instanceof ChildHandleNode) {
                    return (ChildHandleNode) lockFreeLinkedListNode;
                }
                if (lockFreeLinkedListNode instanceof NodeList) {
                    return null;
                }
            }
        }
    }

    public final void L(NodeList nodeList, Throwable th) throws Throwable {
        CompletionHandlerException completionHandlerException = null;
        for (LockFreeLinkedListNode lockFreeLinkedListNodeI = (LockFreeLinkedListNode) nodeList.e(); !o.a(lockFreeLinkedListNodeI, nodeList); lockFreeLinkedListNodeI = lockFreeLinkedListNodeI.i()) {
            if (lockFreeLinkedListNodeI instanceof JobCancellingNode) {
                JobNode jobNode = (JobNode) lockFreeLinkedListNodeI;
                try {
                    jobNode.m(th);
                } catch (Throwable th2) {
                    if (completionHandlerException != null) {
                        g.h.a.i.p(completionHandlerException, th2);
                    } else {
                        completionHandlerException = new CompletionHandlerException("Exception in completion handler " + jobNode + " for " + this, th2);
                    }
                }
            }
        }
        if (completionHandlerException != null) {
            F(completionHandlerException);
        }
        n(th);
    }

    public void M(Object obj) {
    }

    public void N() {
    }

    public final void O(JobNode jobNode) {
        NodeList nodeList = new NodeList();
        LockFreeLinkedListNode.f9344m.lazySet(nodeList, jobNode);
        LockFreeLinkedListNode.f9343f.lazySet(nodeList, jobNode);
        while (true) {
            if (jobNode.e() != jobNode) {
                break;
            } else if (LockFreeLinkedListNode.f9343f.compareAndSet(jobNode, jobNode, nodeList)) {
                nodeList.d(jobNode);
                break;
            }
        }
        f9436f.compareAndSet(this, jobNode, jobNode.i());
    }

    public final String P(Object obj) {
        if (!(obj instanceof b)) {
            return obj instanceof Incomplete ? ((Incomplete) obj).getF9465f() ? "Active" : "New" : obj instanceof CompletedExceptionally ? "Cancelled" : "Completed";
        }
        b bVar = (b) obj;
        return bVar.e() ? "Cancelling" : bVar.f() ? "Completing" : "Active";
    }

    public final CancellationException Q(Throwable th, String str) {
        CancellationException jobCancellationException = th instanceof CancellationException ? (CancellationException) th : null;
        if (jobCancellationException == null) {
            if (str == null) {
                str = p();
            }
            jobCancellationException = new JobCancellationException(str, th, this);
        }
        return jobCancellationException;
    }

    public final Object R(Object obj, Object obj2) throws Throwable {
        Symbol symbol;
        if (!(obj instanceof Incomplete)) {
            return j1.a;
        }
        boolean z2 = true;
        if (((obj instanceof Empty) || (obj instanceof JobNode)) && !(obj instanceof ChildHandleNode) && !(obj2 instanceof CompletedExceptionally)) {
            Incomplete incomplete = (Incomplete) obj;
            if (f9436f.compareAndSet(this, incomplete, obj2 instanceof Incomplete ? new IncompleteStateBox((Incomplete) obj2) : obj2)) {
                M(obj2);
                t(incomplete, obj2);
            } else {
                z2 = false;
            }
            return z2 ? obj2 : j1.f9447c;
        }
        Incomplete incomplete2 = (Incomplete) obj;
        NodeList nodeListB = B(incomplete2);
        if (nodeListB == null) {
            return j1.f9447c;
        }
        ChildHandleNode childHandleNodeK = null;
        b bVar = incomplete2 instanceof b ? (b) incomplete2 : null;
        if (bVar == null) {
            bVar = new b(nodeListB, false, null);
        }
        synchronized (bVar) {
            if (bVar.f()) {
                symbol = j1.a;
            } else {
                bVar.i(true);
                if (bVar == incomplete2 || f9436f.compareAndSet(this, incomplete2, bVar)) {
                    boolean zE = bVar.e();
                    CompletedExceptionally completedExceptionally = obj2 instanceof CompletedExceptionally ? (CompletedExceptionally) obj2 : null;
                    if (completedExceptionally != null) {
                        bVar.b(completedExceptionally.f9464b);
                    }
                    Throwable thD = bVar.d();
                    if (!Boolean.valueOf(true ^ zE).booleanValue()) {
                        thD = null;
                    }
                    if (thD != null) {
                        L(nodeListB, thD);
                    }
                    ChildHandleNode childHandleNode = incomplete2 instanceof ChildHandleNode ? (ChildHandleNode) incomplete2 : null;
                    if (childHandleNode == null) {
                        NodeList f9441f = incomplete2.getF9491f();
                        if (f9441f != null) {
                            childHandleNodeK = K(f9441f);
                        }
                    } else {
                        childHandleNodeK = childHandleNode;
                    }
                    return (childHandleNodeK == null || !S(bVar, childHandleNodeK, obj2)) ? w(bVar, obj2) : j1.f9446b;
                }
                symbol = j1.f9447c;
            }
            return symbol;
        }
    }

    public final boolean S(b bVar, ChildHandleNode childHandleNode, Object obj) {
        while (kotlin.reflect.w.internal.y0.n.c2.c.X(childHandleNode.f9456p, false, false, new a(this, bVar, childHandleNode, obj), 1, null) == NonDisposableHandle.f9458f) {
            childHandleNode = K(childHandleNode);
            if (childHandleNode == null) {
                return false;
            }
        }
        return true;
    }

    @Override // kotlin.coroutines.CoroutineContext
    public <R> R fold(R r2, Function2<? super R, ? super CoroutineContext.a, ? extends R> function2) {
        return (R) CoroutineContext.a.C0101a.a(this, r2, function2);
    }

    /* JADX WARN: Removed duplicated region for block: B:64:0x00a7  */
    /* JADX WARN: Removed duplicated region for block: B:90:0x00a1 A[SYNTHETIC] */
    @Override // s.coroutines.Job
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final s.coroutines.DisposableHandle g(boolean r8, boolean r9, kotlin.jvm.functions.Function1<? super java.lang.Throwable, kotlin.Unit> r10) {
        /*
            r7 = this;
            r0 = 0
            if (r8 == 0) goto L14
            boolean r1 = r10 instanceof s.coroutines.JobCancellingNode
            if (r1 == 0) goto Lb
            r1 = r10
            s.a.f1 r1 = (s.coroutines.JobCancellingNode) r1
            goto Lc
        Lb:
            r1 = r0
        Lc:
            if (r1 != 0) goto L25
            s.a.b1 r1 = new s.a.b1
            r1.<init>(r10)
            goto L25
        L14:
            boolean r1 = r10 instanceof s.coroutines.JobNode
            if (r1 == 0) goto L1c
            r1 = r10
            s.a.h1 r1 = (s.coroutines.JobNode) r1
            goto L1d
        L1c:
            r1 = r0
        L1d:
            if (r1 == 0) goto L20
            goto L25
        L20:
            s.a.c1 r1 = new s.a.c1
            r1.<init>(r10)
        L25:
            r1.f9429o = r7
        L27:
            java.lang.Object r2 = r7.D()
            boolean r3 = r2 instanceof s.coroutines.Empty
            if (r3 == 0) goto L55
            r3 = r2
            s.a.p0 r3 = (s.coroutines.Empty) r3
            boolean r4 = r3.f9465f
            if (r4 == 0) goto L3f
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r3 = s.coroutines.JobSupport.f9436f
            boolean r2 = r3.compareAndSet(r7, r2, r1)
            if (r2 == 0) goto L27
            return r1
        L3f:
            s.a.m1 r2 = new s.a.m1
            r2.<init>()
            boolean r4 = r3.f9465f
            if (r4 == 0) goto L49
            goto L4f
        L49:
            s.a.x0 r4 = new s.a.x0
            r4.<init>(r2)
            r2 = r4
        L4f:
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r4 = s.coroutines.JobSupport.f9436f
            r4.compareAndSet(r7, r3, r2)
            goto L27
        L55:
            boolean r3 = r2 instanceof s.coroutines.Incomplete
            if (r3 == 0) goto Lae
            r3 = r2
            s.a.y0 r3 = (s.coroutines.Incomplete) r3
            s.a.m1 r3 = r3.getF9491f()
            if (r3 != 0) goto L6d
            java.lang.String r3 = "null cannot be cast to non-null type kotlinx.coroutines.JobNode"
            java.util.Objects.requireNonNull(r2, r3)
            s.a.h1 r2 = (s.coroutines.JobNode) r2
            r7.O(r2)
            goto L27
        L6d:
            s.a.n1 r4 = s.coroutines.NonDisposableHandle.f9458f
            if (r8 == 0) goto L9e
            boolean r5 = r2 instanceof s.coroutines.JobSupport.b
            if (r5 == 0) goto L9e
            monitor-enter(r2)
            r5 = r2
            s.a.i1$b r5 = (s.coroutines.JobSupport.b) r5     // Catch: java.lang.Throwable -> L9b
            java.lang.Throwable r5 = r5.d()     // Catch: java.lang.Throwable -> L9b
            if (r5 == 0) goto L8c
            boolean r6 = r10 instanceof s.coroutines.ChildHandleNode     // Catch: java.lang.Throwable -> L9b
            if (r6 == 0) goto L99
            r6 = r2
            s.a.i1$b r6 = (s.coroutines.JobSupport.b) r6     // Catch: java.lang.Throwable -> L9b
            boolean r6 = r6.f()     // Catch: java.lang.Throwable -> L9b
            if (r6 != 0) goto L99
        L8c:
            boolean r4 = r7.i(r2, r3, r1)     // Catch: java.lang.Throwable -> L9b
            if (r4 != 0) goto L94
            monitor-exit(r2)
            goto L27
        L94:
            if (r5 != 0) goto L98
            monitor-exit(r2)
            return r1
        L98:
            r4 = r1
        L99:
            monitor-exit(r2)
            goto L9f
        L9b:
            r8 = move-exception
            monitor-exit(r2)
            throw r8
        L9e:
            r5 = r0
        L9f:
            if (r5 == 0) goto La7
            if (r9 == 0) goto La6
            r10.invoke(r5)
        La6:
            return r4
        La7:
            boolean r2 = r7.i(r2, r3, r1)
            if (r2 == 0) goto L27
            return r1
        Lae:
            if (r9 == 0) goto Lbf
            boolean r8 = r2 instanceof s.coroutines.CompletedExceptionally
            if (r8 == 0) goto Lb7
            s.a.p r2 = (s.coroutines.CompletedExceptionally) r2
            goto Lb8
        Lb7:
            r2 = r0
        Lb8:
            if (r2 == 0) goto Lbc
            java.lang.Throwable r0 = r2.f9464b
        Lbc:
            r10.invoke(r0)
        Lbf:
            s.a.n1 r8 = s.coroutines.NonDisposableHandle.f9458f
            return r8
        */
        throw new UnsupportedOperationException("Method not decompiled: s.coroutines.JobSupport.g(boolean, boolean, kotlin.jvm.functions.Function1):s.a.m0");
    }

    @Override // kotlin.coroutines.CoroutineContext.a, kotlin.coroutines.CoroutineContext
    public <E extends CoroutineContext.a> E get(CoroutineContext.b<E> bVar) {
        return (E) CoroutineContext.a.C0101a.b(this, bVar);
    }

    @Override // kotlin.coroutines.CoroutineContext.a
    public final CoroutineContext.b<?> getKey() {
        return Job.a.f9423f;
    }

    @Override // s.coroutines.Job
    public final CancellationException h() {
        Object objD = D();
        if (objD instanceof b) {
            Throwable thD = ((b) objD).d();
            if (thD != null) {
                return Q(thD, getClass().getSimpleName() + " is cancelling");
            }
            throw new IllegalStateException(("Job is still new or active: " + this).toString());
        }
        if (objD instanceof Incomplete) {
            throw new IllegalStateException(("Job is still new or active: " + this).toString());
        }
        if (objD instanceof CompletedExceptionally) {
            return Q(((CompletedExceptionally) objD).f9464b, null);
        }
        return new JobCancellationException(getClass().getSimpleName() + " has completed normally", null, this);
    }

    public final boolean i(Object obj, NodeList nodeList, JobNode jobNode) {
        char c2;
        c cVar = new c(jobNode, this, obj);
        do {
            LockFreeLinkedListNode lockFreeLinkedListNodeJ = nodeList.j();
            LockFreeLinkedListNode.f9344m.lazySet(jobNode, lockFreeLinkedListNodeJ);
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = LockFreeLinkedListNode.f9343f;
            atomicReferenceFieldUpdater.lazySet(jobNode, nodeList);
            cVar.f9347c = nodeList;
            c2 = !atomicReferenceFieldUpdater.compareAndSet(lockFreeLinkedListNodeJ, nodeList, cVar) ? (char) 0 : cVar.a(lockFreeLinkedListNodeJ) == null ? (char) 1 : (char) 2;
            if (c2 == 1) {
                return true;
            }
        } while (c2 != 2);
        return false;
    }

    @Override // s.coroutines.Job
    public boolean isActive() {
        Object objD = D();
        return (objD instanceof Incomplete) && ((Incomplete) objD).getF9465f();
    }

    @Override // s.coroutines.Job
    public final boolean isCompleted() {
        return !(D() instanceof Incomplete);
    }

    @Override // s.coroutines.ChildJob
    public final void j(ParentJob parentJob) throws Throwable {
        l(parentJob);
    }

    public void k(Object obj) {
    }

    /* JADX WARN: Code restructure failed: missing block: B:59:0x00b7, code lost:
    
        r10 = s.coroutines.j1.a;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x00ea, code lost:
    
        r0 = r10;
     */
    /* JADX WARN: Removed duplicated region for block: B:56:0x00af  */
    /* JADX WARN: Removed duplicated region for block: B:88:0x00b7 A[EDGE_INSN: B:88:0x00b7->B:59:0x00b7 BREAK  A[LOOP:1: B:21:0x0040->B:92:0x0040], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:94:0x0040 A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean l(java.lang.Object r10) throws java.lang.Throwable {
        /*
            Method dump skipped, instruction units count: 256
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: s.coroutines.JobSupport.l(java.lang.Object):boolean");
    }

    @Override // kotlin.coroutines.CoroutineContext
    public CoroutineContext minusKey(CoroutineContext.b<?> bVar) {
        return CoroutineContext.a.C0101a.c(this, bVar);
    }

    public final boolean n(Throwable th) {
        if (H()) {
            return true;
        }
        boolean z2 = th instanceof CancellationException;
        ChildHandle childHandle = (ChildHandle) this._parentHandle;
        return (childHandle == null || childHandle == NonDisposableHandle.f9458f) ? z2 : childHandle.h(th) || z2;
    }

    public String p() {
        return "Job was cancelled";
    }

    @Override // kotlin.coroutines.CoroutineContext
    public CoroutineContext plus(CoroutineContext coroutineContext) {
        return CoroutineContext.a.C0101a.d(this, coroutineContext);
    }

    @Override // s.coroutines.ParentJob
    public CancellationException q() {
        Throwable thD;
        Object objD = D();
        if (objD instanceof b) {
            thD = ((b) objD).d();
        } else if (objD instanceof CompletedExceptionally) {
            thD = ((CompletedExceptionally) objD).f9464b;
        } else {
            if (objD instanceof Incomplete) {
                throw new IllegalStateException(("Cannot be cancelling child in this state: " + objD).toString());
            }
            thD = null;
        }
        CancellationException cancellationException = thD instanceof CancellationException ? (CancellationException) thD : null;
        if (cancellationException != null) {
            return cancellationException;
        }
        StringBuilder sbF = g.a.a.a.a.F("Parent job is ");
        sbF.append(P(objD));
        return new JobCancellationException(sbF.toString(), thD, this);
    }

    public boolean r(Throwable th) {
        if (th instanceof CancellationException) {
            return true;
        }
        return l(th) && getF9428m();
    }

    @Override // s.coroutines.Job
    public void s(CancellationException cancellationException) throws Throwable {
        if (cancellationException == null) {
            cancellationException = new JobCancellationException(p(), null, this);
        }
        l(cancellationException);
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0030  */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0035  */
    @Override // s.coroutines.Job
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean start() {
        /*
            r6 = this;
        L0:
            java.lang.Object r0 = r6.D()
            boolean r1 = r0 instanceof s.coroutines.Empty
            r2 = -1
            r3 = 0
            r4 = 1
            if (r1 == 0) goto L1e
            r1 = r0
            s.a.p0 r1 = (s.coroutines.Empty) r1
            boolean r1 = r1.f9465f
            if (r1 == 0) goto L13
            goto L35
        L13:
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r1 = s.coroutines.JobSupport.f9436f
            s.a.p0 r5 = s.coroutines.j1.f9451g
            boolean r0 = r1.compareAndSet(r6, r0, r5)
            if (r0 != 0) goto L30
            goto L36
        L1e:
            boolean r1 = r0 instanceof s.coroutines.InactiveNodeList
            if (r1 == 0) goto L35
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r1 = s.coroutines.JobSupport.f9436f
            r5 = r0
            s.a.x0 r5 = (s.coroutines.InactiveNodeList) r5
            s.a.m1 r5 = r5.f9491f
            boolean r0 = r1.compareAndSet(r6, r0, r5)
            if (r0 != 0) goto L30
            goto L36
        L30:
            r6.N()
            r2 = r4
            goto L36
        L35:
            r2 = r3
        L36:
            if (r2 == 0) goto L3c
            if (r2 == r4) goto L3b
            goto L0
        L3b:
            return r4
        L3c:
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: s.coroutines.JobSupport.start():boolean");
    }

    public final void t(Incomplete incomplete, Object obj) throws Throwable {
        ChildHandle childHandle = (ChildHandle) this._parentHandle;
        if (childHandle != null) {
            childHandle.b();
            this._parentHandle = NonDisposableHandle.f9458f;
        }
        CompletionHandlerException completionHandlerException = null;
        CompletedExceptionally completedExceptionally = obj instanceof CompletedExceptionally ? (CompletedExceptionally) obj : null;
        Throwable th = completedExceptionally != null ? completedExceptionally.f9464b : null;
        if (incomplete instanceof JobNode) {
            try {
                ((JobNode) incomplete).m(th);
                return;
            } catch (Throwable th2) {
                F(new CompletionHandlerException("Exception in completion handler " + incomplete + " for " + this, th2));
                return;
            }
        }
        NodeList f9441f = incomplete.getF9491f();
        if (f9441f != null) {
            for (LockFreeLinkedListNode lockFreeLinkedListNodeI = (LockFreeLinkedListNode) f9441f.e(); !o.a(lockFreeLinkedListNodeI, f9441f); lockFreeLinkedListNodeI = lockFreeLinkedListNodeI.i()) {
                if (lockFreeLinkedListNodeI instanceof JobNode) {
                    JobNode jobNode = (JobNode) lockFreeLinkedListNodeI;
                    try {
                        jobNode.m(th);
                    } catch (Throwable th3) {
                        if (completionHandlerException != null) {
                            g.h.a.i.p(completionHandlerException, th3);
                        } else {
                            completionHandlerException = new CompletionHandlerException("Exception in completion handler " + jobNode + " for " + this, th3);
                        }
                    }
                }
            }
            if (completionHandlerException != null) {
                F(completionHandlerException);
            }
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(J() + AbstractJsonLexerKt.BEGIN_OBJ + P(D()) + AbstractJsonLexerKt.END_OBJ);
        sb.append('@');
        sb.append(e0.b(this));
        return sb.toString();
    }

    public final Throwable v(Object obj) {
        if (obj == null ? true : obj instanceof Throwable) {
            Throwable th = (Throwable) obj;
            return th == null ? new JobCancellationException(p(), null, this) : th;
        }
        Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.ParentJob");
        return ((ParentJob) obj).q();
    }

    public final Object w(b bVar, Object obj) throws Throwable {
        Throwable thY;
        CompletedExceptionally completedExceptionally = obj instanceof CompletedExceptionally ? (CompletedExceptionally) obj : null;
        Throwable th = completedExceptionally != null ? completedExceptionally.f9464b : null;
        synchronized (bVar) {
            bVar.e();
            List<Throwable> listH = bVar.h(th);
            thY = y(bVar, listH);
            if (thY != null && listH.size() > 1) {
                Set setNewSetFromMap = Collections.newSetFromMap(new IdentityHashMap(listH.size()));
                for (Throwable th2 : listH) {
                    if (th2 != thY && th2 != thY && !(th2 instanceof CancellationException) && setNewSetFromMap.add(th2)) {
                        g.h.a.i.p(thY, th2);
                    }
                }
            }
        }
        if (thY != null && thY != th) {
            obj = new CompletedExceptionally(thY, false, 2);
        }
        if (thY != null) {
            if (n(thY) || E(thY)) {
                Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.CompletedExceptionally");
                CompletedExceptionally.a.compareAndSet((CompletedExceptionally) obj, 0, 1);
            }
        }
        M(obj);
        f9436f.compareAndSet(this, bVar, obj instanceof Incomplete ? new IncompleteStateBox((Incomplete) obj) : obj);
        t(bVar, obj);
        return obj;
    }

    @Override // s.coroutines.Job
    public final ChildHandle x(ChildJob childJob) {
        return (ChildHandle) kotlin.reflect.w.internal.y0.n.c2.c.X(this, true, false, new ChildHandleNode(childJob), 2, null);
    }

    public final Throwable y(b bVar, List<? extends Throwable> list) {
        Object next;
        Object obj = null;
        if (list.isEmpty()) {
            if (bVar.e()) {
                return new JobCancellationException(p(), null, this);
            }
            return null;
        }
        Iterator<T> it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            if (!(((Throwable) next) instanceof CancellationException)) {
                break;
            }
        }
        Throwable th = (Throwable) next;
        if (th != null) {
            return th;
        }
        Throwable th2 = list.get(0);
        if (th2 instanceof TimeoutCancellationException) {
            Iterator<T> it2 = list.iterator();
            while (true) {
                if (!it2.hasNext()) {
                    break;
                }
                Object next2 = it2.next();
                Throwable th3 = (Throwable) next2;
                if (th3 != th2 && (th3 instanceof TimeoutCancellationException)) {
                    obj = next2;
                    break;
                }
            }
            Throwable th4 = (Throwable) obj;
            if (th4 != null) {
                return th4;
            }
        }
        return th2;
    }

    /* JADX INFO: renamed from: z */
    public boolean getF9428m() {
        return true;
    }
}
