package o;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class ZF {
    public static final char[] j = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    public final String a;
    public final String b;
    public final String c;
    public final String d;
    public final int e;
    public final List f;
    public final String g;
    public final String h;
    public final boolean i;

    public ZF(String str, String str2, String str3, String str4, int i, ArrayList arrayList, String str5, String str6) {
        this.a = str;
        this.b = str2;
        this.c = str3;
        this.d = str4;
        this.e = i;
        this.f = arrayList;
        this.g = str5;
        this.h = str6;
        this.i = F3.c(str, "https");
    }

    public final String a() {
        if (this.c.length() == 0) {
            return "";
        }
        int length = this.a.length() + 3;
        String str = this.h;
        return str.substring(Za0.V(str, ':', length, 4) + 1, Za0.V(str, '@', 0, 6));
    }

    public final String b() {
        int length = this.a.length() + 3;
        String str = this.h;
        int iV = Za0.V(str, '/', length, 4);
        return str.substring(iV, AbstractC2264qi0.f(iV, str.length(), str, "?#"));
    }

    public final ArrayList c() {
        int length = this.a.length() + 3;
        String str = this.h;
        int iV = Za0.V(str, '/', length, 4);
        int iF = AbstractC2264qi0.f(iV, str.length(), str, "?#");
        ArrayList arrayList = new ArrayList();
        while (iV < iF) {
            int i = iV + 1;
            int iG = AbstractC2264qi0.g(str, '/', i, iF);
            arrayList.add(str.substring(i, iG));
            iV = iG;
        }
        return arrayList;
    }

    public final String d() {
        if (this.f == null) {
            return null;
        }
        String str = this.h;
        int iV = Za0.V(str, '?', 0, 6) + 1;
        return str.substring(iV, AbstractC2264qi0.g(str, '#', iV, str.length()));
    }

    public final String e() {
        if (this.b.length() == 0) {
            return "";
        }
        int length = this.a.length() + 3;
        String str = this.h;
        return str.substring(length, AbstractC2264qi0.f(length, str.length(), str, ":@"));
    }

    public final boolean equals(Object obj) {
        return (obj instanceof ZF) && F3.c(((ZF) obj).h, this.h);
    }

    public final String f() {
        YF yf;
        try {
            yf = new YF();
            yf.c(this, "/...");
        } catch (IllegalArgumentException unused) {
            yf = null;
        }
        yf.getClass();
        yf.b = C0688a6.f("", 0, 0, " \"':;<=>@[]^`{}|/\\?#", 251);
        yf.c = C0688a6.f("", 0, 0, " \"':;<=>@[]^`{}|/\\?#", 251);
        return yf.a().h;
    }

    public final URI g() {
        String strSubstring;
        YF yf = new YF();
        String str = this.a;
        yf.a = str;
        yf.b = e();
        yf.c = a();
        yf.d = this.d;
        int i = str.equals("http") ? 80 : str.equals("https") ? 443 : -1;
        int i2 = this.e;
        yf.e = i2 != i ? i2 : -1;
        ArrayList arrayList = yf.f;
        arrayList.clear();
        arrayList.addAll(c());
        String strD = d();
        yf.g = strD != null ? C0688a6.o(C0688a6.f(strD, 0, 0, " \"'<>#", 211)) : null;
        if (this.g == null) {
            strSubstring = null;
        } else {
            String str2 = this.h;
            strSubstring = str2.substring(Za0.V(str2, '#', 0, 6) + 1);
        }
        yf.h = strSubstring;
        String str3 = yf.d;
        yf.d = str3 != null ? Pattern.compile("[\"<>^`{|}]").matcher(str3).replaceAll("") : null;
        int size = arrayList.size();
        for (int i3 = 0; i3 < size; i3++) {
            arrayList.set(i3, C0688a6.f((String) arrayList.get(i3), 0, 0, "[]", 227));
        }
        ArrayList arrayList2 = yf.g;
        if (arrayList2 != null) {
            int size2 = arrayList2.size();
            for (int i4 = 0; i4 < size2; i4++) {
                String str4 = (String) arrayList2.get(i4);
                arrayList2.set(i4, str4 != null ? C0688a6.f(str4, 0, 0, "\\^`{|}", 195) : null);
            }
        }
        String str5 = yf.h;
        yf.h = str5 != null ? C0688a6.f(str5, 0, 0, " \"#<>\\^`{|}", 163) : null;
        String string = yf.toString();
        try {
            return new URI(string);
        } catch (URISyntaxException e) {
            try {
                return URI.create(Pattern.compile("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]").matcher(string).replaceAll(""));
            } catch (Exception unused) {
                throw new RuntimeException(e);
            }
        }
    }

    public final int hashCode() {
        return this.h.hashCode();
    }

    public final String toString() {
        return this.h;
    }
}
