package s1;

import android.graphics.ColorSpace;
import java.util.function.DoubleUnaryOperator;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class o0 {

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

    private o0() {
    }

    public static final ColorSpace e(t1.c cVar) {
        ColorSpace.Rgb rgb;
        t1.g gVar = t1.g.f35993a;
        if (kotlin.jvm.internal.t.b(cVar, gVar.w())) {
            return ColorSpace.get(ColorSpace.Named.SRGB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.e())) {
            return ColorSpace.get(ColorSpace.Named.ACES);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.f())) {
            return ColorSpace.get(ColorSpace.Named.ACESCG);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.g())) {
            return ColorSpace.get(ColorSpace.Named.ADOBE_RGB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.h())) {
            return ColorSpace.get(ColorSpace.Named.BT2020);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.i())) {
            return ColorSpace.get(ColorSpace.Named.BT709);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.j())) {
            return ColorSpace.get(ColorSpace.Named.CIE_LAB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.k())) {
            return ColorSpace.get(ColorSpace.Named.CIE_XYZ);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.m())) {
            return ColorSpace.get(ColorSpace.Named.DCI_P3);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.n())) {
            return ColorSpace.get(ColorSpace.Named.DISPLAY_P3);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.o())) {
            return ColorSpace.get(ColorSpace.Named.EXTENDED_SRGB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.p())) {
            return ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.q())) {
            return ColorSpace.get(ColorSpace.Named.LINEAR_SRGB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.r())) {
            return ColorSpace.get(ColorSpace.Named.NTSC_1953);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.u())) {
            return ColorSpace.get(ColorSpace.Named.PRO_PHOTO_RGB);
        }
        if (kotlin.jvm.internal.t.b(cVar, gVar.v())) {
            return ColorSpace.get(ColorSpace.Named.SMPTE_C);
        }
        if (!(cVar instanceof t1.x)) {
            return ColorSpace.get(ColorSpace.Named.SRGB);
        }
        t1.x xVar = (t1.x) cVar;
        float[] c10 = xVar.N().c();
        t1.y L = xVar.L();
        ColorSpace.Rgb.TransferParameters transferParameters = L != null ? new ColorSpace.Rgb.TransferParameters(L.a(), L.b(), L.c(), L.d(), L.e(), L.f(), L.g()) : null;
        if (transferParameters != null) {
            rgb = new ColorSpace.Rgb(cVar.f(), ((t1.x) cVar).K(), c10, transferParameters);
        } else {
            String f10 = cVar.f();
            t1.x xVar2 = (t1.x) cVar;
            float[] K = xVar2.K();
            final dn.l H = xVar2.H();
            DoubleUnaryOperator doubleUnaryOperator = new DoubleUnaryOperator() { // from class: s1.k0
                @Override // java.util.function.DoubleUnaryOperator
                public final double applyAsDouble(double d10) {
                    double f11;
                    f11 = o0.f(dn.l.this, d10);
                    return f11;
                }
            };
            final dn.l D = xVar2.D();
            rgb = new ColorSpace.Rgb(f10, K, c10, doubleUnaryOperator, new DoubleUnaryOperator() { // from class: s1.l0
                @Override // java.util.function.DoubleUnaryOperator
                public final double applyAsDouble(double d10) {
                    double g10;
                    g10 = o0.g(dn.l.this, d10);
                    return g10;
                }
            }, cVar.d(0), cVar.c(0));
        }
        return rgb;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final double f(dn.l lVar, double d10) {
        return ((Number) lVar.invoke(Double.valueOf(d10))).doubleValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final double g(dn.l lVar, double d10) {
        return ((Number) lVar.invoke(Double.valueOf(d10))).doubleValue();
    }

    public static final t1.c h(final ColorSpace colorSpace) {
        t1.z zVar;
        t1.y yVar;
        int id2 = colorSpace.getId();
        if (id2 == ColorSpace.Named.SRGB.ordinal()) {
            return t1.g.f35993a.w();
        }
        if (id2 == ColorSpace.Named.ACES.ordinal()) {
            return t1.g.f35993a.e();
        }
        if (id2 == ColorSpace.Named.ACESCG.ordinal()) {
            return t1.g.f35993a.f();
        }
        if (id2 == ColorSpace.Named.ADOBE_RGB.ordinal()) {
            return t1.g.f35993a.g();
        }
        if (id2 == ColorSpace.Named.BT2020.ordinal()) {
            return t1.g.f35993a.h();
        }
        if (id2 == ColorSpace.Named.BT709.ordinal()) {
            return t1.g.f35993a.i();
        }
        if (id2 == ColorSpace.Named.CIE_LAB.ordinal()) {
            return t1.g.f35993a.j();
        }
        if (id2 == ColorSpace.Named.CIE_XYZ.ordinal()) {
            return t1.g.f35993a.k();
        }
        if (id2 == ColorSpace.Named.DCI_P3.ordinal()) {
            return t1.g.f35993a.m();
        }
        if (id2 == ColorSpace.Named.DISPLAY_P3.ordinal()) {
            return t1.g.f35993a.n();
        }
        if (id2 == ColorSpace.Named.EXTENDED_SRGB.ordinal()) {
            return t1.g.f35993a.o();
        }
        if (id2 == ColorSpace.Named.LINEAR_EXTENDED_SRGB.ordinal()) {
            return t1.g.f35993a.p();
        }
        if (id2 == ColorSpace.Named.LINEAR_SRGB.ordinal()) {
            return t1.g.f35993a.q();
        }
        if (id2 == ColorSpace.Named.NTSC_1953.ordinal()) {
            return t1.g.f35993a.r();
        }
        if (id2 == ColorSpace.Named.PRO_PHOTO_RGB.ordinal()) {
            return t1.g.f35993a.u();
        }
        if (id2 == ColorSpace.Named.SMPTE_C.ordinal()) {
            return t1.g.f35993a.v();
        }
        if (!(colorSpace instanceof ColorSpace.Rgb)) {
            return t1.g.f35993a.w();
        }
        ColorSpace.Rgb rgb = (ColorSpace.Rgb) colorSpace;
        ColorSpace.Rgb.TransferParameters transferParameters = rgb.getTransferParameters();
        t1.z zVar2 = rgb.getWhitePoint().length == 3 ? new t1.z(rgb.getWhitePoint()[0], rgb.getWhitePoint()[1], rgb.getWhitePoint()[2]) : new t1.z(rgb.getWhitePoint()[0], rgb.getWhitePoint()[1]);
        if (transferParameters != null) {
            zVar = zVar2;
            yVar = new t1.y(transferParameters.g, transferParameters.a, transferParameters.b, transferParameters.c, transferParameters.d, transferParameters.e, transferParameters.f);
        } else {
            zVar = zVar2;
            yVar = null;
        }
        return new t1.x(rgb.getName(), rgb.getPrimaries(), zVar, rgb.getTransform(), new t1.j() { // from class: s1.m0
            @Override // t1.j
            public final double a(double d10) {
                double i10;
                i10 = o0.i(colorSpace, d10);
                return i10;
            }
        }, new t1.j() { // from class: s1.n0
            @Override // t1.j
            public final double a(double d10) {
                double j10;
                j10 = o0.j(colorSpace, d10);
                return j10;
            }
        }, colorSpace.getMinValue(0), colorSpace.getMaxValue(0), yVar, rgb.getId());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final double i(ColorSpace colorSpace, double d10) {
        return ((ColorSpace.Rgb) colorSpace).getOetf().applyAsDouble(d10);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final double j(ColorSpace colorSpace, double d10) {
        return ((ColorSpace.Rgb) colorSpace).getEotf().applyAsDouble(d10);
    }
}
