package y;

/* loaded from: classes.dex */
public final class c2 implements w1 {

    /* renamed from: a, reason: collision with root package name */
    private final androidx.collection.j f51121a;

    /* renamed from: b, reason: collision with root package name */
    private final androidx.collection.l f51122b;

    /* renamed from: c, reason: collision with root package name */
    private final int f51123c;

    /* renamed from: d, reason: collision with root package name */
    private final int f51124d;

    /* renamed from: e, reason: collision with root package name */
    private final d0 f51125e;

    /* renamed from: f, reason: collision with root package name */
    private final int f51126f;

    /* renamed from: g, reason: collision with root package name */
    private int[] f51127g;

    /* renamed from: h, reason: collision with root package name */
    private float[] f51128h;

    /* renamed from: i, reason: collision with root package name */
    private q f51129i;

    /* renamed from: j, reason: collision with root package name */
    private q f51130j;

    /* renamed from: k, reason: collision with root package name */
    private q f51131k;

    /* renamed from: l, reason: collision with root package name */
    private q f51132l;

    /* renamed from: m, reason: collision with root package name */
    private float[] f51133m;

    /* renamed from: n, reason: collision with root package name */
    private float[] f51134n;

    /* renamed from: o, reason: collision with root package name */
    private u f51135o;

    public /* synthetic */ c2(androidx.collection.j jVar, androidx.collection.l lVar, int i10, int i11, d0 d0Var, int i12, kotlin.jvm.internal.k kVar) {
        this(jVar, lVar, i10, i11, d0Var, i12);
    }

    private final int h(int i10) {
        int b10 = p0.b(this.f51121a, i10, 0, 0, 6, null);
        return b10 < -1 ? -(b10 + 2) : b10;
    }

    private final float i(int i10) {
        return j(h(i10), i10, false);
    }

    private final float j(int i10, int i11, boolean z10) {
        d0 d0Var;
        float f10;
        androidx.collection.j jVar = this.f51121a;
        if (i10 >= jVar.f1330b - 1) {
            f10 = i11;
        } else {
            int a10 = jVar.a(i10);
            int a11 = this.f51121a.a(i10 + 1);
            if (i11 != a10) {
                int i12 = a11 - a10;
                b2 b2Var = (b2) this.f51122b.c(a10);
                if (b2Var == null || (d0Var = b2Var.b()) == null) {
                    d0Var = this.f51125e;
                }
                float f11 = i12;
                float a12 = d0Var.a((i11 - a10) / f11);
                return z10 ? a12 : ((f11 * a12) + a10) / ((float) 1000);
            }
            f10 = a10;
        }
        return f10 / ((float) 1000);
    }

