package okhttp3.internal;

import E1.d;
import E1.f;
import E1.g;
import androidx.core.location.LocationRequestCompat;
import androidx.media3.session.legacy.PlaybackStateCompat;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.l;
import kotlin.jvm.internal.y;
import kotlin.jvm.internal.z;
import kotlin.ranges.m;
import n1.AbstractC0645a;
import n1.s;
import o1.AbstractC0653A;
import o1.AbstractC0655C;
import o1.AbstractC0668d;
import o1.AbstractC0676l;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.http2.Header;
import okhttp3.internal.io.FileSystem;
import okio.C;
import okio.C0688f;
import okio.E;
import okio.h;
import okio.i;
import okio.t;
import w1.b;
import y1.a;

/* JADX INFO: loaded from: classes2.dex */
public final class Util {
    public static final byte[] EMPTY_BYTE_ARRAY;
    public static final Headers EMPTY_HEADERS = Headers.Companion.of(new String[0]);
    public static final RequestBody EMPTY_REQUEST;
    public static final ResponseBody EMPTY_RESPONSE;
    private static final t UNICODE_BOMS;
    public static final TimeZone UTC;
    private static final f VERIFY_AS_IP_ADDRESS;
    public static final boolean assertionsEnabled;
    public static final String okHttpName;
    public static final String userAgent = "okhttp/4.9.1";

    static {
        byte[] bArr = new byte[0];
        EMPTY_BYTE_ARRAY = bArr;
        EMPTY_RESPONSE = ResponseBody.Companion.create$default(ResponseBody.Companion, bArr, (MediaType) null, 1, (Object) null);
        EMPTY_REQUEST = RequestBody.Companion.create$default(RequestBody.Companion, bArr, (MediaType) null, 0, 0, 7, (Object) null);
        t.a aVar = t.f6052x;
        i.a aVar2 = i.f6032y;
        UNICODE_BOMS = aVar.d(aVar2.b("efbbbf"), aVar2.b("feff"), aVar2.b("fffe"), aVar2.b("0000ffff"), aVar2.b("ffff0000"));
        TimeZone timeZone = TimeZone.getTimeZone("GMT");
        l.b(timeZone);
        UTC = timeZone;
        VERIFY_AS_IP_ADDRESS = new f("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");
        assertionsEnabled = false;
        String name = OkHttpClient.class.getName();
        l.d(name, "OkHttpClient::class.java.name");
        okHttpName = g.d0(g.c0(name, "okhttp3."), "Client");
    }

    public static final <E> void addIfAbsent(List<E> addIfAbsent, E e2) {
        l.e(addIfAbsent, "$this$addIfAbsent");
        if (addIfAbsent.contains(e2)) {
            return;
        }
        addIfAbsent.add(e2);
    }

    public static final int and(byte b2, int i2) {
        return b2 & i2;
    }

    public static final EventListener.Factory asFactory(final EventListener asFactory) {
        l.e(asFactory, "$this$asFactory");
        return new EventListener.Factory() { // from class: okhttp3.internal.Util.asFactory.1
            @Override // okhttp3.EventListener.Factory
            public final EventListener create(Call it) {
                l.e(it, "it");
                return asFactory;
            }
        };
    }

    public static final void assertThreadDoesntHoldLock(Object assertThreadDoesntHoldLock) {
        l.e(assertThreadDoesntHoldLock, "$this$assertThreadDoesntHoldLock");
        if (assertionsEnabled && Thread.holdsLock(assertThreadDoesntHoldLock)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Thread ");
            Thread threadCurrentThread = Thread.currentThread();
            l.d(threadCurrentThread, "Thread.currentThread()");
            sb.append(threadCurrentThread.getName());
            sb.append(" MUST NOT hold lock on ");
            sb.append(assertThreadDoesntHoldLock);
            throw new AssertionError(sb.toString());
        }
    }

