package o;

import com.google.android.gms.common.internal.Preconditions;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class In0 implements Runnable {
    public final /* synthetic */ int l;
    public final /* synthetic */ String m;
    public final /* synthetic */ long n;

    /* renamed from: o, reason: collision with root package name */
    public final /* synthetic */ C2752vp0 f163o;

    public /* synthetic */ In0(C2752vp0 c2752vp0, String str, long j, int i) {
        this.l = i;
        this.m = str;
        this.n = j;
        this.f163o = c2752vp0;
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.l) {
            case 0:
                C2752vp0 c2752vp0 = this.f163o;
                c2752vp0.r();
                String str = this.m;
                Preconditions.checkNotEmpty(str);
                C1839m9 c1839m9 = c2752vp0.c;
                boolean zIsEmpty = c1839m9.isEmpty();
                long j = this.n;
                if (zIsEmpty) {
                    c2752vp0.d = j;
                }
                Integer num = (Integer) c1839m9.get(str);
                if (num == null) {
                    if (c1839m9.n < 100) {
                        c1839m9.put(str, 1);
                        c2752vp0.b.put(str, Long.valueOf(j));
                        break;
                    } else {
                        Nq0 nq0 = ((Kr0) c2752vp0.a).f;
                        Kr0.l(nq0);
                        nq0.i.b("Too many ads visible");
                        break;
                    }
                } else {
                    c1839m9.put(str, Integer.valueOf(num.intValue() + 1));
                    break;
                }
            default:
                C2752vp0 c2752vp02 = this.f163o;
                Kr0 kr0 = (Kr0) c2752vp02.a;
                c2752vp02.r();
                String str2 = this.m;
                Preconditions.checkNotEmpty(str2);
                C1839m9 c1839m92 = c2752vp02.c;
                Integer num2 = (Integer) c1839m92.get(str2);
                if (num2 == null) {
                    Nq0 nq02 = kr0.f;
                    Kr0.l(nq02);
                    nq02.f.c(str2, "Call to endAdUnitExposure for unknown ad unit id");
                    break;
                } else {
                    C2191pt0 c2191pt0 = kr0.l;
                    Nq0 nq03 = kr0.f;
                    Kr0.k(c2191pt0);
                    C1431ht0 c1431ht0Y = c2191pt0.y(false);
                    int iIntValue = num2.intValue() - 1;
                    if (iIntValue != 0) {
                        c1839m92.put(str2, Integer.valueOf(iIntValue));
                        break;
                    } else {
                        c1839m92.remove(str2);
                        C1839m9 c1839m93 = c2752vp02.b;
                        Long l = (Long) c1839m93.get(str2);
                        long j2 = this.n;
                        if (l == null) {
                            Kr0.l(nq03);
                            nq03.f.b("First ad unit exposure time was never set");
                        } else {
                            long jLongValue = j2 - l.longValue();
                            c1839m93.remove(str2);
                            c2752vp02.x(str2, jLongValue, c1431ht0Y);
                        }
                        if (c1839m92.isEmpty()) {
                            long j3 = c2752vp02.d;
                            if (j3 != 0) {
                                c2752vp02.w(j2 - j3, c1431ht0Y);
                                c2752vp02.d = 0L;
                                break;
                            } else {
                                Kr0.l(nq03);
                                nq03.f.b("First ad exposure time was never set");
                                break;
                            }
                        }
                    }
                }
                break;
        }
    }
}
