decord/source/modules/application_commands/native/ApplicationCommandDiscovery.tsx

405 lines
14 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11961
// Function ID: 11962
2026-07-29 08:29:29 +00:00
// Name: ApplicationCommandDiscovery
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 19, 17, 4838, 11962, 10067, 676, 21, 11963, 4380, 712, 4821, 11964, 9687, 1955, 8502, 1351, 1236, 4588, 12, 11965, 7129, 11966, 11967, 1297, 10138, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-25 06:04:03 +00:00
// Module 11961 (ApplicationCommandDiscovery)
2026-08-24 06:08:38 +00:00
import ThemesDefault from "Themes" /* 712 */;
2026-08-25 06:04:03 +00:00
import PermissionOverwriteType from "PermissionOverwriteType" /* 1955 */;
import getFontScale from "getFontScale" /* 4821 */;
import ScoreMethod from "ScoreMethod" /* 8502 */;
import useCommandDiscoveryManager from "useCommandDiscoveryManager" /* 11964 */;
2026-08-24 06:08:38 +00:00
import closure_4 from "_slicedToArray" /* 32 */;
import closure_5 from "noop" /* 19 */;
import get_ActivityIndicator from "get ActivityIndicator" /* 17 */;
2026-08-25 06:04:03 +00:00
import TRUE_OPTION_NAME from "TRUE_OPTION_NAME" /* 4838 */;
import { ITEM_HEIGHT } from "ICON_SIZE" /* 11962 */;
import { AUTOCOMPLETE_ROW_HEIGHT } from "AUTOCOMPLETE_ROW_HEIGHT" /* 10067 */;
2026-08-24 06:08:38 +00:00
import ME from "ME" /* 676 */;
import jsxProd from "jsxProd" /* 21 */;
2026-08-25 06:04:03 +00:00
import createCacheKey from "createCacheKey" /* 4380 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-29 08:29:29 +00:00
({ View: closure_6, SectionList: error } = get_ActivityIndicator);
2026-08-24 06:08:38 +00:00
({ BuiltInSectionId: closure_8, DISCOVERY_COMMANDS_QUERY_LIMIT: c9 } = TRUE_OPTION_NAME);
2026-07-29 08:29:29 +00:00
({ AnalyticEvents: closure_12, SectionListElementType: map1 } = ME);
2026-07-23 10:11:24 +00:00
({ jsx: closure_14, Fragment: closure_15, jsxs: closure_16 } = jsxProd);
2026-07-29 08:29:29 +00:00
createCacheKey = { discoveryWrapper: { flex: 1 }, noCommandsImage: { height: 50, width: 50, marginBottom: 16 }, noCommandsContainer: { padding: 0, height: 100 }, commandsList: null };
2026-08-24 06:08:38 +00:00
createCacheKey = { backgroundColor: ThemesDefault.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND };
2026-07-29 08:29:29 +00:00
createCacheKey[3] = createCacheKey;
2026-08-24 06:08:38 +00:00
let closure_17 = createCacheKey.createStyles(createCacheKey);
let result = require("set").fileFinishedImporting("modules/application_commands/native/ApplicationCommandDiscovery.tsx");
2026-07-20 16:05:17 +00:00
export default function ApplicationCommandDiscovery(channel) {
2026-07-23 10:11:24 +00:00
({ onPressSlashItem: require, onHeightChange } = channel);
2026-07-20 16:05:17 +00:00
channel = channel.channel;
const canOnlyUseTextCommands = channel.canOnlyUseTextCommands;
2026-08-24 06:08:38 +00:00
dependencyMap = undefined;
2026-07-29 08:29:29 +00:00
let bound;
let ref;
let first;
2026-08-24 06:08:38 +00:00
closure_7 = undefined;
closure_8 = undefined;
2026-07-29 08:29:29 +00:00
let commandDiscoveryManager;
2026-07-23 10:11:24 +00:00
let sectionDescriptors;
c11 = undefined;
2026-07-20 16:05:17 +00:00
commandsByActiveSection = undefined;
2026-07-23 10:11:24 +00:00
c13 = undefined;
2026-07-20 16:05:17 +00:00
filteredSectionId = undefined;
2026-07-23 10:11:24 +00:00
c15 = undefined;
2026-07-20 16:05:17 +00:00
filterSection = undefined;
2026-07-23 10:11:24 +00:00
let callback;
let memo;
2026-08-24 06:08:38 +00:00
closure_19 = undefined;
2026-07-23 10:11:24 +00:00
let tmp = callback();
2026-07-29 08:29:29 +00:00
dependencyMap = tmp;
2026-08-24 06:08:38 +00:00
let obj = getFontScale;
2026-07-29 08:29:29 +00:00
bound = Math.max(obj.useFontScale() * c11, c11);
2026-08-24 06:08:38 +00:00
obj1 = ref;
2026-07-23 10:11:24 +00:00
ref = ref.useRef(null);
2026-07-29 08:29:29 +00:00
let tmp4 = bound(ref.useState(0), 2);
first = tmp4[0];
2026-08-24 06:08:38 +00:00
closure_7 = tmp6;
2026-07-29 08:29:29 +00:00
closure_8 = ref.useRef(false);
2026-08-24 06:08:38 +00:00
let obj2 = useCommandDiscoveryManager;
2026-07-29 08:29:29 +00:00
commandDiscoveryManager = obj2.useCommandDiscoveryManager((initialSectionId) => initialSectionId.initialSectionId);
2026-08-25 06:04:03 +00:00
let obj3 = channel(9687);
2026-07-29 08:29:29 +00:00
obj = { context: { channel, type: "channel" }, filters: null, options: null, allowFetch: true };
obj = { commandTypes: null, builtIns: null, applicationCommands: null };
2026-08-24 06:08:38 +00:00
let items = [PermissionOverwriteType.ApplicationCommandType.CHAT];
2026-07-29 08:29:29 +00:00
obj[0] = items;
2026-08-24 06:08:38 +00:00
const BuiltInCommandFilter = ScoreMethod.BuiltInCommandFilter;
2026-07-29 08:29:29 +00:00
obj[1] = canOnlyUseTextCommands ? BuiltInCommandFilter.ONLY_TEXT : BuiltInCommandFilter.ALLOW;
obj[2] = !canOnlyUseTextCommands;
obj[1] = obj;
2026-07-23 10:11:24 +00:00
obj1 = { placeholderCount: 3, limit: commandDiscoveryManager, includeFrecency: true };
2026-07-29 08:29:29 +00:00
obj[2] = obj1;
const discovery = obj3.useDiscovery(obj);
2026-07-23 10:11:24 +00:00
sectionDescriptors = discovery.sectionDescriptors;
({ activeSections: c11, commandsByActiveSection } = discovery);
({ hasMoreAfter: c13, filteredSectionId } = discovery);
({ scrollDown: c15, filterSection } = discovery);
const items1 = [filterSection, commandDiscoveryManager, tmp4[1], sectionDescriptors];
2026-07-29 08:29:29 +00:00
const effect = obj1.useEffect(() => {
2026-07-20 16:05:17 +00:00
if (null != commandDiscoveryManager) {
2026-07-29 08:29:29 +00:00
filterSection(tmp);
const findIndexResult = sectionDescriptors.findIndex((id) => id.id === closure_9);
2026-07-20 16:05:17 +00:00
let num2 = 0;
if (-1 !== findIndexResult) {
num2 = findIndexResult;
}
2026-08-24 06:08:38 +00:00
closure_7(num2);
const tmp6 = closure_7;
2026-07-20 16:05:17 +00:00
}
}, items1);
2026-07-29 08:29:29 +00:00
const effect1 = obj1.useEffect(() => {
2026-08-24 06:08:38 +00:00
const AccessibilityAnnouncer = callback(1351).AccessibilityAnnouncer;
const intl = callback(1236).intl;
AccessibilityAnnouncer.announce(intl.string(callback(1236).t["2wfLMm"]));
2026-08-25 06:04:03 +00:00
callback(4588).trackWithMetadata(commandsByActiveSection.APPLICATION_COMMAND_BROWSER_OPENED);
2026-07-20 16:05:17 +00:00
return () => {
2026-07-29 08:29:29 +00:00
const result = callback(table[12]).updateInitialSectionId(undefined);
2026-07-20 16:05:17 +00:00
};
}, []);
const items2 = [commandsByActiveSection, onHeightChange, bound];
2026-07-29 08:29:29 +00:00
const effect2 = obj1.useEffect(() => {
if (onHeightChange != null) {
2026-08-24 06:08:38 +00:00
closure_0 = bound;
2026-07-29 08:29:29 +00:00
let num2 = 0;
if (0 !== commandsByActiveSection.length) {
num2 = arr.reduce((arg0, data) => {
if (0 === data.data.length) {
2026-08-24 06:08:38 +00:00
let sum = callback(closure_1_3[8]).APPLICATION_SECTION_HEADER_HEIGHT + 160;
2026-07-29 08:29:29 +00:00
} else {
2026-08-24 06:08:38 +00:00
sum = arg0 + (callback(closure_1_3[8]).APPLICATION_SECTION_HEADER_HEIGHT + (callback + closure_1_10) * data.data.length);
2026-07-29 08:29:29 +00:00
}
return sum;
}, 0);
}
tmp(num2);
arr = commandsByActiveSection;
2026-07-20 16:05:17 +00:00
}
}, items2);
const items3 = [sectionDescriptors, filterSection, filteredSectionId];
2026-07-29 08:29:29 +00:00
callback = obj1.useCallback((arg0) => {
2026-07-20 16:05:17 +00:00
if (sectionDescriptors[arg0].id !== filteredSectionId) {
if (tmp.id !== ref.FRECENCY) {
filterSection(tmp.id);
2026-08-24 06:08:38 +00:00
callback2(arg0);
2026-07-20 16:05:17 +00:00
}
2026-08-25 06:04:03 +00:00
const result = closure_1_0(11964).updateInitialSectionId(undefined);
2026-07-20 16:05:17 +00:00
}
filterSection(null);
2026-08-24 06:08:38 +00:00
callback2(0);
2026-07-20 16:05:17 +00:00
}, items3);
2026-07-29 08:29:29 +00:00
const callback1 = obj1.useCallback(() => {
2026-07-20 16:05:17 +00:00
closure_8.current = true;
2026-08-25 06:04:03 +00:00
closure_1_0(4588).trackWithMetadata(commandsByActiveSection.APPLICATION_COMMAND_BROWSER_SCROLLED);
2026-07-20 16:05:17 +00:00
}, []);
2026-07-29 08:29:29 +00:00
const callback2 = obj1.useCallback((nativeEvent) => {
2026-07-20 16:05:17 +00:00
nativeEvent = nativeEvent.nativeEvent;
const targetContentOffset = nativeEvent.targetContentOffset;
let y;
2026-07-29 08:29:29 +00:00
if (targetContentOffset != null) {
2026-07-20 16:05:17 +00:00
y = targetContentOffset.y;
}
if (nativeEvent.contentOffset.y === y) {
closure_8.current = false;
}
}, []);
const items4 = [sectionDescriptors, commandsByActiveSection, bound];
2026-07-29 08:29:29 +00:00
const callback3 = obj1.useCallback(() => {
2026-07-20 16:05:17 +00:00
closure_8.current = false;
}, []);
2026-07-29 08:29:29 +00:00
memo = obj1.useMemo(() => {
2026-08-24 06:08:38 +00:00
c0 = 0;
2026-07-20 16:05:17 +00:00
const items = [];
2026-07-29 08:29:29 +00:00
for (const item10008 of sectionDescriptors) {
let tmp = (function _loop(item10008) {
2026-08-24 06:08:38 +00:00
closure_0 = item10008;
const findIndexResult = closure_1_12.findIndex((section) => section.section.id === item10008.id);
2026-07-29 08:29:29 +00:00
if (findIndexResult >= 0) {
2026-08-24 06:08:38 +00:00
const result = closure_1_12[findIndexResult].data.length * closure_1_4;
const sum = result + closure_2_0(table[8]).APPLICATION_SECTION_HEADER_HEIGHT + closure_0;
2026-07-29 08:29:29 +00:00
items.push(sum);
closure_0 = sum;
} else {
items.push(closure_0);
}
})(item10008);
continue;
2026-07-20 16:05:17 +00:00
}
return items;
}, items4);
const items5 = [memo];
2026-08-24 06:08:38 +00:00
closure_19 = obj1.useMemo(() => onHeightChange(12).throttle((arg0) => {
2026-07-20 16:05:17 +00:00
let num = 0;
2026-07-29 08:29:29 +00:00
if (0 < closure_18.length) {
2026-07-20 16:05:17 +00:00
let num2 = 0;
let num3 = 0;
2026-07-29 08:29:29 +00:00
if (0 === tmp[0]) {
const sum = num3 + 1;
const sum1 = num2 + 1;
2026-07-20 16:05:17 +00:00
num = sum;
2026-07-29 08:29:29 +00:00
while (sum1 < closure_18.length) {
num2 = sum1;
num3 = sum;
if (0 === tmp5[sum1]) {
2026-07-20 16:05:17 +00:00
continue;
} else {
2026-07-29 08:29:29 +00:00
num2 = sum1;
num3 = sum;
2026-07-20 16:05:17 +00:00
num = sum;
2026-07-29 08:29:29 +00:00
if (arg0 < tmp5[sum1]) {
2026-07-20 16:05:17 +00:00
break;
}
}
continue;
}
} else {
num2 = 0;
num3 = 0;
num = 0;
}
}
2026-07-29 08:29:29 +00:00
callback(num);
2026-07-20 16:05:17 +00:00
}, 100), items5);
const items6 = [bound];
const items7 = [channel.guild_id, callback, sectionDescriptors, first];
2026-07-29 08:29:29 +00:00
const callback4 = obj1.useCallback((arg0, arg1) => {
2026-07-20 16:05:17 +00:00
if (null == arg0) {
2026-07-29 08:29:29 +00:00
let obj = { length: 0, offset: 0, index: null };
obj[2] = arg1;
2026-07-20 16:05:17 +00:00
return obj;
} else {
let num = 0;
let num2 = 0;
let num3 = 0;
2026-08-24 06:08:38 +00:00
let ROW = _undefined2.ROW;
2026-07-29 08:29:29 +00:00
const iter = arg0[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp4 = nextResult;
let tmp5 = num;
let tmp6 = num2;
let tmp7 = num3;
if (num + num2 + nextResult.data.length + num3 + 1 >= arg1) {
let tmp12 = num;
let tmp13 = num2;
let tmp14 = num3;
if (arg1 === num + num2 + num3) {
2026-08-24 06:08:38 +00:00
let tmp24 = _undefined2;
let tmp25 = _undefined2;
ROW = _undefined2.HEADER;
2026-07-29 08:29:29 +00:00
} else {
let tmp39 = num;
let tmp40 = num2;
let tmp41 = nextResult;
let tmp42 = num3;
if (arg1 === num + num2 + tmp4.data.length + num3 + 1) {
let tmp20 = num;
num = num + 1;
let tmp21 = num2;
num2 = num2 + nextResult.data.length;
2026-08-24 06:08:38 +00:00
let tmp22 = _undefined2;
let tmp23 = _undefined2;
ROW = _undefined2.FOOTER;
2026-07-29 08:29:29 +00:00
} else {
let tmp15 = num2;
let tmp16 = num;
let sum = num + 1;
num = sum;
num2 = num2 + (arg1 - sum - num2 - num3);
2026-08-24 06:08:38 +00:00
let tmp18 = _undefined2;
let tmp19 = _undefined2;
ROW = _undefined2.ROW;
2026-07-29 08:29:29 +00:00
}
}
let tmp26 = iter;
iter.return();
break;
} else {
let tmp8 = num;
2026-07-20 16:05:17 +00:00
num = num + 1;
2026-07-29 08:29:29 +00:00
let tmp9 = num2;
let tmp10 = nextResult;
num2 = num2 + tmp4.data.length;
let tmp11 = num3;
2026-07-20 16:05:17 +00:00
num3 = num3 + 1;
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp27 = ROW;
2026-08-24 06:08:38 +00:00
let tmp28 = _undefined2;
if (_undefined2.ROW === ROW) {
2026-07-29 08:29:29 +00:00
let num4 = bound;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let tmp30 = tmp28;
if (tmp29.HEADER === ROW) {
2026-08-24 06:08:38 +00:00
let tmp31 = closure_1_0;
let tmp32 = dependencyMap;
2026-08-25 06:04:03 +00:00
num4 = closure_1_0(11963).APPLICATION_SECTION_HEADER_HEIGHT;
2026-07-29 08:29:29 +00:00
} else {
let FOOTER = tmp28.FOOTER;
num4 = 0;
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { length: null, offset: null, index: null };
obj[0] = num4;
2026-08-24 06:08:38 +00:00
let tmp33 = closure_1_0;
let tmp34 = dependencyMap;
2026-07-29 08:29:29 +00:00
let tmp35 = bound;
2026-08-25 06:04:03 +00:00
obj[1] = num * closure_1_0(11963).APPLICATION_SECTION_HEADER_HEIGHT + num2 * bound;
2026-07-29 08:29:29 +00:00
obj[2] = arg1;
return obj;
2026-07-20 16:05:17 +00:00
}
}
}, items6);
2026-07-29 08:29:29 +00:00
obj2 = { style: items8, children: null };
2026-07-23 10:11:24 +00:00
items8 = [tmp.discoveryWrapper, channel.style];
2026-07-29 08:29:29 +00:00
obj3 = {
2026-07-20 16:05:17 +00:00
ref,
sections: commandsByActiveSection,
style: tmp.commandsList,
onScrollBeginDrag: callback1,
onScrollEndDrag: callback2,
onMomentumScrollEnd: callback3,
onScroll(nativeEvent) {
nativeEvent = nativeEvent.nativeEvent;
({ layoutMeasurement, contentSize, contentInset } = nativeEvent);
const y = nativeEvent.contentOffset.y;
2026-08-24 06:08:38 +00:00
callback3(y);
2026-07-29 08:29:29 +00:00
const current = ref.current;
let tmp2 = !current;
if (!current) {
2026-08-24 06:08:38 +00:00
tmp2 = _undefined.length > 0;
2026-07-29 08:29:29 +00:00
}
if (tmp2) {
if (y < contentInset.top) {
const current2 = ref.current;
if (current2 != null) {
current2.scrollToLocation({ sectionIndex: 0, itemIndex: 0, viewPosition: 0, animated: false });
}
} else if (y > contentSize.height - layoutMeasurement.height - contentInset.bottom) {
const current3 = ref.current;
if (current3 != null) {
const obj = { sectionIndex: null, itemIndex: null, viewPosition: 1, animated: false };
2026-08-24 06:08:38 +00:00
obj[0] = _undefined.length - 1;
2026-07-29 08:29:29 +00:00
const _Math = Math;
obj[1] = Math.max(commandsByActiveSection[commandsByActiveSection.length - 1].data.length - 1, 0);
current3.scrollToLocation(obj);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
let tmp7 = c13;
2026-07-23 10:11:24 +00:00
if (c13) {
2026-07-29 08:29:29 +00:00
tmp7 = y + layoutMeasurement.height >= contentSize.height - 3 * bound;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp7) {
2026-08-24 06:08:38 +00:00
_undefined3();
2026-07-20 16:05:17 +00:00
}
},
scrollEventThrottle: 16,
keyExtractor(id) {
return id.id;
2026-07-29 08:29:29 +00:00
},
maintainVisibleContentPosition: null,
renderItem: null,
renderSectionHeader: null,
getItemLayout: null,
stickySectionHeadersEnabled: true
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
let obj4 = null;
2026-08-25 06:04:03 +00:00
const memo1 = obj1.useMemo(() => filteredSectionId(onHeightChange(11965), { onPressSection: callback, sections: sectionDescriptors, selectedIndex: first, guildId: channel.guild_id }), items7);
2026-07-20 16:05:17 +00:00
if (discovery.loading) {
2026-07-29 08:29:29 +00:00
obj4 = { minIndexForVisible: 1 };
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj3[9] = obj4;
obj3[10] = function renderItem(item) {
2026-07-20 16:05:17 +00:00
item = item.item;
const section = item.section;
2026-07-23 10:11:24 +00:00
let found;
2026-08-25 06:04:03 +00:00
if (item.inputType === closure_1_0(7129).ApplicationCommandInputType.PLACEHOLDER) {
return filteredSectionId(onHeightChange(11966), {});
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
found = sectionDescriptors.find((id) => id.id === item.applicationId);
2026-07-29 08:29:29 +00:00
const obj = { command: null, onPress: null, section: null, showIcon: null, guildId: null };
obj[0] = item;
obj[1] = function onPress() {
let tmpResult;
if (item != null) {
tmpResult = tmp(item, found, section.section);
}
return tmpResult;
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
obj[2] = found;
obj[3] = item.applicationId !== section.section.id;
obj[4] = found.guild_id;
2026-08-25 06:04:03 +00:00
return filteredSectionId(onHeightChange(11967), obj);
2026-07-20 16:05:17 +00:00
}
};
2026-07-29 08:29:29 +00:00
obj3[11] = function renderSectionHeader(section) {
2026-07-20 16:05:17 +00:00
section = section.section;
2026-07-29 08:29:29 +00:00
let obj = { section: section.section, guildId: channel.guild_id };
2026-08-25 06:04:03 +00:00
const children = [filteredSectionId(onHeightChange(11963), obj, section.section.id), ];
2026-07-29 08:29:29 +00:00
let tmp3Result = 0 === section.data.length;
if (tmp3Result) {
obj = { lightSource: null, darkSource: null, body: null, containerStyle: null, imageStyle: null };
2026-08-25 06:04:03 +00:00
obj[0] = tmp4(10138);
obj[1] = tmp4(10138);
2026-08-24 06:08:38 +00:00
const intl = closure_1_0(1236).intl;
2026-07-29 08:29:29 +00:00
obj = { applicationName: null };
obj[0] = section.section.name;
2026-08-24 06:08:38 +00:00
obj[2] = intl.format(closure_1_0(1236).t.WoQXT6, obj);
({ noCommandsContainer: obj2[3], noCommandsImage: obj2[4] } = dependencyMap);
tmp3Result = filteredSectionId(closure_1_0(1297).ThemedEmptyState, obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
children[1] = tmp3Result;
return filterSection(c15, { children });
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
obj3[12] = callback4;
2026-08-24 06:08:38 +00:00
const items9 = [filteredSectionId(closure_7, obj3), memo1];
2026-07-29 08:29:29 +00:00
obj2[1] = items9;
2026-07-20 16:05:17 +00:00
return filterSection(first, obj2);
};