Files
2026-07-28 01:06:53 +03:00

354 lines
16 KiB
TypeScript

/* Metro module 1457; source: modules/image_upload/ImageLoaderUtils.tsx; dependencies: [57, 5, 661, 1393, 561, 1458, 1468, 1471, 1475, 22, 1852, 2] */
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
import defaultImport2 from '../../by-id/module-00022.js'; /* Metro dependency 22 */
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
import Module01468 from '../../by-id/module-01468.js'; /* Metro dependency 1468 */
import URLUtils from '../../utils/URLUtils.tsx'; /* Metro dependency 1471 */
import GetDevicePixelRatioNative from '../../utils/getDevicePixelRatio.native.tsx'; /* Metro dependency 1852 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as ImageUtilsModule from '../../utils/ImageUtils.tsx'; /* Metro dependency 1475 */
function _fun16687(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#16687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:6, offset: 0x00e57b5b, size: 373 bytes, params: 8, frame: 20
let env0_0 = require;
const loadImageAsset = function(a0) {
var env0_0 = a0;
var Image = global.Image;
var value2 = new Image();
var env0_1 = value2;
value2.onerror = _fun16689(a0, value2);
value2.onload = _fun16693;
value2.src = a0.url;
};
const getSrcWithWidthAndHeight2 = getSrcWithWidthAndHeight;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ConstantsModule;
const env0_5 = value.NOOP;
const env0_6 = value.MEDIA_PROXY_MAX_TARGET_RESOLUTION;
const env0_7 = RegExp('\\.webp($|\\?|#)', 'i');
const env0_8 = RegExp('\\.avif($|\\?|#)', 'i');
const env0_9 = [16, 20, 22, 24, 28, 32, 40, 44, 48, 56, 60, 64, 80, 96, 100, 128, 160, 240, 256, 300, 320, 480, 512,
600, 640, 1024, 1280, 1536, 2048, 3072, 4096];
value = importDefault(1393) /* metro dependency 1393 */;
value = new value({max: 1000});
(FileImportTrackerModule).fileFinishedImporting('modules/image_upload/ImageLoaderUtils.tsx');
exports.getDevicePixelRatio = importDefault(1852) /* metro dependency 1852: getDevicePixelRatioNative */;
exports.isImageLoaded = isImageLoaded;
exports.loadImage = loadImage;
exports.getBestMediaProxySize = getBestMediaProxySize;
exports.getSrcWithWidthAndHeight = getSrcWithWidthAndHeight2;
exports.getSizedImageSrc = getSizedImageSrc;
exports.getImageSrc = getImageSrc;
function loadImageAsset(a0) { // fn#16688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:359, offset: 0x00e57cd0, size: 84 bytes, params: 2, frame: 14
const env0_0 = a0;
const Image = global.Image;
const image = new Image();
image.onerror = getOnError(a0, image);
image.onload = onload_16693;
image.src = a0.url;
function getOnError(a0, a1) { // fn#16689, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:412, owner: loadImageAsset.getOnError, offset: 0x00e57d24, size: 110 bytes, params: 3, frame: 13
var environment;
var value;
const env0_0 = a0;
const env0_1 = a1;
let backoff = a0.backoff;
if (backoff == null) {
value = environment.__proto__;
value = importDefault(561) /* metro dependency 561: Backoff */;
value = new value();
a0.backoff = value;
}
backoff = a0.backoff;
value = environment.__proto__;
return env1_4(_fun16691);
function* _fun16691() { // fn#16691, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:505, offset: 0x00e57d9b, size: 123 bytes, params: 1, frame: 18
var environment;
if (true) {
value = environment.__proto__.__proto__.__proto__;
var value3 = env3_1(env3_2[5]);
yield value3.isOnline();
if (false) {
return undefined;
}
if (env1_2.fails < 5) {
env1_2.fail(_fun16692);
} else {
env3_12(true, env1_0, env1_1);
}
}
function _fun16692() { // fn#16692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:560, offset: 0x00e57e16, size: 23 bytes, params: 1, frame: 11
env4_11(env2_0);
}
}
}
function loadImageAssetOnload() { // fn#16693, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:628, owner: loadImageAsset.onload, offset: 0x00e57e2d, size: 57 bytes, params: 1, frame: 15
const backoff = env0_0.backoff;
if (backoff != null) {
backoff.succeed();
}
handleImageLoad(false, env0_0, env0_1);
}
}
function handleImageLoad(a0, a1, a2) { // fn#16694, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:707, offset: 0x00e57e66, size: 131 bytes, params: 4, frame: 16
const env0_0 = a0;
const env0_1 = a1;
const callbacks = a1.callbacks;
const url = a1.url;
if (a0) {
env0_10.del(url);
} else {
env0_10.set(url, {url: url, loaded: true, width: a2.width, height: a2.height});
}
if (callbacks != null) {
callbacks.forEach(_fun16695);
}
function _fun16695(a0) { // fn#16695, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:881, offset: 0x00e57ee9, size: 24 bytes, params: 2, frame: 13
return a0(env0_0, require);
}
}
function splitURL(a0) { // fn#16696, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:893, offset: 0x00e57f01, size: 95 bytes, params: 2, frame: 15
let value = a0.split('?');
value = Module00057(value, 2);
const property = value[0];
const property2 = value[1];
const items2 = [property];
value = importDefault(1468) /* metro dependency 1468 */;
items2[1] = value.parse(property2);
return items2;
}
function getSrcWithWidthAndHeight({src, sourceWidth, sourceHeight, targetWidth, targetHeight, format, quality, animated, srcIsAnimated}) { // fn#16697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:983, offset: 0x00e57f60, size: 472 bytes, params: 2, frame: 24
var value;
format = format === undefined ? null : format;
quality = quality === undefined ? null : quality;
animated = !(animated === undefined) && animated;
srcIsAnimated = !(srcIsAnimated === undefined) && srcIsAnimated;
if (src.startsWith('data:image')) {
return src;
}
const defaultImport = URLUtils;
if (defaultImport.isDiscordCdnUrl(src)) {
return src;
}
const value3 = Module00057(splitURL(src), 2);
const property = value3[0];
const property2 = value3[1];
if (format != null) {
property2.format = format;
}
if (quality != null) {
property2.quality = quality;
}
let r1 = animated && srcIsAnimated && (env0_7.test(src) || env0_8.test(src));
if (r1) {
property2.animated = true;
}
const binding = env0_8;
if (binding.test(src)) {
property2.format = 'webp';
}
const {width, height} = (ImageUtilsModule).fit({width: targetWidth,
height: targetHeight, maxWidth: MEDIA_PROXY_MAX_TARGET_RESOLUTION,
maxHeight: MEDIA_PROXY_MAX_TARGET_RESOLUTION});
if (!(width === sourceWidth && height === sourceHeight)) {
property2.width = width | 0;
property2.height = height | 0;
}
if (defaultImport2.isEmpty(property2)) {
r1 = property;
} else {
value = importDefault(1468) /* metro dependency 1468 */;
value = value.stringify(property2);
value = property + ('?' + value);
r1 = value;
}
return r1;
}
function isImageLoaded(a0) { // fn#16698, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1679, offset: 0x00e58138, size: 37 bytes, params: 2, frame: 11
const value = env0_10.get(a0);
return value != null && value.loaded;
}
function loadImage(a0, a1) { // fn#16699, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1758, offset: 0x00e5815d, size: 243 bytes, params: 3, frame: 18
var r0;
var object;
var set;
var callbacks;
var Set;
var value3;
const env0_0 = a0;
var value;
const value2 = env0_10.get(a0);
if (value2 == null) {
if (value2 != null) {
r0 = value2;
} else {
object = {url: a0, loaded: false};
env0_10.set(a0, object);
loadImageAsset(object);
r0 = object;
}
if (a1 != null) {
value = a1.bind(null);
callbacks = r0.callbacks;
if (callbacks == null) {
Set = global.Set;
value3 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set();
r0.callbacks = set instanceof Object ? set : value3;
}
callbacks = r0.callbacks;
callbacks.add(value);
}
r0 = _fun16702;
} else if (value2.loaded) {
if (a1 != null) {
(importDefault(1458) /* metro dependency 1458: NetworkUtils */).awaitOnline().then(_fun16700);
}
r0 = NOOP;
} else {
if (value2 != null) {
r0 = value2;
} else {
object = {url: a0, loaded: false};
env0_10.set(a0, object);
loadImageAsset(object);
r0 = object;
}
if (a1 != null) {
value = a1.bind(null);
callbacks = r0.callbacks;
if (callbacks == null) {
Set = global.Set;
value3 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set();
r0.callbacks = set instanceof Object ? set : value3;
}
callbacks = r0.callbacks;
callbacks.add(value);
}
r0 = _fun16702;
}
return r0;
function _fun16700() { // fn#16700, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1862, offset: 0x00e58250, size: 64 bytes, params: 1, frame: 12
if (env0_2 != null && env0_2.callbacks != null) {
env0_2.callbacks.forEach(_fun16701);
}
function _fun16701(a0) { // fn#16701, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1916, offset: 0x00e58290, size: 61 bytes, params: 2, frame: 14
if (env1_2 != null) {
a0(false, env1_2);
} else {
a0(true, {url: env1_0, loaded: true});
}
}
}
function _fun16702() { // fn#16702, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2116, offset: 0x00e582cd, size: 103 bytes, params: 1, frame: 13
if (env0_1 != null && env0_2 != null) {
if (env0_2.callbacks != null) {
env0_2.callbacks.delete(env0_1);
}
if (env0_2.backoff != null) {
env0_2.backoff.cancel();
}
}
}
}
function getBestMediaProxySize(a0) { // fn#16703, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2245, offset: 0x00e58334, size: 132 bytes, params: 2, frame: 13
var environment;
var binding;
var value2;
let value = a1;
const env0_0 = a0;
if (value !== undefined ? value : false) {
binding = env0_9;
value = binding.filter(_fun16704);
value = value.pop();
if (value == null) {
value = environment;
return env0_9.find(_fun16705) ?? env0_9[env0_9.length - 1];
}
if (a0 / value <= 1.25) {
return value;
}
binding = env0_9;
value2 = binding.find(_fun16705);
} else {
value2 = env0_9.find(_fun16705);
}
return value2 ?? env0_9[env0_9.length - 1];
function _fun16704(a0) { // fn#16704, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2312, offset: 0x00e583b8, size: 16 bytes, params: 2, frame: 2
return a0 <= env0_0;
}
function _fun16705(a0) { // fn#16705, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2383, offset: 0x00e583c8, size: 16 bytes, params: 2, frame: 2
return env0_0 <= a0;
}
}
function getSizedImageSrc(a0, a1, a2) { // fn#16706, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2482, offset: 0x00e583d8, size: 225 bytes, params: 4, frame: 21
let value = a3;
const r6 = value !== undefined ? value : 'webp';
const value2 = (GetDevicePixelRatioNative)();
let Math = global.Math;
const value3 = Math.ceil(a1 * value2);
Math = global.Math;
const value4 = Math.ceil(a2 * value2);
value = Module00057(splitURL(a0), 2);
const property = value[0];
const property2 = value[1];
const stringify = (Module01468).stringify;
const object = {};
copyDataProperties(object, property2, undefined);
object['width'] = value3 | 0;
object['height'] = value4 | 0;
object['format'] = r6;
value = Reflect.apply(stringify, value, [object]);
return '' + property + '?' + value;
}
function getImageSrc({src, width, height, maxWidth, maxHeight, ratio, format, quality, animated, srcIsAnimated}) { // fn#16707, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2703, offset: 0x00e584b9, size: 294 bytes, params: 2, frame: 26
var r7;
var r14;
var value;
var Math;
ratio = ratio === undefined ? 1 : ratio;
format = format === undefined ? null : format;
quality = quality === undefined ? null : quality;
animated = !(animated === undefined) && animated;
srcIsAnimated = !(srcIsAnimated === undefined) && srcIsAnimated;
if (ratio < 1) {
Math = global.Math;
value = Math.round(width * ratio);
Math = global.Math;
r7 = Math.round(height * ratio);
r14 = value;
} else {
r7 = height;
r14 = width;
}
const r9 = maxWidth == null ? r14 : global.Math.min(r14, maxWidth);
const r8 = maxHeight == null ? r7 : global.Math.min(r7, maxHeight);
const value3 = (GetDevicePixelRatioNative)();
return getSrcWithWidthAndHeight({src: src, sourceWidth: width, sourceHeight: height, targetWidth: r9 * value3,
targetHeight: r8 * value3, format: format, quality: quality, animated: animated, srcIsAnimated: srcIsAnimated});
}
}
global.__d(_fun16687, 1457, [57, 5, 661, 1393, 561, 1458, 1468, 1471, 1475, 22, 1852,
2]) /* metro module 1457, dependencies: [57, 5, 661, 1393, 561, 1458, 1468, 1471, 1475, 22, 1852, 2] */;