package okhttp3;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.o;
import kotlin.text.Charsets;
import okhttp3.MediaType;
import okhttp3.n0.c;
import okio.BufferedSink;
import okio.ByteString;

/* JADX INFO: renamed from: y.h0, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b&\u0018\u0000 \u000e2\u00020\u0001:\u0001\u000eB\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H\u0016J\n\u0010\u0005\u001a\u0004\u0018\u00010\u0006H&J\b\u0010\u0007\u001a\u00020\bH\u0016J\b\u0010\t\u001a\u00020\bH\u0016J\u0010\u0010\n\u001a\u00020\u000b2\u0006\u0010\f\u001a\u00020\rH&¨\u0006\u000f"}, d2 = {"Lokhttp3/RequestBody;", "", "()V", "contentLength", "", "contentType", "Lokhttp3/MediaType;", "isDuplex", "", "isOneShot", "writeTo", "", "sink", "Lokio/BufferedSink;", "Companion", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
public abstract class RequestBody {

    /* JADX INFO: renamed from: Companion, reason: from kotlin metadata */
    public static final Companion INSTANCE = new Companion(null);

    /* JADX INFO: renamed from: y.h0$a, reason: from kotlin metadata */
    @Metadata(d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001a\u0010\u0003\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0007J.\u0010\u0003\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u00062\u0006\u0010\t\u001a\u00020\n2\b\b\u0002\u0010\u000b\u001a\u00020\f2\b\b\u0002\u0010\r\u001a\u00020\fH\u0007J\u001a\u0010\u0003\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u00062\u0006\u0010\t\u001a\u00020\u000eH\u0007J\u001a\u0010\u0003\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u00062\u0006\u0010\t\u001a\u00020\u000fH\u0007J\u001d\u0010\u0010\u001a\u00020\u0004*\u00020\b2\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0007¢\u0006\u0002\b\u0003J1\u0010\u0011\u001a\u00020\u0004*\u00020\n2\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u00062\b\b\u0002\u0010\u000b\u001a\u00020\f2\b\b\u0002\u0010\r\u001a\u00020\fH\u0007¢\u0006\u0002\b\u0003J\u001d\u0010\u0011\u001a\u00020\u0004*\u00020\u000e2\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0007¢\u0006\u0002\b\u0003J\u001d\u0010\u0011\u001a\u00020\u0004*\u00020\u000f2\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0007¢\u0006\u0002\b\u0003¨\u0006\u0012"}, d2 = {"Lokhttp3/RequestBody$Companion;", "", "()V", "create", "Lokhttp3/RequestBody;", "contentType", "Lokhttp3/MediaType;", "file", "Ljava/io/File;", "content", "", "offset", "", "byteCount", "", "Lokio/ByteString;", "asRequestBody", "toRequestBody", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class Companion {

        /* JADX INFO: renamed from: y.h0$a$a, reason: collision with other inner class name */
        @Metadata(d1 = {"\u0000#\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016J\n\u0010\u0004\u001a\u0004\u0018\u00010\u0005H\u0016J\u0010\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH\u0016¨\u0006\n"}, d2 = {"okhttp3/RequestBody$Companion$toRequestBody$2", "Lokhttp3/RequestBody;", "contentLength", "", "contentType", "Lokhttp3/MediaType;", "writeTo", "", "sink", "Lokio/BufferedSink;", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
        public static final class C0183a extends RequestBody {
            public final /* synthetic */ MediaType a;

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ int f9635b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            public final /* synthetic */ byte[] f9636c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            public final /* synthetic */ int f9637d;

            public C0183a(MediaType mediaType, int i2, byte[] bArr, int i3) {
                this.a = mediaType;
                this.f9635b = i2;
                this.f9636c = bArr;
                this.f9637d = i3;
            }

            @Override // okhttp3.RequestBody
            public long contentLength() {
                return this.f9635b;
            }

            @Override // okhttp3.RequestBody
            /* JADX INFO: renamed from: contentType, reason: from getter */
            public MediaType getA() {
                return this.a;
            }

            @Override // okhttp3.RequestBody
            public void writeTo(BufferedSink bufferedSink) {
                o.f(bufferedSink, "sink");
                bufferedSink.write(this.f9636c, this.f9637d, this.f9635b);
            }
        }

        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
        }

        public static RequestBody c(Companion companion, MediaType mediaType, byte[] bArr, int i2, int i3, int i4) {
            if ((i4 & 4) != 0) {
                i2 = 0;
            }
            if ((i4 & 8) != 0) {
                i3 = bArr.length;
            }
            o.f(bArr, "content");
            return companion.b(bArr, mediaType, i2, i3);
        }

        public static /* synthetic */ RequestBody d(Companion companion, byte[] bArr, MediaType mediaType, int i2, int i3, int i4) {
            if ((i4 & 1) != 0) {
                mediaType = null;
            }
            if ((i4 & 2) != 0) {
                i2 = 0;
            }
            if ((i4 & 4) != 0) {
                i3 = bArr.length;
            }
            return companion.b(bArr, mediaType, i2, i3);
        }

        public final RequestBody a(String str, MediaType mediaType) {
            o.f(str, "<this>");
            Charset charset = Charsets.f9181b;
            if (mediaType != null) {
                MediaType.a aVar = MediaType.a;
                Charset charsetA = mediaType.a(null);
                if (charsetA == null) {
                    MediaType.a aVar2 = MediaType.a;
                    mediaType = MediaType.a.b(mediaType + "; charset=utf-8");
                } else {
                    charset = charsetA;
                }
            }
            byte[] bytes = str.getBytes(charset);
            o.e(bytes, "this as java.lang.String).getBytes(charset)");
            return b(bytes, mediaType, 0, bytes.length);
        }

        public final RequestBody b(byte[] bArr, MediaType mediaType, int i2, int i3) {
            o.f(bArr, "<this>");
            c.d(bArr.length, i2, i3);
            return new C0183a(mediaType, i3, bArr, i2);
        }
    }

    public static final RequestBody create(File file, MediaType mediaType) {
        Objects.requireNonNull(INSTANCE);
        o.f(file, "<this>");
        return new f0(mediaType, file);
    }

    public static final RequestBody create(String str, MediaType mediaType) {
        return INSTANCE.a(str, mediaType);
    }

    public static final RequestBody create(byte[] bArr, MediaType mediaType, int i2, int i3) {
        return INSTANCE.b(bArr, mediaType, i2, i3);
    }

    public abstract long contentLength();

    /* JADX INFO: renamed from: contentType */
    public abstract MediaType getA();

    public boolean isDuplex() {
        return false;
    }

    public boolean isOneShot() {
        return false;
    }

    public abstract void writeTo(BufferedSink bufferedSink);

    public static final RequestBody create(MediaType mediaType, File file) {
        Objects.requireNonNull(INSTANCE);
        o.f(file, "file");
        o.f(file, "<this>");
        return new f0(mediaType, file);
    }

    public static final RequestBody create(MediaType mediaType, String str) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(str, "content");
        return companion.a(str, mediaType);
    }

    public static final RequestBody create(MediaType mediaType, ByteString byteString) {
        Objects.requireNonNull(INSTANCE);
        o.f(byteString, "content");
        o.f(byteString, "<this>");
        return new g0(mediaType, byteString);
    }

    public static final RequestBody create(MediaType mediaType, byte[] bArr) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(bArr, "content");
        return Companion.c(companion, mediaType, bArr, 0, 0, 12);
    }

    public static final RequestBody create(MediaType mediaType, byte[] bArr, int i2) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(bArr, "content");
        return Companion.c(companion, mediaType, bArr, i2, 0, 8);
    }

    public static final RequestBody create(MediaType mediaType, byte[] bArr, int i2, int i3) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(bArr, "content");
        return companion.b(bArr, mediaType, i2, i3);
    }

    public static final RequestBody create(ByteString byteString, MediaType mediaType) {
        Objects.requireNonNull(INSTANCE);
        o.f(byteString, "<this>");
        return new g0(mediaType, byteString);
    }

    public static final RequestBody create(byte[] bArr) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(bArr, "<this>");
        return Companion.d(companion, bArr, null, 0, 0, 7);
    }

    public static final RequestBody create(byte[] bArr, MediaType mediaType) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(bArr, "<this>");
        return Companion.d(companion, bArr, mediaType, 0, 0, 6);
    }

    public static final RequestBody create(byte[] bArr, MediaType mediaType, int i2) {
        Companion companion = INSTANCE;
        Objects.requireNonNull(companion);
        o.f(bArr, "<this>");
        return Companion.d(companion, bArr, mediaType, i2, 0, 4);
    }
}
