package androidx.leanback.widget;

/* JADX INFO: loaded from: classes.dex */
final class u0 {
    public final a a;
    public final a b;
    public a c;
    public a d;

    public static final class a {
        public int c;
        public int d;
        public int i;
        public int j;
        public int k;
        public boolean l;
        public int e = 2;
        public int f = 3;
        public int g = 0;
        public float h = 50.0f;
        public int b = Integer.MIN_VALUE;
        public int a = Integer.MAX_VALUE;

        public final int a() {
            if (this.l) {
                int i = this.g;
                int i2 = i >= 0 ? this.i - i : -i;
                float f = this.h;
                return f != -1.0f ? i2 - ((int) ((this.i * f) / 100.0f)) : i2;
            }
            int i3 = this.g;
            if (i3 < 0) {
                i3 += this.i;
            }
            float f2 = this.h;
            return f2 != -1.0f ? i3 + ((int) ((this.i * f2) / 100.0f)) : i3;
        }

        public final int b(int i) {
            int i2;
            int i3;
            int i4 = this.i;
            int iA = a();
            int i5 = this.b;
            boolean z = i5 == Integer.MIN_VALUE;
            int i6 = this.a;
            boolean z2 = i6 == Integer.MAX_VALUE;
            if (!z) {
                int i7 = this.j;
                int i8 = iA - i7;
                if (this.l ? (this.f & 2) != 0 : (this.f & 1) != 0) {
                    if (i - i5 <= i8) {
                        int i9 = i5 - i7;
                        return (z2 || i9 <= (i3 = this.c)) ? i9 : i3;
                    }
                }
            }
            if (!z2) {
                int i10 = this.k;
                int i11 = (i4 - iA) - i10;
                if (this.l ? (1 & this.f) != 0 : (this.f & 2) != 0) {
                    if (i6 - i <= i11) {
                        int i12 = i6 - (i4 - i10);
                        return (z || i12 >= (i2 = this.d)) ? i12 : i2;
                    }
                }
            }
            return i - iA;
        }

        /* JADX WARN: Code restructure failed: missing block: B:17:0x0035, code lost:
        
            r6.d = r0 - r6.j;
         */
        /* JADX WARN: Code restructure failed: missing block: B:27:0x0051, code lost:
        
            r6.c = (r4 - r6.j) - r7;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void c(int i, int i2, int i3, int i4) {
            this.b = i;
            this.a = i2;
            int i5 = (this.i - this.j) - this.k;
            int iA = a();
            int i6 = this.b;
            boolean z = i6 == Integer.MIN_VALUE;
            int i7 = this.a;
            boolean z2 = i7 == Integer.MAX_VALUE;
            if (!z) {
                if (this.l) {
                    this.d = i3 - iA;
                } else {
                    this.d = i3 - iA;
                }
            }
            if (!z2) {
                if (this.l) {
                    this.c = i4 - iA;
                } else {
                    this.c = i4 - iA;
                }
            }
            if (z2 || z) {
                return;
            }
            if (this.l) {
                int i8 = this.f;
                if ((i8 & 1) != 0) {
                    if ((this.e & 1) != 0) {
                        this.c = Math.max(this.c, i3 - iA);
                    }
                    this.d = Math.min(this.d, this.c);
                    return;
                } else {
                    if ((i8 & 2) != 0) {
                        if ((this.e & 2) != 0) {
                            this.d = Math.min(this.d, i4 - iA);
                        }
                        this.c = Math.max(this.d, this.c);
                        return;
                    }
                    return;
                }
            }
            int i9 = this.f;
            if ((i9 & 1) != 0) {
                if ((this.e & 1) != 0) {
                    this.d = Math.min(this.d, i4 - iA);
                }
                this.c = Math.max(this.d, this.c);
            } else if ((i9 & 2) != 0) {
                if ((this.e & 2) != 0) {
                    this.c = Math.max(this.c, i3 - iA);
                }
                this.d = Math.min(this.d, this.c);
            }
        }

        public final String toString() {
            return " min:" + this.b + " " + this.d + " max:" + this.a + " " + this.c;
        }
    }

    public u0() {
        a aVar = new a();
        this.a = aVar;
        a aVar2 = new a();
        this.b = aVar2;
        this.c = aVar2;
        this.d = aVar;
    }

    public final String toString() {
        return "horizontal=" + this.b + "; vertical=" + this.a;
    }
}
