package C3;

import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import n4.u0;

/* JADX INFO: renamed from: C3.n, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0052n extends AbstractCollection {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f1286q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final Object f1287r;

    public /* synthetic */ C0052n(int i, Serializable serializable) {
        this.f1286q = i;
        this.f1287r = serializable;
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public final void clear() {
        switch (this.f1286q) {
            case u0.f15495q /* 0 */:
                ((T) this.f1287r).b();
                break;
            case 1:
                ((C0058u) this.f1287r).clear();
                break;
            default:
                ((C0042d) this.f1287r).clear();
                break;
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public boolean contains(Object obj) {
        switch (this.f1286q) {
            case u0.f15495q /* 0 */:
                Iterator it = ((T) this.f1287r).a().values().iterator();
                while (it.hasNext()) {
                    if (((Collection) it.next()).contains(obj)) {
                        return true;
                    }
                }
                return false;
            case 1:
            default:
                return super.contains(obj);
            case 2:
                return ((C0042d) this.f1287r).containsValue(obj);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public boolean isEmpty() {
        switch (this.f1286q) {
            case 2:
                return ((C0042d) this.f1287r).isEmpty();
            default:
                return super.isEmpty();
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
    public final Iterator iterator() {
        switch (this.f1286q) {
            case u0.f15495q /* 0 */:
                return new C0039a((T) this.f1287r);
            case 1:
                C0058u c0058u = (C0058u) this.f1287r;
                Map mapB = c0058u.b();
                return mapB != null ? mapB.values().iterator() : new r(c0058u, 2);
            default:
                return new Q(((C0042d) this.f1287r).entrySet().iterator());
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public boolean remove(Object obj) {
        switch (this.f1286q) {
            case 2:
                try {
                    return super.remove(obj);
                } catch (UnsupportedOperationException unused) {
                    C0042d c0042d = (C0042d) this.f1287r;
                    for (Map.Entry entry : c0042d.entrySet()) {
                        if (s7.l.h(obj, entry.getValue())) {
                            c0042d.remove(entry.getKey());
                            return true;
                        }
                    }
                    return false;
                }
            default:
                return super.remove(obj);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public boolean removeAll(Collection collection) {
        switch (this.f1286q) {
            case 2:
                try {
                    collection.getClass();
                    return super.removeAll(collection);
                } catch (UnsupportedOperationException unused) {
                    HashSet hashSet = new HashSet();
                    C0042d c0042d = (C0042d) this.f1287r;
                    for (Map.Entry entry : c0042d.entrySet()) {
                        if (collection.contains(entry.getValue())) {
                            hashSet.add(entry.getKey());
                        }
                    }
                    return c0042d.keySet().removeAll(hashSet);
                }
            default:
                return super.removeAll(collection);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public boolean retainAll(Collection collection) {
        switch (this.f1286q) {
            case 2:
                try {
                    collection.getClass();
                    return super.retainAll(collection);
                } catch (UnsupportedOperationException unused) {
                    HashSet hashSet = new HashSet();
                    C0042d c0042d = (C0042d) this.f1287r;
                    for (Map.Entry entry : c0042d.entrySet()) {
                        if (collection.contains(entry.getValue())) {
                            hashSet.add(entry.getKey());
                        }
                    }
                    return c0042d.keySet().retainAll(hashSet);
                }
            default:
                return super.retainAll(collection);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection
    public final int size() {
        switch (this.f1286q) {
            case u0.f15495q /* 0 */:
                return ((T) this.f1287r).f1220u;
            case 1:
                return ((C0058u) this.f1287r).size();
            default:
                return ((C0042d) this.f1287r).f1263s.size();
        }
    }

    public C0052n(C0042d c0042d) {
        this.f1286q = 2;
        this.f1287r = c0042d;
    }
}
