package com.google.android.recaptcha.internal;

import A4.d;
import R4.k;
import V4.C0763h0;
import V4.E;
import V4.H0;
import V4.InterfaceC0765i0;
import android.app.Application;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import com.google.android.recaptcha.RecaptchaAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import kotlin.jvm.internal.o;
import m1.g;
import m3.AbstractC2467b;
import w4.C3137A;
import w4.h;
import w4.n;
import x4.AbstractC3229F;
import x4.AbstractC3251q;
import x4.AbstractC3253s;

/* JADX INFO: loaded from: classes3.dex */
public final class zzdt {
    private final String zza;
    private final zzek zzb;
    private final zzl zzc;
    private final h zzd;
    private final h zze;
    private final h zzf;
    private final h zzg;
    private final h zzh;
    private final zzbi zzi;

    public zzdt(String str, zzbi zzbiVar, zzek zzekVar, zzl zzlVar) {
        this.zza = str;
        this.zzi = zzbiVar;
        this.zzb = zzekVar;
        this.zzc = zzlVar;
        int i6 = zzav.zza;
        this.zzd = g.k(zzdm.zza);
        this.zze = g.k(zzdn.zza);
        this.zzf = g.k(zzdo.zza);
        this.zzg = g.k(zzdp.zza);
        this.zzh = g.k(zzdq.zza);
    }

    public static final /* synthetic */ zzbr zzd(zzdt zzdtVar) {
        return (zzbr) zzdtVar.zze.getValue();
    }

    public static final /* synthetic */ zzff zzg(zzdt zzdtVar) {
        return (zzff) zzdtVar.zzd.getValue();
    }

