// Module ID: 9725 // Function ID: 9726 // Name: autocompleter/AutocompleteUtils // Dependencies: [19, 17, 2049, 4467, 4479, 1372, 1074, 9726, 5306, 21, 4836, 576, 4989, 5330, 5754, 4678, 8059, 2] // Exports: findAutoInsertOnSpaceToken, findWordStart, getAutocompleteResultText, getItemLayout, getItemSeparator, getMentionTextWithUser, getPrefix, getQuery, isSingleLineRun, isSpaceJustTypedAtCaret, isUnbrokenRun, isWhitespaceSeparatingBoundary // Module 9725 (autocompleter/AutocompleteUtils) import react_native from "react-native" /* 17 */; import Fragment from "Fragment" /* 21 */; import nativeDefault from "native" /* 576 */; import ChannelRecord from "ChannelRecord" /* 2049 */; import useChannelName from "useChannelName" /* 4989 */; import TimestampUtils from "TimestampUtils" /* 5330 */; import AutocompleteUtilsDefault from "AutocompleteUtils" /* 5754 */; import FormDividerDefault from "FormDivider" /* 8059 */; import react from "react" /* 19 */; import GuildChannelStore from "GuildChannelStore" /* 4467 */; import RelationshipStore from "RelationshipStore" /* 4479 */; import UserStore from "UserStore" /* 1372 */; import Constants from "Constants" /* 1074 */; import ApplicationCommandsConstants from "ApplicationCommandsConstants" /* 9726 */; import ChannelAutocompleteConstants from "ChannelAutocompleteConstants" /* 5306 */; import createStyles from "createStyles" /* 4836 */; import size from "module_2" /* 2 */; let c10; let c9; let closure_12; let closure_14; let map1; let metroImportAll; let metroImportDefault; let obj2; let tmp; let unpackModuleId; const UserUtilsDefault = tmp(4678); function AutocompleteFormDivider() { return jsx(FormDividerDefault, { style: closure_17().itemDivider }); } const StyleSheet = react_native.StyleSheet; let closure_3 = ChannelRecord.isGuildSelectableChannelType; ({ AutoCompleteResultTypes: metroImportDefault, WHITESPACE_RE: metroImportAll } = Constants); ({ AUTOCOMPLETE_EMOJI_ROW_HEIGHT: c9, AUTOCOMPLETE_ROW_HEIGHT: c10 } = ApplicationCommandsConstants); ({ CHANNEL_SENTINEL: unpackModuleId, EMOJI_SENTINEL: closure_12, GAME_MENTION_SENTINEL: map1, MENTION_SENTINEL: closure_14 } = ChannelAutocompleteConstants); const jsx = Fragment.jsx; const hairlineWidth = StyleSheet.hairlineWidth; let obj = { itemDivider: obj2 }; obj2 = { marginLeft: 16, backgroundColor: nativeDefault.colors.BORDER_SUBTLE }; let closure_17 = createStyles.createStyles(obj); const re19 = /[\r\n]/; let result = size.fileFinishedImporting("modules/autocompleter/native/AutocompleteUtils.tsx"); export const getItemLayout = function getItemLayout(arg0, index) { let result; let type; if (arg0 != null) { if (arg0[index] != null) { type = tmp2.type; } } const tmp3 = type === metroImportDefault.EMOJI ? React4 : authStore; const obj = { length: tmp3, offset: result + Math.max(0, (index - 1) * hairlineWidth), index }; result = index * tmp3; return obj; }; export const getAutocompleteResultText = function getAutocompleteResultText(type, channel, set) { if (null != set) { if (!set.has(type.type)) { return ""; } } type = type.type; if (metroImportDefault.USER === type) { let combined; const user = type.user; const obj5 = AutocompleteUtilsDefault; const tmp35 = importDefault; if (obj5.hasSameRoleAsUsername(channel, user)) { const _HermesInternal9 = HermesInternal; combined = "" + tmp37 + user.tag; } else { const _HermesInternal8 = HermesInternal; const tmp35Result = tmp35(4678); combined = "" + tmp37 + tmp35Result.getUserTag(user); } return combined; } else if (metroImportDefault.GLOBAL === type) { return type.text; } else if (metroImportDefault.ROLE === type) { const _HermesInternal7 = HermesInternal; return "" + authStore2 + type.name; } else if (metroImportDefault.CHANNEL === type) { channel = type.channel; if (channel.isThread()) { const escapeChannelName = useChannelName.escapeChannelName; useChannelName; const _HermesInternal6 = HermesInternal; const obj4 = useChannelName; return "#\"" + escapeChannelName(obj4.computeChannelName(type.channel, UserStore, RelationshipStore)) + "\""; } else { const channel2 = type.channel; const guildId = channel2.getGuildId(); if (null != guildId) { if (closure_3(type.channel.type)) { const tmp18 = GuildChannelStore.getTextChannelNameDisambiguations(guildId)[type.channel.id]; let name; if (tmp18 != null) { name = tmp18.name; } if (name == null) { const obj3 = useChannelName; name = obj3.computeChannelName(type.channel, UserStore, RelationshipStore); } const _HermesInternal5 = HermesInternal; return "" + unpackModuleId + name; } } const _HermesInternal4 = HermesInternal; const obj2 = useChannelName; return "" + unpackModuleId + obj2.computeChannelName(type.channel, UserStore, RelationshipStore); } } else if (metroImportDefault.GAME_MENTION === type) { const _HermesInternal3 = HermesInternal; return "" + map1 + type.game.name; } else if (metroImportDefault.TIMESTAMP_MENTION === type) { const obj = TimestampUtils; return obj.unparseTimestamp(type.mention.timestamp, type.mention.format); } else if (metroImportDefault.EMOJI === type) { const _HermesInternal2 = HermesInternal; return "" + closure_12 + type.name + ":"; } else { if (metroImportDefault.EMOJI_PREMIUM_UPSELL !== type) { if (metroImportDefault.SLASH !== type) { if (metroImportDefault.CHOICE === type) { const _HermesInternal = HermesInternal; return "" + type.choice.displayName; } else { return ""; } } } return ""; } }; export const getMentionTextWithUser = function getMentionTextWithUser(messageChannel, user) { let combined; const obj = AutocompleteUtilsDefault; if (obj.hasSameRoleAsUsername(messageChannel, user)) { const _HermesInternal2 = HermesInternal; combined = "" + tmp3 + user.tag; } else { const _HermesInternal = HermesInternal; const tmpResult = UserUtilsDefault; combined = "" + tmp3 + tmpResult.getUserTag(user); } return combined; }; export const getItemSeparator = function getItemSeparator() { return ; }; export const getPrefix = function getPrefix(substr1) { return substr1[0]; }; export const getQuery = function getQuery(arr) { const str = arr.slice(1); return str.toLowerCase(); }; export const isWhitespaceSeparatingBoundary = function isWhitespaceSeparatingBoundary(seenText, lastIndexOfResult) { const isMatch = 0 === lastIndexOfResult || metroImportAll.test(seenText[lastIndexOfResult - 1]); return isMatch; }; export const isUnbrokenRun = function isUnbrokenRun(arr, sum, arg2) { return !metroImportAll.test(arr.slice(sum, arg2)); }; export const isSingleLineRun = function isSingleLineRun(arr, sum, arg2) { return !re19.test(arr.slice(sum, arg2)); }; export const findWordStart = function findWordStart(arg0, arg1) { let tmp = arg1; if (arg1 > 0) { let tmp4 = arg1; tmp = arg1; if (!metroImportAll.test(arg0[arg1 - 1])) { const diff = tmp4 - 1; tmp = diff; while (diff > 0) { tmp4 = diff; tmp = diff; if (metroImportAll.test(arg0[diff - 1])) { break; } } } } return tmp; }; export const isSpaceJustTypedAtCaret = function isSpaceJustTypedAtCaret(text, selectionEnd, c22, selectionEnd2) { let sum = selectionEnd2; if (selectionEnd2 === selectionEnd + 1) { if (c22.length === text.length + 1) { if (" " === c22[sum - 1]) { let num = 0; if (0 < selectionEnd) { while (c22[num] === text[num]) { num = num + 1; } return false; } if (sum < c22.length) { while (c22[sum] === text[sum - 1]) { sum = sum + 1; } return false; } return true; } } } return false; }; export const findAutoInsertOnSpaceToken = function findAutoInsertOnSpaceToken(c22, selectionEnd, arg2) { if (selectionEnd >= arg2.length + 2) { if (" " === c22[selectionEnd - 1]) { const diff = selectionEnd - 1; let tmp3 = diff; if (0 < diff) { let tmp2 = diff; tmp3 = diff; if (!metroImportAll.test(c22[diff - 1])) { const diff1 = tmp2 - 1; tmp3 = diff1; while (0 < diff1) { tmp2 = diff1; tmp3 = diff1; if (metroImportAll.test(c22[diff1 - 1])) { break; } } } } if (c22.startsWith(arg2, tmp3)) { if (c22.lastIndexOf(arg2, diff - arg2.length) !== tmp3) { return null; } else { const obj = { tokenStart: tmp3, trigger: c22.slice(tmp3 + arg2.length, diff) }; return obj; } } else { return null; } } } return null; };