discord-jadx/app/src/main/java/com/discord/widgets/chat/input/WidgetChatInputAutocomplete...

936 lines
57 KiB
Java

package com.discord.widgets.chat.input;
import android.content.Context;
import android.text.Editable;
import android.text.Spannable;
import android.text.style.CharacterStyle;
import android.text.style.MetricAffectingSpan;
import android.text.style.ReplacementSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.MainThread;
import androidx.recyclerview.widget.RecyclerView;
import c.d.b.a.a;
import com.discord.api.channel.Channel;
import com.discord.api.role.GuildRole;
import com.discord.api.sticker.Sticker;
import com.discord.app.AppFragment;
import com.discord.databinding.WidgetChatInputApplicationCommandsBinding;
import com.discord.models.commands.Application;
import com.discord.models.commands.ApplicationCommand;
import com.discord.models.commands.ApplicationCommandOption;
import com.discord.models.experiments.domain.Experiment;
import com.discord.stores.StoreGuilds;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUserSettings;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.guilds.RoleUtils;
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
import com.discord.utilities.recycler.SelfHealingLinearLayoutManager;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
import com.discord.utilities.textprocessing.FontColorSpan;
import com.discord.utilities.textprocessing.SimpleRoundedBackgroundSpan;
import com.discord.widgets.chat.MessageContent;
import com.discord.widgets.chat.MessageManager;
import com.discord.widgets.chat.input.applicationcommands.WidgetChatInputApplicationCommands;
import com.discord.widgets.chat.input.applicationcommands.WidgetChatInputApplicationCommandsKt;
import com.discord.widgets.chat.input.applicationcommands.WidgetChatInputModelMappingFunctions;
import com.discord.widgets.chat.input.applicationcommands.WidgetChatInputModelMappingFunctionsKt;
import com.discord.widgets.chat.input.autocomplete.ApplicationCommandAutocompletable;
import com.discord.widgets.chat.input.autocomplete.Autocompletable;
import com.discord.widgets.chat.input.autocomplete.ChatInputAutocompletables;
import com.discord.widgets.chat.input.autocomplete.EmojiAutocompletable;
import com.discord.widgets.chat.input.autocomplete.LeadingIdentifier;
import com.discord.widgets.chat.input.autocomplete.RoleAutocompletable;
import com.discord.widgets.chat.input.autocomplete.UserAutocompletable;
import com.discord.widgets.chat.input.autocomplete.adapter.ChatInputAutocompleteAdapter;
import com.discord.widgets.chat.input.emoji.EmojiAutocompletePremiumUpsellFeatureFlag;
import com.discord.widgets.chat.input.models.ApplicationCommandData;
import com.discord.widgets.chat.input.models.AutocompleteApplicationCommands;
import com.discord.widgets.chat.input.models.AutocompleteInputCommandContext;
import com.discord.widgets.chat.input.models.AutocompleteInputModel;
import com.discord.widgets.chat.input.models.AutocompleteInputSelectionModel;
import com.discord.widgets.chat.input.models.ChatInputMentionsMap;
import com.discord.widgets.chat.input.models.CommandOptionValue;
import com.discord.widgets.chat.input.models.InputCommandOptions;
import com.discord.widgets.chat.input.models.InputSelectionModel;
import com.discord.widgets.chat.input.models.OptionRange;
import com.discord.widgets.chat.input.models.VerifiedCommandMentionInputModel;
import com.lytefast.flexinput.widget.FlexEditText;
import d0.g0.w;
import d0.t.h0;
import d0.t.n;
import d0.t.t;
import d0.t.u;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.ranges.IntRange;
import rx.Observable;
import rx.subjects.BehaviorSubject;
/* compiled from: WidgetChatInputAutocomplete.kt */
public final class WidgetChatInputAutocomplete {
public static final Companion Companion = new Companion(null);
private static final int DEFAULT_PLACEHOLDER_COUNT = 3;
private final WidgetChatInputApplicationCommands applicationCommands;
private List<Application> applications;
private Map<Long, Integer> applicationsPosition;
private final BehaviorSubject<AutocompleteInputSelectionModel> autocompleteInputSelectionModelSubject;
private WidgetChatInputCategoriesAdapter categoriesAdapter;
private String currentInput;
private WidgetChatInputDiscoveryCommandsModel discoveryCommands;
private final FlexEditText editText;
private final TextView emojiHeader;
private final Function1<Autocompletable, Boolean> handleAutocompleteItemClicked;
private boolean hideMentionsInLandscape;
private final BehaviorSubject<VerifiedCommandMentionInputModel> inputMentionModelSubject;
private final BehaviorSubject<IntRange> inputSelectionSubject;
private InputSelectionModel lastChatInputModel;
private Integer lastJumpedSequenceId;
private String lastToken;
private Map<LeadingIdentifier, ? extends Set<? extends Autocompletable>> mentions;
private ChatInputAutocompleteAdapter mentionsAdapter;
private final RecyclerView mentionsRecycler;
private final Function0<Unit> onAutocompletionsUpdated;
private final Function2<Integer, Integer, Unit> onScrollVisibleDiscoveryCommands;
private final Function2<Integer, Integer, Unit> onScrollVisibleMentions;
private List<? extends ApplicationCommand> queryCommands;
private Long selectedCommandApplicationId;
private WidgetChatInputAutocompleteStickerAdapter stickersAdapter;
private final View stickersContainer;
private final TextView stickersHeader;
private UserAndSelectedGuildRoles userAndRoles;
/* compiled from: WidgetChatInputAutocomplete.kt */
/* renamed from: com.discord.widgets.chat.input.WidgetChatInputAutocomplete$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<Autocompletable, Boolean> {
public static final AnonymousClass1 INSTANCE = new AnonymousClass1();
public AnonymousClass1() {
super(1);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Boolean invoke(Autocompletable autocompletable) {
return Boolean.valueOf(invoke(autocompletable));
}
public final boolean invoke(Autocompletable autocompletable) {
m.checkNotNullParameter(autocompletable, "it");
return false;
}
}
/* compiled from: WidgetChatInputAutocomplete.kt */
/* renamed from: com.discord.widgets.chat.input.WidgetChatInputAutocomplete$2 reason: invalid class name */
public static final class AnonymousClass2 extends o implements Function0<Unit> {
public static final AnonymousClass2 INSTANCE = new AnonymousClass2();
public AnonymousClass2() {
super(0);
}
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public final void mo1invoke() {
}
}
/* compiled from: WidgetChatInputAutocomplete.kt */
/* renamed from: com.discord.widgets.chat.input.WidgetChatInputAutocomplete$3 reason: invalid class name */
public static final class AnonymousClass3 extends o implements Function1<Autocompletable, Unit> {
public final /* synthetic */ WidgetChatInputAutocomplete this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass3(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
super(1);
this.this$0 = widgetChatInputAutocomplete;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Autocompletable autocompletable) {
invoke(autocompletable);
return Unit.a;
}
public final void invoke(Autocompletable autocompletable) {
m.checkNotNullParameter(autocompletable, "it");
WidgetChatInputAutocomplete.access$onClickMentionItem(this.this$0, autocompletable);
}
}
/* compiled from: WidgetChatInputAutocomplete.kt */
/* renamed from: com.discord.widgets.chat.input.WidgetChatInputAutocomplete$4 reason: invalid class name */
public static final class AnonymousClass4 extends o implements Function1<Application, Unit> {
public final /* synthetic */ WidgetChatInputAutocomplete this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass4(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
super(1);
this.this$0 = widgetChatInputAutocomplete;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Application application) {
invoke(application);
return Unit.a;
}
public final void invoke(Application application) {
m.checkNotNullParameter(application, "application");
WidgetChatInputAutocomplete.access$onCommandCategoryClicked(this.this$0, application);
}
}
/* compiled from: WidgetChatInputAutocomplete.kt */
/* renamed from: com.discord.widgets.chat.input.WidgetChatInputAutocomplete$5 reason: invalid class name */
public static final class AnonymousClass5 extends o implements Function1<Sticker, Unit> {
public final /* synthetic */ WidgetChatInputAutocomplete this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass5(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
super(1);
this.this$0 = widgetChatInputAutocomplete;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Sticker sticker) {
invoke(sticker);
return Unit.a;
}
public final void invoke(Sticker sticker) {
m.checkNotNullParameter(sticker, "sticker");
WidgetChatInputAutocomplete.access$onClickStickerItem(this.this$0, sticker);
}
}
/* compiled from: WidgetChatInputAutocomplete.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ void access$removePillSpans(Companion companion, Spannable spannable) {
companion.removePillSpans(spannable);
}
public static final /* synthetic */ void access$removeSpans(Companion companion, Spannable spannable) {
companion.removeSpans(spannable);
}
private final void removePillSpans(Spannable spannable) {
Object[] spans = spannable.getSpans(0, spannable.length(), Object.class);
for (Object obj : spans) {
if (obj instanceof SimpleRoundedBackgroundSpan) {
spannable.removeSpan(obj);
}
}
}
private final void removeSpans(Spannable spannable) {
Object[] spans = spannable.getSpans(0, spannable.length(), Object.class);
for (Object obj : spans) {
if ((obj instanceof CharacterStyle) && !(obj instanceof SimpleRoundedBackgroundSpan)) {
spannable.removeSpan(obj);
}
}
}
}
/* JADX DEBUG: Multi-variable search result rejected for r26v0, resolved type: kotlin.jvm.functions.Function1<? super com.discord.widgets.chat.input.autocomplete.Autocompletable, java.lang.Boolean> */
/* JADX WARN: Multi-variable type inference failed */
public WidgetChatInputAutocomplete(FlexEditText flexEditText, RecyclerView recyclerView, View view, TextView textView, TextView textView2, RecyclerView recyclerView2, RecyclerView recyclerView3, WidgetChatInputApplicationCommandsBinding widgetChatInputApplicationCommandsBinding, Function1<? super Autocompletable, Boolean> function1, Function1<? super List<? extends Autocompletable>, Unit> function12, Function0<Unit> function0) {
m.checkNotNullParameter(flexEditText, "editText");
m.checkNotNullParameter(recyclerView, "stickersRecycler");
m.checkNotNullParameter(view, "stickersContainer");
m.checkNotNullParameter(textView, "stickersHeader");
m.checkNotNullParameter(textView2, "emojiHeader");
m.checkNotNullParameter(recyclerView2, "mentionsRecycler");
m.checkNotNullParameter(recyclerView3, "categoriesRecycler");
m.checkNotNullParameter(widgetChatInputApplicationCommandsBinding, "binding");
m.checkNotNullParameter(function1, "handleAutocompleteItemClicked");
m.checkNotNullParameter(function0, "onAutocompletionsUpdated");
this.editText = flexEditText;
this.stickersContainer = view;
this.stickersHeader = textView;
this.emojiHeader = textView2;
this.mentionsRecycler = recyclerView2;
this.handleAutocompleteItemClicked = function1;
this.onAutocompletionsUpdated = function0;
this.applicationCommands = new WidgetChatInputApplicationCommands(flexEditText, widgetChatInputApplicationCommandsBinding);
this.inputMentionModelSubject = BehaviorSubject.k0();
this.autocompleteInputSelectionModelSubject = BehaviorSubject.k0();
this.inputSelectionSubject = BehaviorSubject.k0();
this.queryCommands = n.emptyList();
this.applications = n.emptyList();
this.mentions = h0.emptyMap();
this.userAndRoles = new UserAndSelectedGuildRoles(0, null, 3, null);
this.applicationsPosition = new HashMap();
this.onScrollVisibleMentions = new WidgetChatInputAutocomplete$onScrollVisibleMentions$1(this, function12);
this.onScrollVisibleDiscoveryCommands = new WidgetChatInputAutocomplete$onScrollVisibleDiscoveryCommands$1(this);
boolean z2 = true;
Experiment userExperiment = StoreStream.Companion.getExperiments().getUserExperiment("2020-12_android_disable_landscape_mentions", true);
this.hideMentionsInLandscape = (userExperiment == null || userExperiment.getBucket() != 1) ? false : z2;
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter = new ChatInputAutocompleteAdapter();
this.mentionsAdapter = chatInputAutocompleteAdapter;
recyclerView2.setAdapter(chatInputAutocompleteAdapter);
recyclerView2.setItemAnimator(null);
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter2 = this.mentionsAdapter;
if (chatInputAutocompleteAdapter2 == null) {
m.throwUninitializedPropertyAccessException("mentionsAdapter");
}
chatInputAutocompleteAdapter2.setOnItemSelected(new AnonymousClass3(this));
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
WidgetChatInputCategoriesAdapter widgetChatInputCategoriesAdapter = (WidgetChatInputCategoriesAdapter) companion.configure(new WidgetChatInputCategoriesAdapter(recyclerView3, new AnonymousClass4(this)));
this.categoriesAdapter = widgetChatInputCategoriesAdapter;
recyclerView3.setLayoutManager(new SelfHealingLinearLayoutManager(recyclerView3, widgetChatInputCategoriesAdapter, 0, false, 8, null));
WidgetChatInputAutocompleteStickerAdapter widgetChatInputAutocompleteStickerAdapter = (WidgetChatInputAutocompleteStickerAdapter) companion.configure(new WidgetChatInputAutocompleteStickerAdapter(recyclerView, new AnonymousClass5(this)));
this.stickersAdapter = widgetChatInputAutocompleteStickerAdapter;
recyclerView.setLayoutManager(new SelfHealingLinearLayoutManager(recyclerView, widgetChatInputAutocompleteStickerAdapter, 0, false, 8, null));
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ WidgetChatInputAutocomplete(FlexEditText flexEditText, RecyclerView recyclerView, View view, TextView textView, TextView textView2, RecyclerView recyclerView2, RecyclerView recyclerView3, WidgetChatInputApplicationCommandsBinding widgetChatInputApplicationCommandsBinding, Function1 function1, Function1 function12, Function0 function0, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(flexEditText, recyclerView, view, textView, textView2, recyclerView2, recyclerView3, widgetChatInputApplicationCommandsBinding, (i & 256) != 0 ? AnonymousClass1.INSTANCE : function1, (i & 512) != 0 ? null : function12, (i & 1024) != 0 ? AnonymousClass2.INSTANCE : function0);
}
public static final /* synthetic */ void access$applyCommandOptionSpans(WidgetChatInputAutocomplete widgetChatInputAutocomplete, VerifiedCommandMentionInputModel verifiedCommandMentionInputModel, ApplicationCommandOption applicationCommandOption, Set set) {
widgetChatInputAutocomplete.applyCommandOptionSpans(verifiedCommandMentionInputModel, applicationCommandOption, set);
}
public static final /* synthetic */ WidgetChatInputApplicationCommands access$getApplicationCommands$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.applicationCommands;
}
public static final /* synthetic */ List access$getApplications$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.applications;
}
public static final /* synthetic */ Map access$getApplicationsPosition$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.applicationsPosition;
}
public static final /* synthetic */ BehaviorSubject access$getAutocompleteInputSelectionModelSubject$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.autocompleteInputSelectionModelSubject;
}
public static final /* synthetic */ WidgetChatInputCategoriesAdapter access$getCategoriesAdapter$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.categoriesAdapter;
}
public static final /* synthetic */ WidgetChatInputDiscoveryCommandsModel access$getDiscoveryCommands$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.discoveryCommands;
}
public static final /* synthetic */ TextView access$getEmojiHeader$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.emojiHeader;
}
public static final /* synthetic */ boolean access$getHideMentionsInLandscape$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.hideMentionsInLandscape;
}
public static final /* synthetic */ InputSelectionModel access$getLastChatInputModel$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.lastChatInputModel;
}
public static final /* synthetic */ Integer access$getLastJumpedSequenceId$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.lastJumpedSequenceId;
}
public static final /* synthetic */ String access$getLastToken$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.lastToken;
}
public static final /* synthetic */ Map access$getMentions$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.mentions;
}
public static final /* synthetic */ ChatInputAutocompleteAdapter access$getMentionsAdapter$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter = widgetChatInputAutocomplete.mentionsAdapter;
if (chatInputAutocompleteAdapter == null) {
m.throwUninitializedPropertyAccessException("mentionsAdapter");
}
return chatInputAutocompleteAdapter;
}
public static final /* synthetic */ Function0 access$getOnAutocompletionsUpdated$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.onAutocompletionsUpdated;
}
public static final /* synthetic */ Function2 access$getOnScrollVisibleDiscoveryCommands$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.onScrollVisibleDiscoveryCommands;
}
public static final /* synthetic */ Function2 access$getOnScrollVisibleMentions$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.onScrollVisibleMentions;
}
public static final /* synthetic */ List access$getQueryCommands$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.queryCommands;
}
public static final /* synthetic */ Long access$getSelectedCommandApplicationId$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.selectedCommandApplicationId;
}
public static final /* synthetic */ WidgetChatInputAutocompleteStickerAdapter access$getStickersAdapter$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.stickersAdapter;
}
public static final /* synthetic */ UserAndSelectedGuildRoles access$getUserAndRoles$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
return widgetChatInputAutocomplete.userAndRoles;
}
public static final /* synthetic */ void access$handleNewCommandsRecyclerScrollPosition(WidgetChatInputAutocomplete widgetChatInputAutocomplete, int i, int i2) {
widgetChatInputAutocomplete.handleNewCommandsRecyclerScrollPosition(i, i2);
}
public static final /* synthetic */ void access$jumpToApplication(WidgetChatInputAutocomplete widgetChatInputAutocomplete, long j) {
widgetChatInputAutocomplete.jumpToApplication(j);
}
public static final /* synthetic */ void access$onClickMentionItem(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Autocompletable autocompletable) {
widgetChatInputAutocomplete.onClickMentionItem(autocompletable);
}
public static final /* synthetic */ void access$onClickStickerItem(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Sticker sticker) {
widgetChatInputAutocomplete.onClickStickerItem(sticker);
}
public static final /* synthetic */ void access$onCommandCategoryClicked(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Application application) {
widgetChatInputAutocomplete.onCommandCategoryClicked(application);
}
public static final /* synthetic */ void access$onModelUpdated(WidgetChatInputAutocomplete widgetChatInputAutocomplete) {
widgetChatInputAutocomplete.onModelUpdated();
}
public static final /* synthetic */ void access$setApplications$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, List list) {
widgetChatInputAutocomplete.applications = list;
}
public static final /* synthetic */ void access$setApplicationsPosition$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Map map) {
widgetChatInputAutocomplete.applicationsPosition = map;
}
public static final /* synthetic */ void access$setCategoriesAdapter$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, WidgetChatInputCategoriesAdapter widgetChatInputCategoriesAdapter) {
widgetChatInputAutocomplete.categoriesAdapter = widgetChatInputCategoriesAdapter;
}
public static final /* synthetic */ void access$setDiscoveryCommands$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, WidgetChatInputDiscoveryCommandsModel widgetChatInputDiscoveryCommandsModel) {
widgetChatInputAutocomplete.discoveryCommands = widgetChatInputDiscoveryCommandsModel;
}
public static final /* synthetic */ void access$setHideMentionsInLandscape$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, boolean z2) {
widgetChatInputAutocomplete.hideMentionsInLandscape = z2;
}
public static final /* synthetic */ void access$setLastChatInputModel$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, InputSelectionModel inputSelectionModel) {
widgetChatInputAutocomplete.lastChatInputModel = inputSelectionModel;
}
public static final /* synthetic */ void access$setLastJumpedSequenceId$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Integer num) {
widgetChatInputAutocomplete.lastJumpedSequenceId = num;
}
public static final /* synthetic */ void access$setLastToken$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, String str) {
widgetChatInputAutocomplete.lastToken = str;
}
public static final /* synthetic */ void access$setMentions$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Map map) {
widgetChatInputAutocomplete.mentions = map;
}
public static final /* synthetic */ void access$setMentionsAdapter$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, ChatInputAutocompleteAdapter chatInputAutocompleteAdapter) {
widgetChatInputAutocomplete.mentionsAdapter = chatInputAutocompleteAdapter;
}
public static final /* synthetic */ void access$setQueryCommands$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, List list) {
widgetChatInputAutocomplete.queryCommands = list;
}
public static final /* synthetic */ void access$setSelectedCommandApplicationId$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, Long l) {
widgetChatInputAutocomplete.selectedCommandApplicationId = l;
}
public static final /* synthetic */ void access$setStickersAdapter$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, WidgetChatInputAutocompleteStickerAdapter widgetChatInputAutocompleteStickerAdapter) {
widgetChatInputAutocomplete.stickersAdapter = widgetChatInputAutocompleteStickerAdapter;
}
public static final /* synthetic */ void access$setUserAndRoles$p(WidgetChatInputAutocomplete widgetChatInputAutocomplete, UserAndSelectedGuildRoles userAndSelectedGuildRoles) {
widgetChatInputAutocomplete.userAndRoles = userAndSelectedGuildRoles;
}
private final void applyCommandOptionSpans(VerifiedCommandMentionInputModel verifiedCommandMentionInputModel, ApplicationCommandOption applicationCommandOption, Set<ApplicationCommandOption> set) {
if (!(!m.areEqual(this.editText.getEditableText().toString(), verifiedCommandMentionInputModel.getInput()))) {
Companion companion = Companion;
Editable editableText = this.editText.getEditableText();
m.checkNotNullExpressionValue(editableText, "editText.editableText");
Companion.access$removePillSpans(companion, editableText);
for (ApplicationCommandOption applicationCommandOption2 : verifiedCommandMentionInputModel.getInputCommandOptions().getInputRanges().keySet()) {
boolean z2 = !set.contains(applicationCommandOption2);
OptionRange optionRange = verifiedCommandMentionInputModel.getInputCommandOptions().getInputRanges().get(applicationCommandOption2);
if (optionRange != null) {
int last = optionRange.getParam().getLast();
if (!m.areEqual(applicationCommandOption, applicationCommandOption2)) {
last = optionRange.getValue().getLast();
}
WidgetChatInputApplicationCommands widgetChatInputApplicationCommands = this.applicationCommands;
Editable editableText2 = this.editText.getEditableText();
m.checkNotNullExpressionValue(editableText2, "editText.editableText");
widgetChatInputApplicationCommands.applyParamSpan(editableText2, optionRange.getParam().getFirst(), last, z2);
}
}
}
}
private final void applyInputSpans(VerifiedCommandMentionInputModel verifiedCommandMentionInputModel) {
if (!(!m.areEqual(this.editText.getEditableText().toString(), verifiedCommandMentionInputModel.getInput()))) {
Companion companion = Companion;
Editable editableText = this.editText.getEditableText();
m.checkNotNullExpressionValue(editableText, "editText.editableText");
Companion.access$removeSpans(companion, editableText);
for (Map.Entry<IntRange, Autocompletable> entry : verifiedCommandMentionInputModel.getInputMentionsMap().entrySet()) {
IntRange key = entry.getKey();
Autocompletable value = entry.getValue();
if (!(value instanceof ApplicationCommandAutocompletable)) {
int themedColor = ColorCompat.getThemedColor(this.editText, 2130970174);
GuildRole guildRole = null;
if (!(value instanceof RoleAutocompletable)) {
value = null;
}
RoleAutocompletable roleAutocompletable = (RoleAutocompletable) value;
if (roleAutocompletable != null) {
guildRole = roleAutocompletable.getRole();
}
for (MetricAffectingSpan metricAffectingSpan : n.listOf((Object[]) new MetricAffectingSpan[]{new FontColorSpan(RoleUtils.getOpaqueColor(guildRole, themedColor)), new StyleSpan(1)})) {
this.editText.getEditableText().setSpan(metricAffectingSpan, key.getFirst(), key.getLast(), 33);
}
}
}
}
}
private final void handleInputModel(AutocompleteInputModel autocompleteInputModel) {
InputCommandOptions inputCommandOptions;
AutocompleteInputCommandContext inputCommandContext = this.applicationCommands.getInputCommandContext(autocompleteInputModel.getInput(), autocompleteInputModel.getApplicationCommands(), autocompleteInputModel.getMe());
WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions = WidgetChatInputModelMappingFunctions.INSTANCE;
ChatInputMentionsMap mapInputToMentions = widgetChatInputModelMappingFunctions.mapInputToMentions(autocompleteInputModel.getInput(), autocompleteInputModel.getAutocompletables(), inputCommandContext.isCommand());
ApplicationCommand selectedCommand = inputCommandContext.getSelectedCommand();
InputCommandOptions inputCommandOptions2 = new InputCommandOptions(null, null, null, 7, null);
if (selectedCommand != null) {
Map<ApplicationCommandOption, OptionRange> findOptionRanges = WidgetChatInputApplicationCommandsKt.findOptionRanges(autocompleteInputModel.getInput(), selectedCommand);
Map<ApplicationCommandOption, CommandOptionValue> parseCommandOptions = widgetChatInputModelMappingFunctions.parseCommandOptions(autocompleteInputModel.getInput(), selectedCommand, mapInputToMentions);
inputCommandOptions = new InputCommandOptions(parseCommandOptions, findOptionRanges, widgetChatInputModelMappingFunctions.getInputValidity(selectedCommand, parseCommandOptions));
} else {
inputCommandOptions = inputCommandOptions2;
}
VerifiedCommandMentionInputModel verifiedCommandMentionInputModel = new VerifiedCommandMentionInputModel(autocompleteInputModel.getInput(), autocompleteInputModel.getAutocompletables(), autocompleteInputModel.getApplicationCommands(), inputCommandContext, inputCommandOptions, mapInputToMentions.getMentions());
if (!this.applicationCommands.appendTextForCommandForInput(verifiedCommandMentionInputModel)) {
applyInputSpans(verifiedCommandMentionInputModel);
this.inputMentionModelSubject.onNext(verifiedCommandMentionInputModel);
}
}
/* JADX WARNING: Removed duplicated region for block: B:50:0x00c3 */
/* JADX WARNING: Removed duplicated region for block: B:68:0x0114 */
/* JADX WARNING: Removed duplicated region for block: B:79:0x0156 */
/* JADX WARNING: Removed duplicated region for block: B:86:0x00fc A[EDGE_INSN: B:86:0x00fc->B:59:0x00fc ?: BREAK , SYNTHETIC] */
private final void handleNewCommandsRecyclerScrollPosition(int i, int i2) {
int i3;
List<Application> applications;
VerifiedCommandMentionInputModel inputModel;
AutocompleteApplicationCommands commands;
Iterator it;
WidgetChatInputDiscoveryCommandsModel widgetChatInputDiscoveryCommandsModel;
List<Pair<Application, List<Autocompletable>>> commandsByApplication;
Object obj;
List list;
boolean z2;
WidgetChatInputDiscoveryCommandsModel widgetChatInputDiscoveryCommandsModel2 = this.discoveryCommands;
if (widgetChatInputDiscoveryCommandsModel2 == null || !widgetChatInputDiscoveryCommandsModel2.getHasMoreBefore() || i >= 3) {
WidgetChatInputDiscoveryCommandsModel widgetChatInputDiscoveryCommandsModel3 = this.discoveryCommands;
if (widgetChatInputDiscoveryCommandsModel3 != null && widgetChatInputDiscoveryCommandsModel3.getHasMoreAfter()) {
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter = this.mentionsAdapter;
if (chatInputAutocompleteAdapter == null) {
m.throwUninitializedPropertyAccessException("mentionsAdapter");
}
if (i2 >= chatInputAutocompleteAdapter.getItemCount() - 3) {
StoreStream.Companion.getApplicationCommands().requestLoadMoreDown();
}
}
} else {
StoreStream.Companion.getApplicationCommands().requestLoadMoreUp();
}
Integer num = this.applicationsPosition.get(-1L);
int intValue = num != null ? num.intValue() : -1;
WidgetChatInputDiscoveryCommandsModel widgetChatInputDiscoveryCommandsModel4 = this.discoveryCommands;
ArrayList arrayList = null;
if (!(widgetChatInputDiscoveryCommandsModel4 == null || (commandsByApplication = widgetChatInputDiscoveryCommandsModel4.getCommandsByApplication()) == null)) {
Iterator<T> it2 = commandsByApplication.iterator();
while (true) {
if (!it2.hasNext()) {
obj = null;
break;
}
obj = it2.next();
if (((Application) ((Pair) obj).getFirst()).getId() == -1) {
z2 = true;
continue;
} else {
z2 = false;
continue;
}
if (z2) {
break;
}
}
Pair pair = (Pair) obj;
if (!(pair == null || (list = (List) pair.getSecond()) == null)) {
i3 = list.size();
if (intValue != -1 || (widgetChatInputDiscoveryCommandsModel = this.discoveryCommands) == null || widgetChatInputDiscoveryCommandsModel.getHasMoreAfter() || i2 != (intValue + i3) - 1) {
it = u.reversed(this.applications).iterator();
while (true) {
if (it.hasNext()) {
break;
}
Application application = (Application) it.next();
Integer num2 = this.applicationsPosition.get(Long.valueOf(application.getId()));
if (num2 != null && i >= num2.intValue()) {
Long l = this.selectedCommandApplicationId;
long id2 = application.getId();
if (l == null || l.longValue() != id2) {
this.selectedCommandApplicationId = Long.valueOf(application.getId());
}
}
}
} else {
this.selectedCommandApplicationId = -1L;
}
InputSelectionModel inputSelectionModel = this.lastChatInputModel;
applications = (inputSelectionModel != null || (inputModel = inputSelectionModel.getInputModel()) == null || (commands = inputModel.getCommands()) == null) ? null : commands.getApplications();
if (applications != null) {
arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(applications, 10));
for (Application application2 : applications) {
long id3 = application2.getId();
Long l2 = this.selectedCommandApplicationId;
arrayList.add(new CommandCategoryItem(application2, l2 != null && id3 == l2.longValue(), null, 0, 12, null));
}
}
if (arrayList != null) {
this.categoriesAdapter.setData(arrayList);
}
onModelUpdated();
StoreStream.Companion.getAnalytics().trackApplicationCommandBrowserScrolled();
}
}
i3 = 0;
if (intValue != -1) {
}
it = u.reversed(this.applications).iterator();
while (true) {
if (it.hasNext()) {
}
}
InputSelectionModel inputSelectionModel = this.lastChatInputModel;
if (inputSelectionModel != null) {
}
if (applications != null) {
}
if (arrayList != null) {
}
onModelUpdated();
StoreStream.Companion.getAnalytics().trackApplicationCommandBrowserScrolled();
}
private final void jumpToApplication(long j) {
Integer num = this.applicationsPosition.get(Long.valueOf(j));
if (num != null) {
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter = this.mentionsAdapter;
if (chatInputAutocompleteAdapter == null) {
m.throwUninitializedPropertyAccessException("mentionsAdapter");
}
ChatInputAutocompleteAdapter.scrollToPosition$default(chatInputAutocompleteAdapter, num.intValue(), false, 2, null);
}
}
private final void onClickMentionItem(Autocompletable autocompletable) {
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
InputCommandOptions inputCommandOptions;
Map<ApplicationCommandOption, OptionRange> inputRanges;
VerifiedCommandMentionInputModel inputModel2;
AutocompleteInputCommandContext inputCommandContext;
if (!this.handleAutocompleteItemClicked.invoke(autocompletable).booleanValue()) {
if (autocompletable instanceof ApplicationCommandAutocompletable) {
ApplicationCommandAutocompletable applicationCommandAutocompletable = (ApplicationCommandAutocompletable) autocompletable;
ApplicationCommand command = applicationCommandAutocompletable.getCommand();
if (WidgetChatInputModelMappingFunctionsKt.hasPermission(command, this.userAndRoles)) {
this.applicationCommands.selectApplicationCommand(command);
StringBuilder sb = new StringBuilder();
String name = applicationCommandAutocompletable.getCommand().getName();
sb.append(String.valueOf('/') + name);
sb.append(" ");
String sb2 = sb.toString();
this.editText.setText(sb2);
this.editText.setSelection(sb2.length());
return;
}
return;
}
InputSelectionModel inputSelectionModel2 = this.lastChatInputModel;
OptionRange optionRange = null;
ApplicationCommand selectedCommand = (inputSelectionModel2 == null || (inputModel2 = inputSelectionModel2.getInputModel()) == null || (inputCommandContext = inputModel2.getInputCommandContext()) == null) ? null : inputCommandContext.getSelectedCommand();
InputSelectionModel inputSelectionModel3 = this.lastChatInputModel;
ApplicationCommandOption selectedCommandOption = inputSelectionModel3 != null ? inputSelectionModel3.getSelectedCommandOption() : null;
InputSelectionModel inputSelectionModel4 = this.lastChatInputModel;
if (!(inputSelectionModel4 == null || (inputModel = inputSelectionModel4.getInputModel()) == null || (inputCommandOptions = inputModel.getInputCommandOptions()) == null || (inputRanges = inputCommandOptions.getInputRanges()) == null)) {
optionRange = inputRanges.get(selectedCommandOption);
}
if (!autocompletable.getInputTextMatchers().isEmpty()) {
if (selectedCommandOption == null || optionRange == null || (inputSelectionModel = this.lastChatInputModel) == null || inputSelectionModel.hasSelectedFreeformInputOption()) {
WidgetChatInputEditText.Companion.insertMention(this.editText, (String) u.first((List<? extends Object>) autocompletable.getInputTextMatchers()), this.lastToken);
} else {
this.editText.getEditableText().replace(optionRange.getValue().getFirst(), optionRange.getValue().getLast(), a.D(new StringBuilder(), (String) u.first((List<? extends Object>) autocompletable.getInputTextMatchers()), " "));
FlexEditText flexEditText = this.editText;
flexEditText.setSelection(flexEditText.getEditableText().toString().length());
}
}
if (!(selectedCommand == null || selectedCommandOption == null)) {
this.editText.post(new WidgetChatInputAutocomplete$onClickMentionItem$1(this, selectedCommand, selectedCommandOption));
}
if (autocompletable instanceof EmojiAutocompletable) {
StoreStream.Companion.getEmojis().onEmojiUsed(((EmojiAutocompletable) autocompletable).getEmoji());
}
Observable<AutocompleteInputSelectionModel> Z = this.autocompleteInputSelectionModelSubject.Z(1);
m.checkNotNullExpressionValue(Z, "autocompleteInputSelecti…lSubject\n .take(1)");
ObservableExtensionsKt.appSubscribe$default(Z, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$onClickMentionItem$2(autocompletable), 62, (Object) null);
}
}
private final void onClickStickerItem(Sticker sticker) {
String str;
StoreStream.Companion companion = StoreStream.Companion;
companion.getExpressionSuggestions().setExpressionSuggestionsEnabled(false);
Editable text = this.editText.getText();
if (text == null || (str = text.toString()) == null) {
str = "";
}
String replaceAfterLast$default = w.replaceAfterLast$default(str, ':', "", null, 4, null);
FlexEditText flexEditText = this.editText;
String substring = replaceAfterLast$default.substring(0, Math.max(0, replaceAfterLast$default.length() - 1));
m.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
flexEditText.setText(substring);
MessageManager.sendMessage$default(new MessageManager(this.stickersAdapter.getContext(), null, null, null, null, null, null, null, null, 510, null), null, null, null, null, d0.t.m.listOf(sticker), false, null, null, null, 495, null);
companion.getStickers().onStickerUsed(sticker);
Observable<AutocompleteInputSelectionModel> Z = this.autocompleteInputSelectionModelSubject.Z(1);
m.checkNotNullExpressionValue(Z, "autocompleteInputSelecti…lSubject\n .take(1)");
ObservableExtensionsKt.appSubscribe$default(Z, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$onClickStickerItem$1(sticker), 62, (Object) null);
}
private final void onCommandCategoryClicked(Application application) {
if (this.discoveryCommands == null) {
StoreStream.Companion.getApplicationCommands().requestDiscoverCommands(application.getId());
} else {
Integer num = this.applicationsPosition.get(Long.valueOf(application.getId()));
if (num == null || !StoreStream.Companion.getApplicationCommands().hasFetchedApplicationCommands(application.getId())) {
StoreStream.Companion.getApplicationCommands().requestDiscoverCommands(application.getId());
} else {
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter = this.mentionsAdapter;
if (chatInputAutocompleteAdapter == null) {
m.throwUninitializedPropertyAccessException("mentionsAdapter");
}
ChatInputAutocompleteAdapter.scrollToPosition$default(chatInputAutocompleteAdapter, num.intValue(), false, 2, null);
}
}
StoreStream.Companion.getAnalytics().trackApplicationCommandBrowserJump(application.getId());
}
@MainThread
private final void onModelUpdated() {
String str = this.currentInput;
if (str != null) {
AutocompleteApplicationCommands autocompleteApplicationCommands = new AutocompleteApplicationCommands(this.applications, this.queryCommands, this.discoveryCommands);
handleInputModel(new AutocompleteInputModel(str, this.userAndRoles, this.mentions, autocompleteApplicationCommands));
}
}
private final boolean replacementSpanCommandParamDeletion() {
Editable editableText = this.editText.getEditableText();
m.checkNotNullExpressionValue(editableText, "editable");
Object[] spans = editableText.getSpans(0, editableText.length(), ReplacementSpan.class);
m.checkExpressionValueIsNotNull(spans, "getSpans(start, end, T::class.java)");
ReplacementSpan[] replacementSpanArr = (ReplacementSpan[]) spans;
for (ReplacementSpan replacementSpan : replacementSpanArr) {
IntRange intRange = new IntRange(editableText.getSpanStart(replacementSpan), editableText.getSpanEnd(replacementSpan));
if (!w.contains$default((CharSequence) editableText.subSequence(intRange.getFirst(), intRange.getLast()).toString(), ':', false, 2, (Object) null)) {
editableText.delete(intRange.getFirst(), intRange.getLast());
return true;
}
}
return false;
}
public final void configureDataSubscriptions(AppFragment appFragment, Observable<Boolean> observable) {
m.checkNotNullParameter(appFragment, "fragment");
m.checkNotNullParameter(observable, "emptyTextSubject");
this.applicationCommands.configureObservables(appFragment);
ChatInputAutocompleteAdapter chatInputAutocompleteAdapter = this.mentionsAdapter;
if (chatInputAutocompleteAdapter == null) {
m.throwUninitializedPropertyAccessException("mentionsAdapter");
}
chatInputAutocompleteAdapter.configureSubscriptions(appFragment);
boolean isEnabled = EmojiAutocompletePremiumUpsellFeatureFlag.Companion.getINSTANCE().isEnabled();
StoreStream.Companion companion = StoreStream.Companion;
Observable r = Observable.i(companion.getUsers().observeMeId(), companion.getGuildSelected().observeSelectedGuildId(), companion.getGuilds().observeComputed(), WidgetChatInputAutocomplete$configureDataSubscriptions$1.INSTANCE).r();
m.checkNotNullExpressionValue(r, "Observable.combineLatest… }.distinctUntilChanged()");
Observable K = ObservableExtensionsKt.ui$default(r, appFragment, null, 2, null).K();
m.checkNotNullExpressionValue(K, "Observable.combineLatest… .onBackpressureLatest()");
ObservableExtensionsKt.appSubscribe$default(K, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$2(this), 62, (Object) null);
Observable<Channel> observeSelectedChannel = companion.getChannelsSelected().observeSelectedChannel();
ObservableExtensionsKt$filterNull$1 observableExtensionsKt$filterNull$1 = ObservableExtensionsKt$filterNull$1.INSTANCE;
Observable<Channel> x2 = observeSelectedChannel.x(observableExtensionsKt$filterNull$1);
ObservableExtensionsKt$filterNull$2 observableExtensionsKt$filterNull$2 = ObservableExtensionsKt$filterNull$2.INSTANCE;
Observable<R> F = x2.F(observableExtensionsKt$filterNull$2);
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
Observable r2 = F.Y(WidgetChatInputAutocomplete$configureDataSubscriptions$3.INSTANCE).r();
m.checkNotNullExpressionValue(r2, "StoreStream.getChannelsS… .distinctUntilChanged()");
Observable K2 = ObservableExtensionsKt.ui$default(r2, appFragment, null, 2, null).K();
m.checkNotNullExpressionValue(K2, "StoreStream.getChannelsS… .onBackpressureLatest()");
ObservableExtensionsKt.appSubscribe$default(K2, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$4(this), 62, (Object) null);
Observable<R> F2 = companion.getChannelsSelected().observeSelectedChannel().x(observableExtensionsKt$filterNull$1).F(observableExtensionsKt$filterNull$2);
m.checkNotNullExpressionValue(F2, "filter { it != null }.map { it!! }");
Observable r3 = F2.Y(WidgetChatInputAutocomplete$configureDataSubscriptions$5.INSTANCE).r();
m.checkNotNullExpressionValue(r3, "StoreStream.getChannelsS… }.distinctUntilChanged()");
Observable K3 = ObservableExtensionsKt.ui$default(r3, appFragment, null, 2, null).K();
m.checkNotNullExpressionValue(K3, "StoreStream.getChannelsS… .onBackpressureLatest()");
ObservableExtensionsKt.appSubscribe$default(K3, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$6(this), 62, (Object) null);
Observable<R> F3 = companion.getChannelsSelected().observeSelectedChannel().x(observableExtensionsKt$filterNull$1).F(observableExtensionsKt$filterNull$2);
m.checkNotNullExpressionValue(F3, "filter { it != null }.map { it!! }");
Observable r4 = F3.Y(WidgetChatInputAutocomplete$configureDataSubscriptions$7.INSTANCE).r();
m.checkNotNullExpressionValue(r4, "StoreStream.getChannelsS… .distinctUntilChanged()");
Observable K4 = ObservableExtensionsKt.ui$default(r4, appFragment, null, 2, null).K();
m.checkNotNullExpressionValue(K4, "StoreStream.getChannelsS… .onBackpressureLatest()");
ObservableExtensionsKt.appSubscribe$default(K4, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$8(this), 62, (Object) null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(ChatInputAutocompletables.INSTANCE.observeChannelAutocompletables()), appFragment, null, 2, null), WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$9(this), 62, (Object) null);
Observable j = Observable.j(this.inputSelectionSubject, this.inputMentionModelSubject, WidgetChatInputAutocomplete$configureDataSubscriptions$10.INSTANCE);
m.checkNotNullExpressionValue(j, "Observable.combineLatest…dOption, selection)\n }");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(j), appFragment, null, 2, null), WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$11(this), 62, (Object) null);
BehaviorSubject<AutocompleteInputSelectionModel> behaviorSubject = this.autocompleteInputSelectionModelSubject;
m.checkNotNullExpressionValue(behaviorSubject, "autocompleteInputSelectionModelSubject");
Observable j2 = Observable.j(ObservableExtensionsKt.leadingEdgeThrottle(behaviorSubject, 100, TimeUnit.MILLISECONDS), StoreUserSettings.observeIsAnimatedEmojisEnabled$default(companion.getUserSettings(), false, 1, null), WidgetChatInputAutocomplete$configureDataSubscriptions$12.INSTANCE);
m.checkNotNullExpressionValue(j2, "Observable.combineLatest…l to allowAnimatedEmoji }");
Observable r5 = ObservableExtensionsKt.computationLatest(j2).r();
m.checkNotNullExpressionValue(r5, "Observable.combineLatest… .distinctUntilChanged()");
Observable K5 = ObservableExtensionsKt.ui$default(r5, appFragment, null, 2, null).K();
m.checkNotNullExpressionValue(K5, "Observable.combineLatest… .onBackpressureLatest()");
ObservableExtensionsKt.appSubscribe$default(K5, WidgetChatInputAutocomplete.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputAutocomplete$configureDataSubscriptions$13(this, isEnabled, appFragment), 62, (Object) null);
Observable r6 = this.autocompleteInputSelectionModelSubject.F(WidgetChatInputAutocomplete$configureDataSubscriptions$14.INSTANCE).r();
m.checkNotNullExpressionValue(r6, "autocompleteInputSelecti… }.distinctUntilChanged()");
StoreGuilds.Actions.requestMembers(appFragment, r6, true);
}
public final ApplicationCommandData getApplicationCommandData() {
return this.applicationCommands.getApplicationSendData(this.queryCommands);
}
public final FlexEditText getEditText() {
return this.editText;
}
public final boolean getIsTypingCommand(String str) {
m.checkNotNullParameter(str, "input");
return w.startsWith$default((CharSequence) str, '/', false, 2, (Object) null);
}
public final RecyclerView getMentionsRecycler() {
return this.mentionsRecycler;
}
public final View getStickersContainer() {
return this.stickersContainer;
}
public final TextView getStickersHeader() {
return this.stickersHeader;
}
public final void onApplicationCommandSendError() {
this.applicationCommands.onApplicationCommandSendError();
}
public final void onSelectionChanged(int i, int i2) {
this.inputSelectionSubject.onNext(new IntRange(i, i2));
}
public final void onTextChanged(String str) {
m.checkNotNullParameter(str, "content");
if (!replacementSpanCommandParamDeletion()) {
this.currentInput = str;
onModelUpdated();
}
}
public final MessageContent replaceAutocompletableDataWithServerValues(String str) {
VerifiedCommandMentionInputModel inputModel;
Map<IntRange, Autocompletable> inputMentionsMap;
m.checkNotNullParameter(str, "content");
InputSelectionModel inputSelectionModel = this.lastChatInputModel;
if (inputSelectionModel == null || (inputModel = inputSelectionModel.getInputModel()) == null || (inputMentionsMap = inputModel.getInputMentionsMap()) == null) {
return new MessageContent(str, n.emptyList());
}
String replaceAutocompleteDataWithServerValues = WidgetChatInputModelMappingFunctions.INSTANCE.replaceAutocompleteDataWithServerValues(str, inputMentionsMap);
List<UserAutocompletable> filterIsInstance = t.filterIsInstance(inputMentionsMap.values(), UserAutocompletable.class);
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(filterIsInstance, 10));
for (UserAutocompletable userAutocompletable : filterIsInstance) {
arrayList.add(userAutocompletable.getUser());
}
int length = replaceAutocompleteDataWithServerValues.length() - 1;
int i = 0;
boolean z2 = false;
while (i <= length) {
boolean z3 = m.compare(replaceAutocompleteDataWithServerValues.charAt(!z2 ? i : length), 32) <= 0;
if (!z2) {
if (!z3) {
z2 = true;
} else {
i++;
}
} else if (!z3) {
break;
} else {
length--;
}
}
return new MessageContent(replaceAutocompleteDataWithServerValues.subSequence(i, length + 1).toString(), arrayList);
}
}