package androidx.datastore.core;

import java.util.Set;
import kotlin.NoWhenBranchMatchedException;

/* JADX INFO: loaded from: classes.dex */
public final class o {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final kotlinx.coroutines.flow.v f1944a;

    public o() {
        this.f1944a = new kotlinx.coroutines.flow.v(f0.f1915b);
    }

    public final c0 a() {
        kotlinx.coroutines.flow.v vVar = this.f1944a;
        vVar.getClass();
        la.e eVar = kotlinx.coroutines.flow.internal.b.f29385b;
        Object obj = kotlinx.coroutines.flow.v.f29428e.get(vVar);
        if (obj == eVar) {
            obj = null;
        }
        return (c0) obj;
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$ArrayArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    public final void b(Set set) {
        kotlinx.coroutines.flow.v vVar;
        Object obj;
        int[] iArr;
        nb.g.i(set, "tableIds");
        if (set.isEmpty()) {
            return;
        }
        do {
            vVar = this.f1944a;
            vVar.getClass();
            obj = kotlinx.coroutines.flow.internal.b.f29385b;
            Object obj2 = kotlinx.coroutines.flow.v.f29428e.get(vVar);
            if (obj2 == obj) {
                obj2 = null;
            }
            int[] iArr2 = (int[]) obj2;
            int length = iArr2.length;
            iArr = new int[length];
            for (int i10 = 0; i10 < length; i10++) {
                iArr[i10] = set.contains(Integer.valueOf(i10)) ? iArr2[i10] + 1 : iArr2[i10];
            }
            if (obj2 != null) {
                obj = obj2;
            }
        } while (!vVar.h(obj, iArr));
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0030  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void c(c0 c0Var) {
        kotlinx.coroutines.flow.v vVar;
        Object obj;
        Object obj2;
        nb.g.i(c0Var, "newState");
        do {
            vVar = this.f1944a;
            vVar.getClass();
            obj = kotlinx.coroutines.flow.internal.b.f29385b;
            obj2 = kotlinx.coroutines.flow.v.f29428e.get(vVar);
            if (obj2 == obj) {
                obj2 = null;
            }
            c0 c0Var2 = (c0) obj2;
            if (!(c0Var2 instanceof w) && !nb.g.c(c0Var2, f0.f1915b)) {
                if (c0Var2 instanceof d) {
                    if (c0Var.f1912a > c0Var2.f1912a) {
                        c0Var2 = c0Var;
                    }
                } else if (!(c0Var2 instanceof t)) {
                    throw new NoWhenBranchMatchedException();
                }
            }
            if (obj2 == null) {
                obj2 = obj;
            }
            if (c0Var2 != null) {
                obj = c0Var2;
            }
        } while (!vVar.h(obj2, obj));
    }

    public o(int i10) {
        this.f1944a = new kotlinx.coroutines.flow.v(new int[i10]);
    }
}
