package h0;

import E1.C0113u;
import M.AbstractC0195z;
import android.content.res.Resources;
import android.os.BadParcelableException;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.fragment.app.FragmentContainerView;
import androidx.lifecycle.C0518x;
import androidx.lifecycle.EnumC0509n;
import androidx.lifecycle.EnumC0510o;
import com.martsnew.tv.R;
import d5.AbstractC0844a;
import e0.C0853a;
import i0.AbstractC1048d;
import i0.C1045a;
import i0.C1047c;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import n4.u0;
import r0.C1482a;
import t0.C1532a;
import u.AbstractC1563h;
import y5.AbstractActivityC1764i;

/* JADX INFO: loaded from: classes.dex */
public final class W {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C0853a f13123a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C2.a f13124b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ComponentCallbacksC1023x f13125c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f13126d = false;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f13127e = -1;

    public W(C0853a c0853a, C2.a aVar, ComponentCallbacksC1023x componentCallbacksC1023x) {
        this.f13123a = c0853a;
        this.f13124b = aVar;
        this.f13125c = componentCallbacksC1023x;
    }

    public final void a() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "moveto ACTIVITY_CREATED: " + componentCallbacksC1023x);
        }
        Bundle bundle = componentCallbacksC1023x.f13294r;
        if (bundle != null) {
            bundle.getBundle("savedInstanceState");
        }
        componentCallbacksC1023x.f13267M.S();
        componentCallbacksC1023x.f13293q = 3;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.A();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onActivityCreated()"));
        }
        if (P.L(3)) {
            Log.d("FragmentManager", "moveto RESTORE_VIEW_STATE: " + componentCallbacksC1023x);
        }
        if (componentCallbacksC1023x.X != null) {
            Bundle bundle2 = componentCallbacksC1023x.f13294r;
            Bundle bundle3 = bundle2 != null ? bundle2.getBundle("savedInstanceState") : null;
            SparseArray<Parcelable> sparseArray = componentCallbacksC1023x.f13295s;
            if (sparseArray != null) {
                componentCallbacksC1023x.X.restoreHierarchyState(sparseArray);
                componentCallbacksC1023x.f13295s = null;
            }
            componentCallbacksC1023x.f13276V = false;
            componentCallbacksC1023x.V(bundle3);
            if (!componentCallbacksC1023x.f13276V) {
                throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onViewStateRestored()"));
            }
            if (componentCallbacksC1023x.X != null) {
                componentCallbacksC1023x.f13286g0.b(EnumC0509n.ON_CREATE);
            }
        }
        componentCallbacksC1023x.f13294r = null;
        P p3 = componentCallbacksC1023x.f13267M;
        p3.H = false;
        p3.f13059I = false;
        p3.f13065O.f13106g = false;
        p3.u(4);
        this.f13123a.i(componentCallbacksC1023x, false);
    }

    public final void b() {
        ComponentCallbacksC1023x componentCallbacksC1023x;
        View view;
        View view2;
        int iIndexOfChild = -1;
        ComponentCallbacksC1023x componentCallbacksC1023x2 = this.f13125c;
        View view3 = componentCallbacksC1023x2.f13277W;
        while (true) {
            componentCallbacksC1023x = null;
            if (view3 == null) {
                break;
            }
            Object tag = view3.getTag(R.id.fragment_container_view_tag);
            ComponentCallbacksC1023x componentCallbacksC1023x3 = tag instanceof ComponentCallbacksC1023x ? (ComponentCallbacksC1023x) tag : null;
            if (componentCallbacksC1023x3 != null) {
                componentCallbacksC1023x = componentCallbacksC1023x3;
                break;
            } else {
                Object parent = view3.getParent();
                view3 = parent instanceof View ? (View) parent : null;
            }
        }
        ComponentCallbacksC1023x componentCallbacksC1023x4 = componentCallbacksC1023x2.f13268N;
        if (componentCallbacksC1023x != null && !componentCallbacksC1023x.equals(componentCallbacksC1023x4)) {
            int i = componentCallbacksC1023x2.f13270P;
            C1047c c1047c = AbstractC1048d.f13482a;
            StringBuilder sb = new StringBuilder("Attempting to nest fragment ");
            sb.append(componentCallbacksC1023x2);
            sb.append(" within the view of parent fragment ");
            sb.append(componentCallbacksC1023x);
            sb.append(" via container with ID ");
            AbstractC1048d.b(new C1045a(componentCallbacksC1023x2, AbstractC0844a.n(sb, i, " without using parent's childFragmentManager")));
            AbstractC1048d.a(componentCallbacksC1023x2).getClass();
        }
        C2.a aVar = this.f13124b;
        aVar.getClass();
        ViewGroup viewGroup = componentCallbacksC1023x2.f13277W;
        if (viewGroup != null) {
            ArrayList arrayList = (ArrayList) aVar.f1157r;
            int iIndexOf = arrayList.indexOf(componentCallbacksC1023x2);
            int i5 = iIndexOf - 1;
            while (true) {
                if (i5 < 0) {
                    while (true) {
                        iIndexOf++;
                        if (iIndexOf >= arrayList.size()) {
                            break;
                        }
                        ComponentCallbacksC1023x componentCallbacksC1023x5 = (ComponentCallbacksC1023x) arrayList.get(iIndexOf);
                        if (componentCallbacksC1023x5.f13277W == viewGroup && (view = componentCallbacksC1023x5.X) != null) {
                            iIndexOfChild = viewGroup.indexOfChild(view);
                            break;
                        }
                    }
                } else {
                    ComponentCallbacksC1023x componentCallbacksC1023x6 = (ComponentCallbacksC1023x) arrayList.get(i5);
                    if (componentCallbacksC1023x6.f13277W == viewGroup && (view2 = componentCallbacksC1023x6.X) != null) {
                        iIndexOfChild = viewGroup.indexOfChild(view2) + 1;
                        break;
                    }
                    i5--;
                }
            }
        }
        componentCallbacksC1023x2.f13277W.addView(componentCallbacksC1023x2.X, iIndexOfChild);
    }

    public final void c() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "moveto ATTACHED: " + componentCallbacksC1023x);
        }
        ComponentCallbacksC1023x componentCallbacksC1023x2 = componentCallbacksC1023x.f13299w;
        W w4 = null;
        C2.a aVar = this.f13124b;
        if (componentCallbacksC1023x2 != null) {
            W w6 = (W) ((HashMap) aVar.f1158s).get(componentCallbacksC1023x2.f13297u);
            if (w6 == null) {
                throw new IllegalStateException("Fragment " + componentCallbacksC1023x + " declared target fragment " + componentCallbacksC1023x.f13299w + " that does not belong to this FragmentManager!");
            }
            componentCallbacksC1023x.f13300x = componentCallbacksC1023x.f13299w.f13297u;
            componentCallbacksC1023x.f13299w = null;
            w4 = w6;
        } else {
            String str = componentCallbacksC1023x.f13300x;
            if (str != null && (w4 = (W) ((HashMap) aVar.f1158s).get(str)) == null) {
                StringBuilder sb = new StringBuilder("Fragment ");
                sb.append(componentCallbacksC1023x);
                sb.append(" declared target fragment ");
                throw new IllegalStateException(I1.a.r(sb, componentCallbacksC1023x.f13300x, " that does not belong to this FragmentManager!"));
            }
        }
        if (w4 != null) {
            w4.k();
        }
        P p3 = componentCallbacksC1023x.f13265K;
        componentCallbacksC1023x.f13266L = p3.f13088w;
        componentCallbacksC1023x.f13268N = p3.f13090y;
        C0853a c0853a = this.f13123a;
        c0853a.q(componentCallbacksC1023x, false);
        ArrayList arrayList = componentCallbacksC1023x.f13291l0;
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            ((AbstractC1022w) obj).a();
        }
        arrayList.clear();
        componentCallbacksC1023x.f13267M.b(componentCallbacksC1023x.f13266L, componentCallbacksC1023x.j(), componentCallbacksC1023x);
        componentCallbacksC1023x.f13293q = 0;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.E(componentCallbacksC1023x.f13266L.f13306u);
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onAttach()"));
        }
        P p4 = componentCallbacksC1023x.f13265K;
        Iterator it = p4.f13081p.iterator();
        while (it.hasNext()) {
            ((T) it.next()).a(p4, componentCallbacksC1023x);
        }
        P p8 = componentCallbacksC1023x.f13267M;
        p8.H = false;
        p8.f13059I = false;
        p8.f13065O.f13106g = false;
        p8.u(0);
        c0853a.j(componentCallbacksC1023x, false);
    }

    public final int d() {
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (componentCallbacksC1023x.f13265K == null) {
            return componentCallbacksC1023x.f13293q;
        }
        int iMin = this.f13127e;
        int iOrdinal = componentCallbacksC1023x.f13284e0.ordinal();
        if (iOrdinal == 1) {
            iMin = Math.min(iMin, 0);
        } else if (iOrdinal == 2) {
            iMin = Math.min(iMin, 1);
        } else if (iOrdinal == 3) {
            iMin = Math.min(iMin, 5);
        } else if (iOrdinal != 4) {
            iMin = Math.min(iMin, -1);
        }
        if (componentCallbacksC1023x.f13260E) {
            if (componentCallbacksC1023x.f13261F) {
                iMin = Math.max(this.f13127e, 2);
                View view = componentCallbacksC1023x.X;
                if (view != null && view.getParent() == null) {
                    iMin = Math.min(iMin, 2);
                }
            } else {
                iMin = this.f13127e < 4 ? Math.min(iMin, componentCallbacksC1023x.f13293q) : Math.min(iMin, 1);
            }
        }
        if (componentCallbacksC1023x.f13262G && componentCallbacksC1023x.f13277W == null) {
            iMin = Math.min(iMin, 4);
        }
        if (!componentCallbacksC1023x.f13257A) {
            iMin = Math.min(iMin, 1);
        }
        ViewGroup viewGroup = componentCallbacksC1023x.f13277W;
        if (viewGroup != null) {
            C1013m c1013mI = C1013m.i(viewGroup, componentCallbacksC1023x.q());
            c1013mI.getClass();
            b0 b0VarF = c1013mI.f(componentCallbacksC1023x);
            int i = b0VarF != null ? b0VarF.f13180b : 0;
            b0 b0VarG = c1013mI.g(componentCallbacksC1023x);
            i = b0VarG != null ? b0VarG.f13180b : 0;
            int i5 = i == 0 ? -1 : c0.f13192a[AbstractC1563h.c(i)];
            if (i5 != -1 && i5 != 1) {
                i = i;
            }
        }
        if (i == 2) {
            iMin = Math.min(iMin, 6);
        } else if (i == 3) {
            iMin = Math.max(iMin, 3);
        } else if (componentCallbacksC1023x.f13258B) {
            iMin = componentCallbacksC1023x.z() ? Math.min(iMin, 1) : Math.min(iMin, -1);
        }
        if (componentCallbacksC1023x.f13278Y && componentCallbacksC1023x.f13293q < 5) {
            iMin = Math.min(iMin, 4);
        }
        if (componentCallbacksC1023x.f13259C) {
            iMin = Math.max(iMin, 3);
        }
        if (P.L(2)) {
            Log.v("FragmentManager", "computeExpectedState() of " + iMin + " for " + componentCallbacksC1023x);
        }
        return iMin;
    }

    public final void e() {
        Bundle bundle;
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "moveto CREATED: " + componentCallbacksC1023x);
        }
        Bundle bundle2 = componentCallbacksC1023x.f13294r;
        Bundle bundle3 = bundle2 != null ? bundle2.getBundle("savedInstanceState") : null;
        if (componentCallbacksC1023x.f13282c0) {
            componentCallbacksC1023x.f13293q = 1;
            Bundle bundle4 = componentCallbacksC1023x.f13294r;
            if (bundle4 == null || (bundle = bundle4.getBundle("childFragmentManager")) == null) {
                return;
            }
            componentCallbacksC1023x.f13267M.Y(bundle);
            P p3 = componentCallbacksC1023x.f13267M;
            p3.H = false;
            p3.f13059I = false;
            p3.f13065O.f13106g = false;
            p3.u(1);
            return;
        }
        C0853a c0853a = this.f13123a;
        c0853a.r(componentCallbacksC1023x, false);
        componentCallbacksC1023x.f13267M.S();
        componentCallbacksC1023x.f13293q = 1;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.f13285f0.f(new U1.b(3, componentCallbacksC1023x));
        componentCallbacksC1023x.F(bundle3);
        componentCallbacksC1023x.f13282c0 = true;
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onCreate()"));
        }
        componentCallbacksC1023x.f13285f0.H(EnumC0509n.ON_CREATE);
        c0853a.m(componentCallbacksC1023x, false);
    }

    public final void f() {
        String resourceName;
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (componentCallbacksC1023x.f13260E) {
            return;
        }
        if (P.L(3)) {
            Log.d("FragmentManager", "moveto CREATE_VIEW: " + componentCallbacksC1023x);
        }
        Bundle bundle = componentCallbacksC1023x.f13294r;
        Bundle bundle2 = bundle != null ? bundle.getBundle("savedInstanceState") : null;
        LayoutInflater layoutInflaterL = componentCallbacksC1023x.L(bundle2);
        ViewGroup viewGroup = componentCallbacksC1023x.f13277W;
        if (viewGroup == null) {
            int i = componentCallbacksC1023x.f13270P;
            if (i == 0) {
                viewGroup = null;
            } else {
                if (i == -1) {
                    throw new IllegalArgumentException(AbstractC0844a.k("Cannot create fragment ", componentCallbacksC1023x, " for a container view with no id"));
                }
                viewGroup = (ViewGroup) componentCallbacksC1023x.f13265K.f13089x.v(i);
                if (viewGroup == null) {
                    if (!componentCallbacksC1023x.H && !componentCallbacksC1023x.f13262G) {
                        try {
                            resourceName = componentCallbacksC1023x.s().getResourceName(componentCallbacksC1023x.f13270P);
                        } catch (Resources.NotFoundException unused) {
                            resourceName = "unknown";
                        }
                        throw new IllegalArgumentException("No view found for id 0x" + Integer.toHexString(componentCallbacksC1023x.f13270P) + " (" + resourceName + ") for fragment " + componentCallbacksC1023x);
                    }
                } else if (!(viewGroup instanceof FragmentContainerView)) {
                    C1047c c1047c = AbstractC1048d.f13482a;
                    AbstractC1048d.b(new C1045a(componentCallbacksC1023x, "Attempting to add fragment " + componentCallbacksC1023x + " to container " + viewGroup + " which is not a FragmentContainerView"));
                    AbstractC1048d.a(componentCallbacksC1023x).getClass();
                }
            }
        }
        componentCallbacksC1023x.f13277W = viewGroup;
        componentCallbacksC1023x.W(layoutInflaterL, viewGroup, bundle2);
        if (componentCallbacksC1023x.X != null) {
            if (P.L(3)) {
                Log.d("FragmentManager", "moveto VIEW_CREATED: " + componentCallbacksC1023x);
            }
            componentCallbacksC1023x.X.setSaveFromParentEnabled(false);
            componentCallbacksC1023x.X.setTag(R.id.fragment_container_view_tag, componentCallbacksC1023x);
            if (viewGroup != null) {
                b();
            }
            if (componentCallbacksC1023x.f13272R) {
                componentCallbacksC1023x.X.setVisibility(8);
            }
            if (componentCallbacksC1023x.X.isAttachedToWindow()) {
                View view = componentCallbacksC1023x.X;
                Field field = M.J.f4065a;
                AbstractC0195z.c(view);
            } else {
                View view2 = componentCallbacksC1023x.X;
                view2.addOnAttachStateChangeListener(new V(0, view2));
            }
            Bundle bundle3 = componentCallbacksC1023x.f13294r;
            componentCallbacksC1023x.U(componentCallbacksC1023x.X, bundle3 != null ? bundle3.getBundle("savedInstanceState") : null);
            componentCallbacksC1023x.f13267M.u(2);
            this.f13123a.w(componentCallbacksC1023x, componentCallbacksC1023x.X, false);
            int visibility = componentCallbacksC1023x.X.getVisibility();
            componentCallbacksC1023x.k().f13254j = componentCallbacksC1023x.X.getAlpha();
            if (componentCallbacksC1023x.f13277W != null && visibility == 0) {
                View viewFindFocus = componentCallbacksC1023x.X.findFocus();
                if (viewFindFocus != null) {
                    componentCallbacksC1023x.k().f13255k = viewFindFocus;
                    if (P.L(2)) {
                        Log.v("FragmentManager", "requestFocus: Saved focused view " + viewFindFocus + " for Fragment " + componentCallbacksC1023x);
                    }
                }
                componentCallbacksC1023x.X.setAlpha(0.0f);
            }
        }
        componentCallbacksC1023x.f13293q = 2;
    }

    public final void g() {
        ComponentCallbacksC1023x componentCallbacksC1023xM;
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "movefrom CREATED: " + componentCallbacksC1023x);
        }
        int i = 0;
        boolean zIsChangingConfigurations = true;
        boolean z8 = componentCallbacksC1023x.f13258B && !componentCallbacksC1023x.z();
        C2.a aVar = this.f13124b;
        if (z8 && !componentCallbacksC1023x.D) {
            aVar.L(componentCallbacksC1023x.f13297u, null);
        }
        if (!z8) {
            S s8 = (S) aVar.f1160u;
            if (!((s8.f13101b.containsKey(componentCallbacksC1023x.f13297u) && s8.f13104e) ? s8.f13105f : true)) {
                String str = componentCallbacksC1023x.f13300x;
                if (str != null && (componentCallbacksC1023xM = aVar.m(str)) != null && componentCallbacksC1023xM.f13274T) {
                    componentCallbacksC1023x.f13299w = componentCallbacksC1023xM;
                }
                componentCallbacksC1023x.f13293q = 0;
                return;
            }
        }
        C1025z c1025z = componentCallbacksC1023x.f13266L;
        if (c1025z != null) {
            zIsChangingConfigurations = ((S) aVar.f1160u).f13105f;
        } else {
            AbstractActivityC1764i abstractActivityC1764i = c1025z.f13306u;
            if (AbstractC0844a.w(abstractActivityC1764i)) {
                zIsChangingConfigurations = true ^ abstractActivityC1764i.isChangingConfigurations();
            }
        }
        if ((z8 && !componentCallbacksC1023x.D) || zIsChangingConfigurations) {
            ((S) aVar.f1160u).e(componentCallbacksC1023x, false);
        }
        componentCallbacksC1023x.f13267M.l();
        componentCallbacksC1023x.f13285f0.H(EnumC0509n.ON_DESTROY);
        componentCallbacksC1023x.f13293q = 0;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.f13282c0 = false;
        componentCallbacksC1023x.I();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onDestroy()"));
        }
        this.f13123a.n(componentCallbacksC1023x, false);
        ArrayList arrayListQ = aVar.q();
        int size = arrayListQ.size();
        while (i < size) {
            Object obj = arrayListQ.get(i);
            i++;
            W w4 = (W) obj;
            if (w4 != null) {
                String str2 = componentCallbacksC1023x.f13297u;
                ComponentCallbacksC1023x componentCallbacksC1023x2 = w4.f13125c;
                if (str2.equals(componentCallbacksC1023x2.f13300x)) {
                    componentCallbacksC1023x2.f13299w = componentCallbacksC1023x;
                    componentCallbacksC1023x2.f13300x = null;
                }
            }
        }
        String str3 = componentCallbacksC1023x.f13300x;
        if (str3 != null) {
            componentCallbacksC1023x.f13299w = aVar.m(str3);
        }
        aVar.z(this);
    }

    public final void h() {
        View view;
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "movefrom CREATE_VIEW: " + componentCallbacksC1023x);
        }
        ViewGroup viewGroup = componentCallbacksC1023x.f13277W;
        if (viewGroup != null && (view = componentCallbacksC1023x.X) != null) {
            viewGroup.removeView(view);
        }
        componentCallbacksC1023x.f13267M.u(1);
        if (componentCallbacksC1023x.X != null) {
            Y y8 = componentCallbacksC1023x.f13286g0;
            y8.c();
            if (y8.f13140u.f8849t.compareTo(EnumC0510o.f8836s) >= 0) {
                componentCallbacksC1023x.f13286g0.b(EnumC0509n.ON_DESTROY);
            }
        }
        componentCallbacksC1023x.f13293q = 1;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.J();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onDestroyView()"));
        }
        androidx.lifecycle.Z zR = componentCallbacksC1023x.r();
        C0113u c0113u = C1532a.f16945c;
        P6.g.e(zR, "store");
        C1482a c1482a = C1482a.f16347b;
        P6.g.e(c1482a, "defaultCreationExtras");
        C2.a aVar = new C2.a(zR, c0113u, c1482a);
        P6.d dVarA = P6.n.a(C1532a.class);
        String strB = dVarA.b();
        if (strB == null) {
            throw new IllegalArgumentException("Local and anonymous classes can not be ViewModels");
        }
        q.j jVar = ((C1532a) aVar.v(dVarA, "androidx.lifecycle.ViewModelProvider.DefaultKey:".concat(strB))).f16946b;
        if (jVar.k() > 0) {
            jVar.l(0).getClass();
            throw new ClassCastException();
        }
        componentCallbacksC1023x.f13263I = false;
        this.f13123a.x(componentCallbacksC1023x, false);
        componentCallbacksC1023x.f13277W = null;
        componentCallbacksC1023x.X = null;
        componentCallbacksC1023x.f13286g0 = null;
        androidx.lifecycle.A a3 = componentCallbacksC1023x.f13287h0;
        a3.getClass();
        androidx.lifecycle.A.a("setValue");
        a3.f8753g++;
        a3.f8751e = null;
        a3.c(null);
        componentCallbacksC1023x.f13261F = false;
    }

    public final void i() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "movefrom ATTACHED: " + componentCallbacksC1023x);
        }
        componentCallbacksC1023x.f13293q = -1;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.K();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onDetach()"));
        }
        P p3 = componentCallbacksC1023x.f13267M;
        if (!p3.f13060J) {
            p3.l();
            componentCallbacksC1023x.f13267M = new P();
        }
        this.f13123a.o(componentCallbacksC1023x, false);
        componentCallbacksC1023x.f13293q = -1;
        componentCallbacksC1023x.f13266L = null;
        componentCallbacksC1023x.f13268N = null;
        componentCallbacksC1023x.f13265K = null;
        if (!componentCallbacksC1023x.f13258B || componentCallbacksC1023x.z()) {
            S s8 = (S) this.f13124b.f1160u;
            if (!((s8.f13101b.containsKey(componentCallbacksC1023x.f13297u) && s8.f13104e) ? s8.f13105f : true)) {
                return;
            }
        }
        if (P.L(3)) {
            Log.d("FragmentManager", "initState called for fragment: " + componentCallbacksC1023x);
        }
        componentCallbacksC1023x.x();
    }

    public final void j() {
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (componentCallbacksC1023x.f13260E && componentCallbacksC1023x.f13261F && !componentCallbacksC1023x.f13263I) {
            if (P.L(3)) {
                Log.d("FragmentManager", "moveto CREATE_VIEW: " + componentCallbacksC1023x);
            }
            Bundle bundle = componentCallbacksC1023x.f13294r;
            Bundle bundle2 = bundle != null ? bundle.getBundle("savedInstanceState") : null;
            componentCallbacksC1023x.W(componentCallbacksC1023x.L(bundle2), null, bundle2);
            View view = componentCallbacksC1023x.X;
            if (view != null) {
                view.setSaveFromParentEnabled(false);
                componentCallbacksC1023x.X.setTag(R.id.fragment_container_view_tag, componentCallbacksC1023x);
                if (componentCallbacksC1023x.f13272R) {
                    componentCallbacksC1023x.X.setVisibility(8);
                }
                Bundle bundle3 = componentCallbacksC1023x.f13294r;
                componentCallbacksC1023x.U(componentCallbacksC1023x.X, bundle3 != null ? bundle3.getBundle("savedInstanceState") : null);
                componentCallbacksC1023x.f13267M.u(2);
                this.f13123a.w(componentCallbacksC1023x, componentCallbacksC1023x.X, false);
                componentCallbacksC1023x.f13293q = 2;
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:145:0x0166, code lost:
    
        continue;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void k() {
        ViewGroup viewGroup;
        ViewGroup viewGroup2;
        ViewGroup viewGroup3;
        boolean z8 = this.f13126d;
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (z8) {
            if (P.L(2)) {
                Log.v("FragmentManager", "Ignoring re-entrant call to moveToExpectedState() for " + componentCallbacksC1023x);
                return;
            }
            return;
        }
        try {
            this.f13126d = true;
            boolean z9 = false;
            while (true) {
                int iD = d();
                int i = componentCallbacksC1023x.f13293q;
                int i5 = 3;
                C2.a aVar = this.f13124b;
                if (iD == i) {
                    if (!z9 && i == -1 && componentCallbacksC1023x.f13258B && !componentCallbacksC1023x.z() && !componentCallbacksC1023x.D) {
                        if (P.L(3)) {
                            Log.d("FragmentManager", "Cleaning up state of never attached fragment: " + componentCallbacksC1023x);
                        }
                        ((S) aVar.f1160u).e(componentCallbacksC1023x, true);
                        aVar.z(this);
                        if (P.L(3)) {
                            Log.d("FragmentManager", "initState called for fragment: " + componentCallbacksC1023x);
                        }
                        componentCallbacksC1023x.x();
                    }
                    if (componentCallbacksC1023x.f13281b0) {
                        if (componentCallbacksC1023x.X != null && (viewGroup = componentCallbacksC1023x.f13277W) != null) {
                            C1013m c1013mI = C1013m.i(viewGroup, componentCallbacksC1023x.q());
                            if (componentCallbacksC1023x.f13272R) {
                                c1013mI.getClass();
                                if (P.L(2)) {
                                    Log.v("FragmentManager", "SpecialEffectsController: Enqueuing hide operation for fragment " + componentCallbacksC1023x);
                                }
                                c1013mI.d(3, 1, this);
                            } else {
                                c1013mI.getClass();
                                if (P.L(2)) {
                                    Log.v("FragmentManager", "SpecialEffectsController: Enqueuing show operation for fragment " + componentCallbacksC1023x);
                                }
                                c1013mI.d(2, 1, this);
                            }
                        }
                        P p3 = componentCallbacksC1023x.f13265K;
                        if (p3 != null && componentCallbacksC1023x.f13257A && P.M(componentCallbacksC1023x)) {
                            p3.f13058G = true;
                        }
                        componentCallbacksC1023x.f13281b0 = false;
                        componentCallbacksC1023x.M(componentCallbacksC1023x.f13272R);
                        componentCallbacksC1023x.f13267M.o();
                    }
                    this.f13126d = false;
                    return;
                }
                if (iD <= i) {
                    switch (i - 1) {
                        case -1:
                            i();
                            break;
                        case u0.f15495q /* 0 */:
                            if (componentCallbacksC1023x.D) {
                                if (((Bundle) ((HashMap) aVar.f1159t).get(componentCallbacksC1023x.f13297u)) == null) {
                                    aVar.L(componentCallbacksC1023x.f13297u, o());
                                }
                            }
                            g();
                            break;
                        case 1:
                            h();
                            componentCallbacksC1023x.f13293q = 1;
                            break;
                        case 2:
                            componentCallbacksC1023x.f13261F = false;
                            componentCallbacksC1023x.f13293q = 2;
                            break;
                        case 3:
                            if (P.L(3)) {
                                Log.d("FragmentManager", "movefrom ACTIVITY_CREATED: " + componentCallbacksC1023x);
                            }
                            if (componentCallbacksC1023x.D) {
                                aVar.L(componentCallbacksC1023x.f13297u, o());
                            } else if (componentCallbacksC1023x.X != null && componentCallbacksC1023x.f13295s == null) {
                                p();
                            }
                            if (componentCallbacksC1023x.X != null && (viewGroup2 = componentCallbacksC1023x.f13277W) != null) {
                                C1013m c1013mI2 = C1013m.i(viewGroup2, componentCallbacksC1023x.q());
                                c1013mI2.getClass();
                                if (P.L(2)) {
                                    Log.v("FragmentManager", "SpecialEffectsController: Enqueuing remove operation for fragment " + componentCallbacksC1023x);
                                }
                                c1013mI2.d(1, 3, this);
                            }
                            componentCallbacksC1023x.f13293q = 3;
                            break;
                        case 4:
                            r();
                            break;
                        case 5:
                            componentCallbacksC1023x.f13293q = 5;
                            break;
                        case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                            l();
                            break;
                    }
                } else {
                    switch (i + 1) {
                        case u0.f15495q /* 0 */:
                            c();
                            break;
                        case 1:
                            e();
                            break;
                        case 2:
                            j();
                            f();
                            break;
                        case 3:
                            a();
                            break;
                        case 4:
                            if (componentCallbacksC1023x.X != null && (viewGroup3 = componentCallbacksC1023x.f13277W) != null) {
                                C1013m c1013mI3 = C1013m.i(viewGroup3, componentCallbacksC1023x.q());
                                int visibility = componentCallbacksC1023x.X.getVisibility();
                                if (visibility == 0) {
                                    i5 = 2;
                                } else if (visibility == 4) {
                                    i5 = 4;
                                } else if (visibility != 8) {
                                    throw new IllegalArgumentException("Unknown visibility " + visibility);
                                }
                                c1013mI3.getClass();
                                I1.a.t(i5, "finalState");
                                if (P.L(2)) {
                                    Log.v("FragmentManager", "SpecialEffectsController: Enqueuing add operation for fragment " + componentCallbacksC1023x);
                                }
                                c1013mI3.d(i5, 2, this);
                            }
                            componentCallbacksC1023x.f13293q = 4;
                            break;
                        case 5:
                            q();
                            break;
                        case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                            componentCallbacksC1023x.f13293q = 6;
                            break;
                        case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                            n();
                            break;
                    }
                }
                z9 = true;
            }
        } catch (Throwable th) {
            this.f13126d = false;
            throw th;
        }
    }

    public final void l() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "movefrom RESUMED: " + componentCallbacksC1023x);
        }
        componentCallbacksC1023x.f13267M.u(5);
        if (componentCallbacksC1023x.X != null) {
            componentCallbacksC1023x.f13286g0.b(EnumC0509n.ON_PAUSE);
        }
        componentCallbacksC1023x.f13285f0.H(EnumC0509n.ON_PAUSE);
        componentCallbacksC1023x.f13293q = 6;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.O();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onPause()"));
        }
        this.f13123a.p(componentCallbacksC1023x, false);
    }

    public final void m(ClassLoader classLoader) {
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        Bundle bundle = componentCallbacksC1023x.f13294r;
        if (bundle == null) {
            return;
        }
        bundle.setClassLoader(classLoader);
        if (componentCallbacksC1023x.f13294r.getBundle("savedInstanceState") == null) {
            componentCallbacksC1023x.f13294r.putBundle("savedInstanceState", new Bundle());
        }
        try {
            componentCallbacksC1023x.f13295s = componentCallbacksC1023x.f13294r.getSparseParcelableArray("viewState");
            componentCallbacksC1023x.f13296t = componentCallbacksC1023x.f13294r.getBundle("viewRegistryState");
            U u8 = (U) componentCallbacksC1023x.f13294r.getParcelable("state");
            if (u8 != null) {
                componentCallbacksC1023x.f13300x = u8.f13109C;
                componentCallbacksC1023x.f13301y = u8.D;
                componentCallbacksC1023x.f13279Z = u8.f13110E;
            }
            if (componentCallbacksC1023x.f13279Z) {
                return;
            }
            componentCallbacksC1023x.f13278Y = true;
        } catch (BadParcelableException e8) {
            throw new IllegalStateException("Failed to restore view hierarchy state for fragment " + componentCallbacksC1023x, e8);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0041  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void n() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "moveto RESUMED: " + componentCallbacksC1023x);
        }
        C1021v c1021v = componentCallbacksC1023x.f13280a0;
        View view = c1021v == null ? null : c1021v.f13255k;
        if (view != null) {
            if (view == componentCallbacksC1023x.X) {
                boolean zRequestFocus = view.requestFocus();
                if (P.L(2)) {
                    StringBuilder sb = new StringBuilder("requestFocus: Restoring focused view ");
                    sb.append(view);
                    sb.append(" ");
                    sb.append(zRequestFocus ? "succeeded" : "failed");
                    sb.append(" on Fragment ");
                    sb.append(componentCallbacksC1023x);
                    sb.append(" resulting in focused view ");
                    sb.append(componentCallbacksC1023x.X.findFocus());
                    Log.v("FragmentManager", sb.toString());
                }
            } else {
                for (ViewParent parent = view.getParent(); parent != null; parent = parent.getParent()) {
                    if (parent == componentCallbacksC1023x.X) {
                        boolean zRequestFocus2 = view.requestFocus();
                        if (P.L(2)) {
                        }
                    }
                }
            }
        }
        componentCallbacksC1023x.k().f13255k = null;
        componentCallbacksC1023x.f13267M.S();
        componentCallbacksC1023x.f13267M.z(true);
        componentCallbacksC1023x.f13293q = 7;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.Q();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onResume()"));
        }
        C0518x c0518x = componentCallbacksC1023x.f13285f0;
        EnumC0509n enumC0509n = EnumC0509n.ON_RESUME;
        c0518x.H(enumC0509n);
        if (componentCallbacksC1023x.X != null) {
            componentCallbacksC1023x.f13286g0.f13140u.H(enumC0509n);
        }
        P p3 = componentCallbacksC1023x.f13267M;
        p3.H = false;
        p3.f13059I = false;
        p3.f13065O.f13106g = false;
        p3.u(7);
        this.f13123a.s(componentCallbacksC1023x, false);
        this.f13124b.L(componentCallbacksC1023x.f13297u, null);
        componentCallbacksC1023x.f13294r = null;
        componentCallbacksC1023x.f13295s = null;
        componentCallbacksC1023x.f13296t = null;
    }

    public final Bundle o() {
        Bundle bundle;
        Bundle bundle2 = new Bundle();
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (componentCallbacksC1023x.f13293q == -1 && (bundle = componentCallbacksC1023x.f13294r) != null) {
            bundle2.putAll(bundle);
        }
        bundle2.putParcelable("state", new U(componentCallbacksC1023x));
        if (componentCallbacksC1023x.f13293q > -1) {
            Bundle bundle3 = new Bundle();
            componentCallbacksC1023x.R(bundle3);
            if (!bundle3.isEmpty()) {
                bundle2.putBundle("savedInstanceState", bundle3);
            }
            this.f13123a.t(componentCallbacksC1023x, bundle3, false);
            Bundle bundle4 = new Bundle();
            componentCallbacksC1023x.f13289j0.q(bundle4);
            if (!bundle4.isEmpty()) {
                bundle2.putBundle("registryState", bundle4);
            }
            Bundle bundleZ = componentCallbacksC1023x.f13267M.Z();
            if (!bundleZ.isEmpty()) {
                bundle2.putBundle("childFragmentManager", bundleZ);
            }
            if (componentCallbacksC1023x.X != null) {
                p();
            }
            SparseArray<? extends Parcelable> sparseArray = componentCallbacksC1023x.f13295s;
            if (sparseArray != null) {
                bundle2.putSparseParcelableArray("viewState", sparseArray);
            }
            Bundle bundle5 = componentCallbacksC1023x.f13296t;
            if (bundle5 != null) {
                bundle2.putBundle("viewRegistryState", bundle5);
            }
        }
        Bundle bundle6 = componentCallbacksC1023x.f13298v;
        if (bundle6 != null) {
            bundle2.putBundle("arguments", bundle6);
        }
        return bundle2;
    }

    public final void p() {
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (componentCallbacksC1023x.X == null) {
            return;
        }
        if (P.L(2)) {
            Log.v("FragmentManager", "Saving view state for fragment " + componentCallbacksC1023x + " with view " + componentCallbacksC1023x.X);
        }
        SparseArray<Parcelable> sparseArray = new SparseArray<>();
        componentCallbacksC1023x.X.saveHierarchyState(sparseArray);
        if (sparseArray.size() > 0) {
            componentCallbacksC1023x.f13295s = sparseArray;
        }
        Bundle bundle = new Bundle();
        componentCallbacksC1023x.f13286g0.f13141v.q(bundle);
        if (bundle.isEmpty()) {
            return;
        }
        componentCallbacksC1023x.f13296t = bundle;
    }

    public final void q() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "moveto STARTED: " + componentCallbacksC1023x);
        }
        componentCallbacksC1023x.f13267M.S();
        componentCallbacksC1023x.f13267M.z(true);
        componentCallbacksC1023x.f13293q = 5;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.S();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onStart()"));
        }
        C0518x c0518x = componentCallbacksC1023x.f13285f0;
        EnumC0509n enumC0509n = EnumC0509n.ON_START;
        c0518x.H(enumC0509n);
        if (componentCallbacksC1023x.X != null) {
            componentCallbacksC1023x.f13286g0.f13140u.H(enumC0509n);
        }
        P p3 = componentCallbacksC1023x.f13267M;
        p3.H = false;
        p3.f13059I = false;
        p3.f13065O.f13106g = false;
        p3.u(5);
        this.f13123a.u(componentCallbacksC1023x, false);
    }

    public final void r() {
        boolean zL = P.L(3);
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13125c;
        if (zL) {
            Log.d("FragmentManager", "movefrom STARTED: " + componentCallbacksC1023x);
        }
        P p3 = componentCallbacksC1023x.f13267M;
        p3.f13059I = true;
        p3.f13065O.f13106g = true;
        p3.u(4);
        if (componentCallbacksC1023x.X != null) {
            componentCallbacksC1023x.f13286g0.b(EnumC0509n.ON_STOP);
        }
        componentCallbacksC1023x.f13285f0.H(EnumC0509n.ON_STOP);
        componentCallbacksC1023x.f13293q = 4;
        componentCallbacksC1023x.f13276V = false;
        componentCallbacksC1023x.T();
        if (!componentCallbacksC1023x.f13276V) {
            throw new d0(AbstractC0844a.k("Fragment ", componentCallbacksC1023x, " did not call through to super.onStop()"));
        }
        this.f13123a.v(componentCallbacksC1023x, false);
    }

    public W(C0853a c0853a, C2.a aVar, ClassLoader classLoader, C1000H c1000h, Bundle bundle) {
        this.f13123a = c0853a;
        this.f13124b = aVar;
        ComponentCallbacksC1023x componentCallbacksC1023xA = ((U) bundle.getParcelable("state")).a(c1000h);
        this.f13125c = componentCallbacksC1023xA;
        componentCallbacksC1023xA.f13294r = bundle;
        Bundle bundle2 = bundle.getBundle("arguments");
        if (bundle2 != null) {
            bundle2.setClassLoader(classLoader);
        }
        componentCallbacksC1023xA.d0(bundle2);
        if (P.L(2)) {
            Log.v("FragmentManager", "Instantiated fragment " + componentCallbacksC1023xA);
        }
    }

    public W(C0853a c0853a, C2.a aVar, ComponentCallbacksC1023x componentCallbacksC1023x, Bundle bundle) {
        this.f13123a = c0853a;
        this.f13124b = aVar;
        this.f13125c = componentCallbacksC1023x;
        componentCallbacksC1023x.f13295s = null;
        componentCallbacksC1023x.f13296t = null;
        componentCallbacksC1023x.f13264J = 0;
        componentCallbacksC1023x.f13261F = false;
        componentCallbacksC1023x.f13257A = false;
        ComponentCallbacksC1023x componentCallbacksC1023x2 = componentCallbacksC1023x.f13299w;
        componentCallbacksC1023x.f13300x = componentCallbacksC1023x2 != null ? componentCallbacksC1023x2.f13297u : null;
        componentCallbacksC1023x.f13299w = null;
        componentCallbacksC1023x.f13294r = bundle;
        componentCallbacksC1023x.f13298v = bundle.getBundle("arguments");
    }
}
