package p7;

import P6.g;
import java.util.ArrayList;
import k7.C;
import k7.r;
import k7.y;
import o7.i;

/* JADX INFO: loaded from: classes.dex */
public final class d {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final o7.d f16160d;

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final int f16164h;
    public int i;

    public d(i iVar, ArrayList arrayList, int i, o7.d dVar, y yVar, int i5, int i8, int i9) {
        g.e(iVar, "call");
        g.e(yVar, "request");
        this.f16157a = iVar;
        this.f16158b = arrayList;
        this.f16159c = i;
        this.f16160d = dVar;
        this.f16161e = yVar;
        this.f16162f = i5;
        this.f16163g = i8;
        this.f16164h = i9;
    }

    public static d a(d dVar, int i, o7.d dVar2, y yVar, int i5) {
        if ((i5 & 1) != 0) {
            i = dVar.f16159c;
        }
        int i8 = i;
        if ((i5 & 2) != 0) {
            dVar2 = dVar.f16160d;
        }
        o7.d dVar3 = dVar2;
        if ((i5 & 4) != 0) {
            yVar = dVar.f16161e;
        }
        y yVar2 = yVar;
        g.e(yVar2, "request");
        return new d(dVar.f16157a, dVar.f16158b, i8, dVar3, yVar2, dVar.f16162f, dVar.f16163g, dVar.f16164h);
    }

    public final C b(y yVar) {
        g.e(yVar, "request");
        ArrayList arrayList = this.f16158b;
        int size = arrayList.size();
        int i = this.f16159c;
        if (i >= size) {
            throw new IllegalStateException("Check failed.");
        }
        this.i++;
        o7.d dVar = this.f16160d;
        if (dVar != null) {
            if (!dVar.f15948b.b(yVar.f14202a)) {
                throw new IllegalStateException(("network interceptor " + arrayList.get(i - 1) + " must retain the same host and port").toString());
            }
            if (this.i != 1) {
                throw new IllegalStateException(("network interceptor " + arrayList.get(i - 1) + " must call proceed() exactly once").toString());
            }
        }
        int i5 = i + 1;
        d dVarA = a(this, i5, null, yVar, 58);
        r rVar = (r) arrayList.get(i);
        C cA = rVar.a(dVarA);
        if (cA == null) {
            throw new NullPointerException("interceptor " + rVar + " returned null");
        }
        if (dVar != null && i5 < arrayList.size() && dVarA.i != 1) {
            throw new IllegalStateException(("network interceptor " + rVar + " must call proceed() exactly once").toString());
        }
        if (cA.f14016w != null) {
            return cA;
        }
        throw new IllegalStateException(("interceptor " + rVar + " returned a response with no body").toString());
    }
}
