package defpackage;

import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;

/* JADX INFO: renamed from: ᴵﾞ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2200 implements Closeable {

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public static final Logger f8739 = Logger.getLogger(AbstractC3401.class.getName());

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final InterfaceC0048 f8740;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public int f8741;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C4903 f8742;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public boolean f8743;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final C0446 f8744;

    public C2200(InterfaceC0048 interfaceC0048) {
        this.f8740 = interfaceC0048;
        C4903 c4903 = new C4903();
        this.f8742 = c4903;
        this.f8741 = 16384;
        this.f8744 = new C0446(c4903);
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        synchronized (this) {
            this.f8743 = true;
            this.f8740.close();
        }
    }

    public final void flush() {
        synchronized (this) {
            if (this.f8743) {
                throw new IOException("closed");
            }
            this.f8740.flush();
        }
    }

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public final void m5767(int i, int i2) {
        synchronized (this) {
            if (this.f8743) {
                throw new IOException("closed");
            }
            if (AbstractC3653.m8218(i2) == -1) {
                throw new IllegalArgumentException("Failed requirement.");
            }
            m5772(i, 4, 3, 0);
            this.f8740.writeInt(AbstractC3653.m8218(i2));
            this.f8740.flush();
        }
    }

    /* JADX INFO: renamed from: ˏːˆ, reason: contains not printable characters */
    public final void m5768(boolean z, int i, ArrayList arrayList) {
        synchronized (this) {
            if (this.f8743) {
                throw new IOException("closed");
            }
            this.f8744.m1849(arrayList);
            long j = this.f8742.f18672;
            long jMin = Math.min(this.f8741, j);
            int i2 = j == jMin ? 4 : 0;
            if (z) {
                i2 |= 1;
            }
            m5772(i, (int) jMin, 1, i2);
            this.f8740.mo1843(this.f8742, jMin);
            if (j > jMin) {
                long j2 = j - jMin;
                while (j2 > 0) {
                    long jMin2 = Math.min(this.f8741, j2);
                    j2 -= jMin2;
                    m5772(i, (int) jMin2, 9, j2 == 0 ? 4 : 0);
                    this.f8740.mo1843(this.f8742, jMin2);
                }
            }
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m5769(boolean z, int i, C4903 c4903, int i2) {
        synchronized (this) {
            if (this.f8743) {
                throw new IOException("closed");
            }
            m5772(i, i2, 0, z ? 1 : 0);
            if (i2 > 0) {
                this.f8740.mo1843(c4903, i2);
            }
        }
    }

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final void m5770(long j, int i) {
        synchronized (this) {
            try {
                if (this.f8743) {
                    throw new IOException("closed");
                }
                if (j == 0 || j > 2147483647L) {
                    throw new IllegalArgumentException(("windowSizeIncrement == 0 || windowSizeIncrement > 0x7fffffffL: " + j).toString());
                }
                Logger logger = f8739;
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine(AbstractC3401.m7802(i, 4, j, false));
                }
                m5772(i, 4, 8, 0);
                this.f8740.writeInt((int) j);
                this.f8740.flush();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final void m5771(int i, int i2, boolean z) {
        synchronized (this) {
            if (this.f8743) {
                throw new IOException("closed");
            }
            m5772(0, 8, 6, z ? 1 : 0);
            this.f8740.writeInt(i);
            this.f8740.writeInt(i2);
            this.f8740.flush();
        }
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final void m5772(int i, int i2, int i3, int i4) {
        if (i3 != 8) {
            Level level = Level.FINE;
            Logger logger = f8739;
            if (logger.isLoggable(level)) {
                logger.fine(AbstractC3401.m7801(false, i, i2, i3, i4));
            }
        }
        if (i2 > this.f8741) {
            throw new IllegalArgumentException(("FRAME_SIZE_ERROR length > " + this.f8741 + ": " + i2).toString());
        }
        if ((Integer.MIN_VALUE & i) != 0) {
            ᵕᵩʽᵲ.ᵱᵽʡᵚ(AbstractC2704.m6517(i, "reserved bit set: "));
            return;
        }
        byte[] bArr = AbstractC1701.f6716;
        InterfaceC0048 interfaceC0048 = this.f8740;
        interfaceC0048.writeByte((i2 >>> 16) & 255);
        interfaceC0048.writeByte((i2 >>> 8) & 255);
        interfaceC0048.writeByte(i2 & 255);
        interfaceC0048.writeByte(i3 & 255);
        interfaceC0048.writeByte(i4 & 255);
        interfaceC0048.writeInt(i & Integer.MAX_VALUE);
    }

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public final void m5773(byte[] bArr, int i, int i2) {
        synchronized (this) {
            if (this.f8743) {
                throw new IOException("closed");
            }
            if (AbstractC3653.m8218(i2) == -1) {
                throw new IllegalArgumentException("errorCode.httpCode == -1");
            }
            m5772(0, bArr.length + 8, 7, 0);
            this.f8740.writeInt(i);
            this.f8740.writeInt(AbstractC3653.m8218(i2));
            if (bArr.length != 0) {
                this.f8740.write(bArr);
            }
            this.f8740.flush();
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m5774(C2753 c2753) {
        synchronized (this) {
            try {
                if (this.f8743) {
                    throw new IOException("closed");
                }
                int i = this.f8741;
                int i2 = c2753.f10578;
                if ((i2 & 32) != 0) {
                    i = c2753.f10577[5];
                }
                this.f8741 = i;
                if (((i2 & 2) != 0 ? c2753.f10577[1] : -1) != -1) {
                    C0446 c0446 = this.f8744;
                    int iMin = Math.min((i2 & 2) != 0 ? c2753.f10577[1] : -1, 16384);
                    int i3 = c0446.f2442;
                    if (i3 != iMin) {
                        if (iMin < i3) {
                            c0446.f2436 = Math.min(c0446.f2436, iMin);
                        }
                        c0446.f2438 = true;
                        c0446.f2442 = iMin;
                        int i4 = c0446.f2437;
                        if (iMin < i4) {
                            if (iMin == 0) {
                                C5511[] c5511Arr = c0446.f2439;
                                Arrays.fill(c5511Arr, 0, c5511Arr.length, (Object) null);
                                c0446.f2443 = c0446.f2439.length - 1;
                                c0446.f2441 = 0;
                                c0446.f2437 = 0;
                            } else {
                                c0446.m1848(i4 - iMin);
                            }
                        }
                    }
                }
                m5772(0, 0, 4, 1);
                this.f8740.flush();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final void m5775(C2753 c2753) {
        synchronized (this) {
            try {
                if (this.f8743) {
                    throw new IOException("closed");
                }
                m5772(0, Integer.bitCount(c2753.f10578) * 6, 4, 0);
                for (int i = 0; i < 10; i++) {
                    boolean z = true;
                    if (((1 << i) & c2753.f10578) == 0) {
                        z = false;
                    }
                    if (z) {
                        this.f8740.writeShort(i);
                        this.f8740.writeInt(c2753.f10577[i]);
                    }
                }
                this.f8740.flush();
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
