package com.google.firebase.firestore.ktx;

import A4.d;
import C4.e;
import C4.j;
import V4.E;
import W.b;
import W.c;
import X4.t;
import Y4.InterfaceC0843i;
import Y4.O;
import com.google.firebase.FirebaseApp;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FieldPath;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;
import com.google.firebase.firestore.FirebaseFirestoreSettings;
import com.google.firebase.firestore.ListenerRegistration;
import com.google.firebase.firestore.MemoryCacheSettings;
import com.google.firebase.firestore.MemoryEagerGcSettings;
import com.google.firebase.firestore.MemoryLruGcSettings;
import com.google.firebase.firestore.MetadataChanges;
import com.google.firebase.firestore.PersistentCacheSettings;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
import com.google.firebase.firestore.util.Executors;
import com.google.firebase.ktx.Firebase;
import java.util.List;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import m3.AbstractC2467b;
import w4.C3137A;
import w4.InterfaceC3141c;

/* JADX INFO: loaded from: classes3.dex */
public final class FirestoreKt {

    /* JADX INFO: renamed from: com.google.firebase.firestore.ktx.FirestoreKt$snapshots$1, reason: invalid class name */
    @e(c = "com.google.firebase.firestore.ktx.FirestoreKt$snapshots$1", f = "Firestore.kt", l = {412}, m = "invokeSuspend")
    public static final class AnonymousClass1 extends j implements J4.e {
        final /* synthetic */ MetadataChanges $metadataChanges;
        final /* synthetic */ DocumentReference $this_snapshots;
        private /* synthetic */ Object L$0;
        int label;

        /* JADX INFO: renamed from: com.google.firebase.firestore.ktx.FirestoreKt$snapshots$1$1, reason: invalid class name and collision with other inner class name */
        public static final class C00051 extends p implements J4.a {
            final /* synthetic */ ListenerRegistration $registration;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C00051(ListenerRegistration listenerRegistration) {
                super(0);
                this.$registration = listenerRegistration;
            }

            @Override // J4.a
            public /* bridge */ /* synthetic */ Object invoke() {
                m352invoke();
                return C3137A.f25453a;
            }

