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

import B.AbstractC0057e;
import B.H0;
import E3.v;
import J4.c;
import X0.I;
import androidx.compose.runtime.Immutable;
import androidx.compose.runtime.internal.StabilityInferred;
import com.google.android.recaptcha.internal.a;
import com.revenuecat.purchases.ColorAlias;
import com.revenuecat.purchases.FontAlias;
import com.revenuecat.purchases.Offering;
import com.revenuecat.purchases.Package;
import com.revenuecat.purchases.paywalls.components.ButtonComponent;
import com.revenuecat.purchases.paywalls.components.CarouselComponent;
import com.revenuecat.purchases.paywalls.components.CountdownComponent;
import com.revenuecat.purchases.paywalls.components.IconComponent;
import com.revenuecat.purchases.paywalls.components.ImageComponent;
import com.revenuecat.purchases.paywalls.components.PackageComponent;
import com.revenuecat.purchases.paywalls.components.PartialCarouselComponent;
import com.revenuecat.purchases.paywalls.components.PartialIconComponent;
import com.revenuecat.purchases.paywalls.components.PartialImageComponent;
import com.revenuecat.purchases.paywalls.components.PartialStackComponent;
import com.revenuecat.purchases.paywalls.components.PartialTextComponent;
import com.revenuecat.purchases.paywalls.components.PartialTimelineComponent;
import com.revenuecat.purchases.paywalls.components.PartialTimelineComponentItem;
import com.revenuecat.purchases.paywalls.components.PartialVideoComponent;
import com.revenuecat.purchases.paywalls.components.PaywallComponent;
import com.revenuecat.purchases.paywalls.components.PurchaseButtonComponent;
import com.revenuecat.purchases.paywalls.components.StackComponent;
import com.revenuecat.purchases.paywalls.components.StickyFooterComponent;
import com.revenuecat.purchases.paywalls.components.TabControlButtonComponent;
import com.revenuecat.purchases.paywalls.components.TabControlComponent;
import com.revenuecat.purchases.paywalls.components.TabControlToggleComponent;
import com.revenuecat.purchases.paywalls.components.TabsComponent;
import com.revenuecat.purchases.paywalls.components.TextComponent;
import com.revenuecat.purchases.paywalls.components.TimelineComponent;
import com.revenuecat.purchases.paywalls.components.VideoComponent;
import com.revenuecat.purchases.paywalls.components.common.Background;
import com.revenuecat.purchases.paywalls.components.common.LocaleId;
import com.revenuecat.purchases.paywalls.components.common.LocalizationData;
import com.revenuecat.purchases.paywalls.components.common.LocalizationKey;
import com.revenuecat.purchases.paywalls.components.common.VariableLocalizationKey;
import com.revenuecat.purchases.paywalls.components.properties.Badge;
import com.revenuecat.purchases.paywalls.components.properties.Border;
import com.revenuecat.purchases.paywalls.components.properties.ColorScheme;
import com.revenuecat.purchases.paywalls.components.properties.CornerRadiuses;
import com.revenuecat.purchases.paywalls.components.properties.Dimension;
import com.revenuecat.purchases.paywalls.components.properties.MaskShape;
import com.revenuecat.purchases.paywalls.components.properties.Padding;
import com.revenuecat.purchases.paywalls.components.properties.Shadow;
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.paywalls.components.properties.ThemeImageUrls;
import com.revenuecat.purchases.paywalls.components.properties.ThemeVideoUrls;
import com.revenuecat.purchases.ui.revenuecatui.components.LocalizedTextPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedCarouselPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedIconPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedImagePartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedPartialKt;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedStackPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedTimelineItemPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedTimelinePartial;
import com.revenuecat.purchases.ui.revenuecatui.components.PresentedVideoPartial;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.AlignmentKt;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.FitModeKt;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.FontKt;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.LocalizationKt;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.PaddingKt;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.ShapeKt;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BackgroundStyleKt;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BackgroundStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BorderStyleKt;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.BorderStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.ColorStyleKt;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.ColorStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.FontSpec;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.FontSpecKt;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.ShadowStyleKt;
import com.revenuecat.purchases.ui.revenuecatui.components.properties.ShadowStyles;
import com.revenuecat.purchases.ui.revenuecatui.components.style.ButtonComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.CarouselComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.IconComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.TabControlStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.TabsComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.components.style.TimelineComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.composables.OfferEligibility;
import com.revenuecat.purchases.ui.revenuecatui.data.PaywallState;
import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError;
import com.revenuecat.purchases.ui.revenuecatui.extensions.OverflowExtensionsKt;
import com.revenuecat.purchases.ui.revenuecatui.extensions.PackageExtensionsKt;
import com.revenuecat.purchases.ui.revenuecatui.extensions.PageControlExtensionsKt;
import com.revenuecat.purchases.ui.revenuecatui.helpers.Logger;
import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyList;
import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyListKt;
import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyMap;
import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyMapKt;
import com.revenuecat.purchases.ui.revenuecatui.helpers.PromoOfferResolver;
import com.revenuecat.purchases.ui.revenuecatui.helpers.ResolvedOffer;
import com.revenuecat.purchases.ui.revenuecatui.helpers.Result;
import com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt;
import f1.C2023k;
import i0.InterfaceC2240d;
import i0.InterfaceC2241e;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import kotlin.jvm.internal.D;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import kotlin.jvm.internal.q;
import w4.C3137A;
import w4.k;
import x4.AbstractC3229F;
import x4.AbstractC3251q;
import x4.AbstractC3253s;
import x4.y;
import x4.z;

/* JADX INFO: loaded from: classes3.dex */
@Immutable
public final class StyleFactory {
    public static final int $stable = 0;
    public static final Companion Companion = new Companion(null);
    private static final Shape.Rectangle DEFAULT_SHAPE = new Shape.Rectangle((CornerRadiuses) null, 1, (h) null);
    private static final float DEFAULT_SPACING = 0.0f;
    private static final boolean DEFAULT_VISIBILITY = true;
    private final Map<ColorAlias, ColorScheme> colorAliases;
    private final Map<FontAlias, FontSpec> fontAliases;
    private final NonEmptyMap<LocaleId, NonEmptyMap<LocalizationKey, LocalizationData>> localizations;
    private final Offering offering;
    private final boolean stripRules;
    private final NonEmptyMap<LocaleId, NonEmptyMap<VariableLocalizationKey, String>> variableLocalizations;

    public static final class Companion {
        public /* synthetic */ Companion(h hVar) {
            this();
        }

        public final Shape.Rectangle getDEFAULT_SHAPE$revenuecatui_defaultsBc8Release() {
            return StyleFactory.DEFAULT_SHAPE;
        }

        private Companion() {
        }
    }

    public static final class StyleFactoryScope {
        private CountdownComponent.CountFrom countFrom;
        private final Map<Integer, c> countPredicates;
        private final Map<Integer, Integer> countValues;
        private Date countdownDate;
        private Integer defaultTabIndex;
        private PaywallState.Loaded.Components.AvailablePackages.Info packageInfo;
        private final Map<Integer, List<PaywallState.Loaded.Components.AvailablePackages.Info>> packagesByTab;
        private final List<PaywallState.Loaded.Components.AvailablePackages.Info> packagesOutsideTabs;
        private TabControlStyle tabControl;
        private Integer tabControlIndex;
        private Integer tabIndex;
        private final WindowInsetsState windowInsetsState;

        public static final class WindowInsetsState {
            private boolean applyTopWindowInsets;
            private boolean ignoreTopWindowInsets;
            private boolean stillLookingForHeaderMedia = true;
            private boolean topWindowInsetsApplied;

            private final boolean isHeaderImage(PaywallComponent paywallComponent) {
                boolean z6;
                if (paywallComponent instanceof ImageComponent) {
                    SizeConstraint width = ((ImageComponent) paywallComponent).getSize().getWidth();
                    if (width instanceof SizeConstraint.Fill) {
                        z6 = true;
                    } else {
                        if (!(width instanceof SizeConstraint.Fit ? true : width instanceof SizeConstraint.Fixed)) {
                            throw new v();
                        }
                        z6 = false;
                    }
                    if (z6) {
                        return true;
                    }
                }
                return false;
            }

            private final boolean isHeaderMedia(PaywallComponent paywallComponent) {
                return isHeaderImage(paywallComponent) || isHeaderVideo(paywallComponent);
            }

            private final boolean isHeaderVideo(PaywallComponent paywallComponent) {
                boolean z6;
                if (paywallComponent instanceof VideoComponent) {
                    SizeConstraint width = ((VideoComponent) paywallComponent).getSize().getWidth();
                    if (width instanceof SizeConstraint.Fill) {
                        z6 = true;
                    } else {
                        if (!(width instanceof SizeConstraint.Fit ? true : width instanceof SizeConstraint.Fixed)) {
                            throw new v();
                        }
                        z6 = false;
                    }
                    if (z6) {
                        return true;
                    }
                }
                return false;
            }

            public final boolean getApplyTopWindowInsets() {
                boolean z6 = this.applyTopWindowInsets;
                this.applyTopWindowInsets = false;
                return z6;
            }

            public final boolean getIgnoreTopWindowInsets() {
                boolean z6 = this.ignoreTopWindowInsets;
                this.ignoreTopWindowInsets = false;
                return z6;
            }

            public final boolean getTopWindowInsetsApplied() {
                return this.topWindowInsetsApplied;
            }

            public final void handleHeaderMediaViewWindowInsets(PaywallComponent component) {
                o.h(component, "component");
                boolean z6 = false;
                if (!(component instanceof StackComponent)) {
                    if (component instanceof ImageComponent) {
                        if (this.stillLookingForHeaderMedia) {
                            this.ignoreTopWindowInsets = isHeaderImage(component);
                        }
                        this.stillLookingForHeaderMedia = false;
                        return;
                    } else {
                        if (!(component instanceof VideoComponent)) {
                            this.stillLookingForHeaderMedia = false;
                            return;
                        }
                        if (this.stillLookingForHeaderMedia) {
                            this.ignoreTopWindowInsets = isHeaderVideo(component);
                        }
                        this.stillLookingForHeaderMedia = false;
                        return;
                    }
                }
                if (this.stillLookingForHeaderMedia) {
                    StackComponent stackComponent = (StackComponent) component;
                    Dimension dimension = stackComponent.getDimension();
                    if (dimension instanceof Dimension.ZLayer) {
                        PaywallComponent paywallComponent = (PaywallComponent) AbstractC3251q.g0(stackComponent.getComponents());
                        if (paywallComponent != null && isHeaderMedia(paywallComponent)) {
                            z6 = true;
                        }
                        this.topWindowInsetsApplied = z6;
                    } else {
                        if (!(dimension instanceof Dimension.Horizontal ? true : dimension instanceof Dimension.Vertical)) {
                            throw new v();
                        }
                    }
                    this.applyTopWindowInsets = z6;
                }
            }

            public final void setApplyTopWindowInsets(boolean z6) {
                this.applyTopWindowInsets = z6;
            }

            public final void setIgnoreTopWindowInsets(boolean z6) {
                this.ignoreTopWindowInsets = z6;
            }

            public final void setTopWindowInsetsApplied(boolean z6) {
                this.topWindowInsetsApplied = z6;
            }
        }

        @StabilityInferred(parameters = 1)
        public static final class WithCount<T> {
            public static final int $stable = 0;
            private final int count;
            private final T value;

            public WithCount(T t6, int i6) {
                this.value = t6;
                this.count = i6;
            }

            /* JADX WARN: Multi-variable type inference failed */
            public static /* synthetic */ WithCount copy$default(WithCount withCount, Object obj, int i6, int i7, Object obj2) {
                if ((i7 & 1) != 0) {
                    obj = withCount.value;
                }
                if ((i7 & 2) != 0) {
                    i6 = withCount.count;
                }
                return withCount.copy(obj, i6);
            }

            public final T component1() {
                return this.value;
            }

            public final int component2() {
                return this.count;
            }

            public final WithCount<T> copy(T t6, int i6) {
                return new WithCount<>(t6, i6);
            }

            public boolean equals(Object obj) {
                if (this == obj) {
                    return true;
                }
                if (!(obj instanceof WithCount)) {
                    return false;
                }
                WithCount withCount = (WithCount) obj;
                return o.c(this.value, withCount.value) && this.count == withCount.count;
            }

            public final int getCount() {
                return this.count;
            }

            public final T getValue() {
                return this.value;
            }

            public int hashCode() {
                T t6 = this.value;
                return Integer.hashCode(this.count) + ((t6 == null ? 0 : t6.hashCode()) * 31);
            }

            public String toString() {
                StringBuilder sb = new StringBuilder("WithCount(value=");
                sb.append(this.value);
                sb.append(", count=");
                return a.m(sb, this.count, ')');
            }
        }

        public StyleFactoryScope() {
            this(null, null, null, null, null, null, null, null, 255, null);
        }

        private final Map<Integer, c> component7() {
            return this.countPredicates;
        }

        private final Map<Integer, Integer> component8() {
            return this.countValues;
        }

