package kotlinx.coroutines.flow.internal;

import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlinx.coroutines.channels.BufferOverflow;
import kotlinx.coroutines.internal.v;
import kotlinx.coroutines.y;

/* JADX INFO: loaded from: classes.dex */
public abstract class e extends d {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final kotlinx.coroutines.flow.f f29389d;

    public e(kotlinx.coroutines.flow.f fVar, kotlin.coroutines.h hVar, int i10, BufferOverflow bufferOverflow) {
        super(hVar, i10, bufferOverflow);
        this.f29389d = fVar;
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x005a  */
    @Override // kotlinx.coroutines.flow.internal.d, kotlinx.coroutines.flow.f
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object a(kotlinx.coroutines.flow.g gVar, Continuation continuation) throws Throwable {
        Object objA;
        kd.e eVar = kd.e.f29109a;
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        if (this.f29387b == -3) {
            kotlin.coroutines.h context = continuation.getContext();
            kotlin.coroutines.h hVarO = y.O(context, this.f29386a);
            if (nb.g.c(hVarO, context)) {
                objA = ((f) this).f29389d.a(gVar, continuation);
                if (objA != coroutineSingletons) {
                    objA = eVar;
                }
                if (objA != coroutineSingletons) {
                    return eVar;
                }
            } else {
                kotlin.coroutines.c cVar = kotlin.coroutines.c.f29225a;
                if (nb.g.c(hVarO.m(cVar), context.m(cVar))) {
                    kotlin.coroutines.h context2 = continuation.getContext();
                    if (!(gVar instanceof k)) {
                        gVar = new m(gVar, context2);
                    }
                    objA = y.i0(hVarO, gVar, v.b(hVarO), new ChannelFlowOperator$collectWithContextUndispatched$2(this, null), continuation);
                    if (objA != coroutineSingletons) {
                        return eVar;
                    }
                } else {
                    objA = super.a(gVar, continuation);
                    if (objA != coroutineSingletons) {
                        return eVar;
                    }
                }
            }
        }
        return objA;
    }

    @Override // kotlinx.coroutines.flow.internal.d
    public final Object c(kotlinx.coroutines.channels.l lVar, Continuation continuation) {
        Object objA = ((f) this).f29389d.a(new k(lVar), continuation);
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        kd.e eVar = kd.e.f29109a;
        if (objA != coroutineSingletons) {
            objA = eVar;
        }
        return objA == coroutineSingletons ? objA : eVar;
    }

    @Override // kotlinx.coroutines.flow.internal.d
    public final String toString() {
        return this.f29389d + " -> " + super.toString();
    }
}
