package ῲ.ⁱ.ῲ.㿎.ᕣ;

import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
import androidx.constraintlayout.solver.widgets.analyzer.DependencyNode;
import androidx.constraintlayout.solver.widgets.analyzer.WidgetRun;
import java.util.ArrayList;
import java.util.Iterator;
import ඓ.K.K.K.C1293;
import ῲ.ⁱ.ῲ.㿎.C2082;

/* renamed from: ῲ.ⁱ.ῲ.㿎.ᕣ.ʬ  reason: contains not printable characters */
/* compiled from: ChainRun */
public class C2084 extends WidgetRun {

    /* renamed from: ᕣ  reason: contains not printable characters */
    public ArrayList<WidgetRun> f7209 = new ArrayList<>();

    /* renamed from: 㑃  reason: contains not printable characters */
    public int f7210;

    public C2084(ConstraintWidget constraintWidget, int i) {
        super(constraintWidget);
        int i2;
        this.f926 = i;
        ConstraintWidget constraintWidget2 = this.f922;
        ConstraintWidget r5 = constraintWidget2.m511(this.f926);
        while (true) {
            constraintWidget2 = r5;
            if (constraintWidget2 == null) {
                break;
            }
            r5 = constraintWidget2.m511(this.f926);
        }
        this.f922 = constraintWidget2;
        this.f7209.add(constraintWidget2.m474(this.f926));
        ConstraintWidget r4 = constraintWidget2.m468(this.f926);
        while (r4 != null) {
            this.f7209.add(r4.m474(this.f926));
            r4 = r4.m468(this.f926);
        }
        Iterator<WidgetRun> it2 = this.f7209.iterator();
        while (it2.hasNext()) {
            WidgetRun next = it2.next();
            int i3 = this.f926;
            if (i3 == 0) {
                next.f922.f858 = this;
            } else if (i3 == 1) {
                next.f922.f817 = this;
            }
        }
        if ((this.f926 == 0 && ((C2082) this.f922.f867).f7189) && this.f7209.size() > 1) {
            ArrayList<WidgetRun> arrayList = this.f7209;
            this.f922 = arrayList.get(arrayList.size() - 1).f922;
        }
        if (this.f926 == 0) {
            i2 = this.f922.f898;
        } else {
            i2 = this.f922.f834;
        }
        this.f7210 = i2;
    }

    public String toString() {
        StringBuilder r0 = C1293.m3416("ChainRun ");
        r0.append(this.f926 == 0 ? "horizontal : " : "vertical : ");
        String sb = r0.toString();
        Iterator<WidgetRun> it2 = this.f7209.iterator();
        while (it2.hasNext()) {
            String r02 = C1293.m3412(sb, "<");
            sb = C1293.m3412(r02 + it2.next(), "> ");
        }
        return sb;
    }

    @Override // androidx.constraintlayout.solver.widgets.analyzer.WidgetRun
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m5492() {
        this.f919 = null;
        Iterator<WidgetRun> it2 = this.f7209.iterator();
        while (it2.hasNext()) {
            it2.next().m518();
        }
    }

    @Override // androidx.constraintlayout.solver.widgets.analyzer.WidgetRun
    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean m5493() {
        int size = this.f7209.size();
        for (int i = 0; i < size; i++) {
            if (!this.f7209.get(i).m519()) {
                return false;
            }
        }
        return true;
    }

