package com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel;

import A4.d;
import B1.g;
import C4.c;
import C4.e;
import C4.j;
import E3.v;
import J4.a;
import V4.C;
import V4.E;
import Y4.C0851q;
import Y4.H;
import Y4.O;
import Y4.S;
import Y4.a0;
import Y4.c0;
import a0.I;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.LocaleList;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.State;
import androidx.compose.runtime.internal.StabilityInferred;
import androidx.lifecycle.X;
import androidx.lifecycle.b0;
import com.revenuecat.purchases.CacheFetchPolicy;
import com.revenuecat.purchases.CreateSupportTicketResult;
import com.revenuecat.purchases.CustomerInfo;
import com.revenuecat.purchases.EntitlementInfo;
import com.revenuecat.purchases.InternalRevenueCatAPI;
import com.revenuecat.purchases.ListenerConversionsCommonKt;
import com.revenuecat.purchases.Offering;
import com.revenuecat.purchases.Offerings;
import com.revenuecat.purchases.Package;
import com.revenuecat.purchases.PeriodType;
import com.revenuecat.purchases.PurchaseParams;
import com.revenuecat.purchases.Purchases;
import com.revenuecat.purchases.PurchasesError;
import com.revenuecat.purchases.PurchasesErrorCode;
import com.revenuecat.purchases.PurchasesException;
import com.revenuecat.purchases.Store;
import com.revenuecat.purchases.SubscriptionInfo;
import com.revenuecat.purchases.common.Constants;
import com.revenuecat.purchases.common.SharedConstants;
import com.revenuecat.purchases.customercenter.CustomActionData;
import com.revenuecat.purchases.customercenter.CustomerCenterConfigData;
import com.revenuecat.purchases.customercenter.CustomerCenterListener;
import com.revenuecat.purchases.customercenter.CustomerCenterManagementOption;
import com.revenuecat.purchases.customercenter.events.CustomerCenterImpressionEvent;
import com.revenuecat.purchases.customercenter.events.CustomerCenterSurveyOptionChosenEvent;
import com.revenuecat.purchases.models.GoogleStoreProduct;
import com.revenuecat.purchases.models.GoogleStoreProductKt;
import com.revenuecat.purchases.models.GoogleSubscriptionOption;
import com.revenuecat.purchases.models.StoreProduct;
import com.revenuecat.purchases.models.SubscriptionOption;
import com.revenuecat.purchases.models.SubscriptionOptions;
import com.revenuecat.purchases.models.Transaction;
import com.revenuecat.purchases.ui.revenuecatui.OfferingSelection;
import com.revenuecat.purchases.ui.revenuecatui.activity.PaywallActivity;
import com.revenuecat.purchases.ui.revenuecatui.activity.PaywallActivityArgs;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.data.CreateSupportTicketData;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.data.CustomerCenterState;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.data.FeedbackSurveyData;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.data.PathUtils;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.data.PromotionalOfferData;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.data.PurchaseInformation;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.dialogs.RestorePurchasesState;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.extensions.SubscriptionOptionExtensionsKt;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.navigation.CustomerCenterDestination;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.navigation.CustomerCenterNavigationState;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.TransactionDetails;
import com.revenuecat.purchases.ui.revenuecatui.data.PurchasesType;
import com.revenuecat.purchases.ui.revenuecatui.helpers.LocaleHelpersKt;
import com.revenuecat.purchases.ui.revenuecatui.helpers.Logger;
import com.revenuecat.purchases.ui.revenuecatui.utils.DateFormatter;
import com.revenuecat.purchases.ui.revenuecatui.utils.DefaultDateFormatter;
import com.revenuecat.purchases.ui.revenuecatui.utils.URLOpener;
import com.revenuecat.purchases.ui.revenuecatui.utils.URLOpeningMethod;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import m3.AbstractC2467b;
import m3.AbstractC2478m;
import n2.AbstractC2612c;
import w4.C3137A;
import x4.AbstractC3251q;
import x4.AbstractC3253s;
import x4.y;

/* JADX INFO: loaded from: classes3.dex */
@StabilityInferred(parameters = 0)
public final class CustomerCenterViewModelImpl extends b0 implements CustomerCenterViewModel {
    private static final long STOP_FLOW_TIMEOUT = 5000;
    private final MutableState<PurchasesError> _actionError;
    private final H _colorScheme;
    private final H _lastLocaleList;
    private final H _state;
    private final I colorScheme;
    private final DateFormatter dateFormatter;
    private CustomerCenterImpressionEvent.CreationData impressionCreationData;
    private boolean isDarkMode;
    private final CustomerCenterListener listener;
    private final Locale locale;
    private final PurchasesType purchases;
    private boolean shouldRefreshOnResume;
    private final a0 state;
    private boolean wasBackgrounded;
    public static final Companion Companion = new Companion(null);
    public static final int $stable = 8;

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