        /* JADX WARN: Multi-variable type inference failed */
        public static /* synthetic */ StyleFactoryScope copy$default(StyleFactoryScope styleFactoryScope, PaywallState.Loaded.Components.AvailablePackages.Info info, TabControlStyle tabControlStyle, Integer num, Integer num2, Date date, CountdownComponent.CountFrom countFrom, Map map, Map map2, int i6, Object obj) {
            if ((i6 & 1) != 0) {
                info = styleFactoryScope.packageInfo;
            }
            if ((i6 & 2) != 0) {
                tabControlStyle = styleFactoryScope.tabControl;
            }
            if ((i6 & 4) != 0) {
                num = styleFactoryScope.tabControlIndex;
            }
            if ((i6 & 8) != 0) {
                num2 = styleFactoryScope.tabIndex;
            }
            if ((i6 & 16) != 0) {
                date = styleFactoryScope.countdownDate;
            }
            if ((i6 & 32) != 0) {
                countFrom = styleFactoryScope.countFrom;
            }
            if ((i6 & 64) != 0) {
                map = styleFactoryScope.countPredicates;
            }
            if ((i6 & 128) != 0) {
                map2 = styleFactoryScope.countValues;
            }
            Map map3 = map;
            Map map4 = map2;
            Date date2 = date;
            CountdownComponent.CountFrom countFrom2 = countFrom;
            return styleFactoryScope.copy(info, tabControlStyle, num, num2, date2, countFrom2, map3, map4);
        }

        private static Object getApplyTopWindowInsets$delegate(StyleFactoryScope styleFactoryScope) {
            q qVar = new q(styleFactoryScope.windowInsetsState, WindowInsetsState.class, "applyTopWindowInsets", "getApplyTopWindowInsets()Z", 0);
            D.f20116a.getClass();
            return qVar;
        }

        private static Object getIgnoreTopWindowInsets$delegate(StyleFactoryScope styleFactoryScope) {
            q qVar = new q(styleFactoryScope.windowInsetsState, WindowInsetsState.class, "ignoreTopWindowInsets", "getIgnoreTopWindowInsets()Z", 0);
            D.f20116a.getClass();
            return qVar;
        }

        private final void recordPackage(PaywallState.Loaded.Components.AvailablePackages.Info info) {
            Integer num = this.tabIndex;
            if (num == null) {
                this.packagesOutsideTabs.add(info);
                return;
            }
            Map<Integer, List<PaywallState.Loaded.Components.AvailablePackages.Info>> map = this.packagesByTab;
            List<PaywallState.Loaded.Components.AvailablePackages.Info> arrayList = map.get(num);
            if (arrayList == null) {
                arrayList = new ArrayList<>();
                map.put(num, arrayList);
            }
            arrayList.add(info);
        }

        public final <T extends ComponentStyle> T applyBottomWindowInsetsIfNecessary(T t6, boolean z6) {
            T tCopy = t6;
            o.h(tCopy, "<this>");
            if (z6) {
                if (tCopy instanceof StackComponentStyle) {
                    tCopy = StackComponentStyle.m790copyKMZiVUk$default((StackComponentStyle) tCopy, null, null, false, null, StyleFactory.DEFAULT_SPACING, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, true, false, 6291455, null);
                } else if (tCopy instanceof StickyFooterComponentStyle) {
                    StickyFooterComponentStyle stickyFooterComponentStyle = (StickyFooterComponentStyle) tCopy;
                    tCopy = stickyFooterComponentStyle.copy(StackComponentStyle.m790copyKMZiVUk$default(stickyFooterComponentStyle.getStackComponentStyle(), null, null, false, null, StyleFactory.DEFAULT_SPACING, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, true, false, 6291455, null));
                }
                o.f(tCopy, "null cannot be cast to non-null type T of com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory.StyleFactoryScope.applyBottomWindowInsetsIfNecessary");
            }
            return tCopy;
        }

        public final <T extends ComponentStyle> T applyHorizontalWindowInsetsIfNecessary(T t6, boolean z6) {
            T tCopy = t6;
            o.h(tCopy, "<this>");
            if (z6) {
                if (tCopy instanceof StackComponentStyle) {
                    tCopy = StackComponentStyle.m790copyKMZiVUk$default((StackComponentStyle) tCopy, null, null, false, null, StyleFactory.DEFAULT_SPACING, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, false, true, 4194303, null);
                } else if (tCopy instanceof StickyFooterComponentStyle) {
                    StickyFooterComponentStyle stickyFooterComponentStyle = (StickyFooterComponentStyle) tCopy;
                    tCopy = stickyFooterComponentStyle.copy(StackComponentStyle.m790copyKMZiVUk$default(stickyFooterComponentStyle.getStackComponentStyle(), null, null, false, null, StyleFactory.DEFAULT_SPACING, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, false, true, 4194303, null));
                }
                o.f(tCopy, "null cannot be cast to non-null type T of com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory.StyleFactoryScope.applyHorizontalWindowInsetsIfNecessary");
            }
            return tCopy;
        }

        public final ComponentStyle applyTopWindowInsetsIfNotYetApplied(ComponentStyle to) {
            o.h(to, "to");
            return to instanceof StackComponentStyle ? StackComponentStyle.m790copyKMZiVUk$default((StackComponentStyle) to, null, null, false, null, StyleFactory.DEFAULT_SPACING, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, !this.windowInsetsState.getTopWindowInsetsApplied(), false, false, 7340031, null) : to;
        }

        public final PaywallState.Loaded.Components.AvailablePackages.Info component1() {
            return this.packageInfo;
        }

        public final TabControlStyle component2() {
            return this.tabControl;
        }

        public final Integer component3() {
            return this.tabControlIndex;
        }

        public final Integer component4() {
            return this.tabIndex;
        }

        public final Date component5() {
            return this.countdownDate;
        }

        public final CountdownComponent.CountFrom component6() {
            return this.countFrom;
        }

