package n;

import com.android.org.conscrypt.ct.CTConstants;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import k.i;
import o.o;

/* JADX INFO: compiled from: ConstraintAnchor.java */
/* JADX INFO: loaded from: classes.dex */
public class d {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private int f5599b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private boolean f5600c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final e f5601d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final b f5602e;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    k.i f5606i;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private HashSet<d> f5598a = null;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f5604g = 0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    int f5605h = Integer.MIN_VALUE;

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

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

        static {
            int[] iArr = new int[b.values().length];
            f5607a = iArr;
            try {
                iArr[b.CENTER.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f5607a[b.LEFT.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f5607a[b.RIGHT.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f5607a[b.TOP.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f5607a[b.BOTTOM.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f5607a[b.BASELINE.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                f5607a[b.CENTER_X.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f5607a[b.CENTER_Y.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                f5607a[b.NONE.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
        }
    }

    /* JADX INFO: compiled from: ConstraintAnchor.java */
    public enum b {
        NONE,
        LEFT,
        TOP,
        RIGHT,
        BOTTOM,
        BASELINE,
        CENTER,
        CENTER_X,
        CENTER_Y
    }

    public d(e eVar, b bVar) {
        this.f5601d = eVar;
        this.f5602e = bVar;
    }

    public boolean a(d dVar, int i3, int i4, boolean z2) {
        if (dVar == null) {
            p();
            return true;
        }
        if (!z2 && !o(dVar)) {
            return false;
        }
        this.f5603f = dVar;
        if (dVar.f5598a == null) {
            dVar.f5598a = new HashSet<>();
        }
        HashSet<d> hashSet = this.f5603f.f5598a;
        if (hashSet != null) {
            hashSet.add(this);
        }
        this.f5604g = i3;
        this.f5605h = i4;
        return true;
    }

    public void b(int i3, ArrayList<o> arrayList, o oVar) {
        HashSet<d> hashSet = this.f5598a;
        if (hashSet != null) {
            Iterator<d> it = hashSet.iterator();
            while (it.hasNext()) {
                o.i.a(it.next().f5601d, i3, arrayList, oVar);
            }
        }
    }

    public HashSet<d> c() {
        return this.f5598a;
    }

    public int d() {
        if (this.f5600c) {
            return this.f5599b;
        }
        return 0;
    }

    public int e() {
        d dVar;
        if (this.f5601d.T() == 8) {
            return 0;
        }
        return (this.f5605h == Integer.MIN_VALUE || (dVar = this.f5603f) == null || dVar.f5601d.T() != 8) ? this.f5604g : this.f5605h;
    }

    public final d f() {
        switch (a.f5607a[this.f5602e.ordinal()]) {
            case 1:
            case 6:
            case 7:
            case 8:
            case 9:
                return null;
            case 2:
                return this.f5601d.N;
            case CTConstants.CERTIFICATE_LENGTH_BYTES /* 3 */:
                return this.f5601d.L;
            case 4:
                return this.f5601d.O;
            case 5:
                return this.f5601d.M;
            default:
                throw new AssertionError(this.f5602e.name());
        }
    }

    public e g() {
        return this.f5601d;
    }

    public k.i h() {
        return this.f5606i;
    }

    public d i() {
        return this.f5603f;
    }

    public b j() {
        return this.f5602e;
    }

    public boolean k() {
        HashSet<d> hashSet = this.f5598a;
        if (hashSet == null) {
            return false;
        }
        Iterator<d> it = hashSet.iterator();
        while (it.hasNext()) {
            if (it.next().f().n()) {
                return true;
            }
        }
        return false;
    }

    public boolean l() {
        HashSet<d> hashSet = this.f5598a;
        return hashSet != null && hashSet.size() > 0;
    }

    public boolean m() {
        return this.f5600c;
    }

    public boolean n() {
        return this.f5603f != null;
    }

    public boolean o(d dVar) {
        if (dVar == null) {
            return false;
        }
        b bVarJ = dVar.j();
        b bVar = this.f5602e;
        if (bVarJ == bVar) {
            return bVar != b.BASELINE || (dVar.g().X() && g().X());
        }
        switch (a.f5607a[bVar.ordinal()]) {
            case 1:
                return (bVarJ == b.BASELINE || bVarJ == b.CENTER_X || bVarJ == b.CENTER_Y) ? false : true;
            case 2:
            case CTConstants.CERTIFICATE_LENGTH_BYTES /* 3 */:
                boolean z2 = bVarJ == b.LEFT || bVarJ == b.RIGHT;
                if (dVar.g() instanceof g) {
                    return z2 || bVarJ == b.CENTER_X;
                }
                return z2;
            case 4:
            case 5:
                boolean z3 = bVarJ == b.TOP || bVarJ == b.BOTTOM;
                if (dVar.g() instanceof g) {
                    return z3 || bVarJ == b.CENTER_Y;
                }
                return z3;
            case 6:
                return (bVarJ == b.LEFT || bVarJ == b.RIGHT) ? false : true;
            case 7:
            case 8:
            case 9:
                return false;
            default:
                throw new AssertionError(this.f5602e.name());
        }
    }

    public void p() {
        HashSet<d> hashSet;
        d dVar = this.f5603f;
        if (dVar != null && (hashSet = dVar.f5598a) != null) {
            hashSet.remove(this);
            if (this.f5603f.f5598a.size() == 0) {
                this.f5603f.f5598a = null;
            }
        }
        this.f5598a = null;
        this.f5603f = null;
        this.f5604g = 0;
        this.f5605h = Integer.MIN_VALUE;
        this.f5600c = false;
        this.f5599b = 0;
    }

    public void q() {
        this.f5600c = false;
        this.f5599b = 0;
    }

    public void r(k.c cVar) {
        k.i iVar = this.f5606i;
        if (iVar == null) {
            this.f5606i = new k.i(i.a.UNRESTRICTED, null);
        } else {
            iVar.e();
        }
    }

    public void s(int i3) {
        this.f5599b = i3;
        this.f5600c = true;
    }

    public String toString() {
        return this.f5601d.r() + ":" + this.f5602e.toString();
    }
}
