package XnFJ5_9;

import com.wang.avi.BuildConfig;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
/* compiled from: HttpUrl.java */
/* loaded from: classes.dex */
public final class G83uNX_24 {
    public static final char[] KQgRr5e_0 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

    /* renamed from: IFxWkV_5  reason: collision with root package name */
    public final String f3397IFxWkV_5;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final int f1639KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final String f1640KQgRr5e_0;
    @Nullable

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final List<String> f1641KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public final String f3398Mqv2r_3;
    public final String PGPF6hQ_2;
    public final String QxJ9d_1;
    @Nullable

    /* renamed from: X6FRs_4  reason: collision with root package name */
    public final String f3399X6FRs_4;

    public G83uNX_24(KQgRr5e_0 kQgRr5e_0) {
        this.f1640KQgRr5e_0 = kQgRr5e_0.f1642KQgRr5e_0;
        this.QxJ9d_1 = KQgRr5e_0(kQgRr5e_0.QxJ9d_1, false);
        this.PGPF6hQ_2 = KQgRr5e_0(kQgRr5e_0.PGPF6hQ_2, false);
        this.f3398Mqv2r_3 = kQgRr5e_0.f3400Mqv2r_3;
        this.f1639KQgRr5e_0 = kQgRr5e_0.KQgRr5e_0();
        KQgRr5e_0(kQgRr5e_0.f1643KQgRr5e_0, false);
        List<String> list = kQgRr5e_0.f1644QxJ9d_1;
        this.f1641KQgRr5e_0 = list != null ? KQgRr5e_0(list, true) : null;
        String str = kQgRr5e_0.f3401X6FRs_4;
        this.f3399X6FRs_4 = str != null ? KQgRr5e_0(str, false) : null;
        this.f3397IFxWkV_5 = kQgRr5e_0.toString();
    }

    public String FSaI4_7() {
        KQgRr5e_0 m745KQgRr5e_0 = m745KQgRr5e_0("/...");
        m745KQgRr5e_0.X6FRs_4(BuildConfig.FLAVOR);
        m745KQgRr5e_0.PGPF6hQ_2(BuildConfig.FLAVOR);
        return m745KQgRr5e_0.m753KQgRr5e_0().toString();
    }

    public String IFxWkV_5() {
        return this.f3398Mqv2r_3;
    }

    @Nullable
    public String IMuAHx_6() {
        if (this.f1641KQgRr5e_0 == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        KQgRr5e_0(sb, this.f1641KQgRr5e_0);
        return sb.toString();
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public URI m748KQgRr5e_0() {
        KQgRr5e_0 m744KQgRr5e_0 = m744KQgRr5e_0();
        m744KQgRr5e_0.m752KQgRr5e_0();
        String kQgRr5e_0 = m744KQgRr5e_0.toString();
        try {
            return new URI(kQgRr5e_0);
        } catch (URISyntaxException e) {
            try {
                return URI.create(kQgRr5e_0.replaceAll("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]", BuildConfig.FLAVOR));
            } catch (Exception unused) {
                throw new RuntimeException(e);
            }
        }
    }

    @Nullable
    public String Mqv2r_3() {
        if (this.f1641KQgRr5e_0 == null) {
            return null;
        }
        int indexOf = this.f3397IFxWkV_5.indexOf(63) + 1;
        String str = this.f3397IFxWkV_5;
        return this.f3397IFxWkV_5.substring(indexOf, XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, indexOf, str.length(), '#'));
    }

    public String PGPF6hQ_2() {
        int indexOf = this.f3397IFxWkV_5.indexOf(47, this.f1640KQgRr5e_0.length() + 3);
        String str = this.f3397IFxWkV_5;
        return this.f3397IFxWkV_5.substring(indexOf, XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, indexOf, str.length(), "?#"));
    }

    public String QxJ9d_1() {
        if (this.PGPF6hQ_2.isEmpty()) {
            return BuildConfig.FLAVOR;
        }
        int indexOf = this.f3397IFxWkV_5.indexOf(64);
        return this.f3397IFxWkV_5.substring(this.f3397IFxWkV_5.indexOf(58, this.f1640KQgRr5e_0.length() + 3) + 1, indexOf);
    }

