/*
 * Decompiled with CFR 0.152.
 */
public abstract class gm {
    private gh b;
    public int p;
    public int q;
    public int r;
    public int s;
    public boolean t = true;
    public boolean u;
    public fs v;

    public abstract void b(ht var1, int var2, int var3);

    public final int b(nj nj2) {
        return this.a(nj2, nj2.a, nj2.b);
    }

    public final boolean a(int n, int n2, boolean bl2) {
        return this.a(n, n2, new int[]{0, 0}, true, bl2);
    }

    public final boolean a(int n, gh gh2) {
        return this.a(n, gh2, false);
    }

    public final boolean n(int n) {
        return this.a(n, null, true);
    }

    public void a(boolean bl2) {
        this.t();
    }

    public final gh u() {
        gh gh2 = this.b;
        this.b = null;
        return gh2;
    }

    public void b(gh gh2) {
        gh2.a = 0;
        gh2.b = 0;
        gh2.c = this.r;
        gh2.d = this.s;
    }

    public int b(nj nj2, int n, int n2) {
        return -1;
    }

    public int a(nj nj2) {
        return -1;
    }

    public int a(pb pb2) {
        return -1;
    }

    public boolean A() {
        return false;
    }

    public boolean b() {
        return false;
    }

    public void c_(int n) {
    }

    public void b(int n, int n2) {
    }

    public void a(int n, int n2) {
    }

    public void p() {
        this.a(false);
    }

    public final void t() {
        this.c(0, 0, this.r, this.s);
    }

    public gm(int n, int n2, int n3, int n4) {
        this.p = n;
        this.q = n2;
        this.r = n3;
        this.s = n4;
    }

    public gm() {
    }

    public final int w() {
        return this.q + this.s;
    }

    public final int v() {
        return this.p + this.r;
    }

    public int h() {
        return this.r;
    }

    public int i() {
        return this.s;
    }

    public int g() {
        if (this.b()) {
            return 1000;
        }
        return 0;
    }

    public final boolean z() {
        if (this.b()) {
            this.o();
            return true;
        }
        return false;
    }

    public boolean t_() {
        return this.v == null || this == this.v.q();
    }

    public final boolean o(int n) {
        return 0 != (0 & n);
    }

    public final void c(boolean bl2) {
        if (this.t != bl2) {
            this.t = bl2;
            this.t();
        }
    }

    public final void m(int n) {
        if (this.s != n) {
            int n2 = this.s;
            this.s = n;
            this.b(this.p, this.q, this.r, n2);
        }
    }

    public final void l(int n) {
        if (this.r != n) {
            int n2 = this.r;
            this.r = n;
            this.b(this.p, this.q, n2, this.s);
        }
    }

    public final void j(int n) {
        if (this.p != n) {
            int n2 = this.p;
            this.p = n;
            this.b(n2, this.q, this.r, this.s);
        }
    }

    public final void k(int n) {
        if (this.q != n) {
            int n2 = this.q;
            this.q = n;
            this.b(this.p, n2, this.r, this.s);
        }
    }

    public final boolean g(int n, int n2) {
        return n >= 0 && n2 >= 0 && n < this.r && n2 < this.s;
    }

    public final int k(gm gm2) {
        if (gm2 != this) {
            return this.v.k(gm2) + this.q + this.v.f();
        }
        return 0;
    }

    public final int j(gm gm2) {
        if (gm2 != this) {
            return this.v.j(gm2) + this.p + this.v.r_();
        }
        return 0;
    }

    public boolean a(int n, gh gh2, boolean bl2) {
        if (!this.t_() && this.b()) {
            if (gh2 != null) {
                gh2.a = 0;
                gh2.b = 0;
                gh2.c = this.r;
                gh2.d = this.s;
            }
            if (bl2) {
                this.z();
            }
            return true;
        }
        return false;
    }

