package kotlin.coroutines;

import java.io.Serializable;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.o;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;

/* JADX INFO: renamed from: r.b0.c, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000L\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\u0000\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0001\u0018\u00002\u00020\u00012\u00060\u0002j\u0002`\u0003:\u0001!B\u0015\u0012\u0006\u0010\u0004\u001a\u00020\u0001\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u0010\u0010\b\u001a\u00020\t2\u0006\u0010\u0005\u001a\u00020\u0006H\u0002J\u0010\u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\u0000H\u0002J\u0013\u0010\f\u001a\u00020\t2\b\u0010\r\u001a\u0004\u0018\u00010\u000eH\u0096\u0002J5\u0010\u000f\u001a\u0002H\u0010\"\u0004\b\u0000\u0010\u00102\u0006\u0010\u0011\u001a\u0002H\u00102\u0018\u0010\u0012\u001a\u0014\u0012\u0004\u0012\u0002H\u0010\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u0002H\u00100\u0013H\u0016¢\u0006\u0002\u0010\u0014J(\u0010\u0015\u001a\u0004\u0018\u0001H\u0016\"\b\b\u0000\u0010\u0016*\u00020\u00062\f\u0010\u0017\u001a\b\u0012\u0004\u0012\u0002H\u00160\u0018H\u0096\u0002¢\u0006\u0002\u0010\u0019J\b\u0010\u001a\u001a\u00020\u001bH\u0016J\u0014\u0010\u001c\u001a\u00020\u00012\n\u0010\u0017\u001a\u0006\u0012\u0002\b\u00030\u0018H\u0016J\b\u0010\u001d\u001a\u00020\u001bH\u0002J\b\u0010\u001e\u001a\u00020\u001fH\u0016J\b\u0010 \u001a\u00020\u000eH\u0002R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\""}, d2 = {"Lkotlin/coroutines/CombinedContext;", "Lkotlin/coroutines/CoroutineContext;", "Ljava/io/Serializable;", "Lkotlin/io/Serializable;", "left", "element", "Lkotlin/coroutines/CoroutineContext$Element;", "(Lkotlin/coroutines/CoroutineContext;Lkotlin/coroutines/CoroutineContext$Element;)V", "contains", "", "containsAll", "context", "equals", "other", "", "fold", "R", "initial", "operation", "Lkotlin/Function2;", "(Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;", "get", "E", "key", "Lkotlin/coroutines/CoroutineContext$Key;", "(Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element;", "hashCode", "", "minusKey", "size", "toString", "", "writeReplace", "Serialized", "kotlin-stdlib"}, k = 1, mv = {1, 7, 1}, xi = 48)
public final class CombinedContext implements CoroutineContext, Serializable {

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

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final CoroutineContext.a f6134m;

    /* JADX INFO: renamed from: r.b0.c$a */
    @Metadata(d1 = {"\u0000\u0010\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00012\u0006\u0010\u0003\u001a\u00020\u0004H\n¢\u0006\u0002\b\u0005"}, d2 = {"<anonymous>", "", "acc", "element", "Lkotlin/coroutines/CoroutineContext$Element;", "invoke"}, k = 3, mv = {1, 7, 1}, xi = 48)
    public static final class a extends Lambda implements Function2<String, CoroutineContext.a, String> {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public static final a f6135f = new a();

        public a() {
            super(2);
        }

        @Override // kotlin.jvm.functions.Function2
        public String invoke(String str, CoroutineContext.a aVar) {
            String str2 = str;
            CoroutineContext.a aVar2 = aVar;
            o.f(str2, "acc");
            o.f(aVar2, "element");
            if (str2.length() == 0) {
                return aVar2.toString();
            }
            return str2 + ", " + aVar2;
        }
    }

    public CombinedContext(CoroutineContext coroutineContext, CoroutineContext.a aVar) {
        o.f(coroutineContext, "left");
        o.f(aVar, "element");
        this.f6133f = coroutineContext;
        this.f6134m = aVar;
    }

    public final int b() {
        int i2 = 2;
        CombinedContext combinedContext = this;
        while (true) {
            CoroutineContext coroutineContext = combinedContext.f6133f;
            combinedContext = coroutineContext instanceof CombinedContext ? (CombinedContext) coroutineContext : null;
            if (combinedContext == null) {
                return i2;
            }
            i2++;
        }
    }

    public boolean equals(Object other) {
        boolean zA;
        if (this != other) {
            if (!(other instanceof CombinedContext)) {
                return false;
            }
            CombinedContext combinedContext = (CombinedContext) other;
            if (combinedContext.b() != b()) {
                return false;
            }
            Objects.requireNonNull(combinedContext);
            CombinedContext combinedContext2 = this;
            while (true) {
                CoroutineContext.a aVar = combinedContext2.f6134m;
                if (!o.a(combinedContext.get(aVar.getKey()), aVar)) {
                    zA = false;
                    break;
                }
                CoroutineContext coroutineContext = combinedContext2.f6133f;
                if (!(coroutineContext instanceof CombinedContext)) {
                    o.d(coroutineContext, "null cannot be cast to non-null type kotlin.coroutines.CoroutineContext.Element");
                    CoroutineContext.a aVar2 = (CoroutineContext.a) coroutineContext;
                    zA = o.a(combinedContext.get(aVar2.getKey()), aVar2);
                    break;
                }
                combinedContext2 = (CombinedContext) coroutineContext;
            }
            if (!zA) {
                return false;
            }
        }
        return true;
    }

    @Override // kotlin.coroutines.CoroutineContext
    public <R> R fold(R initial, Function2<? super R, ? super CoroutineContext.a, ? extends R> operation) {
        o.f(operation, "operation");
        return operation.invoke((Object) this.f6133f.fold(initial, operation), this.f6134m);
    }

    @Override // kotlin.coroutines.CoroutineContext
    public <E extends CoroutineContext.a> E get(CoroutineContext.b<E> bVar) {
        o.f(bVar, "key");
        CombinedContext combinedContext = this;
        while (true) {
            E e2 = (E) combinedContext.f6134m.get(bVar);
            if (e2 != null) {
                return e2;
            }
            CoroutineContext coroutineContext = combinedContext.f6133f;
            if (!(coroutineContext instanceof CombinedContext)) {
                return (E) coroutineContext.get(bVar);
            }
            combinedContext = (CombinedContext) coroutineContext;
        }
    }

    public int hashCode() {
        return this.f6134m.hashCode() + this.f6133f.hashCode();
    }

    @Override // kotlin.coroutines.CoroutineContext
    public CoroutineContext minusKey(CoroutineContext.b<?> bVar) {
        o.f(bVar, "key");
        if (this.f6134m.get(bVar) != null) {
            return this.f6133f;
        }
        CoroutineContext coroutineContextMinusKey = this.f6133f.minusKey(bVar);
        return coroutineContextMinusKey == this.f6133f ? this : coroutineContextMinusKey == EmptyCoroutineContext.f6139f ? this.f6134m : new CombinedContext(coroutineContextMinusKey, this.f6134m);
    }

    @Override // kotlin.coroutines.CoroutineContext
    public CoroutineContext plus(CoroutineContext coroutineContext) {
        o.f(coroutineContext, "context");
        return coroutineContext == EmptyCoroutineContext.f6139f ? this : (CoroutineContext) coroutineContext.fold(this, g.f6138f);
    }

    public String toString() {
        return g.a.a.a.a.z(g.a.a.a.a.E(AbstractJsonLexerKt.BEGIN_LIST), (String) fold("", a.f6135f), AbstractJsonLexerKt.END_LIST);
    }
}
