package g.d.a.j;

import g.d.a.j.e;

/* JADX INFO: compiled from: ResolutionAnchor.java */
/* JADX INFO: loaded from: classes.dex */
public class l extends n {
    e c;
    l d;
    float e;
    l f;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private l f497i;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    int f496h = 0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private m f498j = null;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f499k = 1;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private m f500l = null;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private int f501m = 1;

    public l(e eVar) {
        this.c = eVar;
    }

    @Override // g.d.a.j.n
    public void e() {
        super.e();
        this.d = null;
        this.e = 0.0f;
        this.f498j = null;
        this.f499k = 1;
        this.f500l = null;
        this.f501m = 1;
        this.f = null;
        this.f495g = 0.0f;
        this.f497i = null;
        this.f496h = 0;
    }

    @Override // g.d.a.j.n
    public void f() {
        l lVar;
        l lVar2;
        l lVar3;
        l lVar4;
        l lVar5;
        l lVar6;
        float f;
        float f2;
        float fD;
        float f3;
        l lVar7;
        boolean z = true;
        if (this.b == 1 || this.f496h == 4) {
            return;
        }
        m mVar = this.f498j;
        if (mVar != null) {
            if (mVar.b != 1) {
                return;
            } else {
                this.e = this.f499k * mVar.c;
            }
        }
        m mVar2 = this.f500l;
        if (mVar2 != null) {
            if (mVar2.b != 1) {
                return;
            } else {
                float f4 = mVar2.c;
            }
        }
        if (this.f496h == 1 && ((lVar7 = this.d) == null || lVar7.b == 1)) {
            l lVar8 = this.d;
            if (lVar8 == null) {
                this.f = this;
                this.f495g = this.e;
            } else {
                this.f = lVar8.f;
                this.f495g = lVar8.f495g + this.e;
            }
            b();
            return;
        }
        if (this.f496h != 2 || (lVar4 = this.d) == null || lVar4.b != 1 || (lVar5 = this.f497i) == null || (lVar6 = lVar5.d) == null || lVar6.b != 1) {
            if (this.f496h != 3 || (lVar = this.d) == null || lVar.b != 1 || (lVar2 = this.f497i) == null || (lVar3 = lVar2.d) == null || lVar3.b != 1) {
                if (this.f496h == 5) {
                    this.c.b.U();
                    return;
                }
                return;
            }
            if (g.d.a.e.x() != null) {
                g.d.a.e.x().w++;
            }
            l lVar9 = this.d;
            this.f = lVar9.f;
            l lVar10 = this.f497i;
            l lVar11 = lVar10.d;
            lVar10.f = lVar11.f;
            this.f495g = lVar9.f495g + this.e;
            lVar10.f495g = lVar11.f495g + lVar10.e;
            b();
            this.f497i.b();
            return;
        }
        if (g.d.a.e.x() != null) {
            g.d.a.e.x().v++;
        }
        this.f = this.d.f;
        l lVar12 = this.f497i;
        lVar12.f = lVar12.d.f;
        e.d dVar = this.c.c;
        int i2 = 0;
        if (dVar != e.d.RIGHT && dVar != e.d.BOTTOM) {
            z = false;
        }
        if (z) {
            f = this.d.f495g;
            f2 = this.f497i.d.f495g;
        } else {
            f = this.f497i.d.f495g;
            f2 = this.d.f495g;
        }
        float f5 = f - f2;
        e.d dVar2 = this.c.c;
        if (dVar2 == e.d.LEFT || dVar2 == e.d.RIGHT) {
            fD = f5 - this.c.b.D();
            f3 = this.c.b.V;
        } else {
            fD = f5 - r2.b.r();
            f3 = this.c.b.W;
        }
        int iD = this.c.d();
        int iD2 = this.f497i.c.d();
        if (this.c.i() == this.f497i.c.i()) {
            f3 = 0.5f;
            iD2 = 0;
        } else {
            i2 = iD;
        }
        float f6 = i2;
        float f7 = iD2;
        float f8 = (fD - f6) - f7;
        if (z) {
            l lVar13 = this.f497i;
            lVar13.f495g = lVar13.d.f495g + f7 + (f8 * f3);
            this.f495g = (this.d.f495g - f6) - (f8 * (1.0f - f3));
        } else {
            this.f495g = this.d.f495g + f6 + (f8 * f3);
            l lVar14 = this.f497i;
            lVar14.f495g = (lVar14.d.f495g - f7) - (f8 * (1.0f - f3));
        }
        b();
        this.f497i.b();
    }

    void g(g.d.a.e eVar) {
        g.d.a.i iVarG = this.c.g();
        l lVar = this.f;
        if (lVar == null) {
            eVar.f(iVarG, (int) (this.f495g + 0.5f));
        } else {
            eVar.e(iVarG, eVar.r(lVar.c), (int) (this.f495g + 0.5f), 6);
        }
    }

    public void h(int i2, l lVar, int i3) {
        this.f496h = i2;
        this.d = lVar;
        this.e = i3;
        lVar.a(this);
    }

    public void i(l lVar, int i2) {
        this.d = lVar;
        this.e = i2;
        lVar.a(this);
    }

    public void j(l lVar, int i2, m mVar) {
        this.d = lVar;
        lVar.a(this);
        this.f498j = mVar;
        this.f499k = i2;
        mVar.a(this);
    }

    public float k() {
        return this.f495g;
    }

    public void l(l lVar, float f) {
        if (this.b == 0 || !(this.f == lVar || this.f495g == f)) {
            this.f = lVar;
            this.f495g = f;
            if (this.b == 1) {
                c();
            }
            b();
        }
    }

    String m(int i2) {
        return i2 == 1 ? "DIRECT" : i2 == 2 ? "CENTER" : i2 == 3 ? "MATCH" : i2 == 4 ? "CHAIN" : i2 == 5 ? "BARRIER" : "UNCONNECTED";
    }

    public void n(l lVar, float f) {
        this.f497i = lVar;
    }

    public void o(l lVar, int i2, m mVar) {
        this.f497i = lVar;
        this.f500l = mVar;
        this.f501m = i2;
    }

    public void p(int i2) {
        this.f496h = i2;
    }

    public void q() {
        e eVarI = this.c.i();
        if (eVarI == null) {
            return;
        }
        if (eVarI.i() == this.c) {
            this.f496h = 4;
            eVarI.f().f496h = 4;
        }
        int iD = this.c.d();
        e.d dVar = this.c.c;
        if (dVar == e.d.RIGHT || dVar == e.d.BOTTOM) {
            iD = -iD;
        }
        i(eVarI.f(), iD);
    }

    public String toString() {
        if (this.b != 1) {
            return "{ " + this.c + " UNRESOLVED} type: " + m(this.f496h);
        }
        if (this.f == this) {
            return "[" + this.c + ", RESOLVED: " + this.f495g + "]  type: " + m(this.f496h);
        }
        return "[" + this.c + ", RESOLVED: " + this.f + ":" + this.f495g + "] type: " + m(this.f496h);
    }
}