    public static final /* synthetic */ zzfj zzh(zzdt zzdtVar) {
        return (zzfj) zzdtVar.zzg.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Application zzr() {
        return (Application) this.zzh.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final zzbd zzs(Exception exc, zzbd zzbdVar) {
        return !zzx() ? new zzbd(zzbb.zzc, zzba.zzao, exc.getMessage()) : zzbdVar;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final zzbf zzt() {
        return (zzbf) this.zzf.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final zzek zzu(String str) {
        zzek zzekVarZza = this.zzb.zza();
        zzekVarZza.zzc(str);
        return zzekVarZza;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0014  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object zzv(zzsc zzscVar, long j4, d dVar) throws Throwable {
        zzdj zzdjVar;
        Object objZzc;
        zzdt zzdtVar;
        k children;
        if (dVar instanceof zzdj) {
            zzdjVar = (zzdj) dVar;
            int i6 = zzdjVar.zzd;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                zzdjVar.zzd = i6 - Integer.MIN_VALUE;
            } else {
                zzdjVar = new zzdj(this, dVar);
            }
        }
        zzdj zzdjVar2 = zzdjVar;
        Object obj = zzdjVar2.zzb;
        B4.a aVar = B4.a.f492a;
        int i7 = zzdjVar2.zzd;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            zzy(zzscVar.zzO());
            Iterator it = zzw().iterator();
            while (it.hasNext()) {
                this.zzc.zzf((zze) it.next());
            }
            zzl zzlVar = this.zzc;
            zzek zzekVar = this.zzb;
            zzdjVar2.zza = this;
            zzdjVar2.zzd = 1;
            objZzc = zzlVar.zzc(j4, zzscVar, zzekVar, zzdjVar2);
            if (objZzc != aVar) {
                zzdtVar = this;
            }
            return aVar;
        }
        if (i7 != 1) {
            if (i7 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            Throwable th = (Throwable) zzdjVar2.zza;
            AbstractC2467b.l(obj);
            throw th;
        }
        zzdtVar = (zzdt) zzdjVar2.zza;
        AbstractC2467b.l(obj);
        objZzc = ((n) obj).f25472a;
        Throwable thA = n.a(objZzc);
        if (thA == null) {
            return C3137A.f25453a;
        }
        InterfaceC0765i0 interfaceC0765i0 = (InterfaceC0765i0) zzdtVar.zzi.zzd().getCoroutineContext().get(C0763h0.f8306a);
        if (interfaceC0765i0 != null && (children = interfaceC0765i0.getChildren()) != null) {
            Iterator it2 = children.iterator();
            while (it2.hasNext()) {
                ((InterfaceC0765i0) it2.next()).cancel(null);
            }
        }
        List listD0 = R4.n.d0(E.q(zzdtVar.zzi.zzd().getCoroutineContext()).getChildren());
        zzdjVar2.zza = thA;
        zzdjVar2.zzd = 2;
        if (E.w(listD0, zzdjVar2) != aVar) {
            throw thA;
        }
        return aVar;
    }

    private final List zzw() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new zzv(zzr(), this.zzb.zza(), this.zzi, null, 8, null));
        arrayList.add(new zzja(this.zzb, this.zzi));
        return AbstractC3251q.C0(arrayList);
    }

    private final boolean zzx() {
        NetworkCapabilities networkCapabilities;
        int i6 = zzav.zza;
        try {
            Object systemService = zzr().getSystemService("connectivity");
            o.f(systemService, "null cannot be cast to non-null type android.net.ConnectivityManager");
            ConnectivityManager connectivityManager = (ConnectivityManager) systemService;
            Network activeNetwork = connectivityManager.getActiveNetwork();
            if (activeNetwork != null && (networkCapabilities = connectivityManager.getNetworkCapabilities(activeNetwork)) != null) {
                return networkCapabilities.hasCapability(16);
            }
            return false;
        } catch (Exception unused) {
            return false;
        }
    }

    private static final void zzy(String str) throws zzbd {
        try {
            zzrv zzrvVarZzj = zzrv.zzj(zzbt.zza(str));
            int i6 = zzav.zza;
            ((zzfu) g.k(zzde.zza).getValue()).zza(zzrvVarZzj);
        } catch (Exception e6) {
            throw new zzbd(zzbb.zzl, zzba.zzan, e6.getMessage());
        }
    }

    public final zzsp zzi(RecaptchaAction recaptchaAction, zzsi zzsiVar, zzsc zzscVar) {
        zzso zzsoVarZzf = zzsp.zzf();
        zzsoVarZzf.zzs(this.zza);
        zzsoVarZzf.zze(recaptchaAction.getAction());
        zzsoVarZzf.zzf(zzscVar.zzN());
        zzsoVarZzf.zzq(zzscVar.zzM());
        zzsoVarZzf.zzr(zzsiVar);
        return (zzsp) zzsoVarZzf.zzk();
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object zzl(String str, long j4, d dVar) throws zzbd {
        zzdd zzddVar;
        Exception e6;
        zzen zzenVar;
        zzbd e7;
        H0 e8;
        if (dVar instanceof zzdd) {
            zzddVar = (zzdd) dVar;
            int i6 = zzddVar.zzc;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                zzddVar.zzc = i6 - Integer.MIN_VALUE;
            } else {
                zzddVar = new zzdd(this, dVar);
            }
        }
        Object obj = zzddVar.zza;
        B4.a aVar = B4.a.f492a;
        int i7 = zzddVar.zzc;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            zzen zzenVarZzf = zzu(str).zzf(27);
            try {
                zzl zzlVar = this.zzc;
                zzddVar.zzd = zzenVarZzf;
                zzddVar.zzc = 1;
                Object objZzb = zzlVar.zzb(str, j4, zzddVar);
                if (objZzb == aVar) {
                    return aVar;
                }
                obj = objZzb;
                zzenVar = zzenVarZzf;
            } catch (H0 e9) {
                e8 = e9;
                zzenVar = zzenVarZzf;
                zzbd zzbdVar = new zzbd(zzbb.zzb, zzba.zzb, e8.getMessage());
                zzenVar.zzb(zzbdVar);
                throw zzbdVar;
            } catch (zzbd e10) {
                e7 = e10;
                zzenVar = zzenVarZzf;
                zzenVar.zzb(e7);
                throw e7;
            } catch (Exception e11) {
                e6 = e11;
                zzenVar = zzenVarZzf;
                zzbd zzbdVar2 = new zzbd(zzbb.zzb, zzba.zzaa, e6.getMessage());
                zzenVar.zzb(zzbdVar2);
                throw zzbdVar2;
            }
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            zzenVar = zzddVar.zzd;
            try {
                AbstractC2467b.l(obj);
            } catch (H0 e12) {
                e8 = e12;
                zzbd zzbdVar3 = new zzbd(zzbb.zzb, zzba.zzb, e8.getMessage());
                zzenVar.zzb(zzbdVar3);
                throw zzbdVar3;
            } catch (zzbd e13) {
                e7 = e13;
                zzenVar.zzb(e7);
                throw e7;
            } catch (Exception e14) {
                e6 = e14;
                zzbd zzbdVar22 = new zzbd(zzbb.zzb, zzba.zzaa, e6.getMessage());
                zzenVar.zzb(zzbdVar22);
                throw zzbdVar22;
            }
        }
        zzsi zzsiVar = (zzsi) obj;
        zzenVar.zza();
        return zzsiVar;
    }

    public final Object zzm(zzsp zzspVar, String str, long j4, d dVar) {
        return E.H(this.zzi.zza().getCoroutineContext(), new zzdg(this, str, j4, zzspVar, null), dVar);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object zzn(zzsc zzscVar, long j4, d dVar) throws zzbd {
        zzdk zzdkVar;
        if (dVar instanceof zzdk) {
            zzdkVar = (zzdk) dVar;
            int i6 = zzdkVar.zzc;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                zzdkVar.zzc = i6 - Integer.MIN_VALUE;
            } else {
                zzdkVar = new zzdk(this, dVar);
            }
        }
        Object obj = zzdkVar.zza;
        B4.a aVar = B4.a.f492a;
        int i7 = zzdkVar.zzc;
        try {
            if (i7 == 0) {
                AbstractC2467b.l(obj);
                zzdl zzdlVar = new zzdl(this, zzscVar, j4, null);
                zzdkVar.zzc = 1;
                if (E.I(j4, zzdlVar, zzdkVar) == aVar) {
                    return aVar;
                }
            } else {
                if (i7 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            return C3137A.f25453a;
        } catch (H0 e6) {
            throw new zzbd(zzbb.zzb, zzba.zzb, e6.getMessage());
        } catch (zzbd e7) {
            throw e7;
        } catch (Exception e8) {
            throw new zzbd(zzbb.zzb, zzba.zzap, e8.getMessage());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:44:0x00a7  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object zzo(long j4, d dVar) throws Throwable {
        zzdr zzdrVar;
        Exception e6;
        zzen zzenVar;
        zzdt zzdtVar;
        zzbd e7;
        H0 e8;
        if (dVar instanceof zzdr) {
            zzdrVar = (zzdr) dVar;
            int i6 = zzdrVar.zzc;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                zzdrVar.zzc = i6 - Integer.MIN_VALUE;
            } else {
                zzdrVar = new zzdr(this, dVar);
            }
        }
        Object obj = zzdrVar.zza;
        B4.a aVar = B4.a.f492a;
        int i7 = zzdrVar.zzc;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            zzen zzenVarZzf = this.zzb.zzf(22);
            try {
                zzds zzdsVar = new zzds(this, zzenVarZzf, null);
                zzdrVar.zzd = this;
                zzdrVar.zze = zzenVarZzf;
                zzdrVar.zzc = 1;
                Object objI = E.I(j4, zzdsVar, zzdrVar);
                if (objI == aVar) {
                    return aVar;
                }
                obj = objI;
                zzenVar = zzenVarZzf;
                zzdtVar = this;
            } catch (H0 e9) {
                e8 = e9;
                zzenVar = zzenVarZzf;
                zzdtVar = this;
                zzbd zzbdVarZzs = zzdtVar.zzs(e8, new zzbd(zzbb.zzc, zzba.zzb, e8.getMessage()));
                zzenVar.zzb(zzbdVarZzs);
                throw zzbdVarZzs;
            } catch (zzbd e10) {
                e7 = e10;
                zzenVar = zzenVarZzf;
                zzdtVar = this;
                if (o.c(e7.zzb(), zzbb.zzc)) {
                }
                zzenVar.zzb(e7);
                throw e7;
            } catch (Exception e11) {
                e6 = e11;
                zzenVar = zzenVarZzf;
                zzdtVar = this;
                zzbd zzbdVarZzs2 = zzdtVar.zzs(e6, new zzbd(zzbb.zzc, zzba.zzaw, e6.getMessage()));
                zzenVar.zzb(zzbdVarZzs2);
                throw zzbdVarZzs2;
            }
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            zzenVar = zzdrVar.zze;
            zzdtVar = zzdrVar.zzd;
            try {
                AbstractC2467b.l(obj);
            } catch (H0 e12) {
                e8 = e12;
                zzbd zzbdVarZzs3 = zzdtVar.zzs(e8, new zzbd(zzbb.zzc, zzba.zzb, e8.getMessage()));
                zzenVar.zzb(zzbdVarZzs3);
                throw zzbdVarZzs3;
            } catch (zzbd e13) {
                e7 = e13;
                if (o.c(e7.zzb(), zzbb.zzc)) {
                    e7 = zzdtVar.zzs(e7, e7);
                }
                zzenVar.zzb(e7);
                throw e7;
            } catch (Exception e14) {
                e6 = e14;
                zzbd zzbdVarZzs22 = zzdtVar.zzs(e6, new zzbd(zzbb.zzc, zzba.zzaw, e6.getMessage()));
                zzenVar.zzb(zzbdVarZzs22);
                throw zzbdVarZzs22;
            }
        }
        return (zzsc) obj;
    }

    public final void zzq(String str, zzsr zzsrVar) {
        zzen zzenVarZzf = zzu(str).zzf(29);
        try {
            List<zzst> listZzk = zzsrVar.zzk();
            int iU = AbstractC3229F.u(AbstractC3253s.G(listZzk, 10));
            if (iU < 16) {
                iU = 16;
            }
            LinkedHashMap linkedHashMap = new LinkedHashMap(iU);
            for (zzst zzstVar : listZzk) {
                linkedHashMap.put(zzstVar.zzg(), zzstVar.zzi());
            }
            zzt().zzb(linkedHashMap);
            this.zzc.zzg(zzsrVar);
            zzenVarZzf.zza();
        } catch (zzbd e6) {
            zzenVarZzf.zzb(e6);
        } catch (Exception e7) {
            zzenVarZzf.zzb(new zzbd(zzbb.zzb, zzba.zzas, e7.getMessage()));
        }
    }
}
