package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Vl, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0556Vl extends C0530Ul {
    public int A0;
    public C0421Qg[] B0;
    public C0421Qg[] C0;
    public int D0;
    public boolean E0;
    public boolean F0;
    public WeakReference G0;
    public WeakReference H0;
    public WeakReference I0;
    public WeakReference J0;
    public final HashSet K0;
    public final C1778ld L0;
    public ArrayList q0 = new ArrayList();
    public final C3126zm0 r0 = new C3126zm0(this);
    public final C3135zr s0;
    public int t0;
    public C0167Gl u0;
    public boolean v0;
    public final C2991yL w0;
    public int x0;
    public int y0;
    public int z0;

    public C0556Vl() {
        C3135zr c3135zr = new C3135zr();
        c3135zr.b = true;
        c3135zr.c = true;
        c3135zr.f = new ArrayList();
        new ArrayList();
        c3135zr.h = null;
        c3135zr.i = new C1778ld();
        c3135zr.g = new ArrayList();
        c3135zr.d = this;
        c3135zr.e = this;
        this.s0 = c3135zr;
        this.u0 = null;
        this.v0 = false;
        this.w0 = new C2991yL();
        this.z0 = 0;
        this.A0 = 0;
        this.B0 = new C0421Qg[4];
        this.C0 = new C0421Qg[4];
        this.D0 = 257;
        this.E0 = false;
        this.F0 = false;
        this.G0 = null;
        this.H0 = null;
        this.I0 = null;
        this.J0 = null;
        this.K0 = new HashSet();
        this.L0 = new C1778ld();
    }

    public static void V(C0530Ul c0530Ul, C0167Gl c0167Gl, C1778ld c1778ld) {
        int i;
        int i2;
        if (c0167Gl == null) {
            return;
        }
        int i3 = c0530Ul.g0;
        int[] iArr = c0530Ul.t;
        if (i3 == 8 || (c0530Ul instanceof C2604uE) || (c0530Ul instanceof C0651Zc)) {
            c1778ld.e = 0;
            c1778ld.f = 0;
            return;
        }
        int[] iArr2 = c0530Ul.p0;
        c1778ld.a = iArr2[0];
        c1778ld.b = iArr2[1];
        c1778ld.c = c0530Ul.q();
        c1778ld.d = c0530Ul.k();
        c1778ld.i = false;
        c1778ld.j = 0;
        boolean z = c1778ld.a == 3;
        boolean z2 = c1778ld.b == 3;
        boolean z3 = z && c0530Ul.W > 0.0f;
        boolean z4 = z2 && c0530Ul.W > 0.0f;
        if (z && c0530Ul.t(0) && c0530Ul.r == 0 && !z3) {
            c1778ld.a = 2;
            if (z2 && c0530Ul.s == 0) {
                c1778ld.a = 1;
            }
            z = false;
        }
        if (z2 && c0530Ul.t(1) && c0530Ul.s == 0 && !z4) {
            c1778ld.b = 2;
            if (z && c0530Ul.r == 0) {
                c1778ld.b = 1;
            }
            z2 = false;
        }
        if (c0530Ul.A()) {
            c1778ld.a = 1;
            z = false;
        }
        if (c0530Ul.B()) {
            c1778ld.b = 1;
            z2 = false;
        }
        if (z3) {
            if (iArr[0] == 4) {
                c1778ld.a = 1;
            } else if (!z2) {
                if (c1778ld.b == 1) {
                    i2 = c1778ld.d;
                } else {
                    c1778ld.a = 2;
                    c0167Gl.b(c0530Ul, c1778ld);
                    i2 = c1778ld.f;
                }
                c1778ld.a = 1;
                c1778ld.c = (int) (c0530Ul.W * i2);
            }
        }
        if (z4) {
            if (iArr[1] == 4) {
                c1778ld.b = 1;
            } else if (!z) {
                if (c1778ld.a == 1) {
                    i = c1778ld.c;
                } else {
                    c1778ld.b = 2;
                    c0167Gl.b(c0530Ul, c1778ld);
                    i = c1778ld.e;
                }
                c1778ld.b = 1;
                if (c0530Ul.X == -1) {
                    c1778ld.d = (int) (i / c0530Ul.W);
                } else {
                    c1778ld.d = (int) (c0530Ul.W * i);
                }
            }
        }
        c0167Gl.b(c0530Ul, c1778ld);
        c0530Ul.O(c1778ld.e);
        c0530Ul.L(c1778ld.f);
        c0530Ul.E = c1778ld.h;
        c0530Ul.I(c1778ld.g);
        c1778ld.j = 0;
    }

    @Override // o.C0530Ul
    public final void C() {
        this.w0.t();
        this.x0 = 0;
        this.y0 = 0;
        this.q0.clear();
        super.C();
    }

    @Override // o.C0530Ul
    public final void F(C3126zm0 c3126zm0) {
        super.F(c3126zm0);
        int size = this.q0.size();
        for (int i = 0; i < size; i++) {
            ((C0530Ul) this.q0.get(i)).F(c3126zm0);
        }
    }

    @Override // o.C0530Ul
    public final void P(boolean z, boolean z2) {
        super.P(z, z2);
        int size = this.q0.size();
        for (int i = 0; i < size; i++) {
            ((C0530Ul) this.q0.get(i)).P(z, z2);
        }
    }

    public final void R(C0530Ul c0530Ul, int i) {
        if (i == 0) {
            int i2 = this.z0 + 1;
            C0421Qg[] c0421QgArr = this.C0;
            if (i2 >= c0421QgArr.length) {
                this.C0 = (C0421Qg[]) Arrays.copyOf(c0421QgArr, c0421QgArr.length * 2);
            }
            C0421Qg[] c0421QgArr2 = this.C0;
            int i3 = this.z0;
            c0421QgArr2[i3] = new C0421Qg(c0530Ul, 0, this.v0);
            this.z0 = i3 + 1;
            return;
        }
        if (i == 1) {
            int i4 = this.A0 + 1;
            C0421Qg[] c0421QgArr3 = this.B0;
            if (i4 >= c0421QgArr3.length) {
                this.B0 = (C0421Qg[]) Arrays.copyOf(c0421QgArr3, c0421QgArr3.length * 2);
            }
            C0421Qg[] c0421QgArr4 = this.B0;
            int i5 = this.A0;
            c0421QgArr4[i5] = new C0421Qg(c0530Ul, 1, this.v0);
            this.A0 = i5 + 1;
        }
    }

    public final void S(C2991yL c2991yL) {
        C0556Vl c0556Vl;
        C2991yL c2991yL2;
        boolean zW = W(64);
        b(c2991yL, zW);
        int size = this.q0.size();
        boolean z = false;
        for (int i = 0; i < size; i++) {
            C0530Ul c0530Ul = (C0530Ul) this.q0.get(i);
            boolean[] zArr = c0530Ul.S;
            zArr[0] = false;
            zArr[1] = false;
            if (c0530Ul instanceof C0651Zc) {
                z = true;
            }
        }
        if (z) {
            for (int i2 = 0; i2 < size; i2++) {
                C0530Ul c0530Ul2 = (C0530Ul) this.q0.get(i2);
                if (c0530Ul2 instanceof C0651Zc) {
                    C0651Zc c0651Zc = (C0651Zc) c0530Ul2;
                    for (int i3 = 0; i3 < c0651Zc.r0; i3++) {
                        C0530Ul c0530Ul3 = c0651Zc.q0[i3];
                        if (c0651Zc.t0 || c0530Ul3.c()) {
                            int i4 = c0651Zc.s0;
                            if (i4 == 0 || i4 == 1) {
                                c0530Ul3.S[0] = true;
                            } else if (i4 == 2 || i4 == 3) {
                                c0530Ul3.S[1] = true;
                            }
                        }
                    }
                }
            }
        }
        HashSet hashSet = this.K0;
        hashSet.clear();
        for (int i5 = 0; i5 < size; i5++) {
            C0530Ul c0530Ul4 = (C0530Ul) this.q0.get(i5);
            c0530Ul4.getClass();
            boolean z2 = c0530Ul4 instanceof C2199pz;
            if (z2 || (c0530Ul4 instanceof C2604uE)) {
                if (z2) {
                    hashSet.add(c0530Ul4);
                } else {
                    c0530Ul4.b(c2991yL, zW);
                }
            }
        }
        while (hashSet.size() > 0) {
            int size2 = hashSet.size();
            Iterator it = hashSet.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                C2199pz c2199pz = (C2199pz) ((C0530Ul) it.next());
                for (int i6 = 0; i6 < c2199pz.r0; i6++) {
                    if (hashSet.contains(c2199pz.q0[i6])) {
                        c2199pz.b(c2991yL, zW);
                        hashSet.remove(c2199pz);
                        break;
                    }
                }
            }
            if (size2 == hashSet.size()) {
                Iterator it2 = hashSet.iterator();
                while (it2.hasNext()) {
                    ((C0530Ul) it2.next()).b(c2991yL, zW);
                }
                hashSet.clear();
            }
        }
        if (C2991yL.q) {
            HashSet hashSet2 = new HashSet();
            for (int i7 = 0; i7 < size; i7++) {
                C0530Ul c0530Ul5 = (C0530Ul) this.q0.get(i7);
                c0530Ul5.getClass();
                if (!(c0530Ul5 instanceof C2199pz) && !(c0530Ul5 instanceof C2604uE)) {
                    hashSet2.add(c0530Ul5);
                }
            }
            c0556Vl = this;
            c2991yL2 = c2991yL;
            c0556Vl.a(this, c2991yL2, hashSet2, this.p0[0] == 2 ? 0 : 1, false);
            Iterator it3 = hashSet2.iterator();
            while (it3.hasNext()) {
                C0530Ul c0530Ul6 = (C0530Ul) it3.next();
                AbstractC2539te.s(this, c2991yL2, c0530Ul6);
                c0530Ul6.b(c2991yL2, zW);
            }
        } else {
            c0556Vl = this;
            c2991yL2 = c2991yL;
            for (int i8 = 0; i8 < size; i8++) {
                C0530Ul c0530Ul7 = (C0530Ul) c0556Vl.q0.get(i8);
                if (c0530Ul7 instanceof C0556Vl) {
                    int[] iArr = c0530Ul7.p0;
                    int i9 = iArr[0];
                    int i10 = iArr[1];
                    if (i9 == 2) {
                        c0530Ul7.M(1);
                    }
                    if (i10 == 2) {
                        c0530Ul7.N(1);
                    }
                    c0530Ul7.b(c2991yL2, zW);
                    if (i9 == 2) {
                        c0530Ul7.M(i9);
                    }
                    if (i10 == 2) {
                        c0530Ul7.N(i10);
                    }
                } else {
                    AbstractC2539te.s(this, c2991yL2, c0530Ul7);
                    if (!(c0530Ul7 instanceof C2199pz) && !(c0530Ul7 instanceof C2604uE)) {
                        c0530Ul7.b(c2991yL2, zW);
                    }
                }
            }
        }
        if (c0556Vl.z0 > 0) {
            AbstractC1692kh0.i(this, c2991yL2, null, 0);
        }
        if (c0556Vl.A0 > 0) {
            AbstractC1692kh0.i(this, c2991yL2, null, 1);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final boolean T(int i, boolean z) {
        int i2;
        int i3;
        boolean z2;
        boolean z3;
        C3135zr c3135zr = this.s0;
        ArrayList arrayList = (ArrayList) c3135zr.f;
        C0556Vl c0556Vl = (C0556Vl) c3135zr.d;
        int iJ = c0556Vl.j(0);
        int[] iArr = c0556Vl.p0;
        int iJ2 = c0556Vl.j(1);
        int iR = c0556Vl.r();
        int iS = c0556Vl.s();
        if (z && (iJ == 2 || iJ2 == 2)) {
            int size = arrayList.size();
            int i4 = 0;
            while (true) {
                if (i4 >= size) {
                    z3 = z;
                    break;
                }
                Object obj = arrayList.get(i4);
                i4++;
                AbstractC0745al0 abstractC0745al0 = (AbstractC0745al0) obj;
                if (abstractC0745al0.f == i && !abstractC0745al0.k()) {
                    z3 = false;
                    break;
                }
            }
            if (i == 0) {
                if (z3 && iJ == 2) {
                    c0556Vl.M(1);
                    c0556Vl.O(c3135zr.d(c0556Vl, 0));
                    c0556Vl.d.e.d(c0556Vl.q());
                }
            } else if (z3 && iJ2 == 2) {
                c0556Vl.N(1);
                c0556Vl.L(c3135zr.d(c0556Vl, 1));
                c0556Vl.e.e.d(c0556Vl.k());
            }
        }
        if (i == 0) {
            i2 = 0;
            int i5 = iArr[0];
            if (i5 == 1 || i5 == 4) {
                int iQ = c0556Vl.q() + iR;
                c0556Vl.d.i.d(iQ);
                c0556Vl.d.e.d(iQ - iR);
                i3 = 1;
            }
            i3 = i2;
        } else {
            i2 = 0;
            int i6 = iArr[1];
            if (i6 == 1 || i6 == 4) {
                int iK = c0556Vl.k() + iS;
                c0556Vl.e.i.d(iK);
                c0556Vl.e.e.d(iK - iS);
                i3 = 1;
            }
            i3 = i2;
        }
        c3135zr.g();
        int size2 = arrayList.size();
        int i7 = i2;
        while (i7 < size2) {
            Object obj2 = arrayList.get(i7);
            i7++;
            AbstractC0745al0 abstractC0745al02 = (AbstractC0745al0) obj2;
            if (abstractC0745al02.f == i && (abstractC0745al02.b != c0556Vl || abstractC0745al02.g)) {
                abstractC0745al02.e();
            }
        }
        int size3 = arrayList.size();
        int i8 = i2;
        while (i8 < size3) {
            Object obj3 = arrayList.get(i8);
            i8++;
            AbstractC0745al0 abstractC0745al03 = (AbstractC0745al0) obj3;
            if (abstractC0745al03.f == i && (i3 != 0 || abstractC0745al03.b != c0556Vl)) {
                if (!abstractC0745al03.h.j || !abstractC0745al03.i.j || (!(abstractC0745al03 instanceof C0447Rg) && !abstractC0745al03.e.j)) {
                    z2 = i2;
                    break;
                }
            }
        }
        z2 = 1;
        c0556Vl.M(iJ);
        c0556Vl.N(iJ2);
        return z2;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:339:0x05de  */
    /* JADX WARN: Removed duplicated region for block: B:350:0x0608  */
    /* JADX WARN: Removed duplicated region for block: B:365:0x063b  */
    /* JADX WARN: Removed duplicated region for block: B:370:0x0651  */
    /* JADX WARN: Removed duplicated region for block: B:375:0x065f  */
    /* JADX WARN: Removed duplicated region for block: B:379:0x066a  */
    /* JADX WARN: Removed duplicated region for block: B:382:0x0675 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:384:0x067b  */
    /* JADX WARN: Removed duplicated region for block: B:387:0x0683  */
    /* JADX WARN: Removed duplicated region for block: B:391:0x068a  */
    /* JADX WARN: Removed duplicated region for block: B:394:0x0694  */
    /* JADX WARN: Removed duplicated region for block: B:400:0x06b1  */
    /* JADX WARN: Removed duplicated region for block: B:427:0x0714  */
    /* JADX WARN: Removed duplicated region for block: B:467:0x07c1  */
    /* JADX WARN: Removed duplicated region for block: B:476:0x07fe  */
    /* JADX WARN: Removed duplicated region for block: B:482:0x0818 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:487:0x0825 A[LOOP:14: B:486:0x0823->B:487:0x0825, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:499:0x088c  */
    /* JADX WARN: Removed duplicated region for block: B:500:0x0898  */
    /* JADX WARN: Removed duplicated region for block: B:503:0x08ab  */
    /* JADX WARN: Removed duplicated region for block: B:504:0x08b3  */
    /* JADX WARN: Removed duplicated region for block: B:506:0x08b7  */
    /* JADX WARN: Removed duplicated region for block: B:519:0x08eb  */
    /* JADX WARN: Removed duplicated region for block: B:521:0x08ef  */
    /* JADX WARN: Removed duplicated region for block: B:525:0x0900  */
    /* JADX WARN: Removed duplicated region for block: B:595:0x08f0 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:62:0x012c  */
    /* JADX WARN: Type inference failed for: r8v11 */
    /* JADX WARN: Type inference failed for: r8v12, types: [boolean] */
    /* JADX WARN: Type inference failed for: r8v14 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void U() {
        /*
            Method dump skipped, instructions count: 2318
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0556Vl.U():void");
    }

    public final boolean W(int i) {
        return (this.D0 & i) == i;
    }

    @Override // o.C0530Ul
    public final void n(StringBuilder sb) {
        sb.append(this.j + ":{\n");
        StringBuilder sb2 = new StringBuilder("  actualWidth:");
        sb2.append(this.U);
        sb.append(sb2.toString());
        sb.append("\n");
        sb.append("  actualHeight:" + this.V);
        sb.append("\n");
        ArrayList arrayList = this.q0;
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            ((C0530Ul) obj).n(sb);
            sb.append(",\n");
        }
        sb.append("}");
    }
}
