520 lines
19 KiB
TypeScript
520 lines
19 KiB
TypeScript
/* Metro module 1350; source: modules/user_settings/UserSettingsUtils.tsx; dependencies: [57, 670, 661, 1316, 1314, 1349, 1315, 22, 2] */
|
|
function _fun15515(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#15515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:6, offset: 0x00e34eec, size: 405 bytes, params: 8, frame: 25
|
|
var object3;
|
|
let env0_0 = require;
|
|
const _arrayLikeToArray_15518 = 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 = b64ToProto;
|
|
const closure2 = protoToB64;
|
|
const closure3 = mutateUserGuildSettings;
|
|
const closure4 = mutateUserGuildSettingsInternal;
|
|
const closure5 = mutateUserChannelSettingsInternal;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(57) /* metro dependency 57 */;
|
|
const UserSettingsTypes = (require(670) /* metro dependency 670: UserSettingsConstants */).UserSettingsTypes;
|
|
const env0_4 = (require(661) /* metro dependency 661: Constants */).ZERO_STRING_GUILD_ID;
|
|
object3 = {readerFactory: readerFactory_15524};
|
|
const object4 = {};
|
|
const PRELOADED_USER_SETTINGS = UserSettingsTypes.PRELOADED_USER_SETTINGS;
|
|
let PreloadedUserSettings = (require(1314) /* metro dependency 1314: preloaded_user_settings */).PreloadedUserSettings;
|
|
object4[PRELOADED_USER_SETTINGS] = PreloadedUserSettings;
|
|
const FRECENCY_AND_FAVORITES_SETTINGS = UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS;
|
|
const FrecencyUserSettings = (require(1349) /* metro dependency 1349: frecency_user_settings */).FrecencyUserSettings;
|
|
object4[FRECENCY_AND_FAVORITES_SETTINGS] = FrecencyUserSettings;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/user_settings/UserSettingsUtils.tsx');
|
|
exports.BINARY_READ_OPTIONS = object3;
|
|
exports.b64ToProtoWithType = b64ToProtoWithType;
|
|
exports.b64ToProto = closure;
|
|
exports.b64ToPreloadedUserSettingsProto = function(a0) {
|
|
var b64ToProtoBinding = b64ToProto;
|
|
var PreloadedUserSettings = require(dependencyMap[4]).PreloadedUserSettings;
|
|
return b64ToProtoBinding(PreloadedUserSettings, a0);
|
|
};
|
|
exports.protoToB64WithType = protoToB64WithType;
|
|
exports.protoToB64 = closure2;
|
|
exports.mergeTopLevelFields = function(a0, a1, a2) {
|
|
var r8;
|
|
var propertyName;
|
|
var object = {};
|
|
copyDataProperties(object, a1, r8);
|
|
for (propertyName in a2) {
|
|
delete object[propertyName];
|
|
}
|
|
a0.mergePartial(object, a2);
|
|
return object;
|
|
};
|
|
exports.mutateUserGuildSettings = closure3;
|
|
exports.mutateUserGuildSettingsInternal = closure4;
|
|
exports.mutateUserChannelSettings = function(a0, a1, a2, a3) {
|
|
var env0_0 = a2;
|
|
var env0_1 = a3;
|
|
return mutateUserGuildSettings(a0, a1, _fun15530);
|
|
};
|
|
exports.mutateUserChannelSettingsInternal = closure5;
|
|
exports.runMigrations = runMigrations;
|
|
exports.serializeUsageHistory = serializeUsageHistory;
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_15516(a0, a1) { // fn#15516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:171, offset: 0x00e35081, 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 _fun15517;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_15518(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_15518(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_15518(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun15517;
|
|
}
|
|
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 b64ToProto(a0, a1) { // fn#15519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:1290, offset: 0x00e351f3, size: 130 bytes, params: 3, frame: 18
|
|
var fromBinary;
|
|
var binding;
|
|
var error;
|
|
var Error;
|
|
var prototype;
|
|
var value3;
|
|
if (a1 == null) {
|
|
return null;
|
|
}
|
|
let value = environment;
|
|
try {
|
|
fromBinary = a0.fromBinary;
|
|
binding = env0_5;
|
|
value = Reflect.apply(fromBinary, a0, [(require(1316) /* metro dependency 1316 */).base64decode(a1), binding]);
|
|
} catch (error) {
|
|
Error = global.Error;
|
|
value = 'Settings proto failed to deserialize (potentially corrupt): ' + error;
|
|
prototype = Error.prototype;
|
|
value3 = Object.create(prototype, {constructor: {value: Error}});
|
|
error = new Error(value);
|
|
value = error instanceof Object ? error : value3;
|
|
throw value;
|
|
}
|
|
return value;
|
|
}
|
|
|
|
function protoToB64(a0, a1) { // fn#15520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:1492, offset: 0x00e35275, size: 55 bytes, params: 3, frame: 13
|
|
const value = require(1316) /* metro dependency 1316 */;
|
|
return value.base64encode(a0.toBinary(a1));
|
|
}
|
|
|
|
function mutateUserGuildSettings(a0, a1, a2) { // fn#15521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:1561, offset: 0x00e352ac, size: 91 bytes, params: 4, frame: 15
|
|
var AllGuildSettings;
|
|
if (a0.guilds == null) {
|
|
AllGuildSettings = (require(1314) /* metro dependency 1314: preloaded_user_settings */).AllGuildSettings;
|
|
a0.guilds = AllGuildSettings.create();
|
|
}
|
|
return mutateUserGuildSettingsInternal(a0.guilds, a1, a2);
|
|
}
|
|
|
|
function mutateUserGuildSettingsInternal(a0, a1, a2) { // fn#15522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:1716, offset: 0x00e35307, size: 118 bytes, params: 4, frame: 14
|
|
var GuildSettings;
|
|
const value = a1;
|
|
const r1 = value != null && value !== 'null' ? value : ZERO_STRING_GUILD_ID;
|
|
let guilds = a0.guilds;
|
|
if (!(r1 in guilds)) {
|
|
guilds = a0.guilds;
|
|
GuildSettings = (require(1314) /* metro dependency 1314: preloaded_user_settings */).GuildSettings;
|
|
guilds[r1] = GuildSettings.create();
|
|
}
|
|
return a2(a0.guilds[r1]);
|
|
}
|
|
|
|
function mutateUserChannelSettingsInternal(a0, a1, a2) { // fn#15523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:1874, offset: 0x00e3537d, size: 91 bytes, params: 4, frame: 14
|
|
var ChannelSettings;
|
|
let channels = a0.channels;
|
|
if (!(a1 in channels)) {
|
|
channels = a0.channels;
|
|
ChannelSettings = (require(1314) /* metro dependency 1314: preloaded_user_settings */).ChannelSettings;
|
|
channels[a1] = ChannelSettings.create();
|
|
}
|
|
return a2(a0.channels[a1]);
|
|
}
|
|
|
|
function readerFactory_15524(a0) { // fn#15524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:1102, offset: 0x00e353d8, size: 90 bytes, params: 2, frame: 13
|
|
const BinaryReader = (require(1316) /* metro dependency 1316 */).BinaryReader;
|
|
const TextDecoder = global.TextDecoder;
|
|
const textDecoder = new TextDecoder('utf-8');
|
|
const value2 = Object.create(BinaryReader.prototype, {constructor: {value: BinaryReader}});
|
|
const binaryReader = new BinaryReader(a0, textDecoder);
|
|
return binaryReader instanceof Object ? binaryReader : value2;
|
|
}
|
|
|
|
function b64ToProtoWithType(a0, a1) { // fn#15525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:2140, offset: 0x00e35432, size: 58 bytes, params: 3, frame: 15
|
|
const value = null;
|
|
return value == a1 ? value : a0 in env0_6 ? b64ToProto(env0_6[a0], a1) : value;
|
|
}
|
|
|
|
function protoToB64WithType(a0, a1) { // fn#15527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:2404, offset: 0x00e3549a, size: 31 bytes, params: 3, frame: 13
|
|
return protoToB64(env0_6[a0], a1);
|
|
}
|
|
|
|
function mutateUserChannelSettings(a0, a1, a2, a3) { // fn#15529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:2761, offset: 0x00e354f6, size: 45 bytes, params: 5, frame: 15
|
|
const env0_0 = a2;
|
|
const env0_1 = a3;
|
|
return mutateUserGuildSettings(a0, a1, function(a0) {
|
|
return mutateUserChannelSettingsInternal(a0, importDefault, importAll);
|
|
});
|
|
}
|
|
|
|
function runMigrations(a0, a1) { // fn#15531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:2976, offset: 0x00e35543, size: 418 bytes, params: 3, frame: 23
|
|
var r4;
|
|
var version;
|
|
var r5;
|
|
var r12;
|
|
var r2;
|
|
var value;
|
|
var Versions;
|
|
var create;
|
|
var value5;
|
|
var version2;
|
|
var value6;
|
|
var value11;
|
|
var clientVersion;
|
|
var run;
|
|
var value12;
|
|
var cleanup;
|
|
var value13;
|
|
var push;
|
|
var value14;
|
|
let versions = a0.versions;
|
|
reducibleJoin2: while (true) {
|
|
if (versions != null) {
|
|
break reducibleJoin2;
|
|
}
|
|
value = environment;
|
|
Versions = (require(1315) /* metro dependency 1315: user_settings_shared */).Versions;
|
|
create = Versions.create;
|
|
a0.versions = Reflect.apply(create, Versions, []);
|
|
break reducibleJoin2;
|
|
}
|
|
const value2 = _createForOfIteratorHelperLoose_15516(a1);
|
|
const value3 = value2();
|
|
let done = value3.done;
|
|
if (!done) {
|
|
r4 = value3;
|
|
version = 0;
|
|
reducibleLoop3: while (true) {
|
|
value5 = r4.value;
|
|
version2 = value5.version;
|
|
if (version2 <= version) {
|
|
throw global.Error('Migrations are out of order or there is a duplicate version');
|
|
}
|
|
version = value5.version;
|
|
value6 = value2();
|
|
done = value6.done;
|
|
if (done) {
|
|
break reducibleLoop3;
|
|
}
|
|
r4 = value6;
|
|
continue reducibleLoop3;
|
|
}
|
|
}
|
|
const Math = global.Math;
|
|
const value8 = Math.random() < 0.1;
|
|
const items2 = [];
|
|
value = _createForOfIteratorHelperLoose_15516(a1);
|
|
const value9 = value();
|
|
done = value9.done;
|
|
const value10 = false;
|
|
if (done) {
|
|
r2 = value10;
|
|
} else {
|
|
r4 = value10;
|
|
r5 = value9;
|
|
reducibleLoop7: while (true) {
|
|
value11 = r5.value;
|
|
version = value11.version;
|
|
versions = a0.versions;
|
|
clientVersion = versions.clientVersion;
|
|
if (version <= clientVersion) {
|
|
reducibleJoin16: while (true) {
|
|
if (value8) {
|
|
cleanup = value11.cleanup;
|
|
if (cleanup == null) {
|
|
r12 = r4;
|
|
break reducibleJoin16;
|
|
}
|
|
cleanup = value11.cleanup;
|
|
Reflect.apply(cleanup, value11, []);
|
|
r12 = r4;
|
|
break reducibleJoin16;
|
|
}
|
|
r12 = r4;
|
|
break reducibleJoin16;
|
|
}
|
|
} else {
|
|
run = value11.run;
|
|
value12 = Reflect.apply(run, value11, [a0]);
|
|
versions = a0.versions;
|
|
version = value11.version;
|
|
versions.clientVersion = version;
|
|
if (value10 !== value12) {
|
|
cleanup = value11.cleanup;
|
|
value13 = true;
|
|
reducibleJoin16: while (true) {
|
|
if (cleanup != null) {
|
|
push = items2.push;
|
|
cleanup = value11.cleanup;
|
|
Reflect.apply(push, items2, [cleanup]);
|
|
r12 = value13;
|
|
break reducibleJoin16;
|
|
}
|
|
r12 = value13;
|
|
break reducibleJoin16;
|
|
}
|
|
} else {
|
|
cleanup = value11.cleanup;
|
|
reducibleJoin16: while (true) {
|
|
if (cleanup == null) {
|
|
r12 = r4;
|
|
break reducibleJoin16;
|
|
}
|
|
cleanup = value11.cleanup;
|
|
Reflect.apply(cleanup, value11, []);
|
|
r12 = r4;
|
|
break reducibleJoin16;
|
|
}
|
|
}
|
|
}
|
|
value14 = value();
|
|
done = value14.done;
|
|
if (done) {
|
|
r2 = r12;
|
|
break reducibleLoop7;
|
|
}
|
|
r4 = r12;
|
|
r5 = value14;
|
|
continue reducibleLoop7;
|
|
}
|
|
}
|
|
return {proto: a0, isDirty: r2, cleanupFuncs: items2};
|
|
}
|
|
|
|
function serializeUsageHistory(a0, a1) { // fn#15532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1477:3626, offset: 0x00e356e5, size: 341 bytes, params: 3, frame: 26
|
|
var environment;
|
|
var r2;
|
|
var value2;
|
|
var defaultImport;
|
|
var sortBy;
|
|
var reverse;
|
|
var pop;
|
|
var value5;
|
|
var value6;
|
|
var property;
|
|
var property2;
|
|
var FrecencyItem;
|
|
var create;
|
|
var value7;
|
|
var frecency;
|
|
var recentUses;
|
|
var filter;
|
|
var value8;
|
|
var map;
|
|
var String;
|
|
var Math;
|
|
var round;
|
|
var score;
|
|
var totalUses;
|
|
var value9;
|
|
const Object = global.Object;
|
|
let value = Object.entries(a0);
|
|
let length = value.length;
|
|
reducibleJoin3: while (true) {
|
|
if (!(length > a1)) {
|
|
r2 = value;
|
|
break reducibleJoin3;
|
|
}
|
|
value2 = environment;
|
|
defaultImport = importDefault(22) /* metro dependency 22 */;
|
|
sortBy = defaultImport.sortBy;
|
|
value = Reflect.apply(sortBy, defaultImport, [value, function(a0) {
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var item3;
|
|
var value3;
|
|
var iterator = a0[Symbol.iterator]();
|
|
var iterator2 = iterator.next;
|
|
var item2 = Reflect.apply(iterator2, iterator, []);
|
|
var item = item2.value;
|
|
item2 = item2.done ? undefined : iterator;
|
|
var value = undefined;
|
|
var value2 = item2 === value;
|
|
if (value2) {
|
|
r0 = value;
|
|
r1 = item2;
|
|
r2 = value2;
|
|
} else {
|
|
item3 = Reflect.apply(iterator2, item2, []);
|
|
item = item3.value;
|
|
item3 = item3.done ? undefined : item2;
|
|
value3 = item3 === value;
|
|
if (value3) {
|
|
r0 = value;
|
|
r1 = item3;
|
|
r2 = value3;
|
|
} else {
|
|
r0 = item;
|
|
r1 = item3;
|
|
r2 = value3;
|
|
}
|
|
}
|
|
if (!r2) {
|
|
r1.return();
|
|
}
|
|
return r0.recentUses[r0.recentUses.length - 1];
|
|
}]);
|
|
reverse = value.reverse;
|
|
value = Reflect.apply(reverse, value, []);
|
|
length = value.length;
|
|
if (!(length > a1)) {
|
|
r2 = value;
|
|
break reducibleJoin3;
|
|
}
|
|
reducibleLoop2: while (true) {
|
|
pop = value.pop;
|
|
Reflect.apply(pop, value, []);
|
|
length = value.length;
|
|
if (length > a1) {
|
|
continue reducibleLoop2;
|
|
}
|
|
r2 = value;
|
|
break reducibleJoin3;
|
|
}
|
|
}
|
|
const object2 = {};
|
|
let value3 = _createForOfIteratorHelperLoose_15516(r2);
|
|
const value4 = value3();
|
|
let done = value4.done;
|
|
if (!done) {
|
|
r2 = value4;
|
|
reducibleLoop4: while (true) {
|
|
value5 = r2.value;
|
|
value6 = env0_3(value5, 2);
|
|
property = value6[0];
|
|
property2 = value6[1];
|
|
FrecencyItem = (require(1349) /* metro dependency 1349: frecency_user_settings */).FrecencyItem;
|
|
create = FrecencyItem.create;
|
|
value7 = Reflect.apply(create, FrecencyItem, []);
|
|
frecency = property2.frecency;
|
|
value7.frecency = frecency;
|
|
recentUses = property2.recentUses;
|
|
filter = recentUses.filter;
|
|
value8 = Reflect.apply(filter, recentUses, [function(a0) {
|
|
return a0 != null && a0 > 0;
|
|
}]);
|
|
map = value8.map;
|
|
String = global.String;
|
|
value7.recentUses = Reflect.apply(map, value8, [String]);
|
|
Math = global.Math;
|
|
round = Math.round;
|
|
score = property2.score;
|
|
value7.score = Reflect.apply(round, Math, [score]);
|
|
totalUses = property2.totalUses;
|
|
value7.totalUses = totalUses;
|
|
object2[property] = value7;
|
|
value9 = value3();
|
|
done = value9.done;
|
|
if (done) {
|
|
break reducibleLoop4;
|
|
}
|
|
r2 = value9;
|
|
continue reducibleLoop4;
|
|
}
|
|
}
|
|
return object2;
|
|
}
|
|
|