package com.revenuecat.purchases.ui.revenuecatui.components.ktx;

import E3.v;
import J.c;
import J.g;
import J4.f;
import android.graphics.Path;
import com.revenuecat.purchases.paywalls.components.properties.CornerRadiuses;
import com.revenuecat.purchases.paywalls.components.properties.MaskShape;
import com.revenuecat.purchases.paywalls.components.properties.Shape;
import h1.m;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import o0.e;
import p0.AbstractC2686D;
import p0.C2702h;
import p0.Q;
import p0.X;
import w4.C3137A;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class ShapeKt {
    private static final float SCALE_Y_OFFSET_CONCAVE_CONVEX = 0.1f;

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.ktx.ShapeKt$toShape$1, reason: invalid class name */
    public static final class AnonymousClass1 extends p implements f {
        public static final AnonymousClass1 INSTANCE = new AnonymousClass1();

        public AnonymousClass1() {
            super(3);
        }

        @Override // J4.f
        public /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3) {
            m694invoke12SF9DM((Q) obj, ((e) obj2).f21799a, (m) obj3);
            return C3137A.f25453a;
        }

        /* JADX INFO: renamed from: invoke-12SF9DM, reason: not valid java name */
        public final void m694invoke12SF9DM(Q $receiver, long j4, m mVar) {
            o.h($receiver, "$this$$receiver");
            o.h(mVar, "<anonymous parameter 1>");
            float fB = e.b(j4) * 0.1f * 2.0f;
            C2702h c2702h = (C2702h) $receiver;
            Path path = c2702h.f22920a;
            path.moveTo(0.0f, 0.0f);
            c2702h.f(e.d(j4), 0.0f);
            c2702h.f(e.d(j4), e.b(j4));
            path.quadTo(e.d(j4) / 2, e.b(j4) - fB, 0.0f, e.b(j4));
            c2702h.f(0.0f, 0.0f);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.ktx.ShapeKt$toShape$2, reason: invalid class name */
    public static final class AnonymousClass2 extends p implements f {
        public static final AnonymousClass2 INSTANCE = new AnonymousClass2();

        public AnonymousClass2() {
            super(3);
        }

        @Override // J4.f
        public /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3) {
            m695invoke12SF9DM((Q) obj, ((e) obj2).f21799a, (m) obj3);
            return C3137A.f25453a;
        }

        /* JADX INFO: renamed from: invoke-12SF9DM, reason: not valid java name */
        public final void m695invoke12SF9DM(Q $receiver, long j4, m mVar) {
            o.h($receiver, "$this$$receiver");
            o.h(mVar, "<anonymous parameter 1>");
            float fB = e.b(j4) * 0.1f;
            C2702h c2702h = (C2702h) $receiver;
            Path path = c2702h.f22920a;
            path.moveTo(0.0f, 0.0f);
            c2702h.f(e.d(j4), 0.0f);
            c2702h.f(e.d(j4), e.b(j4) - fB);
            path.quadTo(e.d(j4) / 2, e.b(j4) + fB, 0.0f, e.b(j4) - fB);
            c2702h.f(0.0f, 0.0f);
        }
    }

    private static final X convertCornerRadiusesToShape(CornerRadiuses cornerRadiuses) {
        if (!(cornerRadiuses instanceof CornerRadiuses.Percentage)) {
            if (!(cornerRadiuses instanceof CornerRadiuses.Dp)) {
                throw new v();
            }
            CornerRadiuses.Dp dp = (CornerRadiuses.Dp) cornerRadiuses;
            return g.c((float) dp.getTopLeading(), (float) dp.getTopTrailing(), (float) dp.getBottomTrailing(), (float) dp.getBottomLeading());
        }
        CornerRadiuses.Percentage percentage = (CornerRadiuses.Percentage) cornerRadiuses;
        int topLeading = percentage.getTopLeading();
        int topTrailing = percentage.getTopTrailing();
        int bottomTrailing = percentage.getBottomTrailing();
        int bottomLeading = percentage.getBottomLeading();
        J.f fVar = g.f2694a;
        return new J.f(A4.g.a(topLeading), A4.g.a(topTrailing), A4.g.a(bottomTrailing), A4.g.a(bottomLeading));
    }

    public static final /* synthetic */ X toShape(Shape shape) {
        o.h(shape, "<this>");
        return convertCornerRadiusesToShape(shape.getCornerRadiuses());
    }

    public static final X toShape(MaskShape maskShape) {
        X xConvertCornerRadiusesToShape;
        o.h(maskShape, "<this>");
        if (maskShape instanceof MaskShape.Rectangle) {
            CornerRadiuses corners = ((MaskShape.Rectangle) maskShape).getCorners();
            return (corners == null || (xConvertCornerRadiusesToShape = convertCornerRadiusesToShape(corners)) == null) ? AbstractC2686D.f22844b : xConvertCornerRadiusesToShape;
        }
        if (maskShape instanceof MaskShape.Concave) {
            return new c(AnonymousClass1.INSTANCE);
        }
        if (maskShape instanceof MaskShape.Convex) {
            return new c(AnonymousClass2.INSTANCE);
        }
        if (maskShape instanceof MaskShape.Circle) {
            return g.f2694a;
        }
        throw new v();
    }
}
