package E1;

import android.util.Log;
import androidx.lifecycle.EnumC0509n;
import androidx.lifecycle.InterfaceC0514t;
import androidx.lifecycle.InterfaceC0516v;
import c7.InterfaceC0591B;
import h0.DialogInterfaceOnCancelListenerC1017q;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import n4.u0;

/* JADX INFO: renamed from: E1.m, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class C0106m implements InterfaceC0514t {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f2101q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ Object f2102r;

    public /* synthetic */ C0106m(int i, Object obj) {
        this.f2101q = i;
        this.f2102r = obj;
    }

    @Override // androidx.lifecycle.InterfaceC0514t
    public final void j(InterfaceC0516v interfaceC0516v, EnumC0509n enumC0509n) {
        Object objPrevious;
        switch (this.f2101q) {
            case u0.f15495q /* 0 */:
                F f3 = (F) this.f2102r;
                P6.g.e(f3, "this$0");
                f3.f2012q = enumC0509n.a();
                if (f3.f1999c != null) {
                    for (C0103j c0103j : f3.f2003g) {
                        c0103j.getClass();
                        c0103j.f2089t = enumC0509n.a();
                        c0103j.c();
                    }
                    return;
                }
                return;
            case 1:
                G1.c cVar = (G1.c) this.f2102r;
                P6.g.e(cVar, "this$0");
                if (enumC0509n == EnumC0509n.ON_CREATE) {
                    DialogInterfaceOnCancelListenerC1017q dialogInterfaceOnCancelListenerC1017q = (DialogInterfaceOnCancelListenerC1017q) interfaceC0516v;
                    Iterable iterable = (Iterable) ((c7.K) ((InterfaceC0591B) cVar.b().f2107e.f9369r)).e();
                    if (!(iterable instanceof Collection) || !((Collection) iterable).isEmpty()) {
                        Iterator it = iterable.iterator();
                        while (it.hasNext()) {
                            if (P6.g.a(((C0103j) it.next()).f2091v, dialogInterfaceOnCancelListenerC1017q.f13271Q)) {
                                return;
                            }
                        }
                    }
                    dialogInterfaceOnCancelListenerC1017q.f0(false, false);
                    return;
                }
                if (enumC0509n == EnumC0509n.ON_STOP) {
                    DialogInterfaceOnCancelListenerC1017q dialogInterfaceOnCancelListenerC1017q2 = (DialogInterfaceOnCancelListenerC1017q) interfaceC0516v;
                    if (dialogInterfaceOnCancelListenerC1017q2.h0().isShowing()) {
                        return;
                    }
                    List list = (List) ((c7.K) ((InterfaceC0591B) cVar.b().f2107e.f9369r)).e();
                    ListIterator listIterator = list.listIterator(list.size());
                    while (true) {
                        if (listIterator.hasPrevious()) {
                            objPrevious = listIterator.previous();
                            if (P6.g.a(((C0103j) objPrevious).f2091v, dialogInterfaceOnCancelListenerC1017q2.f13271Q)) {
                            }
                        } else {
                            objPrevious = null;
                        }
                    }
                    if (objPrevious == null) {
                        throw new IllegalStateException(("Dialog " + dialogInterfaceOnCancelListenerC1017q2 + " has already been popped off of the Navigation back stack").toString());
                    }
                    C0103j c0103j2 = (C0103j) objPrevious;
                    if (!P6.g.a(B6.k.o0(list), c0103j2)) {
                        Log.i("DialogFragmentNavigator", "Dialog " + dialogInterfaceOnCancelListenerC1017q2 + " was dismissed while it was not the top of the back stack, popping all dialogs above this dismissed dialog");
                    }
                    cVar.i(c0103j2, false);
                    return;
                }
                return;
            default:
                EnumC0509n enumC0509n2 = EnumC0509n.ON_START;
                V1.a aVar = (V1.a) this.f2102r;
                if (enumC0509n == enumC0509n2) {
                    aVar.f6858h = true;
                    return;
                } else {
                    if (enumC0509n == EnumC0509n.ON_STOP) {
                        aVar.f6858h = false;
                        return;
                    }
                    return;
                }
        }
    }
}
