package N1;

import M.C0171a;
import M.C0172b;
import android.os.Trace;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import androidx.recyclerview.widget.RecyclerView;
import d5.AbstractC0844a;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Set;
import v0.AbstractC1664c;

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

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final List f4558d;

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final /* synthetic */ RecyclerView f4562h;

    public i0(RecyclerView recyclerView) {
        this.f4562h = recyclerView;
        ArrayList arrayList = new ArrayList();
        this.f4555a = arrayList;
        this.f4556b = null;
        this.f4557c = new ArrayList();
        this.f4558d = Collections.unmodifiableList(arrayList);
        this.f4559e = 2;
        this.f4560f = 2;
    }

    public final void a(t0 t0Var, boolean z8) {
        RecyclerView.k(t0Var);
        RecyclerView recyclerView = this.f4562h;
        v0 v0Var = recyclerView.f9025F0;
        View view = t0Var.f4654a;
        if (v0Var != null) {
            u0 u0Var = v0Var.f4682e;
            M.J.j(view, u0Var != null ? (C0172b) u0Var.f4678e.remove(view) : null);
        }
        if (z8) {
            j0 j0Var = recyclerView.f9022E;
            if (j0Var != null) {
                j0Var.a(t0Var);
            }
            ArrayList arrayList = recyclerView.f9024F;
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                ((j0) arrayList.get(i)).a(t0Var);
            }
            T t6 = recyclerView.f9019C;
            if (t6 != null) {
                t6.l(t0Var);
            }
            if (recyclerView.f9087y0 != null) {
                recyclerView.f9082w.c0(t0Var);
            }
            if (RecyclerView.f9009V0) {
                Log.d("RecyclerView", "dispatchViewRecycled: " + t0Var);
            }
        }
        t0Var.f4671s = null;
        t0Var.f4670r = null;
        h0 h0VarC = c();
        h0VarC.getClass();
        int i5 = t0Var.f4659f;
        ArrayList arrayList2 = h0VarC.a(i5).f4542a;
        if (((g0) h0VarC.f4549a.get(i5)).f4543b <= arrayList2.size()) {
            AbstractC1664c.c(view);
        } else {
            if (RecyclerView.f9008U0 && arrayList2.contains(t0Var)) {
                throw new IllegalArgumentException("this scrap item already exists");
            }
            t0Var.o();
            arrayList2.add(t0Var);
        }
    }

    public final int b(int i) {
        RecyclerView recyclerView = this.f4562h;
        if (i >= 0 && i < recyclerView.f9087y0.b()) {
            return !recyclerView.f9087y0.f4620g ? i : recyclerView.f9078u.i(i, 0);
        }
        StringBuilder sbO = AbstractC0844a.o(i, "invalid position ", ". State item count is ");
        sbO.append(recyclerView.f9087y0.b());
        sbO.append(recyclerView.B());
        throw new IndexOutOfBoundsException(sbO.toString());
    }

    public final h0 c() {
        if (this.f4561g == null) {
            h0 h0Var = new h0();
            h0Var.f4549a = new SparseArray();
            h0Var.f4550b = 0;
            h0Var.f4551c = Collections.newSetFromMap(new IdentityHashMap());
            this.f4561g = h0Var;
            e();
        }
        return this.f4561g;
    }

    public final View d(int i) {
        return l(Long.MAX_VALUE, i).f4654a;
    }

    public final void e() {
        RecyclerView recyclerView;
        T t6;
        h0 h0Var = this.f4561g;
        if (h0Var == null || (t6 = (recyclerView = this.f4562h).f9019C) == null || !recyclerView.f9031J) {
            return;
        }
        h0Var.f4551c.add(t6);
    }

    public final void f(T t6, boolean z8) {
        h0 h0Var = this.f4561g;
        if (h0Var == null) {
            return;
        }
        Set set = h0Var.f4551c;
        set.remove(t6);
        if (set.size() != 0 || z8) {
            return;
        }
        int i = 0;
        while (true) {
            SparseArray sparseArray = h0Var.f4549a;
            if (i >= sparseArray.size()) {
                return;
            }
            ArrayList arrayList = ((g0) sparseArray.get(sparseArray.keyAt(i))).f4542a;
            for (int i5 = 0; i5 < arrayList.size(); i5++) {
                AbstractC1664c.c(((t0) arrayList.get(i5)).f4654a);
            }
            i++;
        }
    }

    public final void g() {
        ArrayList arrayList = this.f4557c;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            h(size);
        }
        arrayList.clear();
        if (RecyclerView.f9012Z0) {
            C0224z c0224z = this.f4562h.f9085x0;
            int[] iArr = c0224z.f4725a;
            if (iArr != null) {
                Arrays.fill(iArr, -1);
            }
            c0224z.f4728d = 0;
        }
    }

    public final void h(int i) {
        if (RecyclerView.f9009V0) {
            Log.d("RecyclerView", "Recycling cached view at index " + i);
        }
        ArrayList arrayList = this.f4557c;
        t0 t0Var = (t0) arrayList.get(i);
        if (RecyclerView.f9009V0) {
            Log.d("RecyclerView", "CachedViewHolder to be recycled: " + t0Var);
        }
        a(t0Var, true);
        arrayList.remove(i);
    }

    public final void i(View view) {
        t0 t0VarN = RecyclerView.N(view);
        boolean zL = t0VarN.l();
        RecyclerView recyclerView = this.f4562h;
        if (zL) {
            recyclerView.removeDetachedView(view, false);
        }
        if (t0VarN.k()) {
            t0VarN.f4666n.m(t0VarN);
        } else if (t0VarN.r()) {
            t0VarN.f4662j &= -33;
        }
        j(t0VarN);
        if (recyclerView.f9061g0 == null || t0VarN.i()) {
            return;
        }
        recyclerView.f9061g0.d(t0VarN);
    }

    /* JADX WARN: Code restructure failed: missing block: B:58:0x00b8, code lost:
    
        r5 = r5 - 1;
     */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0030  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x009d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void j(t0 t0Var) {
        boolean z8;
        boolean z9;
        int i;
        boolean zK = t0Var.k();
        boolean z10 = true;
        RecyclerView recyclerView = this.f4562h;
        View view = t0Var.f4654a;
        if (zK || view.getParent() != null) {
            StringBuilder sb = new StringBuilder("Scrapped or attached views may not be recycled. isScrap:");
            sb.append(t0Var.k());
            sb.append(" isAttached:");
            sb.append(view.getParent() != null);
            sb.append(recyclerView.B());
            throw new IllegalArgumentException(sb.toString());
        }
        if (t0Var.l()) {
            StringBuilder sb2 = new StringBuilder("Tmp detached view should be removed from RecyclerView before it can be recycled: ");
            sb2.append(t0Var);
            throw new IllegalArgumentException(I1.a.l(recyclerView, sb2));
        }
        if (t0Var.q()) {
            throw new IllegalArgumentException(I1.a.l(recyclerView, new StringBuilder("Trying to recycle an ignored view holder. You should first call stopIgnoringView(view) before calling recycle.")));
        }
        if ((t0Var.f4662j & 16) == 0) {
            Field field = M.J.f4065a;
            z8 = view.hasTransientState();
        }
        T t6 = recyclerView.f9019C;
        if (t6 != null && z8) {
            t6.i(t0Var);
        }
        boolean z11 = RecyclerView.f9008U0;
        ArrayList arrayList = this.f4557c;
        if (z11 && arrayList.contains(t0Var)) {
            StringBuilder sb3 = new StringBuilder("cached view received recycle internal? ");
            sb3.append(t0Var);
            throw new IllegalArgumentException(I1.a.l(recyclerView, sb3));
        }
        if (t0Var.i()) {
            if (this.f4560f <= 0 || (t0Var.f4662j & 526) != 0) {
                z9 = false;
            } else {
                int size = arrayList.size();
                if (size >= this.f4560f && size > 0) {
                    h(0);
                    size--;
                }
                if (RecyclerView.f9012Z0 && size > 0) {
                    C0224z c0224z = recyclerView.f9085x0;
                    int i5 = t0Var.f4656c;
                    if (c0224z.f4725a != null) {
                        int i8 = c0224z.f4728d * 2;
                        for (int i9 = 0; i9 < i8; i9 += 2) {
                            if (c0224z.f4725a[i9] == i5) {
                                break;
                            }
                        }
                        i = size - 1;
                        loop1: while (i >= 0) {
                            int i10 = ((t0) arrayList.get(i)).f4656c;
                            C0224z c0224z2 = recyclerView.f9085x0;
                            if (c0224z2.f4725a == null) {
                                break;
                            }
                            int i11 = c0224z2.f4728d * 2;
                            for (int i12 = 0; i12 < i11; i12 += 2) {
                                if (c0224z2.f4725a[i12] == i10) {
                                    break;
                                }
                            }
                            break loop1;
                        }
                        size = i + 1;
                    } else {
                        i = size - 1;
                        loop1: while (i >= 0) {
                        }
                        size = i + 1;
                    }
                }
                arrayList.add(size, t0Var);
                z9 = true;
            }
            if (z9) {
                z10 = false;
            } else {
                a(t0Var, true);
            }
            z = z9;
        } else {
            if (RecyclerView.f9009V0) {
                Log.d("RecyclerView", "trying to recycle a non-recycleable holder. Hopefully, it will re-visit here. We are still removing it from animation lists" + recyclerView.B());
            }
            z10 = false;
        }
        recyclerView.f9082w.c0(t0Var);
        if (z || z10 || !z8) {
            return;
        }
        AbstractC1664c.c(view);
        t0Var.f4671s = null;
        t0Var.f4670r = null;
    }

    public final void k(View view) {
        Z z8;
        t0 t0VarN = RecyclerView.N(view);
        boolean z9 = (t0VarN.f4662j & 12) != 0;
        RecyclerView recyclerView = this.f4562h;
        if (!z9 && t0VarN.m() && (z8 = recyclerView.f9061g0) != null) {
            C0214o c0214o = (C0214o) z8;
            if (t0VarN.e().isEmpty() && c0214o.f4602g && !t0VarN.h()) {
                if (this.f4556b == null) {
                    this.f4556b = new ArrayList();
                }
                t0VarN.f4666n = this;
                t0VarN.f4667o = true;
                this.f4556b.add(t0VarN);
                return;
            }
        }
        if (t0VarN.h() && !t0VarN.j() && !recyclerView.f9019C.f4491b) {
            throw new IllegalArgumentException(I1.a.l(recyclerView, new StringBuilder("Called scrap view with an invalid view. Invalid views cannot be reused from scrap, they should rebound from recycler pool.")));
        }
        t0VarN.f4666n = this;
        t0VarN.f4667o = false;
        this.f4555a.add(t0VarN);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:114:0x01f3  */
    /* JADX WARN: Removed duplicated region for block: B:184:0x0356  */
    /* JADX WARN: Removed duplicated region for block: B:186:0x0359  */
    /* JADX WARN: Removed duplicated region for block: B:256:0x0489  */
    /* JADX WARN: Removed duplicated region for block: B:284:0x0521  */
    /* JADX WARN: Removed duplicated region for block: B:352:0x062b  */
    /* JADX WARN: Removed duplicated region for block: B:353:0x0635  */
    /* JADX WARN: Removed duplicated region for block: B:361:0x064e  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0080  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0082  */
    /* JADX WARN: Type inference failed for: r4v58 */
    /* JADX WARN: Type inference failed for: r4v60 */
    /* JADX WARN: Type inference failed for: r4v63 */
    /* JADX WARN: Type inference failed for: r4v79 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final t0 l(long j8, int i) {
        int i5;
        t0 t0VarH;
        int i8;
        long j9;
        boolean z8;
        boolean z9;
        boolean z10;
        boolean z11;
        ViewGroup.LayoutParams layoutParams;
        C0203d0 c0203d0;
        RecyclerView recyclerViewG;
        t0 t0Var;
        int i9;
        View view;
        ?? r42;
        int size;
        int i10;
        int i11 = 1;
        RecyclerView recyclerView = this.f4562h;
        if (i < 0 || i >= recyclerView.f9087y0.b()) {
            throw new IndexOutOfBoundsException("Invalid item position " + i + "(" + i + "). Item count:" + recyclerView.f9087y0.b() + recyclerView.B());
        }
        p0 p0Var = recyclerView.f9087y0;
        int i12 = 32;
        if (p0Var.f4620g) {
            ArrayList arrayList = this.f4556b;
            if (arrayList == null || (size = arrayList.size()) == 0) {
                t0VarH = null;
                i5 = t0VarH == null ? 1 : 0;
            } else {
                int i13 = 0;
                while (true) {
                    if (i13 < size) {
                        t0VarH = (t0) this.f4556b.get(i13);
                        if (!t0VarH.r() && t0VarH.d() == i) {
                            t0VarH.b(32);
                            break;
                        }
                        i13++;
                    } else if (recyclerView.f9019C.f4491b && (i10 = recyclerView.f9078u.i(i, 0)) > 0 && i10 < recyclerView.f9019C.a()) {
                        long jB = recyclerView.f9019C.b(i10);
                        for (int i14 = 0; i14 < size; i14++) {
                            t0 t0Var2 = (t0) this.f4556b.get(i14);
                            if (!t0Var2.r() && t0Var2.f4658e == jB) {
                                t0Var2.b(32);
                                t0VarH = t0Var2;
                                break;
                            }
                        }
                    }
                }
                t0VarH = null;
                if (t0VarH == null) {
                }
            }
        } else {
            i5 = 0;
            t0VarH = null;
        }
        ArrayList arrayList2 = this.f4557c;
        ArrayList arrayList3 = this.f4555a;
        if (t0VarH == null) {
            int size2 = arrayList3.size();
            int i15 = 0;
            while (i15 < size2) {
                t0 t0Var3 = (t0) arrayList3.get(i15);
                if (!t0Var3.r()) {
                    i8 = i11;
                    if (t0Var3.d() == i && !t0Var3.h() && (p0Var.f4620g || !t0Var3.j())) {
                        t0Var3.b(32);
                        t0VarH = t0Var3;
                        break;
                    }
                } else {
                    i8 = i11;
                }
                i15++;
                i11 = i8;
            }
            i8 = i11;
            ArrayList arrayList4 = (ArrayList) recyclerView.f9080v.f72u;
            int size3 = arrayList4.size();
            int i16 = 0;
            while (true) {
                if (i16 >= size3) {
                    view = null;
                    break;
                }
                view = (View) arrayList4.get(i16);
                t0 t0VarN = RecyclerView.N(view);
                if (t0VarN.d() == i && !t0VarN.h() && !t0VarN.j()) {
                    break;
                }
                i16++;
            }
            if (view == null) {
                int size4 = arrayList2.size();
                int i17 = 0;
                while (true) {
                    if (i17 >= size4) {
                        t0VarH = null;
                        break;
                    }
                    t0VarH = (t0) arrayList2.get(i17);
                    if (t0VarH.h() || t0VarH.d() != i || t0VarH.f()) {
                        i17++;
                    } else {
                        arrayList2.remove(i17);
                        if (RecyclerView.f9009V0) {
                            Log.d("RecyclerView", "getScrapOrHiddenOrCachedHolderForPosition(" + i + ") found match in cache: " + t0VarH);
                        }
                    }
                }
            } else {
                t0 t0VarN2 = RecyclerView.N(view);
                A1.I i18 = recyclerView.f9080v;
                int iIndexOfChild = ((S) i18.f70s).f4489q.indexOfChild(view);
                if (iIndexOfChild < 0) {
                    throw new IllegalArgumentException("view is not a child, cannot hide " + view);
                }
                C0207h c0207h = (C0207h) i18.f71t;
                if (!c0207h.u(iIndexOfChild)) {
                    throw new RuntimeException("trying to unhide a view that was not hidden" + view);
                }
                c0207h.r(iIndexOfChild);
                i18.p(view);
                int iN = recyclerView.f9080v.n(view);
                if (iN == -1) {
                    StringBuilder sb = new StringBuilder("layout index should not be -1 after unhiding a view:");
                    sb.append(t0VarN2);
                    throw new IllegalStateException(I1.a.l(recyclerView, sb));
                }
                recyclerView.f9080v.f(iN);
                k(view);
                t0VarN2.b(8224);
                t0VarH = t0VarN2;
            }
            if (t0VarH != null) {
                if (!t0VarH.j()) {
                    int i19 = t0VarH.f4656c;
                    if (i19 < 0 || i19 >= recyclerView.f9019C.a()) {
                        StringBuilder sb2 = new StringBuilder("Inconsistency detected. Invalid view holder adapter position");
                        sb2.append(t0VarH);
                        throw new IndexOutOfBoundsException(I1.a.l(recyclerView, sb2));
                    }
                    if (p0Var.f4620g || recyclerView.f9019C.c(t0VarH.f4656c) == t0VarH.f4659f) {
                        T t6 = recyclerView.f9019C;
                        r42 = (!t6.f4491b || t0VarH.f4658e == t6.b(t0VarH.f4656c)) ? i8 : 0;
                    }
                } else {
                    if (RecyclerView.f9008U0 && !p0Var.f4620g) {
                        throw new IllegalStateException(I1.a.l(recyclerView, new StringBuilder("should not receive a removed view unless it is pre layout")));
                    }
                    r42 = p0Var.f4620g;
                }
                if (r42 == 0) {
                    t0VarH.b(4);
                    if (t0VarH.k()) {
                        recyclerView.removeDetachedView(t0VarH.f4654a, false);
                        t0VarH.f4666n.m(t0VarH);
                    } else if (t0VarH.r()) {
                        t0VarH.f4662j &= -33;
                    }
                    j(t0VarH);
                    t0VarH = null;
                } else {
                    i5 = i8;
                }
            }
        } else {
            i8 = 1;
        }
        if (t0VarH == null) {
            int i20 = recyclerView.f9078u.i(i, 0);
            if (i20 < 0 || i20 >= recyclerView.f9019C.a()) {
                throw new IndexOutOfBoundsException("Inconsistency detected. Invalid item position " + i + "(offset:" + i20 + ").state:" + p0Var.b() + recyclerView.B());
            }
            int iC = recyclerView.f9019C.c(i20);
            T t8 = recyclerView.f9019C;
            j9 = 3;
            if (t8.f4491b) {
                long jB2 = t8.b(i20);
                int size5 = arrayList3.size() - 1;
                while (true) {
                    if (size5 >= 0) {
                        t0VarH = (t0) arrayList3.get(size5);
                        int i21 = size5;
                        if (t0VarH.f4658e != jB2 || t0VarH.r()) {
                            i9 = i21;
                        } else if (iC == t0VarH.f4659f) {
                            t0VarH.b(i12);
                            if (t0VarH.j() && !p0Var.f4620g) {
                                t0VarH.f4662j = (t0VarH.f4662j & (-15)) | 2;
                            }
                        } else {
                            i9 = i21;
                            arrayList3.remove(i9);
                            View view2 = t0VarH.f4654a;
                            recyclerView.removeDetachedView(view2, false);
                            t0 t0VarN3 = RecyclerView.N(view2);
                            t0VarN3.f4666n = null;
                            t0VarN3.f4667o = false;
                            t0VarN3.f4662j &= -33;
                            j(t0VarN3);
                        }
                        size5 = i9 - 1;
                        i12 = 32;
                    } else {
                        int size6 = arrayList2.size() - 1;
                        while (true) {
                            if (size6 < 0) {
                                break;
                            }
                            t0 t0Var4 = (t0) arrayList2.get(size6);
                            if (t0Var4.f4658e != jB2 || t0Var4.f()) {
                                size6--;
                            } else if (iC == t0Var4.f4659f) {
                                arrayList2.remove(size6);
                                t0VarH = t0Var4;
                            } else {
                                h(size6);
                            }
                        }
                        t0VarH = null;
                    }
                }
                if (t0VarH != null) {
                    t0VarH.f4656c = i20;
                    i5 = i8;
                }
            }
            if (t0VarH == null) {
                if (RecyclerView.f9009V0) {
                    Log.d("RecyclerView", "tryGetViewHolderForPositionByDeadline(" + i + ") fetching from shared pool");
                }
                g0 g0Var = (g0) c().f4549a.get(iC);
                if (g0Var != null) {
                    ArrayList arrayList5 = g0Var.f4542a;
                    if (arrayList5.isEmpty()) {
                        t0Var = null;
                        if (t0Var != null) {
                        }
                        t0VarH = t0Var;
                    } else {
                        for (int size7 = arrayList5.size() - 1; size7 >= 0; size7--) {
                            if (!((t0) arrayList5.get(size7)).f()) {
                                t0Var = (t0) arrayList5.remove(size7);
                                break;
                            }
                        }
                        t0Var = null;
                        if (t0Var != null) {
                            t0Var.o();
                            boolean z12 = RecyclerView.f9008U0;
                        }
                        t0VarH = t0Var;
                    }
                }
            }
            if (t0VarH == null) {
                long nanoTime = recyclerView.getNanoTime();
                if (j8 != Long.MAX_VALUE) {
                    long j10 = this.f4561g.a(iC).f4544c;
                    if (((j10 == 0 || j10 + nanoTime < j8) ? i8 : 0) == 0) {
                        return null;
                    }
                }
                T t9 = recyclerView.f9019C;
                t9.getClass();
                try {
                    if (I.g.a()) {
                        Object[] objArr = new Object[i8];
                        objArr[0] = Integer.valueOf(iC);
                        Trace.beginSection(String.format("RV onCreateViewHolder type=0x%X", objArr));
                    }
                    t0VarH = t9.h(recyclerView, iC);
                    if (t0VarH.f4654a.getParent() != null) {
                        throw new IllegalStateException("ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the attachToRoot parameter of LayoutInflater.inflate(..., boolean attachToRoot)");
                    }
                    t0VarH.f4659f = iC;
                    Trace.endSection();
                    if (RecyclerView.f9012Z0 && (recyclerViewG = RecyclerView.G(t0VarH.f4654a)) != null) {
                        t0VarH.f4655b = new WeakReference(recyclerViewG);
                    }
                    long nanoTime2 = recyclerView.getNanoTime() - nanoTime;
                    g0 g0VarA = this.f4561g.a(iC);
                    long j11 = g0VarA.f4544c;
                    if (j11 != 0) {
                        nanoTime2 = (nanoTime2 / 4) + ((j11 / 4) * 3);
                    }
                    g0VarA.f4544c = nanoTime2;
                    if (RecyclerView.f9009V0) {
                        Log.d("RecyclerView", "tryGetViewHolderForPositionByDeadline created new ViewHolder");
                    }
                } catch (Throwable th) {
                    Trace.endSection();
                    throw th;
                }
            }
        } else {
            j9 = 3;
        }
        if (i5 != 0 && !p0Var.f4620g) {
            int i22 = t0VarH.f4662j;
            if ((i22 & 8192) != 0) {
                t0VarH.f4662j = i22 & (-8193);
                if (p0Var.f4622j) {
                    Z.b(t0VarH);
                    Z z13 = recyclerView.f9061g0;
                    t0VarH.e();
                    z13.getClass();
                    A7.a aVar = new A7.a();
                    aVar.d(t0VarH);
                    recyclerView.c0(t0VarH, aVar);
                }
            }
        }
        boolean z14 = p0Var.f4620g;
        View view3 = t0VarH.f4654a;
        if (!z14 || !t0VarH.g()) {
            if (!t0VarH.g()) {
                if (RecyclerView.f9008U0 && t0VarH.j()) {
                    StringBuilder sb3 = new StringBuilder("Removed holder should be bound and it should come here only in pre-layout. Holder: ");
                    sb3.append(t0VarH);
                    throw new IllegalStateException(I1.a.l(recyclerView, sb3));
                }
                int i23 = recyclerView.f9078u.i(i, 0);
                t0VarH.f4671s = null;
                t0VarH.f4670r = recyclerView;
                int i24 = t0VarH.f4659f;
                long nanoTime3 = recyclerView.getNanoTime();
                if (j8 != Long.MAX_VALUE) {
                    long j12 = this.f4561g.a(i24).f4545d;
                    if (j12 == 0 || j12 + nanoTime3 < j8) {
                    }
                }
                if (t0VarH.l()) {
                    recyclerView.attachViewToParent(view3, recyclerView.getChildCount(), view3.getLayoutParams());
                    z8 = true;
                } else {
                    z8 = false;
                }
                T t10 = recyclerView.f9019C;
                t10.getClass();
                boolean z15 = t0VarH.f4671s == null;
                if (z15) {
                    t0VarH.f4656c = i23;
                    if (t10.f4491b) {
                        t0VarH.f4658e = t10.b(i23);
                    }
                    t0VarH.f4662j = (t0VarH.f4662j & (-520)) | 1;
                    if (I.g.a()) {
                        z9 = false;
                        Trace.beginSection(String.format("RV onBindViewHolder type=0x%X", Integer.valueOf(t0VarH.f4659f)));
                    } else {
                        z9 = false;
                    }
                    t0VarH.f4671s = t10;
                    if (RecyclerView.f9008U0) {
                        if (view3.getParent() == null && view3.isAttachedToWindow() != t0VarH.l()) {
                            throw new IllegalStateException("Temp-detached state out of sync with reality. holder.isTmpDetached(): " + t0VarH.l() + ", attached to window: " + view3.isAttachedToWindow() + ", holder: " + t0VarH);
                        }
                        if (view3.getParent() == null && view3.isAttachedToWindow()) {
                            throw new IllegalStateException("Attempting to bind attached holder with no parent (AKA temp detached): " + t0VarH);
                        }
                    }
                    t0VarH.e();
                    t10.g(t0VarH, i23);
                    if (z15) {
                        ArrayList arrayList6 = t0VarH.f4663k;
                        if (arrayList6 != null) {
                            arrayList6.clear();
                        }
                        t0VarH.f4662j &= -1025;
                        ViewGroup.LayoutParams layoutParams2 = view3.getLayoutParams();
                        if (layoutParams2 instanceof C0203d0) {
                            ((C0203d0) layoutParams2).f4522s = true;
                        }
                        Trace.endSection();
                    }
                    if (z8) {
                        recyclerView.detachViewFromParent(view3);
                    }
                    long nanoTime4 = recyclerView.getNanoTime() - nanoTime3;
                    g0 g0VarA2 = this.f4561g.a(t0VarH.f4659f);
                    long j13 = g0VarA2.f4545d;
                    if (j13 != 0) {
                        nanoTime4 = (nanoTime4 / 4) + ((j13 / 4) * j9);
                    }
                    g0VarA2.f4545d = nanoTime4;
                    AccessibilityManager accessibilityManager = recyclerView.f9048S;
                    if ((accessibilityManager == null || !accessibilityManager.isEnabled()) ? z9 : true) {
                        z10 = true;
                        if (view3.getImportantForAccessibility() == 0) {
                            view3.setImportantForAccessibility(1);
                        }
                        v0 v0Var = recyclerView.f9025F0;
                        if (v0Var != null) {
                            u0 u0Var = v0Var.f4682e;
                            if (u0Var != null ? true : z9) {
                                u0Var.getClass();
                                View.AccessibilityDelegate accessibilityDelegateB = M.J.b(view3);
                                C0172b c0172b = accessibilityDelegateB == null ? null : accessibilityDelegateB instanceof C0171a ? ((C0171a) accessibilityDelegateB).f4095a : new C0172b(accessibilityDelegateB);
                                if (c0172b != null && c0172b != u0Var) {
                                    u0Var.f4678e.put(view3, c0172b);
                                }
                            }
                            M.J.j(view3, u0Var);
                        }
                    } else {
                        z10 = true;
                    }
                    if (p0Var.f4620g) {
                        t0VarH.f4660g = i;
                    }
                    z11 = z10;
                }
            } else if (((t0VarH.f4662j & 2) != 0) || t0VarH.h()) {
            }
            layoutParams = view3.getLayoutParams();
            if (layoutParams != null) {
                c0203d0 = (C0203d0) recyclerView.generateDefaultLayoutParams();
                view3.setLayoutParams(c0203d0);
            } else if (recyclerView.checkLayoutParams(layoutParams)) {
                c0203d0 = (C0203d0) layoutParams;
            } else {
                c0203d0 = (C0203d0) recyclerView.generateLayoutParams(layoutParams);
                view3.setLayoutParams(c0203d0);
            }
            c0203d0.f4520q = t0VarH;
            if (i5 != 0 || !z11) {
                z10 = z9;
            }
            c0203d0.f4523t = z10;
            return t0VarH;
        }
        t0VarH.f4660g = i;
        z11 = false;
        z10 = true;
        z9 = false;
        layoutParams = view3.getLayoutParams();
        if (layoutParams != null) {
        }
        c0203d0.f4520q = t0VarH;
        if (i5 != 0) {
            z10 = z9;
        }
        c0203d0.f4523t = z10;
        return t0VarH;
    }

    public final void m(t0 t0Var) {
        if (t0Var.f4667o) {
            this.f4556b.remove(t0Var);
        } else {
            this.f4555a.remove(t0Var);
        }
        t0Var.f4666n = null;
        t0Var.f4667o = false;
        t0Var.f4662j &= -33;
    }

    public final void n() {
        androidx.recyclerview.widget.a aVar = this.f4562h.D;
        this.f4560f = this.f4559e + (aVar != null ? aVar.f9123z : 0);
        ArrayList arrayList = this.f4557c;
        for (int size = arrayList.size() - 1; size >= 0 && arrayList.size() > this.f4560f; size--) {
            h(size);
        }
    }
}
