package com.google.android.gms.internal.ads;

import android.os.Bundle;
import androidx.annotation.Nullable;
import java.util.HashMap;
import java.util.Set;
import java.util.TreeSet;

/* JADX INFO: loaded from: classes2.dex */
public final class t20 {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final String f16682h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final p7.n0 f16683i;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public long f16675a = -1;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public long f16676b = -1;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f16677c = -1;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f16678d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public long f16679e = 0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final Object f16680f = new Object();

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final Object f16681g = new Object();

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f16684j = 0;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f16685k = 0;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f16686l = 0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f16687m = 0;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final HashMap f16688n = new HashMap();

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final HashMap f16689o = new HashMap();

    public t20(String str, p7.o0 o0Var) {
        this.f16682h = str;
        this.f16683i = o0Var;
    }

    public final void a(n7.a4 a4Var, long j10) {
        long j11;
        long j12;
        Bundle bundle;
        int i10;
        synchronized (this.f16680f) {
            try {
                p7.o0 o0Var = (p7.o0) this.f16683i;
                o0Var.k();
                synchronized (o0Var.f31726a) {
                    j11 = o0Var.f31735j;
                }
                m7.n.C.f30472k.getClass();
                long jCurrentTimeMillis = System.currentTimeMillis();
                if (this.f16676b == -1) {
                    if (jCurrentTimeMillis - j11 > ((Long) n7.y.f31093e.f31096c.b(ao.f9062s1)).longValue()) {
                        this.f16678d = -1;
                    } else {
                        o0Var.k();
                        synchronized (o0Var.f31726a) {
                            i10 = o0Var.f31737l;
                        }
                        this.f16678d = i10;
                    }
                    this.f16676b = j10;
                    this.f16675a = j10;
                } else {
                    this.f16675a = j10;
                }
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8981n4)).booleanValue() || (bundle = a4Var.f30895c) == null || bundle.getInt("gw", 2) != 1) {
                    this.f16677c++;
                    int i11 = this.f16678d + 1;
                    this.f16678d = i11;
                    if (i11 == 0) {
                        this.f16679e = 0L;
                        o0Var.w(jCurrentTimeMillis);
                    } else {
                        o0Var.k();
                        synchronized (o0Var.f31726a) {
                            j12 = o0Var.f31736k;
                        }
                        this.f16679e = jCurrentTimeMillis - j12;
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void b() {
        if (((Boolean) vp.f17744a.j()).booleanValue()) {
            synchronized (this.f16680f) {
                this.f16677c--;
                this.f16678d--;
            }
        }
    }

    public final s20 zzi(Set set, @Nullable String str) {
        synchronized (this.f16681g) {
            try {
                int i10 = this.f16687m;
                this.f16687m = i10 + 1;
                if (set.isEmpty()) {
                    return new s20(i10, -1, -1);
                }
                String strI = com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.i(new TreeSet(set));
                HashMap map = this.f16688n;
                Integer num = (Integer) map.get(strI);
                int iIntValue = 0;
                int iIntValue2 = num == null ? 0 : num.intValue();
                map.put(strI, Integer.valueOf(iIntValue2 + 1));
                if (str == null) {
                    return new s20(i10, iIntValue2, -1);
                }
                StringBuilder sb = new StringBuilder(str.length() + 1 + String.valueOf(strI).length());
                sb.append(str);
                sb.append("|");
                sb.append(strI);
                String string = sb.toString();
                HashMap map2 = this.f16689o;
                Integer num2 = (Integer) map2.get(string);
                if (num2 != null) {
                    iIntValue = num2.intValue();
                }
                map2.put(string, Integer.valueOf(iIntValue + 1));
                return new s20(i10, iIntValue2, iIntValue);
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
