/*
 * Decompiled with CFR 0.152.
 */
public final class ix
extends gm {
    private int e;
    private int f;
    private int g;
    public pv a;
    public boolean b;
    public String c;
    public short[] d;

    public final boolean b() {
        return this.b;
    }

    public final w d() {
        return this.a.d.a();
    }

    private final int a(a a2, int n, char c, int n2, int n3, int n4, int n5) {
        char c2;
        int[] nArray = this.a.d.b();
        w w2 = this.d();
        int n6 = this.c.length();
        while ((c2 = c) != '\n') {
            if (n3 <= n5 || n4 == Integer.MAX_VALUE) {
                if (n2 < n6) {
                    c = this.c.charAt(n2);
                    if (oz.a(c2, c)) {
                        n4 = n2;
                    }
                    ++n2;
                    c2 = c < nArray.length ? nArray[c] : w2.d(c);
                    n3 += c2;
                    continue;
                }
                ix ix2 = ix.a(a2, n);
                if (ix2 != null) {
                    c = (char)(n2 - n6);
                    ++n;
                    if (n4 != Integer.MIN_VALUE && n4 != Integer.MAX_VALUE) {
                        n4 -= n6;
                    }
                    if (Integer.MIN_VALUE < (n = ix2.a(a2, n, c2, c, n3, n4, n5)) && n < Integer.MAX_VALUE) {
                        return n + n6;
                    }
                    return n;
                }
                if (n3 <= n5) {
                    return Integer.MAX_VALUE;
                }
            }
            return n4;
        }
        return n2;
    }

    private int a(a a2, int n, int n2, int n3, boolean bl2) {
        int n4 = this.c.length();
        if (n2 < n4) {
            n4 = n2 + 1;
            char c = this.c.charAt(n2);
            int n5 = this.d().d(c);
            n2 = bl2 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
            return this.a(a2, n, c, n4, n5, n2, n3);
        }
        ix ix2 = ix.a(a2, n);
        if (ix2 != null) {
            if ((n = ix2.a(a2, n + 1, n2 - n4, n3, bl2)) > Integer.MIN_VALUE && n < Integer.MAX_VALUE) {
                return n + n4;
            }
            return n;
        }
        return Integer.MAX_VALUE;
    }

    public final void b(ht ht2, int n, int n2) {
        int n3;
        int n4;
        on on2 = this.a.d;
        w w2 = on2.a();
        int n5 = on2.d(4);
        if (this.t_() && !this.a.c()) {
            this.a.b();
        }
        boolean bl2 = this.a.c();
        if (this.d == null) {
            if (bl2) {
                ht2.a(-4860423);
                ht2.c(n, n2, w2.a(this.c), w2.l());
            }
            ht2.a(n5);
            w2.a(ht2, this.c, n, n2);
        } else {
            n4 = n2 + this.e;
            int n6 = ht2.f();
            int n7 = ht2.d();
            int n8 = w2.l();
            for (n3 = 0; n3 < this.d.length; n3 += 3) {
                if (n6 < n4 + n8 && n4 < n6 + n7) {
                    short s = this.d[n3];
                    short s2 = this.d[n3 + 1];
                    if (bl2) {
                        ht2.a(-4860423);
                        ht2.c(n + this.d[n3 + 2], n4, w2.a(this.c, s, s2), w2.l());
                    }
                    ht2.a(n5);
                    w2.a(ht2, this.c, s, s2, n + this.d[n3 + 2], n4);
                }
                n4 += n8;
                if (n3 == 0) {
                    n4 += this.f;
                }
                if (n3 != this.d.length - 6) continue;
                n4 += this.g;
            }
        }
        if (null == this) {
            ht2.a(65280);
            ht2.d(n, n2, this.r - 1, this.s - 1);
            if (this.a() > 1) {
                n5 = w2.l();
                ht2.a(0xFF0000);
                ht2.e(n, n2, n, n2 + this.e);
                n4 = n2 + this.e;
                for (n3 = 0; n3 < this.d.length; n3 += 3) {
                    ht2.a(255);
                    ht2.d(n + this.d[n3 + 2], n4, w2.a(this.c, this.d[n3], this.d[n3 + 1]), n5 - 1);
                    n4 += n5;
                    if (n3 == 0) {
                        ht2.a(0xFF0000);
                        ht2.e(n + 2, n4, n + 2, n4 + this.f);
                        n4 += this.f;
                    }
                    if (n3 != this.d.length - 6) continue;
                    ht2.a(0xFF0000);
                    ht2.e(n + 4, n4, n + 4, n4 + this.g);
                    n4 += this.g;
                }
            }
        }
    }

    public final int a(int n, az az2, int n2, int n3, int n4) {
        int n5;
        int n6;
        this.e = 0;
        this.f = 0;
        this.g = 0;
        a a2 = (a)this.v;
        w w2 = this.d();
        int n7 = this.r;
        int n8 = w2.l();
        int n9 = az2.g(n8);
        if (n2 == -1) {
            n6 = n9 == n7 ? 1 : 0;
            n2 = Math.max(0, this.a(a2, n, 0, n9, n6 != 0));
        }
        if (n2 <= (n5 = this.c.length())) {
            int n10;
            StringBuffer stringBuffer = new StringBuffer();
            int n11 = Math.max(az2.j, n8);
            n6 = 0;
            az2.j = n11;
            this.e = az2.f(n11 - n8);
            this.f = n11 - n8 - this.e;
            while (true) {
                n2 = (n10 = n2) > n6 ? (this.c.charAt(n10 - 1) > ' ' ? n10 : n10 + -1) : n10;
                stringBuffer.append((char)n6);
                stringBuffer.append((char)(n2 - n6));
                n2 = Math.min(w2.a(this.c, n6, n2 - n6), n7);
                if (n3 != n4) {
                    ((a)this.v).a(n3, n4, az2);
                    n3 = n4;
                }
                az2.a(n2, n8, az2.j, 0);
                stringBuffer.append((char)(az2.g + az2.e(n9 - n2)));
                az2.b(az2.j);
                n9 = az2.g(n8);
                n6 = n9 == n7 ? 1 : 0;
                n2 = Math.max(n10, this.a(a2, n, n10, n9, n6 != 0));
                n11 += n8;
                if (n2 > n5) break;
                n6 = n10;
            }
            stringBuffer.append((char)n10);
            stringBuffer.append((char)(this.c.length() - n10));
            az2.a(Math.min(w2.a(this.c, n10, this.c.length() - n10), az2.g(n8)), n8, 0, 0);
            stringBuffer.append((char)az2.g);
            this.d = new short[stringBuffer.length()];
            for (n6 = 0; n6 < this.d.length; ++n6) {
                this.d[n6] = (short)stringBuffer.charAt(n6);
            }
            this.m(n11);
            return n2 - n5;
        }
        int n12 = Math.min(w2.a(this.c), n7);
        az2.a(n12, n8, 0, 0);
        n = n12;
        this.d = null;
        this.j(this.p + az2.g);
        this.l(n);
        this.m(n8);
        return n2 - n5;
    }

    public final void a(boolean bl2) {
        if (this.b && bl2) {
            this.a.b();
        }
        this.y().t();
    }

    public ix(pv pv2, String string, boolean bl2) {
        this.a = pv2;
        this.c = string;
        this.b = bl2;
        if (bl2 && this.t_()) {
            pv2.b();
        }
    }

    public final int a() {
        if (this.d != null) {
            return this.d.length / 3;
        }
        return 1;
    }

    private static ix a(a a2, int n) {
        Object e;
        if (n + 1 < a2.n.size() && (e = a2.n.elementAt(n + 1)) instanceof ix) {
            return (ix)e;
        }
        return null;
    }

    public final void a(int n, int n2, az az2) {
        this.g = az2.f(n2 - this.d().l());
        this.m(this.s + this.g);
        int n3 = this.d.length - 1;
        this.d[n3] = (short)(this.d[n3] + n);
    }
}