    public boolean a(int n, int n2, int[] nArray, boolean bl2, boolean bl3) {
        block5: {
            block4: {
                if (!this.b()) break block4;
                int n3 = this.r;
                int n4 = this.s;
                n3 = n >= 0 ? (n > n3 ? n - n3 : 0) : -n;
                n = n2 >= 0 ? (n2 <= n4 ? 0 : n2 - n4) : -n2;
                nArray[0] = n3;
                nArray[1] = n;
                if (n3 == 0 && n == 0 || !bl3) break block5;
            }
            return false;
        }
        if (bl2) {
            this.o();
        }
        return true;
    }

    public final void a(ht ht2, int n, int n2) {
        int n3 = n + this.p;
        n2 += this.q;
        if (this.t) {
            n = ht2.f();
            n = n < n2 + this.s && n2 < n + ht2.d() ? ((n = ht2.g()) < n3 + this.r && n3 < n + ht2.h() ? 1 : 0) : 0;
            if (n != 0) {
                this.b(ht2, n3, n2);
            }
        }
    }

    public int a(nj nj2, int n, int n2) {
        if (!this.t_() || !this.g(n -= this.p, n2 -= this.q) || (n = this.b(nj2, n, n2)) == -1 && (n = this.a(nj2)) == -1) {
            return -1;
        }
        return n;
    }

    /*
     * Enabled aggressive block sorting
     */
    public final boolean x() {
        return this.t_() && this.a(0, 0, this.r, this.s) || this.A();
    }

    public gm r() {
        if (!this.t_()) {
            return null;
        }
        return this;
    }

    public final gm y() {
        if (this.v != null) {
            return this.v.y();
        }
        return this;
    }

    public void o() {
        if (this.v != null) {
            this.v.i(this);
        }
    }

    public void b(int n, int n2, int n3, int n4) {
        this.c(n - this.p, n2 - this.q, n3, n4);
        this.c(0, 0, this.r, this.s);
        this.b(n, n3);
        if (this.v != null) {
            this.v.a(this);
        }
    }

    public boolean a(int n, int n2, int n3, int n4) {
        if (this.v != null) {
            n += this.p;
            n2 += this.q;
            return this.v.a(n += this.v.r_(), n2 += this.v.f(), n3, n4);
        }
        return true;
    }

    public final void c(int n, int n2, int n3, int n4) {
        if (this.v == null) {
            if (this.b == null) {
                this.b = new gh(n, n2, n3, n4);
                return;
            }
            this.b.b(n, n2, n3, n4);
            return;
        }
        n += this.p;
        n2 += this.q;
        this.v.c(n += this.v.r_(), n2 += this.v.f(), n3, n4);
    }

    public final void e(int n, int n2, int n3, int n4) {
        if (!this.o(1)) {
            if (!this.o(2)) {
                if (this.o(4)) {
                    n += (n3 - this.r) / 2;
                }
            } else {
                n += n3 - this.r;
            }
        }
        if (!this.o(8)) {
            if (!this.o(16)) {
                if (this.o(32)) {
                    n2 += (n4 - this.s) / 2;
                }
            } else {
                n2 += n4 - this.s;
            }
        }
        this.e(n, n2);
    }

    public final void d(int n, int n2, int n3, int n4) {
        if (this.p != n || this.q != n2 || this.r != n3 || this.s != n4) {
            int n5 = this.p;
            int n6 = this.q;
            int n7 = this.r;
            int n8 = this.s;
            this.p = n;
            this.q = n2;
            this.r = n3;
            this.s = n4;
            this.b(n5, n6, n7, n8);
        }
    }

    public final void e(int n, int n2) {
        if (this.p != n || this.q != n2) {
            int n3 = this.p;
            int n4 = this.q;
            this.p = n;
            this.q = n2;
            this.b(n3, n4, this.r, this.s);
        }
    }

    public final void f(int n, int n2) {
        if (this.r != n || this.s != n2) {
            int n3 = this.r;
            int n4 = this.s;
            this.r = n;
            this.s = n2;
            this.b(this.p, this.q, n3, n4);
        }
    }
}

