package defpackage;

import androidx.media3.common.ParserException;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/* renamed from: ᵱˉᵧ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4395 {

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public Object f16456;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public int f16457;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public long f16458;

    public C4395(int i) {
        switch (i) {
            case 3:
                this.f16456 = new ArrayList();
                this.f16457 = 1;
                break;
            default:
                if (ˊᵿʗ.ᵢˇᵭ == null) {
                    Pattern pattern = C4240.f15884;
                    ˊᵿʗ.ᵢˇᵭ = new ˊᵿʗ(10);
                }
                ˊᵿʗ r2 = ˊᵿʗ.ᵢˇᵭ;
                if (C4240.f15883 == null) {
                    C4240.f15883 = new C4240(r2);
                }
                this.f16456 = C4240.f15883;
                break;
        }
    }

    public C4395(int i, URL url, long j) {
        this.f16457 = i;
        this.f16456 = url;
        this.f16458 = j;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static byte[] m9425(byte b, DataInputStream dataInputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] bArr = {b, dataInputStream.readByte()};
        byteArrayOutputStream.write(bArr);
        while (true) {
            if (bArr[0] == 13 && bArr[1] == 10) {
                return byteArrayOutputStream.toByteArray();
            }
            bArr[0] = bArr[1];
            byte b2 = dataInputStream.readByte();
            bArr[1] = b2;
            byteArrayOutputStream.write(b2);
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public synchronized void m9426() {
        this.f16457 = 0;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public synchronized void m9427(int i) {
        if ((i >= 200 && i < 300) || i == 401 || i == 404) {
            m9426();
            return;
        }
        this.f16457++;
        long jM9430 = m9430(i);
        ((C4240) this.f16456).f15885.getClass();
        this.f16458 = System.currentTimeMillis() + jM9430;
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x001d  */
    /* renamed from: ˏᵙ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public synchronized boolean m9428() {
        /*
            r4 = this;
            monitor-enter(r4)
            int r0 = r4.f16457     // Catch: java.lang.Throwable -> L1b
            if (r0 == 0) goto L1d
            java.lang.Object r0 = r4.f16456     // Catch: java.lang.Throwable -> L1b
            ᵮᵾˏ r0 = (defpackage.C4240) r0     // Catch: java.lang.Throwable -> L1b
            ˊᵿʗ r0 = r0.f15885     // Catch: java.lang.Throwable -> L1b
            r0.getClass()     // Catch: java.lang.Throwable -> L1b
            long r0 = java.lang.System.currentTimeMillis()     // Catch: java.lang.Throwable -> L1b
            long r2 = r4.f16458     // Catch: java.lang.Throwable -> L1b
            int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
            if (r0 <= 0) goto L19
            goto L1d
        L19:
            r0 = 0
            goto L1e
        L1b:
            r0 = move-exception
            goto L20
        L1d:
            r0 = 1
        L1e:
            monitor-exit(r4)
            return r0
        L20:
            monitor-exit(r4)     // Catch: java.lang.Throwable -> L1b
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C4395.m9428():boolean");
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public AbstractC2692 m9429(byte[] bArr) {
        long j;
        ArrayList arrayList = (ArrayList) this.f16456;
        ᵛᵾˏ.ᵯٴᵦ(bArr.length >= 2 && bArr[bArr.length - 2] == 13 && bArr[bArr.length - 1] == 10);
        String str = new String(bArr, 0, bArr.length - 2, C3138.f11927);
        arrayList.add(str);
        int i = this.f16457;
        if (i != 1) {
            if (i != 2) {
                ᵨᴵᵺ.ˌʾˀ();
                return null;
            }
            try {
                Matcher matcher = AbstractC0306.f1943.matcher(str);
                if (matcher.find()) {
                    String strGroup = matcher.group(1);
                    strGroup.getClass();
                    j = Long.parseLong(strGroup);
                } else {
                    j = -1;
                }
                if (j != -1) {
                    this.f16458 = j;
                }
                if (str.isEmpty()) {
                    if (this.f16458 <= 0) {
                        AbstractC2692 abstractC2692M6700 = AbstractC2692.m6700(arrayList);
                        arrayList.clear();
                        this.f16457 = 1;
                        this.f16458 = 0L;
                        return abstractC2692M6700;
                    }
                    this.f16457 = 3;
                }
            } catch (NumberFormatException e) {
                throw ParserException.m357(str, e);
            }
        } else if (AbstractC0306.f1944.matcher(str).matches() || AbstractC0306.f1945.matcher(str).matches()) {
            this.f16457 = 2;
        }
        return null;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public synchronized long m9430(int i) {
        if (!(i == 429 || (i >= 500 && i < 600))) {
            return 86400000L;
        }
        double dPow = Math.pow(2.0d, this.f16457);
        ((C4240) this.f16456).getClass();
        return (long) Math.min(dPow + ((long) (Math.random() * 1000.0d)), 1800000.0d);
    }
}
