package defpackage;

import android.util.Log;
import androidx.media3.extractor.ts.TsExtractor;
import defpackage.dw7;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\u008a@¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lorg/json/JSONObject;", "it", "Le6a;", "<anonymous>", "(Lorg/json/JSONObject;)V"}, k = 3, mv = {1, 8, 0})
@DebugMetadata(c = "com.google.firebase.sessions.settings.RemoteSettings$updateSettings$2$1", f = "RemoteSettings.kt", i = {0, 0, 0, 1, 1, 2}, l = {125, 128, 131, 133, TsExtractor.TS_STREAM_TYPE_SPLICE_INFO, TsExtractor.TS_STREAM_TYPE_DTS_HD}, m = "invokeSuspend", n = {"sessionSamplingRate", "sessionTimeoutSeconds", "cacheDuration", "sessionSamplingRate", "cacheDuration", "cacheDuration"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1", "L$0"})
@vx8
final class fy7 extends SuspendLambda implements gr3<JSONObject, Continuation<? super e6a>, Object> {
    public dw7.h a;
    public dw7.h b;
    public int c;
    public /* synthetic */ Object d;
    public final /* synthetic */ by7 e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public fy7(by7 by7Var, Continuation continuation) {
        super(2, continuation);
        this.e = by7Var;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        fy7 fy7Var = new fy7(this.e, continuation);
        fy7Var.d = obj;
        return fy7Var;
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((fy7) create((JSONObject) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Code restructure failed: missing block: B:69:0x0157, code lost:
    
        if (r14 == r4) goto L85;
     */
    /* JADX WARN: Removed duplicated region for block: B:49:0x00ec  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x010d A[PHI: r0 r1
      0x010d: PHI (r0v10 dw7$h) = (r0v7 dw7$h), (r0v7 dw7$h), (r0v11 dw7$h) binds: [B:48:0x00ea, B:53:0x0109, B:11:0x0033] A[DONT_GENERATE, DONT_INLINE]
      0x010d: PHI (r1v11 dw7$h) = (r1v7 dw7$h), (r1v7 dw7$h), (r1v16 dw7$h) binds: [B:48:0x00ea, B:53:0x0109, B:11:0x0033] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x0113  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0134 A[PHI: r0
      0x0134: PHI (r0v12 dw7$h) = (r0v10 dw7$h), (r0v10 dw7$h), (r0v17 dw7$h) binds: [B:56:0x0111, B:61:0x0130, B:10:0x002a] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:65:0x013a  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x015c  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x015f  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0182  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x01a2  */
    /* JADX WARN: Removed duplicated region for block: B:86:0x01a6 A[RETURN] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws JSONException {
        dw7.h hVar;
        Boolean bool;
        dw7.h hVar2;
        dw7.h hVar3;
        dw7.h hVar4;
        dw7.h hVar5;
        e6a e6aVar;
        Object objC;
        ck1 ck1Var = ck1.a;
        int i = this.c;
        e6a e6aVar2 = e6a.a;
        by7 by7Var = this.e;
        switch (i) {
            case 0:
                s38.b(obj);
                JSONObject jSONObject = (JSONObject) this.d;
                Objects.toString(jSONObject);
                dw7.h hVar6 = new dw7.h();
                hVar = new dw7.h();
                dw7.h hVar7 = new dw7.h();
                if (jSONObject.has("app_quality")) {
                    Object obj2 = jSONObject.get("app_quality");
                    cr4.e(obj2, "null cannot be cast to non-null type org.json.JSONObject");
                    JSONObject jSONObject2 = (JSONObject) obj2;
                    try {
                        bool = jSONObject2.has("sessions_enabled") ? (Boolean) jSONObject2.get("sessions_enabled") : null;
                    } catch (JSONException e) {
                        e = e;
                        bool = null;
                    }
                    try {
                        if (jSONObject2.has("sampling_rate")) {
                            hVar6.a = (Double) jSONObject2.get("sampling_rate");
                        }
                        if (jSONObject2.has("session_timeout_seconds")) {
                            hVar.a = (Integer) jSONObject2.get("session_timeout_seconds");
                        }
                        if (jSONObject2.has("cache_duration")) {
                            hVar7.a = (Integer) jSONObject2.get("cache_duration");
                        }
                    } catch (JSONException e2) {
                        e = e2;
                        Log.e("SessionConfigFetcher", "Error parsing the configs remotely fetched: ", e);
                    }
                    break;
                } else {
                    bool = null;
                }
                if (bool == null) {
                    hVar2 = hVar6;
                    hVar3 = hVar7;
                    if (((Integer) hVar.a) != null) {
                    }
                    return ck1Var;
                }
                ln8 ln8VarB = by7Var.b();
                this.d = hVar6;
                this.a = hVar;
                this.b = hVar7;
                this.c = 1;
                Object objC2 = ln8VarB.c(ln8.c, bool, this);
                if (objC2 != ck1.a) {
                    objC2 = e6aVar2;
                }
                if (objC2 != ck1Var) {
                    hVar4 = hVar6;
                    hVar5 = hVar;
                    hVar3 = hVar7;
                    hVar = hVar5;
                    hVar2 = hVar4;
                    if (((Integer) hVar.a) != null) {
                        ln8 ln8VarB2 = by7Var.b();
                        Integer num = (Integer) hVar.a;
                        this.d = hVar2;
                        this.a = hVar3;
                        this.b = null;
                        this.c = 2;
                        Object objC3 = ln8VarB2.c(ln8.e, num, this);
                        if (objC3 != ck1.a) {
                            objC3 = e6aVar2;
                        }
                        if (objC3 != ck1Var) {
                            if (((Double) hVar2.a) == null) {
                                ln8 ln8VarB3 = by7Var.b();
                                Double d = (Double) hVar2.a;
                                this.d = hVar3;
                                this.a = null;
                                this.b = null;
                                this.c = 3;
                                Object objC4 = ln8VarB3.c(ln8.d, d, this);
                                if (objC4 != ck1.a) {
                                    objC4 = e6aVar2;
                                }
                                if (objC4 != ck1Var) {
                                    if (((Integer) hVar3.a) == null) {
                                        ln8 ln8VarB4 = by7Var.b();
                                        Integer num2 = (Integer) hVar3.a;
                                        this.d = null;
                                        this.a = null;
                                        this.b = null;
                                        this.c = 4;
                                        Object objC5 = ln8VarB4.c(ln8.f, num2, this);
                                        if (objC5 != ck1.a) {
                                            objC5 = e6aVar2;
                                        }
                                        break;
                                    } else {
                                        e6aVar = null;
                                        if (e6aVar != null) {
                                            ln8 ln8VarB5 = by7Var.b();
                                            Integer numBoxInt = Boxing.boxInt(86400);
                                            this.d = null;
                                            this.a = null;
                                            this.b = null;
                                            this.c = 5;
                                            Object objC6 = ln8VarB5.c(ln8.f, numBoxInt, this);
                                            if (objC6 != ck1.a) {
                                                objC6 = e6aVar2;
                                            }
                                            if (objC6 != ck1Var) {
                                                ln8 ln8VarB6 = by7Var.b();
                                                Long lBoxLong = Boxing.boxLong(System.currentTimeMillis());
                                                this.d = null;
                                                this.a = null;
                                                this.b = null;
                                                this.c = 6;
                                                objC = ln8VarB6.c(ln8.g, lBoxLong, this);
                                                if (objC != ck1.a) {
                                                    objC = e6aVar2;
                                                }
                                                if (objC != ck1Var) {
                                                    return e6aVar2;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return ck1Var;
            case 1:
                hVar3 = this.b;
                hVar5 = this.a;
                hVar4 = (dw7.h) this.d;
                s38.b(obj);
                hVar = hVar5;
                hVar2 = hVar4;
                if (((Integer) hVar.a) != null) {
                }
                return ck1Var;
            case 2:
                hVar3 = this.a;
                hVar2 = (dw7.h) this.d;
                s38.b(obj);
                if (((Double) hVar2.a) == null) {
                }
                return ck1Var;
            case 3:
                hVar3 = (dw7.h) this.d;
                s38.b(obj);
                if (((Integer) hVar3.a) == null) {
                }
                break;
            case 4:
                s38.b(obj);
                e6aVar = e6aVar2;
                if (e6aVar != null) {
                }
                return ck1Var;
            case 5:
                s38.b(obj);
                ln8 ln8VarB62 = by7Var.b();
                Long lBoxLong2 = Boxing.boxLong(System.currentTimeMillis());
                this.d = null;
                this.a = null;
                this.b = null;
                this.c = 6;
                objC = ln8VarB62.c(ln8.g, lBoxLong2, this);
                if (objC != ck1.a) {
                }
                if (objC != ck1Var) {
                    return ck1Var;
                }
                break;
            case 6:
                s38.b(obj);
                return e6aVar2;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }
}
