package ῲ.ⁱ.ῲ;

import androidx.constraintlayout.solver.SolverVariable;
import java.util.Arrays;
import java.util.Comparator;
import ඓ.K.K.K.C1293;
import ῲ.ⁱ.ῲ.C2073;

/* renamed from: ῲ.ⁱ.ῲ.ⁱ  reason: contains not printable characters */
/* compiled from: PriorityGoalRow */
public class C2075 extends C2073 {

    /* renamed from: ᕣ  reason: contains not printable characters */
    public C2076 f7143;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public SolverVariable[] f7144;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public int f7145 = 128;

    /* renamed from: 㳳  reason: contains not printable characters */
    public int f7146;

    /* renamed from: 㿎  reason: contains not printable characters */
    public SolverVariable[] f7147;

    /* renamed from: ῲ.ⁱ.ῲ.ⁱ$ῲ  reason: contains not printable characters */
    /* compiled from: PriorityGoalRow */
    public class C2076 implements Comparable {

        /* renamed from: ῲ  reason: contains not printable characters */
        public SolverVariable f7149;

        public C2076(C2075 r2) {
        }

        @Override // java.lang.Comparable
        public int compareTo(Object obj) {
            return this.f7149.f789 - ((SolverVariable) obj).f789;
        }

        public String toString() {
            String str = "[ ";
            if (this.f7149 != null) {
                for (int i = 0; i < 9; i++) {
                    StringBuilder r1 = C1293.m3416(str);
                    r1.append(this.f7149.f794[i]);
                    r1.append(" ");
                    str = r1.toString();
                }
            }
            StringBuilder r0 = C1293.m3402(str, "] ");
            r0.append(this.f7149);
            return r0.toString();
        }

        /* renamed from: K  reason: contains not printable characters */
        public final boolean m5427() {
            for (int i = 8; i >= 0; i--) {
                float f = this.f7149.f794[i];
                if (f > 0.0f) {
                    return false;
                }
                if (f < 0.0f) {
                    return true;
                }
            }
            return false;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final boolean m5428(SolverVariable solverVariable) {
            int i = 8;
            while (true) {
                if (i < 0) {
                    break;
                }
                float f = solverVariable.f794[i];
                float f2 = this.f7149.f794[i];
                if (f2 == f) {
                    i--;
                } else if (f2 < f) {
                    return true;
                }
            }
            return false;
        }
    }

    /* renamed from: ῲ.ⁱ.ῲ.ⁱ$K  reason: contains not printable characters */
    /* compiled from: PriorityGoalRow */
    public class C2077 implements Comparator<SolverVariable> {
        public C2077(C2075 r1) {
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
        @Override // java.util.Comparator
        public int compare(SolverVariable solverVariable, SolverVariable solverVariable2) {
            return solverVariable.f789 - solverVariable2.f789;
        }
    }

    public C2075(C2071 r2) {
        super(r2);
        int i = this.f7145;
        this.f7147 = new SolverVariable[i];
        this.f7144 = new SolverVariable[i];
        this.f7146 = 0;
        this.f7143 = new C2076(this);
    }

    @Override // ῲ.ⁱ.ῲ.C2080.AbstractC2081, ῲ.ⁱ.ῲ.C2073
    public void clear() {
        this.f7146 = 0;
        this.f7139 = 0.0f;
    }

    @Override // ῲ.ⁱ.ῲ.C2080.AbstractC2081, ῲ.ⁱ.ῲ.C2073
    public boolean isEmpty() {
        return this.f7146 == 0;
    }