    public static final void assertThreadHoldsLock(Object assertThreadHoldsLock) {
        l.e(assertThreadHoldsLock, "$this$assertThreadHoldsLock");
        if (!assertionsEnabled || Thread.holdsLock(assertThreadHoldsLock)) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append("Thread ");
        Thread threadCurrentThread = Thread.currentThread();
        l.d(threadCurrentThread, "Thread.currentThread()");
        sb.append(threadCurrentThread.getName());
        sb.append(" MUST hold lock on ");
        sb.append(assertThreadHoldsLock);
        throw new AssertionError(sb.toString());
    }

    public static final boolean canParseAsIpAddress(String canParseAsIpAddress) {
        l.e(canParseAsIpAddress, "$this$canParseAsIpAddress");
        return VERIFY_AS_IP_ADDRESS.a(canParseAsIpAddress);
    }

    public static final boolean canReuseConnectionFor(HttpUrl canReuseConnectionFor, HttpUrl other) {
        l.e(canReuseConnectionFor, "$this$canReuseConnectionFor");
        l.e(other, "other");
        return l.a(canReuseConnectionFor.host(), other.host()) && canReuseConnectionFor.port() == other.port() && l.a(canReuseConnectionFor.scheme(), other.scheme());
    }

    public static final int checkDuration(String name, long j2, TimeUnit timeUnit) {
        l.e(name, "name");
        if (!(j2 >= 0)) {
            throw new IllegalStateException((name + " < 0").toString());
        }
        if (!(timeUnit != null)) {
            throw new IllegalStateException("unit == null");
        }
        long millis = timeUnit.toMillis(j2);
        if (!(millis <= ((long) Integer.MAX_VALUE))) {
            throw new IllegalArgumentException((name + " too large.").toString());
        }
        if (millis != 0 || j2 <= 0) {
            return (int) millis;
        }
        throw new IllegalArgumentException((name + " too small.").toString());
    }

    public static final void checkOffsetAndCount(long j2, long j3, long j4) {
        if ((j3 | j4) < 0 || j3 > j2 || j2 - j3 < j4) {
            throw new ArrayIndexOutOfBoundsException();
        }
    }

    public static final void closeQuietly(Closeable closeQuietly) {
        l.e(closeQuietly, "$this$closeQuietly");
        try {
            closeQuietly.close();
        } catch (RuntimeException e2) {
            throw e2;
        } catch (Exception unused) {
        }
    }

    public static final String[] concat(String[] concat, String value) {
        l.e(concat, "$this$concat");
        l.e(value, "value");
        Object[] objArrCopyOf = Arrays.copyOf(concat, concat.length + 1);
        l.d(objArrCopyOf, "java.util.Arrays.copyOf(this, newSize)");
        String[] strArr = (String[]) objArrCopyOf;
        strArr[AbstractC0668d.r(strArr)] = value;
        return strArr;
    }

    public static final int delimiterOffset(String delimiterOffset, String delimiters, int i2, int i3) {
        l.e(delimiterOffset, "$this$delimiterOffset");
        l.e(delimiters, "delimiters");
        while (i2 < i3) {
            if (g.C(delimiters, delimiterOffset.charAt(i2), false, 2, null)) {
                return i2;
            }
            i2++;
        }
        return i3;
    }

    public static /* synthetic */ int delimiterOffset$default(String str, String str2, int i2, int i3, int i4, Object obj) {
        if ((i4 & 2) != 0) {
            i2 = 0;
        }
        if ((i4 & 4) != 0) {
            i3 = str.length();
        }
        return delimiterOffset(str, str2, i2, i3);
    }

    public static final boolean discard(E discard, int i2, TimeUnit timeUnit) {
        l.e(discard, "$this$discard");
        l.e(timeUnit, "timeUnit");
        try {
            return skipAll(discard, i2, timeUnit);
        } catch (IOException unused) {
            return false;
        }
    }

    public static final <T> List<T> filterList(Iterable<? extends T> filterList, y1.l predicate) {
        l.e(filterList, "$this$filterList");
        l.e(predicate, "predicate");
        List<T> listF = AbstractC0676l.f();
        for (T t2 : filterList) {
            if (((Boolean) predicate.invoke(t2)).booleanValue()) {
                if (listF.isEmpty()) {
                    listF = new ArrayList<>();
                }
                z.a(listF).add(t2);
            }
        }
        return listF;
    }

