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

public abstract class cf
extends iu
implements kv {
    private static final String S;
    private static final String T;
    private static final String U;
    private static final String V;
    private static final String b;
    public static final String j;
    public static final String k;
    public static final String l;
    public static final String m;
    public static final String n;
    public static final String o;
    public static final String p;
    public static final String q;
    public static final String r;
    private final String W;
    public final String c;
    public final String d;
    public final String e;
    public final String f;
    public final String g;
    public final String h;
    public final String i;
    private lh a = lh.k();

    public abstract String l();

    public void b() {
    }

    public final int c(pz pz2) {
        return ((ar)pz2).x();
    }

    public final int d(pz pz2) {
        return ((ar)pz2).w();
    }

    public final ar I() {
        return (ar)this.M();
    }

    public boolean J() {
        return false;
    }

    public boolean q() {
        return false;
    }

    public boolean s() {
        return false;
    }

    public boolean r() {
        return false;
    }

    public gm a(ar ar2, hx hx2, int n) {
        return null;
    }

    public String t() {
        return null;
    }

    public String u() {
        return null;
    }

    static {
        b = lh.d(22);
        S = lh.d(253);
        T = lh.d(431);
        U = lh.d(503);
        V = lh.d(451);
        j = lh.d(282);
        k = lh.d(284);
        l = lh.d(283);
        m = lh.d(285);
        n = lh.d(286);
        o = lh.d(287);
        p = lh.d(281);
        q = lh.d(277);
        r = lh.d(559);
    }

    public void g() {
        if (!this.c.equals(this.U())) {
            super.g();
            return;
        }
        this.y();
        this.d();
    }

    private static void a(String string, StringBuffer stringBuffer) {
        if (!ed.b(string)) {
            stringBuffer.append("\n");
            stringBuffer.append(string);
        }
    }

    public final boolean H() {
        String string;
        return this.z.i() == 2 && (string = this.K()) != null && string.startsWith("tel:");
    }

    public final boolean L() {
        ar ar2 = (ar)this.M();
        return ar2 != null && !ar2.f && ar2.b != 6 && !ar2.s();
    }

    public static String[] b(String string) {
        String[] stringArray = new String[3];
        int n = string.indexOf("http://");
        if (n != -1) {
            n = (string = string.substring(n)).indexOf(32) != -1 ? string.indexOf(32) : string.length();
            stringArray[0] = string.substring(0, n);
            stringArray[1] = stringArray[0].substring("http://".length());
            if (stringArray[1].indexOf(47) != -1) {
                stringArray[1] = stringArray[1].substring(0, stringArray[1].indexOf(47));
            }
            if (n != string.length()) {
                stringArray[2] = string.substring(n + 1);
            }
        }
        return stringArray;
    }

    public final void a(no no2, int n, String string, int n2, byte[] byArray) {
        switch (n2) {
            case 1: {
                this.v.c = string;
                return;
            }
            case 2: {
                aq[] aqArray = ((ar)this.M()).C();
                for (n = 0; n < aqArray.length; ++n) {
                    if (!aqArray[n].j.equals(string)) {
                        continue;
                    }
                    byArray = aqArray[n].c;
                    if (byArray == null || byArray.length <= 0) break;
                    no2.a(string, this.a.g().a(byArray, 0, byArray.length));
                    return;
                }
                ck.e().a(new lh(no2, string, n2));
            }
        }
    }

    public cf(gd gd2, ck ck2, lh lh2, jt jt2) {
        super(gd2, ck2, lh2, jt2);
        this.W = lh.d(512);
        this.c = lh.d(428);
        String string = lh.t() ? lh.d(546) : lh.d(403);
        this.d = string;
        string = !lh.t() ? lh.d(402) : lh.d(545);
        this.e = string;
        string = !lh.t() ? lh.d(405) : lh.d(547);
        this.f = string;
        string = lh.t() ? lh.d(544) : lh.d(307);
        this.g = string;
        this.h = lh.d(465);
        this.i = lh.d(399);
    }

    public final ft c(String string) {
        int n = 0;
        ar ar2 = (ar)this.z.c(this.z.w());
        gu gu2 = new gu(5);
        String string2 = ar2.v();
        if (ar2.q()) {
            n = 1;
            gu2.a(lh.d(476), this.D);
        }
        if (!ed.b(string2)) {
            gu2.a(string2, this.E);
        } else {
            n = -1;
        }
        if (ar2.t()) {
            gu2.a(cf.n, this.F);
        }
        if (ar2.X()) {
            gu2.a(r, this.F);
        }
        if (ar2.W()) {
            gu2.a(q, this.F);
        }
        gu2.a(string, this.D);
        return this.u.a(gu2, n);
    }

    public final gm a(ar ar2, hx hx2) {
        int n;
        dm dm2 = ar2.c;
        if (cf.Z() && dm2 != null) {
            this.a(this.c, hx2, 4).c(-5636096, -5636096);
        }
        jp jp2 = null;
        if (ar2.f() != null && ar2.f().length() > 0) {
            jp2 = this.a(ed.a(b, ar2.f()), hx2, 4);
        }
        this.a(ar2, hx2, 4);
        pt pt2 = null;
        if (ar2.q() && !ed.b(ar2.H()) && !ed.b(ar2.G())) {
            pt2 = this.a(ar2.G(), ar2.H(), hx2);
        }
        if (dm2 != null && gu.j()) {
            this.a(S, hx2, 4);
        }
        if (ar2.U() != null) {
            this.a(U, hx2, 4);
        }
        if (dm2 != null) {
            n = dm2.a();
            if (!(n != 1 && n != 4 || ar2.p())) {
                this.a(this.l(), hx2, 4);
            }
            if (!(ar2.o() || ar2.q() || ar2.t())) {
                this.a(T, hx2, 4);
            }
        }
        if (ar2.r() && !ed.b(ar2.Q())) {
            String string = ar2.O();
            n = ar2.P();
            if (n != 1) {
                if (n > 0) {
                    String string2 = "" + n;
                    if (!ed.b(string)) {
                        this.a(ed.a(j, string, string2), hx2, 4);
                    } else {
                        this.a(ed.a(k, string2), hx2, 4);
                    }
                } else if (!ed.b(string)) {
                    this.a(ed.a(l, string), hx2, 4);
                } else {
                    this.a(m, hx2, 4);
                }
            }
        }
        if ((ar2.n() || ar2.b == 2) && this.L()) {
            this.a(this.g, hx2, 4).a('9', true);
        }
        iv[] cfr_ignored_0 = gu.g().c;
        if (false && ar2.o()) {
            this.a(V, hx2, 4);
        }
        if (jp2 == null) {
            if (pt2 == null) {
                return dz.a((fs)hx2, 0);
            }
            return pt2;
        }
        return jp2;
    }

    /*
     * Enabled aggressive block sorting
     */
    public final String K() {
        gm gm2 = ((hx)this.B.a()).r();
        if (gm2 instanceof pt) {
            return ((pt)gm2).b;
        }
        if (!(gm2 instanceof jp)) return null;
        String string = ((jp)gm2).c();
        ar ar2 = this.I();
        String string2 = ar2.f();
        if (!string2.equals("") && string.indexOf(string2) != -1) {
            return "tel:" + ar2.h();
        }
        if (!string.equals(S)) {
            if (string.equals(this.l())) {
                return "favorite:";
            }
            if (string.equals(T)) {
                return "nearby:";
            }
            if (!ed.b(this.t()) && string.equals(this.t())) {
                this.r();
                return null;
            }
            if (!ed.b(this.u()) && string.equals(this.u())) {
                this.q();
                return null;
            } else if (string.indexOf(this.W) == -1) {
                if (string.equals(this.g)) {
                    return "modifysearch:" + this.z.i();
                }
                if (string.equals(this.h)) {
                    StringBuffer stringBuffer = new StringBuffer();
                    stringBuffer.append("sendsms:");
                    stringBuffer.append(ar2.h());
                    stringBuffer.append("[" + ar2.v() + "]");
                    return stringBuffer.toString();
                }
                if (string.equals(U)) {
                    gu.e(((ar)this.M()).b);
                    StringBuffer stringBuffer = new StringBuffer();
                    stringBuffer.append("streetview_panoid:");
                    stringBuffer.append(ar2.U());
                    stringBuffer.append('\u0003');
                    stringBuffer.append(ar2.a().toString());
                    return stringBuffer.toString();
                }
                if (string.equals(V)) {
                    StringBuffer stringBuffer = new StringBuffer();
                    stringBuffer.append(ar2.v());
                    cf.a(ar2.b(), stringBuffer);
                    cf.a(ar2.c(), stringBuffer);
                    cf.a(ar2.h(), stringBuffer);
                    cf.a(ar2.V(), stringBuffer);
                    StringBuffer stringBuffer2 = stringBuffer;
                    return ar.a(null, ar2.v(), stringBuffer2.toString());
                }
                if (!ar2.r() || string.indexOf(k) == -1 && string.indexOf(ar2.O()) == -1) return null;
                me.a((short)2, "kml");
                this.s();
                return "kmlload:" + ar2.Q();
            } else {
                if (this.B == null || !(this.B instanceof d)) return null;
                d d2 = (d)this.B;
                d2.a_((d2.b + 1) % d2.e().size());
                return null;
            }
        }
        String[] stringArray = ar2.e();
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("dirto:");
        stringBuffer.append(stringArray[0]);
        stringBuffer.append('\u0003');
        stringBuffer.append(stringArray[1]);
        stringBuffer.append('\u0003');
        string = ar2.v();
        if (!ed.b(string)) {
            stringBuffer.append(string);
        }
        stringBuffer.append('\u0003');
        string = this.J() ? "1" : "0";
        stringBuffer.append(string);
        stringBuffer.append('\u0003');
        if (ed.b(ar2.U())) return stringBuffer.toString();
        stringBuffer.append(ar2.U());
        return stringBuffer.toString();
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public void C() {
        hx hx2;
        hx hx3;
        d d2;
        w w2;
        int n;
        Vector<ht> vector;
        int n2;
        StringBuffer stringBuffer;
        block52: {
            block51: {
                int n3;
                String string;
                ar ar2;
                block46: {
                    int[] nArray;
                    block50: {
                        block48: {
                            String string2;
                            String string3;
                            block45: {
                                String[] stringArray;
                                block47: {
                                    block49: {
                                        gm gm2;
                                        ar2 = (ar)this.M();
                                        stringBuffer = new StringBuffer();
                                        nArray = new int[]{-1, -1, -1};
                                        n2 = 0;
                                        if (this.B != null && this.z.i() == 2) {
                                            n2 = ((d)this.B).b;
                                            vector = ((d)this.B).e();
                                            for (n = 0; n < vector.size(); ++n) {
                                                fs fs2 = (fs)((ht)vector.elementAt((int)n)).a;
                                                nArray[n] = fs2.g(fs2.q());
                                            }
                                        }
                                        w2 = jj.a(false);
                                        n = this.u.a(false);
                                        if (lh.u()) {
                                            n -= this.u.h();
                                        }
                                        d2 = new d(ps.c, ps.d, this.u.n(), n, w2, false);
                                        if (ar2.q()) {
                                            d2.a(iu.M);
                                        }
                                        vector = new Vector<ht>();
                                        hx3 = ps.a((iy)d2);
                                        ob ob2 = this.a.h();
                                        w w3 = jj.a(false);
                                        w w4 = jj.c(false);
                                        if (ar2.q()) {
                                            this.a(w3, lh.d(476), hx3);
                                        }
                                        dr dr2 = new dr(true, 5);
                                        le le2 = !ar2.q() ? null : ar2.d;
                                        n = dz.a(hx3);
                                        if (le2 != null) {
                                            dr2.d(new oe(0, 0, le2));
                                            n -= le2.a() + 5;
                                        }
                                        string = ar2.v();
                                        cf.a(ob2.a(2, true, false, -16777216, true), string, dr2, n);
                                        hx3.d(dr2);
                                        if (ar2.q()) {
                                            this.a(w3, ar2.E() + " " + ar2.F(), hx3);
                                            cf.a(hx3);
                                        }
                                        if (!string.equals(ar2.b())) {
                                            this.a(w3, ar2.b(), hx3);
                                        }
                                        if (!string.equals(ar2.c()) || !ed.b(ar2.b())) {
                                            this.a(w3, ar2.c(), hx3);
                                        }
                                        if (ar2.t()) {
                                            string3 = ar2.I();
                                            if (!ed.b(string3)) {
                                                this.a(w3, string3, hx3);
                                            }
                                            if (!ed.b(string3 = ar2.J()) && !string.equals(string3)) {
                                                this.a(w3, string3, hx3);
                                            }
                                            this.a(w4, cf.n, hx3);
                                        }
                                        if (ar2.X()) {
                                            this.a(w4, r, hx3);
                                        }
                                        if (ar2.W()) {
                                            this.a(w4, q, hx3);
                                        }
                                        if (ar2.j()) {
                                            this.a(w3, ar2.R(), hx3);
                                        }
                                        if ((gm2 = this.a(ar2, hx3)) != null && hx3.c(gm2)) {
                                            hx3.l(gm2);
                                        }
                                        if (nArray[0] != -1) {
                                            hx3.l(hx3.h(nArray[0]));
                                        }
                                        if (ar2.q() && ar2.a() == null) {
                                            string = lh.d(59);
                                            stringBuffer.append('d');
                                        } else {
                                            string = lh.d(2);
                                            stringBuffer.append('a');
                                        }
                                        vector.addElement(new ht(hx3, string, w2));
                                        if (!ar2.i()) break block46;
                                        if (!ar2.t()) break block47;
                                        hx2 = ps.a((iy)d2);
                                        string = ar2.K();
                                        string3 = ar2.L();
                                        string2 = ar2.M();
                                        if (ed.b(string) && ed.b(string3) && ed.b(string2)) break block48;
                                        if (string.toLowerCase().startsWith("http://")) break block49;
                                        if (string.startsWith("<?xml")) {
                                            no no2 = new no(hx2.a(), this, null, hx2, false);
                                            try {
                                                n = 0;
                                                long l = System.currentTimeMillis();
                                                no2.a(new ByteArrayInputStream(string.getBytes("UTF-8")), "UTF-8");
                                                me.a((short)22, "html", "" + (System.currentTimeMillis() - l));
                                                if (no2.m() == 1 && no2.h(0) instanceof fs) {
                                                    fs fs3 = (fs)no2.h(0);
                                                    n = fs3.m() == 1 && fs3.h(0) instanceof oe && !((oe)fs3.h(0)).a() ? 1 : 0;
                                                }
                                                if (n == 0) {
                                                    hx2.d(no2);
                                                }
                                                break block45;
                                            }
                                            catch (IOException iOException) {
                                                me.b("HTML", iOException);
                                            }
                                            break block45;
                                        } else {
                                            this.a(this.D, string, hx2);
                                        }
                                        break block45;
                                    }
                                    stringArray = cf.b(string);
                                    this.a(stringArray[1], stringArray[0], hx2);
                                    if (ed.b(stringArray[2])) break block45;
                                    this.a(this.D, stringArray[2], hx2);
                                    break block45;
                                }
                                hx2 = ps.a((iy)d2);
                                string = ar2.A();
                                if (!ed.b(string)) {
                                    this.a(ar.h(string), string, hx2);
                                }
                                this.a(ar2.y(), ar2.z(), hx2);
                                gu[] guArray = ar2.B();
                                for (n = 0; n < guArray.length; ++n) {
                                    gu gu2 = guArray[n];
                                    Hashtable hashtable = gu2.c;
                                    stringArray = gu2.a;
                                    for (n3 = 0; n3 < stringArray.length; ++n3) {
                                        string3 = stringArray[n3];
                                        string2 = (String)hashtable.get(string3);
                                        if (string2.equals(string)) continue;
                                        if (!string2.startsWith("http://")) {
                                            w[] wArray = new w[]{this.E, this.D};
                                            String[] stringArray2 = new String[]{string3 + ": ", string2};
                                            new mw(4, 0, dz.a(hx2), wArray, stringArray2).u = true;
                                            hx2.d(new mw(4, 0, dz.a(hx2), wArray, stringArray2));
                                            continue;
                                        }
                                        this.a(string3, string2, hx2);
                                    }
                                    this.a(gu2.a, gu2.b, hx2);
                                }
                                stringBuffer.append('b');
                                break block50;
                            }
                            if (!(ed.b(string3) && ed.b(string2) || hx2.m() <= 0)) {
                                cf.a(hx2);
                            }
                            if (!ed.b(string3)) {
                                this.a(this.F, ed.a(p, string3), hx2);
                            }
                            if (!ed.b(string2)) {
                                this.a(this.F, string2, hx2);
                            }
                        }
                        stringBuffer.append('k');
                    }
                    if (nArray[1] != -1) {
                        hx2.l(hx2.h(nArray[1]));
                    } else {
                        hx2.d(2);
                    }
                    vector.addElement(new ht(hx2, lh.d(59), w2));
                }
                if (!gu.g()) break block51;
                if (!ar2.j() && ar2.k() <= 0) {
                    hx2 = null;
                    break block52;
                } else {
                    lk lk2 = ar2.a.f(118);
                    hx2 = ps.a((iy)d2);
                    int n4 = lk2.d(4);
                    int n5 = this.D.a(ed.a(lh.d(343), new String[]{"8"}));
                    if (lk2.h(5)) {
                        int n6;
                        n = 0;
                        int n7 = 0;
                        for (n3 = 4; n3 >= 0; --n3) {
                            n = Math.max(n, lk2.c(5, n3));
                            n7 = Math.max(n7, this.D.a("" + n6));
                        }
                        if (n > 0) {
                            for (n3 = 4; n3 >= 0; --n3) {
                                n6 = lk2.c(5, n3);
                                string = n3 != 0 ? ed.a(lh.d(343), new String[]{"" + (n3 + 1)}) : lh.d(348);
                                int n8 = n6 * 100 / n;
                                hx2.d(new ne(Math.min(240, dz.a(hx2)), this.D, Math.max(1, 1), n5, n7, string, "" + n6, n8));
                            }
                        }
                    }
                    if (lk2.h(6)) {
                        hx2.d(new bl(0, 0, 0, true, -1, this.D.l() / 4));
                        this.c(ed.a(lh.d(379), lk2.g(6)), hx2);
                        hx2.d(new bl(0, 0, 0, true, -1, this.D.l() / 4));
                    }
                    if (n4 > 0 && ar2.a.h(119)) {
                        this.a(ed.a(lh.d(383), Integer.toString(n4)), "/reviews.html?cid=" + ar2.a().a + ',' + ar2.a().b + ',' + ar2.m(), hx2);
                    }
                }
                break block52;
            }
            hx2 = null;
        }
        if (hx2 != null) {
            vector.addElement(new ht(hx2, lh.d(409), w2));
            stringBuffer.append('r');
        }
        d2.a(vector);
        d2.a_(n2);
        if (ps.a(d2)) {
            for (n = 0; n < vector.size(); ++n) {
                this.a(this.W + " " + '\u00bb', (hx)((ht)vector.elementAt((int)n)).a, 4);
            }
        }
        me.a((short)5, "c", stringBuffer.toString());
        this.B = d2;
        this.C = hx3;
    }
}

