package okhttp3;

import S4.p;
import com.google.android.recaptcha.internal.a;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.jvm.internal.o;
import okhttp3.internal.Util;
import okhttp3.internal.http.DatesKt;
import q.AbstractC2761L;

/* JADX INFO: loaded from: classes3.dex */
public final class Cookie {

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static final Companion f21986j = new Companion(0);

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static final Pattern f21987k = Pattern.compile("(\\d{2,4})[^\\d]*");
    public static final Pattern l = Pattern.compile("(?i)(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec).*");

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final Pattern f21988m = Pattern.compile("(\\d{1,2})[^\\d]*");

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public static final Pattern f21989n = Pattern.compile("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})[^\\d]*");

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final String f21990a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f21991b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final long f21992c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final String f21993d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final String f21994e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final boolean f21995f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final boolean f21996g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final boolean f21997h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final boolean f21998i;

    public static final class Builder {
    }

    public static final class Companion {
        public /* synthetic */ Companion(int i6) {
            this();
        }

        public static int a(String str, int i6, int i7, boolean z6) {
            while (i6 < i7) {
                char cCharAt = str.charAt(i6);
                if (((cCharAt < ' ' && cCharAt != '\t') || cCharAt >= 127 || ('0' <= cCharAt && cCharAt < ':') || (('a' <= cCharAt && cCharAt < '{') || (('A' <= cCharAt && cCharAt < '[') || cCharAt == ':'))) == (!z6)) {
                    return i6;
                }
                i6++;
            }
            return i7;
        }

        /* JADX WARN: Removed duplicated region for block: B:18:0x00a0  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public static long b(int i6, String str) {
            int iA = a(str, 0, i6, false);
            Matcher matcher = Cookie.f21989n.matcher(str);
            int i7 = -1;
            int i8 = -1;
            int i9 = -1;
            int iO0 = -1;
            int i10 = -1;
            int i11 = -1;
            while (iA < i6) {
                int iA2 = a(str, iA + 1, i6, true);
                matcher.region(iA, iA2);
                if (i8 == -1 && matcher.usePattern(Cookie.f21989n).matches()) {
                    String strGroup = matcher.group(1);
                    o.g(strGroup, "matcher.group(1)");
                    i8 = Integer.parseInt(strGroup);
                    String strGroup2 = matcher.group(2);
                    o.g(strGroup2, "matcher.group(2)");
                    i10 = Integer.parseInt(strGroup2);
                    String strGroup3 = matcher.group(3);
                    o.g(strGroup3, "matcher.group(3)");
                    i11 = Integer.parseInt(strGroup3);
                } else if (i9 == -1 && matcher.usePattern(Cookie.f21988m).matches()) {
                    String strGroup4 = matcher.group(1);
                    o.g(strGroup4, "matcher.group(1)");
                    i9 = Integer.parseInt(strGroup4);
                } else if (iO0 == -1) {
                    Pattern pattern = Cookie.l;
                    if (matcher.usePattern(pattern).matches()) {
                        String strGroup5 = matcher.group(1);
                        o.g(strGroup5, "matcher.group(1)");
                        Locale locale = Locale.US;
                        String strO = a.o(locale, "US", strGroup5, locale, "this as java.lang.String).toLowerCase(locale)");
                        String strPattern = pattern.pattern();
                        o.g(strPattern, "MONTH_PATTERN.pattern()");
                        iO0 = p.O0(strPattern, strO, 0, false, 6) / 4;
                    } else if (i7 == -1 && matcher.usePattern(Cookie.f21987k).matches()) {
                        String strGroup6 = matcher.group(1);
                        o.g(strGroup6, "matcher.group(1)");
                        i7 = Integer.parseInt(strGroup6);
                    }
                }
                iA = a(str, iA2 + 1, i6, false);
            }
            if (70 <= i7 && i7 < 100) {
                i7 += 1900;
            }
            if (i7 >= 0 && i7 < 70) {
                i7 += 2000;
            }
            if (i7 < 1601) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            if (iO0 == -1) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            if (1 > i9 || i9 >= 32) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            if (i8 < 0 || i8 >= 24) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            if (i10 < 0 || i10 >= 60) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            if (i11 < 0 || i11 >= 60) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            GregorianCalendar gregorianCalendar = new GregorianCalendar(Util.f22183e);
            gregorianCalendar.setLenient(false);
            gregorianCalendar.set(1, i7);
            gregorianCalendar.set(2, iO0 - 1);
            gregorianCalendar.set(5, i9);
            gregorianCalendar.set(11, i8);
            gregorianCalendar.set(12, i10);
            gregorianCalendar.set(13, i11);
            gregorianCalendar.set(14, 0);
            return gregorianCalendar.getTimeInMillis();
        }

        private Companion() {
        }
    }

    public Cookie(String str, String str2, long j4, String str3, String str4, boolean z6, boolean z7, boolean z8, boolean z9) {
        this.f21990a = str;
        this.f21991b = str2;
        this.f21992c = j4;
        this.f21993d = str3;
        this.f21994e = str4;
        this.f21995f = z6;
        this.f21996g = z7;
        this.f21997h = z8;
        this.f21998i = z9;
    }

    public final boolean equals(Object obj) {
        if (!(obj instanceof Cookie)) {
            return false;
        }
        Cookie cookie = (Cookie) obj;
        return o.c(cookie.f21990a, this.f21990a) && o.c(cookie.f21991b, this.f21991b) && cookie.f21992c == this.f21992c && o.c(cookie.f21993d, this.f21993d) && o.c(cookie.f21994e, this.f21994e) && cookie.f21995f == this.f21995f && cookie.f21996g == this.f21996g && cookie.f21997h == this.f21997h && cookie.f21998i == this.f21998i;
    }

    public final int hashCode() {
        return Boolean.hashCode(this.f21998i) + a.f(a.f(a.f(AbstractC2761L.b(AbstractC2761L.b(a.e(AbstractC2761L.b(AbstractC2761L.b(527, 31, this.f21990a), 31, this.f21991b), 31, this.f21992c), 31, this.f21993d), 31, this.f21994e), 31, this.f21995f), 31, this.f21996g), 31, this.f21997h);
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.f21990a);
        sb.append('=');
        sb.append(this.f21991b);
        if (this.f21997h) {
            long j4 = this.f21992c;
            if (j4 == Long.MIN_VALUE) {
                sb.append("; max-age=0");
            } else {
                sb.append("; expires=");
                String str = DatesKt.f22378a.get().format(new Date(j4));
                o.g(str, "STANDARD_DATE_FORMAT.get().format(this)");
                sb.append(str);
            }
        }
        if (!this.f21998i) {
            sb.append("; domain=");
            sb.append(this.f21993d);
        }
        sb.append("; path=");
        sb.append(this.f21994e);
        if (this.f21995f) {
            sb.append("; secure");
        }
        if (this.f21996g) {
            sb.append("; httponly");
        }
        String string = sb.toString();
        o.g(string, "toString()");
        return string;
    }
}
