package 㿎;

import androidx.recyclerview.widget.RecyclerView;
import com.appsflyer.share.Constants;
import com.facebook.appevents.codeless.CodelessMatcher;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.internal.publicsuffix.PublicSuffixDatabase;
import 㿎.ሽ.C2540;
import 㿎.ሽ.㴹.C2584;

/* renamed from: 㿎.㑃  reason: contains not printable characters */
/* compiled from: Cookie */
public final class C2646 {

    /* renamed from: ᕣ  reason: contains not printable characters */
    public static final Pattern f8993 = Pattern.compile("(?i)(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec).*");

    /* renamed from: 㑃  reason: contains not printable characters */
    public static final Pattern f8994 = Pattern.compile("(\\d{1,2})[^\\d]*");

    /* renamed from: 㳳  reason: contains not printable characters */
    public static final Pattern f8995 = Pattern.compile("(\\d{2,4})[^\\d]*");

    /* renamed from: 䁗  reason: contains not printable characters */
    public static final Pattern f8996 = Pattern.compile("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})[^\\d]*");

    /* renamed from: ʬ  reason: contains not printable characters */
    public final long f8997;

    /* renamed from: ඓ  reason: contains not printable characters */
    public final String f8998;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public final boolean f8999;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final String f9000;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final boolean f9001;

    /* renamed from: K  reason: contains not printable characters */
    public final String f9002;

    /* renamed from: 㴹  reason: contains not printable characters */
    public final boolean f9003;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final String f9004;

    /* renamed from: 㿎  reason: contains not printable characters */
    public final boolean f9005;

