package com.applovin.impl.sdk; import com.applovin.impl.ge; import com.applovin.impl.q6; import java.util.ArrayDeque; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; /* loaded from: classes2.dex */ public class e { private final j a; private final Map b = new HashMap(); private final Object c = new Object(); private final Map d = new HashMap(); private final Object e = new Object(); public enum c { LOAD("load"), SHOW("show"), HIDE("hide"), CLICK("click"), DESTROY("destroy"), SHOW_ERROR("show_error"); public static final Set i = new HashSet(Arrays.asList(values())); private final String a; c(String str) { this.a = str; } @Override // java.lang.Enum public String toString() { return this.a; } } public interface d { void a(b bVar); } public e(j jVar) { this.a = jVar; a(); } public static class b { private final String a; private final String b; private final String c; private final String d; private final String e; private final String f; private final String g; private final int h; private long i; private final ArrayDeque j; public String a() { return this.a; } public String b() { return this.d; } public String c() { return this.c; } public String d() { return this.e; } public String e() { return this.f; } public String f() { return this.g; } public String g() { return this.b; } public int h() { return this.h; } public c i() { return (c) this.j.getLast(); } public String toString() { return "AdInfo{state='" + i() + "', adUnitId='" + this.a + "', format='" + this.b + "', adapterName='" + this.c + "', adapterClass='" + this.d + "', adapterVersion='" + this.e + "', bCode='" + this.f + "', creativeId='" + this.g + "', updated=" + this.i + '}'; } /* JADX INFO: Access modifiers changed from: private */ public void a(c cVar) { this.i = System.currentTimeMillis(); this.j.add(cVar); } private b(ge geVar, c cVar) { this.j = new ArrayDeque(); this.a = geVar.getAdUnitId(); this.b = geVar.getFormat().getLabel(); this.c = geVar.c(); this.d = geVar.b(); this.e = geVar.z(); this.f = geVar.B(); this.g = geVar.getCreativeId(); this.h = geVar.hashCode(); a(cVar); } } public void a(ge geVar, c cVar) { synchronized (this.e) { try { int hashCode = geVar.hashCode(); b bVar = (b) this.d.get(Integer.valueOf(hashCode)); if (bVar == null) { if (cVar == c.DESTROY) { return; } bVar = new b(geVar, cVar); this.d.put(Integer.valueOf(hashCode), bVar); } else if (bVar.i() == cVar) { return; } else { bVar.a(cVar); } if (cVar == c.DESTROY) { this.d.remove(Integer.valueOf(hashCode)); } a(bVar, cVar); } catch (Throwable th) { throw th; } } } public void a() { synchronized (this.c) { try { for (c cVar : c.values()) { this.b.put(cVar, new HashSet()); } } catch (Throwable th) { throw th; } } } public void a(d dVar, Set set) { synchronized (this.c) { try { Iterator it = set.iterator(); while (it.hasNext()) { a((c) it.next()).add(dVar); } } catch (Throwable th) { throw th; } } } public void a(d dVar) { synchronized (this.c) { try { Iterator it = this.b.keySet().iterator(); while (it.hasNext()) { a((c) it.next()).remove(dVar); } } catch (Throwable th) { throw th; } } } private Set a(c cVar) { synchronized (this.c) { try { Set set = (Set) this.b.get(cVar); if (q6.a(set)) { return set; } return new HashSet(); } catch (Throwable th) { throw th; } } } private void a(b bVar, c cVar) { synchronized (this.c) { try { Iterator it = a(cVar).iterator(); while (it.hasNext()) { ((d) it.next()).a(bVar); } } catch (Throwable th) { throw th; } } } }