package lh;

import android.util.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes4.dex */
public class i {

    /* renamed from: a, reason: collision with root package name */
    private final Class f28163a;

    /* renamed from: b, reason: collision with root package name */
    private final List f28164b;

    /* renamed from: c, reason: collision with root package name */
    private final xh.e f28165c;

    /* renamed from: d, reason: collision with root package name */
    private final s3.f f28166d;

    /* renamed from: e, reason: collision with root package name */
    private final String f28167e;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public interface a {
        v a(v vVar);
    }

    public i(Class cls, Class cls2, Class cls3, List list, xh.e eVar, s3.f fVar) {
        this.f28163a = cls;
        this.f28164b = list;
        this.f28165c = eVar;
        this.f28166d = fVar;
        this.f28167e = "Failed DecodePath{" + cls.getSimpleName() + "->" + cls2.getSimpleName() + "->" + cls3.getSimpleName() + "}";
    }

    private v b(com.bumptech.glide.load.data.e eVar, int i10, int i11, jh.h hVar) {
        List list = (List) ei.k.d(this.f28166d.b());
        try {
            return c(eVar, i10, i11, hVar, list);
        } finally {
            this.f28166d.a(list);
        }
    }

    private v c(com.bumptech.glide.load.data.e eVar, int i10, int i11, jh.h hVar, List list) {
        int size = this.f28164b.size();
        v vVar = null;
        for (int i12 = 0; i12 < size; i12++) {
            jh.j jVar = (jh.j) this.f28164b.get(i12);
            try {
                if (jVar.b(eVar.a(), hVar)) {
                    vVar = jVar.a(eVar.a(), i10, i11, hVar);
                }
            } catch (IOException | OutOfMemoryError | RuntimeException e10) {
                if (Log.isLoggable("DecodePath", 2)) {
                    Log.v("DecodePath", "Failed to decode data for " + jVar, e10);
                }
                list.add(e10);
            }
            if (vVar != null) {
                break;
            }
        }
        if (vVar != null) {
            return vVar;
        }
        throw new q(this.f28167e, new ArrayList(list));
    }

    public v a(com.bumptech.glide.load.data.e eVar, int i10, int i11, jh.h hVar, a aVar) {
        return this.f28165c.a(aVar.a(b(eVar, i10, i11, hVar)), hVar);
    }

    public String toString() {
        return "DecodePath{ dataClass=" + this.f28163a + ", decoders=" + this.f28164b + ", transcoder=" + this.f28165c + '}';
    }
}