    @Override // androidx.constraintlayout.solver.widgets.analyzer.WidgetRun
    /* renamed from: ῲ  reason: contains not printable characters */
    public void m5494() {
        for (int i = 0; i < this.f7209.size(); i++) {
            this.f7209.get(i).m520();
        }
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final ConstraintWidget m5495() {
        for (int size = this.f7209.size() - 1; size >= 0; size--) {
            ConstraintWidget constraintWidget = this.f7209.get(size).f922;
            if (constraintWidget.f840 != 8) {
                return constraintWidget;
            }
        }
        return null;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:101:0x0190, code lost:
        if (r7 != r9) goto L_0x01b8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:109:0x01b6, code lost:
        if (r7 != r9) goto L_0x01b8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:54:0x00c5, code lost:
        if (r2.f920.f914 != false) goto L_0x00c7;
     */
    @Override // ῲ.ⁱ.ῲ.㿎.ᕣ.AbstractC2096, androidx.constraintlayout.solver.widgets.analyzer.WidgetRun
    /* renamed from: K  reason: contains not printable characters */
    public void m5497(AbstractC2096 r23) {
        int i;
        int i2;
        int i3;
        int i4;
        int i5;
        float f;
        int i6;
        int i7;
        int i8;
        float f2;
        int i9;
        int i10;
        float f3;
        int i11;
        int i12;
        if (this.f928.f914 && this.f921.f914) {
            ConstraintWidget constraintWidget = this.f922.f867;
            boolean z = (constraintWidget == null || !(constraintWidget instanceof C2082)) ? false : ((C2082) constraintWidget).f7189;
            int i13 = this.f921.f911 - this.f928.f911;
            int size = this.f7209.size();
            int i14 = 0;
            while (true) {
                i = -1;
                i2 = 8;
                if (i14 >= size) {
                    i14 = -1;
                    break;
                }
                if (this.f7209.get(i14).f922.f840 != 8) {
                    break;
                }
                i14++;
            }
            int i15 = size - 1;
            int i16 = i15;
            while (true) {
                if (i16 < 0) {
                    break;
                }
                if (this.f7209.get(i16).f922.f840 != 8) {
                    i = i16;
                    break;
                }
                i16--;
            }
            int i17 = 0;
            while (true) {
                if (i17 >= 2) {
                    i3 = 0;
                    i4 = 0;
                    i5 = 0;
                    f = 0.0f;
                    break;
                }
                int i18 = 0;
                i4 = 0;
                i5 = 0;
                i12 = 0;
                f = 0.0f;
                while (i18 < size) {
                    WidgetRun widgetRun = this.f7209.get(i18);
                    if (widgetRun.f922.f840 != i2) {
                        i12++;
                        if (i18 > 0 && i18 >= i14) {
                            i4 += widgetRun.f928.f915;
                        }
                        int i19 = widgetRun.f920.f911;
                        boolean z2 = widgetRun.f927 != ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT;
                        if (!z2) {
                            if (widgetRun.f924 == 1 && i17 == 0) {
                                i19 = widgetRun.f920.f7240;
                                i5++;
                            }
                            z2 = true;
                        } else if (this.f926 != 0 || widgetRun.f922.f896.f920.f914) {
                            if (this.f926 == 1 && !widgetRun.f922.f835.f920.f914) {
                                return;
                            }
                        } else {
                            return;
                        }
                        if (!z2) {
                            i5++;
                            float f4 = widgetRun.f922.f883[this.f926];
                            if (f4 >= 0.0f) {
                                f += f4;
                            }
                        } else {
                            i4 += i19;
                        }
                        if (i18 < i15 && i18 < i) {
                            i4 += -widgetRun.f921.f915;
                        }
                    }
                    i18++;
                    i2 = 8;
                }
                if (i4 < i13 || i5 == 0) {
                    i3 = i12;
                } else {
                    i17++;
                    i2 = 8;
                }
            }
            i3 = i12;
            int i20 = this.f928.f911;
            if (z) {
                i20 = this.f921.f911;
            }
            if (i4 > i13) {
                i20 = z ? i20 + ((int) ((((float) (i4 - i13)) / 2.0f) + 0.5f)) : i20 - ((int) ((((float) (i4 - i13)) / 2.0f) + 0.5f));
            }
            if (i5 > 0) {
                float f5 = (float) (i13 - i4);
                int i21 = (int) ((f5 / ((float) i5)) + 0.5f);
                int i22 = 0;
                int i23 = 0;
                while (i22 < size) {
                    WidgetRun widgetRun2 = this.f7209.get(i22);
                    ConstraintWidget constraintWidget2 = widgetRun2.f922;
                    if (constraintWidget2.f840 != 8 && widgetRun2.f927 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && !widgetRun2.f920.f914) {
                        int i24 = f > 0.0f ? (int) (((constraintWidget2.f883[this.f926] * f5) / f) + 0.5f) : i21;
                        if (this.f926 == 0) {
                            ConstraintWidget constraintWidget3 = widgetRun2.f922;
                            int i25 = constraintWidget3.f829;
                            f3 = f5;
                            i10 = i20;
                            i11 = Math.max(constraintWidget3.f877, widgetRun2.f924 == 1 ? Math.min(i24, widgetRun2.f920.f7240) : i24);
                            if (i25 > 0) {
                                i11 = Math.min(i25, i11);
                            }
                        } else {
                            i10 = i20;
                            f3 = f5;
                            ConstraintWidget constraintWidget4 = widgetRun2.f922;
                            int i26 = constraintWidget4.f894;
                            i11 = Math.max(constraintWidget4.f824, widgetRun2.f924 == 1 ? Math.min(i24, widgetRun2.f920.f7240) : i24);
                            if (i26 > 0) {
                                i11 = Math.min(i26, i11);
                            }
                        }
                        i23++;
                        i24 = i11;
                        widgetRun2.f920.m5539(i24);
                    } else {
                        i10 = i20;
                        f3 = f5;
                    }
                    i22++;
                    i21 = i21;
                    i4 = i4;
                    f5 = f3;
                    i20 = i10;
                }
                i6 = i20;
                if (i23 > 0) {
                    i5 -= i23;
                    int i27 = 0;
                    for (int i28 = 0; i28 < size; i28++) {
                        WidgetRun widgetRun3 = this.f7209.get(i28);
                        if (widgetRun3.f922.f840 != 8) {
                            if (i28 > 0 && i28 >= i14) {
                                i27 += widgetRun3.f928.f915;
                            }
                            i27 += widgetRun3.f920.f911;
                            if (i28 < i15 && i28 < i) {
                                i27 += -widgetRun3.f921.f915;
                            }
                        }
                    }
                    i4 = i27;
                } else {
                    i4 = i4;
                }
                i7 = 2;
                if (this.f7210 == 2 && i23 == 0) {
                    i8 = 0;
                    this.f7210 = 0;
                } else {
                    i8 = 0;
                }
            } else {
                i6 = i20;
                i8 = 0;
                i7 = 2;
            }
            if (i4 > i13) {
                this.f7210 = i7;
            }
            if (i3 > 0 && i5 == 0 && i14 == i) {
                this.f7210 = i7;
            }
            int i29 = this.f7210;
            if (i29 == 1) {
                if (i3 > 1) {
                    i9 = (i13 - i4) / (i3 - 1);
                } else {
                    i9 = i3 == 1 ? (i13 - i4) / 2 : 0;
                }
                if (i5 > 0) {
                    i9 = 0;
                }
                int i30 = i6;
                while (i8 < size) {
                    WidgetRun widgetRun4 = this.f7209.get(z ? size - (i8 + 1) : i8);
                    if (widgetRun4.f922.f840 == 8) {
                        widgetRun4.f928.m516(i30);
                        widgetRun4.f921.m516(i30);
                    } else {
                        if (i8 > 0) {
                            i30 = z ? i30 - i9 : i30 + i9;
                        }
                        if (i8 > 0 && i8 >= i14) {
                            if (z) {
                                i30 -= widgetRun4.f928.f915;
                            } else {
                                i30 += widgetRun4.f928.f915;
                            }
                        }
                        if (z) {
                            widgetRun4.f921.m516(i30);
                        } else {
                            widgetRun4.f928.m516(i30);
                        }
                        C2095 r10 = widgetRun4.f920;
                        int i31 = r10.f911;
                        if (widgetRun4.f927 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && widgetRun4.f924 == 1) {
                            i31 = r10.f7240;
                        }
                        i30 = z ? i30 - i31 : i30 + i31;
                        if (z) {
                            widgetRun4.f928.m516(i30);
                        } else {
                            widgetRun4.f921.m516(i30);
                        }
                        widgetRun4.f923 = true;
                        if (i8 < i15 && i8 < i) {
                            i30 = z ? i30 - (-widgetRun4.f921.f915) : i30 + (-widgetRun4.f921.f915);
                        }
                    }
                    i8++;
                }
            } else if (i29 == 0) {
                int i32 = (i13 - i4) / (i3 + 1);
                if (i5 > 0) {
                    i32 = 0;
                }
                int i33 = i6;
                while (i8 < size) {
                    WidgetRun widgetRun5 = this.f7209.get(z ? size - (i8 + 1) : i8);
                    if (widgetRun5.f922.f840 == 8) {
                        widgetRun5.f928.m516(i33);
                        widgetRun5.f921.m516(i33);
                    } else {
                        int i34 = z ? i33 - i32 : i33 + i32;
                        if (i8 > 0 && i8 >= i14) {
                            i34 = z ? i34 - widgetRun5.f928.f915 : i34 + widgetRun5.f928.f915;
                        }
                        if (z) {
                            widgetRun5.f921.m516(i34);
                        } else {
                            widgetRun5.f928.m516(i34);
                        }
                        C2095 r102 = widgetRun5.f920;
                        int i35 = r102.f911;
                        if (widgetRun5.f927 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && widgetRun5.f924 == 1) {
                            i35 = Math.min(i35, r102.f7240);
                        }
                        i33 = z ? i34 - i35 : i34 + i35;
                        if (z) {
                            widgetRun5.f928.m516(i33);
                        } else {
                            widgetRun5.f921.m516(i33);
                        }
                        if (i8 < i15 && i8 < i) {
                            i33 = z ? i33 - (-widgetRun5.f921.f915) : i33 + (-widgetRun5.f921.f915);
                        }
                    }
                    i8++;
                }
            } else if (i29 == 2) {
                if (this.f926 == 0) {
                    f2 = this.f922.f878;
                } else {
                    f2 = this.f922.f888;
                }
                if (z) {
                    f2 = 1.0f - f2;
                }
                int i36 = (int) ((((float) (i13 - i4)) * f2) + 0.5f);
                if (i36 < 0 || i5 > 0) {
                    i36 = 0;
                }
                int i37 = z ? i6 - i36 : i6 + i36;
                while (i8 < size) {
                    WidgetRun widgetRun6 = this.f7209.get(z ? size - (i8 + 1) : i8);
                    if (widgetRun6.f922.f840 == 8) {
                        widgetRun6.f928.m516(i37);
                        widgetRun6.f921.m516(i37);
                    } else {
                        if (i8 > 0 && i8 >= i14) {
                            if (z) {
                                i37 -= widgetRun6.f928.f915;
                            } else {
                                i37 += widgetRun6.f928.f915;
                            }
                        }
                        if (z) {
                            widgetRun6.f921.m516(i37);
                        } else {
                            widgetRun6.f928.m516(i37);
                        }
                        C2095 r9 = widgetRun6.f920;
                        int i38 = r9.f911;
                        if (widgetRun6.f927 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
                            if (widgetRun6.f924 == 1) {
                                i38 = r9.f7240;
                            }
                        }
                        i37 = z ? i37 - i38 : i37 + i38;
                        if (z) {
                            widgetRun6.f928.m516(i37);
                        } else {
                            widgetRun6.f921.m516(i37);
                        }
                        if (i8 < i15 && i8 < i) {
                            i37 = z ? i37 - (-widgetRun6.f921.f915) : i37 + (-widgetRun6.f921.f915);
                        }
                    }
                    i8++;
                }
            }
        }
    }

    /* renamed from: 㴹  reason: contains not printable characters */
    public final ConstraintWidget m5498() {
        for (int i = 0; i < this.f7209.size(); i++) {
            ConstraintWidget constraintWidget = this.f7209.get(i).f922;
            if (constraintWidget.f840 != 8) {
                return constraintWidget;
            }
        }
        return null;
    }

    @Override // androidx.constraintlayout.solver.widgets.analyzer.WidgetRun
    /* renamed from: 㸾  reason: contains not printable characters */
    public long m5499() {
        int size = this.f7209.size();
        long j = 0;
        for (int i = 0; i < size; i++) {
            WidgetRun widgetRun = this.f7209.get(i);
            j = ((long) widgetRun.f921.f915) + widgetRun.m529() + j + ((long) widgetRun.f928.f915);
        }
        return j;
    }

    @Override // androidx.constraintlayout.solver.widgets.analyzer.WidgetRun
    /* renamed from: K  reason: contains not printable characters */
    public void m5496() {
        Iterator<WidgetRun> it2 = this.f7209.iterator();
        while (it2.hasNext()) {
            it2.next().m524();
        }
        int size = this.f7209.size();
        if (size >= 1) {
            ConstraintWidget constraintWidget = this.f7209.get(0).f922;
            ConstraintWidget constraintWidget2 = this.f7209.get(size - 1).f922;
            if (this.f926 == 0) {
                ConstraintAnchor constraintAnchor = constraintWidget.f820;
                ConstraintAnchor constraintAnchor2 = constraintWidget2.f833;
                DependencyNode r2 = m523(constraintAnchor, 0);
                int r1 = constraintAnchor.m456();
                ConstraintWidget r4 = m5498();
                if (r4 != null) {
                    r1 = r4.f820.m456();
                }
                if (r2 != null) {
                    DependencyNode dependencyNode = this.f928;
                    dependencyNode.f913.add(r2);
                    dependencyNode.f915 = r1;
                    r2.f908.add(dependencyNode);
                }
                DependencyNode r12 = m523(constraintAnchor2, 0);
                int r0 = constraintAnchor2.m456();
                ConstraintWidget r22 = m5495();
                if (r22 != null) {
                    r0 = r22.f833.m456();
                }
                if (r12 != null) {
                    DependencyNode dependencyNode2 = this.f921;
                    dependencyNode2.f913.add(r12);
                    dependencyNode2.f915 = -r0;
                    r12.f908.add(dependencyNode2);
                }
            } else {
                ConstraintAnchor constraintAnchor3 = constraintWidget.f885;
                ConstraintAnchor constraintAnchor4 = constraintWidget2.f841;
                DependencyNode r3 = m523(constraintAnchor3, 1);
                int r23 = constraintAnchor3.m456();
                ConstraintWidget r42 = m5498();
                if (r42 != null) {
                    r23 = r42.f885.m456();
                }
                if (r3 != null) {
                    DependencyNode dependencyNode3 = this.f928;
                    dependencyNode3.f913.add(r3);
                    dependencyNode3.f915 = r23;
                    r3.f908.add(dependencyNode3);
                }
                DependencyNode r13 = m523(constraintAnchor4, 1);
                int r02 = constraintAnchor4.m456();
                ConstraintWidget r24 = m5495();
                if (r24 != null) {
                    r02 = r24.f841.m456();
                }
                if (r13 != null) {
                    DependencyNode dependencyNode4 = this.f921;
                    dependencyNode4.f913.add(r13);
                    dependencyNode4.f915 = -r02;
                    r13.f908.add(dependencyNode4);
                }
            }
            this.f928.f912 = this;
            this.f921.f912 = this;
        }
    }
}