    public C2646(String str, String str2, long j, String str3, String str4, boolean z, boolean z2, boolean z3, boolean z4) {
        this.f9002 = str;
        this.f9000 = str2;
        this.f8997 = j;
        this.f9004 = str3;
        this.f8998 = str4;
        this.f9003 = z;
        this.f9001 = z2;
        this.f8999 = z3;
        this.f9005 = z4;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:100:0x01ad, code lost:
        if (r2 == false) goto L_0x01f6;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x00d6, code lost:
        if (r19 <= 0) goto L_0x00eb;
     */
    /* JADX WARNING: Removed duplicated region for block: B:117:0x01fa  */
    /* JADX WARNING: Removed duplicated region for block: B:132:0x0204 A[SYNTHETIC] */
    /* renamed from: K  reason: contains not printable characters */
    public static List<C2646> m6973(C2531 r33, C2667 r34) {
        List list;
        C2646 r0;
        C2531 r7;
        String str;
        int r1 = r34.m6993();
        ArrayList arrayList = null;
        for (int i = 0; i < r1; i++) {
            if ("Set-Cookie".equalsIgnoreCase(r34.m6995(i))) {
                if (arrayList == null) {
                    arrayList = new ArrayList(2);
                }
                arrayList.add(r34.m6994(i));
            }
        }
        if (arrayList != null) {
            list = Collections.unmodifiableList(arrayList);
        } else {
            list = Collections.emptyList();
        }
        int size = list.size();
        ArrayList arrayList2 = null;
        for (int i2 = 0; i2 < size; i2++) {
            String str2 = (String) list.get(i2);
            long currentTimeMillis = System.currentTimeMillis();
            int length = str2.length();
            char c = ';';
            int r02 = C2540.m6636(str2, 0, length, ';');
            int r13 = C2540.m6636(str2, 0, r02, '=');
            if (r13 != r02) {
                String r15 = C2540.m6657(str2, 0, r13);
                if (!r15.isEmpty() && C2540.m6631(r15) == -1) {
                    String r16 = C2540.m6657(str2, r13 + 1, r02);
                    if (C2540.m6631(r16) == -1) {
                        int i3 = r02 + 1;
                        long j = 253402300799999L;
                        boolean z = true;
                        long j2 = 253402300799999L;
                        long j3 = -1;
                        boolean z2 = false;
                        boolean z3 = false;
                        String str3 = null;
                        String str4 = null;
                        boolean z4 = true;
                        boolean z5 = false;
                        while (true) {
                            long j4 = RecyclerView.FOREVER_NS;
                            if (i3 < length) {
                                int r132 = C2540.m6636(str2, i3, length, c);
                                int r14 = C2540.m6636(str2, i3, r132, '=');
                                String r03 = C2540.m6657(str2, i3, r14);
                                String r142 = r14 < r132 ? C2540.m6657(str2, r14 + 1, r132) : "";
                                if (r03.equalsIgnoreCase("expires")) {
                                    try {
                                        j2 = m6972(r142, 0, r142.length());
                                    } catch (IllegalArgumentException unused) {
                                    }
                                } else if (r03.equalsIgnoreCase("max-age")) {
                                    try {
                                        j3 = Long.parseLong(r142);
                                    } catch (NumberFormatException e) {
                                        if (r142.matches("-?\\d+")) {
                                            if (!r142.startsWith("-")) {
                                                j3 = Long.MAX_VALUE;
                                            }
                                            j3 = Long.MIN_VALUE;
                                        } else {
                                            throw e;
                                        }
                                    }
                                } else {
                                    if (r03.equalsIgnoreCase("domain")) {
                                        if (!r142.endsWith(CodelessMatcher.CURRENT_CLASS_NAME)) {
                                            if (r142.startsWith(CodelessMatcher.CURRENT_CLASS_NAME)) {
                                                r142 = r142.substring(1);
                                            }
                                            String r04 = C2540.m6641(r142);
                                            if (r04 != null) {
                                                str3 = r04;
                                                z4 = false;
                                            } else {
                                                throw new IllegalArgumentException();
                                            }
                                        } else {
                                            throw new IllegalArgumentException();
                                        }
                                    } else if (r03.equalsIgnoreCase("path")) {
                                        str4 = r142;
                                    } else if (r03.equalsIgnoreCase("secure")) {
                                        z2 = true;
                                    } else if (r03.equalsIgnoreCase("httponly")) {
                                        z3 = true;
                                    }
                                    i3 = r132 + 1;
                                    c = ';';
                                }
                                z5 = true;
                                i3 = r132 + 1;
                                c = ';';
                            } else {
                                if (j3 == Long.MIN_VALUE) {
                                    r7 = r33;
                                    j = Long.MIN_VALUE;
                                } else if (j3 != -1) {
                                    if (j3 <= 9223372036854775L) {
                                        j4 = j3 * 1000;
                                    }
                                    long j5 = currentTimeMillis + j4;
                                    if (j5 < currentTimeMillis || j5 > 253402300799999L) {
                                        r7 = r33;
                                    } else {
                                        r7 = r33;
                                        j = j5;
                                    }
                                } else {
                                    r7 = r33;
                                    j = j2;
                                }
                                String str5 = r7.f8542;
                                String str6 = str3;
                                if (str6 == null) {
                                    str6 = str5;
                                } else if (!str5.equals(str6) && (!str5.endsWith(str6) || str5.charAt((str5.length() - str6.length()) - 1) != '.' || C2540.m6630(str5))) {
                                    z = false;
                                }
                                if (str5.length() == str6.length() || PublicSuffixDatabase.f3512.m2004(str6) != null) {
                                    String str7 = Constants.URL_PATH_DELIMITER;
                                    if (str4 == null || !str4.startsWith(str7)) {
                                        String r2 = r33.m6595();
                                        int lastIndexOf = r2.lastIndexOf(47);
                                        if (lastIndexOf != 0) {
                                            str7 = r2.substring(0, lastIndexOf);
                                        }
                                        str = str7;
                                    } else {
                                        str = str4;
                                    }
                                    r0 = new C2646(r15, r16, j, str6, str, z2, z3, z4, z5);
                                }
                            }
                        }
                        if (r0 != null) {
                            if (arrayList2 == null) {
                                arrayList2 = new ArrayList();
                            }
                            arrayList2.add(r0);
                        }
                    }
                }
            }
            r0 = null;
            if (r0 != null) {
            }
        }
        if (arrayList2 != null) {
            return Collections.unmodifiableList(arrayList2);
        }
        return Collections.emptyList();
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof C2646)) {
            return false;
        }
        C2646 r7 = (C2646) obj;
        if (r7.f9002.equals(this.f9002) && r7.f9000.equals(this.f9000) && r7.f9004.equals(this.f9004) && r7.f8998.equals(this.f8998) && r7.f8997 == this.f8997 && r7.f9003 == this.f9003 && r7.f9001 == this.f9001 && r7.f9005 == this.f9005 && r7.f8999 == this.f8999) {
            return true;
        }
        return false;
    }

    public int hashCode() {
        int hashCode = this.f9000.hashCode();
        int hashCode2 = this.f9004.hashCode();
        int hashCode3 = this.f8998.hashCode();
        long j = this.f8997;
        return ((((((((((hashCode3 + ((hashCode2 + ((hashCode + ((this.f9002.hashCode() + 527) * 31)) * 31)) * 31)) * 31) + ((int) (j ^ (j >>> 32)))) * 31) + (!this.f9003 ? 1 : 0)) * 31) + (!this.f9001 ? 1 : 0)) * 31) + (!this.f9005 ? 1 : 0)) * 31) + (!this.f8999 ? 1 : 0);
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.f9002);
        sb.append('=');
        sb.append(this.f9000);
        if (this.f9005) {
            if (this.f8997 == Long.MIN_VALUE) {
                sb.append("; max-age=0");
            } else {
                sb.append("; expires=");
                sb.append(C2584.f8703.get().format(new Date(this.f8997)));
            }
        }
        if (!this.f8999) {
            sb.append("; domain=");
            sb.append(this.f9004);
        }
        sb.append("; path=");
        sb.append(this.f8998);
        if (this.f9003) {
            sb.append("; secure");
        }
        if (this.f9001) {
            sb.append("; httponly");
        }
        return sb.toString();
    }

    /* renamed from: K  reason: contains not printable characters */
    public static long m6972(String str, int i, int i2) {
        int r13 = m6971(str, i, i2, false);
        Matcher matcher = f8996.matcher(str);
        int i3 = -1;
        int i4 = -1;
        int i5 = -1;
        int i6 = -1;
        int i7 = -1;
        int i8 = -1;
        while (r13 < i2) {
            int r11 = m6971(str, r13 + 1, i2, true);
            matcher.region(r13, r11);
            if (i4 == -1 && matcher.usePattern(f8996).matches()) {
                int parseInt = Integer.parseInt(matcher.group(1));
                int parseInt2 = Integer.parseInt(matcher.group(2));
                i8 = Integer.parseInt(matcher.group(3));
                i7 = parseInt2;
                i4 = parseInt;
            } else if (i5 == -1 && matcher.usePattern(f8994).matches()) {
                i5 = Integer.parseInt(matcher.group(1));
            } else if (i6 == -1 && matcher.usePattern(f8993).matches()) {
                i6 = f8993.pattern().indexOf(matcher.group(1).toLowerCase(Locale.US)) / 4;
            } else if (i3 == -1 && matcher.usePattern(f8995).matches()) {
                i3 = Integer.parseInt(matcher.group(1));
            }
            r13 = m6971(str, r11 + 1, i2, false);
        }
        if (i3 >= 70 && i3 <= 99) {
            i3 += 1900;
        }
        if (i3 >= 0 && i3 <= 69) {
            i3 += RecyclerView.MAX_SCROLL_DURATION;
        }
        if (i3 < 1601) {
            throw new IllegalArgumentException();
        } else if (i6 == -1) {
            throw new IllegalArgumentException();
        } else if (i5 < 1 || i5 > 31) {
            throw new IllegalArgumentException();
        } else if (i4 < 0 || i4 > 23) {
            throw new IllegalArgumentException();
        } else if (i7 < 0 || i7 > 59) {
            throw new IllegalArgumentException();
        } else if (i8 < 0 || i8 > 59) {
            throw new IllegalArgumentException();
        } else {
            GregorianCalendar gregorianCalendar = new GregorianCalendar(C2540.f8561);
            gregorianCalendar.setLenient(false);
            gregorianCalendar.set(1, i3);
            gregorianCalendar.set(2, i6 - 1);
            gregorianCalendar.set(5, i5);
            gregorianCalendar.set(11, i4);
            gregorianCalendar.set(12, i7);
            gregorianCalendar.set(13, i8);
            gregorianCalendar.set(14, 0);
            return gregorianCalendar.getTimeInMillis();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static int m6971(String str, int i, int i2, boolean z) {
        while (i < i2) {
            char charAt = str.charAt(i);
            if (((charAt < ' ' && charAt != '\t') || charAt >= 127 || (charAt >= '0' && charAt <= '9') || ((charAt >= 'a' && charAt <= 'z') || ((charAt >= 'A' && charAt <= 'Z') || charAt == ':'))) == (!z)) {
                return i;
            }
            i++;
        }
        return i2;
    }
}
