package defpackage;

import j$.util.DesugarCollections;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/* JADX INFO: renamed from: ˊᵤᵢ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC1384 {
    static {
        new C1054("\"\\".getBytes(AbstractC4490.f17115)).f4545 = "\"\\";
        new C1054("\t ,=".getBytes(AbstractC4490.f17115)).f4545 = "\t ,=";
    }

    /* JADX WARN: Removed duplicated region for block: B:115:0x01f0  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x008b  */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final void m3960(InterfaceC2605 interfaceC2605, C1695 c1695, C0661 c0661) {
        C2808 c2808;
        C0939 c0939;
        int i;
        C0939 c09392;
        if (interfaceC2605 == InterfaceC2605.f10088) {
            return;
        }
        Pattern pattern = C0939.f4093;
        int size = c0661.size();
        int i2 = 0;
        ArrayList arrayList = null;
        for (int i3 = 0; i3 < size; i3++) {
            if ("Set-Cookie".equalsIgnoreCase(c0661.m2426(i3))) {
                if (arrayList == null) {
                    arrayList = new ArrayList(2);
                }
                arrayList.add(c0661.m2429(i3));
            }
        }
        List listUnmodifiableList = arrayList != null ? DesugarCollections.unmodifiableList(arrayList) : null;
        C2808 c28082 = C2808.f10794;
        List list = listUnmodifiableList == null ? c28082 : listUnmodifiableList;
        int size2 = list.size();
        int i4 = 0;
        ArrayList arrayList2 = null;
        while (i4 < size2) {
            String str = (String) list.get(i4);
            long jCurrentTimeMillis = System.currentTimeMillis();
            byte[] bArr = AbstractC1701.f6716;
            char c = ';';
            int iM4664 = AbstractC1701.m4664(str, ';', i2, str.length());
            char c2 = '=';
            int iM46642 = AbstractC1701.m4664(str, '=', i2, iM4664);
            if (iM46642 == iM4664) {
                c2808 = c28082;
                c0939 = null;
                i = 0;
            } else {
                String strM4655 = AbstractC1701.m4655(i2, iM46642, str);
                if (strM4655.length() != 0 && AbstractC1701.m4666(strM4655) == -1) {
                    String strM46552 = AbstractC1701.m4655(iM46642 + 1, iM4664, str);
                    if (AbstractC1701.m4666(strM46552) == -1) {
                        int i5 = iM4664 + 1;
                        int length = str.length();
                        long j = 253402300799999L;
                        long j2 = 253402300799999L;
                        String str2 = null;
                        String strSubstring = null;
                        boolean z = false;
                        long j3 = -1;
                        boolean z2 = false;
                        boolean z3 = true;
                        String str3 = null;
                        boolean z4 = false;
                        while (true) {
                            if (i5 < length) {
                                C2808 c28083 = c28082;
                                int iM46643 = AbstractC1701.m4664(str, c, i5, length);
                                int iM46644 = AbstractC1701.m4664(str, c2, i5, iM46643);
                                String strM46553 = AbstractC1701.m4655(i5, iM46644, str);
                                String strM46554 = iM46644 < iM46643 ? AbstractC1701.m4655(iM46644 + 1, iM46643, str) : "";
                                if (strM46553.equalsIgnoreCase("expires")) {
                                    try {
                                        j2 = ᵸˊʾᵜ.ᵨᵼⁱ(strM46554.length(), strM46554);
                                        z2 = true;
                                    } catch (NumberFormatException | IllegalArgumentException unused) {
                                    }
                                } else if (strM46553.equalsIgnoreCase("max-age")) {
                                    try {
                                        long j4 = Long.parseLong(strM46554);
                                        j3 = j4 <= 0 ? Long.MIN_VALUE : j4;
                                    } catch (NumberFormatException e) {
                                        if (!Pattern.compile("-?\\d+").matcher(strM46554).matches()) {
                                            throw e;
                                        }
                                        j3 = AbstractC5498.m11136(strM46554, "-", false) ? Long.MIN_VALUE : Long.MAX_VALUE;
                                    }
                                    z2 = true;
                                } else if (strM46553.equalsIgnoreCase("domain")) {
                                    if (AbstractC5498.m11137(strM46554, ".", false)) {
                                        throw new IllegalArgumentException("Failed requirement.");
                                    }
                                    String strM8354 = AbstractC3713.m8354(AbstractC3801.m8474(strM46554, "."));
                                    if (strM8354 == null) {
                                        throw new IllegalArgumentException();
                                    }
                                    str2 = strM8354;
                                    z3 = false;
                                } else if (strM46553.equalsIgnoreCase("path")) {
                                    strSubstring = strM46554;
                                } else if (strM46553.equalsIgnoreCase("secure")) {
                                    z4 = true;
                                } else if (strM46553.equalsIgnoreCase("httponly")) {
                                    z = true;
                                } else if (strM46553.equalsIgnoreCase("samesite")) {
                                    str3 = strM46554;
                                }
                                i5 = iM46643 + 1;
                                c28082 = c28083;
                                c = ';';
                                c2 = '=';
                            } else {
                                c2808 = c28082;
                                if (j3 == Long.MIN_VALUE) {
                                    j = Long.MIN_VALUE;
                                } else if (j3 != -1) {
                                    long j5 = jCurrentTimeMillis + (j3 <= 9223372036854775L ? j3 * 1000 : Long.MAX_VALUE);
                                    if (j5 >= jCurrentTimeMillis && j5 <= 253402300799999L) {
                                        j = j5;
                                    }
                                } else {
                                    j = j2;
                                }
                                String str4 = c1695.f6700;
                                if (str2 == null) {
                                    str2 = str4;
                                } else if (!ᵥˈᵛ.ˊᵫᵗ(str4, str2) && (!AbstractC5498.m11137(str4, str2, false) || str4.charAt((str4.length() - str2.length()) - 1) != '.' || AbstractC3713.f14140.f17246.matcher(str4).matches())) {
                                    i = 0;
                                    c09392 = null;
                                    c0939 = c09392;
                                }
                                if (str4.length() == str2.length() || C2362.f9255.m6044(str2) != null) {
                                    i = 0;
                                    if (strSubstring == null || !AbstractC5498.m11136(strSubstring, "/", false)) {
                                        String strM4635 = c1695.m4635();
                                        int iM8489 = AbstractC3801.m8489(strM4635, '/', 0, 6);
                                        strSubstring = iM8489 != 0 ? strM4635.substring(0, iM8489) : "/";
                                    }
                                    c09392 = new C0939(strM4655, strM46552, j, str2, strSubstring, z4, z, z2, z3, str3);
                                }
                                c0939 = c09392;
                            }
                        }
                    }
                }
            }
            if (c0939 != null) {
                if (arrayList2 == null) {
                    arrayList2 = new ArrayList();
                }
                arrayList2.add(c0939);
            }
            i4++;
            i2 = i;
            c28082 = c2808;
        }
        C2808 c28084 = c28082;
        List listUnmodifiableList2 = arrayList2 != null ? DesugarCollections.unmodifiableList(arrayList2) : null;
        List list2 = listUnmodifiableList2 == null ? c28084 : listUnmodifiableList2;
        if (list2.isEmpty()) {
            return;
        }
        interfaceC2605.m6323(c1695, list2);
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static final boolean m3961(C1120 c1120) {
        if (ᵥˈᵛ.ˊᵫᵗ(c1120.f4784.f16705, "HEAD")) {
            return false;
        }
        int i = c1120.f4790;
        if (((i < 100 || i >= 200) && i != 204 && i != 304) || AbstractC1190.m3671(c1120) != -1) {
            return true;
        }
        String strM2425 = c1120.f4792.m2425("Transfer-Encoding");
        if (strM2425 == null) {
            strM2425 = null;
        }
        return "chunked".equalsIgnoreCase(strM2425);
    }
}
