/* Metro module 15228; source: modules/application_commands/native/ContextMenuCommandRootScreen.tsx; dependencies: [57, 31, 27, 1867, 5066, 33, 4501, 697, 566, 8060, 7869, 8050, 5463, 7705, 8518, 1244, 4573, 15229, 6984, 8671, 2] */
function _fun116484(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#116484, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:6, offset: 0x0248b271, size: 384 bytes, params: 8, frame: 22
var object2;
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_4 = importDefault(57) /* metro dependency 57 */;
const env0_5 = importAll(31) /* metro dependency 31 */;
const env0_6 = (require(27) /* metro dependency 27 */).View;
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
let value = require(5066) /* metro dependency 5066: ApplicationCommandConstants */;
const env0_8 = value.CONTEXT_MENU_COMMANDS_QUERY_LIMIT;
const env0_9 = value.BuiltInSectionId;
value = require(33) /* metro dependency 33 */;
const env0_10 = value.jsx;
const env0_11 = value.jsxs;
value = require(4501) /* metro dependency 4501: createStyles */;
const createStyles = value.createStyles;
object2 = {};
let PX_16 = (importDefault(697) /* metro dependency 697: native */).space.PX_16;
object2.container = {flex: 1, marginHorizontal: PX_16};
const object4 = {};
PX_16 = (importDefault(697) /* metro dependency 697: native */).space.PX_16;
object4.paddingTop = PX_16;
const PX_8 = (importDefault(697) /* metro dependency 697: native */).space.PX_8;
object4.paddingBottom = PX_8;
const BACKGROUND_BASE_LOWER = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWER;
object4.backgroundColor = BACKGROUND_BASE_LOWER;
object2.sectionHeader = object4;
const env0_12 = Reflect.apply(createStyles, value, [object2]);
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/application_commands/native/ContextMenuCommandRootScreen.tsx');
exports.default = ContextMenuCommandRootScreen;
}
function ContextMenuCommandRootScreen(a0) { // fn#116485, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:568, offset: 0x0248b3f1, size: 1323 bytes, params: 2, frame: 32
var object10;
var object2;
var object3;
var SearchField;
var object8;
var intl;
const navigation = a0.navigation;
const {channel, commandType, commandTargetId, onPressAppCommand, onClose} = a0.route.params;
const env0_4 = onClose;
const value = undefined;
const guild = (require(566) /* metro dependency 566: flux */).useStateFromStores([GuildStore], function() {
return GuildStore.getGuild(channel.guild_id);
});
const env0_5 = guild;
let binding = env0_5;
const env0_6 = binding.useRef(false);
const value4 = env0_4(binding.useState(''), 2);
const value5 = 0;
const property = value4[value5];
const property2 = value4[1];
const value6 = property !== '';
binding.useEffect(function() {
return navigation.addListener('beforeRemove', _fun116488);
}, [navigation, onClose]);
const applicationCommandQueryApiModule = importAll(8060) /* metro dependency 8060: ApplicationCommandQueryApi */;
const useDiscovery = applicationCommandQueryApiModule.useDiscovery;
object10 = {context: {channel: channel, type: 'channel'}};
object10.filters = {text: value6 ? property : value, commandTypes: [commandType]};
const object9 = {};
object9.limit = CONTEXT_MENU_COMMANDS_QUERY_LIMIT;
object9.includeFrecency = !value6;
const COMMAND_OR_APPLICATION = value6 ? (require(7869) /* metro dependency 7869: ApplicationCommandQueryTypes */).ScoreMethod.COMMAND_OR_APPLICATION : value;
object9.scoreMethod = COMMAND_OR_APPLICATION;
object10.options = object9;
object10.allowFetch = true;
const {commands, commandsByActiveSection, sectionDescriptors, loading} = Reflect.apply(useDiscovery,
applicationCommandQueryApiModule, [object10]);
binding = env0_5;
const useMemo = binding.useMemo;
const sections = Reflect.apply(useMemo, binding, [function() {
sectionDescriptors.forEach(_fun116490);
return {sections: {}};
}, [sectionDescriptors]]).sections;
const value8 = binding.useCallback(_fun116491, [channel, commandTargetId, guild, navigation, onPressAppCommand]);
const value9 = binding.useCallback(_fun116492, [commandsByActiveSection, navigation, value8]);
const value10 = binding.useMemo(_fun116494, [loading, commands.length, commandsByActiveSection]);
const frecencyItems = value10.frecencyItems;
const value11 = binding.useMemo(_fun116499, [loading, commands, value6, frecencyItems, value10.appItems]);
const insets = (importDefault(5463) /* metro dependency 5463: useSafeAreaInsetsKeyboardAwareNative */)({includeKeyboardHeight: true}).insets;
const value12 = (importDefault(7705) /* metro dependency 7705: useScaledRowHeight */)();
const value13 = binding.useMemo(_fun116501, [value11]);
const styles = useStyles();
const value14 = (require(8518) /* metro dependency 8518: useScaledTextLineHeightAndroid */).useScaledTextLineHeight('text-sm/semibold');
const value15 = binding.useCallback(_fun116503, [loading, commands.length, value6, frecencyItems.length,
styles.sectionHeader]);
const value16 = binding.useCallback(_fun116504, [value11, value8, value9, sections]);
const value17 = binding.useMemo(_fun116507, [loading, commands.length, value6, value14,
styles.sectionHeader.paddingTop, styles.sectionHeader.paddingBottom]);
let r6 = value6 || !loading && commands.length > value5;
if (r6) {
object2 = {};
object3 = {};
object3.marginBottom = value6 ? (importDefault(697) /* metro dependency 697: native */).space.PX_16 : value5;
object2.style = object3;
SearchField = (require(6984) /* metro dependency 6984: SearchFieldNative */).SearchField;
object8 = {size: 'md', onChange: property2};
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
object8.placeholder = intl.string((require(1244) /* metro dependency 1244: indexNative */).t.m1UwbP);
r6 = ;
}
return (
{r6}
{((Component) => )(importDefault(8671) /* metro dependency 8671: FastestListAndroid */)}
);
}
function _fun116487() { // fn#116487, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:855, offset: 0x0248b93c, size: 34 bytes, params: 1, frame: 13
return navigation.addListener('beforeRemove', _fun116488);
}
function _fun116489() { // fn#116489, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:1242, offset: 0x0248b988, size: 41 bytes, params: 1, frame: 12
sectionDescriptors.forEach(_fun116490);
return {sections: {}};
}
function _fun116491(a0) { // fn#116491, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:1337, offset: 0x0248b9b1, size: 147 bytes, params: 2, frame: 15
if (onPressAppCommand != null) {
onPressAppCommand();
}
env0_6.current = true;
(importDefault(8050) /* metro dependency 8050: executeCommand */)({command: a0, optionValues: {},
context: {channel: channel, guild: guild}, commandTargetId: commandTargetId});
(navigation.getParent() ?? navigation).goBack();
}
function _fun116492(a0) { // fn#116492, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:1528, offset: 0x0248ba44, size: 103 bytes, params: 2, frame: 16
const env0_0 = a0;
const value2 = commandsByActiveSection.find(_fun116493);
const value3 = undefined;
const r5 = (value2 == null ? value3 : value2.data) ?? [];
const navigationBinding = navigation;
navigationBinding.navigate('app', {section: a0, commands: r5, onPressCommand: env0_13});
return value3;
}
function _fun116494() { // fn#116494, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:1696, offset: 0x0248baab, size: 167 bytes, params: 1, frame: 16
var r2;
var object2;
var value;
if (loading) {
object2 = {frecencyItems: [], appItems: []};
} else {
if (commands.length === 0) {
return {frecencyItems: [], appItems: []};
}
var value2 = commandsByActiveSection.find(function(a0) {
return a0.section.id === BuiltInSectionId.FRECENCY;
});
value = commandsByActiveSection.filter(function(a0) {
return a0.section.id !== BuiltInSectionId.FRECENCY;
});
object2 = {};
r2 = value2 == null ? undefined : value2.data.map(function(a0) {
return {type: 'command', command: a0};
});
r2 = r2 ?? [];
object2.frecencyItems = r2;
object2.appItems = value.map(function({section}) {
return {type: 'app', section: section};
});
}
return object2;
}
function _fun116499() { // fn#116499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:2077, offset: 0x0248bbc2, size: 186 bytes, params: 1, frame: 13
var object;
if (loading) {
object = {type: 'placeholder'};
object = [[object]];
} else {
var length = commands.length;
if (length === 0) {
object = {type: 'no_commands'};
object = [[object]];
return object;
}
if (result) {
return [commands.map(function(a0) {
return {type: 'command', command: a0};
})];
}
object = [];
length = frecencyItems.length;
if (length > 0) {
object.push(frecencyItems);
}
length = appItems.length;
if (length > 0) {
object.push(appItems);
}
}
return object;
}
function _fun116501() { // fn#116501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:2368, offset: 0x0248bc7c, size: 28 bytes, params: 1, frame: 11
return env0_17.map(function(a0) {
return a0.length;
});
}
function _fun116503(a0) { // fn#116503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:2481, offset: 0x0248bc98, size: 269 bytes, params: 2, frame: 17
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
if (loading) {
return null;
}
if (commands.length === 0) {
return null;
}
if (result) {
return null;
}
const r4 = a0 !== 0 ? intl.string((require(1244) /* metro dependency 1244: indexNative */).t.PHjkRE) : frecencyItems.length > 0 ? intl.string((require(1244) /* metro dependency 1244: indexNative */).t.V0w2ap) : intl.string((require(1244) /* metro dependency 1244: indexNative */).t.PHjkRE);
const Text = (require(4573) /* metro dependency 4573: Text */).Text;
return (
{r4}
);
}
function _fun116504(a0, a1) { // fn#116504, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:2773, offset: 0x0248bda5, size: 405 bytes, params: 3, frame: 22
var environment;
var ContextMenuCommandAppItem;
var object2;
var section;
var value4;
var ContextMenuCommandItem;
var command;
var sectionsBinding;
const property = env0_17[a0][a1];
const value2 = a1 === 0;
const value3 = a1 === env0_17[a0].length - 1;
const type = property.type;
if (type === 'placeholder') {
value = environment.__proto__;
const ContextMenuCommandLoadingItem = (require(15229) /* metro dependency 15229: ContextMenuCommandItem */).ContextMenuCommandLoadingItem;
return (
);
}
if (type === 'no_commands') {
value = environment.__proto__;
const ContextMenuCommandEmptyItem = (require(15229) /* metro dependency 15229: ContextMenuCommandItem */).ContextMenuCommandEmptyItem;
return (
);
}
if (type === 'command') {
value4 = environment.__proto__;
ContextMenuCommandItem = importDefault(15229) /* metro dependency 15229: ContextMenuCommandItem */;
object2 = {};
command = property.command;
object2.item = command;
object2.onPress = onPress_116505;
sectionsBinding = sections;
command = property.command;
object2.section = sectionsBinding[command.applicationId];
object2.start = value2;
object2.end = value3;
command = property.command;
return ;
}
if (type === 'app') {
value = environment.__proto__;
ContextMenuCommandAppItem = (require(15229) /* metro dependency 15229: ContextMenuCommandItem */).ContextMenuCommandAppItem;
object2 = {};
section = property.section;
object2.section = section;
object2.onPress = onPress_116506;
object2.start = value2;
object2.end = value3;
section = property.section;
return ;
}
}
function _fun116507() { // fn#116507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:3321, offset: 0x0248bf74, size: 84 bytes, params: 1, frame: 4
var r0;
var binding;
var sectionHeader;
var value3;
const loadingBinding = loading;
const value2 = 0;
if (loadingBinding) {
r0 = value2;
} else if (value2 === commands.length) {
r0 = value2;
} else if (result) {
r0 = value2;
} else {
binding = env0_20;
sectionHeader = styles.sectionHeader;
value3 = binding + sectionHeader.paddingTop;
sectionHeader = styles.sectionHeader;
r0 = value3 + sectionHeader.paddingBottom;
}
return r0;
}
function _fun116488() { // fn#116488, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:889, offset: 0x0248b95e, size: 42 bytes, params: 1, frame: 11
if (!(env1_6.current || onClose == null)) {
onClose();
}
}
function onPress_116505() { // fn#116505, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:3086, offset: 0x0248bf3a, size: 29 bytes, params: 1, frame: 11
return env1_13(env0_0.command);
}
function onPress_116506() { // fn#116506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15425:3248, offset: 0x0248bf57, size: 29 bytes, params: 1, frame: 11
return env1_14(env0_0.section);
}