package o;

import n.d;
import n.e;
import o.f;
import o.p;

/* JADX INFO: compiled from: VerticalWidgetRun.java */
/* JADX INFO: loaded from: classes.dex */
public class n extends p {

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    g f5728l;

    /* JADX INFO: compiled from: VerticalWidgetRun.java */
    static /* synthetic */ class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f5729a;

        static {
            int[] iArr = new int[p.b.values().length];
            f5729a = iArr;
            try {
                iArr[p.b.START.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f5729a[p.b.END.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f5729a[p.b.CENTER.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public n(n.e eVar) {
        super(eVar);
        f fVar = new f(this);
        this.f5727k = fVar;
        this.f5728l = null;
        this.f5743h.f5710e = f.a.TOP;
        this.f5744i.f5710e = f.a.BOTTOM;
        fVar.f5710e = f.a.BASELINE;
        this.f5741f = 1;
    }

    @Override // o.p, o.d
    public void a(d dVar) {
        float f3;
        float fT;
        float fT2;
        int i3;
        int i4 = a.f5729a[this.f5745j.ordinal()];
        if (i4 == 1) {
            p(dVar);
        } else if (i4 == 2) {
            o(dVar);
        } else if (i4 == 3) {
            n.e eVar = this.f5737b;
            n(dVar, eVar.M, eVar.O, 1);
            return;
        }
        g gVar = this.f5740e;
        if (gVar.f5708c && !gVar.f5715j && this.f5739d == e.b.MATCH_CONSTRAINT) {
            n.e eVar2 = this.f5737b;
            int i5 = eVar2.f5649u;
            if (i5 == 2) {
                n.e eVarI = eVar2.I();
                if (eVarI != null) {
                    if (eVarI.f5617e.f5740e.f5715j) {
                        this.f5740e.d((int) ((r7.f5712g * this.f5737b.B) + 0.5f));
                    }
                }
            } else if (i5 == 3 && eVar2.f5615d.f5740e.f5715j) {
                int iU = eVar2.u();
                if (iU == -1) {
                    n.e eVar3 = this.f5737b;
                    f3 = eVar3.f5615d.f5740e.f5712g;
                    fT = eVar3.t();
                } else if (iU == 0) {
                    fT2 = r7.f5615d.f5740e.f5712g * this.f5737b.t();
                    i3 = (int) (fT2 + 0.5f);
                    this.f5740e.d(i3);
                } else if (iU != 1) {
                    i3 = 0;
                    this.f5740e.d(i3);
                } else {
                    n.e eVar4 = this.f5737b;
                    f3 = eVar4.f5615d.f5740e.f5712g;
                    fT = eVar4.t();
                }
                fT2 = f3 / fT;
                i3 = (int) (fT2 + 0.5f);
                this.f5740e.d(i3);
            }
        }
        f fVar = this.f5743h;
        if (fVar.f5708c) {
            f fVar2 = this.f5744i;
            if (fVar2.f5708c) {
                if (fVar.f5715j && fVar2.f5715j && this.f5740e.f5715j) {
                    return;
                }
                if (!this.f5740e.f5715j && this.f5739d == e.b.MATCH_CONSTRAINT) {
                    n.e eVar5 = this.f5737b;
                    if (eVar5.f5647t == 0 && !eVar5.i0()) {
                        f fVar3 = this.f5743h.f5717l.get(0);
                        f fVar4 = this.f5744i.f5717l.get(0);
                        int i6 = fVar3.f5712g;
                        f fVar5 = this.f5743h;
                        int i7 = i6 + fVar5.f5711f;
                        int i8 = fVar4.f5712g + this.f5744i.f5711f;
                        fVar5.d(i7);
                        this.f5744i.d(i8);
                        this.f5740e.d(i8 - i7);
                        return;
                    }
                }
                if (!this.f5740e.f5715j && this.f5739d == e.b.MATCH_CONSTRAINT && this.f5736a == 1 && this.f5743h.f5717l.size() > 0 && this.f5744i.f5717l.size() > 0) {
                    f fVar6 = this.f5743h.f5717l.get(0);
                    int i9 = (this.f5744i.f5717l.get(0).f5712g + this.f5744i.f5711f) - (fVar6.f5712g + this.f5743h.f5711f);
                    g gVar2 = this.f5740e;
                    int i10 = gVar2.f5718m;
                    if (i9 < i10) {
                        gVar2.d(i9);
                    } else {
                        gVar2.d(i10);
                    }
                }
                if (this.f5740e.f5715j && this.f5743h.f5717l.size() > 0 && this.f5744i.f5717l.size() > 0) {
                    f fVar7 = this.f5743h.f5717l.get(0);
                    f fVar8 = this.f5744i.f5717l.get(0);
                    int i11 = fVar7.f5712g + this.f5743h.f5711f;
                    int i12 = fVar8.f5712g + this.f5744i.f5711f;
                    float fP = this.f5737b.P();
                    if (fVar7 == fVar8) {
                        i11 = fVar7.f5712g;
                        i12 = fVar8.f5712g;
                        fP = 0.5f;
                    }
                    this.f5743h.d((int) (i11 + 0.5f + (((i12 - i11) - this.f5740e.f5712g) * fP)));
                    this.f5744i.d(this.f5743h.f5712g + this.f5740e.f5712g);
                }
            }
        }
    }

    @Override // o.p
    void d() {
        n.e eVarI;
        n.e eVarI2;
        n.e eVar = this.f5737b;
        if (eVar.f5609a) {
            this.f5740e.d(eVar.v());
        }
        if (!this.f5740e.f5715j) {
            this.f5739d = this.f5737b.R();
            if (this.f5737b.X()) {
                this.f5728l = new o.a(this);
            }
            e.b bVar = this.f5739d;
            if (bVar != e.b.MATCH_CONSTRAINT) {
                if (bVar == e.b.MATCH_PARENT && (eVarI2 = this.f5737b.I()) != null && eVarI2.R() == e.b.FIXED) {
                    int iV = (eVarI2.v() - this.f5737b.M.e()) - this.f5737b.O.e();
                    b(this.f5743h, eVarI2.f5617e.f5743h, this.f5737b.M.e());
                    b(this.f5744i, eVarI2.f5617e.f5744i, -this.f5737b.O.e());
                    this.f5740e.d(iV);
                    return;
                }
                if (this.f5739d == e.b.FIXED) {
                    this.f5740e.d(this.f5737b.v());
                }
            }
        } else if (this.f5739d == e.b.MATCH_PARENT && (eVarI = this.f5737b.I()) != null && eVarI.R() == e.b.FIXED) {
            b(this.f5743h, eVarI.f5617e.f5743h, this.f5737b.M.e());
            b(this.f5744i, eVarI.f5617e.f5744i, -this.f5737b.O.e());
            return;
        }
        g gVar = this.f5740e;
        boolean z2 = gVar.f5715j;
        if (z2) {
            n.e eVar2 = this.f5737b;
            if (eVar2.f5609a) {
                n.d[] dVarArr = eVar2.T;
                if (dVarArr[2].f5603f != null && dVarArr[3].f5603f != null) {
                    if (eVar2.i0()) {
                        this.f5743h.f5711f = this.f5737b.T[2].e();
                        this.f5744i.f5711f = -this.f5737b.T[3].e();
                    } else {
                        f fVarH = h(this.f5737b.T[2]);
                        if (fVarH != null) {
                            b(this.f5743h, fVarH, this.f5737b.T[2].e());
                        }
                        f fVarH2 = h(this.f5737b.T[3]);
                        if (fVarH2 != null) {
                            b(this.f5744i, fVarH2, -this.f5737b.T[3].e());
                        }
                        this.f5743h.f5707b = true;
                        this.f5744i.f5707b = true;
                    }
                    if (this.f5737b.X()) {
                        b(this.f5727k, this.f5743h, this.f5737b.n());
                        return;
                    }
                    return;
                }
                if (dVarArr[2].f5603f != null) {
                    f fVarH3 = h(dVarArr[2]);
                    if (fVarH3 != null) {
                        b(this.f5743h, fVarH3, this.f5737b.T[2].e());
                        b(this.f5744i, this.f5743h, this.f5740e.f5712g);
                        if (this.f5737b.X()) {
                            b(this.f5727k, this.f5743h, this.f5737b.n());
                            return;
                        }
                        return;
                    }
                    return;
                }
                if (dVarArr[3].f5603f != null) {
                    f fVarH4 = h(dVarArr[3]);
                    if (fVarH4 != null) {
                        b(this.f5744i, fVarH4, -this.f5737b.T[3].e());
                        b(this.f5743h, this.f5744i, -this.f5740e.f5712g);
                    }
                    if (this.f5737b.X()) {
                        b(this.f5727k, this.f5743h, this.f5737b.n());
                        return;
                    }
                    return;
                }
                if (dVarArr[4].f5603f != null) {
                    f fVarH5 = h(dVarArr[4]);
                    if (fVarH5 != null) {
                        b(this.f5727k, fVarH5, 0);
                        b(this.f5743h, this.f5727k, -this.f5737b.n());
                        b(this.f5744i, this.f5743h, this.f5740e.f5712g);
                        return;
                    }
                    return;
                }
                if ((eVar2 instanceof n.h) || eVar2.I() == null || this.f5737b.m(d.b.CENTER).f5603f != null) {
                    return;
                }
                b(this.f5743h, this.f5737b.I().f5617e.f5743h, this.f5737b.W());
                b(this.f5744i, this.f5743h, this.f5740e.f5712g);
                if (this.f5737b.X()) {
                    b(this.f5727k, this.f5743h, this.f5737b.n());
                    return;
                }
                return;
            }
        }
        if (z2 || this.f5739d != e.b.MATCH_CONSTRAINT) {
            gVar.b(this);
        } else {
            n.e eVar3 = this.f5737b;
            int i3 = eVar3.f5649u;
            if (i3 == 2) {
                n.e eVarI3 = eVar3.I();
                if (eVarI3 != null) {
                    g gVar2 = eVarI3.f5617e.f5740e;
                    this.f5740e.f5717l.add(gVar2);
                    gVar2.f5716k.add(this.f5740e);
                    g gVar3 = this.f5740e;
                    gVar3.f5707b = true;
                    gVar3.f5716k.add(this.f5743h);
                    this.f5740e.f5716k.add(this.f5744i);
                }
            } else if (i3 == 3 && !eVar3.i0()) {
                n.e eVar4 = this.f5737b;
                if (eVar4.f5647t != 3) {
                    g gVar4 = eVar4.f5615d.f5740e;
                    this.f5740e.f5717l.add(gVar4);
                    gVar4.f5716k.add(this.f5740e);
                    g gVar5 = this.f5740e;
                    gVar5.f5707b = true;
                    gVar5.f5716k.add(this.f5743h);
                    this.f5740e.f5716k.add(this.f5744i);
                }
            }
        }
        n.e eVar5 = this.f5737b;
        n.d[] dVarArr2 = eVar5.T;
        if (dVarArr2[2].f5603f != null && dVarArr2[3].f5603f != null) {
            if (eVar5.i0()) {
                this.f5743h.f5711f = this.f5737b.T[2].e();
                this.f5744i.f5711f = -this.f5737b.T[3].e();
            } else {
                f fVarH6 = h(this.f5737b.T[2]);
                f fVarH7 = h(this.f5737b.T[3]);
                if (fVarH6 != null) {
                    fVarH6.b(this);
                }
                if (fVarH7 != null) {
                    fVarH7.b(this);
                }
                this.f5745j = p.b.CENTER;
            }
            if (this.f5737b.X()) {
                c(this.f5727k, this.f5743h, 1, this.f5728l);
            }
        } else if (dVarArr2[2].f5603f != null) {
            f fVarH8 = h(dVarArr2[2]);
            if (fVarH8 != null) {
                b(this.f5743h, fVarH8, this.f5737b.T[2].e());
                c(this.f5744i, this.f5743h, 1, this.f5740e);
                if (this.f5737b.X()) {
                    c(this.f5727k, this.f5743h, 1, this.f5728l);
                }
                e.b bVar2 = this.f5739d;
                e.b bVar3 = e.b.MATCH_CONSTRAINT;
                if (bVar2 == bVar3 && this.f5737b.t() > 0.0f) {
                    l lVar = this.f5737b.f5615d;
                    if (lVar.f5739d == bVar3) {
                        lVar.f5740e.f5716k.add(this.f5740e);
                        this.f5740e.f5717l.add(this.f5737b.f5615d.f5740e);
                        this.f5740e.f5706a = this;
                    }
                }
            }
        } else if (dVarArr2[3].f5603f != null) {
            f fVarH9 = h(dVarArr2[3]);
            if (fVarH9 != null) {
                b(this.f5744i, fVarH9, -this.f5737b.T[3].e());
                c(this.f5743h, this.f5744i, -1, this.f5740e);
                if (this.f5737b.X()) {
                    c(this.f5727k, this.f5743h, 1, this.f5728l);
                }
            }
        } else if (dVarArr2[4].f5603f != null) {
            f fVarH10 = h(dVarArr2[4]);
            if (fVarH10 != null) {
                b(this.f5727k, fVarH10, 0);
                c(this.f5743h, this.f5727k, -1, this.f5728l);
                c(this.f5744i, this.f5743h, 1, this.f5740e);
            }
        } else if (!(eVar5 instanceof n.h) && eVar5.I() != null) {
            b(this.f5743h, this.f5737b.I().f5617e.f5743h, this.f5737b.W());
            c(this.f5744i, this.f5743h, 1, this.f5740e);
            if (this.f5737b.X()) {
                c(this.f5727k, this.f5743h, 1, this.f5728l);
            }
            e.b bVar4 = this.f5739d;
            e.b bVar5 = e.b.MATCH_CONSTRAINT;
            if (bVar4 == bVar5 && this.f5737b.t() > 0.0f) {
                l lVar2 = this.f5737b.f5615d;
                if (lVar2.f5739d == bVar5) {
                    lVar2.f5740e.f5716k.add(this.f5740e);
                    this.f5740e.f5717l.add(this.f5737b.f5615d.f5740e);
                    this.f5740e.f5706a = this;
                }
            }
        }
        if (this.f5740e.f5717l.size() == 0) {
            this.f5740e.f5708c = true;
        }
    }

    @Override // o.p
    public void e() {
        f fVar = this.f5743h;
        if (fVar.f5715j) {
            this.f5737b.k1(fVar.f5712g);
        }
    }

    @Override // o.p
    void f() {
        this.f5738c = null;
        this.f5743h.c();
        this.f5744i.c();
        this.f5727k.c();
        this.f5740e.c();
        this.f5742g = false;
    }

    @Override // o.p
    boolean m() {
        return this.f5739d != e.b.MATCH_CONSTRAINT || this.f5737b.f5649u == 0;
    }

    void q() {
        this.f5742g = false;
        this.f5743h.c();
        this.f5743h.f5715j = false;
        this.f5744i.c();
        this.f5744i.f5715j = false;
        this.f5727k.c();
        this.f5727k.f5715j = false;
        this.f5740e.f5715j = false;
    }

    public String toString() {
        return "VerticalRun " + this.f5737b.r();
    }
}
