package 㿎.ሽ.㿎;

import androidx.recyclerview.widget.RecyclerView;
import com.appsflyer.share.Constants;
import com.facebook.places.model.PlaceFields;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import okio.ByteString;
import ඓ.K.K.K.C1293;
import ᨨ.AbstractC1494;
import ᨨ.AbstractC1496;
import ᨨ.C1486;
import ᨨ.C1492;
import 㿎.ሽ.C2540;

/* renamed from: 㿎.ሽ.㿎.ῲ  reason: contains not printable characters */
/* compiled from: Hpack */
public final class C2608 {

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final Map<ByteString, Integer> f8783;

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

    static {
        int i = 0;
        LinkedHashMap linkedHashMap = new LinkedHashMap(f8784.length);
        while (true) {
            C2614[] kArr = f8784;
            if (i < kArr.length) {
                if (!linkedHashMap.containsKey(kArr[i].f8821)) {
                    linkedHashMap.put(f8784[i].f8821, Integer.valueOf(i));
                }
                i++;
            } else {
                f8783 = Collections.unmodifiableMap(linkedHashMap);
                return;
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static ByteString m6861(ByteString byteString) throws IOException {
        int size = byteString.size();
        for (int i = 0; i < size; i++) {
            byte b = byteString.getByte(i);
            if (b >= 65 && b <= 90) {
                StringBuilder r1 = C1293.m3416("PROTOCOL_ERROR response malformed: mixed case name: ");
                r1.append(byteString.utf8());
                throw new IOException(r1.toString());
            }
        }
        return byteString;
    }

    /* renamed from: 㿎.ሽ.㿎.ῲ$ῲ  reason: contains not printable characters */
    /* compiled from: Hpack */
    public static final class C2609 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public int f8785 = Integer.MAX_VALUE;

        /* renamed from: ඓ  reason: contains not printable characters */
        public int f8786 = RecyclerView.AbstractC0269.FLAG_APPEARED_IN_PRE_LAYOUT;

        /* renamed from: ᨨ  reason: contains not printable characters */
        public int f8787 = 0;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final boolean f8788 = true;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public int f8789 = (this.f8791.length - 1);

        /* renamed from: K  reason: contains not printable characters */
        public final C1492 f8790;

        /* renamed from: 㴹  reason: contains not printable characters */
        public C2614[] f8791 = new C2614[8];

        /* renamed from: 㸾  reason: contains not printable characters */
        public boolean f8792;

        /* renamed from: 㿎  reason: contains not printable characters */
        public int f8793 = 0;

        public C2609(C1492 r2) {
            this.f8790 = r2;
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public void m6862(int i) {
            int min = Math.min(i, 16384);
            int i2 = this.f8786;
            if (i2 != min) {
                if (min < i2) {
                    this.f8785 = Math.min(this.f8785, min);
                }
                this.f8792 = true;
                this.f8786 = min;
                int i3 = this.f8786;
                int i4 = this.f8787;
                if (i3 >= i4) {
                    return;
                }
                if (i3 == 0) {
                    m6864();
                } else {
                    m6863(i4 - i3);
                }
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m6864() {
            Arrays.fill(this.f8791, (Object) null);
            this.f8789 = this.f8791.length - 1;
            this.f8793 = 0;
            this.f8787 = 0;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final int m6863(int i) {
            int i2 = 0;
            if (i > 0) {
                int length = this.f8791.length;
                while (true) {
                    length--;
                    if (length < this.f8789 || i <= 0) {
                        C2614[] kArr = this.f8791;
                        int i3 = this.f8789;
                        System.arraycopy(kArr, i3 + 1, kArr, i3 + 1 + i2, this.f8793);
                        C2614[] kArr2 = this.f8791;
                        int i4 = this.f8789;
                        Arrays.fill(kArr2, i4 + 1, i4 + 1 + i2, (Object) null);
                        this.f8789 += i2;
                    } else {
                        C2614[] kArr3 = this.f8791;
                        i -= kArr3[length].f8819;
                        this.f8787 -= kArr3[length].f8819;
                        this.f8793--;
                        i2++;
                    }
                }
                C2614[] kArr4 = this.f8791;
                int i32 = this.f8789;
                System.arraycopy(kArr4, i32 + 1, kArr4, i32 + 1 + i2, this.f8793);
                C2614[] kArr22 = this.f8791;
                int i42 = this.f8789;
                Arrays.fill(kArr22, i42 + 1, i42 + 1 + i2, (Object) null);
                this.f8789 += i2;
            }
            return i2;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m6868(C2614 k) {
            int i = k.f8819;
            int i2 = this.f8786;
            if (i > i2) {
                m6864();
                return;
            }
            m6863((this.f8787 + i) - i2);
            int i3 = this.f8793 + 1;
            C2614[] kArr = this.f8791;
            if (i3 > kArr.length) {
                C2614[] kArr2 = new C2614[(kArr.length * 2)];
                System.arraycopy(kArr, 0, kArr2, kArr.length, kArr.length);
                this.f8789 = this.f8791.length - 1;
                this.f8791 = kArr2;
            }
            int i4 = this.f8789;
            this.f8789 = i4 - 1;
            this.f8791[i4] = k;
            this.f8793++;
            this.f8787 += i;
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6866(List<C2614> list) throws IOException {
            int i;
            int i2;
            if (this.f8792) {
                int i3 = this.f8785;
                if (i3 < this.f8786) {
                    m6865(i3, 31, 32);
                }
                this.f8792 = false;
                this.f8785 = Integer.MAX_VALUE;
                m6865(this.f8786, 31, 32);
            }
            int size = list.size();
            for (int i4 = 0; i4 < size; i4++) {
                C2614 k = list.get(i4);
                ByteString asciiLowercase = k.f8821.toAsciiLowercase();
                ByteString byteString = k.f8820;
                Integer num = C2608.f8783.get(asciiLowercase);
                if (num != null) {
                    i2 = num.intValue() + 1;
                    if (i2 > 1 && i2 < 8) {
                        if (C2540.m6654(C2608.f8784[i2 - 1].f8820, byteString)) {
                            i = i2;
                        } else if (C2540.m6654(C2608.f8784[i2].f8820, byteString)) {
                            i = i2;
                            i2++;
                        }
                    }
                    i = i2;
                    i2 = -1;
                } else {
                    i2 = -1;
                    i = -1;
                }
                if (i2 == -1) {
                    int i5 = this.f8789 + 1;
                    int length = this.f8791.length;
                    while (true) {
                        if (i5 >= length) {
                            break;
                        }
                        if (C2540.m6654(this.f8791[i5].f8821, asciiLowercase)) {
                            if (C2540.m6654(this.f8791[i5].f8820, byteString)) {
                                i2 = C2608.f8784.length + (i5 - this.f8789);
                                break;
                            } else if (i == -1) {
                                i = (i5 - this.f8789) + C2608.f8784.length;
                            }
                        }
                        i5++;
                    }
                }
                if (i2 != -1) {
                    m6865(i2, 127, 128);
                } else if (i == -1) {
                    this.f8790.writeByte(64);
                    m6867(asciiLowercase);
                    m6867(byteString);
                    m6868(k);
                } else if (!asciiLowercase.startsWith(C2614.f8817) || C2614.f8814.equals(asciiLowercase)) {
                    m6865(i, 63, 64);
                    m6867(byteString);
                    m6868(k);
                } else {
                    m6865(i, 15, 0);
                    m6867(byteString);
                }
            }
        }

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

        /* renamed from: K  reason: contains not printable characters */
        public void m6867(ByteString byteString) throws IOException {
            if (!this.f8788 || C2616.f8826.m6887(byteString) >= byteString.size()) {
                m6865(byteString.size(), 127, 0);
                this.f8790.m3795(byteString);
                return;
            }
            C1492 r0 = new C1492();
            C2616.f8826.m6888(byteString, r0);
            ByteString r4 = r0.m3772();
            m6865(r4.size(), 127, 128);
            this.f8790.m3795(r4);
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ῲ$K  reason: contains not printable characters */
    /* compiled from: Hpack */
    public static final class C2610 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final int f8794;

        /* renamed from: ඓ  reason: contains not printable characters */
        public C2614[] f8795 = new C2614[8];

        /* renamed from: ῲ  reason: contains not printable characters */
        public final AbstractC1496 f8796;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public int f8797 = 0;

        /* renamed from: K  reason: contains not printable characters */
        public final List<C2614> f8798 = new ArrayList();

        /* renamed from: 㴹  reason: contains not printable characters */
        public int f8799 = (this.f8795.length - 1);

        /* renamed from: 㸾  reason: contains not printable characters */
        public int f8800;

        /* renamed from: 㿎  reason: contains not printable characters */
        public int f8801 = 0;

        public C2610(int i, AbstractC1494 r3) {
            this.f8794 = i;
            this.f8800 = i;
            this.f8796 = C1486.m3741(r3);
        }

        /* renamed from: ʬ  reason: contains not printable characters */
        public final ByteString m6870(int i) throws IOException {
            if (i >= 0 && i <= C2608.f8784.length + -1) {
                return C2608.f8784[i].f8821;
            }
            int r0 = m6873(i - C2608.f8784.length);
            if (r0 >= 0) {
                C2614[] kArr = this.f8795;
                if (r0 < kArr.length) {
                    return kArr[r0].f8821;
                }
            }
            StringBuilder r1 = C1293.m3416("Header index too large ");
            r1.append(i + 1);
            throw new IOException(r1.toString());
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public final int m6871(int i) {
            int i2 = 0;
            if (i > 0) {
                int length = this.f8795.length;
                while (true) {
                    length--;
                    if (length < this.f8799 || i <= 0) {
                        C2614[] kArr = this.f8795;
                        int i3 = this.f8799;
                        System.arraycopy(kArr, i3 + 1, kArr, i3 + 1 + i2, this.f8797);
                        this.f8799 += i2;
                    } else {
                        C2614[] kArr2 = this.f8795;
                        i -= kArr2[length].f8819;
                        this.f8801 -= kArr2[length].f8819;
                        this.f8797--;
                        i2++;
                    }
                }
                C2614[] kArr3 = this.f8795;
                int i32 = this.f8799;
                System.arraycopy(kArr3, i32 + 1, kArr3, i32 + 1 + i2, this.f8797);
                this.f8799 += i2;
            }
            return i2;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m6875() {
            Arrays.fill(this.f8795, (Object) null);
            this.f8799 = this.f8795.length - 1;
            this.f8797 = 0;
            this.f8801 = 0;
        }

        /* renamed from: 㸾  reason: contains not printable characters */
        public final boolean m6877(int i) {
            return i >= 0 && i <= C2608.f8784.length - 1;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final int m6873(int i) {
            return this.f8799 + 1 + i;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m6876(int i, C2614 k) {
            this.f8798.add(k);
            int i2 = k.f8819;
            if (i != -1) {
                i2 -= this.f8795[(this.f8799 + 1) + i].f8819;
            }
            int i3 = this.f8800;
            if (i2 > i3) {
                m6875();
                return;
            }
            int r2 = m6871((this.f8801 + i2) - i3);
            if (i == -1) {
                int i4 = this.f8797 + 1;
                C2614[] kArr = this.f8795;
                if (i4 > kArr.length) {
                    C2614[] kArr2 = new C2614[(kArr.length * 2)];
                    System.arraycopy(kArr, 0, kArr2, kArr.length, kArr.length);
                    this.f8799 = this.f8795.length - 1;
                    this.f8795 = kArr2;
                }
                int i5 = this.f8799;
                this.f8799 = i5 - 1;
                this.f8795[i5] = k;
                this.f8797++;
            } else {
                this.f8795[this.f8799 + 1 + i + r2 + i] = k;
            }
            this.f8801 += i2;
        }

        /* renamed from: ʬ  reason: contains not printable characters */
        public ByteString m6869() throws IOException {
            int readByte = this.f8796.readByte() & 255;
            boolean z = (readByte & 128) == 128;
            int r0 = m6874(readByte, 127);
            if (z) {
                return ByteString.of(C2616.f8826.m6889(this.f8796.m3822((long) r0)));
            }
            return this.f8796.m3813((long) r0);
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public List<C2614> m6872() {
            ArrayList arrayList = new ArrayList(this.f8798);
            this.f8798.clear();
            return arrayList;
        }

        /* renamed from: K  reason: contains not printable characters */
        public int m6874(int i, int i2) throws IOException {
            int i3 = i & i2;
            if (i3 < i2) {
                return i3;
            }
            int i4 = 0;
            while (true) {
                int readByte = this.f8796.readByte() & 255;
                if ((readByte & 128) == 0) {
                    return i2 + (readByte << i4);
                }
                i2 += (readByte & 127) << i4;
                i4 += 7;
            }
        }
    }
}
