package n4;

import androidx.recyclerview.widget.i0;
import java.io.Closeable;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import p4.C2730i;
import p4.EnumC2722a;
import p5.C2740j;
import p5.C2743m;

/* JADX INFO: renamed from: n4.d, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C2626d implements Closeable {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final Logger f21639d = Logger.getLogger(n.class.getName());

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final n f21640a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C2624b f21641b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final i0 f21642c;

    public C2626d(n nVar, C2624b c2624b) {
        Level level = Level.FINE;
        this.f21642c = new i0(9);
        this.f21640a = nVar;
        this.f21641b = c2624b;
    }

    public final void a(boolean z6, int i6, C2740j c2740j, int i7) {
        c2740j.getClass();
        this.f21642c.j(2, i6, c2740j, i7, z6);
        try {
            C2730i c2730i = this.f21641b.f21625a;
            synchronized (c2730i) {
                if (c2730i.f23034e) {
                    throw new IOException("closed");
                }
                c2730i.a(i6, i7, (byte) 0, z6 ? (byte) 1 : (byte) 0);
                if (i7 > 0) {
                    c2730i.f23030a.write(c2740j, i7);
                }
            }
        } catch (IOException e6) {
            this.f21640a.p(e6);
        }
    }

    public final void b(EnumC2722a enumC2722a, byte[] bArr) {
        C2624b c2624b = this.f21641b;
        this.f21642c.k(2, 0, enumC2722a, C2743m.l(bArr));
        try {
            c2624b.c(enumC2722a, bArr);
            c2624b.flush();
        } catch (IOException e6) {
            this.f21640a.p(e6);
        }
    }

    public final void c(int i6, int i7, boolean z6) {
        i0 i0Var = this.f21642c;
        if (z6) {
            long j4 = (4294967295L & ((long) i7)) | (((long) i6) << 32);
            if (i0Var.h()) {
                ((Logger) i0Var.f13105b).log((Level) i0Var.f13106c, "OUTBOUND PING: ack=true bytes=" + j4);
            }
        } else {
            i0Var.l(2, (4294967295L & ((long) i7)) | (((long) i6) << 32));
        }
        try {
            this.f21641b.d(i6, i7, z6);
        } catch (IOException e6) {
            this.f21640a.p(e6);
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        try {
            this.f21641b.close();
        } catch (IOException e6) {
            f21639d.log(e6.getClass().equals(IOException.class) ? Level.FINE : Level.INFO, "Failed closing connection", (Throwable) e6);
        }
    }

    public final void d(int i6, EnumC2722a enumC2722a) {
        this.f21642c.m(2, i6, enumC2722a);
        try {
            this.f21641b.f(i6, enumC2722a);
        } catch (IOException e6) {
            this.f21640a.p(e6);
        }
    }

    public final void f(int i6, long j4) {
        this.f21642c.o(2, i6, j4);
        try {
            this.f21641b.i(i6, j4);
        } catch (IOException e6) {
            this.f21640a.p(e6);
        }
    }

    public final void flush() {
        try {
            this.f21641b.flush();
        } catch (IOException e6) {
            this.f21640a.p(e6);
        }
    }
}
