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

import E3.v;
import J4.c;
import com.revenuecat.purchases.Package;
import com.revenuecat.purchases.paywalls.components.PackageComponent;
import com.revenuecat.purchases.paywalls.components.PaywallComponent;
import com.revenuecat.purchases.paywalls.components.PurchaseButtonComponent;
import com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory;
import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError;
import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyList;
import com.revenuecat.purchases.ui.revenuecatui.helpers.ResolvedOffer;
import com.revenuecat.purchases.ui.revenuecatui.helpers.Result;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import x4.AbstractC3229F;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes3.dex */
public final class StyleFactory$createPackageComponentStyle$1$1 extends p implements c {
    final /* synthetic */ PackageComponent $component;
    final /* synthetic */ Package $rcPackage;
    final /* synthetic */ ResolvedOffer $resolvedOffer;
    final /* synthetic */ StyleFactory this$0;

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

        public AnonymousClass1() {
            super(1);
        }

        @Override // J4.c
        public final Boolean invoke(PaywallComponent it) {
            o.h(it, "it");
            return Boolean.valueOf(it instanceof PurchaseButtonComponent);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public StyleFactory$createPackageComponentStyle$1$1(StyleFactory styleFactory, PackageComponent packageComponent, Package r32, ResolvedOffer resolvedOffer) {
        super(1);
        this.this$0 = styleFactory;
        this.$component = packageComponent;
        this.$rcPackage = r32;
        this.$resolvedOffer = resolvedOffer;
    }

    @Override // J4.c
    public final Result<PackageComponentStyle, NonEmptyList<PaywallValidationError>> invoke(StyleFactory.StyleFactoryScope withSelectedScope) {
        o.h(withSelectedScope, "$this$withSelectedScope");
        AnonymousClass1 anonymousClass1 = AnonymousClass1.INSTANCE;
        StyleFactory styleFactory = this.this$0;
        PackageComponent packageComponent = this.$component;
        Integer num = (Integer) AbstractC3251q.p0(withSelectedScope.countPredicates.keySet());
        int iIntValue = (num != null ? num.intValue() : -1) + 1;
        withSelectedScope.countPredicates.put(Integer.valueOf(iIntValue), anonymousClass1);
        withSelectedScope.countValues.put(Integer.valueOf(iIntValue), 0);
        StyleFactory.StyleFactoryScope.WithCount withCount = new StyleFactory.StyleFactoryScope.WithCount(styleFactory.createStackComponentStyle(withSelectedScope, packageComponent.getStack()), ((Number) AbstractC3229F.t(Integer.valueOf(iIntValue), withSelectedScope.countValues)).intValue());
        withSelectedScope.countPredicates.remove(Integer.valueOf(iIntValue));
        withSelectedScope.countValues.remove(Integer.valueOf(iIntValue));
        Result<PackageComponentStyle, NonEmptyList<PaywallValidationError>> result = (Result) withCount.component1();
        int iComponent2 = withCount.component2();
        PackageComponent packageComponent2 = this.$component;
        Package r8 = this.$rcPackage;
        ResolvedOffer resolvedOffer = this.$resolvedOffer;
        if (result instanceof Result.Success) {
            return new Result.Success(new PackageComponentStyle(r8, packageComponent2.isSelectedByDefault(), (StackComponentStyle) ((Result.Success) result).getValue(), iComponent2 == 0, resolvedOffer));
        }
        if (result instanceof Result.Error) {
            return result;
        }
        throw new v();
    }
}
