package com.google.firebase.sessions;

import com.google.firebase.FirebaseApp;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.sessions.InstallationId;
import com.google.firebase.sessions.api.FirebaseSessionsDependencies;
import com.google.firebase.sessions.settings.SessionsSettings;
import dn.p;
import java.util.Map;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.l;
import rm.n0;
import rm.y;
import tp.m0;

@kotlin.coroutines.jvm.internal.f(c = "com.google.firebase.sessions.SessionFirelogPublisherImpl$logSession$1", f = "SessionFirelogPublisher.kt", l = {63, 64, 70}, m = "invokeSuspend")
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\u008a@"}, d2 = {"Ltp/m0;", "Lrm/n0;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
/* loaded from: classes3.dex */
final class SessionFirelogPublisherImpl$logSession$1 extends l implements p {
    final /* synthetic */ SessionDetails $sessionDetails;
    Object L$0;
    Object L$1;
    Object L$2;
    Object L$3;
    Object L$4;
    Object L$5;
    int label;
    final /* synthetic */ SessionFirelogPublisherImpl this$0;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public SessionFirelogPublisherImpl$logSession$1(SessionFirelogPublisherImpl sessionFirelogPublisherImpl, SessionDetails sessionDetails, vm.d<? super SessionFirelogPublisherImpl$logSession$1> dVar) {
        super(2, dVar);
        this.this$0 = sessionFirelogPublisherImpl;
        this.$sessionDetails = sessionDetails;
    }

    @Override // kotlin.coroutines.jvm.internal.a
    public final vm.d<n0> create(Object obj, vm.d<?> dVar) {
        return new SessionFirelogPublisherImpl$logSession$1(this.this$0, this.$sessionDetails, dVar);
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0094 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:17:0x0095  */
    @Override // kotlin.coroutines.jvm.internal.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object f10;
        FirebaseInstallationsApi firebaseInstallationsApi;
        FirebaseApp firebaseApp;
        SessionsSettings sessionsSettings;
        Object registeredSubscribers$com_google_firebase_firebase_sessions;
        SessionEvents sessionEvents;
        SessionFirelogPublisherImpl sessionFirelogPublisherImpl;
        SessionDetails sessionDetails;
        SessionsSettings sessionsSettings2;
        InstallationId installationId;
        f10 = wm.d.f();
        int i10 = this.label;
        if (i10 == 0) {
            y.b(obj);
            SessionFirelogPublisherImpl sessionFirelogPublisherImpl2 = this.this$0;
            this.label = 1;
            obj = sessionFirelogPublisherImpl2.shouldLogSession(this);
            if (obj == f10) {
                return f10;
            }
        } else {
            if (i10 != 1) {
                if (i10 != 2) {
                    if (i10 != 3) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    SessionsSettings sessionsSettings3 = (SessionsSettings) this.L$5;
                    SessionDetails sessionDetails2 = (SessionDetails) this.L$4;
                    FirebaseApp firebaseApp2 = (FirebaseApp) this.L$3;
                    SessionEvents sessionEvents2 = (SessionEvents) this.L$2;
                    SessionFirelogPublisherImpl sessionFirelogPublisherImpl3 = (SessionFirelogPublisherImpl) this.L$1;
                    installationId = (InstallationId) this.L$0;
                    y.b(obj);
                    sessionFirelogPublisherImpl = sessionFirelogPublisherImpl3;
                    sessionsSettings2 = sessionsSettings3;
                    sessionEvents = sessionEvents2;
                    sessionDetails = sessionDetails2;
                    firebaseApp = firebaseApp2;
                    sessionFirelogPublisherImpl.attemptLoggingSessionEvent(sessionEvents.buildSession(firebaseApp, sessionDetails, sessionsSettings2, (Map) obj, installationId.getFid(), installationId.getAuthToken()));
                    return n0.f34904a;
                }
                y.b(obj);
                InstallationId installationId2 = (InstallationId) obj;
                SessionFirelogPublisherImpl sessionFirelogPublisherImpl4 = this.this$0;
                SessionEvents sessionEvents3 = SessionEvents.INSTANCE;
                firebaseApp = sessionFirelogPublisherImpl4.firebaseApp;
                SessionDetails sessionDetails3 = this.$sessionDetails;
                sessionsSettings = this.this$0.sessionSettings;
                FirebaseSessionsDependencies firebaseSessionsDependencies = FirebaseSessionsDependencies.INSTANCE;
                this.L$0 = installationId2;
                this.L$1 = sessionFirelogPublisherImpl4;
                this.L$2 = sessionEvents3;
                this.L$3 = firebaseApp;
                this.L$4 = sessionDetails3;
                this.L$5 = sessionsSettings;
                this.label = 3;
                registeredSubscribers$com_google_firebase_firebase_sessions = firebaseSessionsDependencies.getRegisteredSubscribers$com_google_firebase_firebase_sessions(this);
                if (registeredSubscribers$com_google_firebase_firebase_sessions != f10) {
                    return f10;
                }
                sessionEvents = sessionEvents3;
                sessionFirelogPublisherImpl = sessionFirelogPublisherImpl4;
                sessionDetails = sessionDetails3;
                sessionsSettings2 = sessionsSettings;
                obj = registeredSubscribers$com_google_firebase_firebase_sessions;
                installationId = installationId2;
                sessionFirelogPublisherImpl.attemptLoggingSessionEvent(sessionEvents.buildSession(firebaseApp, sessionDetails, sessionsSettings2, (Map) obj, installationId.getFid(), installationId.getAuthToken()));
                return n0.f34904a;
            }
            y.b(obj);
        }
        if (((Boolean) obj).booleanValue()) {
            InstallationId.Companion companion = InstallationId.INSTANCE;
            firebaseInstallationsApi = this.this$0.firebaseInstallations;
            this.label = 2;
            obj = companion.create(firebaseInstallationsApi, this);
            if (obj == f10) {
                return f10;
            }
            InstallationId installationId22 = (InstallationId) obj;
            SessionFirelogPublisherImpl sessionFirelogPublisherImpl42 = this.this$0;
            SessionEvents sessionEvents32 = SessionEvents.INSTANCE;
            firebaseApp = sessionFirelogPublisherImpl42.firebaseApp;
            SessionDetails sessionDetails32 = this.$sessionDetails;
            sessionsSettings = this.this$0.sessionSettings;
            FirebaseSessionsDependencies firebaseSessionsDependencies2 = FirebaseSessionsDependencies.INSTANCE;
            this.L$0 = installationId22;
            this.L$1 = sessionFirelogPublisherImpl42;
            this.L$2 = sessionEvents32;
            this.L$3 = firebaseApp;
            this.L$4 = sessionDetails32;
            this.L$5 = sessionsSettings;
            this.label = 3;
            registeredSubscribers$com_google_firebase_firebase_sessions = firebaseSessionsDependencies2.getRegisteredSubscribers$com_google_firebase_firebase_sessions(this);
            if (registeredSubscribers$com_google_firebase_firebase_sessions != f10) {
            }
        }
        return n0.f34904a;
    }

    @Override // dn.p
    public final Object invoke(m0 m0Var, vm.d<? super n0> dVar) {
        return ((SessionFirelogPublisherImpl$logSession$1) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
    }
}
