package t1;

import java.util.Arrays;
import s1.g0;
import s1.i0;
import t1.b;

/* loaded from: classes.dex */
public class h {

    /* renamed from: g, reason: collision with root package name */
    public static final a f36017g = new a(null);

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

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

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

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

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

    /* renamed from: f, reason: collision with root package name */
    private final float[] f36023f;

    /* loaded from: classes.dex */
    public static final class a {

        /* renamed from: t1.h$a$a, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public static final class C0849a extends h {
            C0849a(c cVar, int i10) {
                super(cVar, cVar, i10, null);
            }

            @Override // t1.h
            public long a(long j10) {
                return j10;
            }
        }

        private a() {
        }

        public /* synthetic */ a(kotlin.jvm.internal.k kVar) {
            this();
        }

        /* JADX INFO: Access modifiers changed from: private */
        public final float[] b(c cVar, c cVar2, int i10) {
            if (!n.e(i10, n.f36045a.a())) {
                return null;
            }
            long e10 = cVar.e();
            b.a aVar = t1.b.f35984a;
            boolean e11 = t1.b.e(e10, aVar.b());
            boolean e12 = t1.b.e(cVar2.e(), aVar.b());
            if (e11 && e12) {
                return null;
            }
            if (!e11 && !e12) {
                return null;
            }
            if (!e11) {
                cVar = cVar2;
            }
            kotlin.jvm.internal.t.e(cVar, "null cannot be cast to non-null type androidx.compose.ui.graphics.colorspace.Rgb");
            x xVar = (x) cVar;
            float[] c10 = e11 ? xVar.N().c() : k.f36028a.c();
            float[] c11 = e12 ? xVar.N().c() : k.f36028a.c();
            return new float[]{c10[0] / c11[0], c10[1] / c11[1], c10[2] / c11[2]};
        }

        public final h c(c cVar) {
            return new C0849a(cVar, n.f36045a.c());
        }
    }

    /* loaded from: classes.dex */
    public static final class b extends h {

        /* renamed from: h, reason: collision with root package name */
        private final x f36024h;

        /* renamed from: i, reason: collision with root package name */
        private final x f36025i;

        /* renamed from: j, reason: collision with root package name */
        private final float[] f36026j;

        public /* synthetic */ b(x xVar, x xVar2, int i10, kotlin.jvm.internal.k kVar) {
            this(xVar, xVar2, i10);
        }

        private final float[] b(x xVar, x xVar2, int i10) {
            if (d.f(xVar.N(), xVar2.N())) {
                return d.l(xVar2.G(), xVar.M());
            }
            float[] M = xVar.M();
            float[] G = xVar2.G();
            float[] c10 = xVar.N().c();
            float[] c11 = xVar2.N().c();
            z N = xVar.N();
            k kVar = k.f36028a;
            if (!d.f(N, kVar.b())) {
                float[] b10 = t1.a.f35979b.a().b();
                float[] c12 = kVar.c();
                float[] copyOf = Arrays.copyOf(c12, c12.length);
                kotlin.jvm.internal.t.f(copyOf, "copyOf(this, size)");
                M = d.l(d.e(b10, c10, copyOf), xVar.M());
            }
            if (!d.f(xVar2.N(), kVar.b())) {
                float[] b11 = t1.a.f35979b.a().b();
                float[] c13 = kVar.c();
                float[] copyOf2 = Arrays.copyOf(c13, c13.length);
                kotlin.jvm.internal.t.f(copyOf2, "copyOf(this, size)");
                G = d.k(d.l(d.e(b11, c11, copyOf2), xVar2.M()));
            }
            if (n.e(i10, n.f36045a.a())) {
                M = d.m(new float[]{c10[0] / c11[0], c10[1] / c11[1], c10[2] / c11[2]}, M);
            }
            return d.l(G, M);
        }

        @Override // t1.h
        public long a(long j10) {
            float s10 = g0.s(j10);
            float r10 = g0.r(j10);
            float p10 = g0.p(j10);
            float o10 = g0.o(j10);
            float a10 = (float) this.f36024h.E().a(s10);
            float a11 = (float) this.f36024h.E().a(r10);
            float a12 = (float) this.f36024h.E().a(p10);
            float[] fArr = this.f36026j;
            return i0.a((float) this.f36025i.I().a((fArr[0] * a10) + (fArr[3] * a11) + (fArr[6] * a12)), (float) this.f36025i.I().a((fArr[1] * a10) + (fArr[4] * a11) + (fArr[7] * a12)), (float) this.f36025i.I().a((fArr[2] * a10) + (fArr[5] * a11) + (fArr[8] * a12)), o10, this.f36025i);
        }

        private b(x xVar, x xVar2, int i10) {
            super(xVar, xVar2, xVar, xVar2, i10, null, null);
            this.f36024h = xVar;
            this.f36025i = xVar2;
            this.f36026j = b(xVar, xVar2, i10);
        }
    }

    public /* synthetic */ h(c cVar, c cVar2, int i10, kotlin.jvm.internal.k kVar) {
        this(cVar, cVar2, i10);
    }

    public long a(long j10) {
        float s10 = g0.s(j10);
        float r10 = g0.r(j10);
        float p10 = g0.p(j10);
        float o10 = g0.o(j10);
        long h10 = this.f36020c.h(s10, r10, p10);
        float intBitsToFloat = Float.intBitsToFloat((int) (h10 >> 32));
        float intBitsToFloat2 = Float.intBitsToFloat((int) (h10 & 4294967295L));
        float i10 = this.f36020c.i(s10, r10, p10);
        float[] fArr = this.f36023f;
        if (fArr != null) {
            intBitsToFloat *= fArr[0];
            intBitsToFloat2 *= fArr[1];
            i10 *= fArr[2];
        }
        float f10 = intBitsToFloat;
        return this.f36021d.j(f10, intBitsToFloat2, i10, o10, this.f36019b);
    }

    public /* synthetic */ h(c cVar, c cVar2, c cVar3, c cVar4, int i10, float[] fArr, kotlin.jvm.internal.k kVar) {
        this(cVar, cVar2, cVar3, cVar4, i10, fArr);
    }

    private h(c cVar, c cVar2, c cVar3, c cVar4, int i10, float[] fArr) {
        this.f36018a = cVar;
        this.f36019b = cVar2;
        this.f36020c = cVar3;
        this.f36021d = cVar4;
        this.f36022e = i10;
        this.f36023f = fArr;
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private h(c cVar, c cVar2, int i10) {
        this(cVar, cVar2, t1.b.e(r0, r2.b()) ? d.d(cVar, k.f36028a.b(), null, 2, null) : cVar, t1.b.e(cVar2.e(), r2.b()) ? d.d(cVar2, k.f36028a.b(), null, 2, null) : cVar2, i10, f36017g.b(cVar, cVar2, i10), null);
        long e10 = cVar.e();
        b.a aVar = t1.b.f35984a;
    }
}
