package androidx.datastore.core;

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;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\u0004\n\u0002\b\u0002\u0010\u0001\u001a\u00028\u0000\"\u0004\b\u0000\u0010\u0000H\u008a@"}, d2 = {"T", "<anonymous>"}, k = 3, mv = {1, 8, 0})
@DebugMetadata(c = "androidx.datastore.core.DataStoreImpl$transformAndWrite$2", f = "DataStoreImpl.kt", i = {1, 2}, l = {330, 331, 337}, m = "invokeSuspend", n = {"curData", "newData"}, s = {"L$0", "L$0"})
final class DataStoreImpl$transformAndWrite$2 extends SuspendLambda implements sd.l {
    final /* synthetic */ kotlin.coroutines.h $callerContext;
    final /* synthetic */ Function2 $transform;
    Object L$0;
    int label;
    final /* synthetic */ n this$0;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public DataStoreImpl$transformAndWrite$2(n nVar, kotlin.coroutines.h hVar, Function2 function2, Continuation continuation) {
        super(1, continuation);
        this.this$0 = nVar;
        this.$callerContext = hVar;
        this.$transform = function2;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Continuation continuation) {
        return new DataStoreImpl$transformAndWrite$2(this.this$0, this.$callerContext, this.$transform, continuation);
    }

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

    /* JADX WARN: Removed duplicated region for block: B:20:0x0053  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0058  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x005d  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0075  */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        d dVar;
        Object obj2;
        Object obj3;
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        int i10 = this.label;
        if (i10 == 0) {
            kotlin.a.d(obj);
            n nVar = this.this$0;
            this.label = 1;
            obj = n.f(nVar, true, this);
            if (obj == coroutineSingletons) {
                return coroutineSingletons;
            }
        } else {
            if (i10 != 1) {
                if (i10 != 2) {
                    if (i10 != 3) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    obj3 = this.L$0;
                    kotlin.a.d(obj);
                    return obj3;
                }
                dVar = (d) this.L$0;
                kotlin.a.d(obj);
                obj2 = dVar.f1913b;
                if ((obj2 == null ? obj2.hashCode() : 0) == dVar.f1914c) {
                    throw new IllegalStateException("Data in DataStore was mutated but DataStore is only compatible with Immutable types.".toString());
                }
                if (nb.g.c(dVar.f1913b, obj)) {
                    return obj;
                }
                n nVar2 = this.this$0;
                this.L$0 = obj;
                this.label = 3;
                if (nVar2.j(obj, true, this) == coroutineSingletons) {
                    return coroutineSingletons;
                }
                obj3 = obj;
                return obj3;
            }
            kotlin.a.d(obj);
        }
        dVar = (d) obj;
        kotlin.coroutines.h hVar = this.$callerContext;
        DataStoreImpl$transformAndWrite$2$newData$1 dataStoreImpl$transformAndWrite$2$newData$1 = new DataStoreImpl$transformAndWrite$2$newData$1(this.$transform, dVar, null);
        this.L$0 = dVar;
        this.label = 2;
        obj = hb.a.G0(this, hVar, dataStoreImpl$transformAndWrite$2$newData$1);
        if (obj == coroutineSingletons) {
            return coroutineSingletons;
        }
        obj2 = dVar.f1913b;
        if ((obj2 == null ? obj2.hashCode() : 0) == dVar.f1914c) {
        }
    }
}
