package okhttp3;

import com.ifpdos.sdk.httpd.binder.aidl.RequestLine;
import io.netty.handler.codec.rtsp.RtspHeaders;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.collections.EmptyMap;
import kotlin.collections.j;
import kotlin.jvm.internal.o;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.n0.c;
import okhttp3.n0.http.HttpMethod;

/* JADX INFO: renamed from: y.e0, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000N\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010$\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u000b\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\u0018\u00002\u00020\u0001:\u0001*BA\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\b\u0010\b\u001a\u0004\u0018\u00010\t\u0012\u0016\u0010\n\u001a\u0012\u0012\b\u0012\u0006\u0012\u0002\b\u00030\f\u0012\u0004\u0012\u00020\u00010\u000b¢\u0006\u0002\u0010\rJ\u000f\u0010\b\u001a\u0004\u0018\u00010\tH\u0007¢\u0006\u0002\b\u001bJ\r\u0010\u000f\u001a\u00020\u0010H\u0007¢\u0006\u0002\b\u001cJ\u0010\u0010\u001d\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u001e\u001a\u00020\u0005J\r\u0010\u0006\u001a\u00020\u0007H\u0007¢\u0006\u0002\b\u001fJ\u0014\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\u00050 2\u0006\u0010\u001e\u001a\u00020\u0005J\r\u0010\u0004\u001a\u00020\u0005H\u0007¢\u0006\u0002\b!J\u0006\u0010\"\u001a\u00020#J\b\u0010$\u001a\u0004\u0018\u00010\u0001J#\u0010$\u001a\u0004\u0018\u0001H%\"\u0004\b\u0000\u0010%2\u000e\u0010&\u001a\n\u0012\u0006\b\u0001\u0012\u0002H%0\f¢\u0006\u0002\u0010'J\b\u0010(\u001a\u00020\u0005H\u0016J\r\u0010\u0002\u001a\u00020\u0003H\u0007¢\u0006\u0002\b)R\u0015\u0010\b\u001a\u0004\u0018\u00010\t8\u0007¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\u000eR\u0011\u0010\u000f\u001a\u00020\u00108G¢\u0006\u0006\u001a\u0004\b\u000f\u0010\u0011R\u0013\u0010\u0006\u001a\u00020\u00078\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0012R\u0011\u0010\u0013\u001a\u00020\u00148F¢\u0006\u0006\u001a\u0004\b\u0013\u0010\u0015R\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0013\u0010\u0004\u001a\u00020\u00058\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0004\u0010\u0017R$\u0010\n\u001a\u0012\u0012\b\u0012\u0006\u0012\u0002\b\u00030\f\u0012\u0004\u0012\u00020\u00010\u000bX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0018\u0010\u0019R\u0013\u0010\u0002\u001a\u00020\u00038\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0002\u0010\u001a¨\u0006+"}, d2 = {"Lokhttp3/Request;", "", RtspHeaders.Values.URL, "Lokhttp3/HttpUrl;", "method", "", "headers", "Lokhttp3/Headers;", "body", "Lokhttp3/RequestBody;", "tags", "", "Ljava/lang/Class;", "(Lokhttp3/HttpUrl;Ljava/lang/String;Lokhttp3/Headers;Lokhttp3/RequestBody;Ljava/util/Map;)V", "()Lokhttp3/RequestBody;", "cacheControl", "Lokhttp3/CacheControl;", "()Lokhttp3/CacheControl;", "()Lokhttp3/Headers;", "isHttps", "", "()Z", "lazyCacheControl", "()Ljava/lang/String;", "getTags$okhttp", "()Ljava/util/Map;", "()Lokhttp3/HttpUrl;", "-deprecated_body", "-deprecated_cacheControl", "header", "name", "-deprecated_headers", "", "-deprecated_method", "newBuilder", "Lokhttp3/Request$Builder;", "tag", "T", "type", "(Ljava/lang/Class;)Ljava/lang/Object;", "toString", "-deprecated_url", "Builder", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class Request {
    public final HttpUrl a;

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final RequestBody f9623d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Map<Class<?>, Object> f9624e;

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

    /* JADX INFO: renamed from: y.e0$a */
    @Metadata(d1 = {"\u0000V\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0000\b\u0016\u0018\u00002\u00020\u0001B\u0007\b\u0016¢\u0006\u0002\u0010\u0002B\u000f\b\u0010\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005J\u0018\u0010%\u001a\u00020\u00002\u0006\u0010&\u001a\u00020\u00132\u0006\u0010'\u001a\u00020\u0013H\u0016J\b\u0010(\u001a\u00020\u0004H\u0016J\u0010\u0010)\u001a\u00020\u00002\u0006\u0010)\u001a\u00020*H\u0016J\u0014\u0010+\u001a\u00020\u00002\n\b\u0002\u0010\u0006\u001a\u0004\u0018\u00010\u0007H\u0017J\b\u0010,\u001a\u00020\u0000H\u0016J\b\u0010-\u001a\u00020\u0000H\u0016J\u0018\u0010.\u001a\u00020\u00002\u0006\u0010&\u001a\u00020\u00132\u0006\u0010'\u001a\u00020\u0013H\u0016J\u0010\u0010\f\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020/H\u0016J\u001a\u0010\u0012\u001a\u00020\u00002\u0006\u0010\u0012\u001a\u00020\u00132\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007H\u0016J\u0010\u00100\u001a\u00020\u00002\u0006\u0010\u0006\u001a\u00020\u0007H\u0016J\u0010\u00101\u001a\u00020\u00002\u0006\u0010\u0006\u001a\u00020\u0007H\u0016J\u0010\u00102\u001a\u00020\u00002\u0006\u0010\u0006\u001a\u00020\u0007H\u0016J\u0010\u00103\u001a\u00020\u00002\u0006\u0010&\u001a\u00020\u0013H\u0016J-\u00104\u001a\u00020\u0000\"\u0004\b\u0000\u001052\u000e\u00106\u001a\n\u0012\u0006\b\u0000\u0012\u0002H50\u001a2\b\u00104\u001a\u0004\u0018\u0001H5H\u0016¢\u0006\u0002\u00107J\u0012\u00104\u001a\u00020\u00002\b\u00104\u001a\u0004\u0018\u00010\u0001H\u0016J\u0010\u0010\u001f\u001a\u00020\u00002\u0006\u0010\u001f\u001a\u000208H\u0016J\u0010\u0010\u001f\u001a\u00020\u00002\u0006\u0010\u001f\u001a\u00020\u0013H\u0016J\u0010\u0010\u001f\u001a\u00020\u00002\u0006\u0010\u001f\u001a\u00020 H\u0016R\u001c\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\b\u0010\t\"\u0004\b\n\u0010\u000bR\u001a\u0010\f\u001a\u00020\rX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000e\u0010\u000f\"\u0004\b\u0010\u0010\u0011R\u001a\u0010\u0012\u001a\u00020\u0013X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0014\u0010\u0015\"\u0004\b\u0016\u0010\u0017R*\u0010\u0018\u001a\u0012\u0012\b\u0012\u0006\u0012\u0002\b\u00030\u001a\u0012\u0004\u0012\u00020\u00010\u0019X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001b\u0010\u001c\"\u0004\b\u001d\u0010\u001eR\u001c\u0010\u001f\u001a\u0004\u0018\u00010 X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b!\u0010\"\"\u0004\b#\u0010$¨\u00069"}, d2 = {"Lokhttp3/Request$Builder;", "", "()V", "request", "Lokhttp3/Request;", "(Lokhttp3/Request;)V", "body", "Lokhttp3/RequestBody;", "getBody$okhttp", "()Lokhttp3/RequestBody;", "setBody$okhttp", "(Lokhttp3/RequestBody;)V", "headers", "Lokhttp3/Headers$Builder;", "getHeaders$okhttp", "()Lokhttp3/Headers$Builder;", "setHeaders$okhttp", "(Lokhttp3/Headers$Builder;)V", "method", "", "getMethod$okhttp", "()Ljava/lang/String;", "setMethod$okhttp", "(Ljava/lang/String;)V", "tags", "", "Ljava/lang/Class;", "getTags$okhttp", "()Ljava/util/Map;", "setTags$okhttp", "(Ljava/util/Map;)V", RtspHeaders.Values.URL, "Lokhttp3/HttpUrl;", "getUrl$okhttp", "()Lokhttp3/HttpUrl;", "setUrl$okhttp", "(Lokhttp3/HttpUrl;)V", "addHeader", "name", "value", "build", "cacheControl", "Lokhttp3/CacheControl;", "delete", "get", "head", "header", "Lokhttp3/Headers;", "patch", "post", "put", "removeHeader", "tag", "T", "type", "(Ljava/lang/Class;Ljava/lang/Object;)Lokhttp3/Request$Builder;", "Ljava/net/URL;", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static class a {
        public HttpUrl a;

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

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public Headers.a f9627c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public RequestBody f9628d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public Map<Class<?>, Object> f9629e;

        public a() {
            this.f9629e = new LinkedHashMap();
            this.f9626b = RequestLine.METHOD_GET;
            this.f9627c = new Headers.a();
        }

        public a(Request request) {
            LinkedHashMap linkedHashMap;
            o.f(request, "request");
            this.f9629e = new LinkedHashMap();
            this.a = request.a;
            this.f9626b = request.f9621b;
            this.f9628d = request.f9623d;
            if (request.f9624e.isEmpty()) {
                linkedHashMap = new LinkedHashMap();
            } else {
                Map<Class<?>, Object> map = request.f9624e;
                o.f(map, "<this>");
                linkedHashMap = new LinkedHashMap(map);
            }
            this.f9629e = linkedHashMap;
            this.f9627c = request.f9622c.d();
        }

        public Request a() {
            Map mapUnmodifiableMap;
            HttpUrl httpUrl = this.a;
            if (httpUrl == null) {
                throw new IllegalStateException("url == null".toString());
            }
            String str = this.f9626b;
            Headers headersB = this.f9627c.b();
            RequestBody requestBody = this.f9628d;
            Map<Class<?>, Object> map = this.f9629e;
            byte[] bArr = c.a;
            o.f(map, "<this>");
            if (map.isEmpty()) {
                j.o();
                mapUnmodifiableMap = EmptyMap.f9308f;
            } else {
                mapUnmodifiableMap = Collections.unmodifiableMap(new LinkedHashMap(map));
                o.e(mapUnmodifiableMap, "{\n    Collections.unmodi…(LinkedHashMap(this))\n  }");
            }
            return new Request(httpUrl, str, headersB, requestBody, mapUnmodifiableMap);
        }

        public a b(String str, String str2) {
            o.f(str, "name");
            o.f(str2, "value");
            Headers.a aVar = this.f9627c;
            Objects.requireNonNull(aVar);
            o.f(str, "name");
            o.f(str2, "value");
            Headers.b bVar = Headers.f10085f;
            bVar.a(str);
            bVar.b(str2, str);
            aVar.c(str);
            aVar.a(str, str2);
            return this;
        }

        public a c(String str, RequestBody requestBody) {
            o.f(str, "method");
            boolean z2 = true;
            if (!(str.length() > 0)) {
                throw new IllegalArgumentException("method.isEmpty() == true".toString());
            }
            if (requestBody == null) {
                o.f(str, "method");
                if (!o.a(str, RequestLine.METHOD_POST) && !o.a(str, "PUT") && !o.a(str, "PATCH") && !o.a(str, "PROPPATCH") && !o.a(str, "REPORT")) {
                    z2 = false;
                }
                if (!(!z2)) {
                    throw new IllegalArgumentException(g.a.a.a.a.u("method ", str, " must have a request body.").toString());
                }
            } else if (!HttpMethod.a(str)) {
                throw new IllegalArgumentException(g.a.a.a.a.u("method ", str, " must not have a request body.").toString());
            }
            o.f(str, "<set-?>");
            this.f9626b = str;
            this.f9628d = requestBody;
            return this;
        }

        public a d(RequestBody requestBody) {
            o.f(requestBody, "body");
            c(RequestLine.METHOD_POST, requestBody);
            return this;
        }

        public a e(String str) {
            o.f(str, "name");
            this.f9627c.c(str);
            return this;
        }

        public a f(String str) {
            String strSubstring;
            String str2;
            o.f(str, RtspHeaders.Values.URL);
            if (!kotlin.text.j.I(str, "ws:", true)) {
                if (kotlin.text.j.I(str, "wss:", true)) {
                    strSubstring = str.substring(4);
                    o.e(strSubstring, "this as java.lang.String).substring(startIndex)");
                    str2 = "https:";
                }
                o.f(str, "<this>");
                HttpUrl.a aVar = new HttpUrl.a();
                aVar.d(null, str);
                g(aVar.a());
                return this;
            }
            strSubstring = str.substring(3);
            o.e(strSubstring, "this as java.lang.String).substring(startIndex)");
            str2 = "http:";
            str = o.l(str2, strSubstring);
            o.f(str, "<this>");
            HttpUrl.a aVar2 = new HttpUrl.a();
            aVar2.d(null, str);
            g(aVar2.a());
            return this;
        }

        public a g(HttpUrl httpUrl) {
            o.f(httpUrl, RtspHeaders.Values.URL);
            this.a = httpUrl;
            return this;
        }
    }

    public Request(HttpUrl httpUrl, String str, Headers headers, RequestBody requestBody, Map<Class<?>, ? extends Object> map) {
        o.f(httpUrl, RtspHeaders.Values.URL);
        o.f(str, "method");
        o.f(headers, "headers");
        o.f(map, "tags");
        this.a = httpUrl;
        this.f9621b = str;
        this.f9622c = headers;
        this.f9623d = requestBody;
        this.f9624e = map;
    }

    public final CacheControl a() {
        CacheControl cacheControl = this.f9625f;
        if (cacheControl != null) {
            return cacheControl;
        }
        CacheControl cacheControlB = CacheControl.a.b(this.f9622c);
        this.f9625f = cacheControlB;
        return cacheControlB;
    }

    public final String b(String str) {
        o.f(str, "name");
        return this.f9622c.a(str);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public String toString() {
        StringBuilder sbF = g.a.a.a.a.F("Request{method=");
        sbF.append(this.f9621b);
        sbF.append(", url=");
        sbF.append(this.a);
        if (this.f9622c.size() != 0) {
            sbF.append(", headers=[");
            int i2 = 0;
            for (Pair<? extends String, ? extends String> pair : this.f9622c) {
                int i3 = i2 + 1;
                if (i2 < 0) {
                    j.e0();
                    throw null;
                }
                Pair<? extends String, ? extends String> pair2 = pair;
                String str = (String) pair2.f5909f;
                String str2 = (String) pair2.f5910m;
                if (i2 > 0) {
                    sbF.append(", ");
                }
                g.a.a.a.a.r0(sbF, str, AbstractJsonLexerKt.COLON, str2);
                i2 = i3;
            }
            sbF.append(AbstractJsonLexerKt.END_LIST);
        }
        if (!this.f9624e.isEmpty()) {
            sbF.append(", tags=");
            sbF.append(this.f9624e);
        }
        sbF.append(AbstractJsonLexerKt.END_OBJ);
        String string = sbF.toString();
        o.e(string, "StringBuilder().apply(builderAction).toString()");
        return string;
    }
}
