Files
discord-decomp/sources/modules/chat_input/native/ChatInputAppCommandManager.tsx
T
2026-07-28 01:06:53 +03:00

194 lines
12 KiB
TypeScript

/* Metro module 11884; source: modules/chat_input/native/ChatInputAppCommandManager.tsx; dependencies: [57, 31, 7167, 7168, 4501, 697, 11647, 566, 11857, 8060, 1909, 11885, 11858, 2] */
import Module00057 from '../../../by-id/module-00057.js'; /* Metro dependency 57 */
import ApplicationCommandAutocompleteStore from '../../application_commands/ApplicationCommandAutocompleteStore.tsx'; /* Metro dependency 7167 */
import ApplicationCommandStore from '../../application_commands/ApplicationCommandStore.tsx'; /* Metro dependency 7168 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as ServerModule from '../../../flow/Server.tsx'; /* Metro dependency 1909 */
import * as CreateStylesModule from '../../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
import * as ApplicationCommandQueryApiModule from '../../application_commands/ApplicationCommandQueryApi.tsx'; /* Metro dependency 8060 */
import * as ApplicationCommandOptionValueParserModule from './ApplicationCommandOptionValueParser.tsx'; /* Metro dependency 11647 */
import * as ChatInputCommandOptionParserModule from './ChatInputCommandOptionParser.tsx'; /* Metro dependency 11857 */
function _fun91167(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#91167, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:6, offset: 0x02054604, size: 448 bytes, params: 8, frame: 24
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactModule;
const createStyles = CreateStylesModule.createStyles;
object = {};
const object2 = {};
let BACKGROUND_BASE_LOWER = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWER;
object2.backgroundColor = BACKGROUND_BASE_LOWER;
const TEXT_DEFAULT = (importDefault(697) /* metro dependency 697: native */).colors.TEXT_DEFAULT;
object2.color = TEXT_DEFAULT;
object2.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.xs;
object2.fontSize = 14;
object.commandOption = object2;
const object3 = {};
BACKGROUND_BASE_LOWER = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWER;
object3.backgroundColor = BACKGROUND_BASE_LOWER;
const TEXT_FEEDBACK_CRITICAL = (importDefault(697) /* metro dependency 697: native */).colors.TEXT_FEEDBACK_CRITICAL;
object3.color = TEXT_FEEDBACK_CRITICAL;
object3.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.xs;
object3.fontSize = 14;
object.commandErrorOption = object3;
const TEXT_BRAND = (importDefault(697) /* metro dependency 697: native */).colors.TEXT_BRAND;
object.autocomplete = {color: TEXT_BRAND, fontWeight: 'bold'};
const env0_8 = Reflect.apply(createStyles, CreateStylesModule, [object]);
const value3 = value.forwardRef(_fun91168);
value3.displayName = 'ChatInputAppCommandManager';
value = value.memo(value3);
(FileImportTrackerModule).fileFinishedImporting('modules/chat_input/native/ChatInputAppCommandManager.tsx');
exports.default = value;
function _fun91168({chatInputRef, chatInputStateRef, channel, commandsDisabled}, a1) { // fn#91168, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:548, offset: 0x020547c4, size: 517 bytes, params: 3, frame: 28
const styles = useStyles();
const styles2 = styles;
const value2 = (ApplicationCommandOptionValueParserModule).useApplicationCommandOptionValueParser({channel: channel});
const env0_5 = value2;
const activeCommand = (require(566) /* metro dependency 566: flux */).useStateFromStores([ApplicationCommandStore],
function() {
return ApplicationCommandStore.getActiveCommand(channel.id);
});
const lastResponseNonce = (require(566) /* metro dependency 566: flux */).useStateFromStores([ApplicationCommandAutocompleteStore],
function() {
return ApplicationCommandAutocompleteStore.getLastResponseNonce(channel.id);
});
const binding = env0_5;
const useRef = binding.useRef;
const getTextBeforeFirstOption = ChatInputCommandOptionParserModule.getTextBeforeFirstOption;
let text = chatInputStateRef.current.text;
text = Reflect.apply(getTextBeforeFirstOption, ChatInputCommandOptionParserModule, [text]).text;
const value3 = text.slice(1);
const value4 = Reflect.apply(useRef, binding, [value3.trimEnd()]);
const useState = binding.useState;
const value6 = styles2(Reflect.apply(useState, binding, [value4.current]), 2);
const property = value6[0];
const env0_9 = value6[1];
const useCachedResults = ApplicationCommandQueryApiModule.useCachedResults;
object = {type: 'channel', channel: channel};
const ApplicationCommandType = (ServerModule).ApplicationCommandType;
const CHAT = ApplicationCommandType.CHAT;
const commands = Reflect.apply(useCachedResults, ApplicationCommandQueryApiModule, [object, CHAT,
property]).commands;
const env0_11 = binding.useRef(undefined);
binding.useEffect(_fun91175, [binding.useCallback(_fun91171, [activeCommand, channel, chatInputRef,
chatInputStateRef, commandsDisabled, lastResponseNonce, value2, commands, styles])]);
binding.useImperativeHandle(a1, function() {
return {getApplicationCommandManager: _fun91177, updateState: _fun91178};
});
return null;
function _fun91171() { // fn#91171, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1103, offset: 0x02054a0b, size: 382 bytes, params: 1, frame: 17
var environment;
var binding;
var value2;
var defaultImport;
var object;
var value3;
var defaultImport2;
let current = chatInputStateRef.current;
const editId = current.editId;
const focused = current.focused;
const selectionStart = current.selectionStart;
const selectionEnd = current.selectionEnd;
let text = current.text;
const object3 = {};
object3.activeCommand = activeCommand;
object3.channel = channel;
object3.commandsDisabled = commandsDisabled;
object3.editId = editId;
object3.focused = focused;
object3.lastCommandAutocompleteResponseNonce = lastResponseNonce;
object3.queryCommands = commands;
object3.selectionStart = selectionStart;
object3.selectionEnd = selectionEnd;
object3.text = text;
current = env0_11.current;
if (current == null) {
binding = env0_11;
value2 = environment.__proto__;
defaultImport = importDefault(11885) /* metro dependency 11885: ApplicationCommandManager */;
object = {props: object3};
object.ref = chatInputRef;
object.optionValueParser = env0_5;
object.styles = {commandOption: commandOption, commandErrorOption: commandErrorOption,
autocomplete: autocomplete};
value3 = Object.create(defaultImport.prototype, {constructor: {value: defaultImport}});
defaultImport2 = new defaultImport();
binding.current = defaultImport2 instanceof Object ? defaultImport2 : value3;
} else {
current = env0_11.current;
current.updateApplicationCommandManagerState({newState: object3});
}
const getTextBeforeFirstOption = ChatInputCommandOptionParserModule.getTextBeforeFirstOption;
text = Reflect.apply(getTextBeforeFirstOption, ChatInputCommandOptionParserModule, [text]).text;
const value8 = text.slice(1).trimEnd();
if (env0_8.current !== value8) {
env0_9(value8);
env0_8.current = value8;
}
function commandOption() { // fn#91172, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1451, offset: 0x02054b89, size: 51 bytes, params: 1, frame: 11
let value = environment.__proto__.__proto__;
value = require(11858) /* metro dependency 11858: ChatInputParser */;
return value.convertToNativeStyle(styles.commandOption);
}
function commandErrorOption() { // fn#91173, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1521, offset: 0x02054bbc, size: 51 bytes, params: 1, frame: 11
let value = environment.__proto__.__proto__;
value = require(11858) /* metro dependency 11858: ChatInputParser */;
return value.convertToNativeStyle(styles.commandErrorOption);
}
function autocomplete(a0) { // fn#91174, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1590, offset: 0x02054bef, size: 129 bytes, params: 2, frame: 14
var r0;
var value;
var convertToNativeStyle;
var object;
var value2;
var value3;
if (a0 == null) {
value = environment.__proto__.__proto__;
value = require(11858) /* metro dependency 11858: ChatInputParser */;
convertToNativeStyle = value.convertToNativeStyle;
value3 = environment.__proto__;
value = Reflect.apply(convertToNativeStyle, value, [styles.autocomplete]);
r0 = value;
} else {
value = environment.__proto__.__proto__;
value = require(11858) /* metro dependency 11858: ChatInputParser */;
convertToNativeStyle = value.convertToNativeStyle;
object = {};
value2 = environment.__proto__;
copyDataProperties(object, styles.autocomplete, a0);
object['color'] = a0;
value = Reflect.apply(convertToNativeStyle, value, [object]);
r0 = value;
}
return r0;
}
}
function _fun91175() { // fn#91175, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1913, offset: 0x012e3925, size: 15 bytes, params: 1, frame: 9
env0_12();
}
function _fun91176() { // fn#91176, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1954, offset: 0x02054c70, size: 30 bytes, params: 1, frame: 3
return {getApplicationCommandManager: getApplicationCommandManager_91177, updateState: updateState_91178};
function getApplicationCommandManager_91177() { // fn#91177, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:1989, offset: 0x02054c8e, size: 14 bytes, params: 1, frame: 1
return env1_11.current;
}
function updateState_91178() { // fn#91178, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12070:2015, offset: 0x02054c9c, size: 15 bytes, params: 1, frame: 9
return env1_12();
}
}
}
}
global.__d(_fun91167, 11884, [57, 31, 7167, 7168, 4501, 697, 11647, 566, 11857, 8060, 1909, 11885, 11858,
2]) /* metro module 11884, dependencies: [57, 31, 7167, 7168, 4501, 697, 11647, 566, 11857, 8060, 1909, 11885, 11858, 2] */;