        private Companion() {
        }
    }

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

        static {
            int[] iArr = new int[CustomerCenterConfigData.HelpPath.PathType.values().length];
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.MISSING_PURCHASE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.CANCEL.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.CUSTOM_URL.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.CUSTOM_ACTION.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.REFUND_REQUEST.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.CHANGE_PLANS.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                iArr[CustomerCenterConfigData.HelpPath.PathType.UNKNOWN.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            $EnumSwitchMapping$0 = iArr;
            int[] iArr2 = new int[CustomerCenterConfigData.HelpPath.OpenMethod.values().length];
            try {
                iArr2[CustomerCenterConfigData.HelpPath.OpenMethod.IN_APP.ordinal()] = 1;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                iArr2[CustomerCenterConfigData.HelpPath.OpenMethod.EXTERNAL.ordinal()] = 2;
            } catch (NoSuchFieldError unused9) {
            }
            $EnumSwitchMapping$1 = iArr2;
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$createPurchaseInformation$1, reason: invalid class name */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {751}, m = "createPurchaseInformation")
    public static final class AnonymousClass1 extends c {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public AnonymousClass1(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.createPurchaseInformation(null, null, null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$findTargetProduct$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {1206}, m = "findTargetProduct")
    public static final class C16541 extends c {
        int label;
        /* synthetic */ Object result;

        public C16541(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.findTargetProduct(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$getPromotionalSubscriptionOption$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {1181}, m = "getPromotionalSubscriptionOption")
    public static final class C16551 extends c {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C16551(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.getPromotionalSubscriptionOption(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$handleSupportTicketSubmit$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$handleSupportTicketSubmit$1", f = "CustomerCenterViewModel.kt", l = {397}, m = "invokeSuspend")
    public static final class C16561 extends j implements J4.e {
        final /* synthetic */ String $description;
        final /* synthetic */ String $email;
        final /* synthetic */ a $onError;
        final /* synthetic */ a $onSuccess;
        int label;
        final /* synthetic */ CustomerCenterViewModelImpl this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C16561(String str, String str2, CustomerCenterViewModelImpl customerCenterViewModelImpl, a aVar, a aVar2, d dVar) {
            super(2, dVar);
            this.$email = str;
            this.$description = str2;
            this.this$0 = customerCenterViewModelImpl;
            this.$onSuccess = aVar;
            this.$onError = aVar2;
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            return new C16561(this.$email, this.$description, this.this$0, this.$onSuccess, this.$onError, dVar);
        }

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((C16561) create(c6, dVar)).invokeSuspend(C3137A.f25453a);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            Object objAwaitCreateSupportTicket;
            c0 c0Var;
            Object value;
            Object objCopy$default;
            B4.a aVar = B4.a.f492a;
            int i6 = this.label;
            try {
                if (i6 == 0) {
                    AbstractC2467b.l(obj);
                    Logger.INSTANCE.d("Creating support ticket - email: " + this.$email + ", Description: " + this.$description);
                    PurchasesType purchasesType = this.this$0.purchases;
                    String str = this.$email;
                    String str2 = this.$description;
                    this.label = 1;
                    objAwaitCreateSupportTicket = purchasesType.awaitCreateSupportTicket(str, str2, this);
                    if (objAwaitCreateSupportTicket == aVar) {
                        return aVar;
                    }
                } else {
                    if (i6 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    AbstractC2467b.l(obj);
                    objAwaitCreateSupportTicket = obj;
                }
                if (((CreateSupportTicketResult) objAwaitCreateSupportTicket).getSuccess()) {
                    Logger.INSTANCE.d("Support ticket created successfully");
                    H h5 = this.this$0._state;
                    do {
                        c0Var = (c0) h5;
                        value = c0Var.getValue();
                        objCopy$default = (CustomerCenterState) value;
                        if (objCopy$default instanceof CustomerCenterState.Success) {
                            objCopy$default = CustomerCenterState.Success.copy$default((CustomerCenterState.Success) objCopy$default, null, null, null, null, null, null, ((CustomerCenterState.Success) objCopy$default).getNavigationState().pop(), ((CustomerCenterState.Success) objCopy$default).getNavigationState().pop().getCanNavigateBack() ? CustomerCenterState.NavigationButtonType.BACK : CustomerCenterState.NavigationButtonType.CLOSE, null, true, false, 1343, null);
                        }
                    } while (!c0Var.i(value, objCopy$default));
                    this.$onSuccess.invoke();
                } else {
                    Logger.INSTANCE.e("Support ticket creation returned false");
                    this.$onError.invoke();
                }
            } catch (PurchasesException e6) {
                Logger.INSTANCE.e("Error creating support ticket", e6);
                this.$onError.invoke();
            }
            return C3137A.f25453a;
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$launchRefreshIfPossible$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$launchRefreshIfPossible$1", f = "CustomerCenterViewModel.kt", l = {1058}, m = "invokeSuspend")
    public static final class C16571 extends j implements J4.e {
        int label;

        public C16571(d dVar) {
            super(2, dVar);
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            return CustomerCenterViewModelImpl.this.new C16571(dVar);
        }

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((C16571) create(c6, dVar)).invokeSuspend(C3137A.f25453a);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            B4.a aVar = B4.a.f492a;
            int i6 = this.label;
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                CustomerCenterViewModelImpl customerCenterViewModelImpl = CustomerCenterViewModelImpl.this;
                this.label = 1;
                if (customerCenterViewModelImpl.refreshCustomerCenter(this) == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            return C3137A.f25453a;
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$loadAndDisplayPromotionalOffer$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {816}, m = "loadAndDisplayPromotionalOffer")
    public static final class C16581 extends c {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;
        /* synthetic */ Object result;

        public C16581(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.loadAndDisplayPromotionalOffer(null, null, null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$loadCustomerCenter$2, reason: invalid class name */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {967, 968, 975, 983}, m = "loadCustomerCenter")
    public static final class AnonymousClass2 extends c {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        boolean Z$0;
        int label;
        /* synthetic */ Object result;

        public AnonymousClass2(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.loadCustomerCenter(false, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$loadPurchases$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {662, 675, 695}, m = "loadPurchases")
    public static final class C16591 extends c {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        Object L$5;
        Object L$6;
        Object L$7;
        int label;
        /* synthetic */ Object result;

        public C16591(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.loadPurchases(null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$onAcceptedPromotionalOffer$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {860, 864}, m = "onAcceptedPromotionalOffer")
    public static final class C16601 extends c {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C16601(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.onAcceptedPromotionalOffer(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$pathButtonPressed$2, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$pathButtonPressed$2", f = "CustomerCenterViewModel.kt", l = {267}, m = "invokeSuspend")
    public static final class C16612 extends j implements J4.e {
        final /* synthetic */ Context $context;
        final /* synthetic */ CustomerCenterConfigData.HelpPath $path;
        final /* synthetic */ PurchaseInformation $purchaseInformation;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C16612(Context context, PurchaseInformation purchaseInformation, CustomerCenterConfigData.HelpPath helpPath, d dVar) {
            super(2, dVar);
            this.$context = context;
            this.$purchaseInformation = purchaseInformation;
            this.$path = helpPath;
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            return CustomerCenterViewModelImpl.this.new C16612(this.$context, this.$purchaseInformation, this.$path, dVar);
        }

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((C16612) create(c6, dVar)).invokeSuspend(C3137A.f25453a);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            C16612 c16612;
            B4.a aVar = B4.a.f492a;
            int i6 = this.label;
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                CustomerCenterViewModelImpl customerCenterViewModelImpl = CustomerCenterViewModelImpl.this;
                Context context = this.$context;
                PurchaseInformation purchaseInformation = this.$purchaseInformation;
                StoreProduct product = purchaseInformation != null ? purchaseInformation.getProduct() : null;
                CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer promotionalOffer = this.$path.getPromotionalOffer();
                CustomerCenterConfigData.HelpPath helpPath = this.$path;
                PurchaseInformation purchaseInformation2 = this.$purchaseInformation;
                this.label = 1;
                c16612 = this;
                obj = customerCenterViewModelImpl.handlePromotionalOffer(context, product, promotionalOffer, helpPath, purchaseInformation2, c16612);
                if (obj == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                c16612 = this;
            }
            if (!((Boolean) obj).booleanValue()) {
                CustomerCenterViewModelImpl.this.mainPathAction(c16612.$path, c16612.$context, c16612.$purchaseInformation);
            }
            return C3137A.f25453a;
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$restorePurchases$1, reason: invalid class name and case insensitive filesystem */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl", f = "CustomerCenterViewModel.kt", l = {534}, m = "restorePurchases")
    public static final class C16621 extends c {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C16621(d dVar) {
            super(dVar);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return CustomerCenterViewModelImpl.this.restorePurchases(this);
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$tryFallbackToCurrentOffering$1, reason: invalid class name and case insensitive filesystem */
    public static final class C16631 extends p implements J4.c {
        public C16631() {
            super(1);
        }

        @Override // J4.c
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            invoke((PurchasesError) obj);
            return C3137A.f25453a;
        }

        public final void invoke(PurchasesError error) {
            o.h(error, "error");
            CustomerCenterViewModelImpl.this.handlePaywallError("Failed to get current offering: " + error.getMessage(), error.getCode());
        }
    }

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$tryFallbackToCurrentOffering$2, reason: invalid class name and case insensitive filesystem */
    public static final class C16642 extends p implements J4.c {
        final /* synthetic */ Context $context;

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

        @Override // J4.c
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            invoke((Offerings) obj);
            return C3137A.f25453a;
        }

        public final void invoke(Offerings offerings) {
            o.h(offerings, "offerings");
            Offering current = offerings.getCurrent();
            if (current == null) {
                CustomerCenterViewModelImpl.this.handlePaywallError("No offering available for paywall presentation", PurchasesErrorCode.ConfigurationError);
                return;
            }
            Logger.INSTANCE.d("Falling back to current offering: " + current.getIdentifier());
            CustomerCenterViewModelImpl.this.launchPaywallActivity(this.$context, current);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public /* synthetic */ CustomerCenterViewModelImpl(PurchasesType purchasesType, DateFormatter dateFormatter, Locale locale, I i6, boolean z6, CustomerCenterListener customerCenterListener, int i7, h hVar) {
        DateFormatter defaultDateFormatter = (i7 & 2) != 0 ? new DefaultDateFormatter() : dateFormatter;
        if ((i7 & 4) != 0) {
            locale = Locale.getDefault();
            o.g(locale, "getDefault()");
        }
        this(purchasesType, defaultDateFormatter, locale, i6, z6, (i7 & 32) != 0 ? null : customerCenterListener);
    }

    private final TransactionDetails.Subscription asTransactionDetails(SubscriptionInfo subscriptionInfo) {
        return new TransactionDetails.Subscription(subscriptionInfo.getProductIdentifier(), subscriptionInfo.getProductPlanIdentifier(), subscriptionInfo.getStore(), subscriptionInfo.isActive(), subscriptionInfo.getWillRenew(), subscriptionInfo.getExpiresDate(), subscriptionInfo.getPeriodType() == PeriodType.TRIAL, subscriptionInfo.getManagementURL(), subscriptionInfo.getPrice(), subscriptionInfo.isSandbox());
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x0065  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final List<CustomerCenterConfigData.HelpPath> computeMainScreenPaths(CustomerCenterState.Success success) {
        CustomerCenterConfigData.Screen noActiveScreen;
        List<CustomerCenterConfigData.HelpPath> listSupportedPaths;
        List purchases;
        if (success.getPurchases().isEmpty() || ((purchases = success.getPurchases()) != null && purchases.isEmpty())) {
            noActiveScreen = success.getCustomerCenterConfigData().getNoActiveScreen();
        } else {
            Iterator it = purchases.iterator();
            while (it.hasNext()) {
                if (!((PurchaseInformation) it.next()).isExpired()) {
                    noActiveScreen = success.getCustomerCenterConfigData().getManagementScreen();
                    break;
                }
            }
            noActiveScreen = success.getCustomerCenterConfigData().getNoActiveScreen();
        }
        if (noActiveScreen == null) {
            listSupportedPaths = y.f26065a;
        } else {
            listSupportedPaths = supportedPaths(success.getPurchases().size() == 1 ? (PurchaseInformation) AbstractC3251q.e0(success.getPurchases()) : null, noActiveScreen, success.getCustomerCenterConfigData().getLocalization());
            if (listSupportedPaths == null) {
            }
        }
        return success.getPurchases().size() > 1 ? PathUtils.INSTANCE.filterGeneralPaths(listSupportedPaths) : listSupportedPaths;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0015  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object createPurchaseInformation(TransactionDetails transactionDetails, EntitlementInfo entitlementInfo, DateFormatter dateFormatter, Locale locale, CustomerCenterConfigData.Localization localization, d dVar) {
        AnonymousClass1 anonymousClass1;
        DateFormatter dateFormatter2;
        Locale locale2;
        EntitlementInfo entitlementInfo2;
        CustomerCenterConfigData.Localization localization2;
        TransactionDetails transactionDetails2;
        StoreProduct storeProduct;
        CustomerCenterConfigData.Localization localization3;
        EntitlementInfo entitlementInfo3;
        DateFormatter dateFormatter3;
        Locale locale3;
        if (dVar instanceof AnonymousClass1) {
            anonymousClass1 = (AnonymousClass1) dVar;
            int i6 = anonymousClass1.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                anonymousClass1.label = i6 - Integer.MIN_VALUE;
            } else {
                anonymousClass1 = new AnonymousClass1(dVar);
            }
        }
        Object objAwaitGetProduct = anonymousClass1.result;
        B4.a aVar = B4.a.f492a;
        int i7 = anonymousClass1.label;
        if (i7 == 0) {
            AbstractC2467b.l(objAwaitGetProduct);
            if (transactionDetails.getStore() != Store.PLAY_STORE) {
                Logger.INSTANCE.w("Active product is not from Google, loading without product information: " + transactionDetails.getStore());
                dateFormatter2 = dateFormatter;
                locale2 = locale;
                entitlementInfo2 = entitlementInfo;
                localization2 = localization;
                transactionDetails2 = transactionDetails;
                storeProduct = null;
                return new PurchaseInformation(entitlementInfo2, storeProduct, transactionDetails2, dateFormatter2, locale2, localization2);
            }
            PurchasesType purchasesType = this.purchases;
            String productIdentifier = transactionDetails.getProductIdentifier();
            TransactionDetails.Subscription subscription = transactionDetails instanceof TransactionDetails.Subscription ? (TransactionDetails.Subscription) transactionDetails : null;
            String productPlanIdentifier = subscription != null ? subscription.getProductPlanIdentifier() : null;
            anonymousClass1.L$0 = transactionDetails;
            anonymousClass1.L$1 = entitlementInfo;
            anonymousClass1.L$2 = dateFormatter;
            anonymousClass1.L$3 = locale;
            localization3 = localization;
            anonymousClass1.L$4 = localization3;
            anonymousClass1.label = 1;
            objAwaitGetProduct = purchasesType.awaitGetProduct(productIdentifier, productPlanIdentifier, anonymousClass1);
            if (objAwaitGetProduct == aVar) {
                return aVar;
            }
            entitlementInfo3 = entitlementInfo;
            dateFormatter3 = dateFormatter;
            locale3 = locale;
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            CustomerCenterConfigData.Localization localization4 = (CustomerCenterConfigData.Localization) anonymousClass1.L$4;
            locale3 = (Locale) anonymousClass1.L$3;
            dateFormatter3 = (DateFormatter) anonymousClass1.L$2;
            entitlementInfo3 = (EntitlementInfo) anonymousClass1.L$1;
            TransactionDetails transactionDetails3 = (TransactionDetails) anonymousClass1.L$0;
            AbstractC2467b.l(objAwaitGetProduct);
            localization3 = localization4;
            transactionDetails = transactionDetails3;
        }
        StoreProduct storeProduct2 = (StoreProduct) objAwaitGetProduct;
        if (storeProduct2 == null) {
            Logger.INSTANCE.w("Could not find product, loading without product information: " + transactionDetails.getProductIdentifier());
        }
        locale2 = locale3;
        dateFormatter2 = dateFormatter3;
        entitlementInfo2 = entitlementInfo3;
        storeProduct = storeProduct2;
        localization2 = localization3;
        transactionDetails2 = transactionDetails;
        return new PurchaseInformation(entitlementInfo2, storeProduct, transactionDetails2, dateFormatter2, locale2, localization2);
    }

    private final void displayFeedbackSurvey(CustomerCenterConfigData.HelpPath.PathDetail.FeedbackSurvey feedbackSurvey, J4.c cVar) {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        H h5 = this._state;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            objCopy$default = (CustomerCenterState) value;
            if (objCopy$default instanceof CustomerCenterState.Success) {
                CustomerCenterState.Success success = (CustomerCenterState.Success) objCopy$default;
                objCopy$default = CustomerCenterState.Success.copy$default(success, null, null, null, null, null, null, success.getNavigationState().push(new CustomerCenterDestination.FeedbackSurvey(new FeedbackSurveyData(feedbackSurvey, cVar), feedbackSurvey.getTitle())), CustomerCenterState.NavigationButtonType.BACK, null, false, false, 1855, null);
            }
        } while (!c0Var.i(value, objCopy$default));
    }

    private final List<TransactionDetails> findActiveTransactions(CustomerInfo customerInfo) {
        Object nonSubscription;
        Collection<SubscriptionInfo> collectionValues = customerInfo.getSubscriptionsByProductIdentifier().values();
        ArrayList arrayList = new ArrayList();
        for (Object obj : collectionValues) {
            if (((SubscriptionInfo) obj).isActive()) {
                arrayList.add(obj);
            }
        }
        List listX0 = AbstractC3251q.x0(new Comparator() { // from class: com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModelImpl$findActiveTransactions$$inlined$sortedBy$1
            /* JADX WARN: Multi-variable type inference failed */
            @Override // java.util.Comparator
            public final int compare(T t6, T t7) {
                return AbstractC2478m.d(((SubscriptionInfo) t6).getExpiresDate(), ((SubscriptionInfo) t7).getExpiresDate());
            }
        }, arrayList);
        ArrayList arrayList2 = new ArrayList();
        for (Object obj2 : listX0) {
            if (((SubscriptionInfo) obj2).getStore() == Store.PLAY_STORE) {
                arrayList2.add(obj2);
            }
        }
        List<Transaction> nonSubscriptionTransactions = customerInfo.getNonSubscriptionTransactions();
        ArrayList arrayList3 = new ArrayList();
        for (Object obj3 : nonSubscriptionTransactions) {
            if (((Transaction) obj3).getStore() == Store.PLAY_STORE) {
                arrayList3.add(obj3);
            }
        }
        ArrayList arrayList4 = new ArrayList();
        for (Object obj4 : listX0) {
            if (((SubscriptionInfo) obj4).getStore() != Store.PLAY_STORE) {
                arrayList4.add(obj4);
            }
        }
        List<Transaction> nonSubscriptionTransactions2 = customerInfo.getNonSubscriptionTransactions();
        ArrayList arrayList5 = new ArrayList();
        for (Object obj5 : nonSubscriptionTransactions2) {
            if (((Transaction) obj5).getStore() != Store.PLAY_STORE) {
                arrayList5.add(obj5);
            }
        }
        ArrayList arrayListS0 = AbstractC3251q.s0(arrayList5, AbstractC3251q.s0(arrayList4, AbstractC3251q.s0(arrayList3, arrayList2)));
        ArrayList arrayList6 = new ArrayList();
        for (Object obj6 : arrayListS0) {
            if (obj6 instanceof SubscriptionInfo) {
                nonSubscription = asTransactionDetails((SubscriptionInfo) obj6);
            } else if (obj6 instanceof Transaction) {
                Transaction transaction = (Transaction) obj6;
                nonSubscription = new TransactionDetails.NonSubscription(transaction.getProductIdentifier(), transaction.getStore(), transaction.getPrice(), transaction.isSandbox());
            } else {
                nonSubscription = null;
            }
            if (nonSubscription != null) {
                arrayList6.add(nonSubscription);
            }
        }
        return arrayList6;
    }

    private final TransactionDetails.Subscription findLatestExpiredSubscription(CustomerInfo customerInfo) {
        Object next;
        Collection<SubscriptionInfo> collectionValues = customerInfo.getSubscriptionsByProductIdentifier().values();
        ArrayList arrayList = new ArrayList();
        for (Object obj : collectionValues) {
            SubscriptionInfo subscriptionInfo = (SubscriptionInfo) obj;
            if (!subscriptionInfo.isActive() && subscriptionInfo.getExpiresDate() != null) {
                arrayList.add(obj);
            }
        }
        Iterator it = arrayList.iterator();
        if (it.hasNext()) {
            next = it.next();
            if (it.hasNext()) {
                Date expiresDate = ((SubscriptionInfo) next).getExpiresDate();
                o.e(expiresDate);
                do {
                    Object next2 = it.next();
                    Date expiresDate2 = ((SubscriptionInfo) next2).getExpiresDate();
                    o.e(expiresDate2);
                    if (expiresDate.compareTo(expiresDate2) < 0) {
                        next = next2;
                        expiresDate = expiresDate2;
                    }
                } while (it.hasNext());
            }
        } else {
            next = null;
        }
        SubscriptionInfo subscriptionInfo2 = (SubscriptionInfo) next;
        if (subscriptionInfo2 != null) {
            return asTransactionDetails(subscriptionInfo2);
        }
        return null;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object findTargetProduct(String str, String str2, d dVar) {
        C16541 c16541;
        if (dVar instanceof C16541) {
            c16541 = (C16541) dVar;
            int i6 = c16541.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c16541.label = i6 - Integer.MIN_VALUE;
            } else {
                c16541 = new C16541(dVar);
            }
        }
        Object objAwaitGetProduct = c16541.result;
        B4.a aVar = B4.a.f492a;
        int i7 = c16541.label;
        if (i7 == 0) {
            AbstractC2467b.l(objAwaitGetProduct);
            List listD1 = S4.p.d1(str, new String[]{Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR}, 6);
            String str3 = (String) AbstractC3251q.e0(listD1);
            String str4 = (String) AbstractC3251q.h0(1, listD1);
            if (str4 != null) {
                str2 = str4;
            }
            PurchasesType purchasesType = this.purchases;
            c16541.label = 1;
            objAwaitGetProduct = purchasesType.awaitGetProduct(str3, str2, c16541);
            if (objAwaitGetProduct == aVar) {
                return aVar;
            }
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(objAwaitGetProduct);
        }
        return (StoreProduct) objAwaitGetProduct;
    }

    private final g getCurrentLocaleList() {
        String preferredUILocaleOverride = this.purchases.getPreferredUILocaleOverride();
        if (preferredUILocaleOverride == null) {
            return g.b();
        }
        try {
            Locale[] localeArr = {LocaleHelpersKt.createLocaleFromString(preferredUILocaleOverride)};
            g gVar = g.f447b;
            return new g(new B1.h(new LocaleList(localeArr)));
        } catch (IllegalArgumentException unused) {
            Logger.INSTANCE.w("Invalid preferred locale format: " + preferredUILocaleOverride + ". Using system default.");
            return g.b();
        }
    }

    private final SubscriptionOption getCustomerCenterSubscriptionOption(String str, StoreProduct storeProduct) {
        SubscriptionOptions subscriptionOptions = storeProduct.getSubscriptionOptions();
        SubscriptionOption subscriptionOption = null;
        if (subscriptionOptions == null) {
            return null;
        }
        Iterator<SubscriptionOption> it = subscriptionOptions.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            SubscriptionOption next = it.next();
            SubscriptionOption subscriptionOption2 = next;
            if ((subscriptionOption2 instanceof GoogleSubscriptionOption) && subscriptionOption2.getTags().contains(SharedConstants.RC_CUSTOMER_CENTER_TAG) && o.c(((GoogleSubscriptionOption) subscriptionOption2).getOfferId(), str)) {
                subscriptionOption = next;
                break;
            }
        }
        return subscriptionOption;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0081 A[PHI: r2
      0x0081: PHI (r2v4 com.revenuecat.purchases.customercenter.CustomerCenterConfigData$HelpPath$PathDetail$PromotionalOffer$CrossProductPromotion) = 
      (r2v3 com.revenuecat.purchases.customercenter.CustomerCenterConfigData$HelpPath$PathDetail$PromotionalOffer$CrossProductPromotion)
      (r2v12 com.revenuecat.purchases.customercenter.CustomerCenterConfigData$HelpPath$PathDetail$PromotionalOffer$CrossProductPromotion)
      (r2v14 com.revenuecat.purchases.customercenter.CustomerCenterConfigData$HelpPath$PathDetail$PromotionalOffer$CrossProductPromotion)
     binds: [B:15:0x0052, B:19:0x0066, B:22:0x0078] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0086  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x009e  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00df  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x0103  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getPromotionalSubscriptionOption(CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer promotionalOffer, StoreProduct storeProduct, d dVar) {
        C16551 c16551;
        CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer.CrossProductPromotion crossProductPromotion;
        CustomerCenterViewModelImpl customerCenterViewModelImpl;
        StoreProduct storeProduct2;
        if (dVar instanceof C16551) {
            c16551 = (C16551) dVar;
            int i6 = c16551.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c16551.label = i6 - Integer.MIN_VALUE;
            } else {
                c16551 = new C16551(dVar);
            }
        }
        Object objFindTargetProduct = c16551.result;
        B4.a aVar = B4.a.f492a;
        int i7 = c16551.label;
        if (i7 == 0) {
            AbstractC2467b.l(objFindTargetProduct);
            GoogleStoreProduct googleProduct = GoogleStoreProductKt.getGoogleProduct(storeProduct);
            CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer.CrossProductPromotion crossProductPromotion2 = promotionalOffer.getCrossProductPromotions().get(storeProduct.getId());
            if (crossProductPromotion2 != null) {
                crossProductPromotion = crossProductPromotion2;
                if (crossProductPromotion == null) {
                    Logger.INSTANCE.d("No promotional offer configured for product " + storeProduct.getId());
                    return null;
                }
                if (o.c(crossProductPromotion.getTargetProductId(), storeProduct.getId())) {
                    customerCenterViewModelImpl = this;
                    storeProduct2 = storeProduct;
                } else {
                    if ((googleProduct != null ? googleProduct.getBasePlanId() : null) != null) {
                        String targetProductId = crossProductPromotion.getTargetProductId();
                        String basePlanId = googleProduct.getBasePlanId();
                        o.e(basePlanId);
                        c16551.L$0 = this;
                        c16551.L$1 = storeProduct;
                        c16551.L$2 = crossProductPromotion;
                        c16551.label = 1;
                        objFindTargetProduct = findTargetProduct(targetProductId, basePlanId, c16551);
                        if (objFindTargetProduct == aVar) {
                            return aVar;
                        }
                        customerCenterViewModelImpl = this;
                    } else {
                        customerCenterViewModelImpl = this;
                        storeProduct2 = storeProduct;
                        storeProduct = null;
                    }
                }
            } else {
                crossProductPromotion2 = googleProduct != null ? promotionalOffer.getCrossProductPromotions().get(googleProduct.getProductId()) : null;
                if (crossProductPromotion2 == null) {
                    String str = promotionalOffer.getProductMapping().get(storeProduct.getId());
                    if (str != null) {
                        crossProductPromotion2 = new CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer.CrossProductPromotion(str, storeProduct.getId());
                        crossProductPromotion = crossProductPromotion2;
                        if (crossProductPromotion == null) {
                        }
                    } else {
                        crossProductPromotion = null;
                        if (crossProductPromotion == null) {
                        }
                    }
                }
            }
            if (storeProduct == null) {
                return customerCenterViewModelImpl.getCustomerCenterSubscriptionOption(crossProductPromotion.getStoreOfferIdentifier(), storeProduct);
            }
            Logger.INSTANCE.d("Could not find discount of product (" + crossProductPromotion.getTargetProductId() + ") for active subscription " + storeProduct2.getId());
            return null;
        }
        if (i7 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        crossProductPromotion = (CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer.CrossProductPromotion) c16551.L$2;
        storeProduct = (StoreProduct) c16551.L$1;
        customerCenterViewModelImpl = (CustomerCenterViewModelImpl) c16551.L$0;
        AbstractC2467b.l(objFindTargetProduct);
        StoreProduct storeProduct3 = (StoreProduct) objFindTargetProduct;
        storeProduct2 = storeProduct;
        storeProduct = storeProduct3;
        if (storeProduct == null) {
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void goBackToMain() {
        c0 c0Var;
        Object value;
        Object objResetToMainScreen;
        H h5 = this._state;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            objResetToMainScreen = (CustomerCenterState) value;
            if (objResetToMainScreen instanceof CustomerCenterState.Success) {
                objResetToMainScreen = resetToMainScreen((CustomerCenterState.Success) objResetToMainScreen);
            }
        } while (!c0Var.i(value, objResetToMainScreen));
    }

    private final void handleCancelPath(Context context, PurchaseInformation purchaseInformation) {
        Object value = ((c0) this._state).getValue();
        CustomerCenterState.Success success = value instanceof CustomerCenterState.Success ? (CustomerCenterState.Success) value : null;
        if (success == null) {
            return;
        }
        if (purchaseInformation == null) {
            CustomerCenterDestination currentDestination = success.getCurrentDestination();
            purchaseInformation = currentDestination instanceof CustomerCenterDestination.SelectedPurchaseDetail ? ((CustomerCenterDestination.SelectedPurchaseDetail) currentDestination).getPurchaseInformation() : success.getPurchases().size() == 1 ? (PurchaseInformation) AbstractC3251q.e0(success.getPurchases()) : null;
        }
        if ((purchaseInformation != null ? purchaseInformation.getStore() : null) == Store.PLAY_STORE && purchaseInformation.getProduct() != null) {
            startGoogleProductCancellation(context, purchaseInformation.getProduct());
            return;
        }
        if ((purchaseInformation != null ? purchaseInformation.getManagementURL() : null) != null) {
            startManagementUrlCancellation(context, purchaseInformation.getManagementURL());
        } else {
            Logger.INSTANCE.e("No product or management URL available for cancel path");
        }
    }

    public static /* synthetic */ void handleCancelPath$default(CustomerCenterViewModelImpl customerCenterViewModelImpl, Context context, PurchaseInformation purchaseInformation, int i6, Object obj) {
        if ((i6 & 2) != 0) {
            purchaseInformation = null;
        }
        customerCenterViewModelImpl.handleCancelPath(context, purchaseInformation);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void handlePaywallError(String str, PurchasesErrorCode purchasesErrorCode) {
        Logger.INSTANCE.e(str);
        this._actionError.setValue(new PurchasesError(purchasesErrorCode, str));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Object handlePromotionalOffer(Context context, StoreProduct storeProduct, CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer promotionalOffer, CustomerCenterConfigData.HelpPath helpPath, PurchaseInformation purchaseInformation, d dVar) {
        return (storeProduct == null || promotionalOffer == null) ? Boolean.FALSE : loadAndDisplayPromotionalOffer(context, storeProduct, promotionalOffer, helpPath, purchaseInformation, dVar);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void handleSupportTicketSubmit(String str, String str2, a aVar, a aVar2) {
        if (((CustomerCenterState) ((c0) this._state).getValue()) instanceof CustomerCenterState.Success) {
            E.y(X.h(this), null, null, new C16561(str, str2, this, aVar, aVar2, null), 3);
        }
    }

    private final boolean isPathAllowedForStore(CustomerCenterConfigData.HelpPath helpPath, PurchaseInformation purchaseInformation) {
        switch (WhenMappings.$EnumSwitchMapping$0[helpPath.getType().ordinal()]) {
            case 2:
                if ((purchaseInformation != null ? purchaseInformation.getStore() : null) != Store.PLAY_STORE) {
                    if ((purchaseInformation != null ? purchaseInformation.getManagementURL() : null) == null) {
                        return false;
                    }
                }
            case 1:
            case 3:
            case 4:
                return true;
            case 5:
            case 6:
            case 7:
                return false;
            default:
                throw new v();
        }
    }

    private final boolean isPathAllowedForSubscriptionState(CustomerCenterConfigData.HelpPath helpPath, PurchaseInformation purchaseInformation) {
        if (helpPath.getType() == CustomerCenterConfigData.HelpPath.PathType.CANCEL) {
            return (purchaseInformation == null || !purchaseInformation.isSubscription() || purchaseInformation.isExpired()) ? false : true;
        }
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void launchPaywallActivity(Context context, Offering offering) {
        try {
            Logger logger = Logger.INSTANCE;
            logger.d("Showing paywall for offering: " + offering.getIdentifier());
            String identifier = offering.getIdentifier();
            Package r6 = (Package) AbstractC3251q.g0(offering.getAvailablePackages());
            PaywallActivityArgs paywallActivityArgs = new PaywallActivityArgs((String) null, new OfferingSelection.IdAndPresentedOfferingContext(identifier, r6 != null ? r6.getPresentedOfferingContext() : null), (Map) null, true, false, false, (Map) null, (Integer) null, 245, (h) null);
            Intent intent = new Intent(context, (Class<?>) PaywallActivity.class);
            intent.putExtra(PaywallActivity.ARGS_EXTRA, paywallActivityArgs);
            intent.addFlags(268435456);
            context.startActivity(intent);
            logger.d("Successfully launched paywall for offering: " + offering.getIdentifier());
        } catch (ActivityNotFoundException e6) {
            handlePaywallError("PaywallActivity not found: " + e6.getMessage(), PurchasesErrorCode.ConfigurationError);
        } catch (IllegalArgumentException e7) {
            handlePaywallError("Invalid argument for paywall: " + e7.getMessage(), PurchasesErrorCode.UnknownError);
        } catch (SecurityException e8) {
            handlePaywallError("Security error launching paywall: " + e8.getMessage(), PurchasesErrorCode.UnknownError);
        }
    }

    private final void launchRefreshIfPossible() {
        CustomerCenterState customerCenterState = (CustomerCenterState) ((c0) this._state).getValue();
        if (!(customerCenterState instanceof CustomerCenterState.Success) || ((CustomerCenterState.Success) customerCenterState).isRefreshing()) {
            return;
        }
        E.y(X.h(this), null, null, new C16571(null), 3);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:56:0x0194, code lost:
    
        if (r1 == r2) goto L57;
     */
    /* JADX WARN: Removed duplicated region for block: B:31:0x00e0  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x0141  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:41:0x0132 -> B:42:0x0137). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object loadPurchases(DateFormatter dateFormatter, Locale locale, CustomerCenterConfigData.Localization localization, d dVar) {
        C16591 c16591;
        Locale locale2;
        CustomerCenterViewModelImpl customerCenterViewModelImpl;
        DateFormatter dateFormatter2;
        CustomerCenterConfigData.Localization localization2;
        CustomerInfo customerInfo;
        CustomerCenterConfigData.Localization localization3;
        C16591 c165912;
        Locale locale3;
        CustomerCenterViewModelImpl customerCenterViewModelImpl2;
        Collection arrayList;
        Iterator it;
        DateFormatter dateFormatter3;
        Object next;
        Object next2;
        if (dVar instanceof C16591) {
            c16591 = (C16591) dVar;
            int i6 = c16591.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c16591.label = i6 - Integer.MIN_VALUE;
            } else {
                c16591 = new C16591(dVar);
            }
        }
        C16591 c165913 = c16591;
        Object objAwaitCustomerInfo = c165913.result;
        B4.a aVar = B4.a.f492a;
        int i7 = c165913.label;
        if (i7 == 0) {
            AbstractC2467b.l(objAwaitCustomerInfo);
            PurchasesType purchasesType = this.purchases;
            CacheFetchPolicy cacheFetchPolicy = CacheFetchPolicy.FETCH_CURRENT;
            c165913.L$0 = this;
            c165913.L$1 = dateFormatter;
            locale2 = locale;
            c165913.L$2 = locale2;
            c165913.L$3 = localization;
            c165913.label = 1;
            objAwaitCustomerInfo = purchasesType.awaitCustomerInfo(cacheFetchPolicy, c165913);
            if (objAwaitCustomerInfo != aVar) {
                customerCenterViewModelImpl = this;
                dateFormatter2 = dateFormatter;
                localization2 = localization;
            }
            return aVar;
        }
        if (i7 == 1) {
            CustomerCenterConfigData.Localization localization4 = (CustomerCenterConfigData.Localization) c165913.L$3;
            Locale locale4 = (Locale) c165913.L$2;
            DateFormatter dateFormatter4 = (DateFormatter) c165913.L$1;
            CustomerCenterViewModelImpl customerCenterViewModelImpl3 = (CustomerCenterViewModelImpl) c165913.L$0;
            AbstractC2467b.l(objAwaitCustomerInfo);
            localization2 = localization4;
            customerCenterViewModelImpl = customerCenterViewModelImpl3;
            locale2 = locale4;
            dateFormatter2 = dateFormatter4;
        } else {
            if (i7 != 2) {
                if (i7 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(objAwaitCustomerInfo);
                return AbstractC2612c.q(objAwaitCustomerInfo);
            }
            arrayList = (Collection) c165913.L$7;
            it = (Iterator) c165913.L$6;
            Collection collection = (Collection) c165913.L$5;
            CustomerInfo customerInfo2 = (CustomerInfo) c165913.L$4;
            CustomerCenterConfigData.Localization localization5 = (CustomerCenterConfigData.Localization) c165913.L$3;
            Locale locale5 = (Locale) c165913.L$2;
            DateFormatter dateFormatter5 = (DateFormatter) c165913.L$1;
            CustomerCenterViewModelImpl customerCenterViewModelImpl4 = (CustomerCenterViewModelImpl) c165913.L$0;
            AbstractC2467b.l(objAwaitCustomerInfo);
            locale3 = locale5;
            dateFormatter3 = dateFormatter5;
            c165912 = c165913;
            arrayList.add((PurchaseInformation) objAwaitCustomerInfo);
            arrayList = collection;
            customerInfo = customerInfo2;
            customerCenterViewModelImpl2 = customerCenterViewModelImpl4;
            localization3 = localization5;
            if (it.hasNext()) {
                TransactionDetails transactionDetails = (TransactionDetails) it.next();
                Iterator<T> it2 = customerInfo.getEntitlements().getAll().values().iterator();
                while (true) {
                    if (!it2.hasNext()) {
                        next2 = null;
                        break;
                    }
                    next2 = it2.next();
                    if (o.c(((EntitlementInfo) next2).getProductIdentifier(), transactionDetails.getProductIdentifier())) {
                        break;
                    }
                }
                c165912.L$0 = customerCenterViewModelImpl2;
                c165912.L$1 = dateFormatter3;
                c165912.L$2 = locale3;
                c165912.L$3 = localization3;
                c165912.L$4 = customerInfo;
                c165912.L$5 = arrayList;
                c165912.L$6 = it;
                c165912.L$7 = arrayList;
                c165912.label = 2;
                Object objCreatePurchaseInformation = customerCenterViewModelImpl2.createPurchaseInformation(transactionDetails, (EntitlementInfo) next2, dateFormatter3, locale3, localization3, c165912);
                if (objCreatePurchaseInformation != aVar) {
                    localization5 = localization3;
                    customerCenterViewModelImpl4 = customerCenterViewModelImpl2;
                    customerInfo2 = customerInfo;
                    objAwaitCustomerInfo = objCreatePurchaseInformation;
                    collection = arrayList;
                    arrayList.add((PurchaseInformation) objAwaitCustomerInfo);
                    arrayList = collection;
                    customerInfo = customerInfo2;
                    customerCenterViewModelImpl2 = customerCenterViewModelImpl4;
                    localization3 = localization5;
                    if (it.hasNext()) {
                        return (List) arrayList;
                    }
                }
                return aVar;
            }
        }
        customerInfo = (CustomerInfo) objAwaitCustomerInfo;
        boolean zIsEmpty = customerInfo.getActiveSubscriptions().isEmpty();
        boolean zIsEmpty2 = customerInfo.getNonSubscriptionTransactions().isEmpty();
        if (!zIsEmpty || !zIsEmpty2) {
            List<TransactionDetails> listFindActiveTransactions = customerCenterViewModelImpl.findActiveTransactions(customerInfo);
            if (listFindActiveTransactions.isEmpty()) {
                Logger.INSTANCE.w("Could not find subscription information");
            } else {
                localization3 = localization2;
                c165912 = c165913;
                locale3 = locale2;
                customerCenterViewModelImpl2 = customerCenterViewModelImpl;
                arrayList = new ArrayList(AbstractC3253s.G(listFindActiveTransactions, 10));
                it = listFindActiveTransactions.iterator();
                dateFormatter3 = dateFormatter2;
                if (it.hasNext()) {
                }
            }
        }
        TransactionDetails.Subscription subscriptionFindLatestExpiredSubscription = customerCenterViewModelImpl.findLatestExpiredSubscription(customerInfo);
        if (subscriptionFindLatestExpiredSubscription == null) {
            return y.f26065a;
        }
        Iterator<T> it3 = customerInfo.getEntitlements().getAll().values().iterator();
        while (true) {
            if (!it3.hasNext()) {
                next = null;
                break;
            }
            next = it3.next();
            if (o.c(((EntitlementInfo) next).getProductIdentifier(), subscriptionFindLatestExpiredSubscription.getProductIdentifier())) {
                break;
            }
        }
        c165913.L$0 = null;
        c165913.L$1 = null;
        c165913.L$2 = null;
        c165913.L$3 = null;
        c165913.label = 3;
        objAwaitCustomerInfo = customerCenterViewModelImpl.createPurchaseInformation(subscriptionFindLatestExpiredSubscription, (EntitlementInfo) next, dateFormatter2, locale2, localization2, c165913);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void mainPathAction(CustomerCenterConfigData.HelpPath helpPath, Context context, PurchaseInformation purchaseInformation) {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        String actionIdentifier;
        StoreProduct product;
        int i6 = WhenMappings.$EnumSwitchMapping$0[helpPath.getType().ordinal()];
        if (i6 == 1) {
            H h5 = this._state;
            do {
                c0Var = (c0) h5;
                value = c0Var.getValue();
                objCopy$default = (CustomerCenterState) value;
                if (objCopy$default instanceof CustomerCenterState.Success) {
                    objCopy$default = CustomerCenterState.Success.copy$default((CustomerCenterState.Success) objCopy$default, null, null, null, null, RestorePurchasesState.RESTORING, null, null, null, null, false, false, 2031, null);
                }
            } while (!c0Var.i(value, objCopy$default));
            return;
        }
        if (i6 == 2) {
            handleCancelPath(context, purchaseInformation);
            return;
        }
        if (i6 != 3) {
            if (i6 == 4 && (actionIdentifier = helpPath.getActionIdentifier()) != null) {
                onCustomActionSelected(new CustomActionData(actionIdentifier, (purchaseInformation == null || (product = purchaseInformation.getProduct()) == null) ? null : product.getId()));
                return;
            }
            return;
        }
        String url = helpPath.getUrl();
        if (url != null) {
            CustomerCenterConfigData.HelpPath.OpenMethod openMethod = helpPath.getOpenMethod();
            if (openMethod == null) {
                openMethod = CustomerCenterConfigData.HelpPath.OpenMethod.EXTERNAL;
            }
            openURL(context, url, openMethod);
        }
    }

    public static /* synthetic */ void mainPathAction$default(CustomerCenterViewModelImpl customerCenterViewModelImpl, CustomerCenterConfigData.HelpPath helpPath, Context context, PurchaseInformation purchaseInformation, int i6, Object obj) {
        if ((i6 & 4) != 0) {
            purchaseInformation = null;
        }
        customerCenterViewModelImpl.mainPathAction(helpPath, context, purchaseInformation);
    }

    private final void notifyListenersForCustomActionSelected(CustomActionData customActionData) {
        CustomerCenterListener customerCenterListener = this.listener;
        if (customerCenterListener != null) {
            customerCenterListener.onCustomActionSelected(customActionData.getActionIdentifier(), customActionData.getPurchaseIdentifier());
        }
        CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
        if (customerCenterListener2 != null) {
            customerCenterListener2.onCustomActionSelected(customActionData.getActionIdentifier(), customActionData.getPurchaseIdentifier());
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void notifyListenersForFeedbackSurveyCompleted(String str) {
        CustomerCenterListener customerCenterListener = this.listener;
        if (customerCenterListener != null) {
            customerCenterListener.onFeedbackSurveyCompleted(str);
        }
        CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
        if (customerCenterListener2 != null) {
            customerCenterListener2.onFeedbackSurveyCompleted(str);
        }
    }

    private final void notifyListenersForManageSubscription() {
        CustomerCenterListener customerCenterListener = this.listener;
        if (customerCenterListener != null) {
            customerCenterListener.onShowingManageSubscriptions();
        }
        CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
        if (customerCenterListener2 != null) {
            customerCenterListener2.onShowingManageSubscriptions();
        }
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    private final void notifyListenersForManagementOptionSelected(CustomerCenterConfigData.HelpPath helpPath, PurchaseInformation purchaseInformation) {
        CustomerCenterManagementOption customUrl;
        String actionIdentifier;
        StoreProduct product;
        int i6 = WhenMappings.$EnumSwitchMapping$0[helpPath.getType().ordinal()];
        if (i6 == 1) {
            customUrl = CustomerCenterManagementOption.MissingPurchase.INSTANCE;
        } else if (i6 != 2) {
            customUrl = null;
            id = null;
            String id = null;
            customUrl = null;
            customUrl = null;
            if (i6 == 3) {
                String url = helpPath.getUrl();
                if (url != null) {
                    customUrl = new CustomerCenterManagementOption.CustomUrl(Uri.parse(url));
                }
            } else if (i6 == 4 && (actionIdentifier = helpPath.getActionIdentifier()) != null) {
                if (purchaseInformation != null && (product = purchaseInformation.getProduct()) != null) {
                    id = product.getId();
                }
                customUrl = new CustomerCenterManagementOption.CustomAction(actionIdentifier, id);
            }
        } else {
            customUrl = CustomerCenterManagementOption.Cancel.INSTANCE;
        }
        if (customUrl != null) {
            CustomerCenterListener customerCenterListener = this.listener;
            if (customerCenterListener != null) {
                customerCenterListener.onManagementOptionSelected(customUrl);
            }
            CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
            if (customerCenterListener2 != null) {
                customerCenterListener2.onManagementOptionSelected(customUrl);
            }
        }
    }

    private final void notifyListenersForRestoreCompleted(CustomerInfo customerInfo) {
        CustomerCenterListener customerCenterListener = this.listener;
        if (customerCenterListener != null) {
            customerCenterListener.onRestoreCompleted(customerInfo);
        }
        CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
        if (customerCenterListener2 != null) {
            customerCenterListener2.onRestoreCompleted(customerInfo);
        }
    }

    private final void notifyListenersForRestoreFailed(PurchasesError purchasesError) {
        CustomerCenterListener customerCenterListener = this.listener;
        if (customerCenterListener != null) {
            customerCenterListener.onRestoreFailed(purchasesError);
        }
        CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
        if (customerCenterListener2 != null) {
            customerCenterListener2.onRestoreFailed(purchasesError);
        }
    }

    private final void notifyListenersForRestoreStarted() {
        CustomerCenterListener customerCenterListener = this.listener;
        if (customerCenterListener != null) {
            customerCenterListener.onRestoreStarted();
        }
        CustomerCenterListener customerCenterListener2 = this.purchases.getCustomerCenterListener();
        if (customerCenterListener2 != null) {
            customerCenterListener2.onRestoreStarted();
        }
    }

    private final CustomerCenterState.Success preservingUIStateIfRefresh(CustomerCenterState.Success success, boolean z6, CustomerCenterState customerCenterState) {
        if (!z6 || !(customerCenterState instanceof CustomerCenterState.Success)) {
            return success;
        }
        CustomerCenterState.Success success2 = (CustomerCenterState.Success) customerCenterState;
        CustomerCenterNavigationState navigationState = success2.getNavigationState();
        CustomerCenterState.NavigationButtonType navigationButtonType = customerCenterState.getNavigationButtonType();
        return CustomerCenterState.Success.copy$default(success, null, null, null, success2.getDetailScreenPaths(), success2.getRestorePurchasesState(), null, navigationState, navigationButtonType, null, success2.getShowSupportTicketSuccessSnackbar(), false, 1319, null);
    }

    private final CustomerCenterState.Success resetToMainScreen(CustomerCenterState.Success success) {
        return CustomerCenterState.Success.copy$default(success, null, null, null, null, null, null, success.getNavigationState().popToMain(), CustomerCenterState.NavigationButtonType.CLOSE, null, false, false, 1839, null);
    }

    private final void showManageSubscriptions(Context context, String str) {
        try {
            context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/account/subscriptions?sku=" + str + "&package=" + context.getPackageName())));
        } catch (ActivityNotFoundException e6) {
            Logger.INSTANCE.e("Error opening manage subscriptions", e6);
        }
    }

    private final void startGoogleProductCancellation(Context context, StoreProduct storeProduct) {
        GoogleStoreProduct googleStoreProduct = storeProduct instanceof GoogleStoreProduct ? (GoogleStoreProduct) storeProduct : null;
        if (googleStoreProduct == null) {
            Logger.INSTANCE.e("Expected GoogleStoreProduct for Play Store cancellation");
            return;
        }
        this.shouldRefreshOnResume = true;
        notifyListenersForManageSubscription();
        showManageSubscriptions(context, googleStoreProduct.getProductId());
    }

    private final void startManagementUrlCancellation(Context context, Uri uri) {
        this.shouldRefreshOnResume = true;
        notifyListenersForManageSubscription();
        String string = uri.toString();
        o.g(string, "managementURL.toString()");
        openURL(context, string, CustomerCenterConfigData.HelpPath.OpenMethod.EXTERNAL);
    }

    private final List<CustomerCenterConfigData.HelpPath> supportedPaths(PurchaseInformation purchaseInformation, CustomerCenterConfigData.Screen screen, CustomerCenterConfigData.Localization localization) {
        List<CustomerCenterConfigData.HelpPath> paths = screen.getPaths();
        ArrayList arrayList = new ArrayList();
        for (Object obj : paths) {
            if (isPathAllowedForStore((CustomerCenterConfigData.HelpPath) obj, purchaseInformation)) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList();
        for (Object obj2 : arrayList) {
            if (isPathAllowedForSubscriptionState((CustomerCenterConfigData.HelpPath) obj2, purchaseInformation)) {
                arrayList2.add(obj2);
            }
        }
        return transformPathsOnSubscriptionState(arrayList2, purchaseInformation, localization);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    public final void trackCustomerCenterEventOptionChosen(CustomerCenterConfigData.HelpPath.PathType pathType, String str, String str2) {
        Locale localeA = ((g) ((c0) this._lastLocaleList).getValue()).a(0);
        if (localeA == null) {
            localeA = Locale.getDefault();
        }
        Date date = new Date();
        boolean z6 = this.isDarkMode;
        String string = localeA.toString();
        o.g(string, "locale.toString()");
        CustomerCenterSurveyOptionChosenEvent.CreationData creationData = null;
        this.purchases.track(new CustomerCenterSurveyOptionChosenEvent(creationData, new CustomerCenterSurveyOptionChosenEvent.Data(date, z6, string, 0, 0, null, pathType, str, str2, null, 568, null), 1, 0 == true ? 1 : 0));
    }

    private final List<CustomerCenterConfigData.HelpPath> transformPathsOnSubscriptionState(List<CustomerCenterConfigData.HelpPath> list, PurchaseInformation purchaseInformation, CustomerCenterConfigData.Localization localization) {
        ArrayList arrayList = new ArrayList(AbstractC3253s.G(list, 10));
        for (CustomerCenterConfigData.HelpPath helpPathCopy$default : list) {
            if (helpPathCopy$default.getType() == CustomerCenterConfigData.HelpPath.PathType.CANCEL && purchaseInformation != null && purchaseInformation.isCancelled()) {
                helpPathCopy$default = CustomerCenterConfigData.HelpPath.copy$default(helpPathCopy$default, null, localization.commonLocalizedString(CustomerCenterConfigData.Localization.CommonLocalizedString.RESUBSCRIBE), null, null, null, null, null, null, 229, null);
            }
            arrayList.add(helpPathCopy$default);
        }
        return arrayList;
    }

    private final void tryFallbackToCurrentOffering(Context context) {
        ListenerConversionsCommonKt.getOfferingsWith(Purchases.Companion.getSharedInstance(), new C16631(), new C16642(context));
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void clearActionError() {
        this._actionError.setValue(null);
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void contactSupport(Context context, String supportEmail) {
        o.h(context, "context");
        o.h(supportEmail, "supportEmail");
        Intent intent = new Intent("android.intent.action.SENDTO");
        intent.setData(Uri.parse("mailto:".concat(supportEmail)));
        intent.putExtra("android.intent.extra.SUBJECT", "Support Request");
        intent.putExtra("android.intent.extra.TEXT", "Support request details...");
        context.startActivity(Intent.createChooser(intent, "Contact Support"));
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void dismissPromotionalOffer(Context context, CustomerCenterConfigData.HelpPath originalPath) {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        o.h(context, "context");
        o.h(originalPath, "originalPath");
        Object value2 = ((c0) this._state).getValue();
        CustomerCenterState.Success success = value2 instanceof CustomerCenterState.Success ? (CustomerCenterState.Success) value2 : null;
        CustomerCenterDestination currentDestination = success != null ? success.getCurrentDestination() : null;
        mainPathAction(originalPath, context, currentDestination instanceof CustomerCenterDestination.PromotionalOffer ? ((CustomerCenterDestination.PromotionalOffer) currentDestination).getPurchaseInformation() : null);
        H h5 = this._state;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            objCopy$default = (CustomerCenterState) value;
            if (objCopy$default instanceof CustomerCenterState.Success) {
                CustomerCenterState.Success success2 = (CustomerCenterState.Success) objCopy$default;
                objCopy$default = CustomerCenterState.Success.copy$default(success2, null, null, null, null, null, null, success2.getNavigationState().popToMain(), CustomerCenterState.NavigationButtonType.CLOSE, null, false, false, 1855, null);
            }
        } while (!c0Var.i(value, objCopy$default));
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public Object dismissRestoreDialog(d dVar) {
        Object objLoadCustomerCenter = loadCustomerCenter(dVar);
        return objLoadCustomerCenter == B4.a.f492a ? objLoadCustomerCenter : C3137A.f25453a;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void dismissSupportTicketSuccessSnackbar() {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        H h5 = this._state;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            objCopy$default = (CustomerCenterState) value;
            if (objCopy$default instanceof CustomerCenterState.Success) {
                objCopy$default = CustomerCenterState.Success.copy$default((CustomerCenterState.Success) objCopy$default, null, null, null, null, null, null, null, null, null, false, false, 1535, null);
            }
        } while (!c0Var.i(value, objCopy$default));
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public State<PurchasesError> getActionError() {
        return this._actionError;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public a0 getState() {
        return this.state;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object loadAndDisplayPromotionalOffer(Context context, StoreProduct storeProduct, CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer promotionalOffer, CustomerCenterConfigData.HelpPath helpPath, PurchaseInformation purchaseInformation, d dVar) {
        C16581 c16581;
        CustomerCenterConfigData.HelpPath helpPath2;
        PurchaseInformation purchaseInformation2;
        Object promotionalSubscriptionOption;
        CustomerCenterViewModelImpl customerCenterViewModelImpl;
        c0 c0Var;
        Object value;
        Object objCopy$default;
        CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer promotionalOffer2 = promotionalOffer;
        if (dVar instanceof C16581) {
            c16581 = (C16581) dVar;
            int i6 = c16581.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c16581.label = i6 - Integer.MIN_VALUE;
            } else {
                c16581 = new C16581(dVar);
            }
        }
        Object obj = c16581.result;
        B4.a aVar = B4.a.f492a;
        int i7 = c16581.label;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            if (!promotionalOffer2.getEligible()) {
                Logger.INSTANCE.d("User not eligible for promo with id '" + promotionalOffer2.getAndroidOfferId() + "'. Check eligibility configuration in the dashboard, and make sure the user has an active/expired subscription for the product with id '" + storeProduct.getId() + "'.");
                return Boolean.FALSE;
            }
            c16581.L$0 = this;
            c16581.L$1 = promotionalOffer2;
            helpPath2 = helpPath;
            c16581.L$2 = helpPath2;
            purchaseInformation2 = purchaseInformation;
            c16581.L$3 = purchaseInformation2;
            c16581.label = 1;
            promotionalSubscriptionOption = getPromotionalSubscriptionOption(promotionalOffer2, storeProduct, c16581);
            if (promotionalSubscriptionOption == aVar) {
                return aVar;
            }
            customerCenterViewModelImpl = this;
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            PurchaseInformation purchaseInformation3 = (PurchaseInformation) c16581.L$3;
            CustomerCenterConfigData.HelpPath helpPath3 = (CustomerCenterConfigData.HelpPath) c16581.L$2;
            CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer promotionalOffer3 = (CustomerCenterConfigData.HelpPath.PathDetail.PromotionalOffer) c16581.L$1;
            CustomerCenterViewModelImpl customerCenterViewModelImpl2 = (CustomerCenterViewModelImpl) c16581.L$0;
            AbstractC2467b.l(obj);
            purchaseInformation2 = purchaseInformation3;
            promotionalOffer2 = promotionalOffer3;
            promotionalSubscriptionOption = obj;
            helpPath2 = helpPath3;
            customerCenterViewModelImpl = customerCenterViewModelImpl2;
        }
        SubscriptionOption subscriptionOption = (SubscriptionOption) promotionalSubscriptionOption;
        if (subscriptionOption == null) {
            return Boolean.FALSE;
        }
        H h5 = customerCenterViewModelImpl._state;
        boolean z6 = false;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            objCopy$default = (CustomerCenterState) value;
            if (objCopy$default instanceof CustomerCenterState.Success) {
                CustomerCenterState.Success success = (CustomerCenterState.Success) objCopy$default;
                CustomerCenterDestination.PromotionalOffer promotionalOffer4 = new CustomerCenterDestination.PromotionalOffer(new PromotionalOfferData(promotionalOffer2, subscriptionOption, helpPath2, SubscriptionOptionExtensionsKt.getLocalizedDescription(subscriptionOption, success.getCustomerCenterConfigData().getLocalization(), customerCenterViewModelImpl.locale)), purchaseInformation2);
                CustomerCenterNavigationState customerCenterNavigationStatePush = success.getNavigationState().push(promotionalOffer4);
                CustomerCenterState.NavigationButtonType navigationButtonType = CustomerCenterState.NavigationButtonType.CLOSE;
                CustomerCenterState.Success.copy$default(success, null, null, null, null, null, null, customerCenterNavigationStatePush, navigationButtonType, null, false, false, 1855, null);
                objCopy$default = CustomerCenterState.Success.copy$default(success, null, null, null, null, null, null, success.getNavigationState().push(promotionalOffer4), navigationButtonType, null, false, false, 1855, null);
                z6 = true;
            }
        } while (!c0Var.i(value, objCopy$default));
        return Boolean.valueOf(z6);
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    @InternalRevenueCatAPI
    public Object loadCustomerCenter(d dVar) {
        Object objLoadCustomerCenter = loadCustomerCenter(false, dVar);
        return objLoadCustomerCenter == B4.a.f492a ? objLoadCustomerCenter : C3137A.f25453a;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Type inference failed for: r7v2 */
    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object onAcceptedPromotionalOffer(SubscriptionOption subscriptionOption, Activity activity, d dVar) {
        C16601 c16601;
        CustomerCenterViewModelImpl customerCenterViewModelImpl;
        if (dVar instanceof C16601) {
            c16601 = (C16601) dVar;
            int i6 = c16601.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c16601.label = i6 - Integer.MIN_VALUE;
            } else {
                c16601 = new C16601(dVar);
            }
        }
        Object obj = c16601.result;
        B4.a aVar = B4.a.f492a;
        int i7 = c16601.label;
        C3137A c3137a = C3137A.f25453a;
        try {
        } catch (PurchasesException e6) {
            e = e6;
        }
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            if (activity == null) {
                Logger.INSTANCE.e("Activity is null when accepting promotional offer");
                this._actionError.setValue(new PurchasesError(PurchasesErrorCode.PurchaseInvalidError, "Couldn't perform purchase"));
                return c3137a;
            }
            PurchaseParams.Builder builder = new PurchaseParams.Builder(activity, subscriptionOption);
            try {
                PurchasesType purchasesType = this.purchases;
                c16601.L$0 = this;
                c16601.label = 1;
                if (purchasesType.awaitPurchase(builder, c16601) != aVar) {
                    customerCenterViewModelImpl = this;
                }
            } catch (PurchasesException e7) {
                e = e7;
                subscriptionOption = this;
                if (e.getCode() != PurchasesErrorCode.PurchaseCancelledError) {
                    subscriptionOption._actionError.setValue(e.getError());
                    subscriptionOption.goBackToMain();
                }
            }
        } else {
            if (i7 != 1) {
                if (i7 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            customerCenterViewModelImpl = (CustomerCenterViewModelImpl) c16601.L$0;
            AbstractC2467b.l(obj);
        }
        c16601.L$0 = customerCenterViewModelImpl;
        c16601.label = 2;
        return customerCenterViewModelImpl.loadCustomerCenter(c16601) == aVar ? aVar : c3137a;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void onActivityResumed() {
        if (this.shouldRefreshOnResume) {
            this.shouldRefreshOnResume = false;
            Logger.INSTANCE.d("Refreshing Customer Center after returning from manage subscriptions");
            launchRefreshIfPossible();
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void onActivityStarted() {
        if (this.wasBackgrounded) {
            this.wasBackgrounded = false;
            if (this.shouldRefreshOnResume) {
                return;
            }
            launchRefreshIfPossible();
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void onActivityStopped(boolean z6) {
        if (z6) {
            return;
        }
        this.wasBackgrounded = true;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void onCustomActionSelected(CustomActionData customActionData) {
        o.h(customActionData, "customActionData");
        notifyListenersForCustomActionSelected(customActionData);
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void onNavigationButtonPressed(Context context, a onDismiss) {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        CustomerCenterState.NavigationButtonType navigationButtonType;
        o.h(context, "context");
        o.h(onDismiss, "onDismiss");
        CustomerCenterState customerCenterState = (CustomerCenterState) ((c0) this._state).getValue();
        if (customerCenterState instanceof CustomerCenterState.Success) {
            CustomerCenterState.Success success = (CustomerCenterState.Success) customerCenterState;
            if (success.getCurrentDestination() instanceof CustomerCenterDestination.PromotionalOffer) {
                CustomerCenterDestination currentDestination = success.getCurrentDestination();
                o.f(currentDestination, "null cannot be cast to non-null type com.revenuecat.purchases.ui.revenuecatui.customercenter.navigation.CustomerCenterDestination.PromotionalOffer");
                dismissPromotionalOffer(context, ((CustomerCenterDestination.PromotionalOffer) currentDestination).getData().getOriginalPath());
                return;
            }
        }
        CustomerCenterState.NavigationButtonType navigationButtonType2 = ((CustomerCenterState) getState().getValue()).getNavigationButtonType();
        H h5 = this._state;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            CustomerCenterState customerCenterState2 = (CustomerCenterState) value;
            if ((customerCenterState2 instanceof CustomerCenterState.Success) && navigationButtonType2 == (navigationButtonType = CustomerCenterState.NavigationButtonType.BACK)) {
                CustomerCenterState.Success success2 = (CustomerCenterState.Success) customerCenterState2;
                if (success2.getNavigationState().getCanNavigateBack()) {
                    CustomerCenterNavigationState customerCenterNavigationStatePop = success2.getNavigationState().pop();
                    if (!customerCenterNavigationStatePop.getCanNavigateBack()) {
                        navigationButtonType = CustomerCenterState.NavigationButtonType.CLOSE;
                    }
                    objCopy$default = CustomerCenterState.Success.copy$default(success2, null, null, null, null, null, null, customerCenterNavigationStatePop, navigationButtonType, null, false, false, 1855, null);
                } else {
                    objCopy$default = CustomerCenterState.NotLoaded.INSTANCE;
                }
            } else {
                objCopy$default = CustomerCenterState.NotLoaded.INSTANCE;
            }
        } while (!c0Var.i(value, objCopy$default));
        if (navigationButtonType2 == CustomerCenterState.NavigationButtonType.CLOSE) {
            onDismiss.invoke();
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void openURL(Context context, String url, CustomerCenterConfigData.HelpPath.OpenMethod method) {
        URLOpeningMethod uRLOpeningMethod;
        o.h(context, "context");
        o.h(url, "url");
        o.h(method, "method");
        int i6 = WhenMappings.$EnumSwitchMapping$1[method.ordinal()];
        if (i6 == 1) {
            uRLOpeningMethod = URLOpeningMethod.IN_APP_BROWSER;
        } else {
            if (i6 != 2) {
                throw new v();
            }
            uRLOpeningMethod = URLOpeningMethod.EXTERNAL_BROWSER;
        }
        URLOpener.INSTANCE.openURL$revenuecatui_defaultsBc8Release(context, url, uRLOpeningMethod);
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void pathButtonPressed(Context context, CustomerCenterConfigData.HelpPath path, PurchaseInformation purchaseInformation) {
        o.h(context, "context");
        o.h(path, "path");
        notifyListenersForManagementOptionSelected(path, purchaseInformation);
        CustomerCenterConfigData.HelpPath.PathDetail.FeedbackSurvey feedbackSurvey = path.getFeedbackSurvey();
        if (feedbackSurvey != null) {
            displayFeedbackSurvey(feedbackSurvey, new CustomerCenterViewModelImpl$pathButtonPressed$1$1(this, path, context, purchaseInformation));
        } else {
            E.y(X.h(this), null, null, new C16612(context, purchaseInformation, path, null), 3);
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void refreshColors(I currentColorScheme, boolean z6) {
        o.h(currentColorScheme, "currentColorScheme");
        this.isDarkMode = z6;
        c0 c0Var = (c0) this._colorScheme;
        c0Var.getClass();
        c0Var.k(null, currentColorScheme);
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public Object refreshCustomerCenter(d dVar) {
        Object objLoadCustomerCenter = loadCustomerCenter(true, dVar);
        return objLoadCustomerCenter == B4.a.f492a ? objLoadCustomerCenter : C3137A.f25453a;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void refreshStateIfLocaleChanged() {
        g currentLocaleList = getCurrentLocaleList();
        if (o.c(((c0) this._lastLocaleList).getValue(), currentLocaleList)) {
            return;
        }
        ((c0) this._lastLocaleList).j(currentLocaleList);
    }

    /* JADX WARN: Code restructure failed: missing block: B:46:0x00d6, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:47:0x00d7, code lost:
    
        r2 = r23;
     */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object restorePurchases(d dVar) {
        C16621 c16621;
        c0 c0Var;
        Object value;
        Object objCopy$default;
        CustomerCenterViewModelImpl customerCenterViewModelImpl;
        c0 c0Var2;
        Object value2;
        Object objCopy$default2;
        c0 c0Var3;
        Object value3;
        Object objCopy$default3;
        if (dVar instanceof C16621) {
            c16621 = (C16621) dVar;
            int i6 = c16621.label;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c16621.label = i6 - Integer.MIN_VALUE;
            } else {
                c16621 = new C16621(dVar);
            }
        }
        Object objAwaitRestore = c16621.result;
        B4.a aVar = B4.a.f492a;
        int i7 = c16621.label;
        boolean z6 = true;
        if (i7 == 0) {
            AbstractC2467b.l(objAwaitRestore);
            notifyListenersForRestoreStarted();
            H h5 = this._state;
            do {
                c0Var = (c0) h5;
                value = c0Var.getValue();
                objCopy$default = (CustomerCenterState) value;
                if (objCopy$default instanceof CustomerCenterState.Success) {
                    objCopy$default = CustomerCenterState.Success.copy$default((CustomerCenterState.Success) objCopy$default, null, null, null, null, RestorePurchasesState.RESTORING, null, null, null, null, false, false, 2031, null);
                }
            } while (!c0Var.i(value, objCopy$default));
            PurchasesType purchasesType = this.purchases;
            c16621.L$0 = this;
            c16621.label = 1;
            objAwaitRestore = purchasesType.awaitRestore(c16621);
            if (objAwaitRestore == aVar) {
                return aVar;
            }
            customerCenterViewModelImpl = this;
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            customerCenterViewModelImpl = (CustomerCenterViewModelImpl) c16621.L$0;
            try {
                AbstractC2467b.l(objAwaitRestore);
            } catch (PurchasesException e6) {
                e = e6;
                Logger.INSTANCE.e("Error restoring purchases", e);
                customerCenterViewModelImpl.notifyListenersForRestoreFailed(e.getError());
                H h6 = customerCenterViewModelImpl._state;
                do {
                    c0Var2 = (c0) h6;
                    value2 = c0Var2.getValue();
                    objCopy$default2 = (CustomerCenterState) value2;
                    if (objCopy$default2 instanceof CustomerCenterState.Success) {
                        objCopy$default2 = CustomerCenterState.Success.copy$default((CustomerCenterState.Success) objCopy$default2, null, null, null, null, RestorePurchasesState.PURCHASES_NOT_FOUND, null, null, null, null, false, false, 2031, null);
                    }
                } while (!c0Var2.i(value2, objCopy$default2));
            }
        }
        CustomerInfo customerInfo = (CustomerInfo) objAwaitRestore;
        if (customerInfo.getActiveSubscriptions().isEmpty() && customerInfo.getNonSubscriptionTransactions().isEmpty()) {
            z6 = false;
        }
        customerCenterViewModelImpl.notifyListenersForRestoreCompleted(customerInfo);
        H h7 = customerCenterViewModelImpl._state;
        do {
            c0Var3 = (c0) h7;
            value3 = c0Var3.getValue();
            objCopy$default3 = (CustomerCenterState) value3;
            if (objCopy$default3 instanceof CustomerCenterState.Success) {
                objCopy$default3 = CustomerCenterState.Success.copy$default((CustomerCenterState.Success) objCopy$default3, null, null, null, null, z6 ? RestorePurchasesState.PURCHASES_RECOVERED : RestorePurchasesState.PURCHASES_NOT_FOUND, null, null, null, null, false, false, 2031, null);
            }
        } while (!c0Var3.i(value3, objCopy$default3));
        return C3137A.f25453a;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void selectPurchase(PurchaseInformation purchase) {
        c0 c0Var;
        Object value;
        Object error;
        o.h(purchase, "purchase");
        H h5 = this._state;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            error = (CustomerCenterState) value;
            if (error instanceof CustomerCenterState.Success) {
                CustomerCenterState.Success success = (CustomerCenterState.Success) error;
                CustomerCenterConfigData.Screen managementScreen = success.getCustomerCenterConfigData().getManagementScreen();
                if (managementScreen != null) {
                    error = CustomerCenterState.Success.copy$default(success, null, null, null, PathUtils.INSTANCE.filterSubscriptionSpecificPaths(supportedPaths(purchase, managementScreen, success.getCustomerCenterConfigData().getLocalization())), null, null, success.getNavigationState().push(new CustomerCenterDestination.SelectedPurchaseDetail(purchase, managementScreen.getTitle())), CustomerCenterState.NavigationButtonType.BACK, null, false, false, 1847, null);
                } else {
                    Logger.INSTANCE.e("No management screen available in the customer center config data");
                    error = new CustomerCenterState.Error(new PurchasesError(PurchasesErrorCode.UnknownError, "No management screen available in the customer center config data"));
                }
            }
        } while (!c0Var.i(value, error));
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void showCreateSupportTicket() {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        CustomerCenterState customerCenterState = (CustomerCenterState) ((c0) this._state).getValue();
        if (customerCenterState instanceof CustomerCenterState.Success) {
            H h5 = this._state;
            do {
                c0Var = (c0) h5;
                value = c0Var.getValue();
                objCopy$default = (CustomerCenterState) value;
                if (objCopy$default instanceof CustomerCenterState.Success) {
                    CustomerCenterState.Success success = (CustomerCenterState.Success) objCopy$default;
                    objCopy$default = CustomerCenterState.Success.copy$default(success, null, null, null, null, null, null, success.getNavigationState().push(new CustomerCenterDestination.CreateSupportTicket(new CreateSupportTicketData(new CustomerCenterViewModelImpl$showCreateSupportTicket$1$createSupportTicketDestination$1(this), new CustomerCenterViewModelImpl$showCreateSupportTicket$1$createSupportTicketDestination$2(this), new CustomerCenterViewModelImpl$showCreateSupportTicket$1$createSupportTicketDestination$3(this)), ((CustomerCenterState.Success) customerCenterState).getCustomerCenterConfigData().getLocalization().commonLocalizedString(CustomerCenterConfigData.Localization.CommonLocalizedString.SUPPORT_TICKET_CREATE))), CustomerCenterState.NavigationButtonType.BACK, null, false, false, 1855, null);
                }
            } while (!c0Var.i(value, objCopy$default));
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void showPaywall(Context context) {
        o.h(context, "context");
        CustomerCenterState customerCenterState = (CustomerCenterState) ((c0) this._state).getValue();
        if (customerCenterState instanceof CustomerCenterState.Success) {
            Offering noActiveScreenOffering = ((CustomerCenterState.Success) customerCenterState).getNoActiveScreenOffering();
            if (noActiveScreenOffering != null) {
                launchPaywallActivity(context, noActiveScreenOffering);
            } else {
                tryFallbackToCurrentOffering(context);
            }
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void showVirtualCurrencyBalances() {
        c0 c0Var;
        Object value;
        Object objCopy$default;
        CustomerCenterState customerCenterState = (CustomerCenterState) ((c0) this._state).getValue();
        if (customerCenterState instanceof CustomerCenterState.Success) {
            CustomerCenterState.Success success = (CustomerCenterState.Success) customerCenterState;
            if (o.c(success.getCustomerCenterConfigData().getSupport().getDisplayVirtualCurrencies(), Boolean.TRUE)) {
                H h5 = this._state;
                do {
                    c0Var = (c0) h5;
                    value = c0Var.getValue();
                    objCopy$default = (CustomerCenterState) value;
                    if (objCopy$default instanceof CustomerCenterState.Success) {
                        CustomerCenterState.Success success2 = (CustomerCenterState.Success) objCopy$default;
                        objCopy$default = CustomerCenterState.Success.copy$default(success2, null, null, null, null, null, null, success2.getNavigationState().push(new CustomerCenterDestination.VirtualCurrencyBalances(success.getCustomerCenterConfigData().getLocalization().commonLocalizedString(CustomerCenterConfigData.Localization.CommonLocalizedString.VIRTUAL_CURRENCY_BALANCES_SCREEN_HEADER))), CustomerCenterState.NavigationButtonType.BACK, null, false, false, 1855, null);
                    }
                } while (!c0Var.i(value, objCopy$default));
            }
        }
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel
    public void trackImpressionIfNeeded() {
        if (this.impressionCreationData == null) {
            this.impressionCreationData = new CustomerCenterImpressionEvent.CreationData(null, null, 3, null);
            Locale localeA = ((g) ((c0) this._lastLocaleList).getValue()).a(0);
            if (localeA == null) {
                localeA = Locale.getDefault();
            }
            Date date = new Date();
            boolean z6 = this.isDarkMode;
            String string = localeA.toString();
            o.g(string, "locale.toString()");
            this.purchases.track(new CustomerCenterImpressionEvent(null, new CustomerCenterImpressionEvent.Data(date, z6, string, 0, 0, null, 56, null), 1, null));
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /*  JADX ERROR: NullPointerException in pass: ConstructorVisitor
        java.lang.NullPointerException: Cannot invoke "jadx.core.dex.instructions.args.RegisterArg.sameRegAndSVar(jadx.core.dex.instructions.args.InsnArg)" because "resultArg" is null
        	at jadx.core.dex.visitors.MoveInlineVisitor.processMove(MoveInlineVisitor.java:52)
        	at jadx.core.dex.visitors.MoveInlineVisitor.moveInline(MoveInlineVisitor.java:41)
        	at jadx.core.dex.visitors.ConstructorVisitor.visit(ConstructorVisitor.java:43)
        */
    public final java.lang.Object loadCustomerCenter(
    /*  JADX ERROR: Method generation error
        jadx.core.utils.exceptions.JadxRuntimeException: Code variable not set in r30v0 ??
        	at jadx.core.dex.instructions.args.SSAVar.getCodeVar(SSAVar.java:236)
        	at jadx.core.codegen.MethodGen.addMethodArguments(MethodGen.java:224)
        	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:169)
        	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:407)
        	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:337)
        	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:303)
        	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
        	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:261)
        */
    /*  JADX ERROR: NullPointerException in pass: ConstructorVisitor
        java.lang.NullPointerException: Cannot invoke "jadx.core.dex.instructions.args.RegisterArg.sameRegAndSVar(jadx.core.dex.instructions.args.InsnArg)" because "resultArg" is null
        	at jadx.core.dex.visitors.MoveInlineVisitor.processMove(MoveInlineVisitor.java:52)
        	at jadx.core.dex.visitors.MoveInlineVisitor.moveInline(MoveInlineVisitor.java:41)
        */

    public CustomerCenterViewModelImpl(PurchasesType purchases, DateFormatter dateFormatter, Locale locale, I colorScheme, boolean z6, CustomerCenterListener customerCenterListener) {
        o.h(purchases, "purchases");
        o.h(dateFormatter, "dateFormatter");
        o.h(locale, "locale");
        o.h(colorScheme, "colorScheme");
        this.purchases = purchases;
        this.dateFormatter = dateFormatter;
        this.locale = locale;
        this.colorScheme = colorScheme;
        this.isDarkMode = z6;
        this.listener = customerCenterListener;
        this._lastLocaleList = O.c(getCurrentLocaleList());
        this._colorScheme = O.c(colorScheme);
        c0 c0VarC = O.c(CustomerCenterState.NotLoaded.INSTANCE);
        this._state = c0VarC;
        this.state = O.o(new C0851q(new CustomerCenterViewModelImpl$state$1(this, null), c0VarC), X.h(this), S.a(2), CustomerCenterState.Loading.INSTANCE);
        this._actionError = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(null, null, 2, null);
    }
}
