package defpackage;

import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

/* JADX INFO: renamed from: ˁᵛʿ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0727 {

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public int f3295;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public final C5346 f3296;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public boolean f3298;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C2198 f3299;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public EnumC0038 f3300;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public boolean f3301;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C1014 f3297 = new C1014(9);

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final boolean f3292 = true;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public ᵣˊˈᵪ f3294 = new ᵣˊˈᵪ(17);

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final ArrayList f3293 = new ArrayList();

    public C0727(InterfaceC1569 interfaceC1569) {
        this.f3299 = new C2198(interfaceC1569);
        EnumC0038 enumC0038 = EnumC0038.f1191;
        this.f3300 = enumC0038;
        this.f3296 = AbstractC4223.m9176(enumC0038);
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final EnumC0038 m2592(InterfaceC5232 interfaceC5232) {
        C4316 c4316 = (C4316) ((C3430) this.f3294.ᵜᵪʾ).m7849(interfaceC5232);
        C4316 c43162 = c4316 != null ? c4316.f16425 : null;
        EnumC0038 enumC0038 = c43162 != null ? c43162.f16424.f8876 : null;
        ArrayList arrayList = this.f3293;
        EnumC0038 enumC00382 = arrayList.isEmpty() ? null : (EnumC0038) AbstractC3653.m8235(1, arrayList);
        EnumC0038 enumC00383 = this.f3300;
        if (enumC0038 == null || enumC0038.compareTo(enumC00383) >= 0) {
            enumC0038 = enumC00383;
        }
        return (enumC00382 == null || enumC00382.compareTo(enumC0038) >= 0) ? enumC0038 : enumC00382;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m2593(String str) {
        if (this.f3292 && !C0879.m3077().f3891.m7105()) {
            throw new IllegalStateException(AbstractC3589.m8117("Method ", str, " must be called on the main thread").toString());
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void m2594(EnumC0038 enumC0038) {
        if (this.f3300 == enumC0038) {
            return;
        }
        InterfaceC1569 interfaceC1569 = (InterfaceC1569) ((WeakReference) this.f3299.f8735).get();
        EnumC0038 enumC00382 = this.f3300;
        EnumC0038 enumC00383 = EnumC0038.f1191;
        EnumC0038 enumC00384 = EnumC0038.f1189;
        if (enumC00382 == enumC00383 && enumC0038 == enumC00384) {
            throw new IllegalStateException(("State must be at least '" + EnumC0038.f1190 + "' to be moved to '" + enumC0038 + "' in component " + interfaceC1569).toString());
        }
        if (enumC00382 == enumC00384 && enumC00382 != enumC0038) {
            throw new IllegalStateException(("State is '" + enumC00384 + "' and cannot be moved to `" + enumC0038 + "` in component " + interfaceC1569).toString());
        }
        this.f3300 = enumC0038;
        if (this.f3301 || this.f3295 != 0) {
            this.f3298 = true;
            return;
        }
        this.f3301 = true;
        m2596();
        this.f3301 = false;
        if (this.f3300 == enumC00384) {
            this.f3294 = new ᵣˊˈᵪ(17);
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m2595(InterfaceC5232 interfaceC5232) {
        InterfaceC5276 c3640;
        C2241 c2241;
        InterfaceC1569 interfaceC1569;
        m2593("addObserver");
        EnumC0038 enumC0038 = this.f3300;
        EnumC0038 enumC00382 = EnumC0038.f1189;
        if (enumC0038 != enumC00382) {
            enumC00382 = EnumC0038.f1191;
        }
        C2241 c22412 = new C2241();
        c22412.f8876 = enumC00382;
        HashMap map = AbstractC0592.f2894;
        boolean z = interfaceC5232 instanceof InterfaceC5276;
        boolean z2 = interfaceC5232 instanceof C4489;
        Object obj = null;
        int i = 1;
        if (z && z2) {
            c3640 = new C3640((C4489) interfaceC5232, i, (InterfaceC5276) interfaceC5232);
        } else if (z2) {
            c3640 = new C3640((C4489) interfaceC5232, i, obj);
        } else if (z) {
            c3640 = (InterfaceC5276) interfaceC5232;
        } else {
            Class<?> cls = interfaceC5232.getClass();
            if (AbstractC0592.m2222(cls) == 2) {
                List list = (List) AbstractC0592.f2893.get(cls);
                if (list.size() == 1) {
                    AbstractC0592.m2223((Constructor) list.get(0), interfaceC5232);
                    c3640 = new ᵖʧ();
                } else {
                    int size = list.size();
                    InterfaceC2905[] interfaceC2905Arr = new InterfaceC2905[size];
                    for (int i2 = 0; i2 < size; i2++) {
                        AbstractC0592.m2223((Constructor) list.get(i2), interfaceC5232);
                        interfaceC2905Arr[i2] = null;
                    }
                    c3640 = new C3811(i, interfaceC2905Arr);
                }
            } else {
                c3640 = new C3640(interfaceC5232);
            }
        }
        c22412.f8875 = c3640;
        ᵣˊˈᵪ r1 = this.f3294;
        C3430 c3430 = (C3430) r1.ᵜᵪʾ;
        C4316 c4316 = (C4316) c3430.m7849(interfaceC5232);
        if (c4316 != null) {
            c2241 = c4316.f16424;
        } else {
            C4316 c43162 = new C4316(interfaceC5232, c22412);
            c3430.m7853(interfaceC5232, c43162);
            C4316 c43163 = (C4316) r1.ᵨᵼⁱ;
            if (c43163 == null) {
                r1.ᵔᵖᵹᵫ = c43162;
                r1.ᵨᵼⁱ = c43162;
            } else {
                c43163.f16423 = c43162;
                c43162.f16425 = c43163;
                r1.ᵨᵼⁱ = c43162;
            }
            c2241 = null;
        }
        if (c2241 == null && (interfaceC1569 = (InterfaceC1569) ((WeakReference) this.f3299.f8735).get()) != null) {
            i = (this.f3295 != 0 || this.f3301) ? 1 : 0;
            EnumC0038 enumC0038M2592 = m2592(interfaceC5232);
            this.f3295++;
            while (c22412.f8876.compareTo(enumC0038M2592) < 0 && ((C3430) this.f3294.ᵜᵪʾ).m7851(interfaceC5232)) {
                EnumC0038 enumC00383 = c22412.f8876;
                ArrayList arrayList = this.f3293;
                arrayList.add(enumC00383);
                C1494 c1494 = EnumC1653.Companion;
                EnumC0038 enumC00384 = c22412.f8876;
                c1494.getClass();
                int iOrdinal = enumC00384.ordinal();
                EnumC1653 enumC1653 = iOrdinal != 1 ? iOrdinal != 2 ? iOrdinal != 3 ? null : EnumC1653.ON_RESUME : EnumC1653.ON_START : EnumC1653.ON_CREATE;
                if (enumC1653 == null) {
                    C1685.m4559(c22412.f8876, "no event up from ");
                    return;
                } else {
                    c22412.m5842(interfaceC1569, enumC1653);
                    AbstractC5477.m11100(arrayList);
                    enumC0038M2592 = m2592(interfaceC5232);
                }
            }
            if (i == 0) {
                m2596();
            }
            this.f3295--;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:16:0x0036, code lost:
    
        r7.f3298 = false;
        r7.f3296.m10939(r7.f3300);
     */
    /* JADX WARN: Code restructure failed: missing block: B:17:0x003f, code lost:
    
        return;
     */
    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m2596() {
        Object obj = ((WeakReference) this.f3299.f8735).get();
        if (obj == null) {
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("LifecycleOwner of this LifecycleRegistry is already garbage collected. It is too late to change lifecycle state.");
            return;
        }
        final InterfaceC1569 interfaceC1569 = (InterfaceC1569) obj;
        while (true) {
            ᵣˊˈᵪ r1 = this.f3294;
            final int i = 0;
            if (((C3430) r1.ᵜᵪʾ).f13231 == 0) {
                break;
            }
            C4316 c4316 = (C4316) r1.ᵔᵖᵹᵫ;
            if (c4316 == null) {
                throw new NoSuchElementException("Collection is empty.");
            }
            EnumC0038 enumC0038 = c4316.f16424.f8876;
            C4316 c43162 = (C4316) r1.ᵨᵼⁱ;
            if (c43162 == null) {
                throw new NoSuchElementException("Collection is empty.");
            }
            EnumC0038 enumC00382 = c43162.f16424.f8876;
            if (enumC0038 == enumC00382 && this.f3300 == enumC00382) {
                break;
            }
            this.f3298 = false;
            EnumC0038 enumC00383 = this.f3300;
            if (c4316 == null) {
                throw new NoSuchElementException("Collection is empty.");
            }
            if (enumC00383.compareTo(enumC0038) < 0) {
                ᵣˊˈᵪ r12 = this.f3294;
                InterfaceC0778 interfaceC0778 = new InterfaceC0778(this) { // from class: ˊᵖᵘ

                    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
                    public final /* synthetic */ C0727 f5637;

                    {
                        this.f5637 = this;
                    }

                    @Override // defpackage.InterfaceC0778
                    /* JADX INFO: renamed from: ʽˈˋ */
                    public final Object mo1706(Object obj2) {
                        int i2 = i;
                        C5063 c5063 = C5063.f19112;
                        InterfaceC1569 interfaceC15692 = interfaceC1569;
                        C0727 c0727 = this.f5637;
                        Map.Entry entry = (Map.Entry) obj2;
                        switch (i2) {
                            case 0:
                                InterfaceC5232 interfaceC5232 = (InterfaceC5232) entry.getKey();
                                C2241 c2241 = (C2241) entry.getValue();
                                while (true) {
                                    EnumC0038 enumC00384 = c2241.f8876;
                                    EnumC0038 enumC00385 = c0727.f3300;
                                    ArrayList arrayList = c0727.f3293;
                                    if (enumC00384.compareTo(enumC00385) > 0 && !c0727.f3298 && ((C3430) c0727.f3294.ᵜᵪʾ).m7851(interfaceC5232)) {
                                        C1494 c1494 = EnumC1653.Companion;
                                        EnumC0038 enumC00386 = c2241.f8876;
                                        c1494.getClass();
                                        int iOrdinal = enumC00386.ordinal();
                                        EnumC1653 enumC1653 = iOrdinal != 2 ? iOrdinal != 3 ? iOrdinal != 4 ? null : EnumC1653.ON_PAUSE : EnumC1653.ON_STOP : EnumC1653.ON_DESTROY;
                                        if (enumC1653 == null) {
                                            C4935.m10241(c2241.f8876, "no event down from ");
                                        } else {
                                            arrayList.add(enumC1653.m4544());
                                            c2241.m5842(interfaceC15692, enumC1653);
                                            AbstractC5477.m11100(arrayList);
                                        }
                                        break;
                                    }
                                }
                                break;
                            default:
                                InterfaceC5232 interfaceC52322 = (InterfaceC5232) entry.getKey();
                                C2241 c22412 = (C2241) entry.getValue();
                                while (true) {
                                    EnumC0038 enumC00387 = c22412.f8876;
                                    EnumC0038 enumC00388 = c0727.f3300;
                                    ArrayList arrayList2 = c0727.f3293;
                                    if (enumC00387.compareTo(enumC00388) < 0 && !c0727.f3298 && ((C3430) c0727.f3294.ᵜᵪʾ).m7851(interfaceC52322)) {
                                        arrayList2.add(c22412.f8876);
                                        C1494 c14942 = EnumC1653.Companion;
                                        EnumC0038 enumC00389 = c22412.f8876;
                                        c14942.getClass();
                                        int iOrdinal2 = enumC00389.ordinal();
                                        EnumC1653 enumC16532 = iOrdinal2 != 1 ? iOrdinal2 != 2 ? iOrdinal2 != 3 ? null : EnumC1653.ON_RESUME : EnumC1653.ON_START : EnumC1653.ON_CREATE;
                                        if (enumC16532 == null) {
                                            C4935.m10241(c22412.f8876, "no event up from ");
                                        } else {
                                            c22412.m5842(interfaceC15692, enumC16532);
                                            AbstractC5477.m11100(arrayList2);
                                        }
                                        break;
                                    }
                                }
                                break;
                        }
                        return null;
                    }
                };
                for (C4316 c43163 = (C4316) r12.ᵨᵼⁱ; c43163 != null; c43163 = c43163.f16425) {
                    if (!c43163.f16426) {
                        interfaceC0778.mo1706(c43163);
                    }
                }
            }
            C4316 c43164 = (C4316) this.f3294.ᵨᵼⁱ;
            if (!this.f3298 && c43164 != null && this.f3300.compareTo(c43164.f16424.f8876) > 0) {
                ᵣˊˈᵪ r13 = this.f3294;
                final int i2 = 1;
                InterfaceC0778 interfaceC07782 = new InterfaceC0778(this) { // from class: ˊᵖᵘ

                    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
                    public final /* synthetic */ C0727 f5637;

                    {
                        this.f5637 = this;
                    }

                    @Override // defpackage.InterfaceC0778
                    /* JADX INFO: renamed from: ʽˈˋ */
                    public final Object mo1706(Object obj2) {
                        int i22 = i2;
                        C5063 c5063 = C5063.f19112;
                        InterfaceC1569 interfaceC15692 = interfaceC1569;
                        C0727 c0727 = this.f5637;
                        Map.Entry entry = (Map.Entry) obj2;
                        switch (i22) {
                            case 0:
                                InterfaceC5232 interfaceC5232 = (InterfaceC5232) entry.getKey();
                                C2241 c2241 = (C2241) entry.getValue();
                                while (true) {
                                    EnumC0038 enumC00384 = c2241.f8876;
                                    EnumC0038 enumC00385 = c0727.f3300;
                                    ArrayList arrayList = c0727.f3293;
                                    if (enumC00384.compareTo(enumC00385) > 0 && !c0727.f3298 && ((C3430) c0727.f3294.ᵜᵪʾ).m7851(interfaceC5232)) {
                                        C1494 c1494 = EnumC1653.Companion;
                                        EnumC0038 enumC00386 = c2241.f8876;
                                        c1494.getClass();
                                        int iOrdinal = enumC00386.ordinal();
                                        EnumC1653 enumC1653 = iOrdinal != 2 ? iOrdinal != 3 ? iOrdinal != 4 ? null : EnumC1653.ON_PAUSE : EnumC1653.ON_STOP : EnumC1653.ON_DESTROY;
                                        if (enumC1653 == null) {
                                            C4935.m10241(c2241.f8876, "no event down from ");
                                        } else {
                                            arrayList.add(enumC1653.m4544());
                                            c2241.m5842(interfaceC15692, enumC1653);
                                            AbstractC5477.m11100(arrayList);
                                        }
                                        break;
                                    }
                                }
                                break;
                            default:
                                InterfaceC5232 interfaceC52322 = (InterfaceC5232) entry.getKey();
                                C2241 c22412 = (C2241) entry.getValue();
                                while (true) {
                                    EnumC0038 enumC00387 = c22412.f8876;
                                    EnumC0038 enumC00388 = c0727.f3300;
                                    ArrayList arrayList2 = c0727.f3293;
                                    if (enumC00387.compareTo(enumC00388) < 0 && !c0727.f3298 && ((C3430) c0727.f3294.ᵜᵪʾ).m7851(interfaceC52322)) {
                                        arrayList2.add(c22412.f8876);
                                        C1494 c14942 = EnumC1653.Companion;
                                        EnumC0038 enumC00389 = c22412.f8876;
                                        c14942.getClass();
                                        int iOrdinal2 = enumC00389.ordinal();
                                        EnumC1653 enumC16532 = iOrdinal2 != 1 ? iOrdinal2 != 2 ? iOrdinal2 != 3 ? null : EnumC1653.ON_RESUME : EnumC1653.ON_START : EnumC1653.ON_CREATE;
                                        if (enumC16532 == null) {
                                            C4935.m10241(c22412.f8876, "no event up from ");
                                        } else {
                                            c22412.m5842(interfaceC15692, enumC16532);
                                            AbstractC5477.m11100(arrayList2);
                                        }
                                        break;
                                    }
                                }
                                break;
                        }
                        return null;
                    }
                };
                for (C4316 c43165 = (C4316) r13.ᵔᵖᵹᵫ; c43165 != null; c43165 = c43165.f16423) {
                    if (!c43165.f16426) {
                        interfaceC07782.mo1706(c43165);
                    }
                }
            }
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void m2597(EnumC1653 enumC1653) {
        m2593("handleLifecycleEvent");
        m2594(enumC1653.m4544());
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void m2598(InterfaceC5232 interfaceC5232) {
        m2593("removeObserver");
        ᵣˊˈᵪ r2 = this.f3294;
        C4316 c4316 = (C4316) ((C3430) r2.ᵜᵪʾ).m7850(interfaceC5232);
        if (c4316 == null) {
            return;
        }
        C4316 c43162 = c4316.f16425;
        C4316 c43163 = c4316.f16423;
        if (c43162 == null) {
            r2.ᵔᵖᵹᵫ = c43163;
        } else {
            c43162.f16423 = c43163;
        }
        C4316 c43164 = c4316.f16423;
        if (c43164 == null) {
            r2.ᵨᵼⁱ = c43162;
        } else {
            c43164.f16425 = c43162;
        }
        c4316.f16426 = true;
    }
}
