package o; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.List; /* loaded from: classes2.dex */ public final class ury { public static T d(RecyclerView.Sts sts, Class cls, int i) { idN idn = new idN(); if (c(sts, null, null, i, idn) == -1) { return null; } for (C16978sqI c16978sqI : idn.c) { if (cls.isInstance(c16978sqI.e)) { return cls.cast(c16978sqI.e); } } return null; } /* JADX WARN: Multi-variable type inference failed */ public static RecyclerView.Sts d(RecyclerView.Sts sts) { if (!(sts instanceof FcI)) { return sts; } FcI fcI = (FcI) sts; ArrayList arrayList = new ArrayList(); fcI.d(arrayList); fcI.c(); for (int size = arrayList.size() - 1; size >= 0; size--) { d(arrayList.get(size)); } arrayList.clear(); return sts; } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r5v0, types: [androidx.recyclerview.widget.RecyclerView$Sts] */ /* JADX WARN: Type inference failed for: r5v1 */ /* JADX WARN: Type inference failed for: r5v2 */ /* JADX WARN: Type inference failed for: r5v7, types: [androidx.recyclerview.widget.RecyclerView$Sts] */ public static int c(RecyclerView.Sts sts, RecyclerView.Sts sts2, Object obj, int i, idN idn) { KBU kbu = new KBU(); if (idn != null) { idn.c.clear(); } if (sts == 0) { return -1; } if (idn != null) { idn.c.add(new C16978sqI(sts, null)); } while (true) { if (i == -1 || sts == sts2) { break; } if (sts instanceof FcI) { kbu.b = null; kbu.a = null; kbu.e = -1; ((FcI) sts).e(kbu, i); i = kbu.e; Object obj2 = kbu.a; if (kbu.b != null && kbu.e != -1 && idn != null) { idn.d(kbu); } sts = kbu.b; if (sts == 0) { break; } } else if (sts2 != null) { i = -1; } } if (sts2 != null && sts != sts2) { i = -1; } if (obj != null && obj != null) { i = -1; } if (i == -1 && idn != null) { idn.c.clear(); } return i; } private static int b(idN idn, int i, int i2, int i3) { List list = idn.c; while (i > i2) { i3 = ((FcI) list.get(i - 1).e).c(list.get(i), i3); if (i3 == -1) { break; } i--; } return i3; } public static int e(idN idn, RecyclerView.Sts sts, RecyclerView.Sts sts2, int i) { List list = idn.c; int size = list.size(); int i2 = sts == null ? size - 1 : -1; int i3 = sts2 == null ? 0 : -1; if (sts != null || sts2 != null) { for (int i4 = 0; i4 < size; i4++) { C16978sqI c16978sqI = list.get(i4); if (sts != null && c16978sqI.e == sts) { i2 = i4; } if (sts2 != null && c16978sqI.e == sts2) { i3 = i4; } } } if (i2 == -1 || i3 == -1 || i3 > i2) { return -1; } return b(idn, i2, i3, i); } }