package ῲ.ⁱ.ῲ.㿎.ᕣ;

import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import ῲ.ⁱ.ῲ.㿎.C2082;
import ῲ.ⁱ.ῲ.㿎.C2083;
import ῲ.ⁱ.ῲ.㿎.C2103;
import ῲ.ⁱ.ῲ.㿎.ᕣ.C2088;

/* renamed from: ῲ.ⁱ.ῲ.㿎.ᕣ.ⁱ  reason: contains not printable characters */
/* compiled from: Direct */
public class C2091 {

    /* renamed from: K  reason: contains not printable characters */
    public static C2088.C2090 f7236 = new C2088.C2090();

    /* renamed from: ῲ  reason: contains not printable characters */
    public static void m5518(ConstraintWidget constraintWidget, C2088.AbstractC2089 r14) {
        ConstraintAnchor constraintAnchor;
        ConstraintAnchor constraintAnchor2;
        ConstraintAnchor constraintAnchor3;
        ConstraintAnchor constraintAnchor4;
        ConstraintAnchor constraintAnchor5;
        if (!(constraintWidget instanceof C2082) && constraintWidget.m470() && m5525(constraintWidget)) {
            C2082.m5467(constraintWidget, r14, new C2088.C2090(), false);
        }
        ConstraintAnchor r0 = constraintWidget.m488(ConstraintAnchor.Type.TOP);
        ConstraintAnchor r2 = constraintWidget.m488(ConstraintAnchor.Type.BOTTOM);
        int r3 = r0.m459();
        int r4 = r2.m459();
        HashSet<ConstraintAnchor> hashSet = r0.f811;
        if (hashSet != null && r0.f806) {
            Iterator<ConstraintAnchor> it2 = hashSet.iterator();
            while (it2.hasNext()) {
                ConstraintAnchor next = it2.next();
                ConstraintWidget constraintWidget2 = next.f813;
                boolean r10 = m5525(constraintWidget2);
                if (constraintWidget2.m470() && r10) {
                    C2082.m5467(constraintWidget2, r14, new C2088.C2090(), false);
                }
                if (constraintWidget2.m512() != ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT || r10) {
                    if (!constraintWidget2.m470()) {
                        ConstraintAnchor constraintAnchor6 = constraintWidget2.f885;
                        if (next == constraintAnchor6 && constraintWidget2.f841.f812 == null) {
                            int r5 = constraintAnchor6.m456() + r3;
                            constraintWidget2.m481(r5, constraintWidget2.m473() + r5);
                            m5518(constraintWidget2, r14);
                        } else {
                            ConstraintAnchor constraintAnchor7 = constraintWidget2.f841;
                            if (next == constraintAnchor7 && constraintAnchor7.f812 == null) {
                                int r52 = r3 - constraintAnchor7.m456();
                                constraintWidget2.m481(r52 - constraintWidget2.m473(), r52);
                                m5518(constraintWidget2, r14);
                            } else if (next == constraintWidget2.f885 && (constraintAnchor3 = constraintWidget2.f841.f812) != null && constraintAnchor3.f806) {
                                m5520(r14, constraintWidget2);
                            }
                        }
                    }
                } else if (constraintWidget2.m512() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && ((constraintWidget2.f840 == 8 || (constraintWidget2.f827 == 0 && constraintWidget2.f842 == 0.0f)) && !constraintWidget2.m514() && !constraintWidget2.f863)) {
                    if (((next == constraintWidget2.f885 && (constraintAnchor5 = constraintWidget2.f841.f812) != null && constraintAnchor5.f806) || (next == constraintWidget2.f841 && (constraintAnchor4 = constraintWidget2.f885.f812) != null && constraintAnchor4.f806)) && !constraintWidget2.m514()) {
                        m5519(constraintWidget, r14, constraintWidget2);
                    }
                }
            }
        }
        if (!(constraintWidget instanceof C2083)) {
            HashSet<ConstraintAnchor> hashSet2 = r2.f811;
            if (hashSet2 != null && r2.f806) {
                Iterator<ConstraintAnchor> it3 = hashSet2.iterator();
                while (it3.hasNext()) {
                    ConstraintAnchor next2 = it3.next();
                    ConstraintWidget constraintWidget3 = next2.f813;
                    boolean r53 = m5525(constraintWidget3);
                    if (constraintWidget3.m470() && r53) {
                        C2082.m5467(constraintWidget3, r14, new C2088.C2090(), false);
                    }
                    boolean z = (next2 == constraintWidget3.f885 && (constraintAnchor2 = constraintWidget3.f841.f812) != null && constraintAnchor2.f806) || (next2 == constraintWidget3.f841 && (constraintAnchor = constraintWidget3.f885.f812) != null && constraintAnchor.f806);
                    if (constraintWidget3.m512() != ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT || r53) {
                        if (!constraintWidget3.m470()) {
                            ConstraintAnchor constraintAnchor8 = constraintWidget3.f885;
                            if (next2 == constraintAnchor8 && constraintWidget3.f841.f812 == null) {
                                int r22 = constraintAnchor8.m456() + r4;
                                constraintWidget3.m481(r22, constraintWidget3.m473() + r22);
                                m5518(constraintWidget3, r14);
                            } else {
                                ConstraintAnchor constraintAnchor9 = constraintWidget3.f841;
                                if (next2 == constraintAnchor9 && constraintWidget3.f885.f812 == null) {
                                    int r23 = r4 - constraintAnchor9.m456();
                                    constraintWidget3.m481(r23 - constraintWidget3.m473(), r23);
                                    m5518(constraintWidget3, r14);
                                } else if (z && !constraintWidget3.m514()) {
                                    m5520(r14, constraintWidget3);
                                }
                            }
                        }
                    } else if (constraintWidget3.m512() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && ((constraintWidget3.f840 == 8 || (constraintWidget3.f827 == 0 && constraintWidget3.f842 == 0.0f)) && !constraintWidget3.m514() && !constraintWidget3.f863 && z && !constraintWidget3.m514())) {
                        m5519(constraintWidget, r14, constraintWidget3);
                    }
                }
            }
            ConstraintAnchor r13 = constraintWidget.m488(ConstraintAnchor.Type.BASELINE);
            if (r13.f811 != null && r13.f806) {
                int r02 = r13.m459();
                Iterator<ConstraintAnchor> it4 = r13.f811.iterator();
                while (it4.hasNext()) {
                    ConstraintAnchor next3 = it4.next();
                    ConstraintWidget constraintWidget4 = next3.f813;
                    boolean r42 = m5525(constraintWidget4);
                    if (constraintWidget4.m470() && r42) {
                        C2082.m5467(constraintWidget4, r14, new C2088.C2090(), false);
                    }
                    if ((constraintWidget4.m512() != ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT || r42) && !constraintWidget4.m470() && next3 == constraintWidget4.f897) {
                        if (constraintWidget4.f852) {
                            int i = r02 - constraintWidget4.f865;
                            int i2 = constraintWidget4.f819 + i;
                            constraintWidget4.f892 = i;
                            constraintWidget4.f885.m460(i);
                            constraintWidget4.f841.m460(i2);
                            ConstraintAnchor constraintAnchor10 = constraintWidget4.f897;
                            constraintAnchor10.f809 = r02;
                            constraintAnchor10.f806 = true;
                            constraintWidget4.f871 = true;
                        }
                        m5518(constraintWidget4, r14);
                    }
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m5523(C2082 r12, C2088.AbstractC2089 r13) {
        ConstraintWidget.DimensionBehaviour r0 = r12.m508();
        ConstraintWidget.DimensionBehaviour r1 = r12.m512();
        r12.m472();
        ArrayList<ConstraintWidget> arrayList = r12.f7284;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            arrayList.get(i).m472();
        }
        if (r0 == ConstraintWidget.DimensionBehaviour.FIXED) {
            r12.m489(0, r12.m478());
        } else {
            ConstraintAnchor constraintAnchor = r12.f820;
            constraintAnchor.f809 = 0;
            constraintAnchor.f806 = true;
            r12.f822 = 0;
        }
        boolean z = false;
        boolean z2 = false;
        for (int i2 = 0; i2 < size; i2++) {
            ConstraintWidget constraintWidget = arrayList.get(i2);
            if (constraintWidget instanceof C2083) {
                C2083 r10 = (C2083) constraintWidget;
                if (r10.f7203 == 1) {
                    int i3 = r10.f7205;
                    if (i3 != -1) {
                        r10.m5491(i3);
                    } else if (r10.f7206 != -1 && r12.m504()) {
                        r10.m5491(r12.m478() - r10.f7206);
                    } else if (r12.m504()) {
                        r10.m5491((int) ((r10.f7208 * ((float) r12.m478())) + 0.5f));
                    }
                    z = true;
                }
            } else if ((constraintWidget instanceof C2103) && ((C2103) constraintWidget).m5566() == 0) {
                z2 = true;
            }
        }
        if (z) {
            for (int i4 = 0; i4 < size; i4++) {
                ConstraintWidget constraintWidget2 = arrayList.get(i4);
                if (constraintWidget2 instanceof C2083) {
                    C2083 r5 = (C2083) constraintWidget2;
                    if (r5.f7203 == 1) {
                        m5521(r5, r13);
                    }
                }
            }
        }
        m5521((ConstraintWidget) r12, r13);
        if (z2) {
            for (int i5 = 0; i5 < size; i5++) {
                ConstraintWidget constraintWidget3 = arrayList.get(i5);
                if (constraintWidget3 instanceof C2103) {
                    C2103 k = (C2103) constraintWidget3;
                    if (k.m5566() == 0 && k.m5560()) {
                        m5521(k, r13);
                    }
                }
            }
        }
        if (r1 == ConstraintWidget.DimensionBehaviour.FIXED) {
            r12.m481(0, r12.m473());
        } else {
            ConstraintAnchor constraintAnchor2 = r12.f885;
            constraintAnchor2.f809 = 0;
            constraintAnchor2.f806 = true;
            r12.f892 = 0;
        }
        boolean z3 = false;
        boolean z4 = false;
        for (int i6 = 0; i6 < size; i6++) {
            ConstraintWidget constraintWidget4 = arrayList.get(i6);
            if (constraintWidget4 instanceof C2083) {
                C2083 r7 = (C2083) constraintWidget4;
                if (r7.f7203 == 0) {
                    int i7 = r7.f7205;
                    if (i7 != -1) {
                        r7.m5491(i7);
                    } else if (r7.f7206 != -1 && r12.m471()) {
                        r7.m5491(r12.m473() - r7.f7206);
                    } else if (r12.m471()) {
                        r7.m5491((int) ((r7.f7208 * ((float) r12.m473())) + 0.5f));
                    }
                    z3 = true;
                }
            } else if ((constraintWidget4 instanceof C2103) && ((C2103) constraintWidget4).m5566() == 1) {
                z4 = true;
            }
        }
        if (z3) {
            for (int i8 = 0; i8 < size; i8++) {
                ConstraintWidget constraintWidget5 = arrayList.get(i8);
                if (constraintWidget5 instanceof C2083) {
                    C2083 r14 = (C2083) constraintWidget5;
                    if (r14.f7203 == 0) {
                        m5518(r14, r13);
                    }
                }
            }
        }
        m5518(r12, r13);
        if (z4) {
            for (int i9 = 0; i9 < size; i9++) {
                ConstraintWidget constraintWidget6 = arrayList.get(i9);
                if (constraintWidget6 instanceof C2103) {
                    C2103 k2 = (C2103) constraintWidget6;
                    if (k2.m5566() == 1 && k2.m5560()) {
                        m5518(k2, r13);
                    }
                }
            }
        }
        for (int i10 = 0; i10 < size; i10++) {
            ConstraintWidget constraintWidget7 = arrayList.get(i10);
            if (constraintWidget7.m470() && m5525(constraintWidget7)) {
                C2082.m5467(constraintWidget7, r13, f7236, false);
                m5521(constraintWidget7, r13);
                m5518(constraintWidget7, r13);
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m5521(ConstraintWidget constraintWidget, C2088.AbstractC2089 r14) {
        HashSet<ConstraintAnchor> hashSet;
        ConstraintAnchor constraintAnchor;
        ConstraintAnchor constraintAnchor2;
        ConstraintAnchor constraintAnchor3;
        ConstraintAnchor constraintAnchor4;
        ConstraintAnchor constraintAnchor5;
        if (!(constraintWidget instanceof C2082) && constraintWidget.m470() && m5525(constraintWidget)) {
            C2082.m5467(constraintWidget, r14, new C2088.C2090(), false);
        }
        ConstraintAnchor r0 = constraintWidget.m488(ConstraintAnchor.Type.LEFT);
        ConstraintAnchor r2 = constraintWidget.m488(ConstraintAnchor.Type.RIGHT);
        int r3 = r0.m459();
        int r4 = r2.m459();
        HashSet<ConstraintAnchor> hashSet2 = r0.f811;
        if (hashSet2 != null && r0.f806) {
            Iterator<ConstraintAnchor> it2 = hashSet2.iterator();
            while (it2.hasNext()) {
                ConstraintAnchor next = it2.next();
                ConstraintWidget constraintWidget2 = next.f813;
                boolean r10 = m5525(constraintWidget2);
                if (constraintWidget2.m470() && r10) {
                    C2082.m5467(constraintWidget2, r14, new C2088.C2090(), false);
                }
                if (constraintWidget2.m508() != ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT || r10) {
                    if (!constraintWidget2.m470()) {
                        ConstraintAnchor constraintAnchor6 = constraintWidget2.f820;
                        if (next == constraintAnchor6 && constraintWidget2.f833.f812 == null) {
                            int r5 = constraintAnchor6.m456() + r3;
                            constraintWidget2.m489(r5, constraintWidget2.m478() + r5);
                            m5521(constraintWidget2, r14);
                        } else {
                            ConstraintAnchor constraintAnchor7 = constraintWidget2.f833;
                            if (next == constraintAnchor7 && constraintWidget2.f820.f812 == null) {
                                int r52 = r3 - constraintAnchor7.m456();
                                constraintWidget2.m489(r52 - constraintWidget2.m478(), r52);
                                m5521(constraintWidget2, r14);
                            } else if (next == constraintWidget2.f820 && (constraintAnchor3 = constraintWidget2.f833.f812) != null && constraintAnchor3.f806 && !constraintWidget2.m503()) {
                                m5524(r14, constraintWidget2);
                            }
                        }
                    }
                } else if (constraintWidget2.m508() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && ((constraintWidget2.f840 == 8 || (constraintWidget2.f874 == 0 && constraintWidget2.f842 == 0.0f)) && !constraintWidget2.m503() && !constraintWidget2.f863)) {
                    if (((next == constraintWidget2.f820 && (constraintAnchor5 = constraintWidget2.f833.f812) != null && constraintAnchor5.f806) || (next == constraintWidget2.f833 && (constraintAnchor4 = constraintWidget2.f820.f812) != null && constraintAnchor4.f806)) && !constraintWidget2.m503()) {
                        m5522(constraintWidget, r14, constraintWidget2);
                    }
                }
            }
        }
        if (!(constraintWidget instanceof C2083) && (hashSet = r2.f811) != null && r2.f806) {
            Iterator<ConstraintAnchor> it3 = hashSet.iterator();
            while (it3.hasNext()) {
                ConstraintAnchor next2 = it3.next();
                ConstraintWidget constraintWidget3 = next2.f813;
                boolean r53 = m5525(constraintWidget3);
                if (constraintWidget3.m470() && r53) {
                    C2082.m5467(constraintWidget3, r14, new C2088.C2090(), false);
                }
                boolean z = (next2 == constraintWidget3.f820 && (constraintAnchor2 = constraintWidget3.f833.f812) != null && constraintAnchor2.f806) || (next2 == constraintWidget3.f833 && (constraintAnchor = constraintWidget3.f820.f812) != null && constraintAnchor.f806);
                if (constraintWidget3.m508() != ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT || r53) {
                    if (!constraintWidget3.m470()) {
                        ConstraintAnchor constraintAnchor8 = constraintWidget3.f820;
                        if (next2 == constraintAnchor8 && constraintWidget3.f833.f812 == null) {
                            int r22 = constraintAnchor8.m456() + r4;
                            constraintWidget3.m489(r22, constraintWidget3.m478() + r22);
                            m5521(constraintWidget3, r14);
                        } else {
                            ConstraintAnchor constraintAnchor9 = constraintWidget3.f833;
                            if (next2 == constraintAnchor9 && constraintWidget3.f820.f812 == null) {
                                int r23 = r4 - constraintAnchor9.m456();
                                constraintWidget3.m489(r23 - constraintWidget3.m478(), r23);
                                m5521(constraintWidget3, r14);
                            } else if (z && !constraintWidget3.m503()) {
                                m5524(r14, constraintWidget3);
                            }
                        }
                    }
                } else if (constraintWidget3.m508() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && ((constraintWidget3.f840 == 8 || (constraintWidget3.f874 == 0 && constraintWidget3.f842 == 0.0f)) && !constraintWidget3.m503() && !constraintWidget3.f863 && z && !constraintWidget3.m503())) {
                    m5522(constraintWidget, r14, constraintWidget3);
                }
            }
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static void m5520(C2088.AbstractC2089 r6, ConstraintWidget constraintWidget) {
        float f = constraintWidget.f888;
        int r1 = constraintWidget.f885.f812.m459();
        int r2 = constraintWidget.f841.f812.m459();
        int r3 = constraintWidget.f885.m456() + r1;
        int r4 = r2 - constraintWidget.f841.m456();
        if (r1 == r2) {
            f = 0.5f;
        } else {
            r1 = r3;
            r2 = r4;
        }
        int r32 = constraintWidget.m473();
        int i = (r2 - r1) - r32;
        if (r1 > r2) {
            i = (r1 - r2) - r32;
        }
        int i2 = (int) ((f * ((float) i)) + 0.5f);
        int i3 = r1 + i2;
        int i4 = i3 + r32;
        if (r1 > r2) {
            i3 = r1 - i2;
            i4 = i3 - r32;
        }
        constraintWidget.m481(i3, i4);
        m5518(constraintWidget, r6);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static void m5519(ConstraintWidget constraintWidget, C2088.AbstractC2089 r8, ConstraintWidget constraintWidget2) {
        int i;
        float f = constraintWidget2.f888;
        int r2 = constraintWidget2.f885.m456() + constraintWidget2.f885.f812.m459();
        int r1 = constraintWidget2.f841.f812.m459() - constraintWidget2.f841.m456();
        if (r1 >= r2) {
            int r3 = constraintWidget2.m473();
            if (constraintWidget2.f840 != 8) {
                int i2 = constraintWidget2.f827;
                if (i2 == 2) {
                    if (constraintWidget instanceof C2082) {
                        i = constraintWidget.m473();
                    } else {
                        i = constraintWidget.f867.m473();
                    }
                    r3 = (int) (f * 0.5f * ((float) i));
                } else if (i2 == 0) {
                    r3 = r1 - r2;
                }
                r3 = Math.max(constraintWidget2.f824, r3);
                int i3 = constraintWidget2.f894;
                if (i3 > 0) {
                    r3 = Math.min(i3, r3);
                }
            }
            int i4 = r2 + ((int) ((f * ((float) ((r1 - r2) - r3))) + 0.5f));
            constraintWidget2.m481(i4, r3 + i4);
            m5518(constraintWidget2, r8);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static boolean m5525(ConstraintWidget constraintWidget) {
        ConstraintWidget.DimensionBehaviour r0 = constraintWidget.m508();
        ConstraintWidget.DimensionBehaviour r1 = constraintWidget.m512();
        ConstraintWidget constraintWidget2 = constraintWidget.f867;
        C2082 r2 = constraintWidget2 != null ? (C2082) constraintWidget2 : null;
        if (r2 != null) {
            r2.m508();
            ConstraintWidget.DimensionBehaviour dimensionBehaviour = ConstraintWidget.DimensionBehaviour.FIXED;
        }
        if (r2 != null) {
            r2.m512();
            ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = ConstraintWidget.DimensionBehaviour.FIXED;
        }
        boolean z = r0 == ConstraintWidget.DimensionBehaviour.FIXED || r0 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT || (r0 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && constraintWidget.f874 == 0 && constraintWidget.f842 == 0.0f && constraintWidget.m509(0)) || constraintWidget.m504();
        boolean z2 = r1 == ConstraintWidget.DimensionBehaviour.FIXED || r1 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT || (r1 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && constraintWidget.f827 == 0 && constraintWidget.f842 == 0.0f && constraintWidget.m509(1)) || constraintWidget.m471();
        if (constraintWidget.f842 > 0.0f && (z || z2)) {
            return true;
        }
        if (!z || !z2) {
            return false;
        }
        return true;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m5524(C2088.AbstractC2089 r7, ConstraintWidget constraintWidget) {
        float f = constraintWidget.f878;
        int r1 = constraintWidget.f820.f812.m459();
        int r2 = constraintWidget.f833.f812.m459();
        int r3 = constraintWidget.f820.m456() + r1;
        int r4 = r2 - constraintWidget.f833.m456();
        if (r1 == r2) {
            f = 0.5f;
        } else {
            r1 = r3;
            r2 = r4;
        }
        int r32 = constraintWidget.m478();
        int i = (r2 - r1) - r32;
        if (r1 > r2) {
            i = (r1 - r2) - r32;
        }
        if (((C2082) constraintWidget.f867).f7189) {
            f = 1.0f - f;
        }
        int i2 = ((int) ((f * ((float) i)) + 0.5f)) + r1;
        int i3 = i2 + r32;
        if (r1 > r2) {
            i3 = i2 - r32;
        }
        constraintWidget.m489(i2, i3);
        m5521(constraintWidget, r7);
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m5522(ConstraintWidget constraintWidget, C2088.AbstractC2089 r8, ConstraintWidget constraintWidget2) {
        int i;
        float f = constraintWidget2.f878;
        int r2 = constraintWidget2.f820.m456() + constraintWidget2.f820.f812.m459();
        int r1 = constraintWidget2.f833.f812.m459() - constraintWidget2.f833.m456();
        if (r1 >= r2) {
            int r3 = constraintWidget2.m478();
            if (constraintWidget2.f840 != 8) {
                int i2 = constraintWidget2.f874;
                if (i2 == 2) {
                    if (constraintWidget instanceof C2082) {
                        i = constraintWidget.m478();
                    } else {
                        i = constraintWidget.f867.m478();
                    }
                    r3 = (int) (constraintWidget2.f878 * 0.5f * ((float) i));
                } else if (i2 == 0) {
                    r3 = r1 - r2;
                }
                r3 = Math.max(constraintWidget2.f877, r3);
                int i3 = constraintWidget2.f829;
                if (i3 > 0) {
                    r3 = Math.min(i3, r3);
                }
            }
            int i4 = r2 + ((int) ((f * ((float) ((r1 - r2) - r3))) + 0.5f));
            constraintWidget2.m489(i4, r3 + i4);
            m5521(constraintWidget2, r8);
        }
    }
}