        public final StyleFactoryScope copy(PaywallState.Loaded.Components.AvailablePackages.Info info, TabControlStyle tabControlStyle, Integer num, Integer num2, Date date, CountdownComponent.CountFrom countFrom, Map<Integer, c> countPredicates, Map<Integer, Integer> countValues) {
            o.h(countFrom, "countFrom");
            o.h(countPredicates, "countPredicates");
            o.h(countValues, "countValues");
            return new StyleFactoryScope(info, tabControlStyle, num, num2, date, countFrom, countPredicates, countValues);
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof StyleFactoryScope)) {
                return false;
            }
            StyleFactoryScope styleFactoryScope = (StyleFactoryScope) obj;
            return o.c(this.packageInfo, styleFactoryScope.packageInfo) && o.c(this.tabControl, styleFactoryScope.tabControl) && o.c(this.tabControlIndex, styleFactoryScope.tabControlIndex) && o.c(this.tabIndex, styleFactoryScope.tabIndex) && o.c(this.countdownDate, styleFactoryScope.countdownDate) && this.countFrom == styleFactoryScope.countFrom && o.c(this.countPredicates, styleFactoryScope.countPredicates) && o.c(this.countValues, styleFactoryScope.countValues);
        }

        public final boolean getApplyTopWindowInsets() {
            return this.windowInsetsState.getApplyTopWindowInsets();
        }

        public final CountdownComponent.CountFrom getCountFrom() {
            return this.countFrom;
        }

        public final Date getCountdownDate() {
            return this.countdownDate;
        }

        public final Integer getDefaultTabIndex() {
            return this.defaultTabIndex;
        }

        public final boolean getIgnoreTopWindowInsets() {
            return this.windowInsetsState.getIgnoreTopWindowInsets();
        }

        public final OfferEligibility getOfferEligibility() {
            PaywallState.Loaded.Components.AvailablePackages.Info info = this.packageInfo;
            if (info != null) {
                return PackageExtensionsKt.calculateOfferEligibility(info.getResolvedOffer(), info.getPkg());
            }
            return null;
        }

        public final PaywallState.Loaded.Components.AvailablePackages.Info getPackageInfo() {
            return this.packageInfo;
        }

        public final PaywallState.Loaded.Components.AvailablePackages getPackages() {
            return new PaywallState.Loaded.Components.AvailablePackages(this.packagesOutsideTabs, this.packagesByTab);
        }

        public final Package getRcPackage() {
            PaywallState.Loaded.Components.AvailablePackages.Info info = this.packageInfo;
            if (info != null) {
                return info.getPkg();
            }
            return null;
        }

        public final ResolvedOffer getResolvedOffer() {
            PaywallState.Loaded.Components.AvailablePackages.Info info = this.packageInfo;
            if (info != null) {
                return info.getResolvedOffer();
            }
            return null;
        }

        public final TabControlStyle getTabControl() {
            return this.tabControl;
        }

        public final Integer getTabControlIndex() {
            return this.tabControlIndex;
        }

        public final Integer getTabIndex() {
            return this.tabIndex;
        }

        public final WindowInsetsState getWindowInsetsState() {
            return this.windowInsetsState;
        }

        public int hashCode() {
            PaywallState.Loaded.Components.AvailablePackages.Info info = this.packageInfo;
            int iHashCode = (info == null ? 0 : info.hashCode()) * 31;
            TabControlStyle tabControlStyle = this.tabControl;
            int iHashCode2 = (iHashCode + (tabControlStyle == null ? 0 : tabControlStyle.hashCode())) * 31;
            Integer num = this.tabControlIndex;
            int iHashCode3 = (iHashCode2 + (num == null ? 0 : num.hashCode())) * 31;
            Integer num2 = this.tabIndex;
            int iHashCode4 = (iHashCode3 + (num2 == null ? 0 : num2.hashCode())) * 31;
            Date date = this.countdownDate;
            return this.countValues.hashCode() + A0.a.d(this.countPredicates, (this.countFrom.hashCode() + ((iHashCode4 + (date != null ? date.hashCode() : 0)) * 31)) * 31, 31);
        }

        public final void recordComponent(PaywallComponent component) {
            o.h(component, "component");
            for (Map.Entry<Integer, c> entry : this.countPredicates.entrySet()) {
                int iIntValue = entry.getKey().intValue();
                if (((Boolean) entry.getValue().invoke(component)).booleanValue()) {
                    Integer num = this.countValues.get(Integer.valueOf(iIntValue));
                    this.countValues.put(Integer.valueOf(iIntValue), Integer.valueOf((num != null ? num.intValue() : 0) + 1));
                }
            }
            this.windowInsetsState.handleHeaderMediaViewWindowInsets(component);
        }

        public final void setCountFrom(CountdownComponent.CountFrom countFrom) {
            o.h(countFrom, "<set-?>");
            this.countFrom = countFrom;
        }

        public final void setCountdownDate(Date date) {
            this.countdownDate = date;
        }

        public final void setDefaultTabIndex(Integer num) {
            this.defaultTabIndex = num;
        }

        public final void setPackageInfo(PaywallState.Loaded.Components.AvailablePackages.Info info) {
            this.packageInfo = info;
        }

        public final void setTabControl(TabControlStyle tabControlStyle) {
            this.tabControl = tabControlStyle;
        }

        public final void setTabControlIndex(Integer num) {
            this.tabControlIndex = num;
        }

        public final void setTabIndex(Integer num) {
            this.tabIndex = num;
        }

        public String toString() {
            return "StyleFactoryScope(packageInfo=" + this.packageInfo + ", tabControl=" + this.tabControl + ", tabControlIndex=" + this.tabControlIndex + ", tabIndex=" + this.tabIndex + ", countdownDate=" + this.countdownDate + ", countFrom=" + this.countFrom + ", countPredicates=" + this.countPredicates + ", countValues=" + this.countValues + ')';
        }

        public final <T> WithCount<T> withCount(c predicate, c block) {
            o.h(predicate, "predicate");
            o.h(block, "block");
            Integer num = (Integer) AbstractC3251q.p0(this.countPredicates.keySet());
            int iIntValue = (num != null ? num.intValue() : -1) + 1;
            this.countPredicates.put(Integer.valueOf(iIntValue), predicate);
            this.countValues.put(Integer.valueOf(iIntValue), 0);
            WithCount<T> withCount = new WithCount<>(block.invoke(this), ((Number) AbstractC3229F.t(Integer.valueOf(iIntValue), this.countValues)).intValue());
            this.countPredicates.remove(Integer.valueOf(iIntValue));
            this.countValues.remove(Integer.valueOf(iIntValue));
            return withCount;
        }

        public final <T> T withCountdown(Date countdownDate, CountdownComponent.CountFrom countFrom, c block) {
            o.h(countdownDate, "countdownDate");
            o.h(countFrom, "countFrom");
            o.h(block, "block");
            StyleFactoryScope styleFactoryScopeCopy$default = copy$default(this, null, null, null, null, null, null, null, null, 255, null);
            this.countdownDate = countdownDate;
            this.countFrom = countFrom;
            T t6 = (T) block.invoke(this);
            this.countdownDate = styleFactoryScopeCopy$default.countdownDate;
            this.countFrom = styleFactoryScopeCopy$default.countFrom;
            return t6;
        }

        public final <T> T withSelectedScope(PaywallState.Loaded.Components.AvailablePackages.Info info, Integer num, c block) {
            o.h(block, "block");
            if (info != null) {
                recordPackage(info);
            }
            StyleFactoryScope styleFactoryScopeCopy$default = copy$default(this, null, null, null, null, null, null, null, null, 255, null);
            this.packageInfo = info;
            this.tabControlIndex = num;
            T t6 = (T) block.invoke(this);
            this.packageInfo = styleFactoryScopeCopy$default.packageInfo;
            this.tabControlIndex = styleFactoryScopeCopy$default.tabControlIndex;
            return t6;
        }

        public final <T> T withTabControl(TabControlStyle tabControl, c block) {
            o.h(tabControl, "tabControl");
            o.h(block, "block");
            StyleFactoryScope styleFactoryScopeCopy$default = copy$default(this, null, null, null, null, null, null, null, null, 255, null);
            this.tabControl = tabControl;
            T t6 = (T) block.invoke(this);
            this.tabControl = styleFactoryScopeCopy$default.tabControl;
            return t6;
        }

        public final <T> T withTabIndex(int i6, c block) {
            o.h(block, "block");
            StyleFactoryScope styleFactoryScopeCopy$default = copy$default(this, null, null, null, null, null, null, null, null, 255, null);
            this.tabIndex = Integer.valueOf(i6);
            T t6 = (T) block.invoke(this);
            this.tabIndex = styleFactoryScopeCopy$default.tabIndex;
            return t6;
        }

        public StyleFactoryScope(PaywallState.Loaded.Components.AvailablePackages.Info info, TabControlStyle tabControlStyle, Integer num, Integer num2, Date date, CountdownComponent.CountFrom countFrom, Map<Integer, c> countPredicates, Map<Integer, Integer> countValues) {
            o.h(countFrom, "countFrom");
            o.h(countPredicates, "countPredicates");
            o.h(countValues, "countValues");
            this.packageInfo = info;
            this.tabControl = tabControlStyle;
            this.tabControlIndex = num;
            this.tabIndex = num2;
            this.countdownDate = date;
            this.countFrom = countFrom;
            this.countPredicates = countPredicates;
            this.countValues = countValues;
            this.windowInsetsState = new WindowInsetsState();
            this.packagesOutsideTabs = new ArrayList();
            this.packagesByTab = new LinkedHashMap();
        }

        public /* synthetic */ StyleFactoryScope(PaywallState.Loaded.Components.AvailablePackages.Info info, TabControlStyle tabControlStyle, Integer num, Integer num2, Date date, CountdownComponent.CountFrom countFrom, Map map, Map map2, int i6, h hVar) {
            this((i6 & 1) != 0 ? null : info, (i6 & 2) != 0 ? null : tabControlStyle, (i6 & 4) != 0 ? null : num, (i6 & 8) != 0 ? null : num2, (i6 & 16) != 0 ? null : date, (i6 & 32) != 0 ? CountdownComponent.CountFrom.DAYS : countFrom, (i6 & 64) != 0 ? new LinkedHashMap() : map, (i6 & 128) != 0 ? new LinkedHashMap() : map2);
        }
    }

    @Immutable
    public static final class StyleResult {
        public static final int $stable = 0;
        private final PaywallState.Loaded.Components.AvailablePackages availablePackages;
        private final ComponentStyle componentStyle;
        private final Integer defaultTabIndex;

        public StyleResult(ComponentStyle componentStyle, PaywallState.Loaded.Components.AvailablePackages availablePackages, Integer num) {
            o.h(componentStyle, "componentStyle");
            o.h(availablePackages, "availablePackages");
            this.componentStyle = componentStyle;
            this.availablePackages = availablePackages;
            this.defaultTabIndex = num;
        }

        public final PaywallState.Loaded.Components.AvailablePackages getAvailablePackages() {
            return this.availablePackages;
        }

        public final ComponentStyle getComponentStyle() {
            return this.componentStyle;
        }

        public final Integer getDefaultTabIndex() {
            return this.defaultTabIndex;
        }
    }

    public /* synthetic */ class WhenMappings {
        public static final /* synthetic */ int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[ButtonComponent.UrlMethod.values().length];
            try {
                iArr[ButtonComponent.UrlMethod.IN_APP_BROWSER.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[ButtonComponent.UrlMethod.EXTERNAL_BROWSER.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[ButtonComponent.UrlMethod.DEEP_LINK.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[ButtonComponent.UrlMethod.UNKNOWN.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

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

        @Override // J4.c
        public final Result<PresentedCarouselPartial, NonEmptyList<PaywallValidationError>> invoke(PartialCarouselComponent partial) {
            o.h(partial, "partial");
            return PresentedCarouselPartial.Companion.invoke(partial, StyleFactory.this.colorAliases);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createCountdownComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15591 extends p implements c {
        final /* synthetic */ CountdownComponent $component;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C15591(CountdownComponent countdownComponent) {
            super(1);
            this.$component = countdownComponent;
        }

        @Override // J4.c
        public final Result<CountdownComponentStyle, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withCountdown) {
            o.h(withCountdown, "$this$withCountdown");
            Result resultCreateStackComponentStyle = StyleFactory.this.createStackComponentStyle(withCountdown, this.$component.getCountdownStack());
            StackComponent endStack = this.$component.getEndStack();
            Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(endStack != null ? StyleFactory.this.createStackComponentStyle(withCountdown, endStack) : null);
            StackComponent fallback = this.$component.getFallback();
            Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(fallback != null ? StyleFactory.this.createStackComponentStyle(withCountdown, fallback) : null);
            CountdownComponent countdownComponent = this.$component;
            C3137A c3137a = C3137A.f25453a;
            Result.Success success = new Result.Success(c3137a);
            Result.Success success2 = new Result.Success(c3137a);
            Result.Success success3 = new Result.Success(c3137a);
            NonEmptyList nonEmptyListH = a.h(new Result[]{resultCreateStackComponentStyle, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, success, success2, success3});
            if (nonEmptyListH != null) {
                return new Result.Error(nonEmptyListH);
            }
            o.f(resultCreateStackComponentStyle, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
            Object value = ((Result.Success) resultCreateStackComponentStyle).getValue();
            o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
            Object value2 = ((Result.Success) resultOrSuccessfullyNull).getValue();
            o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
            Object value3 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
            Object value4 = success.getValue();
            Object value5 = success2.getValue();
            return new Result.Success(new CountdownComponentStyle(countdownComponent.getStyle().getDate(), countdownComponent.getCountFrom(), (StackComponentStyle) value, (StackComponentStyle) value2, (StackComponentStyle) value3));
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createIconComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15601 extends p implements c {
        public C15601() {
            super(1);
        }

        @Override // J4.c
        public final Result<PresentedIconPartial, NonEmptyList<PaywallValidationError>> invoke(PartialIconComponent partial) {
            o.h(partial, "partial");
            return PresentedIconPartial.Companion.invoke(partial, StyleFactory.this.colorAliases);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createImageComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15611 extends p implements c {
        public C15611() {
            super(1);
        }

        @Override // J4.c
        public final Result<PresentedImagePartial, NonEmptyList<PaywallValidationError>> invoke(PartialImageComponent it) {
            o.h(it, "it");
            ThemeImageUrls source = it.getSource();
            Result<PresentedImagePartial, NonEmptyList<PaywallValidationError>> resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(source != null ? StyleFactory.this.m797withLocalizedOverridesTDPsjl0(source, it.m552getOverrideSourceLidsa7TU9Q()) : null);
            StyleFactory styleFactory = StyleFactory.this;
            if (resultOrSuccessfullyNull instanceof Result.Success) {
                return PresentedImagePartial.Companion.invoke(it, (NonEmptyMap) ((Result.Success) resultOrSuccessfullyNull).getValue(), styleFactory.colorAliases);
            }
            if (resultOrSuccessfullyNull instanceof Result.Error) {
                return resultOrSuccessfullyNull;
            }
            throw new v();
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createStackComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15621 extends p implements c {
        final /* synthetic */ StyleFactoryScope $this_createStackComponentStyle;

        /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createStackComponentStyle$1$1, reason: invalid class name and collision with other inner class name */
        public static final class C00341 extends p implements c {
            final /* synthetic */ StyleFactoryScope $this_createStackComponentStyle;
            final /* synthetic */ StyleFactory this$0;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C00341(StyleFactory styleFactory, StyleFactoryScope styleFactoryScope) {
                super(1);
                this.this$0 = styleFactory;
                this.$this_createStackComponentStyle = styleFactoryScope;
            }

            @Override // J4.c
            public final Result<StackComponentStyle, NonEmptyList<PaywallValidationError>> invoke(StackComponent stackComponent) {
                o.h(stackComponent, "stackComponent");
                return this.this$0.createStackComponentStyle(this.$this_createStackComponentStyle, stackComponent);
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C15621(StyleFactoryScope styleFactoryScope) {
            super(1);
            this.$this_createStackComponentStyle = styleFactoryScope;
        }

        @Override // J4.c
        public final Result<PresentedStackPartial, NonEmptyList<PaywallValidationError>> invoke(PartialStackComponent partial) {
            o.h(partial, "partial");
            return PresentedStackPartial.Companion.invoke(partial, StyleFactory.this.colorAliases, new C00341(StyleFactory.this, this.$this_createStackComponentStyle));
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createStackComponentStyle$6, reason: invalid class name */
    public static final class AnonymousClass6 extends p implements c {
        final /* synthetic */ StyleFactoryScope $this_createStackComponentStyle;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass6(StyleFactoryScope styleFactoryScope) {
            super(1);
            this.$this_createStackComponentStyle = styleFactoryScope;
        }

        @Override // J4.c
        public final Result<StackComponentStyle, NonEmptyList<PaywallValidationError>> invoke(StackComponent stackComponent) {
            o.h(stackComponent, "stackComponent");
            return StyleFactory.this.createStackComponentStyle(this.$this_createStackComponentStyle, stackComponent);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createStickyFooterComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15631 extends p implements c {
        final /* synthetic */ StickyFooterComponent $component;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C15631(StickyFooterComponent stickyFooterComponent) {
            super(1);
            this.$component = stickyFooterComponent;
        }

        @Override // J4.c
        public final Result<StickyFooterComponentStyle, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withSelectedScope) {
            o.h(withSelectedScope, "$this$withSelectedScope");
            Result<StickyFooterComponentStyle, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle = StyleFactory.this.createStackComponentStyle(withSelectedScope, this.$component.getStack());
            if (resultCreateStackComponentStyle instanceof Result.Success) {
                return new Result.Success(new StickyFooterComponentStyle((StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue()));
            }
            if (resultCreateStackComponentStyle instanceof Result.Error) {
                return resultCreateStackComponentStyle;
            }
            throw new v();
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTabControlButtonComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15641 extends p implements c {
        final /* synthetic */ TabControlButtonComponent $component;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C15641(TabControlButtonComponent tabControlButtonComponent) {
            super(1);
            this.$component = tabControlButtonComponent;
        }

        @Override // J4.c
        public final Result<TabControlButtonComponentStyle, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withSelectedScope) {
            o.h(withSelectedScope, "$this$withSelectedScope");
            withSelectedScope.setDefaultTabIndex(0);
            Result<TabControlButtonComponentStyle, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle = StyleFactory.this.createStackComponentStyle(withSelectedScope, this.$component.getStack());
            TabControlButtonComponent tabControlButtonComponent = this.$component;
            if (resultCreateStackComponentStyle instanceof Result.Success) {
                return new Result.Success(new TabControlButtonComponentStyle(tabControlButtonComponent.getTabIndex(), (StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue()));
            }
            if (resultCreateStackComponentStyle instanceof Result.Error) {
                return resultCreateStackComponentStyle;
            }
            throw new v();
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTabsComponentStyleTab$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15651 extends p implements c {
        final /* synthetic */ TabsComponent.Tab $componentTab;
        final /* synthetic */ TabControlStyle $control;
        final /* synthetic */ int $tabIndex;
        final /* synthetic */ StyleFactory this$0;

        /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTabsComponentStyleTab$1$1, reason: invalid class name and collision with other inner class name */
        public static final class C00351 extends p implements c {
            final /* synthetic */ TabsComponent.Tab $componentTab;
            final /* synthetic */ TabControlStyle $control;
            final /* synthetic */ StyleFactory this$0;

            /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTabsComponentStyleTab$1$1$1, reason: invalid class name and collision with other inner class name */
            public static final class C00361 extends p implements c {
                final /* synthetic */ TabsComponent.Tab $componentTab;
                final /* synthetic */ StyleFactory this$0;

                /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
                public C00361(StyleFactory styleFactory, TabsComponent.Tab tab) {
                    super(1);
                    this.this$0 = styleFactory;
                    this.$componentTab = tab;
                }

                @Override // J4.c
                public final Result<TabsComponentStyle.Tab, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withTabControl) {
                    o.h(withTabControl, "$this$withTabControl");
                    Result<TabsComponentStyle.Tab, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle = this.this$0.createStackComponentStyle(withTabControl, this.$componentTab.getStack());
                    if (resultCreateStackComponentStyle instanceof Result.Success) {
                        return new Result.Success(new TabsComponentStyle.Tab((StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue()));
                    }
                    if (resultCreateStackComponentStyle instanceof Result.Error) {
                        return resultCreateStackComponentStyle;
                    }
                    throw new v();
                }
            }

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C00351(TabControlStyle tabControlStyle, StyleFactory styleFactory, TabsComponent.Tab tab) {
                super(1);
                this.$control = tabControlStyle;
                this.this$0 = styleFactory;
                this.$componentTab = tab;
            }

            @Override // J4.c
            public final Result<TabsComponentStyle.Tab, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withTabIndex) {
                o.h(withTabIndex, "$this$withTabIndex");
                return (Result) withTabIndex.withTabControl(this.$control, new C00361(this.this$0, this.$componentTab));
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C15651(int i6, TabControlStyle tabControlStyle, StyleFactory styleFactory, TabsComponent.Tab tab) {
            super(1);
            this.$tabIndex = i6;
            this.$control = tabControlStyle;
            this.this$0 = styleFactory;
            this.$componentTab = tab;
        }

        @Override // J4.c
        public final Result<TabsComponentStyle.Tab, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withSelectedScope) {
            o.h(withSelectedScope, "$this$withSelectedScope");
            return (Result) withSelectedScope.withTabIndex(this.$tabIndex, new C00351(this.$control, this.this$0, this.$componentTab));
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTabsComponentStyleTabControl$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15661 extends p implements c {
        final /* synthetic */ TabsComponent.TabControl $componentControl;
        final /* synthetic */ StyleFactory this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C15661(TabsComponent.TabControl tabControl, StyleFactory styleFactory) {
            super(1);
            this.$componentControl = tabControl;
            this.this$0 = styleFactory;
        }

        @Override // J4.c
        public final Result<TabControlStyle, NonEmptyList<PaywallValidationError>> invoke(StyleFactoryScope withSelectedScope) {
            o.h(withSelectedScope, "$this$withSelectedScope");
            TabsComponent.TabControl tabControl = this.$componentControl;
            if (tabControl instanceof TabsComponent.TabControl.Buttons) {
                Result<TabControlStyle, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle = this.this$0.createStackComponentStyle(withSelectedScope, ((TabsComponent.TabControl.Buttons) tabControl).getStack());
                if (resultCreateStackComponentStyle instanceof Result.Success) {
                    return new Result.Success(new TabControlStyle.Buttons((StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue()));
                }
                if (resultCreateStackComponentStyle instanceof Result.Error) {
                    return resultCreateStackComponentStyle;
                }
                throw new v();
            }
            if (!(tabControl instanceof TabsComponent.TabControl.Toggle)) {
                throw new v();
            }
            Result<TabControlStyle, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle2 = this.this$0.createStackComponentStyle(withSelectedScope, ((TabsComponent.TabControl.Toggle) tabControl).getStack());
            if (resultCreateStackComponentStyle2 instanceof Result.Success) {
                return new Result.Success(new TabControlStyle.Toggle((StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle2).getValue()));
            }
            if (resultCreateStackComponentStyle2 instanceof Result.Error) {
                return resultCreateStackComponentStyle2;
            }
            throw new v();
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTextComponentStyle$2, reason: invalid class name */
    public static final class AnonymousClass2 extends p implements c {
        public AnonymousClass2() {
            super(1);
        }

        @Override // J4.c
        public final Result<LocalizedTextPartial, NonEmptyList<PaywallValidationError>> invoke(PartialTextComponent it) {
            o.h(it, "it");
            return LocalizedTextPartial.Companion.invoke(it, StyleFactory.this.localizations, StyleFactory.this.colorAliases, StyleFactory.this.fontAliases);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createTimelineComponentItemStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15671 extends p implements c {
        public C15671() {
            super(1);
        }

        @Override // J4.c
        public final Result<PresentedTimelineItemPartial, NonEmptyList<PaywallValidationError>> invoke(PartialTimelineComponentItem partial) {
            o.h(partial, "partial");
            return PresentedTimelineItemPartial.Companion.invoke(partial, StyleFactory.this.colorAliases);
        }
    }

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

        public C15681() {
            super(1);
        }

        @Override // J4.c
        public final Result<PresentedTimelinePartial, NonEmptyList<PaywallValidationError>> invoke(PartialTimelineComponent partial) {
            o.h(partial, "partial");
            return new Result.Success(new PresentedTimelinePartial(partial));
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.style.StyleFactory$createVideoComponentStyle$1, reason: invalid class name and case insensitive filesystem */
    public static final class C15691 extends p implements c {
        public C15691() {
            super(1);
        }

        @Override // J4.c
        public final Result<PresentedVideoPartial, NonEmptyList<PaywallValidationError>> invoke(PartialVideoComponent videoPartial) {
            Result resultM797withLocalizedOverridesTDPsjl0;
            o.h(videoPartial, "videoPartial");
            ThemeVideoUrls source = videoPartial.getSource();
            NonEmptyMap nonEmptyMap = null;
            Result<PresentedVideoPartial, NonEmptyList<PaywallValidationError>> resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(source != null ? StyleFactory.this.m798withLocalizedOverridesTDPsjl0(source, videoPartial.m558getOverrideSourceLidsa7TU9Q()) : null);
            StyleFactory styleFactory = StyleFactory.this;
            if (!(resultOrSuccessfullyNull instanceof Result.Success)) {
                if (resultOrSuccessfullyNull instanceof Result.Error) {
                    return resultOrSuccessfullyNull;
                }
                throw new v();
            }
            NonEmptyMap nonEmptyMap2 = (NonEmptyMap) ((Result.Success) resultOrSuccessfullyNull).getValue();
            PresentedVideoPartial.Companion companion = PresentedVideoPartial.Companion;
            ThemeImageUrls fallbackSource = videoPartial.getFallbackSource();
            if (fallbackSource != null && (resultM797withLocalizedOverridesTDPsjl0 = styleFactory.m797withLocalizedOverridesTDPsjl0(fallbackSource, videoPartial.m558getOverrideSourceLidsa7TU9Q())) != null && (resultM797withLocalizedOverridesTDPsjl0 instanceof Result.Success)) {
                nonEmptyMap = (NonEmptyMap) ((Result.Success) resultM797withLocalizedOverridesTDPsjl0).getValue();
            }
            return companion.invoke(videoPartial, nonEmptyMap2, nonEmptyMap, styleFactory.colorAliases);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public StyleFactory(NonEmptyMap<LocaleId, ? extends NonEmptyMap<LocalizationKey, ? extends LocalizationData>> localizations, Map<ColorAlias, ColorScheme> colorAliases, Map<FontAlias, ? extends FontSpec> fontAliases, NonEmptyMap<LocaleId, NonEmptyMap<VariableLocalizationKey, String>> variableLocalizations, Offering offering, boolean z6) {
        o.h(localizations, "localizations");
        o.h(colorAliases, "colorAliases");
        o.h(fontAliases, "fontAliases");
        o.h(variableLocalizations, "variableLocalizations");
        o.h(offering, "offering");
        this.localizations = localizations;
        this.colorAliases = colorAliases;
        this.fontAliases = fontAliases;
        this.variableLocalizations = variableLocalizations;
        this.offering = offering;
        this.stripRules = z6;
    }

    /* JADX INFO: renamed from: buttonComponentStyleUrlDestination-26kQY28, reason: not valid java name */
    private final Result<ButtonComponentStyle.Action.NavigateTo.Destination.Url, NonEmptyList<PaywallValidationError.MissingStringLocalization>> m796buttonComponentStyleUrlDestination26kQY28(String str, ButtonComponent.UrlMethod urlMethod) {
        Result<ButtonComponentStyle.Action.NavigateTo.Destination.Url, NonEmptyList<PaywallValidationError.MissingStringLocalization>> resultM688stringForAllLocales7v81vok = LocalizationKt.m688stringForAllLocales7v81vok(this.localizations, str);
        if (resultM688stringForAllLocales7v81vok instanceof Result.Success) {
            resultM688stringForAllLocales7v81vok = new Result.Success<>(new ButtonComponentStyle.Action.NavigateTo.Destination.Url((NonEmptyMap) ((Result.Success) resultM688stringForAllLocales7v81vok).getValue(), urlMethod));
        } else if (!(resultM688stringForAllLocales7v81vok instanceof Result.Error)) {
            throw new v();
        }
        if (!(resultM688stringForAllLocales7v81vok instanceof Result.Success)) {
            if (resultM688stringForAllLocales7v81vok instanceof Result.Error) {
                return resultM688stringForAllLocales7v81vok;
            }
            throw new v();
        }
        ButtonComponentStyle.Action.NavigateTo.Destination.Url url = (ButtonComponentStyle.Action.NavigateTo.Destination.Url) ((Result.Success) resultM688stringForAllLocales7v81vok).getValue();
        int i6 = WhenMappings.$EnumSwitchMapping$0[url.getMethod().ordinal()];
        if (i6 != 1 && i6 != 2 && i6 != 3) {
            if (i6 != 4) {
                throw new v();
            }
            url = null;
        }
        return new Result.Success(url);
    }

    private final Result<ButtonComponentStyle.Action, NonEmptyList<PaywallValidationError>> convertAction(StyleFactoryScope styleFactoryScope, ButtonComponent.Action action) {
        if (action instanceof ButtonComponent.Action.NavigateBack) {
            return new Result.Success(ButtonComponentStyle.Action.NavigateBack.INSTANCE);
        }
        if (action instanceof ButtonComponent.Action.RestorePurchases) {
            return new Result.Success(ButtonComponentStyle.Action.RestorePurchases.INSTANCE);
        }
        if (!(action instanceof ButtonComponent.Action.NavigateTo)) {
            if (action instanceof ButtonComponent.Action.Unknown) {
                return new Result.Success(null);
            }
            throw new v();
        }
        Result resultConvertDestination = convertDestination(styleFactoryScope, ((ButtonComponent.Action.NavigateTo) action).getDestination());
        if (resultConvertDestination instanceof Result.Success) {
            ButtonComponentStyle.Action.NavigateTo.Destination destination = (ButtonComponentStyle.Action.NavigateTo.Destination) ((Result.Success) resultConvertDestination).getValue();
            return new Result.Success(destination != null ? new ButtonComponentStyle.Action.NavigateTo(destination) : null);
        }
        if (resultConvertDestination instanceof Result.Error) {
            return resultConvertDestination;
        }
        throw new v();
    }

    private final Result<ButtonComponentStyle.Action.NavigateTo.Destination, NonEmptyList<PaywallValidationError>> convertDestination(StyleFactoryScope styleFactoryScope, ButtonComponent.Destination destination) {
        if (destination instanceof ButtonComponent.Destination.CustomerCenter) {
            return new Result.Success(ButtonComponentStyle.Action.NavigateTo.Destination.CustomerCenter.INSTANCE);
        }
        if (destination instanceof ButtonComponent.Destination.PrivacyPolicy) {
            ButtonComponent.Destination.PrivacyPolicy privacyPolicy = (ButtonComponent.Destination.PrivacyPolicy) destination;
            return m796buttonComponentStyleUrlDestination26kQY28(privacyPolicy.m536getUrlLidz7Tp4o(), privacyPolicy.getMethod());
        }
        if (destination instanceof ButtonComponent.Destination.Terms) {
            ButtonComponent.Destination.Terms terms = (ButtonComponent.Destination.Terms) destination;
            return m796buttonComponentStyleUrlDestination26kQY28(terms.m540getUrlLidz7Tp4o(), terms.getMethod());
        }
        if (destination instanceof ButtonComponent.Destination.Url) {
            ButtonComponent.Destination.Url url = (ButtonComponent.Destination.Url) destination;
            return m796buttonComponentStyleUrlDestination26kQY28(url.m544getUrlLidz7Tp4o(), url.getMethod());
        }
        if (!(destination instanceof ButtonComponent.Destination.Sheet)) {
            if (destination instanceof ButtonComponent.Destination.Unknown) {
                return new Result.Success(null);
            }
            throw new v();
        }
        ButtonComponent.Destination.Sheet sheet = (ButtonComponent.Destination.Sheet) destination;
        Result resultCreateStackComponentStyle = createStackComponentStyle(styleFactoryScope, sheet.getStack());
        if (resultCreateStackComponentStyle instanceof Result.Success) {
            resultCreateStackComponentStyle = new Result.Success((StackComponentStyle) styleFactoryScope.applyBottomWindowInsetsIfNecessary((StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue(), true));
        } else if (!(resultCreateStackComponentStyle instanceof Result.Error)) {
            throw new v();
        }
        if (resultCreateStackComponentStyle instanceof Result.Success) {
            resultCreateStackComponentStyle = new Result.Success((StackComponentStyle) styleFactoryScope.applyHorizontalWindowInsetsIfNecessary((StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue(), true));
        } else if (!(resultCreateStackComponentStyle instanceof Result.Error)) {
            throw new v();
        }
        if (resultCreateStackComponentStyle instanceof Result.Success) {
            return new Result.Success(new ButtonComponentStyle.Action.NavigateTo.Destination.Sheet(sheet.getId(), sheet.getName(), (StackComponentStyle) ((Result.Success) resultCreateStackComponentStyle).getValue(), sheet.getBackgroundBlur(), sheet.getSize()));
        }
        if (resultCreateStackComponentStyle instanceof Result.Error) {
            return resultCreateStackComponentStyle;
        }
        throw new v();
    }

    private final Result<ButtonComponentStyle.Action, NonEmptyList<PaywallValidationError>> convertPurchaseButtonMethod(StyleFactoryScope styleFactoryScope, PurchaseButtonComponent.Method method) {
        boolean zBooleanValue;
        if (method == null) {
            return new Result.Success(new ButtonComponentStyle.Action.PurchasePackage(styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer()));
        }
        if (method instanceof PurchaseButtonComponent.Method.InAppCheckout) {
            return new Result.Success(new ButtonComponentStyle.Action.PurchasePackage(styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer()));
        }
        if (method instanceof PurchaseButtonComponent.Method.WebCheckout) {
            Package rcPackage = styleFactoryScope.getRcPackage();
            PurchaseButtonComponent.Method.WebCheckout webCheckout = (PurchaseButtonComponent.Method.WebCheckout) method;
            Boolean autoDismiss = webCheckout.getAutoDismiss();
            zBooleanValue = autoDismiss != null ? autoDismiss.booleanValue() : true;
            ButtonComponent.UrlMethod openMethod = webCheckout.getOpenMethod();
            if (openMethod == null) {
                openMethod = ButtonComponent.UrlMethod.EXTERNAL_BROWSER;
            }
            return new Result.Success(new ButtonComponentStyle.Action.WebCheckout(rcPackage, zBooleanValue, openMethod));
        }
        if (method instanceof PurchaseButtonComponent.Method.WebProductSelection) {
            PurchaseButtonComponent.Method.WebProductSelection webProductSelection = (PurchaseButtonComponent.Method.WebProductSelection) method;
            Boolean autoDismiss2 = webProductSelection.getAutoDismiss();
            zBooleanValue = autoDismiss2 != null ? autoDismiss2.booleanValue() : true;
            ButtonComponent.UrlMethod openMethod2 = webProductSelection.getOpenMethod();
            if (openMethod2 == null) {
                openMethod2 = ButtonComponent.UrlMethod.EXTERNAL_BROWSER;
            }
            return new Result.Success(new ButtonComponentStyle.Action.WebProductSelection(zBooleanValue, openMethod2));
        }
        if (!(method instanceof PurchaseButtonComponent.Method.CustomWebCheckout)) {
            if (!(method instanceof PurchaseButtonComponent.Method.Unknown)) {
                throw new v();
            }
            Logger.INSTANCE.e("Unknown purchase button method. Defaulting to purchasing current/default package.");
            return new Result.Success(new ButtonComponentStyle.Action.PurchasePackage(styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer()));
        }
        PurchaseButtonComponent.Method.CustomWebCheckout customWebCheckout = (PurchaseButtonComponent.Method.CustomWebCheckout) method;
        Result<ButtonComponentStyle.Action, NonEmptyList<PaywallValidationError>> resultM688stringForAllLocales7v81vok = LocalizationKt.m688stringForAllLocales7v81vok(this.localizations, customWebCheckout.getCustomUrl().m563getUrlLidz7Tp4o());
        if (!(resultM688stringForAllLocales7v81vok instanceof Result.Success)) {
            if (resultM688stringForAllLocales7v81vok instanceof Result.Error) {
                return resultM688stringForAllLocales7v81vok;
            }
            throw new v();
        }
        NonEmptyMap nonEmptyMap = (NonEmptyMap) ((Result.Success) resultM688stringForAllLocales7v81vok).getValue();
        Boolean autoDismiss3 = customWebCheckout.getAutoDismiss();
        boolean zBooleanValue2 = autoDismiss3 != null ? autoDismiss3.booleanValue() : true;
        ButtonComponent.UrlMethod openMethod3 = customWebCheckout.getOpenMethod();
        if (openMethod3 == null) {
            openMethod3 = ButtonComponent.UrlMethod.EXTERNAL_BROWSER;
        }
        return new Result.Success(new ButtonComponentStyle.Action.CustomWebCheckout(nonEmptyMap, zBooleanValue2, openMethod3, styleFactoryScope.getRcPackage(), customWebCheckout.getCustomUrl().getPackageParam()));
    }

    public static /* synthetic */ Result create$default(StyleFactory styleFactory, PaywallComponent paywallComponent, boolean z6, boolean z7, int i6, Object obj) {
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        if ((i6 & 4) != 0) {
            z7 = false;
        }
        return styleFactory.create(paywallComponent, z6, z7);
    }

    private final Result<BackgroundStyles, NonEmptyList<PaywallValidationError>> createBackgroundStyles(Background background, ColorScheme colorScheme) {
        Result colorStyles;
        Result<BackgroundStyles, NonEmptyList<PaywallValidationError>> backgroundStyles;
        if (background != null && (backgroundStyles = BackgroundStyleKt.toBackgroundStyles(background, this.colorAliases)) != null) {
            return backgroundStyles;
        }
        if (colorScheme == null || (colorStyles = ColorStyleKt.toColorStyles(colorScheme, this.colorAliases)) == null) {
            colorStyles = null;
        } else if (colorStyles instanceof Result.Success) {
            colorStyles = new Result.Success(BackgroundStyles.Color.m710boximpl(BackgroundStyles.Color.m711constructorimpl((ColorStyles) ((Result.Success) colorStyles).getValue())));
        } else if (!(colorStyles instanceof Result.Error)) {
            throw new v();
        }
        return ResultKt.orSuccessfullyNull(colorStyles);
    }

    private final Result<ButtonComponentStyle, NonEmptyList<PaywallValidationError>> createButtonComponentStyleOrNull(StyleFactoryScope styleFactoryScope, ButtonComponent buttonComponent) {
        Result<StackComponentStyle, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle = createStackComponentStyle(styleFactoryScope, buttonComponent.getStack());
        Result<ButtonComponentStyle.Action, NonEmptyList<PaywallValidationError>> resultConvertAction = convertAction(styleFactoryScope, buttonComponent.getAction());
        C3137A c3137a = C3137A.f25453a;
        Result.Success success = new Result.Success(c3137a);
        Result.Success success2 = new Result.Success(c3137a);
        Result.Success success3 = new Result.Success(c3137a);
        Result.Success success4 = new Result.Success(c3137a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{resultCreateStackComponentStyle, resultConvertAction, success, success2, success3, success4});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(resultCreateStackComponentStyle, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) resultCreateStackComponentStyle).getValue();
        o.f(resultConvertAction, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) resultConvertAction).getValue();
        Object value3 = success.getValue();
        Object value4 = success2.getValue();
        Object value5 = success3.getValue();
        ButtonComponentStyle.Action action = (ButtonComponentStyle.Action) value2;
        return new Result.Success(action != null ? new ButtonComponentStyle((StackComponentStyle) value, action, buttonComponent.getTransition()) : null);
    }

    private final Result<CarouselComponentStyle, NonEmptyList<PaywallValidationError>> createCarouselComponentStyle(StyleFactoryScope styleFactoryScope, CarouselComponent carouselComponent) {
        Result error;
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(carouselComponent.getOverrides(), this.stripRules, new AnonymousClass1());
        if (presentedOverrides instanceof Result.Success) {
            error = presentedOverrides;
        } else {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            error = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        List pages = carouselComponent.getPages();
        ArrayList<Result> arrayList = new ArrayList(AbstractC3253s.G(pages, 10));
        Iterator it = pages.iterator();
        while (it.hasNext()) {
            arrayList.add(createStackComponentStyle(styleFactoryScope, (StackComponent) it.next()));
        }
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        for (Result result : arrayList) {
            if (result instanceof Result.Success) {
                if (arrayList3.isEmpty()) {
                    arrayList2.add((StackComponentStyle) ((Result.Success) result).getValue());
                }
            } else if (result instanceof Result.Error) {
                arrayList3.addAll((Collection) ((Result.Error) result).getValue());
            }
        }
        NonEmptyList nonEmptyListOrNull = NonEmptyListKt.toNonEmptyListOrNull(arrayList3);
        Result error2 = nonEmptyListOrNull != null ? new Result.Error(nonEmptyListOrNull) : new Result.Success(arrayList2);
        Border border = carouselComponent.getBorder();
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(border != null ? BorderStyleKt.toBorderStyles(border, this.colorAliases) : null);
        Shadow shadow = carouselComponent.getShadow();
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(shadow != null ? ShadowStyleKt.toShadowStyles(shadow, this.colorAliases) : null);
        Result<BackgroundStyles, NonEmptyList<PaywallValidationError>> resultCreateBackgroundStyles = createBackgroundStyles(carouselComponent.getBackground(), carouselComponent.getBackgroundColor());
        CarouselComponent.PageControl pageControl = carouselComponent.getPageControl();
        Result resultOrSuccessfullyNull3 = ResultKt.orSuccessfullyNull(pageControl != null ? PageControlExtensionsKt.toPageControlStyles(pageControl, this.colorAliases) : null);
        NonEmptyList nonEmptyListH = a.h(new Result[]{error, error2, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, resultCreateBackgroundStyles, resultOrSuccessfullyNull3});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(error, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) error).getValue();
        Object value2 = ((Result.Success) error2).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        o.f(resultCreateBackgroundStyles, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultCreateBackgroundStyles).getValue();
        o.f(resultOrSuccessfullyNull3, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<F of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        CarouselComponentStyle.PageControlStyles pageControlStyles = (CarouselComponentStyle.PageControlStyles) ((Result.Success) resultOrSuccessfullyNull3).getValue();
        BackgroundStyles backgroundStyles = (BackgroundStyles) value5;
        ShadowStyles shadowStyles = (ShadowStyles) value4;
        BorderStyles borderStyles = (BorderStyles) value3;
        List list = (List) value2;
        List list2 = (List) value;
        Integer initialPageIndex = carouselComponent.getInitialPageIndex();
        int iIntValue = initialPageIndex != null ? initialPageIndex.intValue() : 0;
        InterfaceC2241e alignment = AlignmentKt.toAlignment(carouselComponent.getPageAlignment());
        Boolean visible = carouselComponent.getVisible();
        boolean zBooleanValue = visible != null ? visible.booleanValue() : true;
        Size size = carouselComponent.getSize();
        float fIntValue = carouselComponent.getPagePeek() != null ? r2.intValue() : 0;
        Float pageSpacing = carouselComponent.getPageSpacing();
        float fFloatValue = pageSpacing != null ? pageSpacing.floatValue() : DEFAULT_SPACING;
        H0 paddingValues = PaddingKt.toPaddingValues(carouselComponent.getPadding());
        H0 paddingValues2 = PaddingKt.toPaddingValues(carouselComponent.getMargin());
        Shape shape = carouselComponent.getShape();
        if (shape == null) {
            shape = DEFAULT_SHAPE;
        }
        Shape shape2 = shape;
        Boolean loop = carouselComponent.getLoop();
        return new Result.Success(new CarouselComponentStyle(list, iIntValue, alignment, zBooleanValue, size, fIntValue, fFloatValue, backgroundStyles, paddingValues, paddingValues2, shape2, borderStyles, shadowStyles, pageControlStyles, loop != null ? loop.booleanValue() : false, carouselComponent.getAutoAdvance(), styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), list2, null));
    }

    private final Result<CountdownComponentStyle, NonEmptyList<PaywallValidationError>> createCountdownComponentStyle(StyleFactoryScope styleFactoryScope, CountdownComponent countdownComponent) {
        return (Result) styleFactoryScope.withCountdown(countdownComponent.getStyle().getDate(), countdownComponent.getCountFrom(), new C15591(countdownComponent));
    }

    private final Result<IconComponentStyle, NonEmptyList<PaywallValidationError>> createIconComponentStyle(StyleFactoryScope styleFactoryScope, IconComponent iconComponent) {
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(iconComponent.getOverrides(), this.stripRules, new C15601());
        if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        ColorScheme color = iconComponent.getColor();
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(color != null ? ColorStyleKt.toColorStyles(color, this.colorAliases) : null);
        IconComponent.IconBackground iconBackground = iconComponent.getIconBackground();
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(iconBackground != null ? IconComponentStyleKt.toBackground(iconBackground, this.colorAliases) : null);
        C3137A c3137a = C3137A.f25453a;
        Result.Success success = new Result.Success(c3137a);
        Result.Success success2 = new Result.Success(c3137a);
        Result.Success success3 = new Result.Success(c3137a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{presentedOverrides, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, success, success2, success3});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(presentedOverrides, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) presentedOverrides).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        Object value4 = success.getValue();
        Object value5 = success2.getValue();
        IconComponentStyle.Background background = (IconComponentStyle.Background) value3;
        ColorStyles colorStyles = (ColorStyles) value2;
        List list = (List) value;
        String baseUrl = iconComponent.getBaseUrl();
        String iconName = iconComponent.getIconName();
        IconComponent.Formats formats = iconComponent.getFormats();
        Boolean visible = iconComponent.getVisible();
        return new Result.Success(new IconComponentStyle(baseUrl, iconName, formats, visible != null ? visible.booleanValue() : true, iconComponent.getSize(), colorStyles, PaddingKt.toPaddingValues(iconComponent.getPadding()), PaddingKt.toPaddingValues(iconComponent.getMargin()), background, styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), list));
    }

    private final Result<ImageComponentStyle, NonEmptyList<PaywallValidationError>> createImageComponentStyle(StyleFactoryScope styleFactoryScope, ImageComponent imageComponent) {
        Result<NonEmptyMap<LocaleId, ThemeImageUrls>, NonEmptyList<PaywallValidationError.MissingImageLocalization>> resultM797withLocalizedOverridesTDPsjl0 = m797withLocalizedOverridesTDPsjl0(imageComponent.getSource(), imageComponent.m550getOverrideSourceLidsa7TU9Q());
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(imageComponent.getOverrides(), this.stripRules, new C15611());
        if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        ColorScheme colorOverlay = imageComponent.getColorOverlay();
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(colorOverlay != null ? ColorStyleKt.toColorStyles(colorOverlay, this.colorAliases) : null);
        Border border = imageComponent.getBorder();
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(border != null ? BorderStyleKt.toBorderStyles(border, this.colorAliases) : null);
        Shadow shadow = imageComponent.getShadow();
        Result resultOrSuccessfullyNull3 = ResultKt.orSuccessfullyNull(shadow != null ? ShadowStyleKt.toShadowStyles(shadow, this.colorAliases) : null);
        Result.Success success = new Result.Success(C3137A.f25453a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{resultM797withLocalizedOverridesTDPsjl0, presentedOverrides, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, resultOrSuccessfullyNull3, success});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(resultM797withLocalizedOverridesTDPsjl0, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) resultM797withLocalizedOverridesTDPsjl0).getValue();
        o.f(presentedOverrides, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) presentedOverrides).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        o.f(resultOrSuccessfullyNull3, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultOrSuccessfullyNull3).getValue();
        ShadowStyles shadowStyles = (ShadowStyles) value5;
        BorderStyles borderStyles = (BorderStyles) value4;
        ColorStyles colorStyles = (ColorStyles) value3;
        List list = (List) value2;
        NonEmptyMap nonEmptyMap = (NonEmptyMap) value;
        Boolean visible = imageComponent.getVisible();
        boolean zBooleanValue = visible != null ? visible.booleanValue() : true;
        Size size = imageComponent.getSize();
        H0 paddingValues = PaddingKt.toPaddingValues(imageComponent.getPadding());
        H0 paddingValues2 = PaddingKt.toPaddingValues(imageComponent.getMargin());
        MaskShape maskShape = imageComponent.getMaskShape();
        return new Result.Success(new ImageComponentStyle(nonEmptyMap, zBooleanValue, size, paddingValues, paddingValues2, maskShape != null ? ShapeKt.toShape(maskShape) : null, borderStyles, shadowStyles, colorStyles, FitModeKt.toContentScale(imageComponent.getFitMode()), styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), list, styleFactoryScope.getIgnoreTopWindowInsets()));
    }

    private final Result<ComponentStyle, NonEmptyList<PaywallValidationError>> createInternal(StyleFactoryScope styleFactoryScope, PaywallComponent paywallComponent) {
        styleFactoryScope.recordComponent(paywallComponent);
        if (paywallComponent instanceof ButtonComponent) {
            return createButtonComponentStyleOrNull(styleFactoryScope, (ButtonComponent) paywallComponent);
        }
        if (paywallComponent instanceof ImageComponent) {
            return createImageComponentStyle(styleFactoryScope, (ImageComponent) paywallComponent);
        }
        if (paywallComponent instanceof PackageComponent) {
            return createPackageComponentStyle(styleFactoryScope, (PackageComponent) paywallComponent);
        }
        if (paywallComponent instanceof PurchaseButtonComponent) {
            return createPurchaseButtonComponentStyle(styleFactoryScope, (PurchaseButtonComponent) paywallComponent);
        }
        if (paywallComponent instanceof StackComponent) {
            return createStackComponentStyle(styleFactoryScope, (StackComponent) paywallComponent);
        }
        if (paywallComponent instanceof StickyFooterComponent) {
            return createStickyFooterComponentStyle(styleFactoryScope, (StickyFooterComponent) paywallComponent);
        }
        if (paywallComponent instanceof TextComponent) {
            return createTextComponentStyle(styleFactoryScope, (TextComponent) paywallComponent);
        }
        if (paywallComponent instanceof IconComponent) {
            return createIconComponentStyle(styleFactoryScope, (IconComponent) paywallComponent);
        }
        if (paywallComponent instanceof TimelineComponent) {
            return createTimelineComponentStyle(styleFactoryScope, (TimelineComponent) paywallComponent);
        }
        if (paywallComponent instanceof CarouselComponent) {
            return createCarouselComponentStyle(styleFactoryScope, (CarouselComponent) paywallComponent);
        }
        if (paywallComponent instanceof TabControlButtonComponent) {
            return createTabControlButtonComponentStyle(styleFactoryScope, (TabControlButtonComponent) paywallComponent);
        }
        if (paywallComponent instanceof TabControlToggleComponent) {
            return createTabControlToggleComponentStyle(styleFactoryScope, (TabControlToggleComponent) paywallComponent);
        }
        if (paywallComponent instanceof TabControlComponent) {
            return ResultKt.errorIfNull(styleFactoryScope.getTabControl(), NonEmptyListKt.nonEmptyListOf(PaywallValidationError.TabControlNotInTab.INSTANCE, new PaywallValidationError.TabControlNotInTab[0]));
        }
        if (paywallComponent instanceof TabsComponent) {
            return createTabsComponentStyle(styleFactoryScope, (TabsComponent) paywallComponent);
        }
        if (paywallComponent instanceof VideoComponent) {
            return createVideoComponentStyle(styleFactoryScope, (VideoComponent) paywallComponent);
        }
        if (paywallComponent instanceof CountdownComponent) {
            return createCountdownComponentStyle(styleFactoryScope, (CountdownComponent) paywallComponent);
        }
        throw new v();
    }

    private final Result<PackageComponentStyle, NonEmptyList<PaywallValidationError>> createPackageComponentStyle(StyleFactoryScope styleFactoryScope, PackageComponent packageComponent) {
        Package r02 = (Package) new Result.Success(getPackageOrNull(this.offering, packageComponent.getPackageId())).getValue();
        if (r02 != null) {
            ResolvedOffer resolvedOfferResolve = PromoOfferResolver.INSTANCE.resolve(r02, packageComponent.getPlayStoreOffer());
            return (Result) styleFactoryScope.withSelectedScope(new PaywallState.Loaded.Components.AvailablePackages.Info(r02, packageComponent.isSelectedByDefault(), resolvedOfferResolve), null, new StyleFactory$createPackageComponentStyle$1$1(this, packageComponent, r02, resolvedOfferResolve));
        }
        String identifier = this.offering.getIdentifier();
        String packageId = packageComponent.getPackageId();
        List<Package> availablePackages = this.offering.getAvailablePackages();
        ArrayList arrayList = new ArrayList(AbstractC3253s.G(availablePackages, 10));
        Iterator<T> it = availablePackages.iterator();
        while (it.hasNext()) {
            arrayList.add(((Package) it.next()).getIdentifier());
        }
        Logger.INSTANCE.w(new PaywallValidationError.MissingPackage(identifier, packageId, arrayList).getMessage());
        return new Result.Success(null);
    }

    private final Result<ButtonComponentStyle, NonEmptyList<PaywallValidationError>> createPurchaseButtonComponentStyle(StyleFactoryScope styleFactoryScope, PurchaseButtonComponent purchaseButtonComponent) {
        Result<StackComponentStyle, NonEmptyList<PaywallValidationError>> resultCreateStackComponentStyle = createStackComponentStyle(styleFactoryScope, purchaseButtonComponent.getStack());
        PurchaseButtonComponent.Method method = purchaseButtonComponent.getMethod();
        if (method == null) {
            PurchaseButtonComponent.Action action = purchaseButtonComponent.getAction();
            method = action != null ? action.toMethod() : null;
        }
        Result<ButtonComponentStyle.Action, NonEmptyList<PaywallValidationError>> resultConvertPurchaseButtonMethod = convertPurchaseButtonMethod(styleFactoryScope, method);
        C3137A c3137a = C3137A.f25453a;
        Result.Success success = new Result.Success(c3137a);
        Result.Success success2 = new Result.Success(c3137a);
        Result.Success success3 = new Result.Success(c3137a);
        Result.Success success4 = new Result.Success(c3137a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{resultCreateStackComponentStyle, resultConvertPurchaseButtonMethod, success, success2, success3, success4});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(resultCreateStackComponentStyle, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) resultCreateStackComponentStyle).getValue();
        o.f(resultConvertPurchaseButtonMethod, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) resultConvertPurchaseButtonMethod).getValue();
        Object value3 = success.getValue();
        Object value4 = success2.getValue();
        Object value5 = success3.getValue();
        return new Result.Success(new ButtonComponentStyle((StackComponentStyle) value, (ButtonComponentStyle.Action) value2, null, 4, null));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Result<StackComponentStyle, NonEmptyList<PaywallValidationError>> createStackComponentStyle(StyleFactoryScope styleFactoryScope, StackComponent stackComponent) {
        Result error;
        Result success;
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(stackComponent.getOverrides(), this.stripRules, new C15621(styleFactoryScope));
        if (presentedOverrides instanceof Result.Success) {
            error = presentedOverrides;
        } else {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            error = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        List components = stackComponent.getComponents();
        ArrayList<Result> arrayList = new ArrayList(AbstractC3253s.G(components, 10));
        Iterator it = components.iterator();
        while (it.hasNext()) {
            arrayList.add(createInternal(styleFactoryScope, (PaywallComponent) it.next()));
        }
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        for (Result result : arrayList) {
            if (result instanceof Result.Success) {
                if (arrayList3.isEmpty()) {
                    arrayList2.add((ComponentStyle) ((Result.Success) result).getValue());
                }
            } else if (result instanceof Result.Error) {
                arrayList3.addAll((Collection) ((Result.Error) result).getValue());
            }
        }
        NonEmptyList nonEmptyListOrNull = NonEmptyListKt.toNonEmptyListOrNull(arrayList3);
        Result error2 = nonEmptyListOrNull != null ? new Result.Error(nonEmptyListOrNull) : new Result.Success(arrayList2);
        if (error2 instanceof Result.Success) {
            success = new Result.Success(AbstractC3251q.c0((List) ((Result.Success) error2).getValue()));
        } else {
            if (!(error2 instanceof Result.Error)) {
                throw new v();
            }
            success = error2;
        }
        Badge badge = stackComponent.getBadge();
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(badge != null ? BadgeStyleKt.toBadgeStyle(badge, new AnonymousClass6(styleFactoryScope)) : null);
        Result<BackgroundStyles, NonEmptyList<PaywallValidationError>> resultCreateBackgroundStyles = createBackgroundStyles(stackComponent.getBackground(), stackComponent.getBackgroundColor());
        Border border = stackComponent.getBorder();
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(border != null ? BorderStyleKt.toBorderStyles(border, this.colorAliases) : null);
        Shadow shadow = stackComponent.getShadow();
        Result resultOrSuccessfullyNull3 = ResultKt.orSuccessfullyNull(shadow != null ? ShadowStyleKt.toShadowStyles(shadow, this.colorAliases) : null);
        NonEmptyList nonEmptyListH = a.h(new Result[]{error, success, resultOrSuccessfullyNull, resultCreateBackgroundStyles, resultOrSuccessfullyNull2, resultOrSuccessfullyNull3});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(error, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) error).getValue();
        Object value2 = ((Result.Success) success).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultCreateBackgroundStyles, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultCreateBackgroundStyles).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        o.f(resultOrSuccessfullyNull3, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<F of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        ShadowStyles shadowStyles = (ShadowStyles) ((Result.Success) resultOrSuccessfullyNull3).getValue();
        BorderStyles borderStyles = (BorderStyles) value5;
        BackgroundStyles backgroundStyles = (BackgroundStyles) value4;
        BadgeStyle badgeStyle = (BadgeStyle) value3;
        List list = (List) value2;
        List list2 = (List) value;
        Dimension dimension = stackComponent.getDimension();
        Boolean visible = stackComponent.getVisible();
        boolean zBooleanValue = visible != null ? visible.booleanValue() : true;
        Size size = stackComponent.getSize();
        Float spacing = stackComponent.getSpacing();
        float fFloatValue = spacing != null ? spacing.floatValue() : DEFAULT_SPACING;
        H0 paddingValues = PaddingKt.toPaddingValues(stackComponent.getPadding());
        H0 paddingValues2 = PaddingKt.toPaddingValues(stackComponent.getMargin());
        Shape shape = stackComponent.getShape();
        if (shape == null) {
            shape = DEFAULT_SHAPE;
        }
        Shape shape2 = shape;
        StackComponent.Overflow overflow = stackComponent.getOverflow();
        return new Result.Success(new StackComponentStyle(list, dimension, zBooleanValue, size, fFloatValue, backgroundStyles, paddingValues, paddingValues2, shape2, borderStyles, shadowStyles, badgeStyle, overflow != null ? OverflowExtensionsKt.toOrientation(overflow, stackComponent.getDimension()) : null, styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), styleFactoryScope.getCountdownDate(), styleFactoryScope.getCountFrom(), list2, styleFactoryScope.getApplyTopWindowInsets(), false, false, 6291456, null));
    }

    private final Result<StickyFooterComponentStyle, NonEmptyList<PaywallValidationError>> createStickyFooterComponentStyle(StyleFactoryScope styleFactoryScope, StickyFooterComponent stickyFooterComponent) {
        return (Result) styleFactoryScope.withSelectedScope(null, null, new C15631(stickyFooterComponent));
    }

    private final Result<TabControlButtonComponentStyle, NonEmptyList<PaywallValidationError>> createTabControlButtonComponentStyle(StyleFactoryScope styleFactoryScope, TabControlButtonComponent tabControlButtonComponent) {
        return (Result) styleFactoryScope.withSelectedScope(null, Integer.valueOf(tabControlButtonComponent.getTabIndex()), new C15641(tabControlButtonComponent));
    }

    private final Result<TabControlToggleComponentStyle, NonEmptyList<PaywallValidationError>> createTabControlToggleComponentStyle(StyleFactoryScope styleFactoryScope, TabControlToggleComponent tabControlToggleComponent) {
        Result colorStyles = ColorStyleKt.toColorStyles(tabControlToggleComponent.getThumbColorOn(), this.colorAliases);
        Result colorStyles2 = ColorStyleKt.toColorStyles(tabControlToggleComponent.getThumbColorOff(), this.colorAliases);
        Result colorStyles3 = ColorStyleKt.toColorStyles(tabControlToggleComponent.getTrackColorOn(), this.colorAliases);
        Result colorStyles4 = ColorStyleKt.toColorStyles(tabControlToggleComponent.getTrackColorOff(), this.colorAliases);
        C3137A c3137a = C3137A.f25453a;
        Result.Success success = new Result.Success(c3137a);
        Result.Success success2 = new Result.Success(c3137a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{colorStyles, colorStyles2, colorStyles3, colorStyles4, success, success2});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(colorStyles, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) colorStyles).getValue();
        o.f(colorStyles2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) colorStyles2).getValue();
        o.f(colorStyles3, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) colorStyles3).getValue();
        o.f(colorStyles4, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) colorStyles4).getValue();
        Object value5 = success.getValue();
        ColorStyles colorStyles5 = (ColorStyles) value4;
        ColorStyles colorStyles6 = (ColorStyles) value3;
        ColorStyles colorStyles7 = (ColorStyles) value2;
        ColorStyles colorStyles8 = (ColorStyles) value;
        styleFactoryScope.setDefaultTabIndex(tabControlToggleComponent.getDefaultValue() ? 1 : 0);
        return new Result.Success(new TabControlToggleComponentStyle(colorStyles8, colorStyles7, colorStyles6, colorStyles5));
    }

    private final Result<TabsComponentStyle, NonEmptyList<PaywallValidationError>> createTabsComponentStyle(StyleFactoryScope styleFactoryScope, TabsComponent tabsComponent) {
        Result resultCreateTabsComponentStyleTabControl = createTabsComponentStyleTabControl(styleFactoryScope, tabsComponent.getControl());
        if (!(resultCreateTabsComponentStyleTabControl instanceof Result.Success)) {
            if (resultCreateTabsComponentStyleTabControl instanceof Result.Error) {
                return resultCreateTabsComponentStyleTabControl;
            }
            throw new v();
        }
        TabControlStyle tabControlStyle = (TabControlStyle) ((Result.Success) resultCreateTabsComponentStyleTabControl).getValue();
        String defaultTabId = tabsComponent.getDefaultTabId();
        if (defaultTabId != null) {
            if (S4.p.Q0(defaultTabId)) {
                defaultTabId = null;
            }
            if (defaultTabId != null) {
                Iterator it = tabsComponent.getTabs().iterator();
                int i6 = 0;
                while (true) {
                    if (!it.hasNext()) {
                        i6 = -1;
                        break;
                    }
                    if (o.c(((TabsComponent.Tab) it.next()).getId(), defaultTabId)) {
                        break;
                    }
                    i6++;
                }
                Integer numValueOf = Integer.valueOf(i6);
                if (numValueOf.intValue() == -1) {
                    numValueOf = null;
                }
                if (numValueOf != null) {
                    styleFactoryScope.setDefaultTabIndex(Integer.valueOf(numValueOf.intValue()));
                }
            }
        }
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(tabsComponent.getOverrides(), this.stripRules, new StyleFactory$createTabsComponentStyle$1$5(this));
        if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        Result<NonEmptyList<TabsComponentStyle.Tab>, NonEmptyList<PaywallValidationError>> resultCreateTabsComponentStyleTabs = createTabsComponentStyleTabs(styleFactoryScope, tabsComponent.getTabs(), tabControlStyle);
        Result<BackgroundStyles, NonEmptyList<PaywallValidationError>> resultCreateBackgroundStyles = createBackgroundStyles(tabsComponent.getBackground(), tabsComponent.getBackgroundColor());
        Border border = tabsComponent.getBorder();
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(border != null ? BorderStyleKt.toBorderStyles(border, this.colorAliases) : null);
        Shadow shadow = tabsComponent.getShadow();
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(shadow != null ? ShadowStyleKt.toShadowStyles(shadow, this.colorAliases) : null);
        Result.Success success = new Result.Success(C3137A.f25453a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{presentedOverrides, resultCreateTabsComponentStyleTabs, resultCreateBackgroundStyles, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, success});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(presentedOverrides, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) presentedOverrides).getValue();
        o.f(resultCreateTabsComponentStyleTabs, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) resultCreateTabsComponentStyleTabs).getValue();
        o.f(resultCreateBackgroundStyles, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultCreateBackgroundStyles).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        ShadowStyles shadowStyles = (ShadowStyles) value5;
        BorderStyles borderStyles = (BorderStyles) value4;
        BackgroundStyles backgroundStyles = (BackgroundStyles) value3;
        NonEmptyList nonEmptyList = (NonEmptyList) value2;
        List list = (List) value;
        Boolean visible = tabsComponent.getVisible();
        boolean zBooleanValue = visible != null ? visible.booleanValue() : true;
        Size size = tabsComponent.getSize();
        H0 paddingValues = PaddingKt.toPaddingValues(tabsComponent.getPadding());
        H0 paddingValues2 = PaddingKt.toPaddingValues(tabsComponent.getMargin());
        Shape shape = tabsComponent.getShape();
        if (shape == null) {
            shape = DEFAULT_SHAPE;
        }
        return new Result.Success(new TabsComponentStyle(zBooleanValue, size, paddingValues, paddingValues2, backgroundStyles, shape, borderStyles, shadowStyles, tabControlStyle, nonEmptyList, list));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Result<TabsComponentStyle.Tab, NonEmptyList<PaywallValidationError>> createTabsComponentStyleTab(StyleFactoryScope styleFactoryScope, TabsComponent.Tab tab, TabControlStyle tabControlStyle, int i6) {
        return (Result) styleFactoryScope.withSelectedScope(null, null, new C15651(i6, tabControlStyle, this, tab));
    }

    private final Result<TabControlStyle, NonEmptyList<PaywallValidationError>> createTabsComponentStyleTabControl(StyleFactoryScope styleFactoryScope, TabsComponent.TabControl tabControl) {
        return (Result) styleFactoryScope.withSelectedScope(null, null, new C15661(tabControl, this));
    }

    private final Result<NonEmptyList<TabsComponentStyle.Tab>, NonEmptyList<PaywallValidationError>> createTabsComponentStyleTabs(StyleFactoryScope styleFactoryScope, List<TabsComponent.Tab> list, TabControlStyle tabControlStyle) {
        Result<NonEmptyList<TabsComponentStyle.Tab>, NonEmptyList<PaywallValidationError>> resultErrorIfNull = ResultKt.errorIfNull(NonEmptyListKt.toNonEmptyListOrNull(list), NonEmptyListKt.nonEmptyListOf(PaywallValidationError.TabsComponentWithoutTabs.INSTANCE, new PaywallValidationError.TabsComponentWithoutTabs[0]));
        if (resultErrorIfNull instanceof Result.Success) {
            return NonEmptyListKt.flatten(((NonEmptyList) ((Result.Success) resultErrorIfNull).getValue()).mapIndexed(new StyleFactory$createTabsComponentStyleTabs$1$1(this, styleFactoryScope, tabControlStyle)));
        }
        if (resultErrorIfNull instanceof Result.Error) {
            return resultErrorIfNull;
        }
        throw new v();
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x0097 A[LOOP:1: B:18:0x0091->B:20:0x0097, LOOP_END] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final Result<TextComponentStyle, NonEmptyList<PaywallValidationError>> createTextComponentStyle(StyleFactoryScope styleFactoryScope, TextComponent textComponent) {
        Result resultM744getFontSpecpDyximM;
        Iterator it;
        Result success;
        Result resultM688stringForAllLocales7v81vok = LocalizationKt.m688stringForAllLocales7v81vok(this.localizations, textComponent.m567getTextz7Tp4o());
        if (!(resultM688stringForAllLocales7v81vok instanceof Result.Success)) {
            if (!(resultM688stringForAllLocales7v81vok instanceof Result.Error)) {
                throw new v();
            }
            NonEmptyList nonEmptyList = (NonEmptyList) ((Result.Error) resultM688stringForAllLocales7v81vok).getValue();
            NonEmptyMap<LocaleId, NonEmptyMap<LocalizationKey, LocalizationData>> nonEmptyMap = this.localizations;
            if (nonEmptyMap.isEmpty()) {
                Logger.INSTANCE.w("Missing text for text_lid '" + textComponent.m567getTextz7Tp4o() + "', using empty string.");
                NonEmptyMap<LocaleId, NonEmptyMap<LocalizationKey, LocalizationData>> nonEmptyMap2 = this.localizations;
                Map map = ((NonEmptyMap) nonEmptyMap2).all;
                LinkedHashMap linkedHashMap = new LinkedHashMap(AbstractC3229F.u(map.size()));
                it = map.entrySet().iterator();
                while (it.hasNext()) {
                    linkedHashMap.put(((Map.Entry) it.next()).getKey(), "");
                }
                success = new Result.Success(NonEmptyMapKt.nonEmptyMapOf(new k(nonEmptyMap2.getEntry().getKey(), AbstractC3229F.t(nonEmptyMap2.getEntry().getKey(), linkedHashMap)), linkedHashMap));
                resultM688stringForAllLocales7v81vok = success;
            } else {
                Iterator<Map.Entry<LocaleId, NonEmptyMap<LocalizationKey, LocalizationData>>> it2 = nonEmptyMap.entrySet().iterator();
                while (it2.hasNext()) {
                    if (it2.next().getValue().containsKey(LocalizationKey.m607boximpl(textComponent.m567getTextz7Tp4o()))) {
                        success = new Result.Error(nonEmptyList);
                        break;
                    }
                }
                Logger.INSTANCE.w("Missing text for text_lid '" + textComponent.m567getTextz7Tp4o() + "', using empty string.");
                NonEmptyMap<LocaleId, NonEmptyMap<LocalizationKey, LocalizationData>> nonEmptyMap22 = this.localizations;
                Map map2 = ((NonEmptyMap) nonEmptyMap22).all;
                LinkedHashMap linkedHashMap2 = new LinkedHashMap(AbstractC3229F.u(map2.size()));
                it = map2.entrySet().iterator();
                while (it.hasNext()) {
                }
                success = new Result.Success(NonEmptyMapKt.nonEmptyMapOf(new k(nonEmptyMap22.getEntry().getKey(), AbstractC3229F.t(nonEmptyMap22.getEntry().getKey(), linkedHashMap2)), linkedHashMap2));
                resultM688stringForAllLocales7v81vok = success;
            }
        }
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(textComponent.getOverrides(), this.stripRules, new AnonymousClass2());
        if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        Result colorStyles = ColorStyleKt.toColorStyles(textComponent.getColor(), this.colorAliases);
        ColorScheme backgroundColor = textComponent.getBackgroundColor();
        Result resultRecoverFromFontAliasError = null;
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(backgroundColor != null ? ColorStyleKt.toColorStyles(backgroundColor, this.colorAliases) : null);
        String strM566getFontNameARcRonI = textComponent.m566getFontNameARcRonI();
        if (strM566getFontNameARcRonI != null && (resultM744getFontSpecpDyximM = FontSpecKt.m744getFontSpecpDyximM(this.fontAliases, strM566getFontNameARcRonI)) != null) {
            resultRecoverFromFontAliasError = FontSpecKt.recoverFromFontAliasError(resultM744getFontSpecpDyximM);
        }
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(resultRecoverFromFontAliasError);
        if (!(resultOrSuccessfullyNull2 instanceof Result.Success)) {
            if (!(resultOrSuccessfullyNull2 instanceof Result.Error)) {
                throw new v();
            }
            resultOrSuccessfullyNull2 = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) resultOrSuccessfullyNull2).getValue(), new PaywallValidationError[0]));
        }
        Result.Success success2 = new Result.Success(C3137A.f25453a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{resultM688stringForAllLocales7v81vok, presentedOverrides, colorStyles, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, success2});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(resultM688stringForAllLocales7v81vok, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) resultM688stringForAllLocales7v81vok).getValue();
        o.f(presentedOverrides, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) presentedOverrides).getValue();
        o.f(colorStyles, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) colorStyles).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        FontSpec fontSpec = (FontSpec) value5;
        ColorStyles colorStyles2 = (ColorStyles) value4;
        ColorStyles colorStyles3 = (ColorStyles) value3;
        List list = (List) value2;
        NonEmptyMap nonEmptyMap3 = (NonEmptyMap) value;
        Integer fontWeightInt = textComponent.getFontWeightInt();
        I i6 = fontWeightInt != null ? new I(fontWeightInt.intValue()) : FontKt.toFontWeight(textComponent.getFontWeight());
        int fontSize = textComponent.getFontSize();
        C2023k c2023k = new C2023k(AlignmentKt.toTextAlign(textComponent.getHorizontalAlignment()));
        InterfaceC2240d alignment = AlignmentKt.toAlignment(textComponent.getHorizontalAlignment());
        Boolean visible = textComponent.getVisible();
        return new Result.Success(new TextComponentStyle(nonEmptyMap3, colorStyles3, fontSize, i6, fontSpec, c2023k, alignment, colorStyles2, visible != null ? visible.booleanValue() : true, textComponent.getSize(), PaddingKt.toPaddingValues(textComponent.getPadding()), PaddingKt.toPaddingValues(textComponent.getMargin()), styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), styleFactoryScope.getCountdownDate(), styleFactoryScope.getCountFrom(), this.variableLocalizations, list, null));
    }

    private final Result<TimelineComponentStyle.ItemStyle, NonEmptyList<PaywallValidationError>> createTimelineComponentItemStyle(StyleFactoryScope styleFactoryScope, TimelineComponent.Item item) {
        ColorScheme color;
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(item.getOverrides(), this.stripRules, new C15671());
        if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        Result<TextComponentStyle, NonEmptyList<PaywallValidationError>> resultCreateTextComponentStyle = createTextComponentStyle(styleFactoryScope, item.getTitle());
        TextComponent description = item.getDescription();
        TimelineComponentStyle.ConnectorStyle connectorStyle = null;
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(description != null ? createTextComponentStyle(styleFactoryScope, description) : null);
        Result<IconComponentStyle, NonEmptyList<PaywallValidationError>> resultCreateIconComponentStyle = createIconComponentStyle(styleFactoryScope, item.getIcon());
        TimelineComponent.Connector connector = item.getConnector();
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull((connector == null || (color = connector.getColor()) == null) ? null : ColorStyleKt.toColorStyles(color, this.colorAliases));
        Result.Success success = new Result.Success(C3137A.f25453a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{presentedOverrides, resultCreateTextComponentStyle, resultOrSuccessfullyNull, resultCreateIconComponentStyle, resultOrSuccessfullyNull2, success});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(presentedOverrides, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) presentedOverrides).getValue();
        o.f(resultCreateTextComponentStyle, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) resultCreateTextComponentStyle).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultCreateIconComponentStyle, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultCreateIconComponentStyle).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        ColorStyles colorStyles = (ColorStyles) value5;
        IconComponentStyle iconComponentStyle = (IconComponentStyle) value4;
        TextComponentStyle textComponentStyle = (TextComponentStyle) value3;
        TextComponentStyle textComponentStyle2 = (TextComponentStyle) value2;
        List list = (List) value;
        TimelineComponent.Connector connector2 = item.getConnector();
        if (connector2 != null && colorStyles != null) {
            connectorStyle = new TimelineComponentStyle.ConnectorStyle(connector2.getWidth(), PaddingKt.toPaddingValues(connector2.getMargin()), colorStyles);
        }
        TimelineComponentStyle.ConnectorStyle connectorStyle2 = connectorStyle;
        Boolean visible = item.getVisible();
        return new Result.Success(new TimelineComponentStyle.ItemStyle(textComponentStyle2, visible != null ? visible.booleanValue() : true, textComponentStyle, iconComponentStyle, connectorStyle2, styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), list));
    }

    private final Result<TimelineComponentStyle, NonEmptyList<PaywallValidationError>> createTimelineComponentStyle(StyleFactoryScope styleFactoryScope, TimelineComponent timelineComponent) {
        Result presentedOverrides = PresentedPartialKt.toPresentedOverrides(timelineComponent.getOverrides(), this.stripRules, C15681.INSTANCE);
        if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        List items = timelineComponent.getItems();
        ArrayList<Result> arrayList = new ArrayList(AbstractC3253s.G(items, 10));
        Iterator it = items.iterator();
        while (it.hasNext()) {
            arrayList.add(createTimelineComponentItemStyle(styleFactoryScope, (TimelineComponent.Item) it.next()));
        }
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        for (Result result : arrayList) {
            if (result instanceof Result.Success) {
                if (arrayList3.isEmpty()) {
                    arrayList2.add((TimelineComponentStyle.ItemStyle) ((Result.Success) result).getValue());
                }
            } else if (result instanceof Result.Error) {
                arrayList3.addAll((Collection) ((Result.Error) result).getValue());
            }
        }
        NonEmptyList nonEmptyListOrNull = NonEmptyListKt.toNonEmptyListOrNull(arrayList3);
        Result error = nonEmptyListOrNull != null ? new Result.Error(nonEmptyListOrNull) : new Result.Success(arrayList2);
        C3137A c3137a = C3137A.f25453a;
        Result.Success success = new Result.Success(c3137a);
        Result.Success success2 = new Result.Success(c3137a);
        Result.Success success3 = new Result.Success(c3137a);
        Result.Success success4 = new Result.Success(c3137a);
        NonEmptyList nonEmptyListH = a.h(new Result[]{presentedOverrides, error, success, success2, success3, success4});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(presentedOverrides, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) presentedOverrides).getValue();
        Object value2 = ((Result.Success) error).getValue();
        Object value3 = success.getValue();
        Object value4 = success2.getValue();
        Object value5 = success3.getValue();
        List list = (List) value2;
        List list2 = (List) value;
        int itemSpacing = timelineComponent.getItemSpacing();
        int textSpacing = timelineComponent.getTextSpacing();
        int columnGutter = timelineComponent.getColumnGutter();
        TimelineComponent.IconAlignment iconAlignment = timelineComponent.getIconAlignment();
        Boolean visible = timelineComponent.getVisible();
        return new Result.Success(new TimelineComponentStyle(itemSpacing, textSpacing, columnGutter, iconAlignment, visible != null ? visible.booleanValue() : true, timelineComponent.getSize(), PaddingKt.toPaddingValues(timelineComponent.getPadding()), PaddingKt.toPaddingValues(timelineComponent.getMargin()), list, styleFactoryScope.getRcPackage(), styleFactoryScope.getResolvedOffer(), styleFactoryScope.getTabControlIndex(), styleFactoryScope.getOfferEligibility(), list2));
    }

    private final Result<VideoComponentStyle, NonEmptyList<PaywallValidationError>> createVideoComponentStyle(StyleFactoryScope styleFactoryScope, VideoComponent videoComponent) {
        Result presentedOverrides;
        H0 h0D;
        H0 h0D2;
        Result<NonEmptyMap<LocaleId, ThemeVideoUrls>, NonEmptyList<PaywallValidationError.MissingVideoLocalization>> resultM798withLocalizedOverridesTDPsjl0 = m798withLocalizedOverridesTDPsjl0(videoComponent.getSource(), videoComponent.m570getOverrideSourceLidsa7TU9Q());
        ThemeImageUrls fallbackSource = videoComponent.getFallbackSource();
        Result resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(fallbackSource != null ? m797withLocalizedOverridesTDPsjl0(fallbackSource, videoComponent.m570getOverrideSourceLidsa7TU9Q()) : null);
        List overrides = videoComponent.getOverrides();
        if (overrides == null || (presentedOverrides = PresentedPartialKt.toPresentedOverrides(overrides, this.stripRules, new C15691())) == null) {
            presentedOverrides = null;
        } else if (!(presentedOverrides instanceof Result.Success)) {
            if (!(presentedOverrides instanceof Result.Error)) {
                throw new v();
            }
            presentedOverrides = new Result.Error(NonEmptyListKt.nonEmptyListOf((PaywallValidationError) ((Result.Error) presentedOverrides).getValue(), new PaywallValidationError[0]));
        }
        Result resultOrSuccessfullyNull2 = ResultKt.orSuccessfullyNull(presentedOverrides);
        ColorScheme colorOverlay = videoComponent.getColorOverlay();
        Result resultOrSuccessfullyNull3 = ResultKt.orSuccessfullyNull(colorOverlay != null ? ColorStyleKt.toColorStyles(colorOverlay, this.colorAliases) : null);
        Border border = videoComponent.getBorder();
        Result resultOrSuccessfullyNull4 = ResultKt.orSuccessfullyNull(border != null ? BorderStyleKt.toBorderStyles(border, this.colorAliases) : null);
        Shadow shadow = videoComponent.getShadow();
        Result resultOrSuccessfullyNull5 = ResultKt.orSuccessfullyNull(shadow != null ? ShadowStyleKt.toShadowStyles(shadow, this.colorAliases) : null);
        NonEmptyList nonEmptyListH = a.h(new Result[]{resultM798withLocalizedOverridesTDPsjl0, resultOrSuccessfullyNull, resultOrSuccessfullyNull2, resultOrSuccessfullyNull3, resultOrSuccessfullyNull4, resultOrSuccessfullyNull5});
        if (nonEmptyListH != null) {
            return new Result.Error(nonEmptyListH);
        }
        o.f(resultM798withLocalizedOverridesTDPsjl0, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<A of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value = ((Result.Success) resultM798withLocalizedOverridesTDPsjl0).getValue();
        o.f(resultOrSuccessfullyNull, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<B of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value2 = ((Result.Success) resultOrSuccessfullyNull).getValue();
        o.f(resultOrSuccessfullyNull2, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<C of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value3 = ((Result.Success) resultOrSuccessfullyNull2).getValue();
        o.f(resultOrSuccessfullyNull3, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<D of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value4 = ((Result.Success) resultOrSuccessfullyNull3).getValue();
        o.f(resultOrSuccessfullyNull4, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<E of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        Object value5 = ((Result.Success) resultOrSuccessfullyNull4).getValue();
        o.f(resultOrSuccessfullyNull5, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.helpers.Result.Success<F of com.revenuecat.purchases.ui.revenuecatui.helpers.ResultKt.zipOrAccumulate>");
        ShadowStyles shadowStyles = (ShadowStyles) ((Result.Success) resultOrSuccessfullyNull5).getValue();
        BorderStyles borderStyles = (BorderStyles) value5;
        ColorStyles colorStyles = (ColorStyles) value4;
        List list = (List) value3;
        NonEmptyMap nonEmptyMap = (NonEmptyMap) value2;
        NonEmptyMap nonEmptyMap2 = (NonEmptyMap) value;
        Boolean visible = videoComponent.getVisible();
        boolean zBooleanValue = visible != null ? visible.booleanValue() : true;
        Size size = videoComponent.getSize();
        Padding padding = videoComponent.getPadding();
        if (padding == null || (h0D = PaddingKt.toPaddingValues(padding)) == null) {
            h0D = AbstractC0057e.d(DEFAULT_SPACING, DEFAULT_SPACING, 3);
        }
        H0 h0 = h0D;
        Padding margin = videoComponent.getMargin();
        if (margin == null || (h0D2 = PaddingKt.toPaddingValues(margin)) == null) {
            h0D2 = AbstractC0057e.d(DEFAULT_SPACING, DEFAULT_SPACING, 3);
        }
        H0 h02 = h0D2;
        Package rcPackage = styleFactoryScope.getRcPackage();
        ResolvedOffer resolvedOffer = styleFactoryScope.getResolvedOffer();
        Integer tabControlIndex = styleFactoryScope.getTabControlIndex();
        OfferEligibility offerEligibility = styleFactoryScope.getOfferEligibility();
        if (list == null) {
            list = y.f26065a;
        }
        List list2 = list;
        boolean showControls = videoComponent.getShowControls();
        boolean autoplay = videoComponent.getAutoplay();
        boolean loop = videoComponent.getLoop();
        boolean muteAudio = videoComponent.getMuteAudio();
        MaskShape maskShape = videoComponent.getMaskShape();
        return new Result.Success(new VideoComponentStyle(nonEmptyMap2, nonEmptyMap, showControls, autoplay, loop, muteAudio, size, zBooleanValue, h0, h02, maskShape != null ? ShapeKt.toShape(maskShape) : null, borderStyles, shadowStyles, colorStyles, FitModeKt.toContentScale(videoComponent.getFitMode()), rcPackage, resolvedOffer, tabControlIndex, offerEligibility, styleFactoryScope.getIgnoreTopWindowInsets(), list2));
    }

    private final Package getPackageOrNull(Offering offering, String str) {
        try {
            return offering.getPackage(str);
        } catch (NoSuchElementException unused) {
            return null;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX INFO: renamed from: withLocalizedOverrides-TDPsjl0, reason: not valid java name */
    public final Result<NonEmptyMap<LocaleId, ThemeImageUrls>, NonEmptyList<PaywallValidationError.MissingImageLocalization>> m797withLocalizedOverridesTDPsjl0(ThemeImageUrls themeImageUrls, String str) {
        Result<NonEmptyMap<LocaleId, ThemeImageUrls>, NonEmptyList<PaywallValidationError.MissingImageLocalization>> resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(str != null ? LocalizationKt.m686imageForAllLocales7v81vok(this.localizations, str) : null);
        if (!(resultOrSuccessfullyNull instanceof Result.Success)) {
            if (resultOrSuccessfullyNull instanceof Result.Error) {
                return resultOrSuccessfullyNull;
            }
            throw new v();
        }
        Map map = (NonEmptyMap) ((Result.Success) resultOrSuccessfullyNull).getValue();
        k kVar = new k(this.localizations.getEntry().getKey(), themeImageUrls);
        if (map == null) {
            map = z.f26066a;
        }
        return new Result.Success(NonEmptyMapKt.nonEmptyMapOf(kVar, map));
    }

    public final Result<StyleResult, NonEmptyList<PaywallValidationError>> create(PaywallComponent component, boolean z6, boolean z7) {
        o.h(component, "component");
        StyleFactoryScope styleFactoryScope = new StyleFactoryScope(null, null, null, null, null, null, null, null, 255, null);
        Result resultCreateInternal = createInternal(styleFactoryScope, component);
        if (resultCreateInternal instanceof Result.Success) {
            ComponentStyle componentStyle = (ComponentStyle) ((Result.Success) resultCreateInternal).getValue();
            resultCreateInternal = componentStyle != null ? new Result.Success(componentStyle) : new Result.Error(NonEmptyListKt.nonEmptyListOf(new PaywallValidationError.RootComponentUnsupportedProperties(component), new PaywallValidationError.RootComponentUnsupportedProperties[0]));
        } else if (!(resultCreateInternal instanceof Result.Error)) {
            throw new v();
        }
        if (resultCreateInternal instanceof Result.Success) {
            resultCreateInternal = new Result.Success(styleFactoryScope.applyTopWindowInsetsIfNotYetApplied((ComponentStyle) ((Result.Success) resultCreateInternal).getValue()));
        } else if (!(resultCreateInternal instanceof Result.Error)) {
            throw new v();
        }
        if (resultCreateInternal instanceof Result.Success) {
            resultCreateInternal = new Result.Success(styleFactoryScope.applyBottomWindowInsetsIfNecessary((ComponentStyle) ((Result.Success) resultCreateInternal).getValue(), z6));
        } else if (!(resultCreateInternal instanceof Result.Error)) {
            throw new v();
        }
        if (resultCreateInternal instanceof Result.Success) {
            resultCreateInternal = new Result.Success(styleFactoryScope.applyHorizontalWindowInsetsIfNecessary((ComponentStyle) ((Result.Success) resultCreateInternal).getValue(), z7));
        } else if (!(resultCreateInternal instanceof Result.Error)) {
            throw new v();
        }
        if (resultCreateInternal instanceof Result.Success) {
            return new Result.Success(new StyleResult((ComponentStyle) ((Result.Success) resultCreateInternal).getValue(), styleFactoryScope.getPackages(), styleFactoryScope.getDefaultTabIndex()));
        }
        if (resultCreateInternal instanceof Result.Error) {
            return resultCreateInternal;
        }
        throw new v();
    }

    public /* synthetic */ StyleFactory(NonEmptyMap nonEmptyMap, Map map, Map map2, NonEmptyMap nonEmptyMap2, Offering offering, boolean z6, int i6, h hVar) {
        this(nonEmptyMap, map, map2, nonEmptyMap2, offering, (i6 & 32) != 0 ? false : z6);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX INFO: renamed from: withLocalizedOverrides-TDPsjl0, reason: not valid java name */
    public final Result<NonEmptyMap<LocaleId, ThemeVideoUrls>, NonEmptyList<PaywallValidationError.MissingVideoLocalization>> m798withLocalizedOverridesTDPsjl0(ThemeVideoUrls themeVideoUrls, String str) {
        Result<NonEmptyMap<LocaleId, ThemeVideoUrls>, NonEmptyList<PaywallValidationError.MissingVideoLocalization>> resultOrSuccessfullyNull = ResultKt.orSuccessfullyNull(str != null ? LocalizationKt.m692videoForAllLocales7v81vok(this.localizations, str) : null);
        if (resultOrSuccessfullyNull instanceof Result.Success) {
            Map map = (NonEmptyMap) ((Result.Success) resultOrSuccessfullyNull).getValue();
            k kVar = new k(this.localizations.getEntry().getKey(), themeVideoUrls);
            if (map == null) {
                map = z.f26066a;
            }
            return new Result.Success(NonEmptyMapKt.nonEmptyMapOf(kVar, map));
        }
        if (resultOrSuccessfullyNull instanceof Result.Error) {
            return resultOrSuccessfullyNull;
        }
        throw new v();
    }
}
