package com.martsnew.tv.ui.main;

import A5.f;
import A5.h;
import A6.b;
import A6.k;
import B0.RunnableC0014a;
import E1.A;
import E1.C0094a;
import E1.F;
import K2.e;
import K5.a;
import K5.c;
import K5.d;
import K5.g;
import P6.n;
import android.animation.ValueAnimator;
import android.widget.LinearLayout;
import androidx.navigation.fragment.NavHostFragment;
import com.google.android.gms.internal.measurement.AbstractC0707u1;
import com.martsnew.tv.R;
import com.martsnew.tv.customviews.CustomNavigationView;
import com.martsnew.tv.ui.main.TvMainFragment;
import d.x;
import h0.ComponentCallbacksC1023x;
import h0.P;
import java.util.ArrayList;
import java.util.List;
import n4.u0;
import s5.EnumC1528g;
import s5.InterfaceC1529h;
import u5.AbstractC1655y;
import u5.R0;
import y5.AbstractActivityC1764i;
import y5.InterfaceC1759d;
import y5.InterfaceC1760e;
import y5.InterfaceC1761f;
import y5.InterfaceC1762g;

/* JADX INFO: loaded from: classes.dex */
public final class TvMainFragment extends a<g, AbstractC1655y> implements InterfaceC1529h, InterfaceC1762g, InterfaceC1761f, InterfaceC1760e, InterfaceC1759d {

    /* JADX INFO: renamed from: A0, reason: collision with root package name */
    public final k f11165A0;

    /* JADX INFO: renamed from: B0, reason: collision with root package name */
    public final k f11166B0;

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    public final e f11167v0;

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public boolean f11168w0;

    /* JADX INFO: renamed from: x0, reason: collision with root package name */
    public final k f11169x0;

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public F f11170y0;

    /* JADX INFO: renamed from: z0, reason: collision with root package name */
    public NavHostFragment f11171z0;

    public TvMainFragment() {
        A6.e eVarJ = AbstractC0707u1.j(new f(24, new f(23, this)));
        this.f11167v0 = new e(n.a(g.class), new A5.g(eVarJ, 24), new h(this, eVarJ, 10), new A5.g(eVarJ, 25));
        final int i = 0;
        this.f11169x0 = new k(new O6.a(this) { // from class: K5.b

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

            {
                this.f3610r = this;
            }

            @Override // O6.a
            public final Object a() {
                switch (i) {
                    case u0.f15495q /* 0 */:
                        return Integer.valueOf(this.f3610r.s().getDimensionPixelSize(R.dimen.dp_150));
                    case 1:
                        return Integer.valueOf(this.f3610r.s().getDimensionPixelSize(R.dimen.dp_400));
                    default:
                        return new d(this.f3610r);
                }
            }
        });
        final int i5 = 1;
        this.f11165A0 = new k(new O6.a(this) { // from class: K5.b

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

            {
                this.f3610r = this;
            }

            @Override // O6.a
            public final Object a() {
                switch (i5) {
                    case u0.f15495q /* 0 */:
                        return Integer.valueOf(this.f3610r.s().getDimensionPixelSize(R.dimen.dp_150));
                    case 1:
                        return Integer.valueOf(this.f3610r.s().getDimensionPixelSize(R.dimen.dp_400));
                    default:
                        return new d(this.f3610r);
                }
            }
        });
        final int i8 = 2;
        this.f11166B0 = new k(new O6.a(this) { // from class: K5.b

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

            {
                this.f3610r = this;
            }

            @Override // O6.a
            public final Object a() {
                switch (i8) {
                    case u0.f15495q /* 0 */:
                        return Integer.valueOf(this.f3610r.s().getDimensionPixelSize(R.dimen.dp_150));
                    case 1:
                        return Integer.valueOf(this.f3610r.s().getDimensionPixelSize(R.dimen.dp_400));
                    default:
                        return new d(this.f3610r);
                }
            }
        });
    }

    @Override // y5.v, h0.ComponentCallbacksC1023x
    public final void M(boolean z8) {
        F f3;
        A aE;
        super.M(z8);
        if (z8) {
            s0().e(false);
        } else {
            s0().e(this.f11168w0 || (f3 = this.f11170y0) == null || (aE = f3.e()) == null || aE.f1985x != R.id.home);
        }
    }

