package o;

import com.google.android.gms.common.api.Api;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class NF implements Closeable {

    /* renamed from: o, reason: collision with root package name */
    public static final Logger f253o = Logger.getLogger(AF.class.getName());
    public final InterfaceC1687kf l;
    public final MF m;
    public final C2320rF n;

    public NF(InterfaceC1687kf interfaceC1687kf) {
        this.l = interfaceC1687kf;
        MF mf = new MF(interfaceC1687kf);
        this.m = mf;
        this.n = new C2320rF(mf);
    }

    /* JADX WARN: Code restructure failed: missing block: B:151:0x0241, code lost:
    
        throw new java.io.IOException(o.AbstractC0126Ew.j(r11, "PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: "));
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean b(boolean r23, o.FF r24) throws java.io.IOException {
        /*
            Method dump skipped, instructions count: 878
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.NF.b(boolean, o.FF):boolean");
    }

    /* JADX WARN: Code restructure failed: missing block: B:64:0x0106, code lost:
    
        if (r8 == false) goto L66;
     */
    /* JADX WARN: Code restructure failed: missing block: B:65:0x0108, code lost:
    
        r4.i(o.AbstractC2264qi0.b, true);
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void c(o.FF r19, int r20, int r21, int r22) throws java.io.IOException {
        /*
            Method dump skipped, instructions count: 293
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.NF.c(o.FF, int, int, int):void");
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        this.l.close();
    }

    public final List d(int i, int i2, int i3, int i4) throws IOException {
        MF mf = this.m;
        mf.p = i;
        mf.m = i;
        mf.q = i2;
        mf.n = i3;
        mf.f229o = i4;
        C2320rF c2320rF = this.n;
        C1822m00 c1822m00 = c2320rF.c;
        ArrayList arrayList = c2320rF.b;
        while (!c1822m00.b()) {
            byte b = c1822m00.readByte();
            byte[] bArr = AbstractC2264qi0.a;
            int i5 = b & 255;
            if (i5 == 128) {
                throw new IOException("index == 0");
            }
            if ((b & 128) == 128) {
                int iE = c2320rF.e(i5, 127);
                int i6 = iE - 1;
                if (i6 >= 0) {
                    JE[] jeArr = AbstractC2510tF.a;
                    if (i6 <= jeArr.length - 1) {
                        arrayList.add(jeArr[i6]);
                    }
                }
                int length = c2320rF.e + 1 + (i6 - AbstractC2510tF.a.length);
                if (length >= 0) {
                    JE[] jeArr2 = c2320rF.d;
                    if (length < jeArr2.length) {
                        arrayList.add(jeArr2[length]);
                    }
                }
                throw new IOException(AbstractC0126Ew.j(iE, "Header index too large "));
            }
            if (i5 == 64) {
                JE[] jeArr3 = AbstractC2510tF.a;
                C0135Ff c0135FfD = c2320rF.d();
                AbstractC2510tF.a(c0135FfD);
                c2320rF.c(new JE(c0135FfD, c2320rF.d()));
            } else if ((b & 64) == 64) {
                c2320rF.c(new JE(c2320rF.b(c2320rF.e(i5, 63) - 1), c2320rF.d()));
            } else if ((b & 32) == 32) {
                int iE2 = c2320rF.e(i5, 31);
                c2320rF.a = iE2;
                if (iE2 < 0 || iE2 > 4096) {
                    throw new IOException("Invalid dynamic table size update " + c2320rF.a);
                }
                int i7 = c2320rF.g;
                if (iE2 < i7) {
                    if (iE2 == 0) {
                        AbstractC2219q9.P(c2320rF.d, null);
                        c2320rF.e = c2320rF.d.length - 1;
                        c2320rF.f = 0;
                        c2320rF.g = 0;
                    } else {
                        c2320rF.a(i7 - iE2);
                    }
                }
            } else if (i5 == 16 || i5 == 0) {
                JE[] jeArr4 = AbstractC2510tF.a;
                C0135Ff c0135FfD2 = c2320rF.d();
                AbstractC2510tF.a(c0135FfD2);
                arrayList.add(new JE(c0135FfD2, c2320rF.d()));
            } else {
                arrayList.add(new JE(c2320rF.b(c2320rF.e(i5, 15) - 1), c2320rF.d()));
            }
        }
        List listT0 = AbstractC3117zi.t0(arrayList);
        arrayList.clear();
        return listT0;
    }

    public final void f(FF ff, int i, int i2, int i3) throws IOException {
        if (i3 == 0) {
            throw new IOException("PROTOCOL_ERROR: TYPE_HEADERS streamId == 0");
        }
        int i4 = 0;
        int i5 = 1;
        boolean z = (i2 & 1) != 0;
        if ((i2 & 8) != 0) {
            byte b = this.l.readByte();
            byte[] bArr = AbstractC2264qi0.a;
            i4 = b & 255;
        }
        if ((i2 & 32) != 0) {
            InterfaceC1687kf interfaceC1687kf = this.l;
            interfaceC1687kf.readInt();
            interfaceC1687kf.readByte();
            byte[] bArr2 = AbstractC2264qi0.a;
            i -= 5;
        }
        List listD = d(AbstractC0752ap.V(i, i2, i4), i4, i2, i3);
        KF kf = ff.m;
        if (i3 != 0 && (i3 & 1) == 0) {
            kf.t.c(new HF(kf.n + '[' + i3 + "] onHeaders", kf, i3, listD, z), 0L);
            return;
        }
        synchronized (kf) {
            RF rfC = kf.c(i3);
            if (rfC != null) {
                rfC.i(AbstractC2264qi0.u(listD), z);
                return;
            }
            if (kf.q) {
                return;
            }
            if (i3 <= kf.f190o) {
                return;
            }
            if (i3 % 2 == kf.p % 2) {
                return;
            }
            RF rf = new RF(i3, kf, false, z, AbstractC2264qi0.u(listD));
            kf.f190o = i3;
            kf.m.put(Integer.valueOf(i3), rf);
            kf.r.e().c(new DF(i5, kf, rf, kf.n + '[' + i3 + "] onStream"), 0L);
        }
    }

    public final void g(FF ff, int i, int i2, int i3) throws IOException {
        int i4;
        if (i3 == 0) {
            throw new IOException("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0");
        }
        if ((i2 & 8) != 0) {
            byte b = this.l.readByte();
            byte[] bArr = AbstractC2264qi0.a;
            i4 = b & 255;
        } else {
            i4 = 0;
        }
        int i5 = this.l.readInt() & Api.BaseClientBuilder.API_PRIORITY_OTHER;
        List listD = d(AbstractC0752ap.V(i - 4, i2, i4), i4, i2, i3);
        KF kf = ff.m;
        synchronized (kf) {
            if (kf.J.contains(Integer.valueOf(i5))) {
                kf.l(i5, 2);
                return;
            }
            kf.J.add(Integer.valueOf(i5));
            kf.t.c(new HF(kf.n + '[' + i5 + "] onRequest", kf, i5, listD), 0L);
        }
    }
}
