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

import E3.v;
import J4.a;
import androidx.compose.runtime.SnapshotStateKt;
import androidx.compose.runtime.Stable;
import androidx.compose.runtime.State;
import com.revenuecat.purchases.paywalls.components.common.LocaleId;
import com.revenuecat.purchases.ui.revenuecatui.components.PaywallAction;
import com.revenuecat.purchases.ui.revenuecatui.components.style.ButtonComponentStyle;
import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyMap;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes3.dex */
@Stable
public final class ButtonComponentState {
    public static final int $stable = 0;
    private final State action$delegate;
    private final a localeProvider;
    private final ButtonComponentStyle style;

    public ButtonComponentState(ButtonComponentStyle style, a localeProvider) {
        o.h(style, "style");
        o.h(localeProvider, "localeProvider");
        this.style = style;
        this.localeProvider = localeProvider;
        this.action$delegate = SnapshotStateKt.derivedStateOf(new ButtonComponentState$action$2(this));
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: toPaywallAction-64pKzr8, reason: not valid java name */
    public final PaywallAction m661toPaywallAction64pKzr8(ButtonComponentStyle.Action action, String str) {
        if (action instanceof ButtonComponentStyle.Action.NavigateBack) {
            return PaywallAction.External.NavigateBack.INSTANCE;
        }
        if (action instanceof ButtonComponentStyle.Action.NavigateTo) {
            ButtonComponentStyle.Action.NavigateTo navigateTo = (ButtonComponentStyle.Action.NavigateTo) action;
            ButtonComponentStyle.Action.NavigateTo.Destination destination = navigateTo.getDestination();
            if (destination instanceof ButtonComponentStyle.Action.NavigateTo.Destination.CustomerCenter) {
                return new PaywallAction.External.NavigateTo(PaywallAction.External.NavigateTo.Destination.CustomerCenter.INSTANCE);
            }
            if (destination instanceof ButtonComponentStyle.Action.NavigateTo.Destination.Url) {
                NonEmptyMap urls = ((ButtonComponentStyle.Action.NavigateTo.Destination.Url) navigateTo.getDestination()).getUrls();
                return new PaywallAction.External.NavigateTo(new PaywallAction.External.NavigateTo.Destination.Url((String) urls.getOrDefault(LocaleId.m571boximpl(str), urls.getEntry().getValue()), ((ButtonComponentStyle.Action.NavigateTo.Destination.Url) navigateTo.getDestination()).getMethod()));
            }
            if (destination instanceof ButtonComponentStyle.Action.NavigateTo.Destination.Sheet) {
                return new PaywallAction.Internal.NavigateTo(new PaywallAction.Internal.NavigateTo.Destination.Sheet((ButtonComponentStyle.Action.NavigateTo.Destination.Sheet) navigateTo.getDestination()));
            }
            throw new v();
        }
        if (action instanceof ButtonComponentStyle.Action.PurchasePackage) {
            ButtonComponentStyle.Action.PurchasePackage purchasePackage = (ButtonComponentStyle.Action.PurchasePackage) action;
            return new PaywallAction.External.PurchasePackage(purchasePackage.getRcPackage(), purchasePackage.getResolvedOffer());
        }
        if (action instanceof ButtonComponentStyle.Action.RestorePurchases) {
            return PaywallAction.External.RestorePurchases.INSTANCE;
        }
        if (action instanceof ButtonComponentStyle.Action.WebCheckout) {
            ButtonComponentStyle.Action.WebCheckout webCheckout = (ButtonComponentStyle.Action.WebCheckout) action;
            return new PaywallAction.External.LaunchWebCheckout(null, webCheckout.getOpenMethod(), webCheckout.getAutoDismiss(), new PaywallAction.External.LaunchWebCheckout.PackageParamBehavior.Append(webCheckout.getRcPackage(), null));
        }
        if (action instanceof ButtonComponentStyle.Action.WebProductSelection) {
            ButtonComponentStyle.Action.WebProductSelection webProductSelection = (ButtonComponentStyle.Action.WebProductSelection) action;
            return new PaywallAction.External.LaunchWebCheckout(null, webProductSelection.getOpenMethod(), webProductSelection.getAutoDismiss(), PaywallAction.External.LaunchWebCheckout.PackageParamBehavior.DoNotAppend.INSTANCE);
        }
        if (!(action instanceof ButtonComponentStyle.Action.CustomWebCheckout)) {
            throw new v();
        }
        ButtonComponentStyle.Action.CustomWebCheckout customWebCheckout = (ButtonComponentStyle.Action.CustomWebCheckout) action;
        NonEmptyMap<LocaleId, String> urls2 = customWebCheckout.getUrls();
        return new PaywallAction.External.LaunchWebCheckout((String) urls2.getOrDefault(LocaleId.m571boximpl(str), urls2.getEntry().getValue()), customWebCheckout.getOpenMethod(), customWebCheckout.getAutoDismiss(), new PaywallAction.External.LaunchWebCheckout.PackageParamBehavior.Append(customWebCheckout.getRcPackage(), customWebCheckout.getPackageParam()));
    }

    public final /* synthetic */ PaywallAction getAction() {
        return (PaywallAction) this.action$delegate.getValue();
    }
}
