package com.revenuecat.purchases.ui.revenuecatui.helpers;

import A4.d;
import A4.l;
import J0.K0;
import J4.c;
import a.AbstractC0872a;
import android.app.Activity;
import android.content.res.Configuration;
import androidx.compose.runtime.Composable;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.CompositionLocalKt;
import androidx.compose.runtime.ProvidableCompositionLocal;
import androidx.compose.runtime.ReadOnlyComposable;
import androidx.compose.ui.platform.AndroidCompositionLocals_androidKt;
import com.revenuecat.purchases.CustomerInfo;
import com.revenuecat.purchases.EntitlementInfo;
import com.revenuecat.purchases.ListenerConversionsKt;
import com.revenuecat.purchases.Purchases;
import com.revenuecat.purchases.PurchasesError;
import com.revenuecat.purchases.PurchasesException;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import w4.C3137A;

/* JADX INFO: loaded from: classes3.dex */
public final class HelperFunctionsKt {
    private static final ProvidableCompositionLocal<Activity> LocalActivity = CompositionLocalKt.compositionLocalOf$default(null, HelperFunctionsKt$LocalActivity$1.INSTANCE, 1, null);

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.helpers.HelperFunctionsKt$shouldDisplayBlockForEntitlementIdentifier$1, reason: invalid class name */
    public static final class AnonymousClass1 extends p implements c {
        final /* synthetic */ String $entitlement;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass1(String str) {
            super(1);
            this.$entitlement = str;
        }

        @Override // J4.c
        public final Boolean invoke(CustomerInfo customerInfo) {
            o.h(customerInfo, "customerInfo");
            EntitlementInfo entitlementInfo = customerInfo.getEntitlements().get(this.$entitlement);
            boolean z6 = false;
            if (entitlementInfo != null && entitlementInfo.isActive()) {
                z6 = true;
            }
            return Boolean.valueOf(!z6);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.helpers.HelperFunctionsKt$shouldDisplayPaywall$3, reason: invalid class name */
    public static final class AnonymousClass3 extends p implements c {
        final /* synthetic */ c $result;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass3(c cVar) {
            super(1);
            this.$result = cVar;
        }

        @Override // J4.c
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            invoke((PurchasesError) obj);
            return C3137A.f25453a;
        }

        public final void invoke(PurchasesError it) {
            o.h(it, "it");
            Logger.INSTANCE.e("Error fetching customer info to display paywall", new PurchasesException(it));
            this.$result.invoke(Boolean.FALSE);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.helpers.HelperFunctionsKt$shouldDisplayPaywall$4, reason: invalid class name */
    public static final class AnonymousClass4 extends p implements c {
        final /* synthetic */ c $result;
        final /* synthetic */ c $shouldDisplayBlock;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass4(c cVar, c cVar2) {
            super(1);
            this.$shouldDisplayBlock = cVar;
            this.$result = cVar2;
        }

        @Override // J4.c
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            invoke((CustomerInfo) obj);
            return C3137A.f25453a;
        }

        public final void invoke(CustomerInfo it) {
            o.h(it, "it");
            Boolean bool = (Boolean) this.$shouldDisplayBlock.invoke(it);
            if (bool.booleanValue()) {
                Logger.INSTANCE.d("Displaying paywall according to display logic");
            } else {
                Logger.INSTANCE.d("Not displaying paywall according to display logic");
            }
            this.$result.invoke(bool);
        }
    }

    public static final ProvidableCompositionLocal<Activity> getLocalActivity() {
        return LocalActivity;
    }

    @Composable
    @ReadOnlyComposable
    public static final boolean isInPreviewMode(Composer composer, int i6) {
        if (ComposerKt.isTraceInProgress()) {
            ComposerKt.traceEventStart(774792703, i6, -1, "com.revenuecat.purchases.ui.revenuecatui.helpers.isInPreviewMode (HelperFunctions.kt:24)");
        }
        boolean zBooleanValue = ((Boolean) composer.consume(K0.f2892a)).booleanValue();
        if (ComposerKt.isTraceInProgress()) {
            ComposerKt.traceEventEnd();
        }
        return zBooleanValue;
    }

    public static final c shouldDisplayBlockForEntitlementIdentifier(String entitlement) {
        o.h(entitlement, "entitlement");
        return new AnonymousClass1(entitlement);
    }

    public static final Object shouldDisplayPaywall(c cVar, d dVar) {
        l lVar = new l(AbstractC0872a.V(dVar));
        shouldDisplayPaywall(cVar, new HelperFunctionsKt$shouldDisplayPaywall$2$1(lVar));
        Object objA = lVar.a();
        B4.a aVar = B4.a.f492a;
        return objA;
    }

    @Composable
    @ReadOnlyComposable
    public static final float windowAspectRatio(Composer composer, int i6) {
        if (ComposerKt.isTraceInProgress()) {
            ComposerKt.traceEventStart(1944383602, i6, -1, "com.revenuecat.purchases.ui.revenuecatui.helpers.windowAspectRatio (HelperFunctions.kt:28)");
        }
        Configuration configuration = (Configuration) composer.consume(AndroidCompositionLocals_androidKt.f11153a);
        float f6 = configuration.screenHeightDp / configuration.screenWidthDp;
        if (ComposerKt.isTraceInProgress()) {
            ComposerKt.traceEventEnd();
        }
        return f6;
    }

    public static final void shouldDisplayPaywall(c shouldDisplayBlock, c result) {
        o.h(shouldDisplayBlock, "shouldDisplayBlock");
        o.h(result, "result");
        ListenerConversionsKt.getCustomerInfoWith(Purchases.Companion.getSharedInstance(), new AnonymousClass3(result), new AnonymousClass4(shouldDisplayBlock, result));
    }
}
