package f6;

import B6.k;
import B6.l;
import B6.u;
import P6.g;
import android.view.View;
import android.view.ViewGroup;
import com.rubensousa.dpadrecyclerview.layoutmanager.PivotLayoutManager;
import d3.V0;
import d5.AbstractC0844a;
import d6.C0845A;
import d6.C0847b;
import d6.p;
import d6.w;
import d6.x;
import e6.C0889a;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import t5.C1554b;
import v.c;
import v.d;
import v.e;
import v.h;
import v.i;
import w.AbstractC1694l;
import w.C1683a;
import w.C1684b;
import w.C1685c;
import w.C1687e;
import w.C1688f;
import w.C1689g;
import w.C1690h;
import w.C1691i;
import w.C1692j;
import w.C1693k;
import w.InterfaceC1686d;

/* JADX INFO: renamed from: f6.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0966a {

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public Object f12862h;
    public Object i;

    public /* synthetic */ C0966a() {
        this.f12855a = 1;
    }

    public void a(C1687e c1687e, int i, ArrayList arrayList, C1692j c1692j) {
        AbstractC1694l abstractC1694l = c1687e.f18141d;
        if (abstractC1694l.f18157c == null) {
            e eVar = (e) this.f12858d;
            if (abstractC1694l == eVar.f17903d || abstractC1694l == eVar.f17904e) {
                return;
            }
            if (c1692j == null) {
                c1692j = new C1692j();
                c1692j.f18151a = null;
                c1692j.f18152b = new ArrayList();
                c1692j.f18151a = abstractC1694l;
                arrayList.add(c1692j);
            }
            abstractC1694l.f18157c = c1692j;
            c1692j.f18152b.add(abstractC1694l);
            C1687e c1687e2 = abstractC1694l.f18162h;
            ArrayList arrayList2 = c1687e2.f18147k;
            int size = arrayList2.size();
            int i5 = 0;
            int i8 = 0;
            while (i8 < size) {
                Object obj = arrayList2.get(i8);
                i8++;
                InterfaceC1686d interfaceC1686d = (InterfaceC1686d) obj;
                if (interfaceC1686d instanceof C1687e) {
                    a((C1687e) interfaceC1686d, i, arrayList, c1692j);
                }
            }
            C1687e c1687e3 = abstractC1694l.i;
            ArrayList arrayList3 = c1687e3.f18147k;
            int size2 = arrayList3.size();
            int i9 = 0;
            while (i9 < size2) {
                Object obj2 = arrayList3.get(i9);
                i9++;
                InterfaceC1686d interfaceC1686d2 = (InterfaceC1686d) obj2;
                if (interfaceC1686d2 instanceof C1687e) {
                    a((C1687e) interfaceC1686d2, i, arrayList, c1692j);
                }
            }
            if (i == 1 && (abstractC1694l instanceof C1693k)) {
                ArrayList arrayList4 = ((C1693k) abstractC1694l).f18153k.f18147k;
                int size3 = arrayList4.size();
                int i10 = 0;
                while (i10 < size3) {
                    Object obj3 = arrayList4.get(i10);
                    i10++;
                    InterfaceC1686d interfaceC1686d3 = (InterfaceC1686d) obj3;
                    if (interfaceC1686d3 instanceof C1687e) {
                        a((C1687e) interfaceC1686d3, i, arrayList, c1692j);
                    }
                }
            }
            ArrayList arrayList5 = c1687e2.f18148l;
            int size4 = arrayList5.size();
            int i11 = 0;
            while (i11 < size4) {
                Object obj4 = arrayList5.get(i11);
                i11++;
                a((C1687e) obj4, i, arrayList, c1692j);
            }
            ArrayList arrayList6 = c1687e3.f18148l;
            int size5 = arrayList6.size();
            int i12 = 0;
            while (i12 < size5) {
                Object obj5 = arrayList6.get(i12);
                i12++;
                a((C1687e) obj5, i, arrayList, c1692j);
            }
            if (i == 1 && (abstractC1694l instanceof C1693k)) {
                ArrayList arrayList7 = ((C1693k) abstractC1694l).f18153k.f18148l;
                int size6 = arrayList7.size();
                while (i5 < size6) {
                    Object obj6 = arrayList7.get(i5);
                    i5++;
                    a((C1687e) obj6, i, arrayList, c1692j);
                }
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:63:0x00b9, code lost:
    
        if (r9 == 2) goto L64;
     */
    /* JADX WARN: Removed duplicated region for block: B:132:0x027d A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:146:0x02c6  */
    /* JADX WARN: Removed duplicated region for block: B:150:0x02ef  */
    /* JADX WARN: Removed duplicated region for block: B:153:0x0302  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00b2  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void b(e eVar) {
        C1693k c1693k;
        int i;
        int i5;
        int i8;
        int i9;
        C1693k c1693k2;
        int i10;
        int i11;
        int i12;
        float f3;
        int i13;
        int i14;
        int i15;
        int i16;
        C1693k c1693k3;
        ArrayList arrayList = eVar.f17925d0;
        int size = arrayList.size();
        char c3 = 0;
        int i17 = 0;
        while (i17 < size) {
            Object obj = arrayList.get(i17);
            i17++;
            d dVar = (d) obj;
            int[] iArr = dVar.f17902c0;
            int i18 = iArr[c3];
            int i19 = iArr[1];
            if (dVar.f17893V == 8) {
                dVar.f17897a = true;
            } else {
                float f7 = dVar.f17913o;
                if (f7 < 1.0f && i18 == 3) {
                    dVar.f17908j = 2;
                }
                float f8 = dVar.f17916r;
                if (f8 < 1.0f && i19 == 3) {
                    dVar.f17909k = 2;
                }
                char c8 = c3;
                if (dVar.f17883L > 0.0f) {
                    if (i18 == 3 && (i19 == 2 || i19 == 1)) {
                        dVar.f17908j = 3;
                    } else if (i19 == 3 && (i18 == 2 || i18 == 1)) {
                        dVar.f17909k = 3;
                    } else if (i18 == 3 && i19 == 3) {
                        if (dVar.f17908j == 0) {
                            dVar.f17908j = 3;
                        }
                        if (dVar.f17909k == 0) {
                            dVar.f17909k = 3;
                        }
                    }
                }
                c cVar = dVar.f17924z;
                c cVar2 = dVar.f17922x;
                if (i18 == 3 && dVar.f17908j == 1 && (cVar2.f17870d == null || cVar.f17870d == null)) {
                    i18 = 2;
                }
                c cVar3 = dVar.f17874A;
                c cVar4 = dVar.f17923y;
                int i20 = (i19 == 3 && dVar.f17909k == 1 && (cVar4.f17870d == null || cVar3.f17870d == null)) ? 2 : i19;
                C1691i c1691i = dVar.f17903d;
                c1691i.f18158d = i18;
                int i21 = dVar.f17908j;
                c1691i.f18155a = i21;
                C1693k c1693k4 = dVar.f17904e;
                c1693k4.f18158d = i20;
                int i22 = dVar.f17909k;
                c1693k4.f18155a = i22;
                ArrayList arrayList2 = arrayList;
                if (i18 != 4 && i18 != 1) {
                    i8 = 2;
                    if (i18 != 2) {
                        int[] iArr2 = eVar.f17902c0;
                        c[] cVarArr = dVar.f17878F;
                        int i23 = 3;
                        if (i18 != 3) {
                            i9 = i8;
                            c1693k2 = c1693k4;
                        } else if (i20 == i8 || i20 == 1) {
                            if (i21 == 3) {
                                if (i20 == 2) {
                                    c1693k3 = c1693k4;
                                    k(2, 0, 2, 0, dVar);
                                } else {
                                    c1693k3 = c1693k4;
                                }
                                int i24 = dVar.i();
                                k(1, (int) ((i24 * dVar.f17883L) + 0.5f), 1, i24, dVar);
                                c1691i.f18159e.d(dVar.l());
                                c1693k3.f18159e.d(dVar.i());
                                dVar.f17897a = true;
                            } else {
                                c1693k2 = c1693k4;
                                if (i21 == 1) {
                                    k(2, 0, i20, 0, dVar);
                                    c1691i.f18159e.f18149m = dVar.l();
                                } else if (i21 == 2) {
                                    int i25 = iArr2[c8];
                                    if (i25 == 1 || i25 == 4) {
                                        k(1, (int) ((f7 * eVar.l()) + 0.5f), i20, dVar.i(), dVar);
                                        c1691i.f18159e.d(dVar.l());
                                        c1693k2.f18159e.d(dVar.i());
                                        dVar.f17897a = true;
                                    }
                                    i9 = 2;
                                    i23 = 3;
                                } else {
                                    if (cVarArr[c8].f17870d == null || cVarArr[1].f17870d == null) {
                                        k(2, 0, i20, 0, dVar);
                                        c1691i.f18159e.d(dVar.l());
                                        c1693k2.f18159e.d(dVar.i());
                                        dVar.f17897a = true;
                                    }
                                    i9 = 2;
                                    i23 = 3;
                                }
                            }
                            c3 = c8;
                            arrayList = arrayList2;
                        } else {
                            c1693k2 = c1693k4;
                            i9 = 2;
                        }
                        if (i20 != i23) {
                            i10 = i9;
                            i11 = 1;
                            i12 = i18;
                        } else if (i18 == i9 || i18 == 1) {
                            if (i22 == i23) {
                                if (i18 == 2) {
                                    k(2, 0, 2, 0, dVar);
                                }
                                int iL = dVar.l();
                                float f9 = dVar.f17883L;
                                if (dVar.f17884M == -1) {
                                    f9 = 1.0f / f9;
                                }
                                k(1, iL, 1, (int) ((iL * f9) + 0.5f), dVar);
                                c1691i.f18159e.d(dVar.l());
                                c1693k2.f18159e.d(dVar.i());
                                dVar.f17897a = true;
                            } else {
                                i11 = 1;
                                i10 = 2;
                                if (i22 == 1) {
                                    k(i18, 0, 2, 0, dVar);
                                    c1693k2.f18159e.f18149m = dVar.i();
                                } else {
                                    i12 = i18;
                                    if (i22 == 2) {
                                        int i26 = iArr2[1];
                                        if (i26 == 1 || i26 == 4) {
                                            k(i12, dVar.l(), 1, (int) ((eVar.i() * f8) + 0.5f), dVar);
                                            c1691i.f18159e.d(dVar.l());
                                            c1693k2.f18159e.d(dVar.i());
                                            dVar.f17897a = true;
                                        }
                                    } else {
                                        f3 = f8;
                                        if (cVarArr[2].f17870d == null || cVarArr[3].f17870d == null) {
                                            k(2, 0, i20, 0, dVar);
                                            c1691i.f18159e.d(dVar.l());
                                            c1693k2.f18159e.d(dVar.i());
                                            dVar.f17897a = true;
                                        }
                                        i13 = 1;
                                        i14 = 3;
                                        if (i12 == i14 && i20 == i14) {
                                            if (i21 != i13 || i22 == i13) {
                                                k(i10, 0, i10, 0, dVar);
                                                c1691i.f18159e.f18149m = dVar.l();
                                                c1693k2.f18159e.f18149m = dVar.i();
                                            } else if (i22 == 2 && i21 == 2 && (((i15 = iArr2[c8]) == i11 || i15 == i11) && ((i16 = iArr2[i13]) == i11 || i16 == i11))) {
                                                k(i11, (int) ((f7 * eVar.l()) + 0.5f), i11, (int) ((eVar.i() * f3) + 0.5f), dVar);
                                                c1691i.f18159e.d(dVar.l());
                                                c1693k2.f18159e.d(dVar.i());
                                                dVar.f17897a = true;
                                            }
                                        }
                                    }
                                }
                            }
                            c3 = c8;
                            arrayList = arrayList2;
                        } else {
                            i14 = i23;
                            i10 = 2;
                            i11 = 1;
                            i12 = i18;
                            f3 = f8;
                            i13 = 1;
                            if (i12 == i14) {
                                if (i21 != i13) {
                                    k(i10, 0, i10, 0, dVar);
                                    c1691i.f18159e.f18149m = dVar.l();
                                    c1693k2.f18159e.f18149m = dVar.i();
                                }
                            }
                            c3 = c8;
                            arrayList = arrayList2;
                        }
                        f3 = f8;
                        i13 = 1;
                        i14 = 3;
                        if (i12 == i14) {
                        }
                        c3 = c8;
                        arrayList = arrayList2;
                    }
                } else if (i20 == 4) {
                    c1693k = c1693k4;
                    i = 1;
                    i5 = i18;
                    int iL2 = dVar.l();
                    if (i5 == 4) {
                        iL2 = (eVar.l() - cVar2.f17871e) - cVar.f17871e;
                        i5 = i;
                    }
                    int i27 = iL2;
                    int i28 = dVar.i();
                    if (i20 == 4) {
                        i28 = (eVar.i() - cVar4.f17871e) - cVar3.f17871e;
                        i20 = i;
                    }
                    k(i5, i27, i20, i28, dVar);
                    c1691i.f18159e.d(dVar.l());
                    c1693k.f18159e.d(dVar.i());
                    dVar.f17897a = true;
                    c3 = c8;
                    arrayList = arrayList2;
                } else if (i20 != 1) {
                    i8 = 2;
                } else {
                    i = 1;
                    c1693k = c1693k4;
                    i5 = i18;
                    int iL22 = dVar.l();
                    if (i5 == 4) {
                    }
                    int i272 = iL22;
                    int i282 = dVar.i();
                    if (i20 == 4) {
                    }
                    k(i5, i272, i20, i282, dVar);
                    c1691i.f18159e.d(dVar.l());
                    c1693k.f18159e.d(dVar.i());
                    dVar.f17897a = true;
                    c3 = c8;
                    arrayList = arrayList2;
                }
            }
        }
    }

    public void c() {
        ArrayList arrayList = (ArrayList) this.f12860f;
        arrayList.clear();
        e eVar = (e) this.f12859e;
        eVar.f17903d.f();
        C1693k c1693k = eVar.f17904e;
        c1693k.f();
        arrayList.add(eVar.f17903d);
        arrayList.add(c1693k);
        ArrayList arrayList2 = eVar.f17925d0;
        int size = arrayList2.size();
        HashSet hashSet = null;
        int i = 0;
        while (i < size) {
            Object obj = arrayList2.get(i);
            i++;
            d dVar = (d) obj;
            if (dVar instanceof h) {
                C1689g c1689g = new C1689g(dVar);
                dVar.f17903d.f();
                dVar.f17904e.f();
                c1689g.f18160f = ((h) dVar).f17994h0;
                arrayList.add(c1689g);
            } else {
                if (dVar.q()) {
                    if (dVar.f17899b == null) {
                        dVar.f17899b = new C1685c(dVar, 0);
                    }
                    if (hashSet == null) {
                        hashSet = new HashSet();
                    }
                    hashSet.add(dVar.f17899b);
                } else {
                    arrayList.add(dVar.f17903d);
                }
                if (dVar.r()) {
                    if (dVar.f17901c == null) {
                        dVar.f17901c = new C1685c(dVar, 1);
                    }
                    if (hashSet == null) {
                        hashSet = new HashSet();
                    }
                    hashSet.add(dVar.f17901c);
                } else {
                    arrayList.add(dVar.f17904e);
                }
                if (dVar instanceof i) {
                    arrayList.add(new C1690h(dVar));
                }
            }
        }
        if (hashSet != null) {
            arrayList.addAll(hashSet);
        }
        int size2 = arrayList.size();
        int i5 = 0;
        while (i5 < size2) {
            Object obj2 = arrayList.get(i5);
            i5++;
            ((AbstractC1694l) obj2).f();
        }
        int size3 = arrayList.size();
        int i8 = 0;
        while (i8 < size3) {
            Object obj3 = arrayList.get(i8);
            i8++;
            AbstractC1694l abstractC1694l = (AbstractC1694l) obj3;
            if (abstractC1694l.f18156b != eVar) {
                abstractC1694l.d();
            }
        }
        ArrayList arrayList3 = (ArrayList) this.i;
        arrayList3.clear();
        e eVar2 = (e) this.f12858d;
        g(eVar2.f17903d, 0, arrayList3);
        g(eVar2.f17904e, 1, arrayList3);
        this.f12856b = false;
    }

    public int d(View view) {
        g.e(view, "view");
        m(view);
        n();
        int iH = h(view);
        x xVar = (x) this.f12861g;
        C0967b c0967b = (C0967b) this.f12862h;
        c0967b.getClass();
        g.e(xVar, "alignment");
        int iA = c0967b.a(xVar);
        boolean zG = c0967b.g(iH, iA, xVar);
        boolean zF = c0967b.f(iH, iA, xVar);
        if (c0967b.f12865c) {
            if (zF) {
                return Math.max(c0967b.f12864b, iH - c0967b.b());
            }
            if (zG) {
                return Math.min(c0967b.f12863a, iH - c0967b.f12867e);
            }
        } else {
            if (zG) {
                return Math.min(c0967b.f12863a, iH - c0967b.f12867e);
            }
            if (zF) {
                return Math.max(c0967b.f12864b, iH - c0967b.b());
            }
        }
        return iH - iA;
    }

    public int e(View view, View view2) {
        int i;
        g.e(view, "view");
        int iD = d(view);
        if (view2 != null && (i = i(view, view2)) != 0) {
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            g.c(layoutParams, "null cannot be cast to non-null type com.rubensousa.dpadrecyclerview.layoutmanager.DpadLayoutParams");
            int[] iArr = ((C0889a) layoutParams).f12498y;
            return (iArr == null || iArr.length == 0) ? iD : (iArr[i] - iArr[0]) + iD;
        }
        return iD;
    }

    public int f(e eVar, int i) {
        ArrayList arrayList;
        int i5;
        int i8;
        long jMax;
        float f3;
        e eVar2 = eVar;
        ArrayList arrayList2 = (ArrayList) this.i;
        int size = arrayList2.size();
        int i9 = 0;
        long jMax2 = 0;
        while (i9 < size) {
            AbstractC1694l abstractC1694l = ((C1692j) arrayList2.get(i9)).f18151a;
            if (!(abstractC1694l instanceof C1685c) ? !(i != 0 ? (abstractC1694l instanceof C1693k) : (abstractC1694l instanceof C1691i)) : ((C1685c) abstractC1694l).f18160f != i) {
                C1687e c1687e = (i == 0 ? eVar2.f17903d : eVar2.f17904e).f18162h;
                C1687e c1687e2 = (i == 0 ? eVar2.f17903d : eVar2.f17904e).i;
                boolean zContains = abstractC1694l.f18162h.f18148l.contains(c1687e);
                C1687e c1687e3 = abstractC1694l.i;
                boolean zContains2 = c1687e3.f18148l.contains(c1687e2);
                long j8 = abstractC1694l.j();
                C1687e c1687e4 = abstractC1694l.f18162h;
                if (zContains && zContains2) {
                    long jB = C1692j.b(c1687e4, 0L);
                    ArrayList arrayList3 = arrayList2;
                    i5 = size;
                    long jA = C1692j.a(c1687e3, 0L);
                    long j9 = jB - j8;
                    int i10 = c1687e3.f18143f;
                    arrayList = arrayList3;
                    i8 = i9;
                    if (j9 >= (-i10)) {
                        j9 += (long) i10;
                    }
                    long j10 = (-jA) - j8;
                    long j11 = c1687e4.f18143f;
                    long j12 = j10 - j11;
                    if (j12 >= j11) {
                        j12 -= j11;
                    }
                    d dVar = abstractC1694l.f18156b;
                    if (i == 0) {
                        f3 = dVar.f17890S;
                    } else if (i == 1) {
                        f3 = dVar.f17891T;
                    } else {
                        dVar.getClass();
                        f3 = -1.0f;
                    }
                    float f7 = f3 > 0.0f ? (long) ((j9 / (1.0f - f3)) + (j12 / f3)) : 0L;
                    jMax = (((long) c1687e4.f18143f) + ((((long) ((f7 * f3) + 0.5f)) + j8) + ((long) AbstractC0844a.f(1.0f, f3, f7, 0.5f)))) - ((long) c1687e3.f18143f);
                } else {
                    arrayList = arrayList2;
                    i5 = size;
                    i8 = i9;
                    jMax = zContains ? Math.max(C1692j.b(c1687e4, c1687e4.f18143f), ((long) c1687e4.f18143f) + j8) : zContains2 ? Math.max(-C1692j.a(c1687e3, c1687e3.f18143f), ((long) (-c1687e3.f18143f)) + j8) : (abstractC1694l.j() + ((long) c1687e4.f18143f)) - ((long) c1687e3.f18143f);
                }
            } else {
                arrayList = arrayList2;
                i5 = size;
                i8 = i9;
                jMax = 0;
            }
            jMax2 = Math.max(jMax2, jMax);
            i9 = i8 + 1;
            eVar2 = eVar;
            size = i5;
            arrayList2 = arrayList;
        }
        return (int) jMax2;
    }

    public void g(AbstractC1694l abstractC1694l, int i, ArrayList arrayList) {
        C1687e c1687e;
        ArrayList arrayList2 = abstractC1694l.f18162h.f18147k;
        int size = arrayList2.size();
        int i5 = 0;
        int i8 = 0;
        while (true) {
            c1687e = abstractC1694l.i;
            if (i8 >= size) {
                break;
            }
            Object obj = arrayList2.get(i8);
            i8++;
            InterfaceC1686d interfaceC1686d = (InterfaceC1686d) obj;
            if (interfaceC1686d instanceof C1687e) {
                a((C1687e) interfaceC1686d, i, arrayList, null);
            } else if (interfaceC1686d instanceof AbstractC1694l) {
                a(((AbstractC1694l) interfaceC1686d).f18162h, i, arrayList, null);
            }
        }
        ArrayList arrayList3 = c1687e.f18147k;
        int size2 = arrayList3.size();
        int i9 = 0;
        while (i9 < size2) {
            Object obj2 = arrayList3.get(i9);
            i9++;
            InterfaceC1686d interfaceC1686d2 = (InterfaceC1686d) obj2;
            if (interfaceC1686d2 instanceof C1687e) {
                a((C1687e) interfaceC1686d2, i, arrayList, null);
            } else if (interfaceC1686d2 instanceof AbstractC1694l) {
                a(((AbstractC1694l) interfaceC1686d2).i, i, arrayList, null);
            }
        }
        if (i == 1) {
            ArrayList arrayList4 = ((C1693k) abstractC1694l).f18153k.f18147k;
            int size3 = arrayList4.size();
            while (i5 < size3) {
                Object obj3 = arrayList4.get(i5);
                i5++;
                InterfaceC1686d interfaceC1686d3 = (InterfaceC1686d) obj3;
                if (interfaceC1686d3 instanceof C1687e) {
                    a((C1687e) interfaceC1686d3, i, arrayList, null);
                }
            }
        }
    }

    public int h(View view) {
        m(view);
        if (this.f12856b) {
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            g.c(layoutParams, "null cannot be cast to non-null type com.rubensousa.dpadrecyclerview.layoutmanager.DpadLayoutParams");
            return view.getTop() + ((C0889a) layoutParams).f12494u;
        }
        ViewGroup.LayoutParams layoutParams2 = view.getLayoutParams();
        g.c(layoutParams2, "null cannot be cast to non-null type com.rubensousa.dpadrecyclerview.layoutmanager.DpadLayoutParams");
        return view.getLeft() + ((C0889a) layoutParams2).f12494u;
    }

    public int i(View view, View view2) {
        if (view != null && view2 != null) {
            Object objE = ((i6.c) this.f12859e).e(view);
            if (objE instanceof p) {
                ((C1554b) ((p) objE)).getClass();
                List list = Collections.EMPTY_LIST;
                g.d(list, "emptyList(...)");
                if (!list.isEmpty()) {
                    while (view2 != view && view2 != null) {
                        if (view2.getId() != -1) {
                            int i = 0;
                            for (Object obj : list) {
                                int i5 = i + 1;
                                if (i < 0) {
                                    l.Z();
                                    throw null;
                                }
                                C0845A c0845a = (C0845A) obj;
                                int id = view2.getId();
                                if (id != -1) {
                                    int i8 = c0845a.f12288w;
                                    if (i8 == -1) {
                                        i8 = c0845a.f12287v;
                                    }
                                    if (i8 == id) {
                                        return i;
                                    }
                                }
                                i = i5;
                            }
                        }
                        Object parent = view2.getParent();
                        view2 = parent instanceof View ? (View) parent : null;
                    }
                }
            }
        }
        return 0;
    }

    public View j(View view, int i) {
        g.e(view, "view");
        Object objE = ((i6.c) this.f12859e).e(view);
        if ((objE instanceof p ? (p) objE : null) != null) {
            List list = Collections.EMPTY_LIST;
            g.d(list, "emptyList(...)");
            if (list != null && i < list.size()) {
                C0845A c0845a = (C0845A) list.get(i);
                int i5 = c0845a.f12288w;
                if (i5 == -1) {
                    i5 = c0845a.f12287v;
                }
                return view.findViewById(i5);
            }
        }
        return null;
    }

    public void k(int i, int i5, int i8, int i9, d dVar) {
        C1684b c1684b = (C1684b) this.f12862h;
        c1684b.f18127a = i;
        c1684b.f18128b = i8;
        c1684b.f18129c = i5;
        c1684b.f18130d = i9;
        ((T0.x) this.f12861g).a(dVar, c1684b);
        dVar.y(c1684b.f18131e);
        dVar.v(c1684b.f18132f);
        dVar.f17921w = c1684b.f18134h;
        int i10 = c1684b.f18133g;
        dVar.f17887P = i10;
        dVar.f17921w = i10 > 0;
    }

    public void l() {
        C1683a c1683a;
        C0966a c0966a = this;
        ArrayList arrayList = ((e) c0966a.f12858d).f17925d0;
        int size = arrayList.size();
        char c3 = 0;
        int i = 0;
        while (i < size) {
            int i5 = i + 1;
            d dVar = (d) arrayList.get(i);
            if (!dVar.f17897a) {
                int[] iArr = dVar.f17902c0;
                int i8 = iArr[c3];
                int i9 = iArr[1];
                int i10 = dVar.f17908j;
                int i11 = dVar.f17909k;
                char c8 = (i8 == 2 || (i8 == 3 && i10 == 1)) ? (char) 1 : c3;
                char c9 = (i9 == 2 || (i9 == 3 && i11 == 1)) ? (char) 1 : c3;
                C1691i c1691i = dVar.f17903d;
                C1688f c1688f = c1691i.f18159e;
                boolean z8 = c1688f.f18146j;
                C1693k c1693k = dVar.f17904e;
                C1688f c1688f2 = c1693k.f18159e;
                boolean z9 = c1688f2.f18146j;
                char c10 = c8;
                if (z8 && z9) {
                    c0966a.k(1, c1688f.f18144g, 1, c1688f2.f18144g, dVar);
                    dVar.f17897a = true;
                } else if (z8 && c9 != 0) {
                    k(1, c1688f.f18144g, 2, c1688f2.f18144g, dVar);
                    if (i9 == 3) {
                        c1693k.f18159e.f18149m = dVar.i();
                    } else {
                        c1693k.f18159e.d(dVar.i());
                        dVar.f17897a = true;
                    }
                } else if (z9 && c10 != 0) {
                    k(2, c1688f.f18144g, 1, c1688f2.f18144g, dVar);
                    if (i8 == 3) {
                        c1691i.f18159e.f18149m = dVar.l();
                    } else {
                        c1691i.f18159e.d(dVar.l());
                        dVar.f17897a = true;
                    }
                }
                if (dVar.f17897a && (c1683a = c1693k.f18154l) != null) {
                    c1683a.d(dVar.f17887P);
                }
                c3 = 0;
                c0966a = this;
            }
            i = i5;
        }
    }

    public void m(View view) {
        List list;
        View view2;
        View view3;
        View viewFindViewById;
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        g.c(layoutParams, "null cannot be cast to non-null type com.rubensousa.dpadrecyclerview.layoutmanager.DpadLayoutParams");
        C0889a c0889a = (C0889a) layoutParams;
        Object objE = ((i6.c) this.f12859e).e(view);
        if (objE == null) {
            return;
        }
        int[] iArr = null;
        if (objE instanceof p) {
            list = Collections.EMPTY_LIST;
            g.d(list, "emptyList(...)");
        } else {
            list = null;
        }
        V0 v02 = (V0) this.i;
        if (list == null || list.isEmpty()) {
            C0847b c0847b = (C0847b) this.f12860f;
            boolean z8 = this.f12856b;
            boolean z9 = this.f12857c;
            v02.getClass();
            g.e(c0847b, "alignment");
            c0889a.f12494u = v02.l(view, view, c0847b, z8, z9);
            return;
        }
        boolean z10 = this.f12856b;
        boolean z11 = this.f12857c;
        v02.getClass();
        int[] iArr2 = c0889a.f12498y;
        if (!list.isEmpty()) {
            if (iArr2 == null || iArr2.length != list.size()) {
                iArr2 = new int[list.size()];
            }
            int i = 0;
            for (Object obj : list) {
                int i5 = i + 1;
                if (i < 0) {
                    l.Z();
                    throw null;
                }
                C0845A c0845a = (C0845A) obj;
                int i8 = c0845a.f12287v;
                if (i8 == -1 || (viewFindViewById = view.findViewById(i8)) == null) {
                    view2 = view;
                    view3 = view2;
                } else {
                    view3 = viewFindViewById;
                    view2 = view;
                }
                iArr2[i] = v02.l(view2, view3, c0845a, z10, z11);
                view = view2;
                i = i5;
            }
            iArr = iArr2;
        }
        c0889a.f12498y = iArr;
        if (iArr == null) {
            c0889a.f12494u = 0;
        } else {
            c0889a.f12494u = iArr[0];
        }
    }

    public void n() {
        int i;
        int i5;
        int i8;
        int i9;
        View viewH;
        View viewH2;
        int i10;
        int i11;
        int i12;
        int iH;
        View viewH3;
        View viewH4;
        PivotLayoutManager pivotLayoutManager = (PivotLayoutManager) this.f12858d;
        int iS = pivotLayoutManager.S();
        if (iS == 0) {
            return;
        }
        boolean z8 = this.f12857c;
        i6.c cVar = (i6.c) this.f12859e;
        int iB = -1;
        PivotLayoutManager pivotLayoutManager2 = cVar.f13524a;
        if (z8) {
            int iB2 = (pivotLayoutManager2.I() == 0 || (viewH2 = pivotLayoutManager2.H(0)) == null) ? -1 : i6.c.b(viewH2);
            if (pivotLayoutManager2.I() != 0 && (viewH = pivotLayoutManager2.H(pivotLayoutManager2.I() - 1)) != null) {
                iB = i6.c.b(viewH);
            }
            i = iB;
            i5 = iB2;
            i8 = iS - 1;
            i9 = 0;
        } else {
            int iB3 = (pivotLayoutManager2.I() == 0 || (viewH4 = pivotLayoutManager2.H(pivotLayoutManager2.I() - 1)) == null) ? -1 : i6.c.b(viewH4);
            i9 = iS - 1;
            if (pivotLayoutManager2.I() != 0 && (viewH3 = pivotLayoutManager2.H(0)) != null) {
                iB = i6.c.b(viewH3);
            }
            i = iB;
            i5 = iB3;
            i8 = 0;
        }
        C0967b c0967b = (C0967b) this.f12862h;
        if (i5 < 0 || i < 0) {
            c0967b.f12870h = Integer.MIN_VALUE;
            c0967b.f12863a = Integer.MIN_VALUE;
            c0967b.f12869g = Integer.MAX_VALUE;
            c0967b.f12864b = Integer.MAX_VALUE;
            return;
        }
        boolean z9 = this.f12857c;
        boolean z10 = z9 ? i5 == i8 : i5 == i9;
        boolean z11 = z9 ? i == i9 : i == i8;
        if (z10 || !C0967b.d(c0967b.f12869g) || z11 || !C0967b.d(c0967b.f12870h)) {
            if (z10) {
                View viewD = pivotLayoutManager.D(i5);
                Integer numValueOf = viewD == null ? null : !this.f12857c ? Integer.valueOf(cVar.f(viewD)) : Integer.valueOf(cVar.h(viewD));
                int iIntValue = numValueOf != null ? numValueOf.intValue() : Integer.MAX_VALUE;
                View viewD2 = pivotLayoutManager.D(i5);
                if (viewD2 != null) {
                    int iH2 = h(viewD2);
                    ViewGroup.LayoutParams layoutParams = viewD2.getLayoutParams();
                    g.c(layoutParams, "null cannot be cast to non-null type com.rubensousa.dpadrecyclerview.layoutmanager.DpadLayoutParams");
                    int[] iArr = ((C0889a) layoutParams).f12498y;
                    if (iArr != null && iArr.length != 0) {
                        if (iArr.length == 0) {
                            throw new NoSuchElementException("Array is empty.");
                        }
                        int i13 = iArr[iArr.length - 1];
                        if (iArr.length == 0) {
                            throw new NoSuchElementException("Array is empty.");
                        }
                        iH2 += i13 - iArr[0];
                    }
                    i10 = iIntValue;
                    i11 = iH2;
                } else {
                    i11 = 0;
                    i10 = iIntValue;
                }
            } else {
                i10 = Integer.MAX_VALUE;
                i11 = Integer.MAX_VALUE;
            }
            if (z11) {
                View viewD3 = pivotLayoutManager.D(i);
                Integer numValueOf2 = viewD3 != null ? !this.f12857c ? Integer.valueOf(cVar.h(viewD3)) : Integer.valueOf(cVar.f(viewD3)) : null;
                int iIntValue2 = numValueOf2 != null ? numValueOf2.intValue() : Integer.MIN_VALUE;
                View viewD4 = pivotLayoutManager.D(i);
                i12 = iIntValue2;
                iH = viewD4 != null ? h(viewD4) : 0;
            } else {
                i12 = Integer.MIN_VALUE;
                iH = Integer.MIN_VALUE;
            }
            if (this.f12857c) {
                x xVar = (x) this.f12861g;
                ((C0967b) this.f12862h).h(i10, i12, i11, iH, xVar, xVar);
                if (cVar.i) {
                    c0967b.f12870h = Integer.MIN_VALUE;
                    c0967b.f12863a = Integer.MIN_VALUE;
                }
                if (cVar.f13532j) {
                    c0967b.f12869g = Integer.MAX_VALUE;
                    c0967b.f12864b = Integer.MAX_VALUE;
                    return;
                }
                return;
            }
            x xVar2 = (x) this.f12861g;
            ((C0967b) this.f12862h).h(i12, i10, iH, i11, xVar2, xVar2);
            if (cVar.i) {
                c0967b.f12869g = Integer.MAX_VALUE;
                c0967b.f12864b = Integer.MAX_VALUE;
            }
            if (cVar.f13532j) {
                c0967b.f12870h = Integer.MIN_VALUE;
                c0967b.f12863a = Integer.MIN_VALUE;
            }
        }
    }

    public String toString() {
        switch (this.f12855a) {
            case 2:
                ArrayList arrayList = new ArrayList();
                if (this.f12856b) {
                    arrayList.add("isRegularFile");
                }
                if (this.f12857c) {
                    arrayList.add("isDirectory");
                }
                Long l8 = (Long) this.f12859e;
                if (l8 != null) {
                    arrayList.add("byteCount=" + l8);
                }
                Long l9 = (Long) this.f12860f;
                if (l9 != null) {
                    arrayList.add("createdAt=" + l9);
                }
                Long l10 = (Long) this.f12861g;
                if (l10 != null) {
                    arrayList.add("lastModifiedAt=" + l10);
                }
                Long l11 = (Long) this.f12862h;
                if (l11 != null) {
                    arrayList.add("lastAccessedAt=" + l11);
                }
                Map map = (Map) this.i;
                if (!map.isEmpty()) {
                    arrayList.add("extras=" + map);
                }
                return k.m0(arrayList, ", ", "FileMetadata(", ")", null, 56);
            default:
                return super.toString();
        }
    }

    public C0966a(PivotLayoutManager pivotLayoutManager, i6.c cVar) {
        this.f12855a = 0;
        this.f12858d = pivotLayoutManager;
        this.f12859e = cVar;
        this.f12860f = new C0847b(0, 0.0f, false, 30);
        this.f12861g = new x(w.f12327t, 0, 0.5f, true, false);
        C0967b c0967b = new C0967b();
        c0967b.f12863a = Integer.MIN_VALUE;
        c0967b.f12864b = Integer.MAX_VALUE;
        c0967b.f12869g = Integer.MAX_VALUE;
        c0967b.f12870h = Integer.MIN_VALUE;
        this.f12862h = c0967b;
        this.i = new V0(8);
        this.f12856b = true;
    }

    public C0966a(boolean z8, boolean z9, x7.x xVar, Long l8, Long l9, Long l10, Long l11, Map map) {
        this.f12855a = 2;
        g.e(map, "extras");
        this.f12856b = z8;
        this.f12857c = z9;
        this.f12858d = xVar;
        this.f12859e = l8;
        this.f12860f = l9;
        this.f12861g = l10;
        this.f12862h = l11;
        this.i = B6.w.p0(map);
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C0966a(boolean z8, boolean z9, x7.x xVar, Long l8, Long l9, Long l10, Long l11) {
        this(z8, z9, xVar, l8, l9, l10, l11, u.f1033q);
        this.f12855a = 2;
    }
}
