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

import B.AbstractC0057e;
import B.Q0;
import B.U0;
import J4.f;
import J4.h;
import androidx.compose.runtime.Composable;
import androidx.compose.runtime.ComposableInferredTarget;
import androidx.compose.runtime.ComposableTarget;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.internal.ComposableLambdaKt;
import com.revenuecat.purchases.paywalls.components.properties.FlexDistribution;
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint;
import com.revenuecat.purchases.ui.revenuecatui.components.style.ComponentStyle;
import i0.C2252p;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import w4.C3137A;
import x4.AbstractC3252r;

/* JADX INFO: loaded from: classes3.dex */
final class HorizontalStackScopeImpl implements HorizontalStackScope {
    private final FlexDistribution distribution;
    private final f fillSpaceSpacer;
    private boolean hasAnyItemsWithFillWidth;
    private f rowContent;
    private final float spacing;
    private final SizeConstraint width;

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.stack.HorizontalStackScopeImpl$items$2, reason: invalid class name */
    public static final class AnonymousClass2 extends p implements f {
        final /* synthetic */ h $itemContent;
        final /* synthetic */ List<ComponentStyle> $items;
        final /* synthetic */ HorizontalStackScopeImpl this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        /* JADX WARN: Multi-variable type inference failed */
        public AnonymousClass2(List<? extends ComponentStyle> list, h hVar, HorizontalStackScopeImpl horizontalStackScopeImpl) {
            super(3);
            this.$items = list;
            this.$itemContent = hVar;
            this.this$0 = horizontalStackScopeImpl;
        }

        @Override // J4.f
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3) {
            invoke((Q0) obj, (Composer) obj2, ((Number) obj3).intValue());
            return C3137A.f25453a;
        }

        @ComposableTarget(applier = "androidx.compose.ui.UiComposable")
        @Composable
        public final void invoke(Q0 q02, Composer composer, int i6) {
            o.h(q02, "$this$null");
            int i7 = (i6 & 6) == 0 ? i6 | (composer.changed(q02) ? 4 : 2) : i6;
            if ((i7 & 19) == 18 && composer.getSkipping()) {
                composer.skipToGroupEnd();
                return;
            }
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventStart(1239185597, i7, -1, "com.revenuecat.purchases.ui.revenuecatui.components.stack.HorizontalStackScopeImpl.items.<anonymous> (HorizontalStack.kt:96)");
            }
            List<ComponentStyle> list = this.$items;
            h hVar = this.$itemContent;
            HorizontalStackScopeImpl horizontalStackScopeImpl = this.this$0;
            int i8 = 0;
            for (Object obj : list) {
                int i9 = i8 + 1;
                if (i8 < 0) {
                    AbstractC3252r.F();
                    throw null;
                }
                ComponentStyle componentStyle = (ComponentStyle) obj;
                boolean z6 = i8 == list.size() - 1;
                hVar.invoke(q02, Integer.valueOf(i8), componentStyle, composer, Integer.valueOf(i7 & 14));
                composer.startReplaceGroup(-855017870);
                if (StackComponentViewKt.getUsesAllAvailableSpace(horizontalStackScopeImpl.distribution) && !z6) {
                    AbstractC0057e.g(U0.v(C2252p.f18820a, horizontalStackScopeImpl.spacing, 0.0f, 2), composer, 0);
                    if (horizontalStackScopeImpl.getShouldApplyFillSpacers()) {
                        horizontalStackScopeImpl.fillSpaceSpacer.invoke(Float.valueOf(horizontalStackScopeImpl.distribution == FlexDistribution.SPACE_AROUND ? 2.0f : 1.0f), composer, 0);
                    }
                }
                composer.endReplaceGroup();
                i8 = i9;
            }
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventEnd();
            }
        }
    }

    public /* synthetic */ HorizontalStackScopeImpl(FlexDistribution flexDistribution, float f6, f fVar, SizeConstraint sizeConstraint, kotlin.jvm.internal.h hVar) {
        this(flexDistribution, f6, fVar, sizeConstraint);
    }

    public final f getRowContent() {
        return this.rowContent;
    }

    public final boolean getShouldApplyFillSpacers() {
        return (o.c(this.width, SizeConstraint.Fit.INSTANCE) || this.hasAnyItemsWithFillWidth) ? false : true;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.components.stack.HorizontalStackScope
    @ComposableInferredTarget(scheme = "[_[androidx.compose.ui.UiComposable]]")
    public void items(List<? extends ComponentStyle> items, h itemContent) {
        o.h(items, "items");
        o.h(itemContent, "itemContent");
        boolean z6 = false;
        if (!items.isEmpty()) {
            Iterator<T> it = items.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                } else if (o.c(((ComponentStyle) it.next()).getSize().getWidth(), SizeConstraint.Fill.INSTANCE)) {
                    z6 = true;
                    break;
                }
            }
        }
        this.hasAnyItemsWithFillWidth = z6;
        this.rowContent = ComposableLambdaKt.composableLambdaInstance(1239185597, true, new AnonymousClass2(items, itemContent, this));
    }

    public final void setRowContent(f fVar) {
        o.h(fVar, "<set-?>");
        this.rowContent = fVar;
    }

    private HorizontalStackScopeImpl(FlexDistribution distribution, float f6, f fillSpaceSpacer, SizeConstraint width) {
        o.h(distribution, "distribution");
        o.h(fillSpaceSpacer, "fillSpaceSpacer");
        o.h(width, "width");
        this.distribution = distribution;
        this.spacing = f6;
        this.fillSpaceSpacer = fillSpaceSpacer;
        this.width = width;
        this.rowContent = ComposableSingletons$HorizontalStackKt.INSTANCE.m763getLambda1$revenuecatui_defaultsBc8Release();
    }
}
