package Z4;

import java.util.Arrays;
import w4.C3137A;

/* JADX INFO: renamed from: Z4.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC0869b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public AbstractC0871d[] f9158a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f9159b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f9160c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public C f9161d;

    public final AbstractC0871d d() {
        AbstractC0871d abstractC0871dE;
        C c6;
        synchronized (this) {
            try {
                AbstractC0871d[] abstractC0871dArrF = this.f9158a;
                if (abstractC0871dArrF == null) {
                    abstractC0871dArrF = f();
                    this.f9158a = abstractC0871dArrF;
                } else if (this.f9159b >= abstractC0871dArrF.length) {
                    Object[] objArrCopyOf = Arrays.copyOf(abstractC0871dArrF, abstractC0871dArrF.length * 2);
                    kotlin.jvm.internal.o.g(objArrCopyOf, "copyOf(...)");
                    this.f9158a = (AbstractC0871d[]) objArrCopyOf;
                    abstractC0871dArrF = (AbstractC0871d[]) objArrCopyOf;
                }
                int i6 = this.f9160c;
                do {
                    abstractC0871dE = abstractC0871dArrF[i6];
                    if (abstractC0871dE == null) {
                        abstractC0871dE = e();
                        abstractC0871dArrF[i6] = abstractC0871dE;
                    }
                    i6++;
                    if (i6 >= abstractC0871dArrF.length) {
                        i6 = 0;
                    }
                } while (!abstractC0871dE.a(this));
                this.f9160c = i6;
                this.f9159b++;
                c6 = this.f9161d;
            } catch (Throwable th) {
                throw th;
            }
        }
        if (c6 != null) {
            c6.v(1);
        }
        return abstractC0871dE;
    }

    public abstract AbstractC0871d e();

    public abstract AbstractC0871d[] f();

    public final void g(AbstractC0871d abstractC0871d) {
        C c6;
        int i6;
        A4.d[] dVarArrB;
        synchronized (this) {
            try {
                int i7 = this.f9159b - 1;
                this.f9159b = i7;
                c6 = this.f9161d;
                if (i7 == 0) {
                    this.f9160c = 0;
                }
                kotlin.jvm.internal.o.f(abstractC0871d, "null cannot be cast to non-null type kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot<kotlin.Any>");
                dVarArrB = abstractC0871d.b(this);
            } catch (Throwable th) {
                throw th;
            }
        }
        for (A4.d dVar : dVarArrB) {
            if (dVar != null) {
                dVar.resumeWith(C3137A.f25453a);
            }
        }
        if (c6 != null) {
            c6.v(-1);
        }
    }

    public final C h() {
        C c6;
        synchronized (this) {
            c6 = this.f9161d;
            if (c6 == null) {
                int i6 = this.f9159b;
                c6 = new C(1, Integer.MAX_VALUE, X4.a.f8641b);
                c6.c(Integer.valueOf(i6));
                this.f9161d = c6;
            }
        }
        return c6;
    }
}
