package d.f.a.j;

import d.f.a.j.c;

/* JADX INFO: loaded from: classes.dex */
public class a extends h {
    public int s0 = 0;
    public boolean t0 = true;
    public int u0 = 0;
    public boolean v0 = false;

    @Override // d.f.a.j.d
    public boolean A() {
        return this.v0;
    }

    @Override // d.f.a.j.d
    public boolean B() {
        return this.v0;
    }

    public boolean R() {
        int i2;
        c cVarI;
        c cVarI2;
        c cVarI3;
        int i3;
        int i4;
        c.a aVar = c.a.BOTTOM;
        c.a aVar2 = c.a.TOP;
        c.a aVar3 = c.a.RIGHT;
        c.a aVar4 = c.a.LEFT;
        int i5 = 0;
        boolean z2 = true;
        while (true) {
            i2 = this.r0;
            if (i5 >= i2) {
                break;
            }
            d dVar = this.q0[i5];
            if ((this.t0 || dVar.e()) && ((((i3 = this.s0) == 0 || i3 == 1) && !dVar.A()) || (((i4 = this.s0) == 2 || i4 == 3) && !dVar.B()))) {
                z2 = false;
            }
            i5++;
        }
        if (!z2 || i2 <= 0) {
            return false;
        }
        int iMax = 0;
        boolean z3 = false;
        for (int i6 = 0; i6 < this.r0; i6++) {
            d dVar2 = this.q0[i6];
            if (this.t0 || dVar2.e()) {
                if (!z3) {
                    int i7 = this.s0;
                    if (i7 == 0) {
                        cVarI3 = dVar2.i(aVar4);
                    } else if (i7 == 1) {
                        cVarI3 = dVar2.i(aVar3);
                    } else if (i7 == 2) {
                        cVarI3 = dVar2.i(aVar2);
                    } else {
                        if (i7 == 3) {
                            cVarI3 = dVar2.i(aVar);
                        }
                        z3 = true;
                    }
                    iMax = cVarI3.c();
                    z3 = true;
                }
                int i8 = this.s0;
                if (i8 == 0) {
                    cVarI2 = dVar2.i(aVar4);
                } else {
                    if (i8 == 1) {
                        cVarI = dVar2.i(aVar3);
                    } else if (i8 == 2) {
                        cVarI2 = dVar2.i(aVar2);
                    } else if (i8 == 3) {
                        cVarI = dVar2.i(aVar);
                    }
                    iMax = Math.max(iMax, cVarI.c());
                }
                iMax = Math.min(iMax, cVarI2.c());
            }
        }
        int i9 = iMax + this.u0;
        int i10 = this.s0;
        if (i10 == 0 || i10 == 1) {
            G(i9, i9);
        } else {
            H(i9, i9);
        }
        this.v0 = true;
        return true;
    }

    public int S() {
        int i2 = this.s0;
        if (i2 == 0 || i2 == 1) {
            return 0;
        }
        return (i2 == 2 || i2 == 3) ? 1 : -1;
    }

