package androidx.datastore.core;

import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Ref$BooleanRef;
import kotlin.jvm.internal.Ref$ObjectRef;
import kotlin.jvm.internal.SourceDebugExtension;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\b\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0002\u001a\b\u0012\u0004\u0012\u00028\u00000\u0001\"\u0004\b\u0000\u0010\u0000H\u008a@"}, d2 = {"T", "Landroidx/datastore/core/d;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
@DebugMetadata(c = "androidx.datastore.core.DataStoreImpl$InitDataStore$doRun$initData$1", f = "DataStoreImpl.kt", i = {0, 0, 0, 1, 1, 1, 1, 2, 2, 2}, l = {437, 458, 546, 468}, m = "invokeSuspend", n = {"updateLock", "initializationComplete", "currentData", "updateLock", "initializationComplete", "currentData", "api", "initializationComplete", "currentData", "$this$withLock_u24default$iv"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$3", "L$0", "L$1", "L$2"})
@SourceDebugExtension({"SMAP\nDataStoreImpl.kt\nKotlin\n*S Kotlin\n*F\n+ 1 DataStoreImpl.kt\nandroidx/datastore/core/DataStoreImpl$InitDataStore$doRun$initData$1\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 3 Mutex.kt\nkotlinx/coroutines/sync/MutexKt\n*L\n1#1,538:1\n1855#2,2:539\n120#3,10:541\n*S KotlinDebug\n*F\n+ 1 DataStoreImpl.kt\nandroidx/datastore/core/DataStoreImpl$InitDataStore$doRun$initData$1\n*L\n458#1:539,2\n461#1:541,10\n*E\n"})
final class DataStoreImpl$InitDataStore$doRun$initData$1 extends SuspendLambda implements sd.l {
    int I$0;
    Object L$0;
    Object L$1;
    Object L$2;
    Object L$3;
    Object L$4;
    int label;
    final /* synthetic */ n this$0;
    final /* synthetic */ j this$1;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public DataStoreImpl$InitDataStore$doRun$initData$1(n nVar, j jVar, Continuation continuation) {
        super(1, continuation);
        this.this$0 = nVar;
        this.this$1 = jVar;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Continuation continuation) {
        return new DataStoreImpl$InitDataStore$doRun$initData$1(this.this$0, this.this$1, continuation);
    }

    @Override // sd.l
    public final Object invoke(Object obj) {
        return ((DataStoreImpl$InitDataStore$doRun$initData$1) create((Continuation) obj)).invokeSuspend(kd.e.f29109a);
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x00ab  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x00e1 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00e2  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00ec  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00f1  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x010a A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:41:0x010b  */
    /* JADX WARN: Type inference failed for: r13v5, types: [T, java.lang.Object] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws CorruptionException {
        kotlinx.coroutines.sync.a aVarA;
        Ref$BooleanRef ref$BooleanRef;
        Ref$ObjectRef ref$ObjectRef;
        Ref$ObjectRef ref$ObjectRef2;
        DataStoreImpl$InitDataStore$doRun$initData$1 dataStoreImpl$InitDataStore$doRun$initData$1;
        Ref$BooleanRef ref$BooleanRef2;
        kotlinx.coroutines.sync.a aVar;
        Iterator it;
        kotlinx.coroutines.sync.a aVar2;
        Ref$BooleanRef ref$BooleanRef3;
        Ref$ObjectRef ref$ObjectRef3;
        i iVar;
        Ref$ObjectRef ref$ObjectRef4;
        Object obj2;
        int i10;
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        int i11 = this.label;
        if (i11 == 0) {
            kotlin.a.d(obj);
            aVarA = kotlinx.coroutines.sync.d.a();
            ref$BooleanRef = new Ref$BooleanRef();
            ref$ObjectRef = new Ref$ObjectRef();
            n nVar = this.this$0;
            this.L$0 = aVarA;
            this.L$1 = ref$BooleanRef;
            this.L$2 = ref$ObjectRef;
            this.L$3 = ref$ObjectRef;
            this.label = 1;
            obj = n.f(nVar, true, this);
            if (obj == coroutineSingletons) {
                return coroutineSingletons;
            }
            ref$ObjectRef2 = ref$ObjectRef;
        } else if (i11 == 1) {
            ref$ObjectRef = (Ref$ObjectRef) this.L$3;
            ref$ObjectRef2 = (Ref$ObjectRef) this.L$2;
            ref$BooleanRef = (Ref$BooleanRef) this.L$1;
            aVarA = (kotlinx.coroutines.sync.a) this.L$0;
            kotlin.a.d(obj);
        } else {
            if (i11 != 2) {
                if (i11 != 3) {
                    if (i11 != 4) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    i10 = this.I$0;
                    obj2 = this.L$0;
                    kotlin.a.d(obj);
                    return new d(i10, ((Number) obj).intValue(), obj2);
                }
                aVar = (kotlinx.coroutines.sync.a) this.L$2;
                ref$ObjectRef4 = (Ref$ObjectRef) this.L$1;
                ref$BooleanRef2 = (Ref$BooleanRef) this.L$0;
                kotlin.a.d(obj);
                dataStoreImpl$InitDataStore$doRun$initData$1 = this;
                try {
                    ref$BooleanRef2.element = true;
                    aVar.g(null);
                    obj2 = ref$ObjectRef4.element;
                    int iHashCode = obj2 == null ? obj2.hashCode() : 0;
                    u uVarG = dataStoreImpl$InitDataStore$doRun$initData$1.this$0.g();
                    dataStoreImpl$InitDataStore$doRun$initData$1.L$0 = obj2;
                    dataStoreImpl$InitDataStore$doRun$initData$1.L$1 = null;
                    dataStoreImpl$InitDataStore$doRun$initData$1.L$2 = null;
                    dataStoreImpl$InitDataStore$doRun$initData$1.I$0 = iHashCode;
                    dataStoreImpl$InitDataStore$doRun$initData$1.label = 4;
                    obj = ((b0) uVarG).a();
                    if (obj != coroutineSingletons) {
                        return coroutineSingletons;
                    }
                    i10 = iHashCode;
                    return new d(i10, ((Number) obj).intValue(), obj2);
                } catch (Throwable th) {
                    aVar.g(null);
                    throw th;
                }
            }
            it = (Iterator) this.L$4;
            iVar = (i) this.L$3;
            ref$ObjectRef3 = (Ref$ObjectRef) this.L$2;
            ref$BooleanRef3 = (Ref$BooleanRef) this.L$1;
            aVar2 = (kotlinx.coroutines.sync.a) this.L$0;
            kotlin.a.d(obj);
            dataStoreImpl$InitDataStore$doRun$initData$1 = this;
            while (it.hasNext()) {
                Function2 function2 = (Function2) it.next();
                dataStoreImpl$InitDataStore$doRun$initData$1.L$0 = aVar2;
                dataStoreImpl$InitDataStore$doRun$initData$1.L$1 = ref$BooleanRef3;
                dataStoreImpl$InitDataStore$doRun$initData$1.L$2 = ref$ObjectRef3;
                dataStoreImpl$InitDataStore$doRun$initData$1.L$3 = iVar;
                dataStoreImpl$InitDataStore$doRun$initData$1.L$4 = it;
                dataStoreImpl$InitDataStore$doRun$initData$1.label = 2;
                if (function2.invoke(iVar, dataStoreImpl$InitDataStore$doRun$initData$1) == coroutineSingletons) {
                    return coroutineSingletons;
                }
            }
            ref$ObjectRef2 = ref$ObjectRef3;
            ref$BooleanRef2 = ref$BooleanRef3;
            aVar = aVar2;
            dataStoreImpl$InitDataStore$doRun$initData$1.this$1.f1925c = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$0 = ref$BooleanRef2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$1 = ref$ObjectRef2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$2 = aVar;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$3 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$4 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.label = 3;
            if (aVar.e(dataStoreImpl$InitDataStore$doRun$initData$1) == coroutineSingletons) {
                return coroutineSingletons;
            }
            ref$ObjectRef4 = ref$ObjectRef2;
            ref$BooleanRef2.element = true;
            aVar.g(null);
            obj2 = ref$ObjectRef4.element;
            if (obj2 == null) {
            }
            u uVarG2 = dataStoreImpl$InitDataStore$doRun$initData$1.this$0.g();
            dataStoreImpl$InitDataStore$doRun$initData$1.L$0 = obj2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$1 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$2 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.I$0 = iHashCode;
            dataStoreImpl$InitDataStore$doRun$initData$1.label = 4;
            obj = ((b0) uVarG2).a();
            if (obj != coroutineSingletons) {
            }
        }
        ref$ObjectRef.element = ((d) obj).f1913b;
        i iVar2 = new i(aVarA, ref$BooleanRef, ref$ObjectRef2, this.this$0);
        List list = this.this$1.f1925c;
        if (list != null) {
            it = list.iterator();
            aVar2 = aVarA;
            ref$BooleanRef3 = ref$BooleanRef;
            ref$ObjectRef3 = ref$ObjectRef2;
            iVar = iVar2;
            dataStoreImpl$InitDataStore$doRun$initData$1 = this;
            while (it.hasNext()) {
            }
            ref$ObjectRef2 = ref$ObjectRef3;
            ref$BooleanRef2 = ref$BooleanRef3;
            aVar = aVar2;
            dataStoreImpl$InitDataStore$doRun$initData$1.this$1.f1925c = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$0 = ref$BooleanRef2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$1 = ref$ObjectRef2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$2 = aVar;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$3 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$4 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.label = 3;
            if (aVar.e(dataStoreImpl$InitDataStore$doRun$initData$1) == coroutineSingletons) {
            }
        } else {
            dataStoreImpl$InitDataStore$doRun$initData$1 = this;
            ref$BooleanRef2 = ref$BooleanRef;
            aVar = aVarA;
            dataStoreImpl$InitDataStore$doRun$initData$1.this$1.f1925c = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$0 = ref$BooleanRef2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$1 = ref$ObjectRef2;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$2 = aVar;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$3 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.L$4 = null;
            dataStoreImpl$InitDataStore$doRun$initData$1.label = 3;
            if (aVar.e(dataStoreImpl$InitDataStore$doRun$initData$1) == coroutineSingletons) {
            }
        }
    }
}
