341 lines
14 KiB
TypeScript
341 lines
14 KiB
TypeScript
/* Metro module 4655; source: utils/FileUtils.tsx; dependencies: [1867, 1878, 661, 1880, 22, 4656, 4657, 3802, 4136, 1244, 2] */
|
|
function _fun40174(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#40174, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:6, offset: 0x010f8628, size: 928 bytes, params: 8, frame: 28
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_40177 = 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, a1, a2) {
|
|
var File = global.File;
|
|
var value = Object.create(File.prototype, {constructor: {value: File}});
|
|
var value2 = new File([a0], a1, {type: a2});
|
|
return value2 instanceof Object ? value2 : value;
|
|
};
|
|
const closure2 = classifyFileName;
|
|
const closure3 = maxFileSize;
|
|
const closure4 = getUploadFileSizeSum;
|
|
const closure5 = getMaxRequestSize;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
|
|
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
|
|
let value = require(661) /* metro dependency 661: Constants */;
|
|
const GuildFeatures = value.GuildFeatures;
|
|
const env0_6 = value.MAX_ATTACHMENT_SIZE;
|
|
value = require(1880) /* metro dependency 1880: PremiumConstants */;
|
|
const MAX_GUILD_FILE_SIZE_50_MB = value.MAX_GUILD_FILE_SIZE_50_MB;
|
|
const MAX_GUILD_FILE_SIZE_100_MB = value.MAX_GUILD_FILE_SIZE_100_MB;
|
|
const MAX_GUILD_FILE_SIZE_250_MB = value.MAX_GUILD_FILE_SIZE_250_MB;
|
|
const env0_7 = value.MAX_PREMIUM_TIER_2_ATTACHMENT_SIZE;
|
|
const items3 = [{reType: RegExp('^image\\/vnd.adobe.photoshop', ''), klass: 'photoshop'}];
|
|
items3[1] = {reType: RegExp('^image\\/svg\\+xml', ''), klass: 'webcode'};
|
|
items3[2] = {reType: RegExp('^image\\/', ''), klass: 'image'};
|
|
items3[3] = {reType: RegExp('^video\\/', ''), klass: 'video'};
|
|
items3[4] = {reName: RegExp('\\.pdf$', ''), klass: 'acrobat'};
|
|
items3[5] = {reName: RegExp('\\.ae', ''), klass: 'ae'};
|
|
items3[6] = {reName: RegExp('\\.sketch$', ''), klass: 'sketch'};
|
|
items3[7] = {reName: RegExp('\\.ai$', ''), klass: 'ai'};
|
|
items3[8] = {reName: RegExp('\\.(?:rar|zip|7z|tar|tar\\.gz)$', ''), klass: 'archive'};
|
|
items3[9] = {reName: RegExp('\\.(?:c\\+\\+|cpp|cc|c|h|hpp|mm|m|json|js|ts|rb|rake|py|asm|fs|pyc|dtd|cgi|bat|rss|java|graphml|idb|lua|o|gml|prl|sls|conf|cmake|make|sln|vbe|cxx|wbf|vbs|r|wml|php|bash|applescript|fcgi|yaml|ex|exs|sh|ml|actionscript)$',
|
|
''), klass: 'code'};
|
|
items3[10] = {reName: RegExp('\\.(?:txt|rtf|doc|docx|md|pages|ppt|pptx|pptm|key|log)$', ''), klass: 'document'};
|
|
items3[11] = {reName: RegExp('\\.(?:xls|xlsx|numbers|csv)$', ''), klass: 'spreadsheet'};
|
|
items3[12] = {reName: RegExp('\\.(?:html|xhtml|htm|xml|xsd|css|styl)$', ''), klass: 'webcode'};
|
|
items3[13] = {reName: RegExp('\\.(?:mp3|ogg|opus|wav|aiff|flac)$', ''), klass: 'audio'};
|
|
const MAX_FILE_SIZE_250_MB = GuildFeatures.MAX_FILE_SIZE_250_MB;
|
|
const items2 = [[MAX_FILE_SIZE_250_MB, MAX_GUILD_FILE_SIZE_250_MB]];
|
|
const MAX_FILE_SIZE_100_MB = GuildFeatures.MAX_FILE_SIZE_100_MB;
|
|
items2[1] = [MAX_FILE_SIZE_100_MB, MAX_GUILD_FILE_SIZE_100_MB];
|
|
const MAX_FILE_SIZE_50_MB = GuildFeatures.MAX_FILE_SIZE_50_MB;
|
|
items2[2] = [MAX_FILE_SIZE_50_MB, MAX_GUILD_FILE_SIZE_50_MB];
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/FileUtils.tsx');
|
|
exports.transformNativeFile = transformNativeFile;
|
|
exports.makeFile = closure;
|
|
exports.classifyFile = function(a0) {
|
|
return classifyFileName(a0.name, a0.type);
|
|
};
|
|
exports.classifyFileName = closure2;
|
|
exports.sizeString = sizeString;
|
|
exports.maxFileSize = closure3;
|
|
exports.anyFileTooLarge = anyFileTooLarge;
|
|
exports.getUploadFileSizeSum = closure4;
|
|
exports.uploadSumTooLarge = function(a0) {
|
|
var value2 = getUploadFileSizeSum(a0);
|
|
getMaxRequestSize();
|
|
return value2 > 524288000;
|
|
};
|
|
exports.getMaxRequestSize = closure5;
|
|
exports.fileUploadLimitRoadblockDescription = fileUploadLimitRoadblockDescription;
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_40175(a0, a1) { // fn#40175, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:315, offset: 0x010f89c8, 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 _fun40176;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_40177(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_40177(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_40177(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun40176;
|
|
}
|
|
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 classifyFileName(a0, a1) { // fn#40179, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2148, offset: 0x010f8b75, size: 120 bytes, params: 3, frame: 16
|
|
let env0_0 = a0;
|
|
const env0_1 = a1;
|
|
env0_0 = a0?.toLowerCase() ?? '';
|
|
value = Reflect.apply((importDefault(22) /* metro dependency 22 */).find, value, [env0_8, _fun40180]);
|
|
return value != null ? value.klass : 'unknown';
|
|
}
|
|
|
|
function maxFileSize(a0) { // fn#40181, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2469, offset: 0x010f8c55, size: 118 bytes, params: 2, frame: 16
|
|
const userMaxFileSize = (importDefault(3802) /* metro dependency 3802: PremiumUtils */).getUserMaxFileSize(UserStore.getCurrentUser());
|
|
if (a0 == null) {
|
|
return userMaxFileSize;
|
|
}
|
|
const guild = GuildStore.getGuild(a0);
|
|
const r3 = guild != null ? getGuildMaxFileSize(guild) : MAX_ATTACHMENT_SIZE;
|
|
const Math = global.Math;
|
|
return Math.max(r3, userMaxFileSize);
|
|
}
|
|
|
|
function getUploadFileSizeSum(a0) { // fn#40184, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2852, offset: 0x010f8db7, size: 70 bytes, params: 2, frame: 16
|
|
var r2;
|
|
var r3;
|
|
var r0;
|
|
var value4;
|
|
var size;
|
|
var value5;
|
|
var value6;
|
|
const value = _createForOfIteratorHelperLoose_40175(a0);
|
|
const value2 = value();
|
|
let done = value2.done;
|
|
const value3 = 0;
|
|
if (done) {
|
|
r0 = value3;
|
|
} else {
|
|
r2 = value3;
|
|
for (r3 = value2; true; r3 = value6) {
|
|
value4 = r3.value;
|
|
size = value4.size;
|
|
value5 = r2 + size;
|
|
value6 = value();
|
|
done = value6.done;
|
|
if (done) {
|
|
r0 = value5;
|
|
break;
|
|
}
|
|
r2 = value5;
|
|
}
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getMaxRequestSize() { // fn#40185, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2977, offset: 0x010f8dfd, size: 40 bytes, params: 1, frame: 9
|
|
const currentUser = UserStore.getCurrentUser();
|
|
if (currentUser != null) {
|
|
currentUser.isStaff();
|
|
}
|
|
return 524288000;
|
|
}
|
|
|
|
function transformNativeFile(a0, a1) { // fn#40186, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:3146, offset: 0x010f8e25, size: 77 bytes, params: 3, frame: 17
|
|
var r0;
|
|
var makeFileBinding;
|
|
var buffer;
|
|
var filename;
|
|
let value = a0;
|
|
const value2 = a1;
|
|
const File = global.File;
|
|
if (value instanceof File) {
|
|
r0 = value;
|
|
} else {
|
|
makeFileBinding = makeFile;
|
|
buffer = value.data.buffer;
|
|
filename = value.filename;
|
|
value = 'text/plain';
|
|
value = makeFileBinding(buffer, filename, value2 ?? value);
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function sizeString(a0) { // fn#40188, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:3419, offset: 0x010f8e90, size: 41 bytes, params: 2, frame: 11
|
|
return (importDefault(4656) /* metro dependency 4656 */).filesize(a0);
|
|
}
|
|
|
|
function anyFileTooLarge(a0, a1) { // fn#40189, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:3516, offset: 0x010f8eb9, size: 62 bytes, params: 3, frame: 12
|
|
const env0_0 = maxFileSize(a1);
|
|
const Array = global.Array;
|
|
return Array.from(a0).some(_fun40190);
|
|
}
|
|
|
|
function fileUploadLimitRoadblockDescription({guildId, onClick, maxSize}) { // fn#40192, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:3835, offset: 0x010f8f31, size: 204 bytes, params: 2, frame: 20
|
|
const fileSizeUtilsModule = require(4136) /* metro dependency 4136: FileSizeUtils */;
|
|
let formatSize = fileSizeUtilsModule.formatSize;
|
|
const value4 = Reflect.apply(formatSize, fileSizeUtilsModule,
|
|
[(maxSize ?? maxFileSize(guildId)) / 1024, {useKibibytes: true}]);
|
|
const moduleValue2 = fileSizeUtilsModule;
|
|
formatSize = moduleValue2.formatSize;
|
|
let value = MAX_PREMIUM_TIER_2_ATTACHMENT_SIZE / 1024;
|
|
value = Reflect.apply(formatSize, moduleValue2, [value, {useKibibytes: true}]);
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
return intl.format((require(1244) /* metro dependency 1244: indexNative */).t.tRuxk9, {maxSize: value4,
|
|
premiumMaxSize: value, onClick: onClick});
|
|
}
|
|
|
|
function _fun40180(a0) { // fn#40180, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2261, offset: 0x010f8bed, size: 104 bytes, params: 2, frame: 14
|
|
var r0;
|
|
if (a0.reType == null) {
|
|
r0 = a0.reName != null && env0_0 !== '';
|
|
r0 = r0 && a0.reName.test(env0_0);
|
|
} else if (require != null) {
|
|
r0 = a0.reType.test(require);
|
|
} else {
|
|
r0 = a0.reName != null && env0_0 !== '';
|
|
r0 = r0 && a0.reName.test(env0_0);
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getGuildMaxFileSize(a0) { // fn#40182, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2600, owner: maxFileSize.getGuildMaxFileSize, offset: 0x010f8ccb, size: 99 bytes, params: 2, frame: 15
|
|
const env0_0 = a0;
|
|
const FileUploadPowerupHoldoutExperiment = (require(4657) /* metro dependency 4657: FileUploadPowerupHoldoutExperiment */).FileUploadPowerupHoldoutExperiment;
|
|
const getConfig = FileUploadPowerupHoldoutExperiment.getConfig;
|
|
const env0_1 = Reflect.apply(getConfig, FileUploadPowerupHoldoutExperiment,
|
|
[{location: 'getGuildMaxFileSize'}]).enabled;
|
|
return env1_9.reduce(_fun40183, MAX_ATTACHMENT_SIZE);
|
|
}
|
|
|
|
function _fun40190({size}) { // fn#40190, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:3594, offset: 0x010f8ef7, size: 21 bytes, params: 2, frame: 2
|
|
return size > env0_0;
|
|
}
|
|
|
|
function _fun40183(a0, a1) { // fn#40183, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4833:2751, offset: 0x010f8d2e, size: 137 bytes, params: 3, frame: 16
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var item3;
|
|
var value4;
|
|
const value = a0;
|
|
const iterator = a1[Symbol.iterator]();
|
|
const iterator2 = iterator.next;
|
|
let item2 = Reflect.apply(iterator2, iterator, []);
|
|
let item = item2.value;
|
|
item2 = item2.done ? undefined : iterator;
|
|
const value2 = undefined;
|
|
const value3 = item2 === value2;
|
|
const r5 = value3 ? value2 : item;
|
|
if (value3) {
|
|
r0 = item2;
|
|
r1 = value3;
|
|
r2 = value2;
|
|
} else {
|
|
item3 = Reflect.apply(iterator2, item2, []);
|
|
item = item3.value;
|
|
item3 = item3.done ? undefined : item2;
|
|
value4 = item3 === value2;
|
|
if (value4) {
|
|
r0 = item3;
|
|
r1 = value4;
|
|
r2 = value2;
|
|
} else {
|
|
r0 = item3;
|
|
r1 = value4;
|
|
r2 = item;
|
|
}
|
|
}
|
|
if (!r1) {
|
|
r0.return();
|
|
}
|
|
return enabled && r5 === GuildFeatures.MAX_FILE_SIZE_250_MB ? value : env0_0.features.has(r5) && r2 > value ? r2 : value;
|
|
}
|
|
|