Files
discord-decomp/sources/utils/ExperimentUtils.tsx
T
2026-07-28 01:06:53 +03:00

654 lines
23 KiB
TypeScript

/* Metro module 4112; source: utils/ExperimentUtils.tsx; dependencies: [57, 4107, 4108, 4106, 22, 2] */
import Module00057 from '../by-id/module-00057.js'; /* Metro dependency 57 */
import ExperimentStore from '../modules/experiments/ExperimentStore.tsx'; /* Metro dependency 4107 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ExperimentConstantsModule from '../modules/experiments/ExperimentConstants.tsx'; /* Metro dependency 4108 */
function _fun33764(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#33764, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:6, offset: 0x0103afc8, size: 253 bytes, params: 8, frame: 20
let env0_0 = require;
const _arrayLikeToArray_33767 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const closure = function(a0) {
var value4;
var value5;
var value6;
var value2 = _createForOfIteratorHelperLoose_33765(a0);
var value3 = value2();
if (value3.done) {
return null;
}
var r4 = value3;
loopExit1: while (true) {
value4 = r4.value;
value5 = ExperimentStore.getUserExperimentDescriptor(value4);
if (value5 != null) {
break loopExit1;
}
value6 = value2();
if (value6.done) {
return null;
}
r4 = value6;
continue;
}
return [value4, value5];
};
let Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {getFirstEligibleUserExperiment: closure, isInExperimentBucket: isInExperimentBucket,
experimentDescriptorEquals: experimentDescriptorEquals,
trackExposureToFirstEligibleUserExperiment: trackExposureToFirstEligibleUserExperiment,
getExperimentBucketName: getExperimentBucketName, getRecentExperimentBuckets: function(a0, a1) {
var env0_0 = a1;
var Object = global.Object;
return Object.entries(a0).reduce(_fun33774, {});
}};
(FileImportTrackerModule).fileFinishedImporting('utils/ExperimentUtils.tsx');
exports.default = object;
function _createForOfIteratorHelperLoose_33765(a0, a1) { // fn#33765, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:173, offset: 0x0103b0c5, size: 370 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun33766;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_33767(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_33767(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_33767(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun33766;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun33766() { // fn#33766, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:744, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function isInExperimentBucket(a0, a1) { // fn#33769, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:1363, offset: 0x0103b292, size: 32 bytes, params: 3, frame: 11
return ExperimentStore.getUserExperimentBucket(a0) === a1;
}
function experimentDescriptorEquals(a0, a1) { // fn#33770, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:1466, offset: 0x0103b2b2, size: 224 bytes, params: 3, frame: 14
var type;
var value;
var USER;
if (a0 != null) {
if (a0 === a1) {
return true;
}
if (a0 != null) {
if (a0 == null) {
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
return true;
}
if (a1 == null) {
return false;
}
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
return true;
}
if (a1 != null) {
return false;
}
if (a0 == null) {
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
return true;
}
if (a1 == null) {
return false;
}
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
} else {
if (a1 == null) {
return true;
}
if (a0 === a1) {
return true;
}
if (a0 != null) {
if (a0 == null) {
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
return true;
}
if (a1 == null) {
return false;
}
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
return true;
}
if (a1 != null) {
return false;
}
if (a0 == null) {
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
return true;
}
if (a1 == null) {
return false;
}
if (a0 == null) {
return true;
}
if (a1 == null) {
return true;
}
type = a0.type;
if (type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
type = a0.type;
USER = ExperimentTypes.USER;
if (type !== USER) {
return true;
}
type = a1.type;
USER = ExperimentTypes.USER;
if (type === USER) {
value = importDefault(22) /* metro dependency 22 */;
return value.isEqual(a0.context, a1.context);
}
}
return true;
}
function trackExposureToFirstEligibleUserExperiment(a0) { // fn#33771, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:1862, offset: 0x0103b392, size: 85 bytes, params: 2, frame: 15
var value3;
var property;
var property2;
const firstEligibleUserExperiment = getFirstEligibleUserExperiment(a0);
if (firstEligibleUserExperiment != null) {
value3 = Module00057(firstEligibleUserExperiment, 2);
property = value3[0];
property2 = value3[1];
(require(4106) /* metro dependency 4106: ExperimentManager */).trackExposureToExperiment(property, property2);
return property2;
}
}
function getExperimentBucketName(a0) { // fn#33772, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:2071, offset: 0x0103b3e7, size: 75 bytes, params: 2, frame: 13
const CONTROL = ExperimentBuckets.CONTROL;
return a0 === CONTROL ? 'Control' : a0 === ExperimentBuckets.NOT_ELIGIBLE ? 'Not Eligible' : 'Treatment ' + a0;
}
function getRecentExperimentBuckets(a0, a1) { // fn#33773, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:2217, offset: 0x0103b432, size: 52 bytes, params: 3, frame: 13
const env0_0 = a1;
const Object = global.Object;
return Object.entries(a0).reduce(_fun33774, {});
function _fun33774(a0, a1) { // fn#33774, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4277:2291, offset: 0x0103b466, size: 254 bytes, params: 3, frame: 22
var r1;
var r3;
var r4;
var item3;
var value3;
var split;
var value5;
var binding;
var property;
var property2;
var slice;
var Date;
var concat;
var prototype;
var date;
var error;
var CONTROL;
const iterator = a1[Symbol.iterator]();
const iterator2 = iterator.next;
let item2 = Reflect.apply(iterator2, iterator, []);
let item = item2.value;
item2 = item2.done ? undefined : iterator;
let value = undefined;
const value2 = item2 === value;
const r2 = value2 ? value : item;
reducibleJoin3: while (true) {
if (value2) {
r1 = value;
r3 = item2;
r4 = value2;
break reducibleJoin3;
}
item3 = Reflect.apply(iterator2, item2, []);
item = item3.value;
item3 = item3.done ? undefined : item2;
value3 = item3 === value;
if (value3) {
r1 = value;
r3 = item3;
r4 = value3;
break reducibleJoin3;
}
r1 = item;
r3 = item3;
r4 = value3;
break reducibleJoin3;
}
reducibleJoin5: while (true) {
if (r4) {
break reducibleJoin5;
}
r3.return();
break reducibleJoin5;
}
reducibleJoin8: while (true) {
reduciblePort38: while (true) {
exceptionLanding37: while (true) {
try {
split = r2.split;
} catch (error) {
break exceptionLanding37;
}
break reducibleJoin8;
}
value = false;
r3 = value;
break reduciblePort38;
}
reducibleJoin40: while (true) {
if (r3) {
value = environment.__proto__;
CONTROL = ExperimentBuckets.CONTROL;
value = r1 > CONTROL;
r3 = value;
break reducibleJoin40;
}
break reducibleJoin40;
}
reducibleJoin42: while (true) {
if (r3) {
a0[r2] = r1;
break reducibleJoin42;
}
break reducibleJoin42;
}
return a0;
}
try {
value5 = Reflect.apply(split, r2, ['-']);
} catch (error) {
break exceptionLanding37;
}
try {
binding = env1_3;
} catch (error) {
break exceptionLanding37;
}
try {
value = binding(value5, 2);
} catch (error) {
break exceptionLanding37;
}
try {
property = value[0];
} catch (error) {
break exceptionLanding37;
}
try {
property2 = value[1];
} catch (error) {
break exceptionLanding37;
}
try {
value = property2 == null;
} catch (error) {
break exceptionLanding37;
}
if (value) {
value = false;
r3 = value;
} else {
try {
slice = property2.slice;
} catch (error) {
break exceptionLanding37;
}
try {
value = Reflect.apply(slice, property2, [0, 2]);
} catch (error) {
break exceptionLanding37;
}
try {
Date = global.Date;
} catch (error) {
break exceptionLanding37;
}
try {
} catch (error) {
break exceptionLanding37;
}
try {
} catch (error) {
break exceptionLanding37;
}
try {
value = Reflect.apply(concat, '', [property, '-', value, '-01']);
} catch (error) {
break exceptionLanding37;
}
try {
prototype = Date.prototype;
} catch (error) {
break exceptionLanding37;
}
try {
} catch (error) {
break exceptionLanding37;
}
try {
date = new Date(value);
} catch (error) {
break exceptionLanding37;
}
try {
value = date instanceof Object ? date : undefined;
} catch (error) {
break exceptionLanding37;
}
try {
value = value > require;
} catch (error) {
break exceptionLanding37;
}
r3 = value;
}
reducibleJoin40: while (true) {
if (r3) {
value = environment.__proto__;
CONTROL = ExperimentBuckets.CONTROL;
value = r1 > CONTROL;
r3 = value;
break reducibleJoin40;
}
break reducibleJoin40;
}
reducibleJoin42: while (true) {
if (r3) {
a0[r2] = r1;
break reducibleJoin42;
}
break reducibleJoin42;
}
return a0;
}
}
}
global.__d(_fun33764, 4112, [57, 4107, 4108, 4106, 22,
2]) /* metro module 4112, dependencies: [57, 4107, 4108, 4106, 22, 2] */;