package p447.p448.p455;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.InterfaceC6540;
import p402.p403.C6560;
import p402.p411.p413.C6635;
import p447.p448.C6943;
import p447.p448.p455.C7043;
import p461.C7103;
import p461.C7108;
import p461.InterfaceC7107;
import p461.InterfaceC7129;

/* JADX INFO: renamed from: ސ.ޣ.އ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C7007 {

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final Map<C7108, Integer> f20391;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final C7007 f20392 = new C7007();

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final C7005[] f20390 = {new C7005(C7005.f20386, ""), new C7005(C7005.f20383, "GET"), new C7005(C7005.f20383, "POST"), new C7005(C7005.f20384, "/"), new C7005(C7005.f20384, "/index.html"), new C7005(C7005.f20385, "http"), new C7005(C7005.f20385, "https"), new C7005(C7005.f20382, "200"), new C7005(C7005.f20382, "204"), new C7005(C7005.f20382, "206"), new C7005(C7005.f20382, "304"), new C7005(C7005.f20382, "400"), new C7005(C7005.f20382, "404"), new C7005(C7005.f20382, "500"), new C7005("accept-charset", ""), new C7005("accept-encoding", "gzip, deflate"), new C7005("accept-language", ""), new C7005("accept-ranges", ""), new C7005("accept", ""), new C7005("access-control-allow-origin", ""), new C7005("age", ""), new C7005("allow", ""), new C7005("authorization", ""), new C7005("cache-control", ""), new C7005("content-disposition", ""), new C7005("content-encoding", ""), new C7005("content-language", ""), new C7005("content-length", ""), new C7005("content-location", ""), new C7005("content-range", ""), new C7005("content-type", ""), new C7005("cookie", ""), new C7005("date", ""), new C7005("etag", ""), new C7005("expect", ""), new C7005("expires", ""), new C7005("from", ""), new C7005("host", ""), new C7005("if-match", ""), new C7005("if-modified-since", ""), new C7005("if-none-match", ""), new C7005("if-range", ""), new C7005("if-unmodified-since", ""), new C7005("last-modified", ""), new C7005("link", ""), new C7005("location", ""), new C7005("max-forwards", ""), new C7005("proxy-authenticate", ""), new C7005("proxy-authorization", ""), new C7005("range", ""), new C7005("referer", ""), new C7005("refresh", ""), new C7005("retry-after", ""), new C7005("server", ""), new C7005("set-cookie", ""), new C7005("strict-transport-security", ""), new C7005("transfer-encoding", ""), new C7005("user-agent", ""), new C7005("vary", ""), new C7005("via", ""), new C7005("www-authenticate", "")};

    /* JADX INFO: renamed from: ސ.ޣ.އ.ހ$֏, reason: contains not printable characters */
    public static final class C7008 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final List<C7005> f20393;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final InterfaceC7107 f20394;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public C7005[] f20395;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public int f20396;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public int f20397;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public int f20398;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final int f20399;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public int f20400;

        public /* synthetic */ C7008(InterfaceC7129 interfaceC7129, int i, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
            i2 = (i3 & 4) != 0 ? i : i2;
            if (interfaceC7129 == null) {
                C6635.m9824("source");
                throw null;
            }
            this.f20399 = i;
            this.f20400 = i2;
            this.f20393 = new ArrayList();
            this.f20394 = C4303.m7076(interfaceC7129);
            this.f20395 = new C7005[8];
            this.f20396 = 7;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m10281(int i) {
            return this.f20396 + 1 + i;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m10282(int i, int i2) {
            int i3 = i & i2;
            if (i3 < i2) {
                return i3;
            }
            int i4 = 0;
            while (true) {
                int iM10141 = C6943.m10141(this.f20394.readByte(), 255);
                if ((iM10141 & 128) == 0) {
                    return i2 + (iM10141 << i4);
                }
                i2 += (iM10141 & 127) << i4;
                i4 += 7;
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10283() {
            C6560.m9786(this.f20395, (Object) null, 0, 0, 6);
            this.f20396 = this.f20395.length - 1;
            this.f20397 = 0;
            this.f20398 = 0;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10284(int i, C7005 c7005) {
            this.f20393.add(c7005);
            int i2 = c7005.f20387;
            if (i != -1) {
                C7005 c70052 = this.f20395[this.f20396 + 1 + i];
                if (c70052 == null) {
                    C6635.m9822();
                    throw null;
                }
                i2 -= c70052.f20387;
            }
            int i3 = this.f20400;
            if (i2 > i3) {
                m10283();
                return;
            }
            int iM10285 = m10285((this.f20398 + i2) - i3);
            if (i == -1) {
                int i4 = this.f20397 + 1;
                C7005[] c7005Arr = this.f20395;
                if (i4 > c7005Arr.length) {
                    C7005[] c7005Arr2 = new C7005[c7005Arr.length * 2];
                    System.arraycopy(c7005Arr, 0, c7005Arr2, c7005Arr.length, c7005Arr.length);
                    this.f20396 = this.f20395.length - 1;
                    this.f20395 = c7005Arr2;
                }
                int i5 = this.f20396;
                this.f20396 = i5 - 1;
                this.f20395[i5] = c7005;
                this.f20397++;
            } else {
                this.f20395[this.f20396 + 1 + i + iM10285 + i] = c7005;
            }
            this.f20398 += i2;
        }

        /* JADX WARN: Code restructure failed: missing block: B:13:0x002c, code lost:
        
            r5 = r4.f20395;
            r1 = r4.f20396;
            java.lang.System.arraycopy(r5, r1 + 1, r5, (r1 + 1) + r0, r4.f20397);
            r4.f20396 += r0;
         */
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final int m10285(int i) {
            int i2 = 0;
            if (i > 0) {
                int length = this.f20395.length;
                while (true) {
                    length--;
                    if (length < this.f20396 || i <= 0) {
                        break;
                    }
                    C7005 c7005 = this.f20395[length];
                    if (c7005 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    int i3 = c7005.f20387;
                    i -= i3;
                    this.f20398 -= i3;
                    this.f20397--;
                    i2++;
                }
            }
            return i2;
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final C7108 m10286() {
            int iM10141 = C6943.m10141(this.f20394.readByte(), 255);
            int i = 0;
            boolean z = (iM10141 & 128) == 128;
            long jM10282 = m10282(iM10141, 127);
            if (!z) {
                return this.f20394.mo10427(jM10282);
            }
            C7103 c7103 = new C7103();
            C7043 c7043 = C7043.f20548;
            InterfaceC7107 interfaceC7107 = this.f20394;
            if (interfaceC7107 == null) {
                C6635.m9824("source");
                throw null;
            }
            C7043.C7044 c7044 = C7043.f20547;
            int i2 = 0;
            for (long j = 0; j < jM10282; j++) {
                i = (i << 8) | (interfaceC7107.readByte() & 255);
                i2 += 8;
                while (i2 >= 8) {
                    int i3 = i2 - 8;
                    int i4 = (i >>> i3) & 255;
                    C7043.C7044[] c7044Arr = c7044.f20549;
                    if (c7044Arr == null) {
                        C6635.m9822();
                        throw null;
                    }
                    c7044 = c7044Arr[i4];
                    if (c7044 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    if (c7044.f20549 == null) {
                        c7103.writeByte(c7044.f20550);
                        i2 -= c7044.f20551;
                        c7044 = C7043.f20547;
                    } else {
                        i2 = i3;
                    }
                }
            }
            while (i2 > 0) {
                int i5 = (i << (8 - i2)) & 255;
                C7043.C7044[] c7044Arr2 = c7044.f20549;
                if (c7044Arr2 == null) {
                    C6635.m9822();
                    throw null;
                }
                C7043.C7044 c70442 = c7044Arr2[i5];
                if (c70442 == null) {
                    C6635.m9822();
                    throw null;
                }
                if (c70442.f20549 != null || c70442.f20551 > i2) {
                    break;
                }
                c7103.writeByte(c70442.f20550);
                i2 -= c70442.f20551;
                c7044 = C7043.f20547;
            }
            return c7103.m10426();
        }

        /* JADX WARN: Removed duplicated region for block: B:6:0x000d  */
        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final C7108 m10287(int i) throws IOException {
            boolean z;
            if (i >= 0) {
                C7007 c7007 = C7007.f20392;
                z = i <= C7007.f20390.length + (-1);
            }
            if (z) {
                C7007 c70072 = C7007.f20392;
                return C7007.f20390[i].f20388;
            }
            C7007 c70073 = C7007.f20392;
            int iM10281 = m10281(i - C7007.f20390.length);
            if (iM10281 >= 0) {
                C7005[] c7005Arr = this.f20395;
                if (iM10281 < c7005Arr.length) {
                    C7005 c7005 = c7005Arr[iM10281];
                    if (c7005 != null) {
                        return c7005.f20388;
                    }
                    C6635.m9822();
                    throw null;
                }
            }
            StringBuilder sbM4889 = C2803.m4889("Header index too large ");
            sbM4889.append(i + 1);
            throw new IOException(sbM4889.toString());
        }
    }

    /* JADX INFO: renamed from: ސ.ޣ.އ.ހ$ؠ, reason: contains not printable characters */
    public static final class C7009 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public int f20401;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public boolean f20402;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public int f20403;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public C7005[] f20404;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public int f20405;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public int f20406;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public int f20407;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public int f20408;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public final boolean f20409;

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public final C7103 f20410;

        public /* synthetic */ C7009(int i, boolean z, C7103 c7103, int i2, DefaultConstructorMarker defaultConstructorMarker) {
            i = (i2 & 1) != 0 ? 4096 : i;
            z = (i2 & 2) != 0 ? true : z;
            if (c7103 == null) {
                C6635.m9824("out");
                throw null;
            }
            this.f20408 = i;
            this.f20409 = z;
            this.f20410 = c7103;
            this.f20401 = Integer.MAX_VALUE;
            this.f20403 = i;
            this.f20404 = new C7005[8];
            this.f20405 = 7;
        }

        /* JADX WARN: Code restructure failed: missing block: B:17:0x0036, code lost:
        
            r6 = r5.f20404;
            r1 = r5.f20405;
            java.lang.System.arraycopy(r6, r1 + 1, r6, (r1 + 1) + r0, r5.f20406);
            r6 = r5.f20404;
            r1 = r5.f20405;
            java.util.Arrays.fill(r6, r1 + 1, (r1 + 1) + r0, (java.lang.Object) null);
            r5.f20405 += r0;
         */
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final int m10288(int i) {
            int i2 = 0;
            if (i > 0) {
                int length = this.f20404.length;
                while (true) {
                    length--;
                    if (length < this.f20405 || i <= 0) {
                        break;
                    }
                    C7005[] c7005Arr = this.f20404;
                    C7005 c7005 = c7005Arr[length];
                    if (c7005 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    i -= c7005.f20387;
                    int i3 = this.f20407;
                    C7005 c70052 = c7005Arr[length];
                    if (c70052 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    this.f20407 = i3 - c70052.f20387;
                    this.f20406--;
                    i2++;
                }
            }
            return i2;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10289() {
            C6560.m9786(this.f20404, (Object) null, 0, 0, 6);
            this.f20405 = this.f20404.length - 1;
            this.f20406 = 0;
            this.f20407 = 0;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10290(int i, int i2, int i3) {
            if (i < i2) {
                this.f20410.writeByte(i | i3);
                return;
            }
            this.f20410.writeByte(i3 | i2);
            int i4 = i - i2;
            while (i4 >= 128) {
                this.f20410.writeByte(128 | (i4 & 127));
                i4 >>>= 7;
            }
            this.f20410.writeByte(i4);
        }

        /* JADX WARN: Removed duplicated region for block: B:24:0x0076  */
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void m10291(List<C7005> list) {
            int length;
            int length2;
            if (list == null) {
                C6635.m9824("headerBlock");
                throw null;
            }
            if (this.f20402) {
                int i = this.f20401;
                if (i < this.f20403) {
                    m10290(i, 31, 32);
                }
                this.f20402 = false;
                this.f20401 = Integer.MAX_VALUE;
                m10290(this.f20403, 31, 32);
            }
            int size = list.size();
            for (int i2 = 0; i2 < size; i2++) {
                C7005 c7005 = list.get(i2);
                C7108 c7108Mo10453 = c7005.f20388.mo10453();
                C7108 c7108 = c7005.f20389;
                C7007 c7007 = C7007.f20392;
                Integer num = C7007.f20391.get(c7108Mo10453);
                if (num != null) {
                    length = num.intValue() + 1;
                    if (2 <= length && 7 >= length) {
                        C7007 c70072 = C7007.f20392;
                        if (C6635.m9825(C7007.f20390[length - 1].f20389, c7108)) {
                            length2 = length;
                        } else {
                            C7007 c70073 = C7007.f20392;
                            if (C6635.m9825(C7007.f20390[length].f20389, c7108)) {
                                length2 = length;
                                length++;
                            } else {
                                length2 = length;
                                length = -1;
                            }
                        }
                    }
                } else {
                    length = -1;
                    length2 = -1;
                }
                if (length == -1) {
                    int i3 = this.f20405 + 1;
                    int length3 = this.f20404.length;
                    while (true) {
                        if (i3 >= length3) {
                            break;
                        }
                        C7005 c70052 = this.f20404[i3];
                        if (c70052 == null) {
                            C6635.m9822();
                            throw null;
                        }
                        if (C6635.m9825(c70052.f20388, c7108Mo10453)) {
                            C7005 c70053 = this.f20404[i3];
                            if (c70053 == null) {
                                C6635.m9822();
                                throw null;
                            }
                            if (C6635.m9825(c70053.f20389, c7108)) {
                                int i4 = i3 - this.f20405;
                                C7007 c70074 = C7007.f20392;
                                length = C7007.f20390.length + i4;
                                break;
                            } else if (length2 == -1) {
                                int i5 = i3 - this.f20405;
                                C7007 c70075 = C7007.f20392;
                                length2 = i5 + C7007.f20390.length;
                            }
                        }
                        i3++;
                    }
                }
                if (length != -1) {
                    m10290(length, 127, 128);
                } else if (length2 == -1) {
                    this.f20410.writeByte(64);
                    m10293(c7108Mo10453);
                    m10293(c7108);
                    m10292(c7005);
                } else if (c7108Mo10453.m10448(C7005.f20381) && (!C6635.m9825(C7005.f20386, c7108Mo10453))) {
                    m10290(length2, 15, 0);
                    m10293(c7108);
                } else {
                    m10290(length2, 63, 64);
                    m10293(c7108);
                    m10292(c7005);
                }
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10292(C7005 c7005) {
            int i = c7005.f20387;
            int i2 = this.f20403;
            if (i > i2) {
                m10289();
                return;
            }
            m10288((this.f20407 + i) - i2);
            int i3 = this.f20406 + 1;
            C7005[] c7005Arr = this.f20404;
            if (i3 > c7005Arr.length) {
                C7005[] c7005Arr2 = new C7005[c7005Arr.length * 2];
                System.arraycopy(c7005Arr, 0, c7005Arr2, c7005Arr.length, c7005Arr.length);
                this.f20405 = this.f20404.length - 1;
                this.f20404 = c7005Arr2;
            }
            int i4 = this.f20405;
            this.f20405 = i4 - 1;
            this.f20404[i4] = c7005;
            this.f20406++;
            this.f20407 += i;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10293(C7108 c7108) {
            if (c7108 == null) {
                C6635.m9824("data");
                throw null;
            }
            if (this.f20409) {
                C7043 c7043 = C7043.f20548;
                int iMo10450 = c7108.mo10450();
                long j = 0;
                for (int i = 0; i < iMo10450; i++) {
                    j += (long) C7043.f20546[C6943.m10141(c7108.mo10443(i), 255)];
                }
                if (((int) ((j + ((long) 7)) >> 3)) < c7108.mo10450()) {
                    C7103 c7103 = new C7103();
                    C7043 c70432 = C7043.f20548;
                    int iMo104502 = c7108.mo10450();
                    long j2 = 0;
                    int i2 = 0;
                    for (int i3 = 0; i3 < iMo104502; i3++) {
                        int iM10141 = C6943.m10141(c7108.mo10443(i3), 255);
                        int i4 = C7043.f20545[iM10141];
                        byte b = C7043.f20546[iM10141];
                        j2 = (j2 << b) | ((long) i4);
                        i2 += b;
                        while (i2 >= 8) {
                            i2 -= 8;
                            c7103.writeByte((int) (j2 >> i2));
                        }
                    }
                    if (i2 > 0) {
                        c7103.writeByte((int) ((255 >>> i2) | (j2 << (8 - i2))));
                    }
                    C7108 c7108M10426 = c7103.m10426();
                    m10290(c7108M10426.mo10450(), 127, 128);
                    this.f20410.mo10422(c7108M10426);
                    return;
                }
            }
            m10290(c7108.mo10450(), 127, 0);
            this.f20410.mo10422(c7108);
        }
    }

    static {
        LinkedHashMap linkedHashMap = new LinkedHashMap(f20390.length);
        int length = f20390.length;
        for (int i = 0; i < length; i++) {
            if (!linkedHashMap.containsKey(f20390[i].f20388)) {
                linkedHashMap.put(f20390[i].f20388, Integer.valueOf(i));
            }
        }
        Map<C7108, Integer> mapUnmodifiableMap = Collections.unmodifiableMap(linkedHashMap);
        C6635.m9823((Object) mapUnmodifiableMap, "Collections.unmodifiableMap(result)");
        f20391 = mapUnmodifiableMap;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C7108 m10280(C7108 c7108) {
        if (c7108 == null) {
            C6635.m9824("name");
            throw null;
        }
        int iMo10450 = c7108.mo10450();
        for (int i = 0; i < iMo10450; i++) {
            byte b = (byte) 65;
            byte b2 = (byte) 90;
            byte bMo10443 = c7108.mo10443(i);
            if (b <= bMo10443 && b2 >= bMo10443) {
                StringBuilder sbM4889 = C2803.m4889("PROTOCOL_ERROR response malformed: mixed case name: ");
                sbM4889.append(c7108.m10454());
                throw new IOException(sbM4889.toString());
            }
        }
        return c7108;
    }
}
