package N1;

import b1.C0531c;
import java.io.EOFException;
import java.io.InterruptedIOException;
import java.util.concurrent.atomic.AtomicLong;
import x0.AbstractC1709a;

/* JADX INFO: renamed from: N1.h, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0207h implements T0.n, T0.o, g3.d {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f4546q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public long f4547r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public Object f4548s;

    public /* synthetic */ C0207h(int i, long j8, Object obj) {
        this.f4546q = i;
        this.f4547r = j8;
        this.f4548s = obj;
    }

    public void A(int i) {
        if (i < 64) {
            this.f4547r |= 1 << i;
        } else {
            t();
            ((C0207h) this.f4548s).A(i - 64);
        }
    }

    @Override // T0.n
    public void a() {
        ((T0.j) this.f4548s).f6430v = 0;
    }

    @Override // T0.n
    public void b(int i) {
        ((T0.j) this.f4548s).b(i);
    }

    @Override // T0.n
    public boolean c(byte[] bArr, int i, int i5, boolean z8) {
        return ((T0.j) this.f4548s).c(bArr, 0, i5, z8);
    }

    @Override // T0.n
    public long d() {
        return ((T0.j) this.f4548s).f6427s - this.f4547r;
    }

    @Override // T0.n
    public boolean f(byte[] bArr, int i, int i5, boolean z8) {
        return ((T0.j) this.f4548s).f(bArr, i, i5, z8);
    }

    @Override // T0.o
    public void h() {
        ((T0.o) this.f4548s).h();
    }

    @Override // T0.n
    public long i() {
        return ((T0.j) this.f4548s).i() - this.f4547r;
    }

    @Override // T0.o
    public T0.F j(int i, int i5) {
        return ((T0.o) this.f4548s).j(i, i5);
    }

    @Override // g3.d
    public void l(Exception exc) {
        ((AtomicLong) ((com.google.android.material.datepicker.c) this.f4548s).f10221t).set(this.f4547r);
    }

    @Override // T0.n
    public void n(byte[] bArr, int i, int i5) {
        ((T0.j) this.f4548s).f(bArr, i, i5, false);
    }

    @Override // T0.n
    public void o(int i) throws EOFException, InterruptedIOException {
        ((T0.j) this.f4548s).h(i, false);
    }

    @Override // u0.InterfaceC1571g
    public int p(byte[] bArr, int i, int i5) {
        return ((T0.j) this.f4548s).p(bArr, i, i5);
    }

    @Override // T0.n
    public long q() {
        return ((T0.j) this.f4548s).f6428t - this.f4547r;
    }

    public void r(int i) {
        if (i < 64) {
            this.f4547r &= ~(1 << i);
            return;
        }
        C0207h c0207h = (C0207h) this.f4548s;
        if (c0207h != null) {
            c0207h.r(i - 64);
        }
    }

    @Override // T0.n
    public void readFully(byte[] bArr, int i, int i5) throws EOFException, InterruptedIOException {
        ((T0.j) this.f4548s).c(bArr, i, i5, false);
    }

    public int s(int i) {
        C0207h c0207h = (C0207h) this.f4548s;
        if (c0207h == null) {
            return i >= 64 ? Long.bitCount(this.f4547r) : Long.bitCount(this.f4547r & ((1 << i) - 1));
        }
        if (i < 64) {
            return Long.bitCount(this.f4547r & ((1 << i) - 1));
        }
        return Long.bitCount(this.f4547r) + c0207h.s(i - 64);
    }

    public void t() {
        if (((C0207h) this.f4548s) == null) {
            this.f4548s = new C0207h();
        }
    }

    public String toString() {
        switch (this.f4546q) {
            case n4.u0.f15495q /* 0 */:
                if (((C0207h) this.f4548s) == null) {
                    return Long.toBinaryString(this.f4547r);
                }
                return ((C0207h) this.f4548s).toString() + "xx" + Long.toBinaryString(this.f4547r);
            default:
                return super.toString();
        }
    }

    public boolean u(int i) {
        if (i < 64) {
            return (this.f4547r & (1 << i)) != 0;
        }
        t();
        return ((C0207h) this.f4548s).u(i - 64);
    }

    @Override // T0.o
    public void v(T0.z zVar) {
        ((T0.o) this.f4548s).v(new C0531c(this, zVar, zVar));
    }

    public void w(int i, boolean z8) {
        if (i >= 64) {
            t();
            ((C0207h) this.f4548s).w(i - 64, z8);
            return;
        }
        long j8 = this.f4547r;
        boolean z9 = (Long.MIN_VALUE & j8) != 0;
        long j9 = (1 << i) - 1;
        this.f4547r = ((j8 & (~j9)) << 1) | (j8 & j9);
        if (z8) {
            A(i);
        } else {
            r(i);
        }
        if (z9 || ((C0207h) this.f4548s) != null) {
            t();
            ((C0207h) this.f4548s).w(0, z9);
        }
    }

    public k7.o x() {
        N0.c cVar = new N0.c(1);
        while (true) {
            String strK = ((x7.B) this.f4548s).K(this.f4547r);
            this.f4547r -= (long) strK.length();
            if (strK.length() == 0) {
                return cVar.i();
            }
            int iS = X6.e.S(strK, ':', 1, 4);
            if (iS != -1) {
                String strSubstring = strK.substring(0, iS);
                P6.g.d(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
                String strSubstring2 = strK.substring(iS + 1);
                P6.g.d(strSubstring2, "this as java.lang.String).substring(startIndex)");
                cVar.g(strSubstring, strSubstring2);
            } else if (strK.charAt(0) == ':') {
                String strSubstring3 = strK.substring(1);
                P6.g.d(strSubstring3, "this as java.lang.String).substring(startIndex)");
                cVar.g("", strSubstring3);
            } else {
                cVar.g("", strK);
            }
        }
    }

    public boolean y(int i) {
        if (i >= 64) {
            t();
            return ((C0207h) this.f4548s).y(i - 64);
        }
        long j8 = 1 << i;
        long j9 = this.f4547r;
        boolean z8 = (j9 & j8) != 0;
        long j10 = j9 & (~j8);
        this.f4547r = j10;
        long j11 = j8 - 1;
        this.f4547r = (j10 & j11) | Long.rotateRight((~j11) & j10, 1);
        C0207h c0207h = (C0207h) this.f4548s;
        if (c0207h != null) {
            if (c0207h.u(0)) {
                A(63);
            }
            ((C0207h) this.f4548s).y(0);
        }
        return z8;
    }

    public void z() {
        this.f4547r = 0L;
        C0207h c0207h = (C0207h) this.f4548s;
        if (c0207h != null) {
            c0207h.z();
        }
    }

    public /* synthetic */ C0207h(com.google.android.material.datepicker.c cVar, long j8) {
        this.f4546q = 4;
        this.f4548s = cVar;
        this.f4547r = j8;
    }

    public C0207h(T2.a aVar) {
        this.f4546q = 5;
        P2.w.f(aVar);
        this.f4548s = aVar;
    }

    public C0207h(x7.B b8) {
        this.f4546q = 6;
        P6.g.e(b8, "source");
        this.f4548s = b8;
        this.f4547r = 262144L;
    }

    public C0207h(T0.j jVar, long j8) {
        this.f4546q = 2;
        this.f4548s = jVar;
        AbstractC1709a.d(jVar.f6428t >= j8);
        this.f4547r = j8;
    }

    public C0207h() {
        this.f4546q = 0;
        this.f4547r = 0L;
    }
}
