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

import A2.c;
import B.H0;
import E3.v;
import G0.InterfaceC0262j;
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.ImageUrls;
import com.revenuecat.purchases.paywalls.components.properties.Size;
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint;
import com.revenuecat.purchases.paywalls.components.properties.ThemeImageUrls;
import com.revenuecat.purchases.ui.revenuecatui.CustomVariableValue;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedImagePartial;
import com.revenuecat.purchases.ui.revenuecatui.components.modifier.AspectRatio;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BorderStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.ColorStyles;
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.ImageComponentStyle;
import h1.m;
import java.util.Map;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import n2.AbstractC2612c;
import p0.X;
import x4.z;

/* JADX INFO: loaded from: classes3.dex */
@Stable
public final class ImageComponentState {
    public static final int $stable = 0;
    private final State aspectRatio$delegate;
    private final State border$delegate;
    private final State contentScale$delegate;
    private final a customVariablesProvider;
    private final MutableState darkMode$delegate;
    private final MutableState density$delegate;
    private final State imageAspectRatio$delegate;
    private final State imageUrls$delegate;
    private final MutableState layoutDirection$delegate;
    private final a localeProvider;
    private final State margin$delegate;
    private final State marginAdjustedAspectRatio$delegate;
    private final State overlay$delegate;
    private final PackageAwareDelegate packageAwareDelegate;
    private final State padding$delegate;
    private final State presentedPartial$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 sizePlusMargin$delegate;
    private final ImageComponentStyle style;
    private final State themeImageUrls$delegate;
    private final State visible$delegate;
    private final MutableState windowSize$delegate;

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.image.ImageComponentState$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 ImageComponentState(c initialWindowSize, h1.c initialDensity, boolean z6, m initialLayoutDirection, ImageComponentStyle style, a localeProvider, a selectedPackageInfoProvider, a selectedTabIndexProvider, a selectedOfferEligibilityProvider, a customVariablesProvider) {
        o.h(initialWindowSize, "initialWindowSize");
        o.h(initialDensity, "initialDensity");
        o.h(initialLayoutDirection, "initialLayoutDirection");
        o.h(style, "style");
        o.h(localeProvider, "localeProvider");
        o.h(selectedPackageInfoProvider, "selectedPackageInfoProvider");
        o.h(selectedTabIndexProvider, "selectedTabIndexProvider");
        o.h(selectedOfferEligibilityProvider, "selectedOfferEligibilityProvider");
        o.h(customVariablesProvider, "customVariablesProvider");
        this.style = style;
        this.localeProvider = localeProvider;
        this.selectedPackageInfoProvider = selectedPackageInfoProvider;
        this.selectedTabIndexProvider = selectedTabIndexProvider;
        this.selectedOfferEligibilityProvider = selectedOfferEligibilityProvider;
        this.customVariablesProvider = customVariablesProvider;
        this.windowSize$delegate = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(initialWindowSize, null, 2, null);
        this.density$delegate = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(initialDensity, null, 2, null);
        this.darkMode$delegate = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(Boolean.valueOf(z6), 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 ImageComponentState$presentedPartial$2(this));
        this.themeImageUrls$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$themeImageUrls$2(this));
        this.visible$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$visible$2(this));
        this.imageUrls$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$imageUrls$2(this));
        this.imageAspectRatio$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$imageAspectRatio$2(this));
        this.size$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$size$2(this));
        this.aspectRatio$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$aspectRatio$2(this));
        this.padding$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$padding$2(this));
        this.margin$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$margin$2(this));
        this.sizePlusMargin$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$sizePlusMargin$2(this));
        this.marginAdjustedAspectRatio$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$marginAdjustedAspectRatio$2(this));
        this.shape$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$shape$2(this));
        this.border$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$border$2(this));
        this.shadow$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$shadow$2(this));
        this.overlay$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$overlay$2(this));
        this.contentScale$delegate = SnapshotStateKt.derivedStateOf(new ImageComponentState$contentScale$2(this));
    }

    /* JADX INFO: renamed from: adjustDimension-yOCu0fQ, reason: not valid java name */
    private final SizeConstraint m676adjustDimensionyOCu0fQ(SizeConstraint sizeConstraint, SizeConstraint sizeConstraint2, int i6, int i7, h1.c cVar) {
        if (!(sizeConstraint instanceof SizeConstraint.Fit)) {
            if (sizeConstraint instanceof SizeConstraint.Fill ? true : sizeConstraint instanceof SizeConstraint.Fixed) {
                return sizeConstraint;
            }
            throw new v();
        }
        if (sizeConstraint2 instanceof SizeConstraint.Fit) {
            return new SizeConstraint.Fixed(AbstractC2612c.l(cVar.L(i6)), null);
        }
        if (sizeConstraint2 instanceof SizeConstraint.Fill) {
            return sizeConstraint;
        }
        if (sizeConstraint2 instanceof SizeConstraint.Fixed) {
            return new SizeConstraint.Fixed(AbstractC2612c.l(cVar.N((((float) AbstractC2612c.u(((SizeConstraint.Fixed) sizeConstraint2).m621getValuepVg5ArA())) / cVar.L(i7)) * i6)), null);
        }
        throw new v();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Size adjustForImage(Size size, ImageUrls imageUrls, h1.c cVar) {
        return new Size(m676adjustDimensionyOCu0fQ(size.getWidth(), size.getHeight(), imageUrls.m620getWidthpVg5ArA(), imageUrls.m619getHeightpVg5ArA(), cVar), m676adjustDimensionyOCu0fQ(size.getHeight(), size.getWidth(), imageUrls.m619getHeightpVg5ArA(), imageUrls.m620getWidthpVg5ArA(), cVar));
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    public final boolean getDarkMode() {
        return ((Boolean) this.darkMode$delegate.getValue()).booleanValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final h1.c getDensity() {
        return (h1.c) this.density$delegate.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final float getImageAspectRatio() {
        return ((Number) this.imageAspectRatio$delegate.getValue()).floatValue();
    }

    /* 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 PresentedImagePartial getPresentedPartial() {
        return (PresentedImagePartial) this.presentedPartial$delegate.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final ThemeImageUrls getThemeImageUrls() {
        return (ThemeImageUrls) this.themeImageUrls$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 setDarkMode(boolean z6) {
        this.darkMode$delegate.setValue(Boolean.valueOf(z6));
    }

    private final void setDensity(h1.c cVar) {
        this.density$delegate.setValue(cVar);
    }

    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(ImageComponentState imageComponentState, c cVar, h1.c cVar2, Boolean bool, m mVar, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            cVar = null;
        }
        if ((i6 & 2) != 0) {
            cVar2 = null;
        }
        if ((i6 & 4) != 0) {
            bool = null;
        }
        if ((i6 & 8) != 0) {
            mVar = null;
        }
        imageComponentState.update(cVar, cVar2, bool, mVar);
    }

    public final /* synthetic */ AspectRatio getAspectRatio() {
        return (AspectRatio) this.aspectRatio$delegate.getValue();
    }

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

    public final /* synthetic */ InterfaceC0262j getContentScale() {
        return (InterfaceC0262j) this.contentScale$delegate.getValue();
    }

    public final /* synthetic */ ImageUrls getImageUrls() {
        return (ImageUrls) this.imageUrls$delegate.getValue();
    }

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

    public final /* synthetic */ AspectRatio getMarginAdjustedAspectRatio() {
        return (AspectRatio) this.marginAdjustedAspectRatio$delegate.getValue();
    }

    public final /* synthetic */ ColorStyles getOverlay() {
        return (ColorStyles) this.overlay$delegate.getValue();
    }

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

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

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

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

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

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

    public final /* synthetic */ void update(c cVar, h1.c cVar2, Boolean bool, m mVar) {
        if (cVar != null) {
            setWindowSize(cVar);
        }
        if (cVar2 != null) {
            setDensity(cVar2);
        }
        if (bool != null) {
            setDarkMode(bool.booleanValue());
        }
        if (mVar != null) {
            setLayoutDirection(mVar);
        }
    }

    public /* synthetic */ ImageComponentState(c cVar, h1.c cVar2, boolean z6, m mVar, ImageComponentStyle imageComponentStyle, a aVar, a aVar2, a aVar3, a aVar4, a aVar5, int i6, h hVar) {
        this(cVar, cVar2, z6, mVar, imageComponentStyle, aVar, aVar2, aVar3, aVar4, (i6 & 512) != 0 ? AnonymousClass1.INSTANCE : aVar5);
    }
}
