/* Metro module 6873; source: utils/ApplicationAssetUtils.tsx; dependencies: [57, 5, 6874, 661, 44, 507, 694, 3, 1457, 2] */ import Module00005 from '../by-id/module-00005.js'; /* Metro dependency 5 */ import Module00044 from '../by-id/module-00044.js'; /* Metro dependency 44 */ import Module00057 from '../by-id/module-00057.js'; /* Metro dependency 57 */ import ApplicationAssetsStore from '../modules/applications/ApplicationAssetsStore.tsx'; /* Metro dependency 6874 */ import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */ function _fun54417(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#54417, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:6, offset: 0x01364d47, size: 530 bytes, params: 8, frame: 24 const env0_0 = require; const _arrayLikeToArray_54420 = 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 updateAssets = function() { return _updateAssets.apply(this, arguments); }; const getAssetFromImageURL2 = getAssetFromImageURL; const closure2 = function() { return _getAssets.apply(this, arguments); }; const closure3 = function() { return _fetchAssetIds.apply(this, arguments); }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const PlatformTypes = ConstantsModule.PlatformTypes; const env0_8 = RegExp('https:\\/\\/static-cdn\\.jtvnw\\.net\\/previews-ttv\\/live_user_(.+)-\\{width\\}x\\{height\\}.jpg', ''); const env0_9 = RegExp('https:\\/\\/i\\.ytimg\\.com\\/vi\\/([a-zA-Z0-9_-]+)\\/hqdefault_live\\.jpg', ''); object = {}; const SPOTIFY = PlatformTypes.SPOTIFY; object[SPOTIFY] = {deserialize: function(a0) { return '' + 'https://i.scdn.co/image/' + (0, global.encodeURIComponent)(a0); }, serialize: function(a0) { return a0.split('https://i.scdn.co/image/')[1]; }}; const TWITCH = PlatformTypes.TWITCH; object[TWITCH] = {deserialize: function(a0, a1) { return 'https://static-cdn.jtvnw.net/previews-ttv/live_user_' + (0, global.encodeURIComponent)(a0) + '-' + a1[0] + 'x' + a1[1] + '.jpg'; }, serialize: serialize_54448}; const YOUTUBE = PlatformTypes.YOUTUBE; object[YOUTUBE] = {deserialize: function(a0) { return 'https://i.ytimg.com/vi/' + (0, global.encodeURIComponent)(a0) + '/hqdefault_live.jpg'; }, serialize: serialize_54450}; object['mp'] = {deserialize: deserialize_54451, serialize: function(a0) { return a0; }}; const Map = global.Map; const map = new Map(); (FileImportTrackerModule).fileFinishedImporting('utils/ApplicationAssetUtils.tsx'); exports.getAssetFromImageURL = getAssetFromImageURL2; exports.getAssetImage = getAssetImage; exports.getAssets = closure2; exports.fetchAssetIds = closure3; exports.getAssetIds = function(a0, a1) { var r2; var items = []; if (!updateUrlAssetIds(a1, items)) { r2 = ApplicationAssetsStore.getApplicationAssets(a0)?.assets; if (r2 != null) { updateNonUrlAssetIds(a1, items, r2); } } return items; }; function _createForOfIteratorHelperLoose_54418(a0, a1) { // fn#54418, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:177, offset: 0x01364f59, 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 _fun54419; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_54420(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_54420(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_54420(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun54419; } 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 _fun54419() { // fn#54419, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:748, 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 _updateAssets() { // fn#54422, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:2264, offset: 0x013650cb, size: 48 bytes, params: 1, frame: 14 return Module00005(_fun54424).apply(this, arguments); function* _fun54424(a0) { // fn#54424, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:2313, offset: 0x01365104, size: 174 bytes, params: 2, frame: 17 if (false) { return undefined; } value = environment.__proto__.__proto__; const HTTP = env2_0(env2_2[5]).HTTP; const get = HTTP.get; const object = {'url': null, 'oldFormErrors': true, 'rejectWithError': false}; object.url = env2_6.APPLICATION_ASSETS(a0); yield Reflect.apply(get, HTTP, [object]); const value3 = undefined; if (false) { return value3; } const body = value3.body; const value5 = env2_1(env2_2[6]); value5.dispatch({type: 'APPLICATION_ASSETS_UPDATE', applicationId: a0, assets: body}); return env2_5.getApplicationAssets(a0); } } function getApplicationAssetsMap(a0) { // fn#54425, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:2568, offset: 0x013651b2, size: 95 bytes, params: 2, frame: 15 const applicationAssets = ApplicationAssetsStore.getApplicationAssets(a0); return applicationAssets == null || global.Date.now() - applicationAssets.lastUpdated > 3600000 ? updateAssets(a0) : global.Promise.resolve(applicationAssets); } function getAssetFromImageURL(a0, a1) { // fn#54426, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:2750, offset: 0x01365211, size: 72 bytes, params: 3, frame: 16 var r0; let value = env0_10[a0].serialize(a1); if (value) { value = value.toString(); value = '' + a0 + ':' + value; r0 = value; } else { r0 = null; } return r0; } function _getAssets() { // fn#54428, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:2907, offset: 0x01365259, size: 48 bytes, params: 1, frame: 14 return Module00005(_fun54430).apply(this, arguments); function* _fun54430(a0) { // fn#54430, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:2950, offset: 0x01365292, size: 60 bytes, params: 2, frame: 12 if (false) { return undefined; } value = environment.__proto__.__proto__; value = undefined; yield env2_16(a0); const value3 = undefined; if (false) { return value3; } return value3 == null ? value : value3.assets; } } function _resolveExternalAssets() { // fn#54431, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:3059, offset: 0x013652ce, size: 48 bytes, params: 1, frame: 14 return Module00005(_fun54433).apply(this, arguments); function* _fun54433(a0, a1) { // fn#54433, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:3126, offset: 0x01365307, size: 228 bytes, params: 3, frame: 20 var environment; var r3; var value3; var binding; var HTTP; var post; var object; var value5; var done; var value6; var url; var external_asset_path; var set; var value7; if (true) { if (a1.filter(_fun54434).length !== 0) { value3 = environment.__proto__.__proto__; binding = env2_12; HTTP = env2_0(env2_2[5]).HTTP; post = HTTP.post; object = {}; object.url = env2_6.APPLICATION_EXTERNAL_ASSETS(a0); object.body = {urls: value}; object.oldFormErrors = true; object.rejectWithError = false; yield Reflect.apply(post, HTTP, [object]); value = undefined; if (false) { return value; } value = binding(value.body); value5 = value(); done = value5.done; if (!done) { r3 = value5; reducibleLoop5: while (true) { value6 = r3.value; url = value6.url; external_asset_path = value6.external_asset_path; binding = env2_11; set = binding.set; Reflect.apply(set, binding, [url, external_asset_path]); value7 = value(); done = value7.done; if (done) { break reducibleLoop5; } r3 = value7; continue reducibleLoop5; } } } } function _fun54434(a0) { // fn#54434, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:3157, offset: 0x013653eb, size: 35 bytes, params: 2, frame: 13 var r0; var binding; let value = a0 != null; if (value) { value = environment.__proto__.__proto__.__proto__; binding = env3_11; value = binding.get(a0) == null; r0 = value; } else { r0 = value; } return r0; } } } function updateUrlAssetIds(a0, a1) { // fn#54435, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:3469, offset: 0x0136540e, size: 156 bytes, params: 3, frame: 23 var r4; var r5; var r11; var r1; var property; var binding; let length = a0.filter(function(a0) { var r0; var value = undefined; r0 = a0 == null ? value : a0.startsWith('http:'); r0 = !r0 ? a0 == null ? value : a0.startsWith('https:') : r0; return r0; }).length; let value = 0; if (length > value) { length = a0.length; if (value < length) { r4 = value; r5 = value; while (true) { property = a0[r4]; if (property != null) { binding = env0_11; value = binding.get(property); if (value == null) { r11 = r5; break; } a1[r4] = getAssetFromImageURL('mp', value); value = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1; r11 = value; break; } r11 = r5; value = typeof r4 === 'bigint' ? r4 + 1n : +r4 + 1; length = a0.length; if (value < length) { r4 = value; r5 = r11; continue; } r1 = r11; break; } } else { r1 = value; } } else { r1 = value; } return r1 === a0.length; } function _fetchAssetIds() { // fn#54439, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:4055, offset: 0x01365596, size: 48 bytes, params: 1, frame: 14 return Module00005(_fun54441).apply(this, arguments); async function _fun54441(a0, a1) { // fn#54441, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:4106, offset: 0x013655d8, size: 402 bytes, params: 3, frame: 27 var environment; var r9; let value = a2; if (false) { return undefined; } const env0_0 = a0; const env0_1 = a1; const r11 = value !== undefined ? value : 1; await undefined; if (false) { return undefined; } value = environment.__proto__.__proto__; env2_1(env2_2[6]).dispatch({type: 'APPLICATION_ASSETS_FETCH', applicationId: a0}); items2 = []; const value6 = a1.filter(function(a0) { var r0; var value = undefined; r0 = a0 == null ? value : a0.startsWith('http:'); r0 = !r0 ? a0 == null ? value : a0.startsWith('https:') : r0; return r0; }); if (value6.length > 0) { await resolveExternalAssets(a0, value6); if (false) { return undefined; } } if (env2_21(a1, items2)) { env2_1(env2_2[6]).dispatch({type: 'APPLICATION_ASSETS_FETCH_SUCCESS', applicationId: a0}); return items2; } await env2_18(a0); const value9 = undefined; if (false) { return value9; } const value11 = env2_1(env2_2[6]); value11.dispatch({type: 'APPLICATION_ASSETS_UPDATE', applicationId: a0, assets: value9}); if (env2_22(a1, items2, value9, r11)) { value = env2_14(a0); value = value.then(_fun54444); r9 = value; } else { env2_1(env2_2[6]).dispatch({type: 'APPLICATION_ASSETS_FETCH_SUCCESS', applicationId: a0}); r9 = items2; } return r9; function resolveExternalAssets() { // fn#54443, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:4322, offset: 0x0136576a, size: 30 bytes, params: 1, frame: 13 return env3_20.apply(this, arguments); } function _fun54444() { // fn#54444, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:4686, offset: 0x01365788, size: 40 bytes, params: 1, frame: 15 return env3_23(env0_0, require, env0_2 - 1); } } } function serialize_54448(a0) { // fn#54448, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:1551, offset: 0x01365842, size: 39 bytes, params: 2, frame: 11 const value = a0.match(env0_8); const value2 = null; return value2 != value ? value[1] : value2; } function serialize_54450(a0) { // fn#54450, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:1714, offset: 0x0136589a, size: 39 bytes, params: 2, frame: 11 const value = a0.match(env0_9); const value2 = null; return value2 != value ? value[1] : value2; } function deserialize_54451(a0) { // fn#54451, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:1779, offset: 0x013658c1, size: 300 bytes, params: 2, frame: 17 let value = Module00044; let GLOBAL_ENV = global.window.GLOBAL_ENV; let MEDIA_PROXY_ENDPOINT = GLOBAL_ENV.MEDIA_PROXY_ENDPOINT; value(MEDIA_PROXY_ENDPOINT != null, 'MEDIA_PROXY_ENDPOINT not configured'); const URL = global.URL; const protocol = global.location.protocol; GLOBAL_ENV = global.window.GLOBAL_ENV; MEDIA_PROXY_ENDPOINT = GLOBAL_ENV.MEDIA_PROXY_ENDPOINT; value = protocol + MEDIA_PROXY_ENDPOINT; const uRL = new URL(a0); const value4 = a0.toLowerCase().endsWith('.gif'); const value6 = a0.toLowerCase().endsWith('.webp'); const value8 = a0.toLowerCase().endsWith('.avif'); if (value4 || value8) { uRL.searchParams.set('format', 'webp'); } let r0 = value4 || value6; r0 = !r0 ? value8 : r0; if (r0) { uRL.searchParams.set('animated', 'true'); } return uRL.toString(); } function getAssetImage(a0, a1, a2) { // fn#54453, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:4964, offset: 0x013659ed, size: 610 bytes, params: 4, frame: 34 var r8; var r13; var r0; var r1; var Array; var Math; var max; var items2; var value12; var property; var property2; var hasOwnProperty; let value = a2; const value2 = a3; const value3 = undefined; const r15 = value2 !== value3 ? value2 : 'png'; if (a1 != null) { if (a1.includes(':')) { value12 = Module00057(a1.split(':'), 2); property = value12[0]; property2 = value12[1]; if (property === PlatformTypes.TWITCH) { if (value == null) { value = importDefault(3) /* metro dependency 3: Logger */; value = new value('ApplicationAssetUtils'); value.warn('getAssetImage: size must === [number, number] for Twitch'); r1 = value3; } else if (typeof value === 'number') { value = importDefault(3) /* metro dependency 3: Logger */; value = new value('ApplicationAssetUtils'); value.warn('getAssetImage: size must === [number, number] for Twitch'); r1 = value3; } else { value = env0_10[PlatformTypes.TWITCH].deserialize(property2, value); r1 = value; } r0 = r1; } else { hasOwnProperty = global.Object.prototype.hasOwnProperty; r0 = hasOwnProperty.call(env0_10, property) ? env0_10[property].deserialize(property2) : value3; } return r0; } } if (a0 != null) { if (a1 != null) { Array = global.Array; if (Array.isArray(value)) { Math = global.Math; max = Math.max; items2 = []; arraySpread(items2, value, 0, undefined); value = apply(max, items2, Math, undefined); r8 = value; } else { r8 = value; } value = ''; r13 = typeof r8 !== 'number' ? value : '?size=' + (require(1457) /* metro dependency 1457: ImageLoaderUtils */).getBestMediaProxySize(r8); if (global.window.GLOBAL_ENV.CDN_HOST != null) { value = value + global.location.protocol + '//' + global.window.GLOBAL_ENV.CDN_HOST + '/app-assets/' + a0 + '/' + a1 + '.' + r15 + r13; r0 = value; } else { value = value + (require(507) /* metro dependency 507: HTTPUtils */).getAPIBaseURL() + '/applications/' + a0 + '/app-assets/' + a1 + '.' + r15 + r13; r0 = value; } return r0; } } return value3; } } function updateNonUrlAssetIds(a0, a1, a2, a3) { // fn#54437, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7051:3756, offset: 0x013654e9, size: 173 bytes, params: 5, frame: 26 var r2; var r3; var r1; var r15; var r13; var r0; var property; var Object; var prototype; var hasOwnProperty; var call; var value3; var value4; var id; var value5; let length = a0.length; const value = 0; const value2 = false; if (value < length) { r2 = value; r3 = value2; reducibleLoop1: while (true) { property = a0[r2]; reducibleJoin10: while (true) { if (property == null) { r13 = r3; break reducibleJoin10; } if (a1[r2] != null) { r13 = r3; break reducibleJoin10; } Object = global.Object; prototype = Object.prototype; hasOwnProperty = prototype.hasOwnProperty; call = hasOwnProperty.call; value3 = Reflect.apply(call, hasOwnProperty, [a2, property]); reducibleJoin5: while (true) { if (value3) { property = a2[property]; r1 = property; break reducibleJoin5; } r1 = value3; break reducibleJoin5; } if (!r1) { if (a3 != null) { value4 = true; if (!(a3 <= value)) { r15 = value4; a1[r2] = r1.id; r13 = r15; break reducibleJoin10; } } a1[r2] = null; r13 = r3; break reducibleJoin10; } r15 = r3; id = r1.id; a1[r2] = id; r13 = r15; break reducibleJoin10; } value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; length = a0.length; if (value5 < length) { r2 = value5; r3 = r13; continue reducibleLoop1; } r0 = r13; break reducibleLoop1; } } else { r0 = value2; } return r0; } global.__d(_fun54417, 6873, [57, 5, 6874, 661, 44, 507, 694, 3, 1457, 2]) /* metro module 6873, dependencies: [57, 5, 6874, 661, 44, 507, 694, 3, 1457, 2] */;