package o;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class M30 extends AbstractC0298Lm implements InterfaceC2294qz {

    /* renamed from: o, reason: collision with root package name */
    public final InterfaceC2294qz f224o;
    public final InterfaceC2747vn p;
    public final int q;
    public InterfaceC2747vn r;
    public InterfaceC0220Im s;

    public M30(InterfaceC2294qz interfaceC2294qz, InterfaceC2747vn interfaceC2747vn) {
        super(C1980nj.n, C0281Kv.l);
        this.f224o = interfaceC2294qz;
        this.p = interfaceC2747vn;
        this.q = ((Number) interfaceC2747vn.R(0, new X8(17))).intValue();
    }

    @Override // o.InterfaceC2294qz
    public final Object c(Object obj, InterfaceC0220Im interfaceC0220Im) {
        try {
            Object objP = p(interfaceC0220Im, obj);
            return objP == EnumC0091Dn.l ? objP : Oh0.a;
        } catch (Throwable th) {
            this.r = new C0122Es(th, interfaceC0220Im.h());
            throw th;
        }
    }

    @Override // o.AbstractC0728ad, o.InterfaceC0117En
    public final InterfaceC0117En e() {
        InterfaceC0220Im interfaceC0220Im = this.s;
        if (interfaceC0220Im instanceof InterfaceC0117En) {
            return (InterfaceC0117En) interfaceC0220Im;
        }
        return null;
    }

    @Override // o.AbstractC0298Lm, o.InterfaceC0220Im
    public final InterfaceC2747vn h() {
        InterfaceC2747vn interfaceC2747vn = this.r;
        return interfaceC2747vn == null ? C0281Kv.l : interfaceC2747vn;
    }

    @Override // o.AbstractC0728ad
    public final StackTraceElement m() {
        return null;
    }

    @Override // o.AbstractC0728ad
    public final Object n(Object obj) {
        Throwable thA = I20.a(obj);
        if (thA != null) {
            this.r = new C0122Es(thA, h());
        }
        InterfaceC0220Im interfaceC0220Im = this.s;
        if (interfaceC0220Im != null) {
            interfaceC0220Im.resumeWith(obj);
        }
        return EnumC0091Dn.l;
    }

    public final Object p(InterfaceC0220Im interfaceC0220Im, Object obj) {
        InterfaceC2747vn interfaceC2747vnH = interfaceC0220Im.h();
        AbstractC0752ap.F(interfaceC2747vnH);
        InterfaceC2747vn interfaceC2747vn = this.r;
        if (interfaceC2747vn != interfaceC2747vnH) {
            if (interfaceC2747vn instanceof C0122Es) {
                throw new IllegalStateException(AbstractC0725ab0.G("\n            Flow exception transparency is violated:\n                Previous 'emit' call has thrown exception " + ((C0122Es) interfaceC2747vn).m + ", but then emission attempt of value '" + obj + "' has been detected.\n                Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.\n                For a more detailed explanation, please refer to Flow documentation.\n            ").toString());
            }
            if (((Number) interfaceC2747vnH.R(0, new C1825m2(10, this))).intValue() != this.q) {
                throw new IllegalStateException(("Flow invariant is violated:\n\t\tFlow was collected in " + this.p + ",\n\t\tbut emission happened in " + interfaceC2747vnH + ".\n\t\tPlease refer to 'flow' documentation or use 'flowOn' instead").toString());
            }
            this.r = interfaceC2747vnH;
        }
        this.s = interfaceC0220Im;
        Object objD = O30.a.d(this.f224o, obj, this);
        if (!F3.c(objD, EnumC0091Dn.l)) {
            this.s = null;
        }
        return objD;
    }
}
