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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final gs0 f14724a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final kq0 f14725b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final ArrayList f14727d = new ArrayList();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f14728e;

    public ns0(gs0 gs0Var, kq0 kq0Var) {
        this.f14724a = gs0Var;
        this.f14725b = kq0Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0042 A[Catch: all -> 0x001a, LOOP:0: B:15:0x003c->B:17:0x0042, LOOP_END, TryCatch #0 {all -> 0x001a, blocks: (B:4:0x0008, B:6:0x000c, B:8:0x0012, B:11:0x001c, B:12:0x0034, B:14:0x0036, B:15:0x003c, B:17:0x0042, B:18:0x0050), top: B:22:0x0008 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final JSONArray a() {
        Iterator it;
        JSONArray jSONArray = new JSONArray();
        synchronized (this.f14726c) {
            try {
                if (this.f14728e) {
                    it = this.f14727d.iterator();
                    while (it.hasNext()) {
                    }
                } else {
                    gs0 gs0Var = this.f14724a;
                    if (gs0Var.f11850b) {
                        b(gs0Var.b());
                        it = this.f14727d.iterator();
                        while (it.hasNext()) {
                            jSONArray.put(((ls0) it.next()).a());
                        }
                    } else {
                        n7.a3 a3Var = new n7.a3(this);
                        gs0 gs0Var2 = this.f14724a;
                        gs0Var2.getClass();
                        gs0Var2.f11853e.g(new bv(gs0Var2, a3Var, 28), gs0Var2.f11858j);
                    }
                }
            } finally {
            }
        }
        return jSONArray;
    }

    public final void b(List list) {
        px pxVar;
        jq0 jq0VarB;
        jq0 jq0VarB2;
        px pxVar2;
        synchronized (this.f14726c) {
            try {
                if (this.f14728e) {
                    return;
                }
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    zt ztVar = (zt) it.next();
                    tn tnVar = ao.Ba;
                    n7.y yVar = n7.y.f31093e;
                    String string = (!((Boolean) yVar.f31096c.b(tnVar)).booleanValue() || (jq0VarB2 = this.f14725b.b(ztVar.f19385a)) == null || (pxVar2 = jq0VarB2.f12969c) == null) ? "" : pxVar2.toString();
                    String str = string;
                    boolean z10 = ((Boolean) yVar.f31096c.b(ao.Ca)).booleanValue() && (jq0VarB = this.f14725b.b(ztVar.f19385a)) != null && jq0VarB.f12970d;
                    ArrayList arrayList = this.f14727d;
                    String str2 = ztVar.f19385a;
                    jq0 jq0VarB3 = this.f14725b.b(str2);
                    arrayList.add(new ls0(str2, str, (jq0VarB3 == null || (pxVar = jq0VarB3.f12968b) == null) ? "" : pxVar.toString(), ztVar.f19386b ? 1 : 0, ztVar.f19388d, ztVar.f19387c, z10));
                }
                this.f14728e = true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
