decord/source/modules/application_commands/native/ContextMenuCommandRootScreen.tsx
2026-08-03 11:20:01 +00:00

292 lines
11 KiB
TypeScript

// Module ID: 15782
// Function ID: 15783
// Name: ContextMenuCommandRootScreen
// Dependencies: [32, 19, 17, 1862, 4689, 21, 4255, 712, 589, 8365, 8146, 8360, 5281, 9013, 10068, 1236, 4251, 15783, 5891, 9422, 2]
// Exports: default
// Module 15782 (ContextMenuCommandRootScreen)
import _slicedToArray from "_slicedToArray";
import module_9422 from "module_9422";
import { View } from "ContextMenuCommandItem";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import TRUE_OPTION_NAME from "TRUE_OPTION_NAME";
import jsxProd from "jsxProd";
import createCacheKey from "createCacheKey";
let c10;
let c9;
let closure_12;
let metroImportAll;
let unpackModuleId;
const require = arg1;
({ CONTEXT_MENU_COMMANDS_QUERY_LIMIT: metroImportAll, BuiltInSectionId: c9 } = TRUE_OPTION_NAME);
({ jsx: c10, Fragment: unpackModuleId, jsxs: closure_12 } = jsxProd);
createCacheKey = { content: null, sectionHeader: null };
createCacheKey = { paddingHorizontal: require("Themes").space.PX_16 };
createCacheKey[0] = createCacheKey;
createCacheKey[1] = { paddingTop: require("Themes").space.PX_16, paddingBottom: require("Themes").space.PX_8, backgroundColor: require("Themes").colors.MOBILE_ACTIONSHEET_BACKGROUND };
createCacheKey = createCacheKey.createStyles(createCacheKey);
let obj1 = { paddingTop: require("Themes").space.PX_16, paddingBottom: require("Themes").space.PX_8, backgroundColor: require("Themes").colors.MOBILE_ACTIONSHEET_BACKGROUND };
const result = require("get ActivityIndicator").fileFinishedImporting("modules/application_commands/native/ContextMenuCommandRootScreen.tsx");
export default function ContextMenuCommandRootScreen(navigation) {
navigation = navigation.navigation;
const params = navigation.route.params;
const channel = params.channel;
const commandTargetId = params.commandTargetId;
const onPressAppCommand = params.onPressAppCommand;
const onClose = params.onClose;
let stateFromStores;
let closure_6;
let c7;
let commands;
let commandsByActiveSection;
let sectionDescriptors;
let loading;
let sections;
let callback;
let callback1;
let frecencyItems;
let appItems;
let memo1;
let c18;
let c19;
let scaledTextLineHeight;
let obj = navigation(onPressAppCommand[8]);
let items = [c7];
stateFromStores = obj.useStateFromStores(items, () => _undefined.getGuild(channel.guild_id));
let obj1 = stateFromStores;
closure_6 = stateFromStores.useRef(false);
const tmp4 = onClose(stateFromStores.useState(""), 2);
const first = tmp4[0];
c7 = tmp6;
let items1 = [navigation, onClose];
const effect = stateFromStores.useEffect(() => navigation.addListener("beforeRemove", () => {
if (!ref.current) {
if (_slicedToArray != null) {
tmp();
}
}
}), items1);
let obj2 = commandTargetId(onPressAppCommand[9]);
obj = { context: { channel, type: "channel" }, filters: null, options: null, allowFetch: true };
let tmp8;
if ("" !== first) {
tmp8 = first;
}
let items2 = [params.commandType];
obj[1] = { text: tmp8, commandTypes: items2 };
obj = { limit: commands, includeFrecency: !tmp6, scoreMethod: null };
let prop;
if ("" !== first) {
prop = tmp(tmp2[10]).ScoreMethod.COMMAND_OR_APPLICATION;
}
obj[2] = prop;
obj[2] = obj;
const discovery = obj2.useDiscovery(obj);
commands = discovery.commands;
commandsByActiveSection = discovery.commandsByActiveSection;
sectionDescriptors = discovery.sectionDescriptors;
loading = discovery.loading;
let items3 = [sectionDescriptors];
sections = obj1.useMemo(() => {
const sections = {};
const item = sectionDescriptors.forEach((id) => {
sections[id.id] = id;
});
return { sections };
}, items3).sections;
let items4 = [channel, commandTargetId, stateFromStores, navigation, onPressAppCommand];
callback = obj1.useCallback((command) => {
if (onPressAppCommand != null) {
tmp();
}
closure_6.current = true;
obj = { command, optionValues: {}, context: obj, commandTargetId };
obj = { channel, guild: stateFromStores };
channel(onPressAppCommand[11])(obj);
let parent = navigation.getParent();
if (parent == null) {
parent = navigation;
}
parent.goBack();
}, items4);
let items5 = [commandsByActiveSection, navigation, callback];
callback1 = obj1.useCallback((section) => {
const navigation = section;
const found = commandsByActiveSection.find((section) => section.section.id === section.id);
let data;
if (found != null) {
data = found.data;
}
if (data == null) {
data = [];
}
navigation.navigate("app", { section, commands: data, onPressCommand: callback });
}, items5);
const items6 = [loading, commands.length, commandsByActiveSection];
const memo = obj1.useMemo(() => {
if (!loading) {
if (0 !== commands.length) {
const found = commandsByActiveSection.find((section) => section.section.id === constants.FRECENCY);
const found1 = commandsByActiveSection.filter((section) => section.section.id !== constants.FRECENCY);
let mapped;
if (found != null) {
const data = found.data;
mapped = data.map((command) => ({ type: "command", command }));
}
if (mapped == null) {
mapped = [];
}
const obj = { frecencyItems: null, appItems: null };
obj[0] = mapped;
obj[1] = found1.map((section) => ({ type: "app", section: section.section }));
return obj;
}
}
return { frecencyItems: [], appItems: [] };
}, items6);
frecencyItems = memo.frecencyItems;
appItems = memo.appItems;
const items7 = [loading, commands, "" !== first, frecencyItems, appItems];
memo1 = obj1.useMemo(() => {
if (loading) {
const items = [{ type: "placeholder" }];
const items1 = [items];
return items1;
} else {
let arr = commands;
if (0 === commands.length) {
const items2 = [{ type: "no_commands" }];
const items3 = [items2];
return items3;
} else if (c7) {
const items4 = [arr.map((command) => ({ type: "command", command }))];
return items4;
} else {
const items5 = [];
if (frecencyItems.length > 0) {
arr = items5.push(tmp2);
}
if (appItems.length > 0) {
arr = items5.push(tmp4);
}
return items5;
}
}
}, items7);
const items8 = [memo1];
const memo2 = obj1.useMemo(() => memo1.map((arg0) => arg0.length), items8);
const tmp18 = callback();
c18 = tmp18;
c19 = "text-sm/semibold";
const tmp16 = channel(onPressAppCommand[13])();
scaledTextLineHeight = navigation(onPressAppCommand[14]).useScaledTextLineHeight("text-sm/semibold");
const items9 = [loading, commands.length, "" !== first, frecencyItems.length, tmp18.sectionHeader];
const items10 = [memo1, callback, callback1, sections];
const callback2 = obj1.useCallback((arg0) => {
if (!loading) {
if (0 !== commands.length) {
if (!c7) {
if (0 === arg0) {
if (frecencyItems.length > 0) {
const intl2 = navigation(onPressAppCommand[15]).intl;
let stringResult = intl2.string(navigation(onPressAppCommand[15]).t.V0w2ap);
}
const obj = { variant: null, color: "text-default", style: null, children: null };
obj[0] = c19;
obj[2] = _undefined2.sectionHeader;
obj[3] = stringResult;
return sectionDescriptors(navigation(onPressAppCommand[16]).Text, obj);
}
const intl = navigation(onPressAppCommand[15]).intl;
stringResult = intl.string(navigation(onPressAppCommand[15]).t.PHjkRE);
}
}
}
return null;
}, items9);
const items11 = [loading, commands.length, "" !== first, scaledTextLineHeight, tmp18.sectionHeader.paddingTop, tmp18.sectionHeader.paddingBottom];
const callback3 = obj1.useCallback((arg0, arg1) => {
const navigation = tmp;
const type = tmp.type;
if ("placeholder" === type) {
let obj = { start: null, end: null };
obj[0] = tmp2;
obj[1] = tmp3;
return sectionDescriptors(navigation(onPressAppCommand[17]).ContextMenuCommandLoadingItem, obj, "placeholder");
} else if ("no_commands" === type) {
obj = { start: null, end: null };
obj[0] = tmp2;
obj[1] = tmp3;
return sectionDescriptors(navigation(onPressAppCommand[17]).ContextMenuCommandEmptyItem, obj, "no_commands");
} else if ("command" === type) {
const obj1 = { item: null, onPress: null, section: null, start: null, end: null };
obj1[0] = tmp.command;
obj1[1] = function onPress() {
return outer1_13(tmp.command);
};
obj1[2] = sections[tmp.command.applicationId];
obj1[3] = tmp2;
obj1[4] = tmp3;
return sectionDescriptors(channel(onPressAppCommand[17]), obj1, tmp.command.id);
} else if ("app" === type) {
obj = { section: null, onPress: null, start: null, end: null };
obj[0] = tmp.section;
obj[1] = function onPress() {
return outer1_14(tmp.section);
};
obj[2] = tmp2;
obj[3] = tmp3;
return sectionDescriptors(navigation(onPressAppCommand[17]).ContextMenuCommandAppItem, obj, tmp.section.id);
}
}, items10);
let tmp27Result = tmp6;
const memo3 = obj1.useMemo(() => {
let num = 0;
if (!loading) {
num = 0;
if (0 !== commands.length) {
num = 0;
if (!c7) {
num = scaledTextLineHeight + _undefined2.sectionHeader.paddingTop + _undefined2.sectionHeader.paddingBottom;
}
}
}
return num;
}, items11);
if ("" === first) {
let tmp26 = !loading;
if (!loading) {
tmp26 = commands.length > 0;
}
tmp27Result = tmp26;
}
if (tmp27Result) {
const items12 = [tmp18.content, ];
let num2 = 0;
if (tmp6) {
num2 = tmp15(tmp2[7]).space.PX_16;
}
obj1 = { style: null, children: null };
obj2 = { marginBottom: null };
obj2[0] = num2;
items12[1] = obj2;
obj1[0] = items12;
const obj3 = { size: "md", onChange: null, placeholder: null };
obj3[1] = tmp4[1];
let intl = tmp(tmp2[15]).intl;
obj3[2] = intl.string(tmp(tmp2[15]).t.m1UwbP);
obj1[1] = sectionDescriptors(tmp(tmp2[18]).SearchField, obj3);
tmp27Result = tmp27(closure_6, obj1);
const tmp28 = closure_6;
}
const obj4 = { children: null };
const items13 = [tmp27Result, ];
const tmp23 = sections;
const tmp24 = loading;
const tmpResult = navigation(onPressAppCommand[14]);
items13[1] = sectionDescriptors(channel(onPressAppCommand[19]), { sections: memo2, estimatedListSize: "windowSize", itemSize: tmp16, insetEnd: channel(onPressAppCommand[12])({ includeKeyboardHeight: true }).insets.bottom, renderItem: callback3, renderSectionHeader: callback2, sectionHeaderSize: memo3, style: tmp18.content });
obj4[0] = items13;
return tmp23(tmp24, obj4);
};