    public String X6FRs_4() {
        if (this.QxJ9d_1.isEmpty()) {
            return BuildConfig.FLAVOR;
        }
        int length = this.f1640KQgRr5e_0.length() + 3;
        String str = this.f3397IFxWkV_5;
        return this.f3397IFxWkV_5.substring(length, XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, length, str.length(), ":@"));
    }

    public String Xgtqvk_8() {
        return this.f1640KQgRr5e_0;
    }

    public boolean equals(@Nullable Object obj) {
        return (obj instanceof G83uNX_24) && ((G83uNX_24) obj).f3397IFxWkV_5.equals(this.f3397IFxWkV_5);
    }

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

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

    /* compiled from: HttpUrl.java */
    /* loaded from: classes.dex */
    public static final class KQgRr5e_0 {
        @Nullable

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public String f1642KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final List<String> f1643KQgRr5e_0;
        @Nullable

        /* renamed from: Mqv2r_3  reason: collision with root package name */
        public String f3400Mqv2r_3;
        @Nullable

        /* renamed from: QxJ9d_1  reason: collision with other field name */
        public List<String> f1644QxJ9d_1;
        @Nullable

        /* renamed from: X6FRs_4  reason: collision with root package name */
        public String f3401X6FRs_4;
        public String QxJ9d_1 = BuildConfig.FLAVOR;
        public String PGPF6hQ_2 = BuildConfig.FLAVOR;
        public int KQgRr5e_0 = -1;

        public KQgRr5e_0() {
            ArrayList arrayList = new ArrayList();
            this.f1643KQgRr5e_0 = arrayList;
            arrayList.add(BuildConfig.FLAVOR);
        }

        public KQgRr5e_0 KQgRr5e_0(int i) {
            if (i > 0 && i <= 65535) {
                this.KQgRr5e_0 = i;
                return this;
            }
            throw new IllegalArgumentException("unexpected port: " + i);
        }

        public KQgRr5e_0 Mqv2r_3(String str) {
            if (str != null) {
                if (str.equalsIgnoreCase("http")) {
                    this.f1642KQgRr5e_0 = "http";
                } else if (str.equalsIgnoreCase("https")) {
                    this.f1642KQgRr5e_0 = "https";
                } else {
                    throw new IllegalArgumentException("unexpected scheme: " + str);
                }
                return this;
            }
            throw new NullPointerException("scheme == null");
        }

        public KQgRr5e_0 PGPF6hQ_2(String str) {
            if (str != null) {
                this.PGPF6hQ_2 = G83uNX_24.KQgRr5e_0(str, " \"':;<=>@[]^`{}|/\\?#", false, false, false, true);
                return this;
            }
            throw new NullPointerException("password == null");
        }

        public KQgRr5e_0 QxJ9d_1(String str) {
            if (str != null) {
                String m751KQgRr5e_0 = m751KQgRr5e_0(str, 0, str.length());
                if (m751KQgRr5e_0 != null) {
                    this.f3400Mqv2r_3 = m751KQgRr5e_0;
                    return this;
                }
                throw new IllegalArgumentException("unexpected host: " + str);
            }
            throw new NullPointerException("host == null");
        }

        public KQgRr5e_0 X6FRs_4(String str) {
            if (str != null) {
                this.QxJ9d_1 = G83uNX_24.KQgRr5e_0(str, " \"':;<=>@[]^`{}|/\\?#", false, false, false, true);
                return this;
            }
            throw new NullPointerException("username == null");
        }

        public String toString() {
            StringBuilder sb = new StringBuilder();
            String str = this.f1642KQgRr5e_0;
            if (str != null) {
                sb.append(str);
                sb.append("://");
            } else {
                sb.append("//");
            }
            if (!this.QxJ9d_1.isEmpty() || !this.PGPF6hQ_2.isEmpty()) {
                sb.append(this.QxJ9d_1);
                if (!this.PGPF6hQ_2.isEmpty()) {
                    sb.append(':');
                    sb.append(this.PGPF6hQ_2);
                }
                sb.append('@');
            }
            String str2 = this.f3400Mqv2r_3;
            if (str2 != null) {
                if (str2.indexOf(58) != -1) {
                    sb.append('[');
                    sb.append(this.f3400Mqv2r_3);
                    sb.append(']');
                } else {
                    sb.append(this.f3400Mqv2r_3);
                }
            }
            if (this.KQgRr5e_0 != -1 || this.f1642KQgRr5e_0 != null) {
                int KQgRr5e_0 = KQgRr5e_0();
                String str3 = this.f1642KQgRr5e_0;
                if (str3 == null || KQgRr5e_0 != G83uNX_24.KQgRr5e_0(str3)) {
                    sb.append(':');
                    sb.append(KQgRr5e_0);
                }
            }
            G83uNX_24.QxJ9d_1(sb, this.f1643KQgRr5e_0);
            if (this.f1644QxJ9d_1 != null) {
                sb.append('?');
                G83uNX_24.KQgRr5e_0(sb, this.f1644QxJ9d_1);
            }
            if (this.f3401X6FRs_4 != null) {
                sb.append('#');
                sb.append(this.f3401X6FRs_4);
            }
            return sb.toString();
        }

        public static int PGPF6hQ_2(String str, int i, int i2) {
            if (i2 - i < 2) {
                return -1;
            }
            char charAt = str.charAt(i);
            if ((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z')) {
                while (true) {
                    i++;
                    if (i >= i2) {
                        break;
                    }
                    char charAt2 = str.charAt(i);
                    if (charAt2 < 'a' || charAt2 > 'z') {
                        if (charAt2 < 'A' || charAt2 > 'Z') {
                            if (charAt2 < '0' || charAt2 > '9') {
                                if (charAt2 != '+' && charAt2 != '-' && charAt2 != '.') {
                                    if (charAt2 == ':') {
                                        return i;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return -1;
        }

        public int KQgRr5e_0() {
            int i = this.KQgRr5e_0;
            return i != -1 ? i : G83uNX_24.KQgRr5e_0(this.f1642KQgRr5e_0);
        }

        public KQgRr5e_0 KQgRr5e_0(@Nullable String str) {
            this.f1644QxJ9d_1 = str != null ? G83uNX_24.m743KQgRr5e_0(G83uNX_24.KQgRr5e_0(str, " \"'<>#", true, false, true, true)) : null;
            return this;
        }

        /* renamed from: QxJ9d_1  reason: collision with other method in class */
        public final boolean m757QxJ9d_1(String str) {
            return str.equals("..") || str.equalsIgnoreCase("%2e.") || str.equalsIgnoreCase(".%2e") || str.equalsIgnoreCase("%2e%2e");
        }

        public static int Mqv2r_3(String str, int i, int i2) {
            int i3 = 0;
            while (i < i2) {
                char charAt = str.charAt(i);
                if (charAt != '\\' && charAt != '/') {
                    break;
                }
                i3++;
                i++;
            }
            return i3;
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public KQgRr5e_0 m752KQgRr5e_0() {
            int size = this.f1643KQgRr5e_0.size();
            for (int i = 0; i < size; i++) {
                this.f1643KQgRr5e_0.set(i, G83uNX_24.KQgRr5e_0(this.f1643KQgRr5e_0.get(i), "[]", true, true, false, true));
            }
            List<String> list = this.f1644QxJ9d_1;
            if (list != null) {
                int size2 = list.size();
                for (int i2 = 0; i2 < size2; i2++) {
                    String str = this.f1644QxJ9d_1.get(i2);
                    if (str != null) {
                        this.f1644QxJ9d_1.set(i2, G83uNX_24.KQgRr5e_0(str, "\\^`{|}", true, true, true, true));
                    }
                }
            }
            String str2 = this.f3401X6FRs_4;
            if (str2 != null) {
                this.f3401X6FRs_4 = G83uNX_24.KQgRr5e_0(str2, " \"#<>\\^`{|}", true, true, false, false);
            }
            return this;
        }

        public static int QxJ9d_1(String str, int i, int i2) {
            while (i < i2) {
                char charAt = str.charAt(i);
                if (charAt == ':') {
                    return i;
                }
                if (charAt == '[') {
                    do {
                        i++;
                        if (i < i2) {
                        }
                    } while (str.charAt(i) != ']');
                }
                i++;
            }
            return i2;
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public G83uNX_24 m753KQgRr5e_0() {
            if (this.f1642KQgRr5e_0 != null) {
                if (this.f3400Mqv2r_3 != null) {
                    return new G83uNX_24(this);
                }
                throw new IllegalStateException("host == null");
            }
            throw new IllegalStateException("scheme == null");
        }

        public KQgRr5e_0 KQgRr5e_0(@Nullable G83uNX_24 g83uNX_24, String str) {
            int PGPF6hQ_2;
            int KQgRr5e_0;
            int i;
            int KQgRr5e_02 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, 0, str.length());
            int QxJ9d_1 = XnFJ5_9.Ft6VRog_36.X6FRs_4.QxJ9d_1(str, KQgRr5e_02, str.length());
            if (PGPF6hQ_2(str, KQgRr5e_02, QxJ9d_1) != -1) {
                if (str.regionMatches(true, KQgRr5e_02, "https:", 0, 6)) {
                    this.f1642KQgRr5e_0 = "https";
                    KQgRr5e_02 += 6;
                } else if (str.regionMatches(true, KQgRr5e_02, "http:", 0, 5)) {
                    this.f1642KQgRr5e_0 = "http";
                    KQgRr5e_02 += 5;
                } else {
                    throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but was '" + str.substring(0, PGPF6hQ_2) + "'");
                }
            } else if (g83uNX_24 != null) {
                this.f1642KQgRr5e_0 = g83uNX_24.f1640KQgRr5e_0;
            } else {
                throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but no colon was found");
            }
            int Mqv2r_32 = Mqv2r_3(str, KQgRr5e_02, QxJ9d_1);
            char c = '?';
            char c2 = '#';
            if (Mqv2r_32 < 2 && g83uNX_24 != null && g83uNX_24.f1640KQgRr5e_0.equals(this.f1642KQgRr5e_0)) {
                this.QxJ9d_1 = g83uNX_24.X6FRs_4();
                this.PGPF6hQ_2 = g83uNX_24.QxJ9d_1();
                this.f3400Mqv2r_3 = g83uNX_24.f3398Mqv2r_3;
                this.KQgRr5e_0 = g83uNX_24.f1639KQgRr5e_0;
                this.f1643KQgRr5e_0.clear();
                this.f1643KQgRr5e_0.addAll(g83uNX_24.m749KQgRr5e_0());
                if (KQgRr5e_02 == QxJ9d_1 || str.charAt(KQgRr5e_02) == '#') {
                    KQgRr5e_0(g83uNX_24.Mqv2r_3());
                }
            } else {
                int i2 = KQgRr5e_02 + Mqv2r_32;
                boolean z = false;
                boolean z2 = false;
                while (true) {
                    KQgRr5e_0 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, i2, QxJ9d_1, "@/\\?#");
                    char charAt = KQgRr5e_0 != QxJ9d_1 ? str.charAt(KQgRr5e_0) : (char) 65535;
                    if (charAt == 65535 || charAt == c2 || charAt == '/' || charAt == '\\' || charAt == c) {
                        break;
                    }
                    if (charAt == '@') {
                        if (!z) {
                            int KQgRr5e_03 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, i2, KQgRr5e_0, ':');
                            i = KQgRr5e_0;
                            String KQgRr5e_04 = G83uNX_24.KQgRr5e_0(str, i2, KQgRr5e_03, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
                            if (z2) {
                                KQgRr5e_04 = this.QxJ9d_1 + "%40" + KQgRr5e_04;
                            }
                            this.QxJ9d_1 = KQgRr5e_04;
                            if (KQgRr5e_03 != i) {
                                this.PGPF6hQ_2 = G83uNX_24.KQgRr5e_0(str, KQgRr5e_03 + 1, i, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
                                z = true;
                            }
                            z2 = true;
                        } else {
                            i = KQgRr5e_0;
                            this.PGPF6hQ_2 += "%40" + G83uNX_24.KQgRr5e_0(str, i2, i, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
                        }
                        i2 = i + 1;
                    }
                    c = '?';
                    c2 = '#';
                }
                int QxJ9d_12 = QxJ9d_1(str, i2, KQgRr5e_0);
                int i3 = QxJ9d_12 + 1;
                if (i3 < KQgRr5e_0) {
                    this.f3400Mqv2r_3 = m751KQgRr5e_0(str, i2, QxJ9d_12);
                    int KQgRr5e_05 = KQgRr5e_0(str, i3, KQgRr5e_0);
                    this.KQgRr5e_0 = KQgRr5e_05;
                    if (KQgRr5e_05 == -1) {
                        throw new IllegalArgumentException("Invalid URL port: \"" + str.substring(i3, KQgRr5e_0) + '\"');
                    }
                } else {
                    this.f3400Mqv2r_3 = m751KQgRr5e_0(str, i2, QxJ9d_12);
                    this.KQgRr5e_0 = G83uNX_24.KQgRr5e_0(this.f1642KQgRr5e_0);
                }
                if (this.f3400Mqv2r_3 == null) {
                    throw new IllegalArgumentException("Invalid URL host: \"" + str.substring(i2, QxJ9d_12) + '\"');
                }
                KQgRr5e_02 = KQgRr5e_0;
            }
            int KQgRr5e_06 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, KQgRr5e_02, QxJ9d_1, "?#");
            m755KQgRr5e_0(str, KQgRr5e_02, KQgRr5e_06);
            if (KQgRr5e_06 < QxJ9d_1 && str.charAt(KQgRr5e_06) == '?') {
                int KQgRr5e_07 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, KQgRr5e_06, QxJ9d_1, '#');
                this.f1644QxJ9d_1 = G83uNX_24.m743KQgRr5e_0(G83uNX_24.KQgRr5e_0(str, KQgRr5e_06 + 1, KQgRr5e_07, " \"'<>#", true, false, true, true, null));
                KQgRr5e_06 = KQgRr5e_07;
            }
            if (KQgRr5e_06 < QxJ9d_1 && str.charAt(KQgRr5e_06) == '#') {
                this.f3401X6FRs_4 = G83uNX_24.KQgRr5e_0(str, 1 + KQgRr5e_06, QxJ9d_1, BuildConfig.FLAVOR, true, false, false, false, null);
            }
            return this;
        }

        /*  JADX ERROR: JadxOverflowException in pass: RegionMakerVisitor
            jadx.core.utils.exceptions.JadxOverflowException: Regions count limit reached
            	at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:56)
            	at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:30)
            	at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:18)
            */
        /* JADX WARN: Removed duplicated region for block: B:13:0x002c  */
        /* JADX WARN: Removed duplicated region for block: B:21:0x0044 A[SYNTHETIC] */
        /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:19:0x0041 -> B:11:0x0029). Please submit an issue!!! */
        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void m755KQgRr5e_0(java.lang.String r11, int r12, int r13) {
            /*
                r10 = this;
                if (r12 != r13) goto L3
                return
            L3:
                char r0 = r11.charAt(r12)
                r1 = 47
                java.lang.String r2 = ""
                r3 = 1
                if (r0 == r1) goto L1e
                r1 = 92
                if (r0 != r1) goto L13
                goto L1e
            L13:
                java.util.List<java.lang.String> r0 = r10.f1643KQgRr5e_0
                int r1 = r0.size()
                int r1 = r1 - r3
                r0.set(r1, r2)
                goto L29
            L1e:
                java.util.List<java.lang.String> r0 = r10.f1643KQgRr5e_0
                r0.clear()
                java.util.List<java.lang.String> r0 = r10.f1643KQgRr5e_0
                r0.add(r2)
                goto L41
            L29:
                r6 = r12
                if (r6 >= r13) goto L44
                java.lang.String r12 = "/\\"
                int r12 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(r11, r6, r13, r12)
                if (r12 >= r13) goto L36
                r0 = 1
                goto L37
            L36:
                r0 = 0
            L37:
                r9 = 1
                r4 = r10
                r5 = r11
                r7 = r12
                r8 = r0
                r4.KQgRr5e_0(r5, r6, r7, r8, r9)
                if (r0 == 0) goto L29
            L41:
                int r12 = r12 + 1
                goto L29
            L44:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: XnFJ5_9.G83uNX_24.KQgRr5e_0.m755KQgRr5e_0(java.lang.String, int, int):void");
        }

        public final void KQgRr5e_0(String str, int i, int i2, boolean z, boolean z2) {
            String KQgRr5e_0 = G83uNX_24.KQgRr5e_0(str, i, i2, " \"<>^`{}|/\\?#", z2, false, false, true, null);
            if (m756KQgRr5e_0(KQgRr5e_0)) {
                return;
            }
            if (m757QxJ9d_1(KQgRr5e_0)) {
                m754KQgRr5e_0();
                return;
            }
            List<String> list = this.f1643KQgRr5e_0;
            if (list.get(list.size() - 1).isEmpty()) {
                List<String> list2 = this.f1643KQgRr5e_0;
                list2.set(list2.size() - 1, KQgRr5e_0);
            } else {
                this.f1643KQgRr5e_0.add(KQgRr5e_0);
            }
            if (z) {
                this.f1643KQgRr5e_0.add(BuildConfig.FLAVOR);
            }
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public final boolean m756KQgRr5e_0(String str) {
            return str.equals(".") || str.equalsIgnoreCase("%2e");
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public final void m754KQgRr5e_0() {
            List<String> list = this.f1643KQgRr5e_0;
            if (list.remove(list.size() - 1).isEmpty() && !this.f1643KQgRr5e_0.isEmpty()) {
                List<String> list2 = this.f1643KQgRr5e_0;
                list2.set(list2.size() - 1, BuildConfig.FLAVOR);
                return;
            }
            this.f1643KQgRr5e_0.add(BuildConfig.FLAVOR);
        }

        @Nullable
        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public static String m751KQgRr5e_0(String str, int i, int i2) {
            return XnFJ5_9.Ft6VRog_36.X6FRs_4.m728KQgRr5e_0(G83uNX_24.KQgRr5e_0(str, i, i2, false));
        }

        public static int KQgRr5e_0(String str, int i, int i2) {
            int parseInt;
            try {
                parseInt = Integer.parseInt(G83uNX_24.KQgRr5e_0(str, i, i2, BuildConfig.FLAVOR, false, false, false, true, null));
            } catch (NumberFormatException unused) {
            }
            if (parseInt <= 0 || parseInt > 65535) {
                return -1;
            }
            return parseInt;
        }
    }

    public static void QxJ9d_1(StringBuilder sb, List<String> list) {
        int size = list.size();
        for (int i = 0; i < size; i++) {
            sb.append('/');
            sb.append(list.get(i));
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public boolean m750KQgRr5e_0() {
        return this.f1640KQgRr5e_0.equals("https");
    }

    public int KQgRr5e_0() {
        return this.f1639KQgRr5e_0;
    }

    public static int KQgRr5e_0(String str) {
        if (str.equals("http")) {
            return 80;
        }
        return str.equals("https") ? 443 : -1;
    }

    public static G83uNX_24 QxJ9d_1(String str) {
        KQgRr5e_0 kQgRr5e_0 = new KQgRr5e_0();
        kQgRr5e_0.KQgRr5e_0(null, str);
        return kQgRr5e_0.m753KQgRr5e_0();
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public List<String> m749KQgRr5e_0() {
        int indexOf = this.f3397IFxWkV_5.indexOf(47, this.f1640KQgRr5e_0.length() + 3);
        String str = this.f3397IFxWkV_5;
        int KQgRr5e_02 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, indexOf, str.length(), "?#");
        ArrayList arrayList = new ArrayList();
        while (indexOf < KQgRr5e_02) {
            int i = indexOf + 1;
            int KQgRr5e_03 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(this.f3397IFxWkV_5, i, KQgRr5e_02, '/');
            arrayList.add(this.f3397IFxWkV_5.substring(i, KQgRr5e_03));
            indexOf = KQgRr5e_03;
        }
        return arrayList;
    }

    public static void KQgRr5e_0(StringBuilder sb, List<String> list) {
        int size = list.size();
        for (int i = 0; i < size; i += 2) {
            String str = list.get(i);
            String str2 = list.get(i + 1);
            if (i > 0) {
                sb.append('&');
            }
            sb.append(str);
            if (str2 != null) {
                sb.append('=');
                sb.append(str2);
            }
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static List<String> m743KQgRr5e_0(String str) {
        ArrayList arrayList = new ArrayList();
        int i = 0;
        while (i <= str.length()) {
            int indexOf = str.indexOf(38, i);
            if (indexOf == -1) {
                indexOf = str.length();
            }
            int indexOf2 = str.indexOf(61, i);
            if (indexOf2 != -1 && indexOf2 <= indexOf) {
                arrayList.add(str.substring(i, indexOf2));
                arrayList.add(str.substring(indexOf2 + 1, indexOf));
            } else {
                arrayList.add(str.substring(i, indexOf));
                arrayList.add(null);
            }
            i = indexOf + 1;
        }
        return arrayList;
    }

    @Nullable
    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public String m747KQgRr5e_0() {
        if (this.f3399X6FRs_4 == null) {
            return null;
        }
        return this.f3397IFxWkV_5.substring(this.f3397IFxWkV_5.indexOf(35) + 1);
    }

    @Nullable
    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public G83uNX_24 m746KQgRr5e_0(String str) {
        KQgRr5e_0 m745KQgRr5e_0 = m745KQgRr5e_0(str);
        if (m745KQgRr5e_0 != null) {
            return m745KQgRr5e_0.m753KQgRr5e_0();
        }
        return null;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public KQgRr5e_0 m744KQgRr5e_0() {
        KQgRr5e_0 kQgRr5e_0 = new KQgRr5e_0();
        kQgRr5e_0.f1642KQgRr5e_0 = this.f1640KQgRr5e_0;
        kQgRr5e_0.QxJ9d_1 = X6FRs_4();
        kQgRr5e_0.PGPF6hQ_2 = QxJ9d_1();
        kQgRr5e_0.f3400Mqv2r_3 = this.f3398Mqv2r_3;
        kQgRr5e_0.KQgRr5e_0 = this.f1639KQgRr5e_0 != KQgRr5e_0(this.f1640KQgRr5e_0) ? this.f1639KQgRr5e_0 : -1;
        kQgRr5e_0.f1643KQgRr5e_0.clear();
        kQgRr5e_0.f1643KQgRr5e_0.addAll(m749KQgRr5e_0());
        kQgRr5e_0.KQgRr5e_0(Mqv2r_3());
        kQgRr5e_0.f3401X6FRs_4 = m747KQgRr5e_0();
        return kQgRr5e_0;
    }

    @Nullable
    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public KQgRr5e_0 m745KQgRr5e_0(String str) {
        try {
            KQgRr5e_0 kQgRr5e_0 = new KQgRr5e_0();
            kQgRr5e_0.KQgRr5e_0(this, str);
            return kQgRr5e_0;
        } catch (IllegalArgumentException unused) {
            return null;
        }
    }

    public static String KQgRr5e_0(String str, boolean z) {
        return KQgRr5e_0(str, 0, str.length(), z);
    }

    public final List<String> KQgRr5e_0(List<String> list, boolean z) {
        int size = list.size();
        ArrayList arrayList = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            String str = list.get(i);
            arrayList.add(str != null ? KQgRr5e_0(str, z) : null);
        }
        return Collections.unmodifiableList(arrayList);
    }

    public static String KQgRr5e_0(String str, int i, int i2, boolean z) {
        for (int i3 = i; i3 < i2; i3++) {
            char charAt = str.charAt(i3);
            if (charAt == '%' || (charAt == '+' && z)) {
                Nm6q_10.X6FRs_4 x6FRs_4 = new Nm6q_10.X6FRs_4();
                x6FRs_4.KQgRr5e_0(str, i, i3);
                KQgRr5e_0(x6FRs_4, str, i3, i2, z);
                return x6FRs_4.QxJ9d_1();
            }
        }
        return str.substring(i, i2);
    }

    public static void KQgRr5e_0(Nm6q_10.X6FRs_4 x6FRs_4, String str, int i, int i2, boolean z) {
        int i3;
        while (i < i2) {
            int codePointAt = str.codePointAt(i);
            if (codePointAt == 37 && (i3 = i + 2) < i2) {
                int KQgRr5e_02 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str.charAt(i + 1));
                int KQgRr5e_03 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str.charAt(i3));
                if (KQgRr5e_02 != -1 && KQgRr5e_03 != -1) {
                    x6FRs_4.KQgRr5e_0((KQgRr5e_02 << 4) + KQgRr5e_03);
                    i = i3;
                }
                x6FRs_4.Mqv2r_3(codePointAt);
            } else {
                if (codePointAt == 43 && z) {
                    x6FRs_4.KQgRr5e_0(32);
                }
                x6FRs_4.Mqv2r_3(codePointAt);
            }
            i += Character.charCount(codePointAt);
        }
    }

    public static boolean KQgRr5e_0(String str, int i, int i2) {
        int i3 = i + 2;
        return i3 < i2 && str.charAt(i) == '%' && XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str.charAt(i + 1)) != -1 && XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str.charAt(i3)) != -1;
    }

    public static String KQgRr5e_0(String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, @Nullable Charset charset) {
        int i3 = i;
        while (i3 < i2) {
            int codePointAt = str.codePointAt(i3);
            if (codePointAt >= 32 && codePointAt != 127 && (codePointAt < 128 || !z4)) {
                if (str2.indexOf(codePointAt) == -1 && ((codePointAt != 37 || (z && (!z2 || KQgRr5e_0(str, i3, i2)))) && (codePointAt != 43 || !z3))) {
                    i3 += Character.charCount(codePointAt);
                }
            }
            Nm6q_10.X6FRs_4 x6FRs_4 = new Nm6q_10.X6FRs_4();
            x6FRs_4.KQgRr5e_0(str, i, i3);
            KQgRr5e_0(x6FRs_4, str, i3, i2, str2, z, z2, z3, z4, charset);
            return x6FRs_4.QxJ9d_1();
        }
        return str.substring(i, i2);
    }

    public static void KQgRr5e_0(Nm6q_10.X6FRs_4 x6FRs_4, String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, @Nullable Charset charset) {
        Nm6q_10.X6FRs_4 x6FRs_42 = null;
        while (i < i2) {
            int codePointAt = str.codePointAt(i);
            if (!z || (codePointAt != 9 && codePointAt != 10 && codePointAt != 12 && codePointAt != 13)) {
                if (codePointAt == 43 && z3) {
                    x6FRs_4.KQgRr5e_0(z ? "+" : "%2B");
                } else if (codePointAt >= 32 && codePointAt != 127 && ((codePointAt < 128 || !z4) && str2.indexOf(codePointAt) == -1 && (codePointAt != 37 || (z && (!z2 || KQgRr5e_0(str, i, i2)))))) {
                    x6FRs_4.Mqv2r_3(codePointAt);
                } else {
                    if (x6FRs_42 == null) {
                        x6FRs_42 = new Nm6q_10.X6FRs_4();
                    }
                    if (charset != null && !charset.equals(StandardCharsets.UTF_8)) {
                        x6FRs_42.KQgRr5e_0(str, i, Character.charCount(codePointAt) + i, charset);
                    } else {
                        x6FRs_42.Mqv2r_3(codePointAt);
                    }
                    while (!x6FRs_42.KQgRr5e_0()) {
                        int readByte = x6FRs_42.readByte() & 255;
                        x6FRs_4.KQgRr5e_0(37);
                        x6FRs_4.KQgRr5e_0((int) KQgRr5e_0[(readByte >> 4) & 15]);
                        x6FRs_4.KQgRr5e_0((int) KQgRr5e_0[readByte & 15]);
                    }
                }
            }
            i += Character.charCount(codePointAt);
        }
    }

    public static String KQgRr5e_0(String str, String str2, boolean z, boolean z2, boolean z3, boolean z4) {
        return KQgRr5e_0(str, 0, str.length(), str2, z, z2, z3, z4, null);
    }
}
