892 lines
37 KiB
TypeScript
892 lines
37 KiB
TypeScript
// Metro module 11484 (f11485).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import * as Module19 from "react";
|
|
import { forwardRef, useState, useContext, useMemo, useEffect, useImperativeHandle, useCallback, useRef } from "react";
|
|
import { FlatList, View, StyleSheet } from "react-native";
|
|
import ApplicationCommandStore from "../../application_commands/ApplicationCommandStore";
|
|
import EmojiStore from "../../emojis/EmojiStore";
|
|
import GatewayConnectionStore from "../../gateway/GatewayConnectionStore";
|
|
import StickersStore from "../../stickers/StickersStore";
|
|
import { AnalyticEvents, AutoCompleteResultTypes, UpsellTypes, WHITESPACE_RE } from "../../../Constants";
|
|
import { BOOLEAN_CHOICES } from "../../application_commands/ApplicationCommandConstants";
|
|
import { AUTOCOMPLETE_EMOJI_ROW_HEIGHT, AUTOCOMPLETE_ROW_HEIGHT } from "../../application_commands/native/ApplicationCommandsConstants";
|
|
import { CHANNEL_SENTINEL, EMOJI_SENTINEL, GAME_MENTION_INPUT_PREFIX, MENTION_SENTINEL } from "../../channel_autocomplete/ChannelAutocompleteConstants";
|
|
import { AutocompleteTypes } from "../../channel_text_area/native/ChannelAutocompleteConstants";
|
|
import { EmojiInteractionPoint } from "../../emojis/EmojiConstants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import * as _PlatformUtils from "../../../utils/PlatformUtils";
|
|
import { isAndroid } from "../../../utils/PlatformUtils";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import Autocomplete, { AUTOCOMPLETE_STICKER_NODE_SIZE, AUTOCOMPLETE_STICKER_NODE_MARGIN } from "./Autocomplete";
|
|
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
|
|
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
|
|
import { NAV_BAR_HEIGHT } from "../../../design/components/Navigator/native/NavigatorConstants.native";
|
|
import { useStateFromStoresObject, useStateFromStores, BatchedStoreListener } from "../../../_bundle/Module589";
|
|
import { useToken } from "../../../design/tokens/native/useToken";
|
|
import { useScaledTextLineHeight } from "../../screen/native/useScaledTextLineHeight.android";
|
|
import useGameMentionSearchBarHeight from "../../game_mentions/hooks/native/useGameMentionSearchBarHeight";
|
|
import { IncludeStickersInAutocomplete } from "../../user_settings/UserSettings";
|
|
import { RedesignCompatContext } from "../../../design/components/RedesignCompat/native/RedesignCompat.native";
|
|
import { getAutocompleteOptions } from "./AutocompleteOptions";
|
|
import { getGameMentionsAutocompleteConfig } from "../../game_mentions/getGameMentionsAutocompleteConfig";
|
|
import useMentionAnchor from "./useMentionAnchor";
|
|
import { initiateEmojiInteraction } from "../../emojis/EmojiActionCreators";
|
|
import { getApplicationCommandOptionQueryOptions } from "../../application_commands/ApplicationCommandUtils";
|
|
import { ApplicationCommandOptionType } from "../../../flow/Server";
|
|
import * as _AutocompleteUtils from "./AutocompleteUtils";
|
|
import { getPrefix, getQuery, getAutocompleteResultText, getItemSeparator } from "./AutocompleteUtils";
|
|
import { getTextBeforeFirstOption } from "../../chat_input/native/ChatInputCommandOptionParser";
|
|
import { KeyboardTypes } from "../../keyboard/native/KeyboardTypes";
|
|
import { trackWithMetadata } from "../../app_analytics/AppAnalyticsUtils";
|
|
import { iOSTrackAutocompleteOpen, iOSTrackAutocompleteSelect } from "../../channel_text_area/native/ChannelAutocompleteAnalytics";
|
|
import { useMobileVisualRefreshConfig } from "../../themes/experiments/MobileVisualRefreshExperiment";
|
|
import { useIsScreenReaderEnabled } from "../../a11y/native/useIsScreenReaderEnabled.native";
|
|
import useAutocompleteAnimatedHeightStyles from "./useAutocompleteAnimatedHeightStyles";
|
|
import PremiumUpsellUtils from "../../../utils/native/PremiumUpsellUtils";
|
|
import { openCommandAttachmentPreview } from "../../application_commands/native/ApplicationCommandUtils";
|
|
import { NewTag } from "../../../design/void/native";
|
|
import ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import ApplicationCommandDiscovery from "../../application_commands/native/ApplicationCommandDiscovery";
|
|
import { ApplicationCommandTriggerLocations } from "../../application_commands/ApplicationCommandTypes";
|
|
import ApplicationCommandList from "../../application_commands/native/ApplicationCommandList";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import FormDivider from "../../../design/void/Form/native/FormDivider";
|
|
import GameMentionSearchBar from "../../game_mentions/native/GameMentionSearchBar";
|
|
import ApplicationCommandBar from "../../application_commands/native/ApplicationCommandBar";
|
|
let variant, hairlineWidth, useStyles, c7821_31;
|
|
const getStickersItemLayout = function getStickersItemLayout(a0, a1) {
|
|
return {
|
|
length: AUTOCOMPLETE_STICKER_NODE_SIZE,
|
|
offset: a1 * (AUTOCOMPLETE_STICKER_NODE_SIZE + AUTOCOMPLETE_STICKER_NODE_MARGIN) + (a1 - 1) * AUTOCOMPLETE_STICKER_NODE_MARGIN,
|
|
index: a1
|
|
};
|
|
};
|
|
variant = "text-sm/semibold";
|
|
hairlineWidth = StyleSheet.hairlineWidth;
|
|
useStyles = createStyles((a0, a1, a2, a3, a4) => ({
|
|
autocompletePositionRelative: {
|
|
position: "relative"
|
|
},
|
|
autocompleteWrapper: {
|
|
position: isAndroid() ? "relative" : "absolute",
|
|
marginHorizontal: a3,
|
|
marginBottom: a4
|
|
},
|
|
autocompleteWrapperAbsolute: {
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0
|
|
},
|
|
autocompleteContainer: {
|
|
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND,
|
|
borderRadius: a0,
|
|
borderWidth: a1,
|
|
borderTopWidth: a2,
|
|
borderColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BORDER,
|
|
overflow: "hidden"
|
|
},
|
|
autocomplete: {
|
|
flexGrow: 0,
|
|
flexShrink: 1,
|
|
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND
|
|
},
|
|
sectionDivider: {
|
|
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BORDER,
|
|
marginLeft: -16
|
|
},
|
|
sectionTitle: {
|
|
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND,
|
|
paddingLeft: 12,
|
|
marginVertical: 12,
|
|
justifyContent: "center"
|
|
},
|
|
stickersAutocompleteList: {
|
|
paddingLeft: 12 - AUTOCOMPLETE_STICKER_NODE_MARGIN,
|
|
marginBottom: 12,
|
|
height: AUTOCOMPLETE_STICKER_NODE_SIZE,
|
|
flexShrink: 0
|
|
},
|
|
newTag: {
|
|
backgroundColor: Module712.colors.BADGE_BACKGROUND_BRAND
|
|
}
|
|
}));
|
|
c7821_31 = {
|
|
resultCount: 0,
|
|
stickerResults: [],
|
|
nonStickerResults: [],
|
|
hasStickerResults: false,
|
|
hasNonStickerResults: false
|
|
};
|
|
const r73 = forwardRef(function({ analyticsLocations, channel, canMentionEveryone, keyboardType, onChangeAutoCompleteVisibility, commandsDisabled, chatInputRef, canOnlyUseTextCommands, screenIndex }, a1) {
|
|
let r265;
|
|
let optionStates, activeOption, activeCommand, token, scaledTextLineHeight, c18886_12, setting, resultCount, stickerResults, nonStickerResults, hasStickerResults, hasNonStickerResults, setState, context, memo, focused, text, selectionStart, selectionEnd, setState2, setState3, gameMentionsAutocompleteConfig, c18886_29, anchor, beginSearch, autocompleteType, query, queryOptions, autocompleteSelectionStart, showOptionValuesPicker, callback, callback2, memo2, ref, ref2, c18886_42, memo3, state, setState4, chatInputFloating, c18886_47, token2, styles, isScreenReaderEnabled, callback3, callback4, state2, setState5;
|
|
optionStates = void 0;
|
|
activeOption = void 0;
|
|
activeCommand = void 0;
|
|
token = void 0;
|
|
scaledTextLineHeight = void 0;
|
|
c18886_12 = void 0;
|
|
setting = void 0;
|
|
resultCount = void 0;
|
|
stickerResults = void 0;
|
|
nonStickerResults = void 0;
|
|
hasStickerResults = void 0;
|
|
hasNonStickerResults = void 0;
|
|
setState = void 0;
|
|
context = void 0;
|
|
memo = void 0;
|
|
focused = void 0;
|
|
text = void 0;
|
|
selectionStart = void 0;
|
|
selectionEnd = void 0;
|
|
setState2 = void 0;
|
|
setState3 = void 0;
|
|
gameMentionsAutocompleteConfig = void 0;
|
|
c18886_29 = void 0;
|
|
anchor = void 0;
|
|
beginSearch = void 0;
|
|
autocompleteType = void 0;
|
|
query = void 0;
|
|
queryOptions = void 0;
|
|
autocompleteSelectionStart = void 0;
|
|
showOptionValuesPicker = void 0;
|
|
callback = void 0;
|
|
callback2 = void 0;
|
|
memo2 = void 0;
|
|
ref = void 0;
|
|
ref2 = void 0;
|
|
c18886_42 = void 0;
|
|
memo3 = void 0;
|
|
state = void 0;
|
|
setState4 = void 0;
|
|
chatInputFloating = void 0;
|
|
c18886_47 = void 0;
|
|
token2 = void 0;
|
|
styles = void 0;
|
|
isScreenReaderEnabled = void 0;
|
|
callback3 = void 0;
|
|
callback4 = void 0;
|
|
state2 = void 0;
|
|
setState5 = void 0;
|
|
const stateFromStoresObject = useStateFromStoresObject([ApplicationCommandStore], () => ({
|
|
optionStates: ApplicationCommandStore.getOptionStates(channel.id),
|
|
activeOption: ApplicationCommandStore.getActiveOption(channel.id),
|
|
activeCommand: ApplicationCommandStore.getActiveCommand(channel.id),
|
|
activeSection: ApplicationCommandStore.getActiveCommandSection(channel.id)
|
|
}));
|
|
optionStates = stateFromStoresObject.optionStates;
|
|
activeOption = stateFromStoresObject.activeOption;
|
|
activeCommand = stateFromStoresObject.activeCommand;
|
|
const activeSection = stateFromStoresObject.activeSection;
|
|
token = useToken(Module712.modules.mobile.TABLE_ROW_HEIGHT);
|
|
scaledTextLineHeight = useScaledTextLineHeight(variant);
|
|
const gameMentionSearchBarHeight = useGameMentionSearchBarHeight();
|
|
c18886_12 = gameMentionSearchBarHeight;
|
|
setting = IncludeStickersInAutocomplete.getSetting();
|
|
const r84 = _slicedToArray(useState(c7821_31), 2);
|
|
const r85 = r84[0];
|
|
resultCount = r85.resultCount;
|
|
stickerResults = r85.stickerResults;
|
|
nonStickerResults = r85.nonStickerResults;
|
|
let hasStickerResults2 = r85.hasStickerResults;
|
|
hasStickerResults = hasStickerResults2;
|
|
let hasNonStickerResults2 = r85.hasNonStickerResults;
|
|
hasNonStickerResults = hasNonStickerResults2;
|
|
setState = r84[1];
|
|
const stateFromStores2 = useStateFromStores([EmojiStore], () => EmojiStore.loadState);
|
|
const stateFromStores = useStateFromStores([StickersStore], () => StickersStore.loadState);
|
|
context = useContext(RedesignCompatContext);
|
|
memo = useMemo(() => getAutocompleteOptions(channel, true, setting), [channel, setting]);
|
|
const r108 = _slicedToArray(useState({
|
|
focused: false,
|
|
text: "",
|
|
selectionStart: 0,
|
|
selectionEnd: 0
|
|
}), 2);
|
|
const r109 = r108[0];
|
|
focused = r109.focused;
|
|
text = r109.text;
|
|
selectionStart = r109.selectionStart;
|
|
selectionEnd = r109.selectionEnd;
|
|
setState2 = r108[1];
|
|
let state3;
|
|
[state3, setState3] = useState(0);
|
|
gameMentionsAutocompleteConfig = getGameMentionsAutocompleteConfig("AutocompleteWrapper game search");
|
|
const r33 = gameMentionsAutocompleteConfig.enabled && !gameMentionsAutocompleteConfig.combineMentionAutocomplete;
|
|
c18886_29 = r33;
|
|
const mentionAnchor = useMentionAnchor(text, selectionEnd, chatInputRef, r33, GAME_MENTION_INPUT_PREFIX);
|
|
anchor = mentionAnchor.anchor;
|
|
beginSearch = mentionAnchor.beginSearch;
|
|
useEffect(() => {
|
|
let c27073_0 = false;
|
|
GatewayConnectionStore.addConditionalChangeListener(() => {
|
|
let r0 = !c27073_0;
|
|
if (!c27073_0) {
|
|
const isConnected = GatewayConnectionStore.isConnected();
|
|
let r8 = void 0;
|
|
if (isConnected) {
|
|
initiateEmojiInteraction(EmojiInteractionPoint.AutocompleteWrapperShown);
|
|
r8 = false;
|
|
}
|
|
r0 = r8;
|
|
}
|
|
return r0;
|
|
});
|
|
return () => {
|
|
c27073_0 = true;
|
|
};
|
|
}, []);
|
|
useImperativeHandle(a1, useMemo(() => {
|
|
let c27074_0 = -1;
|
|
return () => ({
|
|
setChatInputHeight: setState3,
|
|
setData: ({ focused: focused2, text: text2, selectionStart: selectionStart3, selectionEnd: selectionEnd2 }) => {
|
|
if (c27074_0 !== -1) {
|
|
clearTimeout(c27074_0);
|
|
}
|
|
c27074_0 = setTimeout(() => {
|
|
setState2((prevState2) => prevState2.focused === focused2 && (prevState2.text === text2 && (prevState2.selectionStart === selectionStart3 && prevState2.selectionEnd === selectionEnd2)) ? prevState2 : {
|
|
focused: focused2,
|
|
text: text2,
|
|
selectionStart: selectionStart3,
|
|
selectionEnd: selectionEnd2
|
|
});
|
|
}, 16);
|
|
}
|
|
});
|
|
}, []));
|
|
const memo4 = useMemo(() => {
|
|
let r17, r30, r130, CHOICES, autocompleteSelectionStart2, channelTypes, choices, showOptionValuesPicker2;
|
|
let prefix, query2, c27075_3;
|
|
let selectionStart2 = selectionStart;
|
|
if (text != null && text.trim().length !== 0) {
|
|
const r7 = activeOption != null ? getApplicationCommandOptionQueryOptions(activeOption) : {
|
|
canMentionEveryone,
|
|
canMentionHere: canMentionEveryone,
|
|
canMentionChannels: true,
|
|
canMentionUsers: true,
|
|
canMentionRoles: true,
|
|
canMentionAnyGuildUser: false,
|
|
canMentionNonMentionableRoles: false,
|
|
canMentionOtherGlobals: true,
|
|
canMentionGames: true
|
|
};
|
|
const r11 = activeOption != null ? optionStates[activeOption.name] : void 0;
|
|
const r48 = activeCommand != null;
|
|
let r28 = void 0;
|
|
let r27 = void 0;
|
|
if (r48) {
|
|
const r49 = activeOption != null;
|
|
r28 = void 0;
|
|
r27 = void 0;
|
|
if (r49) {
|
|
const r50 = r11 != null;
|
|
r28 = void 0;
|
|
r27 = void 0;
|
|
if (r50) {
|
|
let location2 = r11.location;
|
|
if (location2 == null) {
|
|
location2 = 0;
|
|
}
|
|
let length = r11.length;
|
|
if (length == null) {
|
|
length = 0;
|
|
}
|
|
const r19 = selectionStart >= location2 + length ? text.substring(location2 + length, selectionStart) : void 0;
|
|
L27: {
|
|
query2 = r19;
|
|
if (activeOption.choices == null && !activeOption.autocomplete) {
|
|
const type = activeOption.type;
|
|
if (ApplicationCommandOptionType.BOOLEAN === type) {
|
|
prefix = "";
|
|
CHOICES = AutocompleteTypes.CHOICES;
|
|
choices = BOOLEAN_CHOICES;
|
|
showOptionValuesPicker2 = true;
|
|
channelTypes = void 0;
|
|
r17 = "";
|
|
break L27;
|
|
}
|
|
if (ApplicationCommandOptionType.CHANNEL === type) {
|
|
prefix = CHANNEL_SENTINEL;
|
|
CHOICES = AutocompleteTypes.CHANNELS;
|
|
channelTypes = activeOption.channelTypes;
|
|
showOptionValuesPicker2 = true;
|
|
choices = void 0;
|
|
r17 = CHANNEL_SENTINEL;
|
|
break L27;
|
|
}
|
|
if (ApplicationCommandOptionType.ROLE !== type && ApplicationCommandOptionType.USER !== type) {
|
|
const MENTIONABLE = ApplicationCommandOptionType.MENTIONABLE;
|
|
showOptionValuesPicker2 = false;
|
|
channelTypes = void 0;
|
|
choices = void 0;
|
|
r17 = void 0;
|
|
CHOICES = void 0;
|
|
if (MENTIONABLE !== type) {
|
|
break L27;
|
|
}
|
|
}
|
|
prefix = MENTION_SENTINEL;
|
|
CHOICES = AutocompleteTypes.MENTIONS;
|
|
showOptionValuesPicker2 = true;
|
|
channelTypes = void 0;
|
|
choices = void 0;
|
|
r17 = MENTION_SENTINEL;
|
|
} else {
|
|
prefix = "";
|
|
CHOICES = AutocompleteTypes.CHOICES;
|
|
choices = activeOption.choices;
|
|
showOptionValuesPicker2 = true;
|
|
channelTypes = void 0;
|
|
r17 = "";
|
|
}
|
|
}
|
|
r28 = r19;
|
|
r27 = CHOICES;
|
|
if (showOptionValuesPicker2) {
|
|
const r167 = r17 != null && r17 !== "" && r19 != null && r19.startsWith(r17);
|
|
let query5 = r19;
|
|
if (r167) {
|
|
query2 = r19.length > r17.length ? r19.substring(r17.length) : "";
|
|
query5 = query2;
|
|
}
|
|
const optionValues = {};
|
|
c27075_3 = optionValues;
|
|
Object.entries(optionStates).forEach((item) => {
|
|
const [r13, r14] = item;
|
|
if (r14.optionValue != null) {
|
|
c27075_3[r13] = r14.optionValue;
|
|
}
|
|
});
|
|
return {
|
|
query: query5,
|
|
autocompleteType: CHOICES,
|
|
autocompleteSelectionStart: location2 + length,
|
|
queryOptions: {
|
|
activeCommand,
|
|
optionValues,
|
|
isActiveApplicationCommand: showOptionValuesPicker2,
|
|
option: activeOption,
|
|
choices,
|
|
channelTypes,
|
|
...r7
|
|
},
|
|
showOptionValuesPicker: showOptionValuesPicker2
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (c18886_29 && anchor != null) {
|
|
return {
|
|
query: text.slice(anchor + GAME_MENTION_INPUT_PREFIX.length, selectionEnd).toLowerCase(),
|
|
autocompleteType: AutocompleteTypes.GAME_MENTIONS,
|
|
autocompleteSelectionStart: anchor,
|
|
queryOptions: {
|
|
...r7
|
|
}
|
|
};
|
|
}
|
|
const r4 = r11 != null;
|
|
let r26 = null;
|
|
if (r4) {
|
|
let location3 = r11.location;
|
|
if (location3 == null) {
|
|
location3 = 0;
|
|
}
|
|
let length2 = r11.length;
|
|
if (length2 == null) {
|
|
length2 = 0;
|
|
}
|
|
r26 = location3 + length2;
|
|
}
|
|
const r103 = r26 == null;
|
|
let r22 = selectionStart;
|
|
while (true) {
|
|
const isWhitespaceSeparatingBoundary = _AutocompleteUtils.isWhitespaceSeparatingBoundary(text, r22);
|
|
const r110 = r22;
|
|
let r31 = r28;
|
|
let autocompleteType2 = r27;
|
|
const r25 = r103 ? 0 : r26;
|
|
L47: {
|
|
L44: {
|
|
if (r110 !== r25) {
|
|
r30 = autocompleteType2;
|
|
if (!isWhitespaceSeparatingBoundary) {
|
|
break L44;
|
|
}
|
|
}
|
|
const r114 = text.slice(r110, selectionEnd);
|
|
prefix = getPrefix(r114);
|
|
query2 = getQuery(r114);
|
|
if (query2 != null) {
|
|
const r128 = WHITESPACE_RE.test(query2);
|
|
autocompleteSelectionStart2 = r110;
|
|
r130 = query2;
|
|
if (r128) {
|
|
break L47;
|
|
}
|
|
}
|
|
r30 = Object.keys(memo).find((item) => {
|
|
const r8 = memo[item];
|
|
let r11 = item !== AutocompleteTypes.SLASHES && item !== AutocompleteTypes.SLASHES_DISCOVERY || activeCommand == null && !commandsDisabled;
|
|
if (r11) {
|
|
r11 = prefix !== void 0 && query2 !== void 0 && r8.matches(prefix, query2, selectionStart2);
|
|
}
|
|
return r11;
|
|
});
|
|
r31 = query2;
|
|
autocompleteSelectionStart2 = r110;
|
|
r130 = r31;
|
|
autocompleteType2 = r30;
|
|
if (autocompleteType2 != null) {
|
|
break L47;
|
|
}
|
|
}
|
|
const r135 = r110 - 1;
|
|
selectionStart2 = r135;
|
|
const r136 = r103 ? 0 : r26;
|
|
r22 = r135;
|
|
r28 = r31;
|
|
r27 = r30;
|
|
r130 = r28;
|
|
autocompleteType2 = r27;
|
|
autocompleteSelectionStart2 = r22;
|
|
if (autocompleteSelectionStart2 >= r136) {
|
|
continue;
|
|
}
|
|
}
|
|
const SLASHES = AutocompleteTypes.SLASHES;
|
|
let query4 = r130;
|
|
if (autocompleteType2 === SLASHES) {
|
|
query2 = getTextBeforeFirstOption(r130 == null ? "" : r130).text;
|
|
query4 = query2;
|
|
}
|
|
return {
|
|
query: query4,
|
|
autocompleteType: autocompleteType2,
|
|
autocompleteSelectionStart: autocompleteSelectionStart2,
|
|
queryOptions: {
|
|
...r7
|
|
}
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
query: null,
|
|
autocompleteType: null,
|
|
autocompleteSelectionStart: null
|
|
};
|
|
}, [selectionStart, selectionEnd, text, activeCommand, optionStates, activeOption, canMentionEveryone, commandsDisabled, memo, stateFromStores2, stateFromStores, r33, anchor]);
|
|
autocompleteType = memo4.autocompleteType;
|
|
query = memo4.query;
|
|
queryOptions = memo4.queryOptions;
|
|
autocompleteSelectionStart = memo4.autocompleteSelectionStart;
|
|
showOptionValuesPicker = memo4.showOptionValuesPicker;
|
|
callback = useCallback((a0) => {
|
|
if (autocompleteType != null && query != null) {
|
|
const r16 = memo[autocompleteType].queryResults(query, queryOptions, a0);
|
|
const stickerResults2 = [];
|
|
let c27076_0 = stickerResults2;
|
|
const nonStickerResults2 = [];
|
|
let c27076_1 = nonStickerResults2;
|
|
r16.forEach((item) => {
|
|
if (item.type === AutoCompleteResultTypes.STICKER) {
|
|
c27076_0.push(item);
|
|
} else {
|
|
c27076_1.push(item);
|
|
}
|
|
});
|
|
setState({
|
|
resultCount: r16.length,
|
|
stickerResults: stickerResults2,
|
|
nonStickerResults: nonStickerResults2,
|
|
hasStickerResults: stickerResults2.length > 0,
|
|
hasNonStickerResults: nonStickerResults2.length > 0
|
|
});
|
|
} else {
|
|
setState(c7821_31);
|
|
}
|
|
}, [autocompleteType, query, queryOptions, memo]);
|
|
useEffect(() => {
|
|
const r6 = autocompleteType != null ? memo == null ? void 0 : memo[autocompleteType].stores : null;
|
|
if (r6 != null) {
|
|
let c27077_0;
|
|
const batchedStoreListener = new BatchedStoreListener(r6, () => callback(false));
|
|
c27077_0 = batchedStoreListener;
|
|
batchedStoreListener.attach("AutocompleteWrapper");
|
|
return () => c27077_0.detach();
|
|
}
|
|
}, [autocompleteType, callback, memo]);
|
|
useEffect(() => {
|
|
callback(true);
|
|
}, [callback]);
|
|
callback2 = useCallback(() => ({
|
|
numStickerResults: stickerResults.length,
|
|
numEmojiResults: nonStickerResults.filter((nonStickerResult) => nonStickerResult.type === AutoCompleteResultTypes.EMOJI).length
|
|
}), [stickerResults, nonStickerResults]);
|
|
memo2 = useMemo(() => {
|
|
const r1 = resultCount > 0 || (autocompleteType === AutocompleteTypes.SLASHES || autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY) || autocompleteType === AutocompleteTypes.GAME_MENTIONS;
|
|
const SYSTEM = KeyboardTypes.SYSTEM;
|
|
let r24 = focused;
|
|
if (focused) {
|
|
r24 = r1;
|
|
}
|
|
if (r24) {
|
|
r24 = keyboardType === SYSTEM;
|
|
}
|
|
return r24;
|
|
}, [autocompleteType, focused, keyboardType, resultCount]);
|
|
ref = useRef(false);
|
|
useEffect(() => {
|
|
const current = ref.current;
|
|
let current2 = autocompleteType === AutocompleteTypes.SLASHES;
|
|
if (current) {
|
|
if (!current2) {
|
|
current2 = autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY;
|
|
}
|
|
if (!current2) {
|
|
current2 = activeCommand != null;
|
|
}
|
|
ref.current = current2;
|
|
} else {
|
|
ref.current = (current2 ? current2 : autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY) || activeCommand != null;
|
|
if (ref.current) {
|
|
trackWithMetadata(AnalyticEvents.APPLICATION_COMMAND_TOP_OF_FUNNEL, {
|
|
location: "slash_ui"
|
|
});
|
|
}
|
|
}
|
|
}, [autocompleteType, activeCommand]);
|
|
ref2 = useRef(null);
|
|
useEffect(() => {
|
|
let r2 = memo2;
|
|
if (!memo2) {
|
|
r2 = activeCommand != null;
|
|
}
|
|
if (onChangeAutoCompleteVisibility != null) {
|
|
onChangeAutoCompleteVisibility(r2);
|
|
}
|
|
if (r2) {
|
|
const current = `${channel.id}:${autocompleteType == null ? "" : autocompleteType}`;
|
|
if (ref2.current !== current) {
|
|
ref2.current = current;
|
|
iOSTrackAutocompleteOpen(autocompleteType, channel, {
|
|
...callback2(),
|
|
gameMentionsAvailable: autocompleteType === AutocompleteTypes.MENTIONS ? gameMentionsAutocompleteConfig.enabled : void 0
|
|
});
|
|
}
|
|
} else {
|
|
ref2.current = null;
|
|
}
|
|
}, [onChangeAutoCompleteVisibility, activeCommand, memo2, autocompleteType, channel, callback2, gameMentionsAutocompleteConfig.enabled]);
|
|
const windowDimensions_native = useWindowDimensions_native({
|
|
ignoreKeyboard: true
|
|
});
|
|
const insets = useSafeAreaInsetsKeyboardAware_native({
|
|
includeKeyboardHeight: true
|
|
}).insets;
|
|
const r195 = windowDimensions_native.height - insets.top - insets.bottom - NAV_BAR_HEIGHT - state3;
|
|
c18886_42 = r195;
|
|
memo3 = useMemo(() => {
|
|
const r8 = scaledTextLineHeight + 24;
|
|
const r11 = 200 + r8;
|
|
return Math.min(c18886_42, stickerResults.length > 0 ? r11 + r8 + AUTOCOMPLETE_STICKER_NODE_SIZE + 12 + hairlineWidth : autocompleteType !== AutocompleteTypes.EMOJIS_AND_STICKERS ? autocompleteType === AutocompleteTypes.GAME_MENTIONS ? 200 + c18886_12 : 200 : r11);
|
|
}, [autocompleteType, stickerResults.length, r195, scaledTextLineHeight, gameMentionSearchBarHeight]);
|
|
[state, setState4] = useState(null);
|
|
const memo5 = useMemo(() => {
|
|
let r8;
|
|
if (autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS) {
|
|
const length = nonStickerResults.length;
|
|
let r31 = token;
|
|
let r32 = 0;
|
|
if (length !== 0) {
|
|
if (!context) {
|
|
r31 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
|
|
}
|
|
r32 = length * r31 + (length - 1) * hairlineWidth;
|
|
}
|
|
const r41 = hasNonStickerResults ? r32 + (scaledTextLineHeight + 24) : r32;
|
|
let r45 = hasStickerResults;
|
|
const r46 = hasStickerResults ? r41 + (scaledTextLineHeight + 24 + AUTOCOMPLETE_STICKER_NODE_SIZE + 12) : r41;
|
|
if (hasStickerResults) {
|
|
r45 = hasNonStickerResults;
|
|
}
|
|
r8 = r45 ? r46 + hairlineWidth : r46;
|
|
} else if (autocompleteType === AutocompleteTypes.SLASHES || autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY) {
|
|
let r27 = state;
|
|
if (state == null) {
|
|
r27 = 0;
|
|
}
|
|
r8 = r27;
|
|
} else {
|
|
const r16 = autocompleteType != null;
|
|
r8 = 0;
|
|
if (r16) {
|
|
let r17 = token;
|
|
let r0 = 0;
|
|
if (resultCount !== 0) {
|
|
if (!context) {
|
|
r17 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
|
|
}
|
|
r0 = resultCount * r17 + (resultCount - 1) * hairlineWidth;
|
|
}
|
|
r8 = autocompleteType === AutocompleteTypes.GAME_MENTIONS ? r0 + c18886_12 : r0;
|
|
}
|
|
}
|
|
return Math.min(memo2 ? r8 : 0, memo3);
|
|
}, [resultCount, autocompleteType, memo2, hasStickerResults, hasNonStickerResults, nonStickerResults.length, memo3, state, context, token, scaledTextLineHeight, gameMentionSearchBarHeight]);
|
|
chatInputFloating = useMobileVisualRefreshConfig({
|
|
location: "AutocompleteWrapper"
|
|
}).chatInputFloating;
|
|
const r5 = memo5 > 0;
|
|
c18886_47 = r5;
|
|
const token3 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_BORDER_RADIUS);
|
|
const token4 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_BORDER_WIDTH);
|
|
const token5 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_TOP_BORDER_WIDTH);
|
|
const token6 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_MARGIN_HORIZONTAL);
|
|
token2 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_MARGIN_BOTTOM);
|
|
const r263 = r5 ? token4 : 0;
|
|
const r264 = r5 ? token5 : 0;
|
|
L10: {
|
|
if (!r5) {
|
|
const r4 = activeCommand != null;
|
|
r265 = 0;
|
|
if (!r4) {
|
|
break L10;
|
|
}
|
|
r265 = commandsDisabled ? 0 : token2;
|
|
} else {
|
|
r265 = token2;
|
|
}
|
|
}
|
|
styles = useStyles(token3, r263, r264, token6, r265);
|
|
isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
const r280 = isAndroid() || _PlatformUtils.isIOS() && (isScreenReaderEnabled ? isScreenReaderEnabled : chatInputFloating);
|
|
const memo6 = useMemo(() => {
|
|
let r9;
|
|
L4: {
|
|
const isIOS = _PlatformUtils.isIOS();
|
|
r9 = null;
|
|
if (isIOS) {
|
|
if (!isScreenReaderEnabled) {
|
|
r9 = null;
|
|
if (!chatInputFloating) {
|
|
break L4;
|
|
}
|
|
}
|
|
r9 = styles.autocompletePositionRelative;
|
|
}
|
|
}
|
|
return r9;
|
|
}, [isScreenReaderEnabled, chatInputFloating, styles.autocompletePositionRelative]);
|
|
const memo7 = useMemo(() => c18886_47 ? {
|
|
marginTop: token2
|
|
} : void 0, [r5, token2]);
|
|
const styles2 = useAutocompleteAnimatedHeightStyles(memo5, screenIndex);
|
|
callback3 = useCallback((a0, a1, a2) => {
|
|
if (a0.type !== AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL) {
|
|
if (a0.type === AutoCompleteResultTypes.GLOBAL && a0.inlineAutocompleteType === "gameMentionInput") {
|
|
chatInputRef.current.insertText(GAME_MENTION_INPUT_PREFIX, a1, false);
|
|
beginSearch(a1);
|
|
return void 0;
|
|
}
|
|
const autocompleteResultText = getAutocompleteResultText(a0, channel);
|
|
const applicationCommandManager = chatInputRef.current.getApplicationCommandManager();
|
|
const type = a0.type;
|
|
const GAME_MENTION = AutoCompleteResultTypes.GAME_MENTION;
|
|
let r43 = void 0;
|
|
if (type === GAME_MENTION) {
|
|
if (applicationCommandManager != null) {
|
|
applicationCommandManager.addGameMention(a0.game);
|
|
}
|
|
const r14 = applicationCommandManager == null ? void 0 : applicationCommandManager.buildGameMentionNode(a0.game);
|
|
r43 = r14 != null ? [r14] : void 0;
|
|
}
|
|
if (!(applicationCommandManager == null ? void 0 : applicationCommandManager.setAutoCompleteResult(channel.id, autocompleteResultText, a2, a0))) {
|
|
chatInputRef.current.insertText(autocompleteResultText, a1, a0.type !== AutoCompleteResultTypes.STICKER, r43);
|
|
if (a0.type === AutoCompleteResultTypes.STICKER) {
|
|
chatInputRef.current.handleSelectSticker(a0.sticker, a1);
|
|
}
|
|
}
|
|
} else {
|
|
PremiumUpsellUtils.handleShowUpsellAlert({
|
|
initialUpsellKey: UpsellTypes.EMOJI_AUTOCOMPLETE,
|
|
analyticsLocations
|
|
});
|
|
}
|
|
}, [analyticsLocations, beginSearch, channel, chatInputRef]);
|
|
const callback5 = useCallback((a0) => {
|
|
const applicationCommandManager = chatInputRef.current.getApplicationCommandManager();
|
|
if (a0.type === ApplicationCommandOptionType.ATTACHMENT) {
|
|
const r24 = optionStates[a0.name];
|
|
const id = channel.id;
|
|
if (r24.lastValidationResult?.success) {
|
|
openCommandAttachmentPreview(applicationCommandManager, id, a0.name);
|
|
} else if (applicationCommandManager != null) {
|
|
applicationCommandManager.insertOrJumpCommandOption(a0);
|
|
}
|
|
} else {
|
|
const r17 = applicationCommandManager == null ? void 0 : applicationCommandManager.props.text.length;
|
|
if (applicationCommandManager != null) {
|
|
applicationCommandManager.insertOrJumpCommandOption(a0, r17);
|
|
}
|
|
}
|
|
}, [chatInputRef, optionStates, channel]);
|
|
callback4 = useCallback((a0) => {
|
|
iOSTrackAutocompleteSelect(autocompleteType, channel, {
|
|
selectionType: a0.type === AutoCompleteResultTypes.GLOBAL && a0.inlineAutocompleteType === "gameMentionInput" ? AutoCompleteResultTypes.GAME_MENTION : a0.type,
|
|
stickerId: a0.type === AutoCompleteResultTypes.STICKER ? a0.sticker.id : null,
|
|
gameId: a0.type === AutoCompleteResultTypes.GAME_MENTION ? a0.game.id : null,
|
|
...callback2()
|
|
});
|
|
let r35 = autocompleteSelectionStart;
|
|
if (autocompleteSelectionStart == null) {
|
|
r35 = 0;
|
|
}
|
|
callback3(a0, r35, showOptionValuesPicker);
|
|
}, [autocompleteSelectionStart, autocompleteType, callback2, channel, callback3, showOptionValuesPicker]);
|
|
[state2, setState5] = useState(null);
|
|
const callback6 = useCallback(({ item }) => {
|
|
const type = item.type;
|
|
if (AutoCompleteResultTypes.USER === type) {
|
|
return <Autocomplete.User {...item} guildId={channel.guild_id} onPress={() => callback4(item)} />;
|
|
}
|
|
if (AutoCompleteResultTypes.GLOBAL === type) {
|
|
return <Autocomplete.Global {...item} onPress={() => callback4(item)} badge={item.inlineAutocompleteType === "gameMentionInput" ? gameMentionsAutocompleteConfig.showNewTag ? <NewTag containerStyle={styles.newTag} variant="text-xs/bold" color="badge-text-brand" /> : void 0 : void 0} />;
|
|
}
|
|
if (AutoCompleteResultTypes.ROLE === type) {
|
|
return <Autocomplete.Role {...item} onPress={() => callback4(item)} showDescription={autocompleteType === AutocompleteTypes.MENTIONS && activeCommand == null} />;
|
|
}
|
|
if (AutoCompleteResultTypes.CHANNEL === type) {
|
|
return <Autocomplete.Channel {...item} onPress={() => callback4(item)} />;
|
|
}
|
|
if (AutoCompleteResultTypes.EMOJI === type) {
|
|
return <Autocomplete.Emoji {...item} onPress={() => callback4(item)} />;
|
|
}
|
|
if (AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL === type) {
|
|
return <Autocomplete.EmojiPremiumUpsell {...item} onPress={() => callback4(item)} />;
|
|
}
|
|
if (AutoCompleteResultTypes.CHOICE === type) {
|
|
return <Autocomplete.Choice {...item} onPress={() => callback4(item)} />;
|
|
}
|
|
if (AutoCompleteResultTypes.CHOICE_LOADING === type) {
|
|
return <Autocomplete.ChoiceLoading />;
|
|
}
|
|
if (AutoCompleteResultTypes.STICKER === type) {
|
|
const isInteracting = state2 === item.sticker.id;
|
|
return <Autocomplete.Sticker key={`${item.sticker.id}-${isInteracting}`} {...item} onPress={() => callback4(item)} onLongPress={() => setState5(item.sticker.id)} isInteracting={isInteracting} />;
|
|
}
|
|
if (AutoCompleteResultTypes.GAME_MENTION === type) {
|
|
return <Autocomplete.Game {...item} onPress={() => callback4(item)} />;
|
|
}
|
|
if (AutoCompleteResultTypes.LABEL === type) {
|
|
return <Autocomplete.Label {...item} />;
|
|
}
|
|
return null;
|
|
}, [autocompleteType, callback4, state2, channel, activeCommand, gameMentionsAutocompleteConfig.showNewTag, styles]);
|
|
const style = [styles.autocomplete, {
|
|
maxHeight: memo3
|
|
}];
|
|
const style2 = [styles.autocompleteWrapper, r280 ? !r280 : styles.autocompleteWrapperAbsolute, memo6];
|
|
let r336 = autocompleteType != null;
|
|
if (r336) {
|
|
const r345 = [autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY && <ApplicationCommandDiscovery channel={channel} onPressSlashItem={(event, a1, a2) => {
|
|
const r4 = {
|
|
command: event,
|
|
section: a1,
|
|
type: AutoCompleteResultTypes.SLASH,
|
|
visualSection: a2,
|
|
location: ApplicationCommandTriggerLocations.DISCOVERY
|
|
};
|
|
let r18 = autocompleteSelectionStart;
|
|
if (autocompleteSelectionStart == null) {
|
|
r18 = 0;
|
|
}
|
|
callback3(r4, r18);
|
|
}} onHeightChange={setState4} canOnlyUseTextCommands={canOnlyUseTextCommands} />, autocompleteType === AutocompleteTypes.SLASHES && <ApplicationCommandList channel={channel} query={query == null ? "" : query} onPressCommandItem={(event, a1) => {
|
|
const r4 = {
|
|
command: event,
|
|
section: a1,
|
|
type: AutoCompleteResultTypes.SLASH,
|
|
location: ApplicationCommandTriggerLocations.DISCOVERY,
|
|
query
|
|
};
|
|
let r18 = autocompleteSelectionStart;
|
|
if (autocompleteSelectionStart == null) {
|
|
r18 = 0;
|
|
}
|
|
callback3(r4, r18);
|
|
}} style={style} ItemSeparatorComponent={getItemSeparator} getItemLayout={_AutocompleteUtils.getItemLayout} onCommandsChange={(event) => {
|
|
let r9 = token;
|
|
let r0 = 0;
|
|
if (event !== 0) {
|
|
if (!context) {
|
|
r9 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
|
|
}
|
|
r0 = event * r9 + (event - 1) * hairlineWidth;
|
|
}
|
|
setState4(r0);
|
|
}} />, , , ,];
|
|
let r361 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS;
|
|
if (r361) {
|
|
let r362 = hasStickerResults;
|
|
if (hasStickerResults) {
|
|
r362 = <>
|
|
{[<View style={[styles.sectionTitle, {
|
|
height: scaledTextLineHeight
|
|
}]}>
|
|
<Text variant={variant}>
|
|
{intl.format(t.uferGG, {
|
|
prefix: query
|
|
})}
|
|
</Text>
|
|
</View>, <FlatList horizontal style={{
|
|
...style,
|
|
...styles.stickersAutocompleteList
|
|
}} keyExtractor={(item) => item.sticker.id} data={stickerResults} renderItem={callback6} showsHorizontalScrollIndicator={false} getItemLayout={getStickersItemLayout} contentInset={{
|
|
right: 12
|
|
}} />]}
|
|
</>;
|
|
}
|
|
const r398 = [r362, , ,];
|
|
if (hasStickerResults) {
|
|
hasStickerResults2 = hasNonStickerResults;
|
|
}
|
|
if (hasStickerResults2) {
|
|
hasStickerResults2 = <FormDivider style={styles.sectionDivider} />;
|
|
}
|
|
r398[1] = hasStickerResults2;
|
|
if (hasNonStickerResults) {
|
|
hasNonStickerResults2 = <View style={[styles.sectionTitle, {
|
|
height: scaledTextLineHeight
|
|
}]}>
|
|
<Text variant={variant}>
|
|
{intl.format(t.ksAVYt, {
|
|
prefix: `${EMOJI_SENTINEL}${query}`
|
|
})}
|
|
</Text>
|
|
</View>;
|
|
}
|
|
r398[2] = hasNonStickerResults2;
|
|
r361 = <>{r398}</>;
|
|
}
|
|
r345[2] = r361;
|
|
r345[3] = autocompleteType === AutocompleteTypes.GAME_MENTIONS && <GameMentionSearchBar />;
|
|
r345[4] = <FlatList style={style} keyExtractor={(item, index) => String(index)} data={nonStickerResults} renderItem={callback6} ItemSeparatorComponent={getItemSeparator} getItemLayout={_AutocompleteUtils.getItemLayout} />;
|
|
r336 = <>{r345}</>;
|
|
}
|
|
return <View style={styles.autocompletePositionRelative}>
|
|
<View style={style2}>
|
|
<ReanimatedRexport.View style={[styles.autocompleteContainer, styles2]}>{r336}</ReanimatedRexport.View>
|
|
{activeCommand != null && !commandsDisabled && <View style={memo7}>
|
|
<ApplicationCommandBar command={activeCommand} section={activeSection} guildId={channel.guild_id} onPressOption={callback5} currentOption={activeOption} optionStates={optionStates} />
|
|
</View>}
|
|
</View>
|
|
</View>;
|
|
});
|
|
r73.displayName = "AutocompleteWrapper";
|
|
const r76 = Module19.memo(r73);
|
|
export default r76;
|