/*
 * Decompiled with CFR 0.152.
 */
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Vector;

public final class no
extends a {
    private static String[] H;
    public static int a;
    private Hashtable I;
    private Hashtable J;
    private int K;
    private boolean L;
    public Hashtable A;
    public Hashtable B;
    public pv C;
    public boolean E = true;
    public hx F;
    public az w = new az(true);
    public kv x;
    public String y;
    public String z;

    public final void b(String string) {
        gm gm2 = (gm)this.A.get(string);
        if (gm2 != null) {
            if (this.F != null) {
                this.F.b(gm2);
            }
            gm2.z();
        }
    }

    public final void a(int n, int n2) {
        if (n == Integer.MAX_VALUE) {
            n = 960;
        }
        this.K = n;
        this.l(this.K);
        this.a();
    }

    public final void b(ht ht2, int n, int n2) {
        if (this.b != null && this.b.d != null) {
            if (!this.c) {
                int n3 = this.b(960);
                if (n3 > this.K && this.L) {
                    n3 = n3 <= 760 ? 760 : 960;
                    this.K = n3;
                }
                this.a(this.K, (az)null, false);
                this.t();
            }
            super.b(ht2, n, n2);
        }
    }

    public final void a(String string, Object object) {
        if (!(object instanceof String)) {
            Vector vector;
            if (object instanceof le && (vector = (Vector)this.J.get(string)) != null) {
                le le2 = (le)object;
                this.J.remove(string);
                for (int i = 0; i < vector.size(); ++i) {
                    Object e = vector.elementAt(i);
                    if (!(e instanceof a)) {
                        if (!(e instanceof le[])) continue;
                        ((le[])e)[0] = le2;
                        this.t();
                        continue;
                    }
                    ((a)e).o = le2;
                    ((a)e).a();
                }
            }
        } else {
            az az2 = this.w;
            synchronized (az2) {
                this.w.a(this, string, (String)object);
            }
            this.d();
        }
        this.I.put(string, object);
    }

    public final Object a(String string, int n, Object object) {
        Object v2 = this.I.get(string = ar.a(this.z, string));
        if (v2 == null && object != null) {
            Vector<Object> vector = (Vector<Object>)this.J.get(string);
            if (vector == null) {
                vector = new Vector<Object>();
                this.J.put(string, vector);
            }
            vector.addElement(object);
            if (vector.size() == 1) {
                this.x.a(this, 1, string, n, null);
            }
        }
        return v2;
    }

    public final int a(pb pb2) {
        int n = super.a(pb2);
        if (n == -1) {
            pv pv2 = null;
            if (pb2.c != 7) {
                pv2 = (pv)this.B.get(new Character(pb2.b()));
                if (pv2 == null) {
                    pv2 = (pv)this.B.get(new Character((char)(48 + pb2.a())));
                }
            } else {
                gm gm2 = this.r();
                if (!(gm2 instanceof ix)) {
                    if (gm2 instanceof a) {
                        pv2 = ((a)gm2).b;
                    }
                } else {
                    pv2 = ((ix)gm2).a;
                }
            }
            if (pv2 != null) {
                String string;
                while ((string = pv2.d("href")) == null && pv2.b != null) {
                    pv2 = pv2.b;
                }
                if (string != null) {
                    if (!string.startsWith("#")) {
                        this.x.a(this, 1, this.c(string.trim()), 1, null);
                        return -2;
                    }
                    this.b(string.substring(1));
                    return -2;
                }
            }
            return -1;
        }
        return n;
    }

    public final no a(InputStream inputStream, String string) {
        try {
            int n;
            pv pv2 = new pv(this, "");
            az az2 = new az();
            az2.a(inputStream, string);
            az2.a("http://xmlpull.org/v1/doc/features.html#relaxed", true);
            for (n = 0; n < H.length; n += 2) {
                az2.a(H[n], H[n + 1]);
            }
            pv2.a(az2);
            pv pv3 = pv2.b("html");
            if (pv3 == null) {
                pv3 = new pv(this, "html");
            }
            this.b = pv3.b("body");
            if (this.b == null) {
                this.b = new pv(this, "body");
                pv3.a(this.b);
                block7: for (n = 0; n < pv2.a(); ++n) {
                    switch (pv2.a(n)) {
                        case 1: {
                            if (pv2.b((int)n).c.equals("html")) continue block7;
                            this.b.a(pv2.b(n));
                            continue block7;
                        }
                        case 2: {
                            this.b.a(pv2.c(n));
                        }
                    }
                }
            }
            pv3.b = null;
            this.d();
        }
        catch (jw jw2) {
            jw2.printStackTrace();
            throw new IOException(jw2.toString());
        }
        this.a(this.r, (az)null, false);
        return this;
    }

    private void d() {
        az az2 = this.w;
        synchronized (az2) {
            this.b.a(this.w, new Vector());
        }
        synchronized (this) {
            this.E = false;
            this.n = new Vector();
            this.b(this.b, new boolean[]{false, true});
            this.a();
            return;
        }
    }

    public no(int n, kv kv2, String string, hx hx2, boolean bl2) {
        super(null, false);
        this.I = new Hashtable();
        this.J = new Hashtable();
        this.A = new Hashtable();
        this.B = new Hashtable();
        this.l(n);
        this.m(n);
        this.K = n;
        this.x = kv2;
        this.F = hx2;
        this.L = bl2;
        if (string != null) {
            this.z = string;
            this.y = string;
        }
        if (H == null) {
            H = az.a();
        }
    }

    public final int b(nj nj2, int n, int n2) {
        if (!nj2.j()) {
            if (nj2.f()) {
                this.a(n, n2, true);
                return -2;
            }
            return -1;
        }
        this.a(n, n2, true);
        this.a(pb.a(7));
        return -2;
    }

    public final boolean a(String string) {
        return string == null || string.trim().length() == 0 || (string = string.toLowerCase()).indexOf("all") != -1 || string.indexOf("screen") != -1 || string.indexOf("handheld") != -1 && !this.L;
    }

    public final String c(String string) {
        return ar.a(this.z, string);
    }
}

