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

import A2.c;
import B.AbstractC0057e;
import B.H0;
import E3.v;
import J4.a;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.Stable;
import androidx.compose.runtime.State;
import com.revenuecat.purchases.paywalls.components.properties.Dimension;
import com.revenuecat.purchases.paywalls.components.properties.Shape;
import com.revenuecat.purchases.paywalls.components.properties.Size;
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint;
import com.revenuecat.purchases.ui.revenuecatui.CustomVariableValue;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedStackPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BackgroundStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BorderStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.ShadowStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.state.PackageAwareDelegate;
import com.revenuecat.purchases.ui.revenuecatui.components.style.BadgeStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.ComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.StackComponentStyle;
import h1.f;
import h1.m;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import n2.AbstractC2612c;
import x.EnumC3207z0;
import x4.z;

/* JADX INFO: loaded from: classes3.dex */
@Stable
public final class StackComponentState {
    public static final int $stable = 0;
    private final boolean applyBottomWindowInsets;
    private final boolean applyHorizontalWindowInsets;
    private final boolean applyTopWindowInsets;
    private final State background$delegate;
    private final State badge$delegate;
    private final State border$delegate;
    private final List<ComponentStyle> children;
    private final a customVariablesProvider;
    private final State dimension$delegate;
    private final MutableState layoutDirection$delegate;
    private final State margin$delegate;
    private final PackageAwareDelegate packageAwareDelegate;
    private final State padding$delegate;
    private final State presentedPartial$delegate;
    private final State scrollOrientation$delegate;
    private final a selectedOfferEligibilityProvider;
    private final a selectedPackageInfoProvider;
    private final a selectedTabIndexProvider;
    private final State shadow$delegate;
    private final State shape$delegate;
    private final State size$delegate;
    private final State spacing$delegate;
    private final StackComponentStyle style;
    private final State visible$delegate;
    private final MutableState windowSize$delegate;

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

        public AnonymousClass1() {
            super(0);
        }