    private final void k(q qVar, q qVar2, q qVar3) {
        float[] fArr;
        float[] fArr2;
        boolean z10 = this.f51135o != null;
        if (this.f51129i == null) {
            this.f51129i = r.g(qVar);
            this.f51130j = r.g(qVar3);
            int b10 = this.f51121a.b();
            float[] fArr3 = new float[b10];
            for (int i10 = 0; i10 < b10; i10++) {
                fArr3[i10] = this.f51121a.a(i10) / ((float) 1000);
            }
            this.f51128h = fArr3;
            int b11 = this.f51121a.b();
            int[] iArr = new int[b11];
            for (int i11 = 0; i11 < b11; i11++) {
                b2 b2Var = (b2) this.f51122b.c(this.f51121a.a(i11));
                int a10 = b2Var != null ? b2Var.a() : this.f51126f;
                if (!t.c(a10, t.f51392a.a())) {
                    z10 = true;
                }
                iArr[i11] = a10;
            }
            this.f51127g = iArr;
        }
        if (z10) {
            float[] fArr4 = null;
            if (this.f51135o != null) {
                q qVar4 = this.f51131k;
                if (qVar4 == null) {
                    kotlin.jvm.internal.t.y("lastInitialValue");
                    qVar4 = null;
                }
                if (kotlin.jvm.internal.t.b(qVar4, qVar)) {
                    q qVar5 = this.f51132l;
                    if (qVar5 == null) {
                        kotlin.jvm.internal.t.y("lastTargetValue");
                        qVar5 = null;
                    }
                    if (kotlin.jvm.internal.t.b(qVar5, qVar2)) {
                        return;
                    }
                }
            }
            this.f51131k = qVar;
            this.f51132l = qVar2;
            int b12 = (qVar.b() % 2) + qVar.b();
            this.f51133m = new float[b12];
            this.f51134n = new float[b12];
            int b13 = this.f51121a.b();
            float[][] fArr5 = new float[b13];
            for (int i12 = 0; i12 < b13; i12++) {
                int a11 = this.f51121a.a(i12);
                if (a11 != 0) {
                    if (a11 != g()) {
                        fArr = new float[b12];
                        Object c10 = this.f51122b.c(a11);
                        kotlin.jvm.internal.t.d(c10);
                        q c11 = ((b2) c10).c();
                        for (int i13 = 0; i13 < b12; i13++) {
                            fArr[i13] = c11.a(i13);
                        }
                    } else if (this.f51122b.a(a11)) {
                        fArr = new float[b12];
                        Object c12 = this.f51122b.c(a11);
                        kotlin.jvm.internal.t.d(c12);
                        q c13 = ((b2) c12).c();
                        for (int i14 = 0; i14 < b12; i14++) {
                            fArr[i14] = c13.a(i14);
                        }
                    } else {
                        fArr2 = new float[b12];
                        for (int i15 = 0; i15 < b12; i15++) {
                            fArr2[i15] = qVar2.a(i15);
                        }
                    }
                    fArr2 = fArr;
                } else if (this.f51122b.a(a11)) {
                    fArr = new float[b12];
                    Object c14 = this.f51122b.c(a11);
                    kotlin.jvm.internal.t.d(c14);
                    q c15 = ((b2) c14).c();
                    for (int i16 = 0; i16 < b12; i16++) {
                        fArr[i16] = c15.a(i16);
                    }
                    fArr2 = fArr;
                } else {
                    fArr2 = new float[b12];
                    for (int i17 = 0; i17 < b12; i17++) {
                        fArr2[i17] = qVar.a(i17);
                    }
                }
                fArr5[i12] = fArr2;
            }
            int[] iArr2 = this.f51127g;
            if (iArr2 == null) {
                kotlin.jvm.internal.t.y("modes");
                iArr2 = null;
            }
            float[] fArr6 = this.f51128h;
            if (fArr6 == null) {
                kotlin.jvm.internal.t.y("times");
            } else {
                fArr4 = fArr6;
            }
            this.f51135o = new u(iArr2, fArr4, fArr5);
        }
    }

    @Override // y.t1
    public q c(long j10, q qVar, q qVar2, q qVar3) {
        int b10 = (int) u1.b(this, j10 / 1000000);
        if (this.f51122b.a(b10)) {
            Object c10 = this.f51122b.c(b10);
            kotlin.jvm.internal.t.d(c10);
            return ((b2) c10).c();
        }
        if (b10 >= g()) {
            return qVar2;
        }
        if (b10 <= 0) {
            return qVar;
        }
        k(qVar, qVar2, qVar3);
        int i10 = 0;
        if (this.f51135o == null) {
            int h10 = h(b10);
            float j11 = j(h10, b10, true);
            int a10 = this.f51121a.a(h10);
            if (this.f51122b.a(a10)) {
                Object c11 = this.f51122b.c(a10);
                kotlin.jvm.internal.t.d(c11);
                qVar = ((b2) c11).c();
            }
            int a11 = this.f51121a.a(h10 + 1);
            if (this.f51122b.a(a11)) {
                Object c12 = this.f51122b.c(a11);
                kotlin.jvm.internal.t.d(c12);
                qVar2 = ((b2) c12).c();
            }
            q qVar4 = this.f51129i;
            if (qVar4 == null) {
                kotlin.jvm.internal.t.y("valueVector");
                qVar4 = null;
            }
            int b11 = qVar4.b();
            while (i10 < b11) {
                q qVar5 = this.f51129i;
                if (qVar5 == null) {
                    kotlin.jvm.internal.t.y("valueVector");
                    qVar5 = null;
                }
                qVar5.e(i10, s1.k(qVar.a(i10), qVar2.a(i10), j11));
                i10++;
            }
            q qVar6 = this.f51129i;
            if (qVar6 != null) {
                return qVar6;
            }
            kotlin.jvm.internal.t.y("valueVector");
            return null;
        }
        float i11 = i(b10);
        u uVar = this.f51135o;
        if (uVar == null) {
            kotlin.jvm.internal.t.y("arcSpline");
            uVar = null;
        }
        float[] fArr = this.f51133m;
        if (fArr == null) {
            kotlin.jvm.internal.t.y("posArray");
            fArr = null;
        }
        uVar.a(i11, fArr);
        float[] fArr2 = this.f51133m;
        if (fArr2 == null) {
            kotlin.jvm.internal.t.y("posArray");
            fArr2 = null;
        }
        int length = fArr2.length;
        while (i10 < length) {
            q qVar7 = this.f51129i;
            if (qVar7 == null) {
                kotlin.jvm.internal.t.y("valueVector");
                qVar7 = null;
            }
            float[] fArr3 = this.f51133m;
            if (fArr3 == null) {
                kotlin.jvm.internal.t.y("posArray");
                fArr3 = null;
            }
            qVar7.e(i10, fArr3[i10]);
            i10++;
        }
        q qVar8 = this.f51129i;
        if (qVar8 != null) {
            return qVar8;
        }
        kotlin.jvm.internal.t.y("valueVector");
        return null;
    }

