package 㿎;

import java.nio.charset.Charset;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ඓ.K.K.K.C1293;

/* renamed from: 㿎.ᓆ  reason: contains not printable characters */
/* compiled from: MediaType */
public final class C2628 {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static final Pattern f8929 = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");

    /* renamed from: 㴹  reason: contains not printable characters */
    public static final Pattern f8930 = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");

    /* renamed from: ʬ  reason: contains not printable characters */
    public final String f8931;

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

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

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

    public C2628(String str, String str2, String str3, String str4) {
        this.f8933 = str;
        this.f8932 = str2;
        this.f8931 = str3;
        this.f8934 = str4;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static C2628 m6936(String str) {
        try {
            return m6937(str);
        } catch (IllegalArgumentException unused) {
            return null;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static C2628 m6937(String str) {
        Matcher matcher = f8929.matcher(str);
        if (matcher.lookingAt()) {
            String lowerCase = matcher.group(1).toLowerCase(Locale.US);
            String lowerCase2 = matcher.group(2).toLowerCase(Locale.US);
            String str2 = null;
            Matcher matcher2 = f8930.matcher(str);
            for (int end = matcher.end(); end < str.length(); end = matcher2.end()) {
                matcher2.region(end, str.length());
                if (matcher2.lookingAt()) {
                    String group = matcher2.group(1);
                    if (group != null && group.equalsIgnoreCase("charset")) {
                        String group2 = matcher2.group(2);
                        if (group2 == null) {
                            group2 = matcher2.group(3);
                        } else if (group2.startsWith("'") && group2.endsWith("'") && group2.length() > 2) {
                            group2 = group2.substring(1, group2.length() - 1);
                        }
                        if (str2 == null || group2.equalsIgnoreCase(str2)) {
                            str2 = group2;
                        } else {
                            throw new IllegalArgumentException("Multiple charsets defined: \"" + str2 + "\" and: \"" + group2 + "\" for: \"" + str + '\"');
                        }
                    }
                } else {
                    StringBuilder r3 = C1293.m3416("Parameter is not formatted correctly: \"");
                    r3.append(str.substring(end));
                    r3.append("\" for: \"");
                    r3.append(str);
                    r3.append('\"');
                    throw new IllegalArgumentException(r3.toString());
                }
            }
            return new C2628(str, lowerCase, lowerCase2, str2);
        }
        throw new IllegalArgumentException("No subtype found for: \"" + str + '\"');
    }

    public boolean equals(Object obj) {
        return (obj instanceof C2628) && ((C2628) obj).f8933.equals(this.f8933);
    }

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

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

    /* renamed from: K  reason: contains not printable characters */
    public Charset m6938() {
        try {
            if (this.f8934 != null) {
                return Charset.forName(this.f8934);
            }
        } catch (IllegalArgumentException unused) {
        }
        return null;
    }
}
