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

317 lines
17 KiB
TypeScript

/* Metro module 15688; source: modules/dice_roll/DiceRollLifecycleManager.tsx; dependencies: [6, 7, 15, 17, 18, 1379, 1934, 11526, 7872, 4503, 1244, 7067, 7076, 4860, 2] */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import SelectedChannelStore from '../../stores/SelectedChannelStore.tsx'; /* Metro dependency 1934 */
import DiceRollStore from './DiceRollStore.tsx'; /* Metro dependency 11526 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as MessageConstantsModule from '../messages/MessageConstants.tsx'; /* Metro dependency 4503 */
import * as DiceRollConstantsModule from './DiceRollConstants.tsx'; /* Metro dependency 7872 */
import * as DiceRollStoreModule from './DiceRollStore.tsx'; /* Metro dependency 11526 */
function _fun120356(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#120356, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:6, offset: 0x02528ebf, size: 391 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = DiceRollConstantsModule;
const env0_12 = value.AFTER_ROLL_DELAY_MS;
const env0_13 = value.ALLOWED_DICE_SIDES_SET;
const env0_14 = value.DEFAULT_DICE_SIDES;
const env0_15 = value.DISMISS_DELAY_MS;
const env0_16 = value.MAX_DICE_COUNT;
const env0_17 = value.ROLL_DURATION_MS;
value = importDefault(4860) /* metro dependency 4860: AutomaticLifecycleManager */;
value = _fun120360(value);
value = new value();
(FileImportTrackerModule).fileFinishedImporting('modules/dice_roll/DiceRollLifecycleManager.tsx');
exports.default = value;
function _isNativeReflectConstruct_120357() { // fn#120357, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:387, offset: 0x02529046, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_120357_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun120360(a0) { // fn#120360, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:590, offset: 0x025290a8, size: 151 bytes, params: 2, frame: 16
const DiceRollLifecycleManager2 = DiceRollLifecycleManager;
Inherits(DiceRollLifecycleManager2, a0);
return CreateClass(DiceRollLifecycleManager2, [{key: 'finishRoll', value: function(a0, a1, a2, a3) {
var env0_0 = this;
DiceRollStore.setState({rolling: false, results: a3});
this.postRollDismissTimer = global.setTimeout(_fun120368, AFTER_ROLL_DELAY_MS);
this.sendMessage(a0, a1, a2, a3);
}}, {key: 'sendMessage', value: value_120369}, {key: 'dismiss', value: function() {
var env0_0 = this;
DiceRollStore.setState({dismissing: true});
this.collapseTimer = global.setTimeout(_fun120373, DISMISS_DELAY_MS);
}}, {key: 'clearTimers', value: function() {
if (this.rollTimer != null) {
global.clearTimeout(this.rollTimer);
this.rollTimer = null;
}
if (this.postRollDismissTimer != null) {
global.clearTimeout(this.postRollDismissTimer);
this.postRollDismissTimer = null;
}
if (this.collapseTimer != null) {
global.clearTimeout(this.collapseTimer);
this.collapseTimer = null;
}
}}]);
function DiceRollLifecycleManager(a0) { // fn#120361, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:602, offset: 0x0252913f, size: 212 bytes, params: 2, frame: 20
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_3;
binding(this, DiceRollLifecycleManager);
const items2 = [];
arraySpread(items2, value, 0, items2);
value = env1_6(DiceRollLifecycleManager);
binding = env1_5;
if (_isNativeReflectConstruct_120357()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items2, env1_6(this).constructor);
r0 = value;
} else {
value = value.apply(this, items2);
r0 = value;
}
value = binding(this, r0);
value.actions = {CHANNEL_SELECT: CHANNEL_SELECT_120362, DICE_ROLL_START: DICE_ROLL_START};
value.rollTimer = null;
value.postRollDismissTimer = null;
value.collapseTimer = null;
value.handleChannelSelect = handleChannelSelect_120364;
value.handleStartRoll = handleStartRoll;
return value;
function DiceRollLifecycleManagerCHANNEL_SELECT(a0) { // fn#120362, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:886, owner: DiceRollLifecycleManager.CHANNEL_SELECT, offset: 0x013e6c11, size: 23 bytes, params: 2, frame: 11
return env0_0.handleChannelSelect(a0);
}
function DICE_ROLL_START(a0) { // fn#120363, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:930, owner: DiceRollLifecycleManager.DICE_ROLL_START, offset: 0x02529213, size: 23 bytes, params: 2, frame: 11
return env0_0.handleStartRoll(a0);
}
function DiceRollLifecycleManagerHandleChannelSelect({channelId}) { // fn#120364, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:1043, owner: DiceRollLifecycleManager.handleChannelSelect, offset: 0x0252922a, size: 84 bytes, params: 2, frame: 11
var binding;
let value = environment.__proto__.__proto__;
value = DiceRollStore.getState();
if (value.channelId != null && value.channelId !== channelId) {
binding = env0_0;
binding.clearTimers();
binding.dismiss();
}
}
function handleStartRoll({channelId, diceCount, diceSides}) { // fn#120365, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:1165, owner: DiceRollLifecycleManager.handleStartRoll, offset: 0x0252927e, size: 353 bytes, params: 2, frame: 23
var environment;
var r4;
var r8;
var r7;
var r5;
var value;
var diceRollStoreBinding;
var getState;
var channelId2;
var value2;
var Math;
var min;
var Math2;
var max;
var value3;
var value4;
var has;
var setState;
var items2;
var value5;
var push;
var floor;
var Math3;
var random;
var value6;
var value7;
var binding;
var setTimeout;
const channelId3 = channelId;
reducibleJoin2: while (true) {
if (diceCount !== undefined) {
break reducibleJoin2;
}
value = 1;
diceCount = value;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (diceSides !== undefined) {
r4 = diceSides;
break reducibleJoin4;
}
value = environment.__proto__.__proto__;
r4 = DEFAULT_DICE_SIDES;
break reducibleJoin4;
}
var env0_1;
var env0_2;
var env0_3;
value = environment.__proto__.__proto__;
const selectedChannelStoreBinding = SelectedChannelStore;
const getChannelId = selectedChannelStoreBinding.getChannelId;
reducibleJoin13: while (true) {
if (Reflect.apply(getChannelId, selectedChannelStoreBinding, []) !== channelId) {
break reducibleJoin13;
}
diceRollStoreBinding = DiceRollStore;
getState = diceRollStoreBinding.getState;
channelId2 = Reflect.apply(getState, diceRollStoreBinding, []).channelId;
if (channelId2 != null) {
break reducibleJoin13;
}
value2 = 42;
reducibleJoin8: while (true) {
if (value2 === diceCount) {
r8 = value2;
break reducibleJoin8;
}
Math = global.Math;
min = Math.min;
Math2 = global.Math;
max = Math2.max;
value3 = Reflect.apply(max, Math2, [diceCount, 1]);
value4 = Reflect.apply(min, Math, [value3, MAX_DICE_COUNT]);
r8 = value4;
break reducibleJoin8;
}
env0_1 = r8;
has = ALLOWED_DICE_SIDES_SET.has;
reducibleJoin10: while (true) {
if (Reflect.apply(has, ALLOWED_DICE_SIDES_SET, [r4])) {
r7 = r4;
break reducibleJoin10;
}
r7 = DEFAULT_DICE_SIDES;
break reducibleJoin10;
}
env0_2 = r7;
diceRollStoreBinding = DiceRollStore;
setState = diceRollStoreBinding.setState;
Reflect.apply(setState, diceRollStoreBinding, [{channelId: channelId, rolling: true, diceCount: r8,
diceSides: r7,
results: null}]);
items2 = [];
env0_3 = items2;
value5 = 0;
if (value5 < r8) {
r5 = value5;
reducibleLoop11: while (true) {
push = items2.push;
Math = global.Math;
floor = Math.floor;
Math3 = global.Math;
random = Math3.random;
Reflect.apply(push, items2, [Reflect.apply(floor, Math, [Reflect.apply(random, Math3, []) * r7]) + 1]);
value6 = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1;
if (value6 < r8) {
r5 = value6;
continue reducibleLoop11;
}
break reducibleLoop11;
}
}
value7 = environment;
binding = channelId3;
setTimeout = global.setTimeout;
binding.rollTimer = setTimeout(_fun120366, ROLL_DURATION_MS);
break reducibleJoin13;
}
function _fun120366() { // fn#120366, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:1484, offset: 0x025293df, size: 53 bytes, params: 1, frame: 17
const binding = env1_0;
binding.rollTimer = null;
binding.finishRoll(channelId, env0_1, env0_2, env0_3);
}
}
}
function value_120367(a0, a1, a2, a3) { // fn#120367, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:1626, offset: 0x02529414, size: 104 bytes, params: 5, frame: 19
DiceRollStore.setState({rolling: false, results: a3});
this.postRollDismissTimer = global.setTimeout(_fun120368, AFTER_ROLL_DELAY_MS);
this.sendMessage(a0, a1, a2, a3);
function _fun120368() { // fn#120368, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:1717, offset: 0x0252947c, size: 29 bytes, params: 1, frame: 9
const binding = env0_0;
binding.postRollDismissTimer = null;
binding.dismiss();
}
}
function value_120369(a0, a1, a2, a3) { // fn#120369, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:1826, offset: 0x02529499, size: 548 bytes, params: 5, frame: 35
var r6;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
var value7;
var value9;
var defaultImport;
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
value7 = '[`' + intl.formatToPlainString(t.uV5JaG, {count: a1,
sides: a2}) + '`](' + ('' + global.location.protocol + global.window.GLOBAL_ENV.WEBAPP_ENDPOINT + '/channels/' + (channel.getGuildId() ?? '@me') + '/' + a0 + '/roll-dice/' + a1 + 'd' + a2) + ')';
value9 = intl.formatToMarkdownString(t.tmSbYW, {total: a3.reduce(function(a0, a1) {
return a0 + a1;
}, 0), count: a1, sides: a2});
r6 = a1 === 1 ? '### ' + value9 + ' ' + value7 : '### ' + value9 + ' ' + value7 + '\n' + ('-# ' + a3.map(_fun120371).join(' '));
defaultImport = importDefault(7067) /* metro dependency 7067: MessageActionCreators */;
defaultImport.sendMessage(a0, (importDefault(7076) /* metro dependency 7076: MessageParser */).parse(channel,
r6),
true, {location: MessageSendLocation.CHAT_INPUT});
}
}
function value_120372() { // fn#120372, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:2424, offset: 0x025296e3, size: 71 bytes, params: 1, frame: 16
DiceRollStore.setState({dismissing: true});
this.collapseTimer = global.setTimeout(_fun120373, DISMISS_DELAY_MS);
function _fun120373() { // fn#120373, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:2494, offset: 0x0252972a, size: 41 bytes, params: 1, frame: 11
env0_0.collapseTimer = null;
DiceRollStore.setState(INITIAL_STATE);
}
}
}
}
function _fun120371(a0) { // fn#120371, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15896:2235, offset: 0x025296bd, size: 38 bytes, params: 2, frame: 11
return ':game_die: ' + a0.toString();
}
global.__d(_fun120356, 15688, [6, 7, 15, 17, 18, 1379, 1934, 11526, 7872, 4503, 1244, 7067, 7076, 4860,
2]) /* metro module 15688, dependencies: [6, 7, 15, 17, 18, 1379, 1934, 11526, 7872, 4503, 1244, 7067, 7076, 4860, 2] */;