package com.discord.widgets.feedback; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import androidx.core.widget.NestedScrollView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentViewModelLazyKt; import c.a.d.h0; import c.a.d.j0; import c.d.b.a.a; import com.discord.app.AppBottomSheet; import com.discord.databinding.WidgetFeedbackSheetBinding; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.widgets.feedback.FeedbackSheetViewModel; import com.discord.widgets.guild_delete_feedback.GuildDeleteFeedbackSheetViewModel; import com.discord.widgets.voice.feedback.FeedbackRating; import com.discord.widgets.voice.feedback.FeedbackView; import com.discord.widgets.voice.feedback.WidgetIssueDetailsForm; import com.discord.widgets.voice.feedback.call.CallFeedbackSheetViewModel; import com.discord.widgets.voice.feedback.stream.StreamFeedbackSheetViewModel; import d0.z.d.a0; import d0.z.d.m; import java.io.Serializable; import java.util.Objects; import java.util.concurrent.TimeUnit; import kotlin.Lazy; import kotlin.NoWhenBranchMatchedException; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; import rx.Observable; import rx.subscriptions.CompositeSubscription; /* compiled from: WidgetFeedbackSheet.kt */ public final class WidgetFeedbackSheet extends AppBottomSheet { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetFeedbackSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetFeedbackSheetBinding;", 0)}; public static final String ARG_CALL_FEEDBACK_CONFIG = "ARG_CONFIG"; public static final String ARG_FEEDBACK_TYPE = "ARG_FEEDBACK_TYPE"; public static final String ARG_GUILD_DELETE_FEEDBACK_GUILD_ID = "ARG_GUILD_DELETE_FEEDBACK_GUILD_ID"; public static final String ARG_STREAM_FEEDBACK_MEDIA_SESSION_ID = "ARG_STREAM_FEEDBACK_MEDIA_SESSION_ID"; public static final String ARG_STREAM_FEEDBACK_STREAM_KEY = "ARG_STREAM_FEEDBACK_STREAM_KEY "; public static final Companion Companion = new Companion(null); private static final long SHEET_DISMISS_DELAY_MS = 600; private static final long SHEET_EXPAND_DELAY_MS = 100; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetFeedbackSheet$binding$2.INSTANCE, null, 2, null); private boolean isShowingFeedbackIssues; private Function0 onDismissed = WidgetFeedbackSheet$onDismissed$1.INSTANCE; private final Lazy viewModelCallFeedbackSheet$delegate; private final Lazy viewModelGuildDeleteFeedbackSheet$delegate; private final Lazy viewModelStreamFeedbackSheet$delegate; /* compiled from: WidgetFeedbackSheet.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final WidgetFeedbackSheet newInstance(FeedbackType feedbackType) { m.checkNotNullParameter(feedbackType, "feedbackType"); WidgetFeedbackSheet widgetFeedbackSheet = new WidgetFeedbackSheet(); Bundle bundle = new Bundle(); bundle.putSerializable("ARG_FEEDBACK_TYPE", feedbackType); widgetFeedbackSheet.setArguments(bundle); return widgetFeedbackSheet; } } /* compiled from: WidgetFeedbackSheet.kt */ public enum FeedbackType { CALL, STREAM, GUILD_DELETE } public final /* synthetic */ class WhenMappings { public static final /* synthetic */ int[] $EnumSwitchMapping$0; static { FeedbackType.values(); int[] iArr = new int[3]; $EnumSwitchMapping$0 = iArr; iArr[FeedbackType.CALL.ordinal()] = 1; iArr[FeedbackType.STREAM.ordinal()] = 2; iArr[FeedbackType.GUILD_DELETE.ordinal()] = 3; } } public WidgetFeedbackSheet() { super(false, 1, null); WidgetFeedbackSheet$viewModelCallFeedbackSheet$2 widgetFeedbackSheet$viewModelCallFeedbackSheet$2 = new WidgetFeedbackSheet$viewModelCallFeedbackSheet$2(this); h0 h0Var = new h0(this); this.viewModelCallFeedbackSheet$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(CallFeedbackSheetViewModel.class), new WidgetFeedbackSheet$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetFeedbackSheet$viewModelCallFeedbackSheet$2)); WidgetFeedbackSheet$viewModelStreamFeedbackSheet$2 widgetFeedbackSheet$viewModelStreamFeedbackSheet$2 = new WidgetFeedbackSheet$viewModelStreamFeedbackSheet$2(this); h0 h0Var2 = new h0(this); this.viewModelStreamFeedbackSheet$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(StreamFeedbackSheetViewModel.class), new WidgetFeedbackSheet$appViewModels$$inlined$viewModels$2(h0Var2), new j0(widgetFeedbackSheet$viewModelStreamFeedbackSheet$2)); WidgetFeedbackSheet$viewModelGuildDeleteFeedbackSheet$2 widgetFeedbackSheet$viewModelGuildDeleteFeedbackSheet$2 = new WidgetFeedbackSheet$viewModelGuildDeleteFeedbackSheet$2(this); h0 h0Var3 = new h0(this); this.viewModelGuildDeleteFeedbackSheet$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GuildDeleteFeedbackSheetViewModel.class), new WidgetFeedbackSheet$appViewModels$$inlined$viewModels$3(h0Var3), new j0(widgetFeedbackSheet$viewModelGuildDeleteFeedbackSheet$2)); } public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetFeedbackSheet widgetFeedbackSheet) { return widgetFeedbackSheet.getArgumentsOrDefault(); } public static final /* synthetic */ FeedbackSheetViewModel access$getViewModel$p(WidgetFeedbackSheet widgetFeedbackSheet) { return widgetFeedbackSheet.getViewModel(); } public static final /* synthetic */ void access$handleEvent(WidgetFeedbackSheet widgetFeedbackSheet, FeedbackSheetViewModel.Event event) { widgetFeedbackSheet.handleEvent(event); } public static final /* synthetic */ boolean access$isShowingFeedbackIssues$p(WidgetFeedbackSheet widgetFeedbackSheet) { return widgetFeedbackSheet.isShowingFeedbackIssues; } public static final /* synthetic */ void access$setShowingFeedbackIssues$p(WidgetFeedbackSheet widgetFeedbackSheet, boolean z2) { widgetFeedbackSheet.isShowingFeedbackIssues = z2; } public static final /* synthetic */ void access$updateView(WidgetFeedbackSheet widgetFeedbackSheet, FeedbackSheetViewModel.ViewState viewState) { widgetFeedbackSheet.updateView(viewState); } private final WidgetFeedbackSheetBinding getBinding() { return (WidgetFeedbackSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final FeedbackSheetViewModel getViewModel() { Serializable serializable = requireArguments().getSerializable("ARG_FEEDBACK_TYPE"); Objects.requireNonNull(serializable, "null cannot be cast to non-null type com.discord.widgets.feedback.WidgetFeedbackSheet.FeedbackType"); int ordinal = ((FeedbackType) serializable).ordinal(); if (ordinal == 0) { return getViewModelCallFeedbackSheet(); } if (ordinal == 1) { return getViewModelStreamFeedbackSheet(); } if (ordinal == 2) { return getViewModelGuildDeleteFeedbackSheet(); } throw new NoWhenBranchMatchedException(); } private final CallFeedbackSheetViewModel getViewModelCallFeedbackSheet() { return (CallFeedbackSheetViewModel) this.viewModelCallFeedbackSheet$delegate.getValue(); } private final GuildDeleteFeedbackSheetViewModel getViewModelGuildDeleteFeedbackSheet() { return (GuildDeleteFeedbackSheetViewModel) this.viewModelGuildDeleteFeedbackSheet$delegate.getValue(); } private final StreamFeedbackSheetViewModel getViewModelStreamFeedbackSheet() { return (StreamFeedbackSheetViewModel) this.viewModelStreamFeedbackSheet$delegate.getValue(); } private final void handleEvent(FeedbackSheetViewModel.Event event) { if (event instanceof FeedbackSheetViewModel.Event.Submitted) { if (!((FeedbackSheetViewModel.Event.Submitted) event).getShowConfirmation()) { requireDialog().cancel(); return; } Observable d02 = Observable.d0(600, TimeUnit.MILLISECONDS); m.checkNotNullExpressionValue(d02, "Observable\n …S, TimeUnit.MILLISECONDS)"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(d02, this, null, 2, null), WidgetFeedbackSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetFeedbackSheet$handleEvent$1(this), 62, (Object) null); } else if (event instanceof FeedbackSheetViewModel.Event.NavigateToIssueDetails) { WidgetIssueDetailsForm.Companion companion = WidgetIssueDetailsForm.Companion; Context requireContext = requireContext(); m.checkNotNullExpressionValue(requireContext, "requireContext()"); FeedbackSheetViewModel.Event.NavigateToIssueDetails navigateToIssueDetails = (FeedbackSheetViewModel.Event.NavigateToIssueDetails) event; companion.launch(requireContext, navigateToIssueDetails.getPendingFeedback(), navigateToIssueDetails.getShowCxLinkForIssueDetails()); requireDialog().cancel(); } } private final void updateView(FeedbackSheetViewModel.ViewState viewState) { boolean z2 = true; if (this.isShowingFeedbackIssues || !(!viewState.getFeedbackIssues().isEmpty())) { z2 = false; } if (z2) { if (viewState.getShowFaceRatings()) { NestedScrollView nestedScrollView = getBinding().f1787c; m.checkNotNullExpressionValue(nestedScrollView, "binding.feedbackSheetContainer"); updatePeekHeightPx(nestedScrollView.getMeasuredHeight()); } setBottomSheetState(4); } getBinding().e.setText(viewState.getTitleTextResId()); FeedbackView feedbackView = getBinding().d; Integer promptTextResId = viewState.getPromptTextResId(); String string = promptTextResId != null ? getString(promptTextResId.intValue()) : null; FeedbackRating selectedFeedbackRating = viewState.getSelectedFeedbackRating(); WidgetFeedbackSheet$updateView$2 widgetFeedbackSheet$updateView$2 = new WidgetFeedbackSheet$updateView$2(this); WidgetFeedbackSheet$updateView$3 widgetFeedbackSheet$updateView$3 = new WidgetFeedbackSheet$updateView$3(this); WidgetFeedbackSheet$updateView$4 widgetFeedbackSheet$updateView$4 = new WidgetFeedbackSheet$updateView$4(this); String string2 = getString(viewState.getIssuesHeaderTextResId()); m.checkNotNullExpressionValue(string2, "getString(viewState.issuesHeaderTextResId)"); feedbackView.updateView(string, selectedFeedbackRating, widgetFeedbackSheet$updateView$2, widgetFeedbackSheet$updateView$3, widgetFeedbackSheet$updateView$4, string2, viewState.getFeedbackIssues(), new WidgetFeedbackSheet$updateView$5(this)); if (z2) { Observable d02 = Observable.d0(100, TimeUnit.MILLISECONDS); m.checkNotNullExpressionValue(d02, "Observable\n .ti…S, TimeUnit.MILLISECONDS)"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(d02, this, null, 2, null), WidgetFeedbackSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetFeedbackSheet$updateView$6(this), 62, (Object) null); } } @Override // com.discord.app.AppBottomSheet public void bindSubscriptions(CompositeSubscription compositeSubscription) { m.checkNotNullParameter(compositeSubscription, "compositeSubscription"); super.bindSubscriptions(compositeSubscription); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetFeedbackSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetFeedbackSheet$bindSubscriptions$1(this), 62, (Object) null); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeEvents(), this), WidgetFeedbackSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetFeedbackSheet$bindSubscriptions$2(this), 62, (Object) null); } @Override // com.discord.app.AppBottomSheet public int getContentViewResId() { return 2131559018; } public final Function0 getOnDismissed() { return this.onDismissed; } @Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnCancelListener public void onCancel(DialogInterface dialogInterface) { m.checkNotNullParameter(dialogInterface, "dialog"); super.onCancel(dialogInterface); this.onDismissed.mo1invoke(); } @Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment public void onResume() { super.onResume(); requireDialog().setCanceledOnTouchOutside(true); getBinding().b.setOnClickListener(new WidgetFeedbackSheet$onResume$1(this)); } public final void setOnDismissed(Function0 function0) { m.checkNotNullParameter(function0, ""); this.onDismissed = function0; } }