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;

/* JADX INFO: renamed from: ᵸᵷᵢ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5019 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public long f19018;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public Object f19019;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public int f19020;

    public C5019(int i) {
        switch (i) {
            case 3:
                this.f19019 = new ArrayList();
                this.f19020 = 1;
                break;
            default:
                if (ᵨᵡᵱ.ᵜᵪʾ == null) {
                    Pattern pattern = C2447.f9505;
                    ᵨᵡᵱ.ᵜᵪʾ = new ᵨᵡᵱ(10);
                }
                ᵨᵡᵱ r2 = ᵨᵡᵱ.ᵜᵪʾ;
                if (C2447.f9506 == null) {
                    C2447.f9506 = new C2447(r2);
                }
                this.f19019 = C2447.f9506;
                break;
        }
    }

    public C5019(int i, URL url, long j) {
        this.f19020 = i;
        this.f19019 = url;
        this.f19018 = j;
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static byte[] m10352(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);
        }
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public synchronized long m10353(int i) {
        if (!(i == 429 || (i >= 500 && i < 600))) {
            return 86400000L;
        }
        double dPow = Math.pow(2.0d, this.f19020);
        ((C2447) this.f19019).getClass();
        return (long) Math.min(dPow + ((long) (Math.random() * 1000.0d)), 1800000.0d);
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x001d  */
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public synchronized boolean m10354() {
        boolean z;
        if (this.f19020 != 0) {
            ((C2447) this.f19019).f9507.getClass();
            z = System.currentTimeMillis() > this.f19018;
        }
        return z;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public synchronized void m10355() {
        this.f19020 = 0;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public AbstractC4509 m10356(byte[] bArr) {
        long j;
        ArrayList arrayList = (ArrayList) this.f19019;
        ᵻᵪ.ᵱᵽʡᵚ(bArr.length >= 2 && bArr[bArr.length - 2] == 13 && bArr[bArr.length - 1] == 10);
        String str = new String(bArr, 0, bArr.length - 2, C5094.f19191);
        arrayList.add(str);
        int i = this.f19020;
        if (i != 1) {
            if (i != 2) {
                ᵷᵝˎ.ᵱʡˏ();
                return null;
            }
            try {
                Matcher matcher = AbstractC0208.f1680.matcher(str);
                if (matcher.find()) {
                    String strGroup = matcher.group(1);
                    strGroup.getClass();
                    j = Long.parseLong(strGroup);
                } else {
                    j = -1;
                }
                if (j != -1) {
                    this.f19018 = j;
                }
                if (str.isEmpty()) {
                    if (this.f19018 <= 0) {
                        AbstractC4509 abstractC4509M9559 = AbstractC4509.m9559(arrayList);
                        arrayList.clear();
                        this.f19020 = 1;
                        this.f19018 = 0L;
                        return abstractC4509M9559;
                    }
                    this.f19020 = 3;
                }
            } catch (NumberFormatException e) {
                throw ParserException.m355(str, e);
            }
        } else if (AbstractC0208.f1682.matcher(str).matches() || AbstractC0208.f1678.matcher(str).matches()) {
            this.f19020 = 2;
        }
        return null;
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public synchronized void m10357(int i) {
        if ((i >= 200 && i < 300) || i == 401 || i == 404) {
            m10355();
            return;
        }
        this.f19020++;
        long jM10353 = m10353(i);
        ((C2447) this.f19019).f9507.getClass();
        this.f19018 = System.currentTimeMillis() + jM10353;
    }
}