            /* JADX INFO: renamed from: invoke, reason: collision with other method in class */
            public final void m352invoke() {
                this.$registration.remove();
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass1(DocumentReference documentReference, MetadataChanges metadataChanges, d dVar) {
            super(2, dVar);
            this.$this_snapshots = documentReference;
            this.$metadataChanges = metadataChanges;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void invokeSuspend$lambda$0(t tVar, DocumentSnapshot documentSnapshot, FirebaseFirestoreException firebaseFirestoreException) {
            if (firebaseFirestoreException != null) {
                E.i(tVar, E.a("Error getting DocumentReference snapshot", firebaseFirestoreException));
            } else if (documentSnapshot != null) {
                b.y0(tVar, documentSnapshot);
            }
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            AnonymousClass1 anonymousClass1 = new AnonymousClass1(this.$this_snapshots, this.$metadataChanges, dVar);
            anonymousClass1.L$0 = obj;
            return anonymousClass1;
        }

        @Override // J4.e
        public final Object invoke(t tVar, d dVar) {
            return ((AnonymousClass1) create(tVar, dVar)).invokeSuspend(C3137A.f25453a);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            B4.a aVar = B4.a.f492a;
            int i6 = this.label;
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                t tVar = (t) this.L$0;
                ListenerRegistration listenerRegistrationAddSnapshotListener = this.$this_snapshots.addSnapshotListener(Executors.BACKGROUND_EXECUTOR, this.$metadataChanges, new a(tVar, 0));
                o.g(listenerRegistrationAddSnapshotListener, "addSnapshotListener(BACK…apshot)\n        }\n      }");
                C00051 c00051 = new C00051(listenerRegistrationAddSnapshotListener);
                this.label = 1;
                if (c.l(tVar, c00051, this) == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            return C3137A.f25453a;
        }
    }

    /* JADX INFO: renamed from: com.google.firebase.firestore.ktx.FirestoreKt$snapshots$2, reason: invalid class name */
    @e(c = "com.google.firebase.firestore.ktx.FirestoreKt$snapshots$2", f = "Firestore.kt", l = {445}, m = "invokeSuspend")
    public static final class AnonymousClass2 extends j implements J4.e {
        final /* synthetic */ MetadataChanges $metadataChanges;
        final /* synthetic */ Query $this_snapshots;
        private /* synthetic */ Object L$0;
        int label;

        /* JADX INFO: renamed from: com.google.firebase.firestore.ktx.FirestoreKt$snapshots$2$1, reason: invalid class name */
        public static final class AnonymousClass1 extends p implements J4.a {
            final /* synthetic */ ListenerRegistration $registration;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public AnonymousClass1(ListenerRegistration listenerRegistration) {
                super(0);
                this.$registration = listenerRegistration;
            }

            @Override // J4.a
            public /* bridge */ /* synthetic */ Object invoke() {
                m353invoke();
                return C3137A.f25453a;
            }

            /* JADX INFO: renamed from: invoke, reason: collision with other method in class */
            public final void m353invoke() {
                this.$registration.remove();
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass2(Query query, MetadataChanges metadataChanges, d dVar) {
            super(2, dVar);
            this.$this_snapshots = query;
            this.$metadataChanges = metadataChanges;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void invokeSuspend$lambda$0(t tVar, QuerySnapshot querySnapshot, FirebaseFirestoreException firebaseFirestoreException) {
            if (firebaseFirestoreException != null) {
                E.i(tVar, E.a("Error getting Query snapshot", firebaseFirestoreException));
            } else if (querySnapshot != null) {
                b.y0(tVar, querySnapshot);
            }
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            AnonymousClass2 anonymousClass2 = new AnonymousClass2(this.$this_snapshots, this.$metadataChanges, dVar);
            anonymousClass2.L$0 = obj;
            return anonymousClass2;
        }

        @Override // J4.e
        public final Object invoke(t tVar, d dVar) {
            return ((AnonymousClass2) create(tVar, dVar)).invokeSuspend(C3137A.f25453a);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            B4.a aVar = B4.a.f492a;
            int i6 = this.label;
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                t tVar = (t) this.L$0;
                ListenerRegistration listenerRegistrationAddSnapshotListener = this.$this_snapshots.addSnapshotListener(Executors.BACKGROUND_EXECUTOR, this.$metadataChanges, new a(tVar, 1));
                o.g(listenerRegistrationAddSnapshotListener, "addSnapshotListener(BACK…apshot)\n        }\n      }");
                AnonymousClass1 anonymousClass1 = new AnonymousClass1(listenerRegistrationAddSnapshotListener);
                this.label = 1;
                if (c.l(tVar, anonymousClass1, this) == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            return C3137A.f25453a;
        }
    }

    @InterfaceC3141c
    public static final <T> InterfaceC0843i dataObjects(Query query, MetadataChanges metadataChanges) {
        o.h(query, "<this>");
        o.h(metadataChanges, "metadataChanges");
        snapshots(query, metadataChanges);
        o.m();
        throw null;
    }

    public static InterfaceC0843i dataObjects$default(Query query, MetadataChanges metadataChanges, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            metadataChanges = MetadataChanges.EXCLUDE;
        }
        o.h(query, "<this>");
        o.h(metadataChanges, "metadataChanges");
        snapshots(query, metadataChanges);
        o.m();
        throw null;
    }

    public static final FirebaseFirestore firestore(Firebase firebase, FirebaseApp app) {
        o.h(firebase, "<this>");
        o.h(app, "app");
        FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance(app);
        o.g(firebaseFirestore, "getInstance(app)");
        return firebaseFirestore;
    }

    @InterfaceC3141c
    public static final FirebaseFirestoreSettings firestoreSettings(J4.c init) {
        o.h(init, "init");
        FirebaseFirestoreSettings.Builder builder = new FirebaseFirestoreSettings.Builder();
        init.invoke(builder);
        FirebaseFirestoreSettings firebaseFirestoreSettingsBuild = builder.build();
        o.g(firebaseFirestoreSettingsBuild, "builder.build()");
        return firebaseFirestoreSettingsBuild;
    }

    @InterfaceC3141c
    public static final <T> T getField(DocumentSnapshot documentSnapshot, FieldPath fieldPath) {
        o.h(documentSnapshot, "<this>");
        o.h(fieldPath, "fieldPath");
        o.m();
        throw null;
    }

    public static final FirebaseFirestore getFirestore(Firebase firebase) {
        o.h(firebase, "<this>");
        FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
        o.g(firebaseFirestore, "getInstance()");
        return firebaseFirestore;
    }

    public static final MemoryCacheSettings memoryCacheSettings(J4.c init) {
        o.h(init, "init");
        MemoryCacheSettings.Builder builderNewBuilder = MemoryCacheSettings.newBuilder();
        o.g(builderNewBuilder, "newBuilder()");
        init.invoke(builderNewBuilder);
        MemoryCacheSettings memoryCacheSettingsBuild = builderNewBuilder.build();
        o.g(memoryCacheSettingsBuild, "builder.build()");
        return memoryCacheSettingsBuild;
    }

    public static final MemoryEagerGcSettings memoryEagerGcSettings(J4.c init) {
        o.h(init, "init");
        MemoryEagerGcSettings.Builder builderNewBuilder = MemoryEagerGcSettings.newBuilder();
        o.g(builderNewBuilder, "newBuilder()");
        init.invoke(builderNewBuilder);
        MemoryEagerGcSettings memoryEagerGcSettingsBuild = builderNewBuilder.build();
        o.g(memoryEagerGcSettingsBuild, "builder.build()");
        return memoryEagerGcSettingsBuild;
    }

    public static final MemoryLruGcSettings memoryLruGcSettings(J4.c init) {
        o.h(init, "init");
        MemoryLruGcSettings.Builder builderNewBuilder = MemoryLruGcSettings.newBuilder();
        o.g(builderNewBuilder, "newBuilder()");
        init.invoke(builderNewBuilder);
        MemoryLruGcSettings memoryLruGcSettingsBuild = builderNewBuilder.build();
        o.g(memoryLruGcSettingsBuild, "builder.build()");
        return memoryLruGcSettingsBuild;
    }

    public static final PersistentCacheSettings persistentCacheSettings(J4.c init) {
        o.h(init, "init");
        PersistentCacheSettings.Builder builderNewBuilder = PersistentCacheSettings.newBuilder();
        o.g(builderNewBuilder, "newBuilder()");
        init.invoke(builderNewBuilder);
        PersistentCacheSettings persistentCacheSettingsBuild = builderNewBuilder.build();
        o.g(persistentCacheSettingsBuild, "builder.build()");
        return persistentCacheSettingsBuild;
    }

    @InterfaceC3141c
    public static final InterfaceC0843i snapshots(DocumentReference documentReference, MetadataChanges metadataChanges) {
        o.h(documentReference, "<this>");
        o.h(metadataChanges, "metadataChanges");
        return O.g(new AnonymousClass1(documentReference, metadataChanges, null));
    }

    public static /* synthetic */ InterfaceC0843i snapshots$default(DocumentReference documentReference, MetadataChanges metadataChanges, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            metadataChanges = MetadataChanges.EXCLUDE;
        }
        return snapshots(documentReference, metadataChanges);
    }

    @InterfaceC3141c
    public static final <T> T toObject(DocumentSnapshot documentSnapshot) {
        o.h(documentSnapshot, "<this>");
        o.m();
        throw null;
    }

    @InterfaceC3141c
    public static final <T> List<T> toObjects(QuerySnapshot querySnapshot) {
        o.h(querySnapshot, "<this>");
        o.m();
        throw null;
    }

    public static final FirebaseFirestore firestore(Firebase firebase, FirebaseApp app, String database) {
        o.h(firebase, "<this>");
        o.h(app, "app");
        o.h(database, "database");
        FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance(app, database);
        o.g(firebaseFirestore, "getInstance(app, database)");
        return firebaseFirestore;
    }

    @InterfaceC3141c
    public static final <T> T getField(DocumentSnapshot documentSnapshot, FieldPath fieldPath, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior) {
        o.h(documentSnapshot, "<this>");
        o.h(fieldPath, "fieldPath");
        o.h(serverTimestampBehavior, "serverTimestampBehavior");
        o.m();
        throw null;
    }

    @InterfaceC3141c
    public static final InterfaceC0843i snapshots(Query query, MetadataChanges metadataChanges) {
        o.h(query, "<this>");
        o.h(metadataChanges, "metadataChanges");
        return O.g(new AnonymousClass2(query, metadataChanges, null));
    }

    @InterfaceC3141c
    public static final <T> T toObject(DocumentSnapshot documentSnapshot, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior) {
        o.h(documentSnapshot, "<this>");
        o.h(serverTimestampBehavior, "serverTimestampBehavior");
        o.m();
        throw null;
    }

    @InterfaceC3141c
    public static final <T> List<T> toObjects(QuerySnapshot querySnapshot, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior) {
        o.h(querySnapshot, "<this>");
        o.h(serverTimestampBehavior, "serverTimestampBehavior");
        o.m();
        throw null;
    }

    @InterfaceC3141c
    public static final <T> InterfaceC0843i dataObjects(DocumentReference documentReference, MetadataChanges metadataChanges) {
        o.h(documentReference, "<this>");
        o.h(metadataChanges, "metadataChanges");
        snapshots(documentReference, metadataChanges);
        o.m();
        throw null;
    }

    public static final FirebaseFirestore firestore(Firebase firebase, String database) {
        o.h(firebase, "<this>");
        o.h(database, "database");
        FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance(database);
        o.g(firebaseFirestore, "getInstance(database)");
        return firebaseFirestore;
    }

    @InterfaceC3141c
    public static final <T> T getField(DocumentSnapshot documentSnapshot, String field) {
        o.h(documentSnapshot, "<this>");
        o.h(field, "field");
        o.m();
        throw null;
    }

    public static /* synthetic */ InterfaceC0843i snapshots$default(Query query, MetadataChanges metadataChanges, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            metadataChanges = MetadataChanges.EXCLUDE;
        }
        return snapshots(query, metadataChanges);
    }

    @InterfaceC3141c
    public static final <T> T toObject(QueryDocumentSnapshot queryDocumentSnapshot) {
        o.h(queryDocumentSnapshot, "<this>");
        o.m();
        throw null;
    }

    @InterfaceC3141c
    public static final <T> T getField(DocumentSnapshot documentSnapshot, String field, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior) {
        o.h(documentSnapshot, "<this>");
        o.h(field, "field");
        o.h(serverTimestampBehavior, "serverTimestampBehavior");
        o.m();
        throw null;
    }

    @InterfaceC3141c
    public static final <T> T toObject(QueryDocumentSnapshot queryDocumentSnapshot, DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior) {
        o.h(queryDocumentSnapshot, "<this>");
        o.h(serverTimestampBehavior, "serverTimestampBehavior");
        o.m();
        throw null;
    }

    public static InterfaceC0843i dataObjects$default(DocumentReference documentReference, MetadataChanges metadataChanges, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            metadataChanges = MetadataChanges.EXCLUDE;
        }
        o.h(documentReference, "<this>");
        o.h(metadataChanges, "metadataChanges");
        snapshots(documentReference, metadataChanges);
        o.m();
        throw null;
    }
}
