package o;

import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Iw0 {
    public final String a;
    public final boolean b;
    public final Rr0 c;
    public final BitSet d;
    public final BitSet e;
    public final C1839m9 f;
    public final C1839m9 g;
    public final /* synthetic */ Nn0 h;

    public Iw0(Nn0 nn0, String str, Rr0 rr0, BitSet bitSet, BitSet bitSet2, C1839m9 c1839m9, C1839m9 c1839m92) {
        this.h = nn0;
        this.a = str;
        this.d = bitSet;
        this.e = bitSet2;
        this.f = c1839m9;
        this.g = new C1839m9(0);
        Iterator it = ((C1554j9) c1839m92.keySet()).iterator();
        while (it.hasNext()) {
            Integer num = (Integer) it.next();
            ArrayList arrayList = new ArrayList();
            arrayList.add((Long) c1839m92.get(num));
            this.g.put(num, arrayList);
        }
        this.b = false;
        this.c = rr0;
    }

    public final void a(Ln0 ln0) {
        int iQ;
        boolean z;
        boolean zV;
        switch (ln0.g) {
            case 0:
                iQ = ((C0755aq0) ln0.i).q();
                break;
            default:
                iQ = ((C1425hq0) ln0.i).q();
                break;
        }
        if (ln0.c != null) {
            this.e.set(iQ, true);
        }
        Boolean bool = ln0.d;
        if (bool != null) {
            this.d.set(iQ, bool.booleanValue());
        }
        if (ln0.e != null) {
            Integer numValueOf = Integer.valueOf(iQ);
            C1839m9 c1839m9 = this.f;
            Long l = (Long) c1839m9.get(numValueOf);
            long jLongValue = ln0.e.longValue() / 1000;
            if (l == null || jLongValue > l.longValue()) {
                c1839m9.put(numValueOf, Long.valueOf(jLongValue));
            }
        }
        if (ln0.f != null) {
            Integer numValueOf2 = Integer.valueOf(iQ);
            C1839m9 c1839m92 = this.g;
            List arrayList = (List) c1839m92.get(numValueOf2);
            if (arrayList == null) {
                arrayList = new ArrayList();
                c1839m92.put(numValueOf2, arrayList);
            }
            switch (ln0.g) {
                case 0:
                    z = false;
                    break;
                default:
                    z = true;
                    break;
            }
            if (z) {
                arrayList.clear();
            }
            C3144zv0.a();
            Kr0 kr0 = (Kr0) this.h.a;
            C1421ho0 c1421ho0 = kr0.d;
            C1805lq0 c1805lq0 = AbstractC1900mq0.F0;
            String str = this.a;
            if (c1421ho0.C(str, c1805lq0)) {
                switch (ln0.g) {
                    case 0:
                        zV = ((C0755aq0) ln0.i).v();
                        break;
                    default:
                        zV = false;
                        break;
                }
                if (zV) {
                    arrayList.clear();
                }
            }
            C3144zv0.a();
            if (!kr0.d.C(str, c1805lq0)) {
                arrayList.add(Long.valueOf(ln0.f.longValue() / 1000));
                return;
            }
            Long lValueOf = Long.valueOf(ln0.f.longValue() / 1000);
            if (arrayList.contains(lValueOf)) {
                return;
            }
            arrayList.add(lValueOf);
        }
    }

    public final C1522ir0 b(int i) {
        ArrayList arrayList;
        List list;
        C1427hr0 c1427hr0W = C1522ir0.w();
        c1427hr0W.b();
        ((C1522ir0) c1427hr0W.m).x(i);
        c1427hr0W.b();
        ((C1522ir0) c1427hr0W.m).A(this.b);
        Rr0 rr0 = this.c;
        if (rr0 != null) {
            c1427hr0W.b();
            ((C1522ir0) c1427hr0W.m).z(rr0);
        }
        Qr0 qr0X = Rr0.x();
        ArrayList arrayListV = C1720kv0.V(this.d);
        qr0X.b();
        ((Rr0) qr0X.m).B(arrayListV);
        ArrayList arrayListV2 = C1720kv0.V(this.e);
        qr0X.b();
        ((Rr0) qr0X.m).z(arrayListV2);
        C1839m9 c1839m9 = this.f;
        if (c1839m9 == null) {
            arrayList = null;
        } else {
            ArrayList arrayList2 = new ArrayList(c1839m9.n);
            Iterator it = ((C1554j9) c1839m9.keySet()).iterator();
            while (it.hasNext()) {
                Integer num = (Integer) it.next();
                int iIntValue = num.intValue();
                Long l = (Long) c1839m9.get(num);
                if (l != null) {
                    C2376rr0 c2376rr0T = C2566tr0.t();
                    c2376rr0T.b();
                    ((C2566tr0) c2376rr0T.m).u(iIntValue);
                    long jLongValue = l.longValue();
                    c2376rr0T.b();
                    ((C2566tr0) c2376rr0T.m).v(jLongValue);
                    arrayList2.add((C2566tr0) c2376rr0T.e());
                }
            }
            arrayList = arrayList2;
        }
        if (arrayList != null) {
            qr0X.b();
            ((Rr0) qr0X.m).D(arrayList);
        }
        C1839m9 c1839m92 = this.g;
        if (c1839m92 == null) {
            list = Collections.EMPTY_LIST;
        } else {
            ArrayList arrayList3 = new ArrayList(c1839m92.n);
            Iterator it2 = ((C1554j9) c1839m92.keySet()).iterator();
            while (it2.hasNext()) {
                Integer num2 = (Integer) it2.next();
                Tr0 tr0U = Ur0.u();
                int iIntValue2 = num2.intValue();
                tr0U.b();
                ((Ur0) tr0U.m).v(iIntValue2);
                List list2 = (List) c1839m92.get(num2);
                if (list2 != null) {
                    Collections.sort(list2);
                    tr0U.b();
                    ((Ur0) tr0U.m).w(list2);
                }
                arrayList3.add((Ur0) tr0U.e());
            }
            list = arrayList3;
        }
        qr0X.b();
        ((Rr0) qr0X.m).F(list);
        c1427hr0W.b();
        ((C1522ir0) c1427hr0W.m).y((Rr0) qr0X.e());
        return (C1522ir0) c1427hr0W.e();
    }

    public Iw0(Nn0 nn0, String str) {
        this.h = nn0;
        this.a = str;
        this.b = true;
        this.d = new BitSet();
        this.e = new BitSet();
        this.f = new C1839m9(0);
        this.g = new C1839m9(0);
    }
}
