package o;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Zk0 {
    public static int f;
    public ArrayList a;
    public int b;
    public int c;
    public ArrayList d;
    public int e;

    public final void a(ArrayList arrayList) {
        int size = this.a.size();
        if (this.e != -1 && size > 0) {
            for (int i = 0; i < arrayList.size(); i++) {
                Zk0 zk0 = (Zk0) arrayList.get(i);
                if (this.e == zk0.b) {
                    c(this.c, zk0);
                }
            }
        }
        if (size == 0) {
            arrayList.remove(this);
        }
    }

    public final int b(C2991yL c2991yL, int i) {
        int iN;
        int iN2;
        ArrayList arrayList = this.a;
        if (arrayList.size() == 0) {
            return 0;
        }
        C0556Vl c0556Vl = (C0556Vl) ((C0530Ul) arrayList.get(0)).T;
        c2991yL.t();
        c0556Vl.b(c2991yL, false);
        for (int i2 = 0; i2 < arrayList.size(); i2++) {
            ((C0530Ul) arrayList.get(i2)).b(c2991yL, false);
        }
        if (i == 0 && c0556Vl.z0 > 0) {
            AbstractC1692kh0.i(c0556Vl, c2991yL, arrayList, 0);
        }
        if (i == 1 && c0556Vl.A0 > 0) {
            AbstractC1692kh0.i(c0556Vl, c2991yL, arrayList, 1);
        }
        try {
            c2991yL.p();
        } catch (Exception e) {
            System.err.println(e.toString() + "\n" + Arrays.toString(e.getStackTrace()).replace("[", "   at ").replace(",", "\n   at").replace("]", ""));
        }
        this.d = new ArrayList();
        for (int i3 = 0; i3 < arrayList.size(); i3++) {
            C0530Ul c0530Ul = (C0530Ul) arrayList.get(i3);
            BP bp = new BP(26);
            new WeakReference(c0530Ul);
            C2991yL.n(c0530Ul.I);
            C2991yL.n(c0530Ul.J);
            C2991yL.n(c0530Ul.K);
            C2991yL.n(c0530Ul.L);
            C2991yL.n(c0530Ul.M);
            this.d.add(bp);
        }
        if (i == 0) {
            iN = C2991yL.n(c0556Vl.I);
            iN2 = C2991yL.n(c0556Vl.K);
            c2991yL.t();
        } else {
            iN = C2991yL.n(c0556Vl.J);
            iN2 = C2991yL.n(c0556Vl.L);
            c2991yL.t();
        }
        return iN2 - iN;
    }

    public final void c(int i, Zk0 zk0) {
        int i2 = zk0.b;
        ArrayList arrayList = this.a;
        int size = arrayList.size();
        int i3 = 0;
        while (i3 < size) {
            Object obj = arrayList.get(i3);
            i3++;
            C0530Ul c0530Ul = (C0530Ul) obj;
            ArrayList arrayList2 = zk0.a;
            if (!arrayList2.contains(c0530Ul)) {
                arrayList2.add(c0530Ul);
            }
            if (i == 0) {
                c0530Ul.n0 = i2;
            } else {
                c0530Ul.o0 = i2;
            }
        }
        this.e = i2;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder();
        int i = this.c;
        sb.append(i == 0 ? "Horizontal" : i == 1 ? "Vertical" : i == 2 ? "Both" : "Unknown");
        sb.append(" [");
        sb.append(this.b);
        sb.append("] <");
        String string = sb.toString();
        ArrayList arrayList = this.a;
        int size = arrayList.size();
        int i2 = 0;
        while (i2 < size) {
            Object obj = arrayList.get(i2);
            i2++;
            string = string + " " + ((C0530Ul) obj).h0;
        }
        return AbstractC2462sn.i(string, " >");
    }
}