    @Override // d.f.a.j.d
    public void d(d.f.a.d dVar, boolean z2) {
        c[] cVarArr;
        boolean z3;
        d.f.a.h hVar;
        c cVar;
        int i2;
        int i3;
        int i4;
        d.f.a.h hVar2;
        int i5;
        c[] cVarArr2 = this.Q;
        cVarArr2[0] = this.I;
        cVarArr2[2] = this.J;
        cVarArr2[1] = this.K;
        cVarArr2[3] = this.L;
        int i6 = 0;
        while (true) {
            cVarArr = this.Q;
            if (i6 >= cVarArr.length) {
                break;
            }
            cVarArr[i6].f2311i = dVar.l(cVarArr[i6]);
            i6++;
        }
        int i7 = this.s0;
        if (i7 < 0 || i7 >= 4) {
            return;
        }
        c cVar2 = cVarArr[i7];
        if (!this.v0) {
            R();
        }
        if (this.v0) {
            this.v0 = false;
            int i8 = this.s0;
            if (i8 == 0 || i8 == 1) {
                dVar.e(this.I.f2311i, this.Z);
                hVar2 = this.K.f2311i;
                i5 = this.Z;
            } else {
                if (i8 != 2 && i8 != 3) {
                    return;
                }
                dVar.e(this.J.f2311i, this.f2322a0);
                hVar2 = this.L.f2311i;
                i5 = this.f2322a0;
            }
            dVar.e(hVar2, i5);
            return;
        }
        for (int i9 = 0; i9 < this.r0; i9++) {
            d dVar2 = this.q0[i9];
            if ((this.t0 || dVar2.e()) && ((((i3 = this.s0) == 0 || i3 == 1) && dVar2.m() == 3 && dVar2.I.f2308f != null && dVar2.K.f2308f != null) || (((i4 = this.s0) == 2 || i4 == 3) && dVar2.q() == 3 && dVar2.J.f2308f != null && dVar2.L.f2308f != null))) {
                z3 = true;
                break;
            }
        }
        z3 = false;
        boolean z4 = this.I.e() || this.K.e();
        boolean z5 = this.J.e() || this.L.e();
        int i10 = !z3 && (((i2 = this.s0) == 0 && z4) || ((i2 == 2 && z5) || ((i2 == 1 && z4) || (i2 == 3 && z5)))) ? 5 : 4;
        for (int i11 = 0; i11 < this.r0; i11++) {
            d dVar3 = this.q0[i11];
            if (this.t0 || dVar3.e()) {
                d.f.a.h hVarL = dVar.l(dVar3.Q[this.s0]);
                c[] cVarArr3 = dVar3.Q;
                int i12 = this.s0;
                cVarArr3[i12].f2311i = hVarL;
                int i13 = (cVarArr3[i12].f2308f == null || cVarArr3[i12].f2308f.f2306d != this) ? 0 : cVarArr3[i12].f2309g + 0;
                if (i12 == 0 || i12 == 2) {
                    d.f.a.h hVar3 = cVar2.f2311i;
                    int i14 = this.u0 - i13;
                    d.f.a.b bVarM = dVar.m();
                    d.f.a.h hVarN = dVar.n();
                    hVarN.f2273p = 0;
                    bVarM.f(hVar3, hVarL, hVarN, i14);
                    dVar.c(bVarM);
                } else {
                    d.f.a.h hVar4 = cVar2.f2311i;
                    int i15 = this.u0 + i13;
                    d.f.a.b bVarM2 = dVar.m();
                    d.f.a.h hVarN2 = dVar.n();
                    hVarN2.f2273p = 0;
                    bVarM2.e(hVar4, hVarL, hVarN2, i15);
                    dVar.c(bVarM2);
                }
                dVar.d(cVar2.f2311i, hVarL, this.u0 + i13, i10);
            }
        }
        int i16 = this.s0;
        if (i16 == 0) {
            dVar.d(this.K.f2311i, this.I.f2311i, 0, 8);
            dVar.d(this.I.f2311i, this.U.K.f2311i, 0, 4);
            hVar = this.I.f2311i;
            cVar = this.U.I;
        } else if (i16 == 1) {
            dVar.d(this.I.f2311i, this.K.f2311i, 0, 8);
            dVar.d(this.I.f2311i, this.U.I.f2311i, 0, 4);
            hVar = this.I.f2311i;
            cVar = this.U.K;
        } else if (i16 == 2) {
            dVar.d(this.L.f2311i, this.J.f2311i, 0, 8);
            dVar.d(this.J.f2311i, this.U.L.f2311i, 0, 4);
            hVar = this.J.f2311i;
            cVar = this.U.J;
        } else {
            if (i16 != 3) {
                return;
            }
            dVar.d(this.J.f2311i, this.L.f2311i, 0, 8);
            dVar.d(this.J.f2311i, this.U.J.f2311i, 0, 4);
            hVar = this.J.f2311i;
            cVar = this.U.L;
        }
        dVar.d(hVar, cVar.f2311i, 0, 0);
    }

    @Override // d.f.a.j.d
    public boolean e() {
        return true;
    }

    @Override // d.f.a.j.d
    public String toString() {
        String strA = g.a.a.a.a.A(g.a.a.a.a.F("[Barrier] "), this.i0, " {");
        for (int i2 = 0; i2 < this.r0; i2++) {
            d dVar = this.q0[i2];
            if (i2 > 0) {
                strA = g.a.a.a.a.t(strA, ", ");
            }
            StringBuilder sbF = g.a.a.a.a.F(strA);
            sbF.append(dVar.i0);
            strA = sbF.toString();
        }
        return g.a.a.a.a.t(strA, "}");
    }
}
