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

import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;

/* JADX INFO: loaded from: classes2.dex */
public final class uy0 implements qu1 {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final qe1 f17435c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final re1 f17436d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Executor f17437e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final ScheduledExecutorService f17438f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final oc0 f17439g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final zw0 f17441i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final Context f17442j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final md1 f17443k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final gy0 f17444l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final zq0 f17445m;

    public uy0(Context context, cd1 cd1Var, qy0 qy0Var, we0 we0Var, qe1 qe1Var, re1 re1Var, oc0 oc0Var, a30 a30Var, ScheduledExecutorService scheduledExecutorService, zw0 zw0Var, md1 md1Var, gy0 gy0Var, zq0 zq0Var) {
        this.f17442j = context;
        this.f17433a = cd1Var;
        this.f17440h = qy0Var;
        this.f17434b = we0Var;
        this.f17435c = qe1Var;
        this.f17436d = re1Var;
        this.f17439g = oc0Var;
        this.f17437e = a30Var;
        this.f17438f = scheduledExecutorService;
        this.f17441i = zw0Var;
        this.f17443k = md1Var;
        this.f17444l = gy0Var;
        this.f17445m = zq0Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0059  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static String a(eb1 eb1Var) {
        tn tnVar = ao.f9051r6;
        n7.y yVar = n7.y.f31093e;
        String strN = "No fill.";
        String str = true != ((Boolean) yVar.f31096c.b(tnVar)).booleanValue() ? "No ad config." : "No fill.";
        za1 za1Var = eb1Var.f10746b.f10364b;
        int i10 = za1Var.f19185f;
        if (i10 == 0) {
            strN = str;
        } else if (i10 < 200 || i10 >= 300) {
            strN = (i10 < 300 || i10 >= 400) ? defpackage.e.n(new StringBuilder(String.valueOf(i10).length() + 35), "Received error HTTP response code: ", i10) : "No location header to follow redirect or too many redirects.";
        } else {
            if (((Boolean) yVar.f31096c.b(ao.f9034q6)).booleanValue()) {
            }
        }
        ya1 ya1Var = za1Var.zzj;
        return ya1Var != null ? ya1Var.f18778a : strN;
    }

    @Override // com.google.android.gms.internal.ads.qu1
    public final com.google.common.util.concurrent.w zza(Object obj) {
        int i10;
        Bundle bundle;
        eb1 eb1Var = (eb1) obj;
        tn tnVar = ao.B2;
        n7.y yVar = n7.y.f31093e;
        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue() && (bundle = eb1Var.f10746b.zzd) != null) {
            this.f17445m.f19368e.putAll(bundle);
        }
        if (((Boolean) yVar.f31096c.b(ao.C2)).booleanValue()) {
            com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.n(m7.n.C.f30472k, this.f17445m.f19368e, zzdxh.RENDERING_START.a());
        }
        String strA = a(eb1Var);
        zw0 zw0Var = this.f17441i;
        db1 db1Var = eb1Var.f10746b;
        za1 za1Var = db1Var.f10364b;
        zw0Var.a(za1Var);
        if (((Boolean) yVar.f31096c.b(ao.f9086t9)).booleanValue() && (i10 = za1Var.f19185f) != 0 && (i10 < 200 || i10 >= 300)) {
            return ih1.q0(new zzenv(3, strA));
        }
        String str = za1Var.f19195p;
        if (!((Boolean) yVar.f31096c.b(ao.f8964m4)).booleanValue() || TextUtils.isEmpty(str)) {
            for (wa1 wa1Var : db1Var.f10363a) {
                zw0Var.d(wa1Var, zw0Var.f19406a.size());
                Iterator it = wa1Var.f17971a.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        zw0Var.zze(wa1Var, 0L, sb1.zzd(1, null, null));
                        break;
                    }
                    vw0 vw0VarZza = this.f17439g.zza(wa1Var.f17973b, (String) it.next());
                    if (vw0VarZza == null || !vw0VarZza.a(eb1Var, wa1Var)) {
                    }
                }
            }
        } else {
            List list = db1Var.f10363a;
            synchronized (zw0Var) {
                Map map = zw0Var.f19407b;
                if (map.containsKey(str)) {
                    n7.h4 h4Var = (n7.h4) map.get(str);
                    List list2 = zw0Var.f19406a;
                    int iIndexOf = list2.indexOf(h4Var);
                    try {
                        list2.remove(iIndexOf);
                    } catch (IndexOutOfBoundsException e10) {
                        m7.n.C.f30469h.d("AdapterResponseInfoCollector.replaceAdapterResponseInfoEntry", e10);
                    }
                    zw0Var.f19407b.remove(str);
                    Iterator it2 = list.iterator();
                    while (it2.hasNext()) {
                        zw0Var.d((wa1) it2.next(), iIndexOf);
                        iIndexOf++;
                    }
                }
            }
        }
        we0 we0Var = this.f17434b;
        ba0 ba0Var = new ba0(eb1Var, this.f17436d, this.f17435c);
        Executor executor = this.f17437e;
        we0Var.G0(ba0Var, executor);
        if (za1Var.f19196q > 1) {
            return this.f17444l.a(eb1Var);
        }
        String strA2 = a(eb1Var);
        cd1 cd1Var = this.f17433a;
        zzfno zzfnoVar = zzfno.RENDER_CONFIG_INIT;
        Objects.requireNonNull(cd1Var);
        vc1 vc1VarF = new xc1(cd1Var, zzfnoVar, null, yc1.f18806d, Collections.emptyList(), ih1.q0(new zzenv(3, strA2))).f();
        qy0 qy0Var = this.f17440h;
        synchronized (qy0Var) {
            ((i8.d) qy0Var.f15888a).getClass();
            qy0Var.f15896i = SystemClock.elapsedRealtime();
        }
        int i11 = 0;
        for (wa1 wa1Var2 : db1Var.f10363a) {
            Iterator it3 = wa1Var2.f17971a.iterator();
            while (true) {
                if (!it3.hasNext()) {
                    break;
                }
                String str2 = (String) it3.next();
                vw0 vw0VarZza2 = this.f17439g.zza(wa1Var2.f17973b, str2);
                if (vw0VarZza2 != null && vw0VarZza2.a(eb1Var, wa1Var2)) {
                    xc1 xc1VarA = cd1Var.a(vc1VarF, zzfno.RENDER_CONFIG_WATERFALL);
                    StringBuilder sb = new StringBuilder(String.valueOf(i11).length() + 15 + String.valueOf(str2).length());
                    sb.append("render-config-");
                    sb.append(i11);
                    sb.append("-");
                    sb.append(str2);
                    vc1VarF = new xc1(xc1VarA.f18411e, xc1VarA.f18407a, sb.toString(), xc1VarA.f18408b, xc1VarA.f18409c, xc1VarA.f18410d).d(Throwable.class, new w90(this, wa1Var2, eb1Var, vw0VarZza2, 5)).f();
                    break;
                }
            }
            i11++;
        }
        vc1VarF.g(new z80(qy0Var, 22), executor);
        return vc1VarF;
    }
}
