package r;

import b0.D;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public abstract class k {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    final g f6330a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    final long f6331b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    final long f6332c;

    public static abstract class a extends k {

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        final int f6333d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final long f6334e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final List f6335f;

        public a(g gVar, long j2, long j3, int i2, long j4, List list) {
            super(gVar, j2, j3);
            this.f6333d = i2;
            this.f6334e = j4;
            this.f6335f = list;
        }

        public int c() {
            return this.f6333d;
        }

        public abstract int d(long j2);

        public final long e(int i2, long j2) {
            List list = this.f6335f;
            return list != null ? (((d) list.get(i2 - this.f6333d)).f6340b * 1000000) / this.f6331b : i2 == d(j2) ? j2 - g(i2) : (this.f6334e * 1000000) / this.f6331b;
        }

        public int f(long j2, long j3) {
            int iC = c();
            int iD = d(j3);
            if (this.f6335f == null) {
                int i2 = this.f6333d + ((int) (j2 / ((this.f6334e * 1000000) / this.f6331b)));
                return i2 < iC ? iC : (iD == -1 || i2 <= iD) ? i2 : iD;
            }
            int i3 = iC;
            while (i3 <= iD) {
                int i4 = (i3 + iD) / 2;
                long jG = g(i4);
                if (jG < j2) {
                    i3 = i4 + 1;
                } else {
                    if (jG <= j2) {
                        return i4;
                    }
                    iD = i4 - 1;
                }
            }
            return i3 == iC ? i3 : iD;
        }

        public final long g(int i2) {
            List list = this.f6335f;
            return D.I(list != null ? ((d) list.get(i2 - this.f6333d)).f6339a - this.f6332c : ((long) (i2 - this.f6333d)) * this.f6334e, 1000000L, this.f6331b);
        }

        public abstract g h(h hVar, int i2);

        public boolean i() {
            return this.f6335f != null;
        }
    }

    public static class b extends a {

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        final List f6336g;

        public b(g gVar, long j2, long j3, int i2, long j4, List list, List list2) {
            super(gVar, j2, j3, i2, j4, list);
            this.f6336g = list2;
        }

        @Override // r.k.a
        public int d(long j2) {
            return (this.f6333d + this.f6336g.size()) - 1;
        }

        @Override // r.k.a
        public g h(h hVar, int i2) {
            return (g) this.f6336g.get(i2 - this.f6333d);
        }

        @Override // r.k.a
        public boolean i() {
            return true;
        }
    }

    public static class c extends a {

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        final l f6337g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        final l f6338h;

        public c(g gVar, long j2, long j3, int i2, long j4, List list, l lVar, l lVar2) {
            super(gVar, j2, j3, i2, j4, list);
            this.f6337g = lVar;
            this.f6338h = lVar2;
        }

        @Override // r.k
        public g a(h hVar) {
            l lVar = this.f6337g;
            if (lVar == null) {
                return super.a(hVar);
            }
            p.j jVar = hVar.f6318c;
            return new g(lVar.a(jVar.f6165a, 0, jVar.f6167c, 0L), 0L, -1L);
        }

        @Override // r.k.a
        public int d(long j2) {
            if (this.f6335f != null) {
                return (r0.size() + this.f6333d) - 1;
            }
            if (j2 == -1) {
                return -1;
            }
            return (this.f6333d + ((int) D.f(j2, (this.f6334e * 1000000) / this.f6331b))) - 1;
        }

        @Override // r.k.a
        public g h(h hVar, int i2) {
            List list = this.f6335f;
            long j2 = list != null ? ((d) list.get(i2 - this.f6333d)).f6339a : ((long) (i2 - this.f6333d)) * this.f6334e;
            l lVar = this.f6338h;
            p.j jVar = hVar.f6318c;
            return new g(lVar.a(jVar.f6165a, i2, jVar.f6167c, j2), 0L, -1L);
        }
    }

    public static class d {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        long f6339a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        long f6340b;

        public d(long j2, long j3) {
            this.f6339a = j2;
            this.f6340b = j3;
        }
    }

    public k(g gVar, long j2, long j3) {
        this.f6330a = gVar;
        this.f6331b = j2;
        this.f6332c = j3;
    }

    public g a(h hVar) {
        return this.f6330a;
    }

    public long b() {
        return D.I(this.f6332c, 1000000L, this.f6331b);
    }

    public static class e extends k {

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        final long f6341d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final long f6342e;

        public e(g gVar, long j2, long j3, long j4, long j5) {
            super(gVar, j2, j3);
            this.f6341d = j4;
            this.f6342e = j5;
        }

        public g c() {
            long j2 = this.f6342e;
            if (j2 <= 0) {
                return null;
            }
            return new g(null, this.f6341d, j2);
        }

        public e() {
            this(null, 1L, 0L, 0L, -1L);
        }
    }
}
