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

import A4.d;
import C4.e;
import C4.j;
import J4.c;
import V4.C;
import V4.E;
import android.app.Activity;
import android.content.Context;
import androidx.media3.extractor.ts.TsExtractor;
import com.revenuecat.purchases.models.SubscriptionOption;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.actions.CustomerCenterAction;
import com.revenuecat.purchases.ui.revenuecatui.customercenter.viewmodel.CustomerCenterViewModel;
import com.revenuecat.purchases.ui.revenuecatui.helpers.ContextExtensionsKt;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes3.dex */
public final class InternalCustomerCenterKt$InternalCustomerCenter$7$1 extends p implements c {
    final /* synthetic */ Context $context;
    final /* synthetic */ C $coroutineScope;
    final /* synthetic */ J4.a $onDismiss;
    final /* synthetic */ CustomerCenterViewModel $viewModel;

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.customercenter.InternalCustomerCenterKt$InternalCustomerCenter$7$1$1, reason: invalid class name */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.InternalCustomerCenterKt$InternalCustomerCenter$7$1$1", f = "InternalCustomerCenter.kt", l = {167}, m = "invokeSuspend")
    public static final class AnonymousClass1 extends j implements J4.e {
        final /* synthetic */ CustomerCenterViewModel $viewModel;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass1(CustomerCenterViewModel customerCenterViewModel, d dVar) {
            super(2, dVar);
            this.$viewModel = customerCenterViewModel;
        }

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

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((AnonymousClass1) 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);
                CustomerCenterViewModel customerCenterViewModel = this.$viewModel;
                this.label = 1;
                if (customerCenterViewModel.restorePurchases(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.InternalCustomerCenterKt$InternalCustomerCenter$7$1$2, reason: invalid class name */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.InternalCustomerCenterKt$InternalCustomerCenter$7$1$2", f = "InternalCustomerCenter.kt", l = {173}, m = "invokeSuspend")
    public static final class AnonymousClass2 extends j implements J4.e {
        final /* synthetic */ CustomerCenterViewModel $viewModel;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass2(CustomerCenterViewModel customerCenterViewModel, d dVar) {
            super(2, dVar);
            this.$viewModel = customerCenterViewModel;
        }

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

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((AnonymousClass2) 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);
                CustomerCenterViewModel customerCenterViewModel = this.$viewModel;
                this.label = 1;
                if (customerCenterViewModel.dismissRestoreDialog(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.InternalCustomerCenterKt$InternalCustomerCenter$7$1$3, reason: invalid class name */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.customercenter.InternalCustomerCenterKt$InternalCustomerCenter$7$1$3", f = "InternalCustomerCenter.kt", l = {TsExtractor.TS_PACKET_SIZE}, m = "invokeSuspend")
    public static final class AnonymousClass3 extends j implements J4.e {
        final /* synthetic */ CustomerCenterAction $action;
        final /* synthetic */ Activity $activity;
        final /* synthetic */ CustomerCenterViewModel $viewModel;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass3(CustomerCenterViewModel customerCenterViewModel, CustomerCenterAction customerCenterAction, Activity activity, d dVar) {
            super(2, dVar);
            this.$viewModel = customerCenterViewModel;
            this.$action = customerCenterAction;
            this.$activity = activity;
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            return new AnonymousClass3(this.$viewModel, this.$action, this.$activity, dVar);
        }

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((AnonymousClass3) 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);
                CustomerCenterViewModel customerCenterViewModel = this.$viewModel;
                SubscriptionOption subscriptionOption = ((CustomerCenterAction.PurchasePromotionalOffer) this.$action).getSubscriptionOption();
                Activity activity = this.$activity;
                this.label = 1;
                if (customerCenterViewModel.onAcceptedPromotionalOffer(subscriptionOption, activity, 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 WARN: 'super' call moved to the top of the method (can break code semantics) */
    public InternalCustomerCenterKt$InternalCustomerCenter$7$1(CustomerCenterViewModel customerCenterViewModel, Context context, C c6, J4.a aVar) {
        super(1);
        this.$viewModel = customerCenterViewModel;
        this.$context = context;
        this.$coroutineScope = c6;
        this.$onDismiss = aVar;
    }

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

    public final void invoke(CustomerCenterAction action) {
        o.h(action, "action");
        if (action instanceof CustomerCenterAction.PathButtonPressed) {
            CustomerCenterAction.PathButtonPressed pathButtonPressed = (CustomerCenterAction.PathButtonPressed) action;
            this.$viewModel.pathButtonPressed(this.$context, pathButtonPressed.getPath(), pathButtonPressed.getPurchaseInformation());
            return;
        }
        if (action instanceof CustomerCenterAction.PerformRestore) {
            E.y(this.$coroutineScope, null, null, new AnonymousClass1(this.$viewModel, null), 3);
            return;
        }
        if (action instanceof CustomerCenterAction.DismissRestoreDialog) {
            E.y(this.$coroutineScope, null, null, new AnonymousClass2(this.$viewModel, null), 3);
            return;
        }
        if (action instanceof CustomerCenterAction.ContactSupport) {
            this.$viewModel.contactSupport(this.$context, ((CustomerCenterAction.ContactSupport) action).getEmail());
            return;
        }
        if (action instanceof CustomerCenterAction.OpenURL) {
            CustomerCenterViewModel.DefaultImpls.openURL$default(this.$viewModel, this.$context, ((CustomerCenterAction.OpenURL) action).getUrl(), null, 4, null);
            return;
        }
        if (action instanceof CustomerCenterAction.NavigationButtonPressed) {
            this.$viewModel.onNavigationButtonPressed(this.$context, this.$onDismiss);
            return;
        }
        if (action instanceof CustomerCenterAction.DismissPromotionalOffer) {
            this.$viewModel.dismissPromotionalOffer(this.$context, ((CustomerCenterAction.DismissPromotionalOffer) action).getOriginalPath());
            return;
        }
        if (action instanceof CustomerCenterAction.PurchasePromotionalOffer) {
            E.y(this.$coroutineScope, null, null, new AnonymousClass3(this.$viewModel, action, ContextExtensionsKt.getActivity(this.$context), null), 3);
            return;
        }
        if (action instanceof CustomerCenterAction.CustomActionSelected) {
            this.$viewModel.onCustomActionSelected(((CustomerCenterAction.CustomActionSelected) action).getCustomActionData());
            return;
        }
        if (action instanceof CustomerCenterAction.SelectPurchase) {
            this.$viewModel.selectPurchase(((CustomerCenterAction.SelectPurchase) action).getPurchase());
            return;
        }
        if (action instanceof CustomerCenterAction.ShowPaywall) {
            this.$viewModel.showPaywall(this.$context);
            return;
        }
        if (action instanceof CustomerCenterAction.ShowVirtualCurrencyBalances) {
            this.$viewModel.showVirtualCurrencyBalances();
        } else if (action instanceof CustomerCenterAction.ShowSupportTicketCreation) {
            this.$viewModel.showCreateSupportTicket();
        } else if (action instanceof CustomerCenterAction.DismissSupportTicketSuccessSnackbar) {
            this.$viewModel.dismissSupportTicketSuccessSnackbar();
        }
    }
}