    public static final String format(String format, Object... args) {
        l.e(format, "format");
        l.e(args, "args");
        y yVar = y.f5106a;
        Locale locale = Locale.US;
        Object[] objArrCopyOf = Arrays.copyOf(args, args.length);
        String str = String.format(locale, format, Arrays.copyOf(objArrCopyOf, objArrCopyOf.length));
        l.d(str, "java.lang.String.format(locale, format, *args)");
        return str;
    }

    public static final boolean hasIntersection(String[] hasIntersection, String[] strArr, Comparator<? super String> comparator) {
        l.e(hasIntersection, "$this$hasIntersection");
        l.e(comparator, "comparator");
        if (hasIntersection.length != 0 && strArr != null && strArr.length != 0) {
            for (String str : hasIntersection) {
                for (String str2 : strArr) {
                    if (comparator.compare(str, str2) == 0) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static final long headersContentLength(Response headersContentLength) {
        l.e(headersContentLength, "$this$headersContentLength");
        String str = headersContentLength.headers().get(com.ifpdos.sdk.httpd.binder.aidl.Headers.KEY_CONTENT_LENGTH);
        if (str != null) {
            return toLongOrDefault(str, -1L);
        }
        return -1L;
    }

    public static final void ignoreIoExceptions(a block) {
        l.e(block, "block");
        try {
            block.invoke();
        } catch (IOException unused) {
        }
    }

    @SafeVarargs
    public static final <T> List<T> immutableListOf(T... elements) {
        l.e(elements, "elements");
        Object[] objArr = (Object[]) elements.clone();
        List<T> listUnmodifiableList = Collections.unmodifiableList(AbstractC0676l.h(Arrays.copyOf(objArr, objArr.length)));
        l.d(listUnmodifiableList, "Collections.unmodifiable…istOf(*elements.clone()))");
        return listUnmodifiableList;
    }

    public static final int indexOf(String[] indexOf, String value, Comparator<String> comparator) {
        l.e(indexOf, "$this$indexOf");
        l.e(value, "value");
        l.e(comparator, "comparator");
        int length = indexOf.length;
        for (int i2 = 0; i2 < length; i2++) {
            if (comparator.compare(indexOf[i2], value) == 0) {
                return i2;
            }
        }
        return -1;
    }

    public static final int indexOfControlOrNonAscii(String indexOfControlOrNonAscii) {
        l.e(indexOfControlOrNonAscii, "$this$indexOfControlOrNonAscii");
        int length = indexOfControlOrNonAscii.length();
        for (int i2 = 0; i2 < length; i2++) {
            char cCharAt = indexOfControlOrNonAscii.charAt(i2);
            if (l.f(cCharAt, 31) <= 0 || l.f(cCharAt, 127) >= 0) {
                return i2;
            }
        }
        return -1;
    }

    public static final int indexOfFirstNonAsciiWhitespace(String indexOfFirstNonAsciiWhitespace, int i2, int i3) {
        l.e(indexOfFirstNonAsciiWhitespace, "$this$indexOfFirstNonAsciiWhitespace");
        while (i2 < i3) {
            char cCharAt = indexOfFirstNonAsciiWhitespace.charAt(i2);
            if (cCharAt != '\t' && cCharAt != '\n' && cCharAt != '\f' && cCharAt != '\r' && cCharAt != ' ') {
                return i2;
            }
            i2++;
        }
        return i3;
    }

    public static /* synthetic */ int indexOfFirstNonAsciiWhitespace$default(String str, int i2, int i3, int i4, Object obj) {
        if ((i4 & 1) != 0) {
            i2 = 0;
        }
        if ((i4 & 2) != 0) {
            i3 = str.length();
        }
        return indexOfFirstNonAsciiWhitespace(str, i2, i3);
    }

    public static final int indexOfLastNonAsciiWhitespace(String indexOfLastNonAsciiWhitespace, int i2, int i3) {
        l.e(indexOfLastNonAsciiWhitespace, "$this$indexOfLastNonAsciiWhitespace");
        int i4 = i3 - 1;
        if (i4 >= i2) {
            while (true) {
                char cCharAt = indexOfLastNonAsciiWhitespace.charAt(i4);
                if (cCharAt != '\t' && cCharAt != '\n' && cCharAt != '\f' && cCharAt != '\r' && cCharAt != ' ') {
                    return i4 + 1;
                }
                if (i4 == i2) {
                    break;
                }
                i4--;
            }
        }
        return i2;
    }

    public static /* synthetic */ int indexOfLastNonAsciiWhitespace$default(String str, int i2, int i3, int i4, Object obj) {
        if ((i4 & 1) != 0) {
            i2 = 0;
        }
        if ((i4 & 2) != 0) {
            i3 = str.length();
        }
        return indexOfLastNonAsciiWhitespace(str, i2, i3);
    }

    public static final int indexOfNonWhitespace(String indexOfNonWhitespace, int i2) {
        l.e(indexOfNonWhitespace, "$this$indexOfNonWhitespace");
        int length = indexOfNonWhitespace.length();
        while (i2 < length) {
            char cCharAt = indexOfNonWhitespace.charAt(i2);
            if (cCharAt != ' ' && cCharAt != '\t') {
                return i2;
            }
            i2++;
        }
        return indexOfNonWhitespace.length();
    }

    public static /* synthetic */ int indexOfNonWhitespace$default(String str, int i2, int i3, Object obj) {
        if ((i3 & 1) != 0) {
            i2 = 0;
        }
        return indexOfNonWhitespace(str, i2);
    }

    public static final String[] intersect(String[] intersect, String[] other, Comparator<? super String> comparator) {
        l.e(intersect, "$this$intersect");
        l.e(other, "other");
        l.e(comparator, "comparator");
        ArrayList arrayList = new ArrayList();
        for (String str : intersect) {
            int length = other.length;
            int i2 = 0;
            while (true) {
                if (i2 >= length) {
                    break;
                }
                if (comparator.compare(str, other[i2]) == 0) {
                    arrayList.add(str);
                    break;
                }
                i2++;
            }
        }
        Object[] array = arrayList.toArray(new String[0]);
        if (array != null) {
            return (String[]) array;
        }
        throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
    }

    public static final boolean isCivilized(FileSystem isCivilized, File file) throws IOException {
        l.e(isCivilized, "$this$isCivilized");
        l.e(file, "file");
        C cSink = isCivilized.sink(file);
        try {
            try {
                isCivilized.delete(file);
                b.a(cSink, null);
                return true;
            } catch (IOException unused) {
                s sVar = s.f5871a;
                b.a(cSink, null);
                isCivilized.delete(file);
                return false;
            }
        } finally {
        }
    }

    public static final boolean isHealthy(Socket isHealthy, h source) {
        l.e(isHealthy, "$this$isHealthy");
        l.e(source, "source");
        try {
            int soTimeout = isHealthy.getSoTimeout();
            try {
                isHealthy.setSoTimeout(1);
                boolean z2 = !source.k();
                isHealthy.setSoTimeout(soTimeout);
                return z2;
            } catch (Throwable th) {
                isHealthy.setSoTimeout(soTimeout);
                throw th;
            }
        } catch (SocketTimeoutException unused) {
            return true;
        } catch (IOException unused2) {
            return false;
        }
    }

    public static final void notify(Object notify) {
        l.e(notify, "$this$notify");
        notify.notify();
    }

    public static final void notifyAll(Object notifyAll) {
        l.e(notifyAll, "$this$notifyAll");
        notifyAll.notifyAll();
    }

    public static final int parseHexDigit(char c2) {
        if ('0' <= c2 && '9' >= c2) {
            return c2 - '0';
        }
        if ('a' <= c2 && 'f' >= c2) {
            return c2 - 'W';
        }
        if ('A' <= c2 && 'F' >= c2) {
            return c2 - '7';
        }
        return -1;
    }

    public static final String peerName(Socket peerName) {
        l.e(peerName, "$this$peerName");
        SocketAddress remoteSocketAddress = peerName.getRemoteSocketAddress();
        if (!(remoteSocketAddress instanceof InetSocketAddress)) {
            return remoteSocketAddress.toString();
        }
        String hostName = ((InetSocketAddress) remoteSocketAddress).getHostName();
        l.d(hostName, "address.hostName");
        return hostName;
    }

    public static final Charset readBomAsCharset(h readBomAsCharset, Charset charset) throws IOException {
        l.e(readBomAsCharset, "$this$readBomAsCharset");
        l.e(charset, "default");
        int iD0 = readBomAsCharset.d0(UNICODE_BOMS);
        if (iD0 == -1) {
            return charset;
        }
        if (iD0 == 0) {
            Charset UTF_8 = StandardCharsets.UTF_8;
            l.d(UTF_8, "UTF_8");
            return UTF_8;
        }
        if (iD0 == 1) {
            Charset UTF_16BE = StandardCharsets.UTF_16BE;
            l.d(UTF_16BE, "UTF_16BE");
            return UTF_16BE;
        }
        if (iD0 == 2) {
            Charset UTF_16LE = StandardCharsets.UTF_16LE;
            l.d(UTF_16LE, "UTF_16LE");
            return UTF_16LE;
        }
        if (iD0 == 3) {
            return d.f530a.a();
        }
        if (iD0 == 4) {
            return d.f530a.b();
        }
        throw new AssertionError();
    }

    public static final <T> T readFieldOrNull(Object instance, Class<T> fieldType, String fieldName) throws IllegalAccessException {
        T tCast;
        Object fieldOrNull;
        l.e(instance, "instance");
        l.e(fieldType, "fieldType");
        l.e(fieldName, "fieldName");
        Class<?> superclass = instance.getClass();
        while (true) {
            tCast = null;
            if (l.a(superclass, Object.class)) {
                if (l.a(fieldName, "delegate") || (fieldOrNull = readFieldOrNull(instance, Object.class, "delegate")) == null) {
                    return null;
                }
                return (T) readFieldOrNull(fieldOrNull, fieldType, fieldName);
            }
            try {
                Field field = superclass.getDeclaredField(fieldName);
                l.d(field, "field");
                field.setAccessible(true);
                Object obj = field.get(instance);
                if (!fieldType.isInstance(obj)) {
                    break;
                }
                tCast = fieldType.cast(obj);
                break;
            } catch (NoSuchFieldException unused) {
                superclass = superclass.getSuperclass();
                l.d(superclass, "c.superclass");
            }
        }
        return tCast;
    }

    public static final int readMedium(h readMedium) throws IOException {
        l.e(readMedium, "$this$readMedium");
        return and(readMedium.readByte(), 255) | (and(readMedium.readByte(), 255) << 16) | (and(readMedium.readByte(), 255) << 8);
    }

    public static final boolean skipAll(E skipAll, int i2, TimeUnit timeUnit) throws IOException {
        l.e(skipAll, "$this$skipAll");
        l.e(timeUnit, "timeUnit");
        long jNanoTime = System.nanoTime();
        long jDeadlineNanoTime = skipAll.timeout().hasDeadline() ? skipAll.timeout().deadlineNanoTime() - jNanoTime : Long.MAX_VALUE;
        skipAll.timeout().deadlineNanoTime(Math.min(jDeadlineNanoTime, timeUnit.toNanos(i2)) + jNanoTime);
        try {
            C0688f c0688f = new C0688f();
            while (skipAll.read(c0688f, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1) {
                c0688f.a();
            }
            if (jDeadlineNanoTime == LocationRequestCompat.PASSIVE_INTERVAL) {
                skipAll.timeout().clearDeadline();
            } else {
                skipAll.timeout().deadlineNanoTime(jNanoTime + jDeadlineNanoTime);
            }
            return true;
        } catch (InterruptedIOException unused) {
            if (jDeadlineNanoTime == LocationRequestCompat.PASSIVE_INTERVAL) {
                skipAll.timeout().clearDeadline();
            } else {
                skipAll.timeout().deadlineNanoTime(jNanoTime + jDeadlineNanoTime);
            }
            return false;
        } catch (Throwable th) {
            if (jDeadlineNanoTime == LocationRequestCompat.PASSIVE_INTERVAL) {
                skipAll.timeout().clearDeadline();
            } else {
                skipAll.timeout().deadlineNanoTime(jNanoTime + jDeadlineNanoTime);
            }
            throw th;
        }
    }

    public static final ThreadFactory threadFactory(final String name, final boolean z2) {
        l.e(name, "name");
        return new ThreadFactory() { // from class: okhttp3.internal.Util.threadFactory.1
            @Override // java.util.concurrent.ThreadFactory
            public final Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable, name);
                thread.setDaemon(z2);
                return thread;
            }
        };
    }

    public static final void threadName(String name, a block) {
        l.e(name, "name");
        l.e(block, "block");
        Thread currentThread = Thread.currentThread();
        l.d(currentThread, "currentThread");
        String name2 = currentThread.getName();
        currentThread.setName(name);
        try {
            block.invoke();
        } finally {
            k.b(1);
            currentThread.setName(name2);
            k.a(1);
        }
    }

    public static final List<Header> toHeaderList(Headers toHeaderList) {
        l.e(toHeaderList, "$this$toHeaderList");
        kotlin.ranges.i iVarI = m.i(0, toHeaderList.size());
        ArrayList arrayList = new ArrayList(AbstractC0676l.o(iVarI, 10));
        Iterator it = iVarI.iterator();
        while (it.hasNext()) {
            int iNextInt = ((AbstractC0653A) it).nextInt();
            arrayList.add(new Header(toHeaderList.name(iNextInt), toHeaderList.value(iNextInt)));
        }
        return arrayList;
    }

    public static final Headers toHeaders(List<Header> toHeaders) {
        l.e(toHeaders, "$this$toHeaders");
        Headers.Builder builder = new Headers.Builder();
        for (Header header : toHeaders) {
            builder.addLenient$okhttp(header.component1().w(), header.component2().w());
        }
        return builder.build();
    }

    public static final String toHexString(long j2) {
        String hexString = Long.toHexString(j2);
        l.d(hexString, "java.lang.Long.toHexString(this)");
        return hexString;
    }

    public static final String toHostHeader(HttpUrl toHostHeader, boolean z2) {
        String strHost;
        l.e(toHostHeader, "$this$toHostHeader");
        if (g.D(toHostHeader.host(), ":", false, 2, null)) {
            strHost = '[' + toHostHeader.host() + ']';
        } else {
            strHost = toHostHeader.host();
        }
        if (!z2 && toHostHeader.port() == HttpUrl.Companion.defaultPort(toHostHeader.scheme())) {
            return strHost;
        }
        return strHost + ':' + toHostHeader.port();
    }

    public static /* synthetic */ String toHostHeader$default(HttpUrl httpUrl, boolean z2, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            z2 = false;
        }
        return toHostHeader(httpUrl, z2);
    }

    public static final <T> List<T> toImmutableList(List<? extends T> toImmutableList) {
        l.e(toImmutableList, "$this$toImmutableList");
        List<T> listUnmodifiableList = Collections.unmodifiableList(AbstractC0676l.R(toImmutableList));
        l.d(listUnmodifiableList, "Collections.unmodifiableList(toMutableList())");
        return listUnmodifiableList;
    }

    public static final <K, V> Map<K, V> toImmutableMap(Map<K, ? extends V> toImmutableMap) {
        l.e(toImmutableMap, "$this$toImmutableMap");
        if (toImmutableMap.isEmpty()) {
            return AbstractC0655C.d();
        }
        Map<K, V> mapUnmodifiableMap = Collections.unmodifiableMap(new LinkedHashMap(toImmutableMap));
        l.d(mapUnmodifiableMap, "Collections.unmodifiableMap(LinkedHashMap(this))");
        return mapUnmodifiableMap;
    }

    public static final long toLongOrDefault(String toLongOrDefault, long j2) {
        l.e(toLongOrDefault, "$this$toLongOrDefault");
        try {
            return Long.parseLong(toLongOrDefault);
        } catch (NumberFormatException unused) {
            return j2;
        }
    }

    public static final int toNonNegativeInt(String str, int i2) {
        if (str != null) {
            try {
                long j2 = Long.parseLong(str);
                if (j2 > Integer.MAX_VALUE) {
                    return Integer.MAX_VALUE;
                }
                if (j2 < 0) {
                    return 0;
                }
                return (int) j2;
            } catch (NumberFormatException unused) {
            }
        }
        return i2;
    }

    public static final String trimSubstring(String trimSubstring, int i2, int i3) {
        l.e(trimSubstring, "$this$trimSubstring");
        int iIndexOfFirstNonAsciiWhitespace = indexOfFirstNonAsciiWhitespace(trimSubstring, i2, i3);
        String strSubstring = trimSubstring.substring(iIndexOfFirstNonAsciiWhitespace, indexOfLastNonAsciiWhitespace(trimSubstring, iIndexOfFirstNonAsciiWhitespace, i3));
        l.d(strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        return strSubstring;
    }

    public static /* synthetic */ String trimSubstring$default(String str, int i2, int i3, int i4, Object obj) {
        if ((i4 & 1) != 0) {
            i2 = 0;
        }
        if ((i4 & 2) != 0) {
            i3 = str.length();
        }
        return trimSubstring(str, i2, i3);
    }

    public static final void wait(Object wait) throws InterruptedException {
        l.e(wait, "$this$wait");
        wait.wait();
    }

    public static final Throwable withSuppressed(Exception withSuppressed, List<? extends Exception> suppressed) {
        l.e(withSuppressed, "$this$withSuppressed");
        l.e(suppressed, "suppressed");
        if (suppressed.size() > 1) {
            System.out.println(suppressed);
        }
        Iterator<? extends Exception> it = suppressed.iterator();
        while (it.hasNext()) {
            AbstractC0645a.a(withSuppressed, it.next());
        }
        return withSuppressed;
    }

    public static final void writeMedium(okio.g writeMedium, int i2) throws IOException {
        l.e(writeMedium, "$this$writeMedium");
        writeMedium.writeByte((i2 >>> 16) & 255);
        writeMedium.writeByte((i2 >>> 8) & 255);
        writeMedium.writeByte(i2 & 255);
    }

    public static final int and(short s2, int i2) {
        return s2 & i2;
    }

    public static final int delimiterOffset(String delimiterOffset, char c2, int i2, int i3) {
        l.e(delimiterOffset, "$this$delimiterOffset");
        while (i2 < i3) {
            if (delimiterOffset.charAt(i2) == c2) {
                return i2;
            }
            i2++;
        }
        return i3;
    }

    public static /* synthetic */ int delimiterOffset$default(String str, char c2, int i2, int i3, int i4, Object obj) {
        if ((i4 & 2) != 0) {
            i2 = 0;
        }
        if ((i4 & 4) != 0) {
            i3 = str.length();
        }
        return delimiterOffset(str, c2, i2, i3);
    }

    public static final String toHexString(int i2) {
        String hexString = Integer.toHexString(i2);
        l.d(hexString, "Integer.toHexString(this)");
        return hexString;
    }

    public static final long and(int i2, long j2) {
        return ((long) i2) & j2;
    }

    public static final void closeQuietly(Socket closeQuietly) {
        l.e(closeQuietly, "$this$closeQuietly");
        try {
            closeQuietly.close();
        } catch (AssertionError e2) {
            throw e2;
        } catch (RuntimeException e3) {
            if (!l.a(e3.getMessage(), "bio == null")) {
                throw e3;
            }
        } catch (Exception unused) {
        }
    }

    public static final void closeQuietly(ServerSocket closeQuietly) {
        l.e(closeQuietly, "$this$closeQuietly");
        try {
            closeQuietly.close();
        } catch (RuntimeException e2) {
            throw e2;
        } catch (Exception unused) {
        }
    }

    public static final int skipAll(C0688f skipAll, byte b2) throws EOFException {
        l.e(skipAll, "$this$skipAll");
        int i2 = 0;
        while (!skipAll.k() && skipAll.j(0L) == b2) {
            i2++;
            skipAll.readByte();
        }
        return i2;
    }
}
