package X4;

import V4.N0;
import kotlin.jvm.internal.D;
import w4.C3137A;

/* JADX INFO: loaded from: classes3.dex */
public final class q extends e {

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final a f8693n;

    public q(int i6, a aVar) {
        super(i6);
        this.f8693n = aVar;
        if (aVar != a.f8640a) {
            if (i6 < 1) {
                throw new IllegalArgumentException(Z0.o.j(i6, "Buffered channel capacity must be at least 1, but ", " was specified").toString());
            }
        } else {
            throw new IllegalArgumentException(("This implementation does not support suspension for senders, use " + D.a(e.class).c() + " instead").toString());
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:51:0x00b6, code lost:
    
        return r8;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object I(Object obj, boolean z6) {
        a aVar = a.f8642c;
        C3137A c3137a = C3137A.f25453a;
        if (this.f8693n == aVar) {
            Object objF = super.f(obj);
            return (!(objF instanceof k) || (objF instanceof j)) ? objF : c3137a;
        }
        Object obj2 = g.f8666d;
        m mVar = (m) e.f8657f.get(this);
        while (true) {
            long andIncrement = e.f8653b.getAndIncrement(this);
            long j4 = 1152921504606846975L & andIncrement;
            boolean zT = t(andIncrement, false);
            int i6 = g.f8664b;
            long j6 = i6;
            long j7 = j4 / j6;
            int i7 = (int) (j4 % j6);
            if (mVar.f10849c != j7) {
                m mVarB = e.b(this, j7, mVar);
                if (mVarB != null) {
                    mVar = mVarB;
                } else if (zT) {
                    return new j(q());
                }
            }
            int iH = e.h(this, mVar, i7, obj, j4, obj2, zT);
            if (iH == 0) {
                mVar.b();
                return c3137a;
            }
            if (iH == 1) {
                break;
            }
            if (iH != 2) {
                if (iH == 3) {
                    throw new IllegalStateException("unexpected");
                }
                if (iH == 4) {
                    if (j4 < e.f8654c.get(this)) {
                        mVar.b();
                    }
                    return new j(q());
                }
                if (iH == 5) {
                    mVar.b();
                }
            } else {
                if (zT) {
                    mVar.i();
                    return new j(q());
                }
                N0 n02 = obj2 instanceof N0 ? (N0) obj2 : null;
                if (n02 != null) {
                    n02.a(mVar, i7 + i6);
                }
                l((mVar.f10849c * j6) + ((long) i7));
            }
        }
    }

    @Override // X4.e, X4.w
    public final Object f(Object obj) {
        return I(obj, false);
    }

    @Override // X4.e, X4.w
    public final Object g(A4.d dVar, Object obj) throws Throwable {
        if (I(obj, true) instanceof j) {
            throw q();
        }
        return C3137A.f25453a;
    }

    @Override // X4.e
    public final boolean w() {
        return this.f8693n == a.f8641b;
    }
}
