// Metro module 9578 (f9579).
import { StyleSheet } from "react-native";
import { isGuildSelectableChannelType } from "../../../records/ChannelRecord";
import GuildChannelStore from "../../../stores/GuildChannelStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import UserStore from "../../../stores/UserStore";
import { AutoCompleteResultTypes, WHITESPACE_RE } from "../../../Constants";
import { AUTOCOMPLETE_EMOJI_ROW_HEIGHT, AUTOCOMPLETE_ROW_HEIGHT } from "../../application_commands/native/ApplicationCommandsConstants";
import { CHANNEL_SENTINEL, EMOJI_SENTINEL, GAME_MENTION_SENTINEL, MENTION_SENTINEL } from "../../channel_autocomplete/ChannelAutocompleteConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { escapeChannelName, computeChannelName } from "../../channel/useChannelName";
import AutocompleteUtils from "../../../utils/AutocompleteUtils";
import UserUtils from "../../../utils/UserUtils";
import FormDivider from "../../../design/void/Form/native/FormDivider";
let hairlineWidth, useStyles;
const AutocompleteFormDivider = function AutocompleteFormDivider() {
return ;
};
hairlineWidth = StyleSheet.hairlineWidth;
useStyles = createStyles({
itemDivider: {
marginLeft: 16,
backgroundColor: Module712.colors.BORDER_SUBTLE
}
});
export function getItemLayout(a0, a1) {
const length = (a0 == null ? void 0 : a0[a1]?.type) === AutoCompleteResultTypes.EMOJI ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
return {
length,
offset: a1 * length + Math.max(0, (a1 - 1) * hairlineWidth),
index: a1
};
}
export function getAutocompleteResultText(a0, a1, a2) {
if (a2 != null && !a2.has(a0.type)) {
return "";
}
const type = a0.type;
if (AutoCompleteResultTypes.USER === type) {
const user = a0.user;
return AutocompleteUtils.hasSameRoleAsUsername(a1, user) ? `${MENTION_SENTINEL}${user.tag}` : `${MENTION_SENTINEL}${UserUtils.getUserTag(user)}`;
}
if (AutoCompleteResultTypes.GLOBAL === type) {
return a0.text;
}
if (AutoCompleteResultTypes.ROLE === type) {
return `${MENTION_SENTINEL}${a0.name}`;
}
if (AutoCompleteResultTypes.CHANNEL === type) {
if (a0.channel.isThread()) {
return `#"${escapeChannelName(computeChannelName(a0.channel, UserStore, RelationshipStore))}"`;
}
const guildId = a0.channel.getGuildId();
if (guildId != null && isGuildSelectableChannelType(a0.channel.type)) {
let r82 = GuildChannelStore.getTextChannelNameDisambiguations(guildId)[a0.channel.id]?.name;
if (r82 == null) {
r82 = computeChannelName(a0.channel, UserStore, RelationshipStore);
}
return `${CHANNEL_SENTINEL}${r82}`;
}
return `${CHANNEL_SENTINEL}${computeChannelName(a0.channel, UserStore, RelationshipStore)}`;
}
if (AutoCompleteResultTypes.GAME_MENTION === type) {
return `${GAME_MENTION_SENTINEL}${a0.game.name}`;
}
if (AutoCompleteResultTypes.EMOJI === type) {
return `${EMOJI_SENTINEL}${a0.name}:`;
}
if (AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL !== type && AutoCompleteResultTypes.SLASH !== type) {
if (AutoCompleteResultTypes.CHOICE === type) {
return `${a0.choice.displayName}`;
}
if (AutoCompleteResultTypes.STICKER !== type && AutoCompleteResultTypes.CHOICE_LOADING !== type && AutoCompleteResultTypes.LABEL !== type) {
return void 0;
}
return "";
}
return "";
}
export function getMentionTextWithUser(a0, a1) {
return AutocompleteUtils.hasSameRoleAsUsername(a0, a1) ? `${MENTION_SENTINEL}${a1.tag}` : `${MENTION_SENTINEL}${UserUtils.getUserTag(a1)}`;
}
export function getItemSeparator() {
return ;
}
export function getPrefix(a0) {
return a0[0];
}
export function getQuery(a0) {
return a0.slice(1).toLowerCase();
}
export function isWhitespaceSeparatingBoundary(a0, a1) {
return a1 === 0 || WHITESPACE_RE.test(a0[a1 - 1]);
}
export function isUnbrokenRun(a0, a1, a2) {
return !WHITESPACE_RE.test(a0.slice(a1, a2));
}