/*
 * Decompiled with CFR 0.152.
 */
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;

public final class je
extends ep
implements in,
nf {
    private volatile boolean e = false;
    private volatile byte[] g;
    private static final String E = lh.d(0);
    private static final String F = lh.d(292);
    private final lh A;
    private final w B;
    private final w C;
    private final w D;
    private hx h;
    private hx i;
    private hx l;
    private hx o;
    private String b;
    private boolean c;
    private Boolean d = null;
    private boolean f = false;
    private ft j;
    private hx k;
    private hx m;
    private hx n;
    private hx p = null;
    private gm u;
    private Hashtable v;
    private String w = null;
    private String x = null;
    private boolean y;
    private String z;
    public boolean a;

    private static String s() {
        return "help13.dat_" + lh.o();
    }

    private static int a(hx hx2) {
        return hx2.a();
    }

    public final void l() {
        this.a = true;
    }

    public final synchronized void b() {
        this.v = null;
        this.k = null;
        this.i = null;
        this.h = null;
        this.j = null;
    }

    public final Boolean m() {
        Boolean bl2 = this.d;
        this.d = null;
        return bl2;
    }

    private gm a(hx hx2, String string, w w2) {
        jp jp2 = new jp(4, 0, je.a(hx2), pt.a(w2), 0, w2, string, false, this.s.k);
        jp2.u = true;
        hx2.d(jp2);
        return jp2;
    }

    private hx u() {
        hx hx2 = ps.a(this.j);
        dz.a(hx2, lh.d(268), this.D);
        return hx2;
    }

    private void f(hx hx2) {
        je.e(hx2);
        dz.a(hx2, lh.d(270), this.C);
    }

    private void c(hx hx2) {
        dz.a(hx2, lh.d(578), this.C);
    }

    private void d(hx hx2) {
        this.a(hx2, E, this.C);
    }

    public final void a(ht ht2) {
        this.j.a(ht2, 0, 0);
    }

    public final boolean a(boolean bl2) {
        return this.a(this.j);
    }

    public final int a(nj nj2) {
        switch (this.j.b(nj2)) {
            case -3: {
                return this.a(pb.a(7));
            }
        }
        return 3;
    }

    public final synchronized void a() {
        this.q();
        String string = this.e ? "i" : "a";
        me.a((short)6, string);
    }

    private static void e(hx hx2) {
        int n = hx2.m();
        if (n > 0) {
            hx2.g(n - 1);
        }
    }

    public static boolean p() {
        return lh.k().f().g("EnableMyLocation") == null;
    }

    private boolean z() {
        gm gm2 = this.i.r();
        return gm2 == null || gm2 == this.i || !this.i.c(gm2);
    }

    private boolean w() {
        return this.A.m() || !je.p();
    }

    private static String x() {
        if (je.p()) {
            return lh.d(66);
        }
        return lh.d(87);
    }

    public final synchronized void af() {
        if (!this.e) {
            this.g = null;
        }
    }

    private void D() {
        if (this.i == this.k && this.k.m() < 3 && !this.f) {
            this.f = true;
            ck.e().a(new lh("http://www.google.com/gmm/terms.html?ver=3", this));
            if (this.a) {
                this.r();
            }
        }
    }

    public final cq d() {
        if (this.a && this.i == this.k) {
            return jy.k;
        }
        if (this.i != this.h) {
            return jy.g;
        }
        return jy.a;
    }

    /*
     * Enabled aggressive block sorting
     */
    public final cq e() {
        if (!this.a) {
            if (this.i == this.h) {
                if (this.g == null || this.g.length <= 0) return jy.i;
                if (lh.t()) return null;
                return jy.c;
            }
            if (this.z() || lh.t()) return null;
            return jy.c;
        }
        if (this.f) return null;
        if (this.z()) {
            return jy.j;
        }
        if (!lh.t()) return jy.c;
        return null;
    }

    public final synchronized void a(String string, boolean bl2) {
        this.y = false;
        me.a((short)6, "", string);
        this.c = bl2;
        if (this.g != null && this.g.length > 0) {
            hx hx2 = (hx)this.v.get(string);
            if (hx2 != null) {
                this.b(hx2);
                return;
            }
        } else {
            this.b = string;
        }
    }

    public final void g_() {
        boolean bl2 = this.c;
        int n = -1;
        if (this.h != null) {
            n = this.h.g(this.h.q());
            if (this.v != null) {
                Enumeration enumeration = this.v.keys();
                while (enumeration.hasMoreElements()) {
                    String string = (String)enumeration.nextElement();
                    if (this.v.get(string) != this.i) continue;
                    this.b = string;
                    break;
                }
            }
        }
        this.q();
        this.c = bl2;
        this.D();
        if (n != -1) {
            this.h.l(this.h.h(n));
        }
    }

    public je(eb eb2, String string, lh lh2) {
        super(eb2, null);
        this.A = lh2;
        if (string == null) {
            string = "";
        }
        this.z = "," + string + ",";
        nz.a(this);
        this.D = jj.a();
        this.B = jj.c();
        this.C = jj.a(false);
    }

    private void b(hx hx2) {
        if (this.p == hx2) {
            if (ps.a() && !this.y) {
                String string = lh.d(396);
                String string2 = ps.e();
                if (!ed.b(string2)) {
                    string = string + "\n" + string2;
                }
                this.u = this.a(this.p, string, this.C);
            } else {
                this.p.f(this.u);
            }
        }
        this.i = hx2;
        this.j.b(this.i);
    }

    private synchronized void q() {
        this.j = this.s.a(false, false);
        this.c = false;
        if (!this.a) {
            if (this.g != null && this.g.length != 0) {
                this.v();
                return;
            }
            this.h = this.u();
            this.d(this.h);
            this.c(this.h);
            this.b(this.h);
            this.r();
            return;
        }
        this.k = ps.a(this.j);
        dz.a(this.k, lh.d(513), this.B);
        this.c(this.k);
        this.b(this.k);
        this.D();
    }

    private void r() {
        if (!this.e) {
            this.g = lh.k().f().d(je.s());
            if (this.g != null && this.g.length > 0) {
                this.v();
                return;
            }
            this.e = true;
            ck.e().a(new lh("help13.dat", this));
        }
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public final void a(String string, byte[] byArray) {
        block12: {
            hx hx2;
            block10: {
                block11: {
                    if ("help13.dat".equals(string.substring(string.indexOf("/") + 1))) break block11;
                    if (!"http://www.google.com/gmm/terms.html?ver=3".equals(string)) break block12;
                    hx2 = this.k;
                    if (this.t && hx2 != null) {
                        if (byArray == null) {
                            this.f(hx2);
                            break block10;
                        } else {
                            try {
                                no no2 = new no(je.a(hx2), null, "http://www.google.com/gmm/terms.html?ver=3", hx2, false);
                                no2.a(new ByteArrayInputStream(byArray), "UTF-8");
                                no no3 = no2;
                                je.e(hx2);
                                hx2.d(no3);
                            }
                            catch (IOException iOException) {
                                me.a("UI-Help2", iOException);
                            }
                        }
                    }
                    break block10;
                }
                this.g = byArray;
                lh.k().f().b(this.g, je.s());
                if (this.t && this.k == null) {
                    if (byArray == null) {
                        this.f(this.h);
                    } else {
                        this.v();
                    }
                }
                this.e = false;
                me.a((short)6, "l", "h");
                return;
            }
            if (this.k != null) {
                hx2 = this.k;
                if (this.a) {
                    this.a(hx2, lh.d(53), this.C);
                    this.a(hx2, lh.d(1), this.C);
                    hx2.d(2);
                }
            }
            this.f = false;
            me.a((short)6, "l", "t1");
        }
    }

    /*
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    public final synchronized int a(pb pb2) {
        if (pb2.c != 8 && pb2.c != 5) {
            if (this.a && pb2.d == 6 && this.z()) {
                if (this.f) return 3;
                this.d = new Boolean(true);
                this.a = false;
                return 1;
            }
            if (this.i == this.l) {
                this.i.a(pb2);
                return 6;
            }
            if (this.i != this.m) {
                if (this.i != this.n) {
                    if (this.i != this.o) {
                        switch (this.i.a(pb2)) {
                            case -3: {
                                String string = ((jp)this.i.r()).c();
                                Object object = dz.c(this.i);
                                if (string.equals(E)) return 1;
                                me.a((short)6, "", string);
                                if (this.a && string.equals(lh.d(1))) {
                                    this.d = new Boolean(true);
                                    this.a = false;
                                    return 1;
                                }
                                if (this.a && string.equals(lh.d(53))) {
                                    this.d = new Boolean(false);
                                    return 1;
                                }
                                if (string.equals(this.w) && this.i != this.h) {
                                    return 16;
                                }
                                if (string.equals(je.x())) {
                                    object = lh.k().f();
                                    byte[] byArray = je.p() ? new byte[]{1} : null;
                                    object.a("EnableMyLocation", byArray);
                                    string = je.p() ? "i" : "o";
                                    me.a((short)50, string);
                                    object.h();
                                    return 13;
                                }
                                if (string.equals(this.x)) {
                                    if (this.q == null) return 3;
                                    this.q.a("http://m.google.com/privacy");
                                    return 3;
                                }
                                if (string.equals(F)) {
                                    if (this.q == null) return 3;
                                    this.q.a("http://m.google.com/legalnotices");
                                    return 3;
                                }
                                if (this.u == object) return 15;
                                this.y = true;
                                hx hx2 = (hx)this.v.get(string);
                                if (hx2 == null) {
                                    throw new RuntimeException("Unknown page: " + string);
                                }
                                this.b(hx2);
                                this.D();
                                return 3;
                            }
                            default: {
                                return 3;
                            }
                        }
                    }
                    this.i.a(pb2);
                    return 10;
                }
                this.i.a(pb2);
                return 8;
            }
            this.i.a(pb2);
            return 7;
        }
        this.i.l(this.i.h(0));
        if (!this.a) {
            if (this.i == this.h) return 2;
            if (this.c) return 2;
            this.b(this.h);
            return 3;
        }
        this.d = new Boolean(false);
        return 1;
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    private void v() {
        if (!this.t) return;
        byte[] byArray = this.g;
        hx hx2 = this.u();
        this.v = new Hashtable();
        DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(byArray));
        hx hx3 = null;
        hx hx4 = null;
        boolean bl2 = false;
        boolean bl3 = false;
        if (this.w() && this.z.indexOf("GPS") == -1) {
            this.z = this.z + ",GPS,";
        }
        try {
            hx hx5 = hx2;
            boolean bl4 = false;
            int n = dataInputStream.readUnsignedShort();
            for (int i = 0; i < n; ++i) {
                boolean bl5;
                block17: {
                    String string;
                    char c;
                    block18: {
                        block19: {
                            block20: {
                                block21: {
                                    block22: {
                                        block23: {
                                            block25: {
                                                block26: {
                                                    block24: {
                                                        c = dataInputStream.readChar();
                                                        string = dataInputStream.readUTF();
                                                        bl5 = "HELZptS".indexOf(c) >= 0;
                                                        if (bl3) break block17;
                                                        if (c == '?' || c == '!') break block18;
                                                        if (bl2 && !bl5) continue;
                                                        bl2 = false;
                                                        if (!bl5) break block19;
                                                        if (hx5 == hx2) {
                                                            this.d(hx2);
                                                        }
                                                        hx5 = ps.a(this.j);
                                                        this.v.put(string, hx5);
                                                        this.a(hx2, string, this.C);
                                                        if (c == 'E') break block20;
                                                        if (c == 'L') break block21;
                                                        if (c == 'S') break block22;
                                                        if (c == 'p') break block23;
                                                        if (c != 't' || this.a) break block24;
                                                        this.k = hx5;
                                                        break block19;
                                                    }
                                                    if (c == 'Z') break block25;
                                                    if (string.equals(lh.d(274))) break block26;
                                                    if (!string.equals(lh.d(418))) {
                                                        if (string.equals(lh.d(104))) {
                                                            this.o = hx5;
                                                        }
                                                        break block19;
                                                    } else {
                                                        this.n = hx5;
                                                    }
                                                    break block19;
                                                }
                                                this.m = hx5;
                                                break block19;
                                            }
                                            this.l = hx5;
                                            break block19;
                                        }
                                        this.x = string;
                                        break block19;
                                    }
                                    this.p = hx5;
                                    break block19;
                                }
                                hx3 = hx5;
                                break block19;
                            }
                            hx4 = hx5;
                            this.w = string;
                        }
                        if (c == 'P' && bl4) {
                            dz.a(hx5, " ", this.C);
                        } else if (c == 'I') {
                            string = "     " + string;
                        }
                        w w2 = !bl5 ? this.C : this.B;
                        dz.a(hx5, string, w2);
                        if (bl5) {
                            bl4 = false;
                            continue;
                        }
                        bl4 = true;
                        continue;
                    }
                    bl5 = this.z.indexOf(',' + string + ',') >= 0;
                    bl3 = c == '?';
                    bl3 = bl5 ^ bl3;
                    continue;
                }
                bl2 |= bl5;
                bl3 = false;
            }
            this.a(hx2, F, this.C);
            if (hx4 != null) {
                dz.a(hx4, " ", this.C);
                this.a(hx4, this.w, this.C);
            }
            if (hx3 != null && this.w()) {
                dz.a(hx3, " ", this.C);
                this.a(hx3, je.x(), this.C);
            }
        }
        catch (IOException iOException) {
            me.a("UI-Help1", iOException);
        }
        this.h = hx2;
        if (this.b != null) {
            this.a(this.b, this.c);
            this.b = null;
            return;
        } else {
            if (this.a) return;
            this.b(hx2);
            return;
        }
    }
}