    @Override // y5.v, h0.ComponentCallbacksC1023x
    public final void Q() {
        super.Q();
        CustomNavigationView customNavigationView = ((AbstractC1655y) f0()).f17832K;
        R0 r02 = customNavigationView.f11117s;
        if (r02 == null) {
            P6.g.h("binding");
            throw null;
        }
        r02.f17656U.clearFocus();
        R0 r03 = customNavigationView.f11117s;
        if (r03 == null) {
            P6.g.h("binding");
            throw null;
        }
        r03.f17658W.clearFocus();
        R0 r04 = customNavigationView.f11117s;
        if (r04 == null) {
            P6.g.h("binding");
            throw null;
        }
        r04.f17654S.clearFocus();
        R0 r05 = customNavigationView.f11117s;
        if (r05 == null) {
            P6.g.h("binding");
            throw null;
        }
        r05.f17655T.clearFocus();
        R0 r06 = customNavigationView.f11117s;
        if (r06 == null) {
            P6.g.h("binding");
            throw null;
        }
        r06.X.clearFocus();
        R0 r07 = customNavigationView.f11117s;
        if (r07 == null) {
            P6.g.h("binding");
            throw null;
        }
        r07.f17657V.clearFocus();
        R0 r08 = customNavigationView.f11117s;
        if (r08 != null) {
            r08.f17653R.clearFocus();
        } else {
            P6.g.h("binding");
            throw null;
        }
    }