        @Override // J4.a
        public final Map<String, CustomVariableValue> invoke() {
            return z.f26066a;
        }
    }

    public StackComponentState(c initialWindowSize, m initialLayoutDirection, StackComponentStyle style, a selectedPackageInfoProvider, a selectedTabIndexProvider, a selectedOfferEligibilityProvider, a customVariablesProvider) {
        o.h(initialWindowSize, "initialWindowSize");
        o.h(initialLayoutDirection, "initialLayoutDirection");
        o.h(style, "style");
        o.h(selectedPackageInfoProvider, "selectedPackageInfoProvider");
        o.h(selectedTabIndexProvider, "selectedTabIndexProvider");
        o.h(selectedOfferEligibilityProvider, "selectedOfferEligibilityProvider");
        o.h(customVariablesProvider, "customVariablesProvider");
        this.style = style;
        this.selectedPackageInfoProvider = selectedPackageInfoProvider;
        this.selectedTabIndexProvider = selectedTabIndexProvider;
        this.selectedOfferEligibilityProvider = selectedOfferEligibilityProvider;
        this.customVariablesProvider = customVariablesProvider;
        this.windowSize$delegate = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(initialWindowSize, null, 2, null);
        this.layoutDirection$delegate = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(initialLayoutDirection, null, 2, null);
        this.packageAwareDelegate = new PackageAwareDelegate(style, selectedPackageInfoProvider, selectedTabIndexProvider, selectedOfferEligibilityProvider);
        this.presentedPartial$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$presentedPartial$2(this));
        this.visible$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$visible$2(this));
        this.children = style.getChildren();
        this.applyTopWindowInsets = style.getApplyTopWindowInsets();
        this.applyBottomWindowInsets = style.getApplyBottomWindowInsets();
        this.applyHorizontalWindowInsets = style.getApplyHorizontalWindowInsets();
        this.dimension$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$dimension$2(this));
        this.spacing$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$spacing$2(this));
        this.background$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$background$2(this));
        this.padding$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$padding$2(this));
        this.margin$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$margin$2(this));
        this.size$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$size$2(this));
        this.shape$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$shape$2(this));
        this.border$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$border$2(this));
        this.shadow$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$shadow$2(this));
        this.badge$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$badge$2(this));
        this.scrollOrientation$delegate = SnapshotStateKt.derivedStateOf(new StackComponentState$scrollOrientation$2(this));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Size adjustForMargin(Size size, H0 h0, m mVar) {
        SizeConstraint width = size.getWidth();
        if (width instanceof SizeConstraint.Fixed) {
            width = new SizeConstraint.Fixed(AbstractC2612c.l(AbstractC0057e.l(h0, mVar)) + AbstractC2612c.l(AbstractC0057e.m(h0, mVar)) + ((SizeConstraint.Fixed) width).m621getValuepVg5ArA(), null);
        } else {
            if (!(width instanceof SizeConstraint.Fill ? true : width instanceof SizeConstraint.Fit)) {
                throw new v();
            }
        }
        SizeConstraint height = size.getHeight();
        if (height instanceof SizeConstraint.Fixed) {
            height = new SizeConstraint.Fixed(AbstractC2612c.l(h0.a()) + AbstractC2612c.l(h0.c()) + ((SizeConstraint.Fixed) height).m621getValuepVg5ArA(), null);
        } else {
            if (!(height instanceof SizeConstraint.Fill ? true : height instanceof SizeConstraint.Fit)) {
                throw new v();
            }
        }
        return new Size(width, height);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    public final m getLayoutDirection() {
        return (m) this.layoutDirection$delegate.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final PresentedStackPartial getPresentedPartial() {
        return (PresentedStackPartial) this.presentedPartial$delegate.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    public final c getWindowSize() {
        return (c) this.windowSize$delegate.getValue();
    }

    private final void setLayoutDirection(m mVar) {
        this.layoutDirection$delegate.setValue(mVar);
    }

    private final void setWindowSize(c cVar) {
        this.windowSize$delegate.setValue(cVar);
    }

    public static /* synthetic */ void update$default(StackComponentState stackComponentState, c cVar, m mVar, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            cVar = null;
        }
        if ((i6 & 2) != 0) {
            mVar = null;
        }
        stackComponentState.update(cVar, mVar);
    }

    public final /* synthetic */ boolean getApplyBottomWindowInsets() {
        return this.applyBottomWindowInsets;
    }

    public final /* synthetic */ boolean getApplyHorizontalWindowInsets() {
        return this.applyHorizontalWindowInsets;
    }

    public final /* synthetic */ boolean getApplyTopWindowInsets() {
        return this.applyTopWindowInsets;
    }

    public final /* synthetic */ BackgroundStyles getBackground() {
        return (BackgroundStyles) this.background$delegate.getValue();
    }

    public final /* synthetic */ BadgeStyle getBadge() {
        return (BadgeStyle) this.badge$delegate.getValue();
    }

    public final /* synthetic */ BorderStyles getBorder() {
        return (BorderStyles) this.border$delegate.getValue();
    }

    public final /* synthetic */ List getChildren() {
        return this.children;
    }

    public final /* synthetic */ Dimension getDimension() {
        return (Dimension) this.dimension$delegate.getValue();
    }

    public final /* synthetic */ H0 getMargin() {
        return (H0) this.margin$delegate.getValue();
    }

    public final /* synthetic */ H0 getPadding() {
        return (H0) this.padding$delegate.getValue();
    }

    public final /* synthetic */ EnumC3207z0 getScrollOrientation() {
        return (EnumC3207z0) this.scrollOrientation$delegate.getValue();
    }

    public final /* synthetic */ ShadowStyles getShadow() {
        return (ShadowStyles) this.shadow$delegate.getValue();
    }

    public final /* synthetic */ Shape getShape() {
        return (Shape) this.shape$delegate.getValue();
    }

    public final /* synthetic */ Size getSize() {
        return (Size) this.size$delegate.getValue();
    }

    /* JADX INFO: renamed from: getSpacing-D9Ej5fM, reason: not valid java name */
    public final /* synthetic */ float m766getSpacingD9Ej5fM() {
        return ((f) this.spacing$delegate.getValue()).f16618a;
    }

    public final /* synthetic */ boolean getVisible() {
        return ((Boolean) this.visible$delegate.getValue()).booleanValue();
    }

    public final /* synthetic */ void update(c cVar, m mVar) {
        if (cVar != null) {
            setWindowSize(cVar);
        }
        if (mVar != null) {
            setLayoutDirection(mVar);
        }
    }

    public /* synthetic */ StackComponentState(c cVar, m mVar, StackComponentStyle stackComponentStyle, a aVar, a aVar2, a aVar3, a aVar4, int i6, h hVar) {
        this(cVar, mVar, stackComponentStyle, aVar, aVar2, aVar3, (i6 & 64) != 0 ? AnonymousClass1.INSTANCE : aVar4);
    }
}
