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

import android.app.UiModeManager;
import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.webkit.WebView;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class jc1 implements zu1, z3.a0, kg1, w8.e, w8.d, up1, tq1, dr0, co2, or2 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f12807a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f12808b;

    public jc1(int i10) {
        this.f12807a = i10;
        if (i10 == 15) {
            this.f12808b = new HashMap();
            return;
        }
        if (i10 == 21) {
            this.f12808b = zzgup.t(2, 1, 5);
        } else if (i10 != 25) {
            this.f12808b = new int[2];
        } else {
            this.f12808b = sl0.f16474a;
        }
    }

    public static jc1 c(BigInteger bigInteger) {
        return new jc1(bigInteger, 16);
    }

    public static jc1 d(byte[] bArr) {
        return new jc1(i92.a(bArr), 17);
    }

    public static uq2 e(fl flVar, int[] iArr, zzguf zzgufVar) {
        uq2 uq2Var = new uq2(flVar, iArr);
        zzguf.s(zzgufVar);
        return uq2Var;
    }

    public static jc1 g(int i10) {
        return new jc1(i92.a(j12.a(i10)), 17);
    }

    @Override // com.google.android.gms.internal.ads.or2
    public final List a(int i10, fl flVar, int[] iArr) {
        ts1 ts1Var = b.f9321f;
        bs1 bs1Var = zzguf.f19771b;
        as1 as1Var = new as1(4);
        for (int i11 = 0; i11 < flVar.f11273a; i11++) {
            as1Var.a(new gr2(i10, flVar, i11, (jr2) this.f12808b, iArr[i11]));
        }
        return as1Var.g();
    }

    @Override // com.google.android.gms.internal.ads.tq1
    public final /* synthetic */ Iterator b(ru ruVar, CharSequence charSequence) {
        switch (this.f12807a) {
            case 11:
                return new pq1(charSequence, ((lq1) this.f12808b).a(charSequence), 1);
            default:
                return new pq1(charSequence, (jq1) this.f12808b, 0);
        }
    }

    public final JSONObject f(View view) {
        switch (this.f12807a) {
            case 3:
                JSONObject jSONObjectA = qg1.a(0, 0, 0, 0);
                UiModeManager uiModeManager = vj1.f17664l;
                zzfsp zzfspVar = zzfsp.OTHER;
                zzfsp zzfspVar2 = zzfsp.CTV;
                if (uiModeManager != null) {
                    int currentModeType = uiModeManager.getCurrentModeType();
                    if (currentModeType == 1) {
                        zzfspVar = zzfsp.MOBILE;
                    } else if (currentModeType == 4) {
                        zzfspVar = zzfspVar2;
                    }
                }
                int i10 = zzfspVar != zzfspVar2 ? 2 : ih1.f12516h;
                int i11 = i10 - 1;
                if (i10 == 0) {
                    throw null;
                }
                try {
                    jSONObjectA.put("noOutputDevice", i11 == 0);
                    break;
                } catch (JSONException unused) {
                    ni.g();
                }
                return jSONObjectA;
            default:
                if (view == null) {
                    return qg1.a(0, 0, 0, 0);
                }
                int[] iArr = (int[]) this.f12808b;
                int width = view.getWidth();
                int height = view.getHeight();
                view.getLocationOnScreen(iArr);
                return qg1.a(iArr[0], iArr[1], width, height);
        }
    }

    public final byte[] h() {
        return ((i92) this.f12808b).b();
    }

    public final int i() {
        return ((i92) this.f12808b).f12427a.length;
    }

    @Override // w8.d
    public final void onComplete(w8.h hVar) {
        wj1 wj1Var = (wj1) this.f12808b;
        if (((w8.t) hVar).f34253d) {
            wj1Var.cancel(false);
            return;
        }
        if (hVar.j()) {
            wj1Var.c(hVar.g());
            return;
        }
        Exception exception = hVar.getException();
        if (exception == null) {
            throw new IllegalStateException();
        }
        wj1Var.d(exception);
    }

    @Override // w8.e
    public final /* synthetic */ void onFailure(Exception exc) {
        nh1 nh1Var = (nh1) this.f12808b;
        nh1Var.getClass();
        if (exc instanceof InterruptedException) {
            Thread.currentThread().interrupt();
        }
        nh1Var.f14612c.c(2025, -1L, exc);
    }

    @Override // z3.a0
    public final void onPostMessage(WebView webView, z3.p pVar, Uri uri, boolean z10, z3.a aVar) {
        try {
            JSONObject jSONObject = new JSONObject(pVar.getData());
            String string = jSONObject.getString("method");
            String string2 = jSONObject.getJSONObject("data").getString("adSessionId");
            if (string.equals("startSession")) {
                ((wf1) this.f12808b).a(string2);
                return;
            }
            if (!string.equals("finishSession")) {
                qf1.f15728a.booleanValue();
                return;
            }
            HashMap map = ((wf1) this.f12808b).f18038d;
            sf1 sf1Var = (sf1) map.get(string2);
            if (sf1Var != null) {
                sf1Var.b();
                map.remove(string2);
            }
        } catch (JSONException unused) {
            ni.g();
        }
    }

    @Override // com.google.android.gms.internal.ads.dr0, com.google.android.gms.internal.ads.co0
    /* JADX INFO: renamed from: zza */
    public final /* synthetic */ void mo2zza(Object obj) {
        switch (this.f12807a) {
            case 18:
                ((og) obj).c((rw) this.f12808b);
                break;
            default:
                int i10 = uh2.f17256a0;
                ((og) obj).p((d9) this.f12808b);
                break;
        }
    }

    @Override // com.google.android.gms.internal.ads.zu1
    /* JADX INFO: renamed from: zzb */
    public final void mo3zzb(Object obj) {
        switch (this.f12807a) {
            case 1:
                lf1 lf1Var = (lf1) this.f12808b;
                synchronized (lf1Var) {
                    try {
                        lf1Var.f13669j.set(false);
                        if (obj != null) {
                            lf1Var.f13667h.a();
                            lf1Var.f13673n.set(true);
                            lf1Var.e(obj);
                        }
                        if (obj == null || lf1Var.zzf == null) {
                            lf1Var.f(obj == null);
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                    break;
                }
                return;
            case 8:
                rl1 rl1Var = (rl1) obj;
                ml1 ml1Var = (ml1) ((yl1) this.f12808b).f18881c;
                synchronized (ml1Var.f14258m) {
                    ee eeVar = ml1Var.S;
                    String strZza = rl1Var.zza();
                    eeVar.c();
                    ((fe) eeVar.f8617b).L(strZza);
                    break;
                }
                return;
            default:
                ((ip1) this.f12808b).c();
                return;
        }
    }

    @Override // com.google.android.gms.internal.ads.co2
    public final int zza(Object obj) {
        tn2 tn2Var = (tn2) obj;
        HashMap map = do2.f10469a;
        zn2 zn2Var = (zn2) this.f12808b;
        tn2Var.getClass();
        String str = zn2Var.zzo;
        String str2 = tn2Var.f16955b;
        return ((str2.equals(str) || str2.equals(do2.zzg(zn2Var))) && tn2Var.e(zn2Var, false) && tn2Var.f(zn2Var)) ? 1 : 0;
    }

    public /* synthetic */ jc1(bj1 bj1Var) {
        this.f12807a = 6;
        this.f12808b = bj1Var;
    }

    public /* synthetic */ jc1(Object obj, int i10) {
        this.f12807a = i10;
        this.f12808b = obj;
    }

    public jc1() {
        this.f12807a = 14;
        this.f12808b = new AtomicBoolean(false);
    }

    public jc1(Context context, m50 m50Var) {
        this.f12807a = 22;
        this.f12808b = new fh2(context, m50Var);
    }

    public jc1(lf1 lf1Var) {
        this.f12807a = 1;
        Objects.requireNonNull(lf1Var);
        this.f12808b = lf1Var;
    }

    @Override // com.google.android.gms.internal.ads.zu1
    public final void zza(Throwable th) {
        switch (this.f12807a) {
            case 1:
                lf1 lf1Var = (lf1) this.f12808b;
                synchronized (lf1Var) {
                    try {
                        lf1Var.f13669j.set(false);
                        if ((th instanceof zzfqs) && ((zzfqs) th).a() == 0) {
                            throw null;
                        }
                        lf1Var.f(true);
                    } catch (Throwable th2) {
                        throw th2;
                    }
                }
                return;
            case 8:
                return;
            default:
                ip1 ip1Var = (ip1) this.f12808b;
                ip1Var.b(th);
                ip1Var.c();
                return;
        }
    }

    public jc1(wf1 wf1Var) {
        this.f12807a = 2;
        Objects.requireNonNull(wf1Var);
        this.f12808b = wf1Var;
    }

    public jc1(yl1 yl1Var) {
        this.f12807a = 8;
        Objects.requireNonNull(yl1Var);
        this.f12808b = yl1Var;
    }

    public jc1(jp1 jp1Var, ip1 ip1Var) {
        this.f12807a = 9;
        this.f12808b = ip1Var;
        Objects.requireNonNull(jp1Var);
    }
}
