package com.revenuecat.purchases.ui.revenuecatui.data;

import J4.a;
import b1.C1186a;
import com.revenuecat.purchases.ui.revenuecatui.components.ktx.LocalizationKt;
import com.revenuecat.purchases.ui.revenuecatui.data.PaywallState;
import java.util.Locale;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes3.dex */
public final class PaywallState$Loaded$Components$currencyLocale$2 extends p implements a {
    final /* synthetic */ PaywallState.Loaded.Components this$0;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public PaywallState$Loaded$Components$currencyLocale$2(PaywallState.Loaded.Components components) {
        super(0);
        this.this$0 = components;
    }

    @Override // J4.a
    public final C1186a invoke() {
        String str = this.this$0.storefrontCountryCode;
        if (str == null || S4.p.Q0(str)) {
            return this.this$0.getLocale();
        }
        String language = this.this$0.getLocale().f13226a.getLanguage();
        Locale locale = Locale.ROOT;
        String lowerCase = language.toLowerCase(locale);
        o.g(lowerCase, "toLowerCase(...)");
        Locale javaLocale = (Locale) this.this$0.getAvailableStorefrontCountryLocalesByLanguage().get(lowerCase);
        if (javaLocale == null && (javaLocale = (Locale) AbstractC3251q.f0(this.this$0.getAvailableStorefrontCountryLocalesByLanguage().values())) == null) {
            Locale.Builder locale2 = new Locale.Builder().setLocale(LocalizationKt.toJavaLocale(this.this$0.getLocale()));
            String upperCase = this.this$0.storefrontCountryCode.toUpperCase(locale);
            o.g(upperCase, "toUpperCase(...)");
            javaLocale = locale2.setRegion(upperCase).build();
        }
        o.g(javaLocale, "javaLocale");
        return LocalizationKt.toComposeLocale(javaLocale);
    }
}
