package N1;

/* JADX INFO: renamed from: N1.g, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0206g implements K {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final K f4537q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f4538r = 0;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f4539s = -1;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f4540t = -1;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Object f4541u = null;

    public C0206g(K k8) {
        this.f4537q = k8;
    }

    public final void a() {
        int i = this.f4538r;
        if (i == 0) {
            return;
        }
        K k8 = this.f4537q;
        if (i == 1) {
            k8.j(this.f4539s, this.f4540t);
        } else if (i == 2) {
            k8.h(this.f4539s, this.f4540t);
        } else if (i == 3) {
            k8.m(this.f4539s, this.f4540t, this.f4541u);
        }
        this.f4541u = null;
        this.f4538r = 0;
    }

    @Override // N1.K
    public final void h(int i, int i5) {
        int i8;
        if (this.f4538r == 2 && (i8 = this.f4539s) >= i && i8 <= i + i5) {
            this.f4540t += i5;
            this.f4539s = i;
        } else {
            a();
            this.f4539s = i;
            this.f4540t = i5;
            this.f4538r = 2;
        }
    }

    @Override // N1.K
    public final void j(int i, int i5) {
        int i8;
        if (this.f4538r == 1 && i >= (i8 = this.f4539s)) {
            int i9 = this.f4540t;
            if (i <= i8 + i9) {
                this.f4540t = i9 + i5;
                this.f4539s = Math.min(i, i8);
                return;
            }
        }
        a();
        this.f4539s = i;
        this.f4540t = i5;
        this.f4538r = 1;
    }

    @Override // N1.K
    public final void k(int i, int i5) {
        a();
        this.f4537q.k(i, i5);
    }

    @Override // N1.K
    public final void m(int i, int i5, Object obj) {
        int i8;
        int i9;
        int i10;
        if (this.f4538r == 3 && i <= (i9 = this.f4540t + (i8 = this.f4539s)) && (i10 = i + i5) >= i8 && this.f4541u == obj) {
            this.f4539s = Math.min(i, i8);
            this.f4540t = Math.max(i9, i10) - this.f4539s;
            return;
        }
        a();
        this.f4539s = i;
        this.f4540t = i5;
        this.f4541u = obj;
        this.f4538r = 3;
    }
}