    @Override // y.t1
    public q d(long j10, q qVar, q qVar2, q qVar3) {
        long b10 = u1.b(this, j10 / 1000000);
        if (b10 < 0) {
            return qVar3;
        }
        k(qVar, qVar2, qVar3);
        int i10 = 0;
        if (this.f51135o == null) {
            q d10 = u1.d(this, b10 - 1, qVar, qVar2, qVar3);
            q d11 = u1.d(this, b10, qVar, qVar2, qVar3);
            int b11 = d10.b();
            while (i10 < b11) {
                q qVar4 = this.f51130j;
                if (qVar4 == null) {
                    kotlin.jvm.internal.t.y("velocityVector");
                    qVar4 = null;
                }
                qVar4.e(i10, (d10.a(i10) - d11.a(i10)) * 1000.0f);
                i10++;
            }
            q qVar5 = this.f51130j;
            if (qVar5 != null) {
                return qVar5;
            }
            kotlin.jvm.internal.t.y("velocityVector");
            return null;
        }
        float i11 = i((int) b10);
        u uVar = this.f51135o;
        if (uVar == null) {
            kotlin.jvm.internal.t.y("arcSpline");
            uVar = null;
        }
        float[] fArr = this.f51134n;
        if (fArr == null) {
            kotlin.jvm.internal.t.y("slopeArray");
            fArr = null;
        }
        uVar.b(i11, fArr);
        float[] fArr2 = this.f51134n;
        if (fArr2 == null) {
            kotlin.jvm.internal.t.y("slopeArray");
            fArr2 = null;
        }
        int length = fArr2.length;
        while (i10 < length) {
            q qVar6 = this.f51130j;
            if (qVar6 == null) {
                kotlin.jvm.internal.t.y("velocityVector");
                qVar6 = null;
            }
            float[] fArr3 = this.f51134n;
            if (fArr3 == null) {
                kotlin.jvm.internal.t.y("slopeArray");
                fArr3 = null;
            }
            qVar6.e(i10, fArr3[i10]);
            i10++;
        }
        q qVar7 = this.f51130j;
        if (qVar7 != null) {
            return qVar7;
        }
        kotlin.jvm.internal.t.y("velocityVector");
        return null;
    }

    @Override // y.w1
    public int e() {
        return this.f51124d;
    }

    @Override // y.w1
    public int g() {
        return this.f51123c;
    }

    private c2(androidx.collection.j jVar, androidx.collection.l lVar, int i10, int i11, d0 d0Var, int i12) {
        this.f51121a = jVar;
        this.f51122b = lVar;
        this.f51123c = i10;
        this.f51124d = i11;
        this.f51125e = d0Var;
        this.f51126f = i12;
    }
}
