package vq;

import kotlin.jvm.internal.t;
import uq.a0;
import uq.b0;
import uq.d0;
import uq.e0;
import uq.u;

/* loaded from: classes3.dex */
public abstract class l {
    private static final void a(String str, d0 d0Var) {
        if (d0Var != null) {
            if (!(d0Var.v() == null)) {
                throw new IllegalArgumentException((str + ".networkResponse != null").toString());
            }
            if (!(d0Var.d() == null)) {
                throw new IllegalArgumentException((str + ".cacheResponse != null").toString());
            }
            if (d0Var.y() == null) {
                return;
            }
            throw new IllegalArgumentException((str + ".priorResponse != null").toString());
        }
    }

    public static final d0.a b(d0.a aVar, String name, String value) {
        t.g(aVar, "<this>");
        t.g(name, "name");
        t.g(value, "value");
        aVar.g().a(name, value);
        return aVar;
    }

    public static final d0.a c(d0.a aVar, e0 body) {
        t.g(aVar, "<this>");
        t.g(body, "body");
        aVar.s(body);
        return aVar;
    }

    public static final d0.a d(d0.a aVar, d0 d0Var) {
        t.g(aVar, "<this>");
        a("cacheResponse", d0Var);
        aVar.t(d0Var);
        return aVar;
    }

    public static final void e(d0 d0Var) {
        t.g(d0Var, "<this>");
        d0Var.b().close();
    }

    public static final d0.a f(d0.a aVar, int i10) {
        t.g(aVar, "<this>");
        aVar.u(i10);
        return aVar;
    }

    public static final String g(d0 d0Var, String name, String str) {
        t.g(d0Var, "<this>");
        t.g(name, "name");
        String e10 = d0Var.r().e(name);
        return e10 == null ? str : e10;
    }

    public static final d0.a h(d0.a aVar, String name, String value) {
        t.g(aVar, "<this>");
        t.g(name, "name");
        t.g(value, "value");
        aVar.g().h(name, value);
        return aVar;
    }

    public static final d0.a i(d0.a aVar, u headers) {
        t.g(aVar, "<this>");
        t.g(headers, "headers");
        aVar.v(headers.r());
        return aVar;
    }

    public static final d0.a j(d0.a aVar, String message) {
        t.g(aVar, "<this>");
        t.g(message, "message");
        aVar.w(message);
        return aVar;
    }

    public static final d0.a k(d0.a aVar, d0 d0Var) {
        t.g(aVar, "<this>");
        a("networkResponse", d0Var);
        aVar.x(d0Var);
        return aVar;
    }

    public static final d0.a l(d0 d0Var) {
        t.g(d0Var, "<this>");
        return new d0.a(d0Var);
    }

    public static final d0.a m(d0.a aVar, d0 d0Var) {
        t.g(aVar, "<this>");
        aVar.y(d0Var);
        return aVar;
    }

    public static final d0.a n(d0.a aVar, a0 protocol) {
        t.g(aVar, "<this>");
        t.g(protocol, "protocol");
        aVar.z(protocol);
        return aVar;
    }

    public static final d0.a o(d0.a aVar, b0 request) {
        t.g(aVar, "<this>");
        t.g(request, "request");
        aVar.A(request);
        return aVar;
    }

    public static final String p(d0 d0Var) {
        t.g(d0Var, "<this>");
        return "Response{protocol=" + d0Var.z() + ", code=" + d0Var.f() + ", message=" + d0Var.t() + ", url=" + d0Var.C().k() + '}';
    }

    public static final d0.a q(d0.a aVar, dn.a trailersFn) {
        t.g(aVar, "<this>");
        t.g(trailersFn, "trailersFn");
        aVar.B(trailersFn);
        return aVar;
    }

    public static final uq.d r(d0 d0Var) {
        t.g(d0Var, "<this>");
        uq.d h10 = d0Var.h();
        if (h10 != null) {
            return h10;
        }
        uq.d a10 = uq.d.f37397n.a(d0Var.r());
        d0Var.I(a10);
        return a10;
    }

    public static final boolean s(d0 d0Var) {
        t.g(d0Var, "<this>");
        int f10 = d0Var.f();
        if (f10 != 307 && f10 != 308) {
            switch (f10) {
                case 300:
                case 301:
                case 302:
                case 303:
                    break;
                default:
                    return false;
            }
        }
        return true;
    }

    public static final boolean t(d0 d0Var) {
        t.g(d0Var, "<this>");
        int f10 = d0Var.f();
        return 200 <= f10 && f10 < 300;
    }

    public static final d0 u(d0 d0Var) {
        t.g(d0Var, "<this>");
        return d0Var.w().b(new b(d0Var.b().f(), d0Var.b().e())).c();
    }
}