    @Override // y5.InterfaceC1761f
    public final void c() {
        P pN;
        List listT;
        if (this.f11168w0) {
            NavHostFragment navHostFragment = this.f11171z0;
            if (navHostFragment != null && (pN = navHostFragment.n()) != null && (listT = pN.f13069c.t()) != null) {
                ArrayList arrayList = new ArrayList();
                for (Object obj : listT) {
                    if (obj instanceof InterfaceC1761f) {
                        arrayList.add(obj);
                    }
                }
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj2 = arrayList.get(i);
                    i++;
                    ((InterfaceC1761f) obj2).c();
                }
            }
            u0();
        }
    }

    @Override // y5.InterfaceC1759d
    public final void d() {
        P pN;
        List listT;
        NavHostFragment navHostFragment = this.f11171z0;
        if (navHostFragment == null || (pN = navHostFragment.n()) == null || (listT = pN.f13069c.t()) == null) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        for (Object obj : listT) {
            if (obj instanceof InterfaceC1759d) {
                arrayList.add(obj);
            }
        }
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj2 = arrayList.get(i);
            i++;
            ((InterfaceC1759d) obj2).d();
        }
    }

    @Override // y5.InterfaceC1760e
    public final void f() {
        P pN;
        List listT;
        NavHostFragment navHostFragment = this.f11171z0;
        if (navHostFragment == null || (pN = navHostFragment.n()) == null || (listT = pN.f13069c.t()) == null) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        for (Object obj : listT) {
            if (obj instanceof InterfaceC1760e) {
                arrayList.add(obj);
            }
        }
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj2 = arrayList.get(i);
            i++;
            ((InterfaceC1760e) obj2).f();
        }
    }

    @Override // y5.v
    public final int g0() {
        return R.layout.fragment_tv_main;
    }

    @Override // y5.InterfaceC1762g
    public final void i() {
        NavHostFragment navHostFragment;
        P pN;
        List listT;
        if (this.f11168w0 || (navHostFragment = this.f11171z0) == null || (pN = navHostFragment.n()) == null || (listT = pN.f13069c.t()) == null) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        for (Object obj : listT) {
            if (obj instanceof InterfaceC1762g) {
                arrayList.add(obj);
            }
        }
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj2 = arrayList.get(i);
            i++;
            ((InterfaceC1762g) obj2).i();
        }
    }

    @Override // y5.v
    public final void p0() {
        P pN;
        x xVarG;
        ((AbstractC1655y) f0()).f17832K.setMenuClickListener(this);
        AbstractC1655y abstractC1655y = (AbstractC1655y) f0();
        boolean zB = h0().f3617d.f16277a.b();
        CustomNavigationView customNavigationView = abstractC1655y.f17832K;
        R0 r02 = customNavigationView.f11117s;
        F f3 = null;
        if (r02 == null) {
            P6.g.h("binding");
            throw null;
        }
        LinearLayout linearLayout = r02.f17657V;
        P6.g.d(linearLayout, "layoutMyList");
        linearLayout.setVisibility(zB ? 0 : 8);
        if (zB) {
            R0 r03 = customNavigationView.f11117s;
            if (r03 == null) {
                P6.g.h("binding");
                throw null;
            }
            r03.f17653R.setNextFocusDownId(r03.f17657V.getId());
            R0 r04 = customNavigationView.f11117s;
            if (r04 == null) {
                P6.g.h("binding");
                throw null;
            }
            r04.f17656U.setNextFocusUpId(r04.f17657V.getId());
        } else {
            R0 r05 = customNavigationView.f11117s;
            if (r05 == null) {
                P6.g.h("binding");
                throw null;
            }
            r05.f17653R.setNextFocusDownId(r05.f17656U.getId());
            R0 r06 = customNavigationView.f11117s;
            if (r06 == null) {
                P6.g.h("binding");
                throw null;
            }
            r06.f17656U.setNextFocusUpId(r06.X.getId());
        }
        ComponentCallbacksC1023x componentCallbacksC1023xC = n().C(R.id.nested_nav_host_fragment);
        NavHostFragment navHostFragment = componentCallbacksC1023xC instanceof NavHostFragment ? (NavHostFragment) componentCallbacksC1023xC : null;
        this.f11171z0 = navHostFragment;
        if (navHostFragment != null && (f3 = navHostFragment.f8979o0) == null) {
            throw new IllegalStateException("NavController is not available before onCreate()");
        }
        this.f11170y0 = f3;
        AbstractActivityC1764i abstractActivityC1764iM = m();
        if (abstractActivityC1764iM != null && (xVarG = abstractActivityC1764iM.g()) != null) {
            d dVarS0 = s0();
            P6.g.e(dVarS0, "onBackPressedCallback");
            xVarG.b(dVarS0);
        }
        NavHostFragment navHostFragment2 = this.f11171z0;
        if (navHostFragment2 != null && (pN = navHostFragment2.n()) != null) {
            pN.f13079n.add(new c(0, this));
        }
        if (h0().f3618e != EnumC1528g.f16901r) {
            v0(h0().f3618e);
        }
    }

    public final d s0() {
        return (d) this.f11166B0.getValue();
    }

    @Override // y5.v
    /* JADX INFO: renamed from: t0, reason: merged with bridge method [inline-methods] */
    public final g h0() {
        return (g) this.f11167v0.getValue();
    }

    public final void u0() {
        this.f11168w0 = false;
        ValueAnimator valueAnimatorOfInt = ValueAnimator.ofInt(((AbstractC1655y) f0()).f17832K.getMeasuredWidth(), ((Number) this.f11169x0.getValue()).intValue());
        int i = CustomNavigationView.f11114t;
        CustomNavigationView customNavigationView = ((AbstractC1655y) f0()).f17832K;
        P6.g.d(customNavigationView, "leftMenu");
        P6.g.b(valueAnimatorOfInt);
        s7.d.b(customNavigationView, valueAnimatorOfInt);
        CustomNavigationView customNavigationView2 = ((AbstractC1655y) f0()).f17832K;
        customNavigationView2.f(false);
        customNavigationView2.b(false);
        customNavigationView2.setBackgroundColor(customNavigationView2.getContext().getColor(R.color.colorBackground));
        ((AbstractC1655y) f0()).f17832K.clearFocus();
    }

    public final void v0(EnumC1528g enumC1528g) {
        F f3;
        F f7;
        F f8;
        F f9;
        F f10;
        P6.g.e(enumC1528g, "menuId");
        switch (enumC1528g.ordinal()) {
            case u0.f15495q /* 0 */:
                h0().f3618e = enumC1528g;
                F f11 = this.f11170y0;
                if (f11 != null && !f11.l(R.id.search, false) && (f3 = this.f11170y0) != null) {
                    f3.h(R.id.search, null);
                }
                break;
            case 1:
                h0().f3618e = enumC1528g;
                F f12 = this.f11170y0;
                if (f12 != null) {
                    f12.l(R.id.home, false);
                }
                break;
            case 2:
                h0().f3618e = enumC1528g;
                F f13 = this.f11170y0;
                if (f13 != null && !f13.l(R.id.movies, false) && (f7 = this.f11170y0) != null) {
                    f7.h(R.id.movies, null);
                }
                break;
            case 3:
                h0().f3618e = enumC1528g;
                F f14 = this.f11170y0;
                if (f14 != null && !f14.l(R.id.tvSeries, false) && (f8 = this.f11170y0) != null) {
                    f8.h(R.id.tvSeries, null);
                }
                break;
            case 4:
                h0().f3618e = enumC1528g;
                F f15 = this.f11170y0;
                if (f15 != null && !f15.l(R.id.genres, false) && (f9 = this.f11170y0) != null) {
                    f9.h(R.id.genres, null);
                }
                break;
            case 5:
                h0().f3618e = enumC1528g;
                F f16 = this.f11170y0;
                if (f16 != null && !f16.l(R.id.myList, false) && (f10 = this.f11170y0) != null) {
                    f10.h(R.id.myList, null);
                }
                break;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                j0(new C0094a());
                break;
            default:
                throw new b();
        }
        u0();
    }

    public final void w0() {
        ValueAnimator valueAnimatorOfInt = ValueAnimator.ofInt(((AbstractC1655y) f0()).f17832K.getMeasuredWidth(), ((Number) this.f11165A0.getValue()).intValue());
        this.f11168w0 = true;
        s0().e(true);
        int i = CustomNavigationView.f11114t;
        CustomNavigationView customNavigationView = ((AbstractC1655y) f0()).f17832K;
        P6.g.d(customNavigationView, "leftMenu");
        P6.g.b(valueAnimatorOfInt);
        s7.d.b(customNavigationView, valueAnimatorOfInt);
        CustomNavigationView customNavigationView2 = ((AbstractC1655y) f0()).f17832K;
        customNavigationView2.getClass();
        customNavigationView2.postDelayed(new RunnableC0014a(25, customNavigationView2), 100L);
    }
}
