package e6;

import android.content.Context;
import b7.h;
import b7.j;
import c7.c;
import c7.d;
import com.bykv.vk.openvk.fm.fm.fm.lb.lb;
import com.google.android.gms.internal.ads.a21;
import com.google.android.gms.internal.ads.e41;
import com.google.android.gms.internal.ads.gj;
import com.google.android.gms.internal.ads.h51;
import com.google.android.gms.internal.ads.h71;
import com.google.android.gms.internal.ads.l31;
import com.google.android.gms.internal.ads.lh2;
import com.google.android.gms.internal.ads.o41;
import com.google.android.gms.internal.ads.sl0;
import com.google.android.gms.internal.ads.yh;
import com.google.android.gms.internal.ads.ys0;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.Executor;
import nb.g;
import w6.f;

/* JADX INFO: loaded from: classes.dex */
public final class a implements x5.b, x6.b {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f25489d = new gj();

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

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

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

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

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

    public a(yh yhVar, lh2 lh2Var, sl0 sl0Var, int i10, int i11, int i12, int i13) {
        this.f25486a = yhVar;
        this.f25488c = lh2Var;
        this.f25490e = ((h71) sl0Var).zzd(yhVar.zzd(), new ys0(this, 1));
        this.f25491f = new l31(this, i10);
        this.f25492g = new e41(this, i11);
        this.f25493h = new o41(this, i12);
        this.f25494i = new h51(this, i13);
        a21 a21Var = new a21(this);
        this.f25487b = a21Var;
        yhVar.p(a21Var);
    }

    public static HashSet e() {
        lb lbVar;
        lb lbVar2;
        HashSet hashSet = new HashSet();
        for (d6.a aVar : d6.a.f25000e.values()) {
            if (aVar != null && (lbVar2 = aVar.f25004d) != null) {
                hashSet.add(g.O(lbVar2.jnr(), lbVar2.qhl()).getAbsolutePath());
                hashSet.add(g.J(lbVar2.jnr(), lbVar2.qhl()).getAbsolutePath());
            }
        }
        for (f6.b bVar : f6.a.f25943a.values()) {
            if (bVar != null && (lbVar = bVar.f25945b) != null) {
                hashSet.add(g.O(lbVar.jnr(), lbVar.qhl()).getAbsolutePath());
                hashSet.add(g.J(lbVar.jnr(), lbVar.qhl()).getAbsolutePath());
            }
        }
        return hashSet;
    }

    public final ArrayList a() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new x5.a(new File(b()).listFiles(), o6.b.f31427d));
        arrayList.add(new x5.a(new File(d()).listFiles(), o6.b.f31426c));
        if (((String) this.f25492g) == null) {
            this.f25492g = ((String) this.f25490e) + File.separator + ((String) this.f25487b);
            File file = new File((String) this.f25492g);
            if (!file.exists()) {
                file.mkdirs();
            }
        }
        arrayList.add(new x5.a(new File((String) this.f25492g).listFiles(), o6.b.f31428e));
        arrayList.add(new x5.a(new File(c()).listFiles(), o6.b.f31429f));
        return arrayList;
    }

    public final String b() {
        if (((String) this.f25491f) == null) {
            this.f25491f = ((String) this.f25490e) + File.separator + ((String) this.f25486a);
            File file = new File((String) this.f25491f);
            if (!file.exists()) {
                file.mkdirs();
            }
        }
        return (String) this.f25491f;
    }

    public final String c() {
        if (((String) this.f25494i) == null) {
            this.f25494i = ((String) this.f25490e) + File.separator + ((String) this.f25489d);
            File file = new File((String) this.f25494i);
            if (!file.exists()) {
                file.mkdirs();
            }
        }
        return (String) this.f25494i;
    }

    public final String d() {
        if (((String) this.f25493h) == null) {
            this.f25493h = ((String) this.f25490e) + File.separator + ((String) this.f25488c);
            File file = new File((String) this.f25493h);
            if (!file.exists()) {
                file.mkdirs();
            }
        }
        return (String) this.f25493h;
    }

    public final synchronized void f() {
        try {
            HashSet hashSetE = null;
            for (x5.a aVar : a()) {
                File[] fileArr = aVar.f34745a;
                if (fileArr != null && fileArr.length >= aVar.f34746b) {
                    if (hashSetE == null) {
                        hashSetE = e();
                    }
                    int i10 = aVar.f34746b - 2;
                    if (i10 < 0) {
                        i10 = 0;
                    }
                    File[] fileArr2 = aVar.f34745a;
                    if (i10 >= 0 && fileArr2 != null) {
                        try {
                            if (fileArr2.length > i10) {
                                List listAsList = Arrays.asList(fileArr2);
                                Collections.sort(listAsList, new d0.g(9));
                                while (i10 < listAsList.size()) {
                                    if (!hashSetE.contains(((File) listAsList.get(i10)).getAbsolutePath())) {
                                        ((File) listAsList.get(i10)).delete();
                                    }
                                    i10++;
                                }
                            }
                        } catch (Throwable unused) {
                        }
                    }
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    @Override // jd.a
    public final Object get() {
        return new h((Context) ((jd.a) this.f25486a).get(), (f) ((jd.a) this.f25487b).get(), (d) ((jd.a) this.f25488c).get(), (j) ((jd.a) this.f25489d).get(), (Executor) ((jd.a) this.f25490e).get(), (d7.b) ((jd.a) this.f25491f).get(), (e7.a) ((jd.a) this.f25492g).get(), (e7.a) ((jd.a) this.f25493h).get(), (c) ((jd.a) this.f25494i).get());
    }
}
