package androidx.view;

import android.net.Uri;
import android.os.Bundle;
import androidx.credentials.exceptions.publickeycredential.DomExceptionUtils;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.upstream.CmcdData;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import defpackage.cr4;
import defpackage.d75;
import defpackage.e6a;
import defpackage.ik2;
import defpackage.j65;
import defpackage.n89;
import defpackage.pw7;
import defpackage.v65;
import defpackage.vw2;
import defpackage.vx8;
import defpackage.y41;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0005\u0018\u00002\u00020\u0001:\u0004\u0002\u0003\u0004\u0005¨\u0006\u0006"}, d2 = {"Landroidx/navigation/aa;", "", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "b", "c", "d", "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class aa {
    public static final Pattern q = Pattern.compile("^[a-zA-Z]+[+\\w\\-.]*:");
    public static final Pattern r = Pattern.compile("\\{(.+?)\\}");
    public final String a;
    public final String b;
    public final String c;
    public final ArrayList d;
    public final String e;
    public final j65 f;
    public final j65 g;
    public final Object h;
    public boolean i;
    public final Object j;
    public final Object k;
    public final Object l;
    public final j65 m;
    public final String n;
    public final j65 o;
    public final boolean p;

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\u0018\u00002\u00020\u0001:\u0001\u0002¨\u0006\u0003"}, d2 = {"Landroidx/navigation/aa$a;", "", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @vx8
    public static final class a {
        public String a;
        public String b;
        public String c;

        /* JADX INFO: renamed from: androidx.navigation.aa$a$a, reason: collision with other inner class name */
        @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0080\u0003\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Landroidx/navigation/aa$a$a;", "", "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
        @vx8
        public static final class C0054a {
        }
    }

    @Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0082\u0003\u0018\u00002\u00020\u0001R\u001c\u0010\u0004\u001a\n \u0003*\u0004\u0018\u00010\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0004\u0010\u0005R\u001c\u0010\u0006\u001a\n \u0003*\u0004\u0018\u00010\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0006\u0010\u0005¨\u0006\u0007"}, d2 = {"Landroidx/navigation/aa$b;", "", "Ljava/util/regex/Pattern;", "kotlin.jvm.PlatformType", "FILL_IN_PATTERN", "Ljava/util/regex/Pattern;", "SCHEME_PATTERN", "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class b {
    }

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u000f\n\u0000\b\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001¨\u0006\u0002"}, d2 = {"Landroidx/navigation/aa$c;", "", "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @vx8
    public static final class c implements Comparable<c> {
        public final String a;
        public final String b;

        public c(String str) {
            List listBk;
            cr4.g(str, "mimeType");
            List listG = new pw7(DomExceptionUtils.SEPARATOR).g(str);
            if (listG.isEmpty()) {
                listBk = ik2.a;
            } else {
                ListIterator listIterator = listG.listIterator(listG.size());
                while (listIterator.hasPrevious()) {
                    if (((String) listIterator.previous()).length() != 0) {
                        listBk = y41.bk(listG, listIterator.nextIndex() + 1);
                        break;
                    }
                }
                listBk = ik2.a;
            }
            this.a = (String) listBk.get(0);
            this.b = (String) listBk.get(1);
        }

        @Override // java.lang.Comparable
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public final int compareTo(c cVar) {
            cr4.g(cVar, "other");
            int i = cr4.b(this.a, cVar.a) ? 2 : 0;
            return cr4.b(this.b, cVar.b) ? i + 1 : i;
        }
    }

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0002\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Landroidx/navigation/aa$d;", "", "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class d {
        public String a;
        public final ArrayList b = new ArrayList();
    }

    public aa(String str, String str2, String str3) {
        this.a = str;
        this.b = str2;
        this.c = str3;
        ArrayList arrayList = new ArrayList();
        this.d = arrayList;
        this.f = v65.a(new ai(this));
        this.g = v65.a(new ag(this));
        d75 d75Var = d75.b;
        this.h = v65.b(d75Var, new aj(this));
        this.j = v65.b(d75Var, new ac(this));
        this.k = v65.b(d75Var, new ab(this));
        this.l = v65.b(d75Var, new ae(this));
        this.m = v65.a(new ad(this));
        this.o = v65.a(new ah(this));
        if (str != null) {
            StringBuilder sb = new StringBuilder("^");
            if (!q.matcher(str).find()) {
                sb.append("http[s]?://");
            }
            Matcher matcher = Pattern.compile("(\\?|\\#|$)").matcher(str);
            matcher.find();
            boolean z = false;
            String strSubstring = str.substring(0, matcher.start());
            cr4.f(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
            a(strSubstring, arrayList, sb);
            if (!n89.l(sb, ".*", false) && !n89.l(sb, "([^/]+?)", false)) {
                z = true;
            }
            this.p = z;
            sb.append("($|(\\?(.)*)|(\\#(.)*))");
            String string = sb.toString();
            cr4.f(string, "uriRegex.toString()");
            this.e = n89.an(string, ".*", "\\E.*\\Q");
        }
        if (str3 == null) {
            return;
        }
        if (!Pattern.compile("^[\\s\\S]+/[\\s\\S]+$").matcher(str3).matches()) {
            throw new IllegalArgumentException(vw2.ab("The given mimeType ", str3, " does not match to required \"type/subtype\" format").toString());
        }
        c cVar = new c(str3);
        this.n = n89.an("^(" + cVar.a + "|[*]+)/(" + cVar.b + "|[*]+)$", "*|[*]", "[\\s\\S]");
    }

    public static void a(String str, ArrayList arrayList, StringBuilder sb) {
        Matcher matcher = r.matcher(str);
        int iEnd = 0;
        while (matcher.find()) {
            String strGroup = matcher.group(1);
            cr4.e(strGroup, "null cannot be cast to non-null type kotlin.String");
            arrayList.add(strGroup);
            if (matcher.start() > iEnd) {
                String strSubstring = str.substring(iEnd, matcher.start());
                cr4.f(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
                sb.append(Pattern.quote(strSubstring));
            }
            sb.append("([^/]+?)");
            iEnd = matcher.end();
        }
        if (iEnd < str.length()) {
            String strSubstring2 = str.substring(iEnd);
            cr4.f(strSubstring2, "this as java.lang.String).substring(startIndex)");
            sb.append(Pattern.quote(strSubstring2));
        }
    }

    public static void d(Bundle bundle, String str, String str2, e eVar) {
        if (eVar == null) {
            bundle.putString(str, str2);
            return;
        }
        ay ayVar = eVar.a;
        cr4.g(str, "key");
        ayVar.e(bundle, str, ayVar.f(str2));
    }

    public final boolean b(Matcher matcher, Bundle bundle, LinkedHashMap linkedHashMap) {
        ArrayList arrayList = this.d;
        ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
        int i = 0;
        for (Object obj : arrayList) {
            int i2 = i + 1;
            if (i < 0) {
                y41.bm();
                throw null;
            }
            String str = (String) obj;
            String strDecode = Uri.decode(matcher.group(i2));
            e eVar = (e) linkedHashMap.get(str);
            try {
                cr4.f(strDecode, AppMeasurementSdk.ConditionalUserProperty.VALUE);
                d(bundle, str, strDecode, eVar);
                arrayList2.add(e6a.a);
                i = i2;
            } catch (IllegalArgumentException unused) {
                return false;
            }
        }
        return true;
    }

    /* JADX WARN: Type inference failed for: r2v0, types: [j65, java.lang.Object] */
    public final boolean c(Uri uri, Bundle bundle, LinkedHashMap linkedHashMap) {
        String query;
        aa aaVar = this;
        for (Map.Entry entry : ((Map) aaVar.h.getValue()).entrySet()) {
            String str = (String) entry.getKey();
            d dVar = (d) entry.getValue();
            List<String> queryParameters = uri.getQueryParameters(str);
            if (aaVar.i && (query = uri.getQuery()) != null && !query.equals(uri.toString())) {
                queryParameters = y41.am(query);
            }
            if (queryParameters != null) {
                for (String str2 : queryParameters) {
                    String str3 = dVar.a;
                    Matcher matcher = str3 != null ? Pattern.compile(str3, 32).matcher(str2) : null;
                    int i = 0;
                    if (matcher == null || !matcher.matches()) {
                        return false;
                    }
                    Bundle bundle2 = new Bundle();
                    try {
                        ArrayList arrayList = dVar.b;
                        ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
                        for (Object obj : arrayList) {
                            int i2 = i + 1;
                            if (i < 0) {
                                y41.bm();
                                throw null;
                            }
                            String str4 = (String) obj;
                            String strGroup = matcher.group(i2);
                            if (strGroup == null) {
                                strGroup = "";
                            }
                            try {
                                e eVar = (e) linkedHashMap.get(str4);
                                if (!bundle.containsKey(str4)) {
                                    if (!strGroup.equals('{' + str4 + '}')) {
                                        d(bundle2, str4, strGroup, eVar);
                                    }
                                } else if (eVar != null) {
                                    ay ayVar = eVar.a;
                                    Object objA = ayVar.a(bundle, str4);
                                    if (!bundle.containsKey(str4)) {
                                        throw new IllegalArgumentException("There is no previous value in this bundle.");
                                    }
                                    ayVar.e(bundle, str4, ayVar.c(objA, strGroup));
                                } else {
                                    continue;
                                }
                                arrayList2.add(e6a.a);
                                i = i2;
                            } catch (IllegalArgumentException unused) {
                                continue;
                            }
                        }
                        bundle.putAll(bundle2);
                    } catch (IllegalArgumentException unused2) {
                    }
                }
            }
            aaVar = this;
        }
        return true;
    }

    public final boolean equals(Object obj) {
        if (obj != null && (obj instanceof aa)) {
            aa aaVar = (aa) obj;
            if (cr4.b(this.a, aaVar.a) && cr4.b(this.b, aaVar.b) && cr4.b(this.c, aaVar.c)) {
                return true;
            }
        }
        return false;
    }

    public final int hashCode() {
        String str = this.a;
        int iHashCode = (str != null ? str.hashCode() : 0) * 31;
        String str2 = this.b;
        int iHashCode2 = (iHashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
        String str3 = this.c;
        return iHashCode2 + (str3 != null ? str3.hashCode() : 0);
    }
}
