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

public final class fu
implements lc {
    public static final char a = (char)Math.min(60466, 60671);
    private Vector d;
    private long[] e;
    private Hashtable f;
    private Hashtable g;
    public int b;
    public int c;

    private aq e(long l) {
        return (aq)this.g.get(new Long(l));
    }

    private aq d(char c) {
        return (aq)this.f.get(new Integer(c));
    }

    private static boolean c(long l) {
        return l < 0L;
    }

    public final int b(char c) {
        aq aq2 = this.d(c);
        if (aq2 != null) {
            return aq.b(aq2).b();
        }
        return 0;
    }

    public final int c(char c) {
        aq aq2 = this.d(c);
        if (aq2 != null) {
            return aq.b(aq2).a();
        }
        return 0;
    }

    public final boolean a(char c, ht ht2, int n, int n2) {
        aq aq2 = this.d(c);
        if (aq2 != null && aq.b(aq2) != null) {
            ht2.a(aq.b(aq2), n, n2);
            return true;
        }
        return false;
    }

    public final boolean a(char c) {
        return this.d(c) != null;
    }

    public final void a(int n) {
        if (this.c != n) {
            this.d();
            this.c = n;
        }
    }

    public final char a(long l) {
        aq aq2 = this.e(l);
        if (aq2 != null) {
            return aq.a(aq2);
        }
        return '\uec00';
    }

    public final byte[] b(long l) {
        aq aq2 = this.e(l);
        if (aq2 != null) {
            return aq2.c;
        }
        return null;
    }

    public final long[] b() {
        int n;
        int n2 = 0;
        for (n = 0; n < this.e.length && this.e[n] != 0L; ++n) {
            if (fu.c(this.e[n])) continue;
            ++n2;
        }
        long[] lArray = new long[n2];
        n = 0;
        int n3 = 0;
        while (n3 < n2) {
            long l = this.e[n];
            if (!fu.c(l)) {
                lArray[n3] = l;
                ++n3;
            }
            ++n;
        }
        return lArray;
    }

    private void d() {
        this.c = -1;
        this.f = new Hashtable();
        this.g = new Hashtable();
        this.e = new long[0];
        this.d = new Vector(this.b);
        for (int n = 60416; n < 60416 + this.b; n = (int)((char)(n + 1))) {
            this.d.addElement(new Integer(n));
        }
    }

    public final String h() {
        StringBuffer stringBuffer = new StringBuffer();
        Enumeration enumeration = this.f.keys();
        while (enumeration.hasMoreElements()) {
            stringBuffer.append((char)((Integer)enumeration.nextElement()).intValue());
        }
        return stringBuffer.toString();
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public final aq a(byte[] byArray, long l) {
        if (l == 0L || byArray == null) return null;
        aq aq2 = this.e(l);
        if (aq2 == null) {
            if (this.d.isEmpty()) return null;
            char c = (char)((Integer)this.d.firstElement()).intValue();
            this.d.removeElementAt(0);
            aq2 = new aq(this, byArray, l, c, null);
            this.f.put(new Integer(c), aq2);
            this.g.put(new Long(l), aq2);
            return aq2;
        }
        aq2.c = byArray;
        return aq2;
    }

    public final Hashtable a(Hashtable hashtable) {
        long l;
        long[] lArray = new long[this.b];
        int n = 0;
        Hashtable<Long, Long> hashtable2 = null;
        Enumeration enumeration = hashtable.keys();
        while (enumeration.hasMoreElements()) {
            Long l2 = (Long)enumeration.nextElement();
            if (l2 == 0L) continue;
            if (n >= this.b) {
                if (hashtable2 == null) {
                    hashtable2 = new Hashtable<Long, Long>();
                }
                hashtable2.put(l2, l2);
                continue;
            }
            lArray[n] = l2;
            ++n;
        }
        for (int i = 0; i < this.e.length && (l = this.e[i]) != 0L; ++i) {
            aq aq2;
            if (!fu.c(l)) {
                if (hashtable.containsKey(new Long(l))) continue;
                if (n < lArray.length) {
                    lArray[n] = l;
                    ++n;
                    continue;
                }
            }
            if ((aq2 = this.e(l)) == null) continue;
            Integer n2 = new Integer(aq2.d);
            this.d.addElement(n2);
            this.f.remove(n2);
            this.g.remove(new Long(l));
        }
        this.e = lArray;
        return hashtable2;
    }

    public fu(int n) {
        this.b = Math.min(n, a - 60416);
        this.d();
        aa aa2 = lh.k().f();
        if (nz.a(aa2, "SAVED_REMOTE_ICONS_DATA_BLOCK") != null) {
            int n2;
            lk lk2 = new lk(la.B);
            try {
                lk2.a(aa2.d("SAVED_REMOTE_ICONS_DATA_BLOCK"));
                this.c = lk2.d(17);
                n2 = lk2.i(1);
            }
            catch (IOException iOException) {}
            this.e = new long[n2];
            for (n = 0; n < n2; ++n) {
                long l;
                lk lk3 = lk2.e(1, n);
                byte[] byArray = lk3.c(3);
                this.e[n] = l = lk3.e(2);
                this.a(byArray, l);
            }
        }
    }

    public final void c() {
        try {
            long l;
            int n;
            aa aa2 = lh.k().f();
            lk lk2 = new lk(la.B);
            lk2.h(17, this.c);
            for (n = 0; n < this.e.length && (l = this.e[n]) != 0L; ++n) {
                aq aq2;
                if (fu.c(l) || (aq2 = this.e(l)) == null) continue;
                lk lk3 = lk2.a(1);
                lk3.b(2, aq2.m);
                lk3.b(3, aq2.c);
                lk2.a(1, lk3);
            }
            n = lk2.i(1);
            if (n > 4) {
                lk2.g(1, n - 1);
            }
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            lk2.a(byteArrayOutputStream);
            aa2.b(byteArrayOutputStream.toByteArray(), "SAVED_REMOTE_ICONS_DATA_BLOCK");
            return;
        }
        catch (IOException iOException) {
            return;
        }
    }
}

