package e9;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import kotlinx.coroutines.y;

/* JADX INFO: loaded from: classes2.dex */
public final class a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f25573a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f25575c;

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final float f25578f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final int f25579g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final float f25580h;

    /* JADX WARN: Removed duplicated region for block: B:43:0x00c6  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00ca  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public a(int i10, float f10, float f11, float f12, int i11, float f13, int i12, float f14, int i13, float f15) {
        float fAbs;
        this.f25573a = i10;
        float f16 = y.f(f10, f11, f12);
        this.f25574b = f16;
        this.f25575c = i11;
        this.f25577e = f13;
        this.f25576d = i12;
        this.f25578f = f14;
        this.f25579g = i13;
        float f17 = i13;
        float f18 = (f13 * i12) + (f14 * f17);
        float f19 = i11;
        float f20 = f15 - ((f16 * f19) + f18);
        if (i11 > 0 && f20 > 0.0f) {
            this.f25574b = Math.min(f20 / f19, f12 - f16) + f16;
        } else if (i11 > 0 && f20 < 0.0f) {
            this.f25574b = Math.max(f20 / f19, f11 - f16) + f16;
        }
        int i14 = this.f25575c;
        float f21 = i14 > 0 ? this.f25574b : 0.0f;
        this.f25574b = f21;
        int i15 = this.f25576d;
        float f22 = i15;
        float f23 = f22 / 2.0f;
        float f24 = (f15 - ((i14 + f23) * (i14 > 0 ? f21 : 0.0f))) / (f23 + f17);
        this.f25578f = f24;
        float f25 = (f21 + f24) / 2.0f;
        this.f25577e = f25;
        if (i15 > 0 && f24 != f14) {
            float f26 = (f14 - f24) * f17;
            float fMin = Math.min(Math.abs(f26), f25 * 0.1f * f22);
            if (f26 > 0.0f) {
                this.f25577e -= fMin / this.f25576d;
                this.f25578f = (fMin / f17) + this.f25578f;
            } else {
                this.f25577e = (fMin / this.f25576d) + this.f25577e;
                this.f25578f -= fMin / f17;
            }
        }
        if (i13 <= 0 || this.f25575c <= 0 || this.f25576d <= 0) {
            fAbs = (i13 <= 0 || this.f25575c <= 0 || this.f25578f > this.f25574b) ? i10 * Math.abs(f14 - this.f25578f) : Float.MAX_VALUE;
        } else {
            float f27 = this.f25578f;
            float f28 = this.f25577e;
            if (f27 <= f28 || f28 <= this.f25574b) {
            }
        }
        this.f25580h = fAbs;
    }

    @Nullable
    public static a findLowestCostArrangement(float f10, float f11, float f12, float f13, @NonNull int[] iArr, float f14, @NonNull int[] iArr2, float f15, @NonNull int[] iArr3) {
        a aVar = null;
        int i10 = 1;
        for (int i11 : iArr3) {
            int length = iArr2.length;
            int i12 = 0;
            while (i12 < length) {
                int i13 = iArr2[i12];
                int length2 = iArr.length;
                int i14 = 0;
                while (i14 < length2) {
                    int i15 = i14;
                    int i16 = length2;
                    int i17 = i12;
                    int i18 = length;
                    a aVar2 = new a(i10, f11, f12, f13, iArr[i14], f14, i13, f15, i11, f10);
                    float f16 = aVar2.f25580h;
                    if (aVar == null || f16 < aVar.f25580h) {
                        if (f16 == 0.0f) {
                            return aVar2;
                        }
                        aVar = aVar2;
                    }
                    i10++;
                    i14 = i15 + 1;
                    length2 = i16;
                    i12 = i17;
                    length = i18;
                }
                i12++;
            }
        }
        return aVar;
    }

    public final String toString() {
        return "Arrangement [priority=" + this.f25573a + ", smallCount=" + this.f25575c + ", smallSize=" + this.f25574b + ", mediumCount=" + this.f25576d + ", mediumSize=" + this.f25577e + ", largeCount=" + this.f25579g + ", largeSize=" + this.f25578f + ", cost=" + this.f25580h + "]";
    }
}
