package N1;

import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import java.util.ArrayList;

/* JADX INFO: renamed from: N1.o, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0214o extends Z {

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static TimeInterpolator f4601s;

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

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

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

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

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

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

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

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

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

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

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

    public static void h(ArrayList arrayList) {
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            ((t0) arrayList.get(size)).f4654a.animate().cancel();
        }
    }

    @Override // N1.Z
    public final boolean a(t0 t0Var, t0 t0Var2, A7.a aVar, A7.a aVar2) {
        int i;
        int i5;
        int i8 = aVar.f460a;
        int i9 = aVar.f461b;
        if (t0Var2.q()) {
            int i10 = aVar.f460a;
            i5 = aVar.f461b;
            i = i10;
        } else {
            i = aVar2.f460a;
            i5 = aVar2.f461b;
        }
        if (t0Var == t0Var2) {
            return g(t0Var, i8, i9, i, i5);
        }
        View view = t0Var.f4654a;
        float translationX = view.getTranslationX();
        float translationY = view.getTranslationY();
        float alpha = view.getAlpha();
        l(t0Var);
        view.setTranslationX(translationX);
        view.setTranslationY(translationY);
        view.setAlpha(alpha);
        l(t0Var2);
        float f3 = -((int) ((i - i8) - translationX));
        View view2 = t0Var2.f4654a;
        view2.setTranslationX(f3);
        view2.setTranslationY(-((int) ((i5 - i9) - translationY)));
        view2.setAlpha(0.0f);
        ArrayList arrayList = this.f4605k;
        C0212m c0212m = new C0212m();
        c0212m.f4582a = t0Var;
        c0212m.f4583b = t0Var2;
        c0212m.f4584c = i8;
        c0212m.f4585d = i9;
        c0212m.f4586e = i;
        c0212m.f4587f = i5;
        arrayList.add(c0212m);
        return true;
    }

    @Override // N1.Z
    public final void d(t0 t0Var) {
        View view = t0Var.f4654a;
        view.animate().cancel();
        ArrayList arrayList = this.f4604j;
        int size = arrayList.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            if (((C0213n) arrayList.get(size)).f4589a == t0Var) {
                view.setTranslationY(0.0f);
                view.setTranslationX(0.0f);
                c(t0Var);
                arrayList.remove(size);
            }
        }
        j(this.f4605k, t0Var);
        if (this.f4603h.remove(t0Var)) {
            view.setAlpha(1.0f);
            c(t0Var);
        }
        if (this.i.remove(t0Var)) {
            view.setAlpha(1.0f);
            c(t0Var);
        }
        ArrayList arrayList2 = this.f4608n;
        for (int size2 = arrayList2.size() - 1; size2 >= 0; size2--) {
            ArrayList arrayList3 = (ArrayList) arrayList2.get(size2);
            j(arrayList3, t0Var);
            if (arrayList3.isEmpty()) {
                arrayList2.remove(size2);
            }
        }
        ArrayList arrayList4 = this.f4607m;
        for (int size3 = arrayList4.size() - 1; size3 >= 0; size3--) {
            ArrayList arrayList5 = (ArrayList) arrayList4.get(size3);
            int size4 = arrayList5.size() - 1;
            while (true) {
                if (size4 < 0) {
                    break;
                }
                if (((C0213n) arrayList5.get(size4)).f4589a == t0Var) {
                    view.setTranslationY(0.0f);
                    view.setTranslationX(0.0f);
                    c(t0Var);
                    arrayList5.remove(size4);
                    if (arrayList5.isEmpty()) {
                        arrayList4.remove(size3);
                    }
                } else {
                    size4--;
                }
            }
        }
        ArrayList arrayList6 = this.f4606l;
        for (int size5 = arrayList6.size() - 1; size5 >= 0; size5--) {
            ArrayList arrayList7 = (ArrayList) arrayList6.get(size5);
            if (arrayList7.remove(t0Var)) {
                view.setAlpha(1.0f);
                c(t0Var);
                if (arrayList7.isEmpty()) {
                    arrayList6.remove(size5);
                }
            }
        }
        this.f4611q.remove(t0Var);
        this.f4609o.remove(t0Var);
        this.f4612r.remove(t0Var);
        this.f4610p.remove(t0Var);
        i();
    }

    @Override // N1.Z
    public final void e() {
        ArrayList arrayList = this.f4604j;
        int size = arrayList.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            C0213n c0213n = (C0213n) arrayList.get(size);
            View view = c0213n.f4589a.f4654a;
            view.setTranslationY(0.0f);
            view.setTranslationX(0.0f);
            c(c0213n.f4589a);
            arrayList.remove(size);
        }
        ArrayList arrayList2 = this.f4603h;
        for (int size2 = arrayList2.size() - 1; size2 >= 0; size2--) {
            c((t0) arrayList2.get(size2));
            arrayList2.remove(size2);
        }
        ArrayList arrayList3 = this.i;
        int size3 = arrayList3.size();
        while (true) {
            size3--;
            if (size3 < 0) {
                break;
            }
            t0 t0Var = (t0) arrayList3.get(size3);
            t0Var.f4654a.setAlpha(1.0f);
            c(t0Var);
            arrayList3.remove(size3);
        }
        ArrayList arrayList4 = this.f4605k;
        for (int size4 = arrayList4.size() - 1; size4 >= 0; size4--) {
            C0212m c0212m = (C0212m) arrayList4.get(size4);
            t0 t0Var2 = c0212m.f4582a;
            if (t0Var2 != null) {
                k(c0212m, t0Var2);
            }
            t0 t0Var3 = c0212m.f4583b;
            if (t0Var3 != null) {
                k(c0212m, t0Var3);
            }
        }
        arrayList4.clear();
        if (f()) {
            ArrayList arrayList5 = this.f4607m;
            for (int size5 = arrayList5.size() - 1; size5 >= 0; size5--) {
                ArrayList arrayList6 = (ArrayList) arrayList5.get(size5);
                for (int size6 = arrayList6.size() - 1; size6 >= 0; size6--) {
                    C0213n c0213n2 = (C0213n) arrayList6.get(size6);
                    View view2 = c0213n2.f4589a.f4654a;
                    view2.setTranslationY(0.0f);
                    view2.setTranslationX(0.0f);
                    c(c0213n2.f4589a);
                    arrayList6.remove(size6);
                    if (arrayList6.isEmpty()) {
                        arrayList5.remove(arrayList6);
                    }
                }
            }
            ArrayList arrayList7 = this.f4606l;
            for (int size7 = arrayList7.size() - 1; size7 >= 0; size7--) {
                ArrayList arrayList8 = (ArrayList) arrayList7.get(size7);
                for (int size8 = arrayList8.size() - 1; size8 >= 0; size8--) {
                    t0 t0Var4 = (t0) arrayList8.get(size8);
                    t0Var4.f4654a.setAlpha(1.0f);
                    c(t0Var4);
                    arrayList8.remove(size8);
                    if (arrayList8.isEmpty()) {
                        arrayList7.remove(arrayList8);
                    }
                }
            }
            ArrayList arrayList9 = this.f4608n;
            for (int size9 = arrayList9.size() - 1; size9 >= 0; size9--) {
                ArrayList arrayList10 = (ArrayList) arrayList9.get(size9);
                for (int size10 = arrayList10.size() - 1; size10 >= 0; size10--) {
                    C0212m c0212m2 = (C0212m) arrayList10.get(size10);
                    t0 t0Var5 = c0212m2.f4582a;
                    if (t0Var5 != null) {
                        k(c0212m2, t0Var5);
                    }
                    t0 t0Var6 = c0212m2.f4583b;
                    if (t0Var6 != null) {
                        k(c0212m2, t0Var6);
                    }
                    if (arrayList10.isEmpty()) {
                        arrayList9.remove(arrayList10);
                    }
                }
            }
            h(this.f4611q);
            h(this.f4610p);
            h(this.f4609o);
            h(this.f4612r);
            ArrayList arrayList11 = this.f4495b;
            if (arrayList11.size() > 0) {
                arrayList11.get(0).getClass();
                throw new ClassCastException();
            }
            arrayList11.clear();
        }
    }

    @Override // N1.Z
    public final boolean f() {
        return (this.i.isEmpty() && this.f4605k.isEmpty() && this.f4604j.isEmpty() && this.f4603h.isEmpty() && this.f4610p.isEmpty() && this.f4611q.isEmpty() && this.f4609o.isEmpty() && this.f4612r.isEmpty() && this.f4607m.isEmpty() && this.f4606l.isEmpty() && this.f4608n.isEmpty()) ? false : true;
    }

    public final boolean g(t0 t0Var, int i, int i5, int i8, int i9) {
        View view = t0Var.f4654a;
        int translationX = i + ((int) view.getTranslationX());
        int translationY = i5 + ((int) t0Var.f4654a.getTranslationY());
        l(t0Var);
        int i10 = i8 - translationX;
        int i11 = i9 - translationY;
        if (i10 == 0 && i11 == 0) {
            c(t0Var);
            return false;
        }
        if (i10 != 0) {
            view.setTranslationX(-i10);
        }
        if (i11 != 0) {
            view.setTranslationY(-i11);
        }
        ArrayList arrayList = this.f4604j;
        C0213n c0213n = new C0213n();
        c0213n.f4589a = t0Var;
        c0213n.f4590b = translationX;
        c0213n.f4591c = translationY;
        c0213n.f4592d = i8;
        c0213n.f4593e = i9;
        arrayList.add(c0213n);
        return true;
    }

    public final void i() {
        if (f()) {
            return;
        }
        ArrayList arrayList = this.f4495b;
        if (arrayList.size() <= 0) {
            arrayList.clear();
        } else {
            arrayList.get(0).getClass();
            throw new ClassCastException();
        }
    }

    public final void j(ArrayList arrayList, t0 t0Var) {
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            C0212m c0212m = (C0212m) arrayList.get(size);
            if (k(c0212m, t0Var) && c0212m.f4582a == null && c0212m.f4583b == null) {
                arrayList.remove(c0212m);
            }
        }
    }

    public final boolean k(C0212m c0212m, t0 t0Var) {
        if (c0212m.f4583b == t0Var) {
            c0212m.f4583b = null;
        } else {
            if (c0212m.f4582a != t0Var) {
                return false;
            }
            c0212m.f4582a = null;
        }
        t0Var.f4654a.setAlpha(1.0f);
        View view = t0Var.f4654a;
        view.setTranslationX(0.0f);
        view.setTranslationY(0.0f);
        c(t0Var);
        return true;
    }

    public final void l(t0 t0Var) {
        if (f4601s == null) {
            f4601s = new ValueAnimator().getInterpolator();
        }
        t0Var.f4654a.animate().setInterpolator(f4601s);
        d(t0Var);
    }
}
