package p011d0;

import android.os.Build;
import android.os.LocaleList;
import java.util.Locale;
import p017f0.C0687b;

/* renamed from: d0.i */
/* loaded from: classes.dex */
public final class C0608i {

    /* renamed from: b */
    public static final C0608i f2139b = m3275a(new Locale[0]);

    /* renamed from: a */
    public final InterfaceC0614m f2140a;

    /* renamed from: d0.i$a */
    /* loaded from: classes.dex */
    public static class C0609a {

        /* renamed from: a */
        public static final Locale[] f2141a = {new Locale("en", "XA"), new Locale("ar", "XB")};

        /* renamed from: a */
        public static Locale m3266a(String str) {
            Locale forLanguageTag;
            forLanguageTag = Locale.forLanguageTag(str);
            return forLanguageTag;
        }

        /* renamed from: b */
        public static boolean m3265b(Locale locale) {
            for (Locale locale2 : f2141a) {
                if (locale2.equals(locale)) {
                    return true;
                }
            }
            return false;
        }

        /* renamed from: c */
        public static boolean m3264c(Locale locale, Locale locale2) {
            if (locale.equals(locale2)) {
                return true;
            }
            if (!locale.getLanguage().equals(locale2.getLanguage()) || m3265b(locale) || m3265b(locale2)) {
                return false;
            }
            String m3106c = C0687b.m3106c(locale);
            if (m3106c.isEmpty()) {
                String country = locale.getCountry();
                return country.isEmpty() || country.equals(locale2.getCountry());
            }
            return m3106c.equals(C0687b.m3106c(locale2));
        }
    }

    /* renamed from: d0.i$b */
    /* loaded from: classes.dex */
    public static class C0610b {
        /* renamed from: a */
        public static LocaleList m3263a(Locale... localeArr) {
            return new LocaleList(localeArr);
        }

        /* renamed from: b */
        public static LocaleList m3262b() {
            LocaleList adjustedDefault;
            adjustedDefault = LocaleList.getAdjustedDefault();
            return adjustedDefault;
        }

        /* renamed from: c */
        public static LocaleList m3261c() {
            LocaleList localeList;
            localeList = LocaleList.getDefault();
            return localeList;
        }
    }

    public C0608i(InterfaceC0614m interfaceC0614m) {
        this.f2140a = interfaceC0614m;
    }

    /* renamed from: a */
    public static C0608i m3275a(Locale... localeArr) {
        return Build.VERSION.SDK_INT >= 24 ? m3267i(C0610b.m3263a(localeArr)) : new C0608i(new C0613l(localeArr));
    }

    /* renamed from: b */
    public static Locale m3274b(String str) {
        if (str.contains("-")) {
            String[] split = str.split("-", -1);
            if (split.length > 2) {
                return new Locale(split[0], split[1], split[2]);
            }
            if (split.length > 1) {
                return new Locale(split[0], split[1]);
            }
            if (split.length == 1) {
                return new Locale(split[0]);
            }
        } else if (!str.contains("_")) {
            return new Locale(str);
        } else {
            String[] split2 = str.split("_", -1);
            if (split2.length > 2) {
                return new Locale(split2[0], split2[1], split2[2]);
            }
            if (split2.length > 1) {
                return new Locale(split2[0], split2[1]);
            }
            if (split2.length == 1) {
                return new Locale(split2[0]);
            }
        }
        throw new IllegalArgumentException("Can not parse language tag: [" + str + "]");
    }

    /* renamed from: c */
    public static C0608i m3273c(String str) {
        if (str == null || str.isEmpty()) {
            return m3271e();
        }
        String[] split = str.split(",", -1);
        int length = split.length;
        Locale[] localeArr = new Locale[length];
        for (int i = 0; i < length; i++) {
            localeArr[i] = Build.VERSION.SDK_INT >= 21 ? C0609a.m3266a(split[i]) : m3274b(split[i]);
        }
        return m3275a(localeArr);
    }

    /* renamed from: e */
    public static C0608i m3271e() {
        return f2139b;
    }

    /* renamed from: i */
    public static C0608i m3267i(LocaleList localeList) {
        return new C0608i(new C0620s(localeList));
    }

    /* renamed from: d */
    public Locale m3272d(int i) {
        return this.f2140a.get(i);
    }

    public boolean equals(Object obj) {
        return (obj instanceof C0608i) && this.f2140a.equals(((C0608i) obj).f2140a);
    }

    /* renamed from: f */
    public boolean m3270f() {
        return this.f2140a.isEmpty();
    }

    /* renamed from: g */
    public int m3269g() {
        return this.f2140a.size();
    }

    /* renamed from: h */
    public String m3268h() {
        return this.f2140a.mo3251b();
    }

    public int hashCode() {
        return this.f2140a.hashCode();
    }

    public String toString() {
        return this.f2140a.toString();
    }
}