    @Override // ῲ.ⁱ.ῲ.C2073
    public String toString() {
        StringBuilder r0 = C1293.m3402("", " goal -> (");
        r0.append(this.f7139);
        r0.append(") : ");
        String sb = r0.toString();
        for (int i = 0; i < this.f7146; i++) {
            this.f7143.f7149 = this.f7147[i];
            StringBuilder r02 = C1293.m3416(sb);
            r02.append(this.f7143);
            r02.append(" ");
            sb = r02.toString();
        }
        return sb;
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public final void m5422(SolverVariable solverVariable) {
        int i = 0;
        while (i < this.f7146) {
            if (this.f7147[i] == solverVariable) {
                while (true) {
                    int i2 = this.f7146;
                    if (i < i2 - 1) {
                        SolverVariable[] solverVariableArr = this.f7147;
                        int i3 = i + 1;
                        solverVariableArr[i] = solverVariableArr[i3];
                        i = i3;
                    } else {
                        this.f7146 = i2 - 1;
                        solverVariable.f797 = false;
                        return;
                    }
                }
            } else {
                i++;
            }
        }
    }

    @Override // ῲ.ⁱ.ῲ.C2080.AbstractC2081, ῲ.ⁱ.ῲ.C2073
    /* renamed from: K  reason: contains not printable characters */
    public SolverVariable m5423(C2080 r6, boolean[] zArr) {
        int i = -1;
        for (int i2 = 0; i2 < this.f7146; i2++) {
            SolverVariable[] solverVariableArr = this.f7147;
            SolverVariable solverVariable = solverVariableArr[i2];
            if (!zArr[solverVariable.f789]) {
                C2076 r4 = this.f7143;
                r4.f7149 = solverVariable;
                if (i == -1) {
                    if (!r4.m5427()) {
                    }
                } else if (!r4.m5428(solverVariableArr[i])) {
                }
                i = i2;
            }
        }
        if (i == -1) {
            return null;
        }
        return this.f7147[i];
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public final void m5426(SolverVariable solverVariable) {
        int i;
        int i2 = this.f7146 + 1;
        SolverVariable[] solverVariableArr = this.f7147;
        if (i2 > solverVariableArr.length) {
            this.f7147 = (SolverVariable[]) Arrays.copyOf(solverVariableArr, solverVariableArr.length * 2);
            SolverVariable[] solverVariableArr2 = this.f7147;
            this.f7144 = (SolverVariable[]) Arrays.copyOf(solverVariableArr2, solverVariableArr2.length * 2);
        }
        SolverVariable[] solverVariableArr3 = this.f7147;
        int i3 = this.f7146;
        solverVariableArr3[i3] = solverVariable;
        this.f7146 = i3 + 1;
        int i4 = this.f7146;
        if (i4 > 1 && solverVariableArr3[i4 - 1].f789 > solverVariable.f789) {
            int i5 = 0;
            while (true) {
                i = this.f7146;
                if (i5 >= i) {
                    break;
                }
                this.f7144[i5] = this.f7147[i5];
                i5++;
            }
            Arrays.sort(this.f7144, 0, i, new C2077(this));
            for (int i6 = 0; i6 < this.f7146; i6++) {
                this.f7147[i6] = this.f7144[i6];
            }
        }
        solverVariable.f797 = true;
        solverVariable.m451(this);
    }

    @Override // ῲ.ⁱ.ῲ.C2080.AbstractC2081, ῲ.ⁱ.ῲ.C2073
    /* renamed from: K  reason: contains not printable characters */
    public void m5424(SolverVariable solverVariable) {
        C2076 r0 = this.f7143;
        r0.f7149 = solverVariable;
        Arrays.fill(r0.f7149.f794, 0.0f);
        solverVariable.f794[solverVariable.f792] = 1.0f;
        m5426(solverVariable);
    }

    @Override // ῲ.ⁱ.ῲ.C2073
    /* renamed from: K  reason: contains not printable characters */
    public void m5425(C2080 r18, C2073 r19, boolean z) {
        SolverVariable solverVariable = r19.f7140;
        if (solverVariable != null) {
            C2073.AbstractC2074 k = r19.f7138;
            int r4 = k.m5411();
            for (int i = 0; i < r4; i++) {
                SolverVariable r7 = k.m5412(i);
                float r8 = k.m5414(i);
                C2076 r9 = this.f7143;
                r9.f7149 = r7;
                boolean z2 = true;
                if (r9.f7149.f797) {
                    for (int i2 = 0; i2 < 9; i2++) {
                        float[] fArr = r9.f7149.f794;
                        fArr[i2] = (solverVariable.f794[i2] * r8) + fArr[i2];
                        if (Math.abs(fArr[i2]) < 1.0E-4f) {
                            r9.f7149.f794[i2] = 0.0f;
                        } else {
                            z2 = false;
                        }
                    }
                    if (z2) {
                        C2075.this.m5422(r9.f7149);
                    }
                    z2 = false;
                } else {
                    for (int i3 = 0; i3 < 9; i3++) {
                        float f = solverVariable.f794[i3];
                        if (f != 0.0f) {
                            float f2 = f * r8;
                            if (Math.abs(f2) < 1.0E-4f) {
                                f2 = 0.0f;
                            }
                            r9.f7149.f794[i3] = f2;
                        } else {
                            r9.f7149.f794[i3] = 0.0f;
                        }
                    }
                }
                if (z2) {
                    m5426(r7);
                }
                this.f7139 = (r19.f7139 * r8) + this.f7139;
            }
            m5422(solverVariable);
        }
    }
}
