package A1;

import N1.C0207h;
import N1.S;
import N1.T;
import N1.t0;
import android.opengl.GLES20;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import com.martsnew.tv.ui.home.TvHomeFragment;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class I implements E {

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f69r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public Object f70s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public Object f71t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Object f72u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public Object f73v;

    public /* synthetic */ I() {
        this.f68q = 3;
    }

    public static void a(int i, int i5, String str) throws x0.f {
        int iGlCreateShader = GLES20.glCreateShader(i5);
        GLES20.glShaderSource(iGlCreateShader, str);
        GLES20.glCompileShader(iGlCreateShader);
        int[] iArr = {0};
        GLES20.glGetShaderiv(iGlCreateShader, 35713, iArr, 0);
        AbstractC1709a.f(GLES20.glGetShaderInfoLog(iGlCreateShader) + ", source: \n" + str, iArr[0] == 1);
        GLES20.glAttachShader(i, iGlCreateShader);
        GLES20.glDeleteShader(iGlCreateShader);
        AbstractC1709a.e();
    }

    public void c(View view, int i, boolean z8) {
        RecyclerView recyclerView = ((S) this.f70s).f4489q;
        int childCount = i < 0 ? recyclerView.getChildCount() : j(i);
        ((C0207h) this.f71t).w(childCount, z8);
        if (z8) {
            m(view);
        }
        recyclerView.addView(view, childCount);
        t0 t0VarN = RecyclerView.N(view);
        T t6 = recyclerView.f9019C;
        if (t6 != null && t0VarN != null) {
            t6.j(t0VarN);
        }
        ArrayList arrayList = recyclerView.f9050T;
        if (arrayList != null) {
            for (int size = arrayList.size() - 1; size >= 0; size--) {
                H5.n nVar = (H5.n) recyclerView.f9050T.get(size);
                nVar.getClass();
                P6.g.e(view, "view");
                TvHomeFragment tvHomeFragment = nVar.f3148a;
                tvHomeFragment.f11160L1 = view;
                view.requestFocus();
                ArrayList arrayList2 = tvHomeFragment.J0().f17576P.f9050T;
                if (arrayList2 != null) {
                    arrayList2.remove(nVar);
                }
            }
        }
    }

    public void d(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z8) {
        RecyclerView recyclerView = ((S) this.f70s).f4489q;
        int childCount = i < 0 ? recyclerView.getChildCount() : j(i);
        ((C0207h) this.f71t).w(childCount, z8);
        if (z8) {
            m(view);
        }
        t0 t0VarN = RecyclerView.N(view);
        if (t0VarN != null) {
            if (!t0VarN.l() && !t0VarN.q()) {
                StringBuilder sb = new StringBuilder("Called attach on a child which is not detached: ");
                sb.append(t0VarN);
                throw new IllegalArgumentException(I1.a.l(recyclerView, sb));
            }
            if (RecyclerView.f9009V0) {
                Log.d("RecyclerView", "reAttach " + t0VarN);
            }
            t0VarN.f4662j &= -257;
        } else if (RecyclerView.f9008U0) {
            StringBuilder sb2 = new StringBuilder("No ViewHolder found for child: ");
            sb2.append(view);
            sb2.append(", index: ");
            sb2.append(childCount);
            throw new IllegalArgumentException(I1.a.l(recyclerView, sb2));
        }
        recyclerView.attachViewToParent(view, childCount, layoutParams);
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x0138  */
    @Override // A1.E
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void e(x0.o oVar) {
        x0.t tVar;
        SparseBooleanArray sparseBooleanArray;
        SparseArray sparseArray;
        x0.t tVar2;
        int i;
        int i5;
        char c3;
        x0.t tVar3;
        int i8;
        int i9;
        if (oVar.t() != 2) {
            return;
        }
        J j8 = (J) this.f73v;
        int i10 = j8.f74a;
        int i11 = 0;
        List list = j8.f76c;
        if (i10 == 1 || i10 == 2 || j8.f86n == 1) {
            tVar = (x0.t) list.get(0);
        } else {
            tVar = new x0.t(((x0.t) list.get(0)).d());
            list.add(tVar);
        }
        if ((oVar.t() & 128) == 0) {
            return;
        }
        oVar.G(1);
        int iZ = oVar.z();
        int i12 = 3;
        oVar.G(3);
        T0.H h8 = (T0.H) this.f70s;
        oVar.e(h8.f6361d, 0, 2);
        h8.q(0);
        h8.t(3);
        j8.f92t = h8.i(13);
        oVar.e(h8.f6361d, 0, 2);
        h8.q(0);
        h8.t(4);
        oVar.G(h8.i(12));
        C0005f c0005f = j8.f79f;
        int i13 = j8.f74a;
        if (i13 == 2 && j8.f90r == null) {
            N nA = c0005f.a(21, new L(21, null, 0, null, x0.v.f18555c));
            j8.f90r = nA;
            if (nA != null) {
                nA.b(tVar, j8.f85m, new M(iZ, 21, 8192));
            }
        }
        SparseArray sparseArray2 = (SparseArray) this.f71t;
        sparseArray2.clear();
        SparseIntArray sparseIntArray = (SparseIntArray) this.f72u;
        sparseIntArray.clear();
        int iA = oVar.a();
        while (true) {
            sparseBooleanArray = j8.i;
            if (iA <= 0) {
                break;
            }
            oVar.e(h8.f6361d, i11, 5);
            h8.q(i11);
            int i14 = h8.i(8);
            h8.t(i12);
            int i15 = h8.i(13);
            h8.t(4);
            int i16 = h8.i(12);
            int i17 = oVar.f18540b;
            int i18 = i17 + i16;
            String str = null;
            ArrayList arrayList = null;
            int i19 = -1;
            int iT = 0;
            T0.H h9 = h8;
            while (true) {
                if (oVar.f18540b >= i18) {
                    i5 = iA;
                    break;
                }
                int iT2 = oVar.t();
                i5 = iA;
                int iT3 = oVar.f18540b + oVar.t();
                if (iT3 > i18) {
                    break;
                }
                if (iT2 == 5) {
                    long jV = oVar.v();
                    if (jV == 1094921523) {
                        i19 = 129;
                    } else if (jV == 1161904947) {
                        i19 = 135;
                    } else if (jV == 1094921524) {
                        i19 = 172;
                    } else if (jV == 1212503619) {
                        i19 = 36;
                    }
                    tVar3 = tVar;
                    i8 = iZ;
                    i9 = iT3;
                } else if (iT2 == 106) {
                    tVar3 = tVar;
                    i8 = iZ;
                    i9 = iT3;
                    i19 = 129;
                } else if (iT2 == 122) {
                    tVar3 = tVar;
                    i8 = iZ;
                    i19 = 135;
                    i9 = iT3;
                } else {
                    if (iT2 == 127) {
                        int iT4 = oVar.t();
                        if (iT4 != 21) {
                            if (iT4 == 14) {
                                i19 = 136;
                            } else if (iT4 == 33) {
                                i19 = 139;
                            }
                        }
                    } else if (iT2 == 123) {
                        i19 = 138;
                    } else if (iT2 == 10) {
                        String strTrim = oVar.r(3, StandardCharsets.UTF_8).trim();
                        iT = oVar.t();
                        str = strTrim;
                    } else if (iT2 == 89) {
                        ArrayList arrayList2 = new ArrayList();
                        while (oVar.f18540b < iT3) {
                            String strTrim2 = oVar.r(3, StandardCharsets.UTF_8).trim();
                            oVar.t();
                            x0.t tVar4 = tVar;
                            byte[] bArr = new byte[4];
                            oVar.e(bArr, 0, 4);
                            arrayList2.add(new K(strTrim2, bArr));
                            tVar = tVar4;
                            iT3 = iT3;
                            iZ = iZ;
                        }
                        tVar3 = tVar;
                        i8 = iZ;
                        i9 = iT3;
                        arrayList = arrayList2;
                        i19 = 89;
                    } else {
                        tVar3 = tVar;
                        i8 = iZ;
                        i9 = iT3;
                        if (iT2 == 111) {
                            i19 = 257;
                        }
                    }
                    tVar3 = tVar;
                    i8 = iZ;
                    i9 = iT3;
                }
                oVar.G(i9 - oVar.f18540b);
                tVar = tVar3;
                iA = i5;
                iZ = i8;
            }
            x0.t tVar5 = tVar;
            int i20 = iZ;
            oVar.F(i18);
            L l8 = new L(i19, str, iT, arrayList, Arrays.copyOfRange(oVar.f18539a, i17, i18));
            if (i14 == 6 || i14 == 5) {
                i14 = i19;
            }
            int i21 = i5 - (i16 + 5);
            int i22 = i13 == 2 ? i14 : i15;
            if (sparseBooleanArray.get(i22)) {
                c3 = 21;
            } else {
                c3 = 21;
                N nA2 = (i13 == 2 && i14 == 21) ? j8.f90r : c0005f.a(i14, l8);
                if (i13 != 2 || i15 < sparseIntArray.get(i22, 8192)) {
                    sparseIntArray.put(i22, i15);
                    sparseArray2.put(i22, nA2);
                }
            }
            iA = i21;
            tVar = tVar5;
            h8 = h9;
            iZ = i20;
            i11 = 0;
            i12 = 3;
        }
        x0.t tVar6 = tVar;
        int i23 = iZ;
        int size = sparseIntArray.size();
        int i24 = 0;
        while (true) {
            sparseArray = j8.f81h;
            if (i24 >= size) {
                break;
            }
            int iKeyAt = sparseIntArray.keyAt(i24);
            int iValueAt = sparseIntArray.valueAt(i24);
            sparseBooleanArray.put(iKeyAt, true);
            j8.f82j.put(iValueAt, true);
            N n8 = (N) sparseArray2.valueAt(i24);
            if (n8 != null) {
                if (n8 != j8.f90r) {
                    T0.o oVar2 = j8.f85m;
                    i = i23;
                    M m8 = new M(i, iKeyAt, 8192);
                    tVar2 = tVar6;
                    n8.b(tVar2, oVar2, m8);
                } else {
                    tVar2 = tVar6;
                    i = i23;
                }
                sparseArray.put(iValueAt, n8);
            } else {
                tVar2 = tVar6;
                i = i23;
            }
            i24++;
            tVar6 = tVar2;
            i23 = i;
        }
        if (i13 == 2) {
            if (j8.f87o) {
                return;
            }
            j8.f85m.h();
            j8.f86n = 0;
            j8.f87o = true;
            return;
        }
        sparseArray.remove(this.f69r);
        int i25 = i13 == 1 ? 0 : j8.f86n - 1;
        j8.f86n = i25;
        if (i25 == 0) {
            j8.f85m.h();
            j8.f87o = true;
        }
    }

    public void f(int i) {
        int iJ = j(i);
        ((C0207h) this.f71t).y(iJ);
        RecyclerView recyclerView = ((S) this.f70s).f4489q;
        View childAt = recyclerView.getChildAt(iJ);
        if (childAt != null) {
            t0 t0VarN = RecyclerView.N(childAt);
            if (t0VarN != null) {
                if (t0VarN.l() && !t0VarN.q()) {
                    StringBuilder sb = new StringBuilder("called detach on an already detached child ");
                    sb.append(t0VarN);
                    throw new IllegalArgumentException(I1.a.l(recyclerView, sb));
                }
                if (RecyclerView.f9009V0) {
                    Log.d("RecyclerView", "tmpDetach " + t0VarN);
                }
                t0VarN.b(256);
            }
        } else if (RecyclerView.f9008U0) {
            StringBuilder sb2 = new StringBuilder("No view at offset ");
            sb2.append(iJ);
            throw new IllegalArgumentException(I1.a.l(recyclerView, sb2));
        }
        recyclerView.detachViewFromParent(iJ);
    }

    public int g(String str) throws x0.f {
        int iGlGetAttribLocation = GLES20.glGetAttribLocation(this.f69r, str);
        GLES20.glEnableVertexAttribArray(iGlGetAttribLocation);
        AbstractC1709a.e();
        return iGlGetAttribLocation;
    }

    public View h(int i) {
        return ((S) this.f70s).f4489q.getChildAt(j(i));
    }

    public int i() {
        return ((S) this.f70s).f4489q.getChildCount() - ((ArrayList) this.f72u).size();
    }

    public int j(int i) {
        if (i < 0) {
            return -1;
        }
        int childCount = ((S) this.f70s).f4489q.getChildCount();
        int i5 = i;
        while (i5 < childCount) {
            C0207h c0207h = (C0207h) this.f71t;
            int iS = i - (i5 - c0207h.s(i5));
            if (iS == 0) {
                while (c0207h.u(i5)) {
                    i5++;
                }
                return i5;
            }
            i5 += iS;
        }
        return -1;
    }

    public View k(int i) {
        return ((S) this.f70s).f4489q.getChildAt(i);
    }

    public int l() {
        return ((S) this.f70s).f4489q.getChildCount();
    }

    public void m(View view) {
        ((ArrayList) this.f72u).add(view);
        S s8 = (S) this.f70s;
        t0 t0VarN = RecyclerView.N(view);
        if (t0VarN != null) {
            int i = t0VarN.f4669q;
            View view2 = t0VarN.f4654a;
            if (i != -1) {
                t0VarN.f4668p = i;
            } else {
                t0VarN.f4668p = view2.getImportantForAccessibility();
            }
            RecyclerView recyclerView = s8.f4489q;
            if (!recyclerView.R()) {
                view2.setImportantForAccessibility(4);
            } else {
                t0VarN.f4669q = 4;
                recyclerView.f9037M0.add(t0VarN);
            }
        }
    }

    public int n(View view) {
        int iIndexOfChild = ((S) this.f70s).f4489q.indexOfChild(view);
        if (iIndexOfChild == -1) {
            return -1;
        }
        C0207h c0207h = (C0207h) this.f71t;
        if (c0207h.u(iIndexOfChild)) {
            return -1;
        }
        return iIndexOfChild - c0207h.s(iIndexOfChild);
    }

    public void o(int i) {
        S s8 = (S) this.f70s;
        int i5 = this.f69r;
        if (i5 == 1) {
            throw new IllegalStateException("Cannot call removeView(At) within removeView(At)");
        }
        if (i5 == 2) {
            throw new IllegalStateException("Cannot call removeView(At) within removeViewIfHidden");
        }
        try {
            int iJ = j(i);
            View childAt = s8.f4489q.getChildAt(iJ);
            if (childAt != null) {
                this.f69r = 1;
                this.f73v = childAt;
                if (((C0207h) this.f71t).y(iJ)) {
                    p(childAt);
                }
                s8.i(iJ);
            }
            this.f69r = 0;
            this.f73v = null;
        } catch (Throwable th) {
            this.f69r = 0;
            this.f73v = null;
            throw th;
        }
    }

    public void p(View view) {
        if (((ArrayList) this.f72u).remove(view)) {
            S s8 = (S) this.f70s;
            t0 t0VarN = RecyclerView.N(view);
            if (t0VarN != null) {
                int i = t0VarN.f4668p;
                RecyclerView recyclerView = s8.f4489q;
                if (recyclerView.R()) {
                    t0VarN.f4669q = i;
                    recyclerView.f9037M0.add(t0VarN);
                } else {
                    t0VarN.f4654a.setImportantForAccessibility(i);
                }
                t0VarN.f4668p = 0;
            }
        }
    }

    public String toString() {
        switch (this.f68q) {
            case 1:
                return ((C0207h) this.f71t).toString() + ", hidden list:" + ((ArrayList) this.f72u).size();
            default:
                return super.toString();
        }
    }

    public I(S s8) {
        this.f68q = 1;
        this.f69r = 0;
        this.f70s = s8;
        this.f71t = new C0207h();
        this.f72u = new ArrayList();
    }

    public I(String str, String str2) throws x0.f {
        this.f68q = 4;
        int iGlCreateProgram = GLES20.glCreateProgram();
        this.f69r = iGlCreateProgram;
        AbstractC1709a.e();
        a(iGlCreateProgram, 35633, str);
        a(iGlCreateProgram, 35632, str2);
        GLES20.glLinkProgram(iGlCreateProgram);
        int[] iArr = {0};
        GLES20.glGetProgramiv(iGlCreateProgram, 35714, iArr, 0);
        AbstractC1709a.f("Unable to link shader program: \n" + GLES20.glGetProgramInfoLog(iGlCreateProgram), iArr[0] == 1);
        GLES20.glUseProgram(iGlCreateProgram);
        this.f72u = new HashMap();
        int[] iArr2 = new int[1];
        GLES20.glGetProgramiv(iGlCreateProgram, 35721, iArr2, 0);
        this.f70s = new d3.E[iArr2[0]];
        for (int i = 0; i < iArr2[0]; i++) {
            int i5 = this.f69r;
            int[] iArr3 = new int[1];
            GLES20.glGetProgramiv(i5, 35722, iArr3, 0);
            int i8 = iArr3[0];
            byte[] bArr = new byte[i8];
            GLES20.glGetActiveAttrib(i5, i, i8, new int[1], 0, new int[1], 0, new int[1], 0, bArr, 0);
            int i9 = 0;
            while (true) {
                if (i9 >= i8) {
                    break;
                }
                if (bArr[i9] == 0) {
                    i8 = i9;
                    break;
                }
                i9++;
            }
            String str3 = new String(bArr, 0, i8);
            GLES20.glGetAttribLocation(i5, str3);
            d3.E e8 = new d3.E(16);
            ((d3.E[]) this.f70s)[i] = e8;
            ((HashMap) this.f72u).put(str3, e8);
        }
        this.f73v = new HashMap();
        int[] iArr4 = new int[1];
        GLES20.glGetProgramiv(this.f69r, 35718, iArr4, 0);
        this.f71t = new d3.C[iArr4[0]];
        for (int i10 = 0; i10 < iArr4[0]; i10++) {
            int i11 = this.f69r;
            int[] iArr5 = new int[1];
            GLES20.glGetProgramiv(i11, 35719, iArr5, 0);
            int i12 = iArr5[0];
            byte[] bArr2 = new byte[i12];
            GLES20.glGetActiveUniform(i11, i10, i12, new int[1], 0, new int[1], 0, new int[1], 0, bArr2, 0);
            int i13 = 0;
            while (true) {
                if (i13 >= i12) {
                    break;
                }
                if (bArr2[i13] == 0) {
                    i12 = i13;
                    break;
                }
                i13++;
            }
            String str4 = new String(bArr2, 0, i12);
            GLES20.glGetUniformLocation(i11, str4);
            d3.C c3 = new d3.C(17);
            ((d3.C[]) this.f71t)[i10] = c3;
            ((HashMap) this.f73v).put(str4, c3);
        }
        AbstractC1709a.e();
    }

    public I(T0.x xVar, P.g gVar, byte[] bArr, B0.t0[] t0VarArr, int i) {
        this.f68q = 2;
        this.f70s = xVar;
        this.f71t = gVar;
        this.f72u = bArr;
        this.f73v = t0VarArr;
        this.f69r = i;
    }

    public I(J j8, int i) {
        this.f68q = 0;
        this.f73v = j8;
        this.f70s = new T0.H(5, new byte[5]);
        this.f71t = new SparseArray();
        this.f72u = new SparseIntArray();
        this.f69r = i;
    }

    @Override // A1.E
    public void b(x0.t tVar, T0.o oVar, M m8) {
    }
}
