/* Metro module 10012; source: modules/game_profile/AnnouncementMessageUtils.tsx; dependencies: [3794, 1909, 4630, 4631, 10013, 4625, 8433, 1244, 1471, 2] */ import URLUtils from '../../utils/URLUtils.tsx'; /* Metro dependency 1471 */ import MaybeCreateMessageRecordFromSnapshot from '../forwarding/maybeCreateMessageRecordFromSnapshot.tsx'; /* Metro dependency 10013 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as MessageRecordModule from '../../records/MessageRecord.tsx'; /* Metro dependency 3794 */ import * as MessageRecordUtilsModule from '../messages/MessageRecordUtils.tsx'; /* Metro dependency 4625 */ import * as MediaFormatTestersModule from '../messages/MediaFormatTesters.tsx'; /* Metro dependency 4631 */ import * as UseFormattedExpirationLabelModule from '../polls/chat/useFormattedExpirationLabel.tsx'; /* Metro dependency 8433 */ function _fun78204(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#78204, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:6, offset: 0x01e211e2, size: 186 bytes, params: 8, frame: 18 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_4 = RegExp('^#{1,3}\\s+(.+)$', ''); const env0_5 = RegExp('^https?:\\/\\/\\S+$', ''); (FileImportTrackerModule).fileFinishedImporting('modules/game_profile/AnnouncementMessageUtils.tsx'); exports.toAnnouncementMessages = function(a0) { return a0.map(_fun78206); }; exports.getPollExpiryLabel = getPollExpiryLabel; exports.getPosterUrl = getPosterUrl; function toAnnouncementMessages(a0) { // fn#78205, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:281, offset: 0x01e2129c, size: 24 bytes, params: 2, frame: 11 return a0.map(_fun78206); function _fun78206(a0) { // fn#78206, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:330, offset: 0x01e212b4, size: 635 bytes, params: 2, frame: 28 var r2; var name; var iconProxyURL; var r14; var r13; var r12; var r0; var object; var property; var author; var footer; var url; const value2 = undefined; const defaultImport = MaybeCreateMessageRecordFromSnapshot; const value3 = defaultImport(MessageRecordUtilsModule.createMessageRecord(a0)); const content = value3.content; const value4 = extractContent(value3); const value5 = extractMedia(value3); const value6 = value4.indexOf('\n'); const value7 = value6 === -1; const value9 = (value7 ? value4 : value4.slice(0, value6)).match(env1_4); if (value9 != null) { object = {}; object.title = value9[1].trim(); object.body = value7 ? '' : value4.slice(value6 + 1).trimStart(); r2 = object; } else { r2 = {body: value4}; } const title = r2.title; const body = r2.body; const reactions = a0.reactions; r2 = reactions == null ? value2 : reactions.reduce(function(a0, a1) { return a0 + a1.count; }, 0); const value14 = 0; const r3 = r2 ?? value14; if (value4 === content) { r2 = value2; } else if (isMessageComponentsV2(value3)) { r2 = value2; } else { property = value3.embeds[value14]; if (property != null) { author = property.author; name = author == null ? value2 : author.name; author = property.author; iconProxyURL = author == null ? value2 : author.iconProxyURL; r14 = iconProxyURL ?? (property.author == null ? value2 : property.author.iconURL); footer = property.footer; r13 = (footer == null ? value2 : footer.text) ?? (property.provider == null ? value2 : property.provider.name); footer = property.footer; iconProxyURL = footer == null ? value2 : footer.iconProxyURL; r12 = iconProxyURL ?? (property.footer == null ? value2 : property.footer.iconURL); url = property.url; r0 = name != null || r13 != null || url != null ? {authorName: name, authorIconUrl: r14, providerName: r13, providerIconUrl: r12, url: url, color: property.color ?? value2} : value2; } else { r0 = value2; } r2 = r0; } return {id: value3.id, media: value5, title: title, body: body, content: value4, timestamp: a0.timestamp, reactionCount: r3, embedSource: r2, poll: value3.poll}; function extractContent(a0) { // fn#78207, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:399, offset: 0x01e2152f, size: 268 bytes, params: 2, frame: 20 var environment; var r2; var binding; var property; var items2; let value = environment.__proto__.__proto__; if (isMessageComponentsV2(a0)) { value = a0.components.filter(function({type}) { return type === require(dependencyMap[1]).ComponentType.TEXT_DISPLAY; }); value = value.map(_fun78209); return value.join('\n'); } const content = a0.content; if (content.length === 0) { property = a0.embeds[0]; value = null; if (value == property) { r2 = value; } else { items2 = []; if (value != property.rawTitle) { items2.push('# ' + property.rawTitle); } if (value != property.rawDescription) { items2.push(property.rawDescription); } r2 = items2.length > 0 ? items2.join('\n') : value; } r2 = value == r2 ? content : r2; } else { binding = env2_5; if (binding.test(content.trim())) { property = a0.embeds[0]; value = null; if (value == property) { r2 = value; } else { items2 = []; if (value != property.rawTitle) { items2.push('# ' + property.rawTitle); } if (value != property.rawDescription) { items2.push(property.rawDescription); } r2 = items2.length > 0 ? items2.join('\n') : value; } r2 = value == r2 ? content : r2; } else { r2 = content; } } return r2; } function extractMedia(a0) { // fn#78210, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:836, offset: 0x01e2166e, size: 737 bytes, params: 2, frame: 29 var environment; var media; var thumbnail; var image; var r9; var value3; var unfurledMediaItemType; var attachments; var value5; var value6; var embeds; var value7; var value8; var value9; var embedMediaToMediaItem; var object; var object2; var object3; var object4; let value = environment.__proto__.__proto__; const isMessageComponentsV2Binding = isMessageComponentsV2; const value2 = undefined; if (isMessageComponentsV2Binding(a0)) { value3 = a0.components.find(function({type}) { return type === require(dependencyMap[1]).ComponentType.MEDIA_GALLERY; }); media = value3 == null || value3.items[0] == null ? value2 : value3.items[0].media; if (media == null) { attachments = a0.attachments; value5 = attachments.find(_fun78212); if (value5 != null) { return (require(4630) /* metro dependency 4630: MediaTypes */).messageAttachmentToMediaItem(value5, a0); } attachments = a0.attachments; value6 = attachments.find(_fun78213); if (value6 != null) { return (require(4630) /* metro dependency 4630: MediaTypes */).messageAttachmentToMediaItem(value6, a0); } embeds = a0.embeds; value7 = embeds.find(_fun78214); thumbnail = value7 == null ? value2 : value7.thumbnail; if (thumbnail != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; thumbnail = value7.thumbnail; object4 = {type: 'embed'}; object4.embedIndex = a0.embeds.findIndex(_fun78215); return Reflect.apply(embedMediaToMediaItem, value, [thumbnail, {message: a0, identifier: object4}, 'IMAGE']); } embeds = a0.embeds; value8 = embeds.find(_fun78216); image = value8 == null ? value2 : value8.image; if (image != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; image = value8.image; object3 = {type: 'embed'}; object3.embedIndex = a0.embeds.findIndex(_fun78217); return Reflect.apply(embedMediaToMediaItem, value, [image, {message: a0, identifier: object3}, 'IMAGE']); } embeds = a0.embeds; value9 = embeds.find(_fun78218); thumbnail = value9 == null ? value2 : value9.thumbnail; if (thumbnail != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; thumbnail = value9.thumbnail; object2 = {type: 'embed'}; object2.embedIndex = a0.embeds.findIndex(_fun78219); value = Reflect.apply(embedMediaToMediaItem, value, [thumbnail, {message: a0, identifier: object2}, 'IMAGE']); r9 = value; } else { r9 = value2; } return r9; } unfurledMediaItemType = (require(4630) /* metro dependency 4630: MediaTypes */).getUnfurledMediaItemType(media); if (unfurledMediaItemType !== 'INVALID') { object = {}; copyDataProperties(object, media, undefined); object['type'] = unfurledMediaItemType; object['sourceMetadata'] = {message: a0}; return object; } attachments = a0.attachments; value5 = attachments.find(_fun78212); if (value5 != null) { return (require(4630) /* metro dependency 4630: MediaTypes */).messageAttachmentToMediaItem(value5, a0); } attachments = a0.attachments; value6 = attachments.find(_fun78213); if (value6 != null) { return (require(4630) /* metro dependency 4630: MediaTypes */).messageAttachmentToMediaItem(value6, a0); } embeds = a0.embeds; value7 = embeds.find(_fun78214); thumbnail = value7 == null ? value2 : value7.thumbnail; if (thumbnail != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; thumbnail = value7.thumbnail; object4 = {type: 'embed'}; object4.embedIndex = a0.embeds.findIndex(_fun78215); return Reflect.apply(embedMediaToMediaItem, value, [thumbnail, {message: a0, identifier: object4}, 'IMAGE']); } embeds = a0.embeds; value8 = embeds.find(_fun78216); image = value8 == null ? value2 : value8.image; if (image != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; image = value8.image; object3 = {type: 'embed'}; object3.embedIndex = a0.embeds.findIndex(_fun78217); return Reflect.apply(embedMediaToMediaItem, value, [image, {message: a0, identifier: object3}, 'IMAGE']); } embeds = a0.embeds; value9 = embeds.find(_fun78218); } else { value5 = a0.attachments.find(_fun78212); if (value5 != null) { return (require(4630) /* metro dependency 4630: MediaTypes */).messageAttachmentToMediaItem(value5, a0); } value6 = a0.attachments.find(_fun78213); if (value6 != null) { return (require(4630) /* metro dependency 4630: MediaTypes */).messageAttachmentToMediaItem(value6, a0); } value7 = a0.embeds.find(function(a0) { return a0.video != null && a0.thumbnail != null; }); thumbnail = value7 == null ? value2 : value7.thumbnail; if (thumbnail != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; thumbnail = value7.thumbnail; object4 = {type: 'embed'}; object4.embedIndex = a0.embeds.findIndex(_fun78215); return Reflect.apply(embedMediaToMediaItem, value, [thumbnail, {message: a0, identifier: object4}, 'IMAGE']); } value8 = a0.embeds.find(function(a0) { return a0.image != null; }); image = value8 == null ? value2 : value8.image; if (image != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; image = value8.image; object3 = {type: 'embed'}; object3.embedIndex = a0.embeds.findIndex(_fun78217); return Reflect.apply(embedMediaToMediaItem, value, [image, {message: a0, identifier: object3}, 'IMAGE']); } value9 = a0.embeds.find(function(a0) { return a0.thumbnail != null; }); } thumbnail = value9 == null ? value2 : value9.thumbnail; if (thumbnail != null) { value = require(4630) /* metro dependency 4630: MediaTypes */; embedMediaToMediaItem = value.embedMediaToMediaItem; thumbnail = value9.thumbnail; object2 = {type: 'embed'}; object2.embedIndex = a0.embeds.findIndex(_fun78219); value = Reflect.apply(embedMediaToMediaItem, value, [thumbnail, {message: a0, identifier: object2}, 'IMAGE']); r9 = value; } else { r9 = value2; } return r9; function _fun78212({content_type}) { // fn#78212, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:1141, offset: 0x01e21982, size: 47 bytes, params: 2, frame: 11 const value = environment.__proto__.__proto__.__proto__; return (MediaFormatTestersModule).isImageContentType(content_type); } function _fun78213({content_type}) { // fn#78213, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:1277, offset: 0x01e219b1, size: 47 bytes, params: 2, frame: 11 const value = environment.__proto__.__proto__.__proto__; return (MediaFormatTestersModule).isVideoContentType(content_type); } function _fun78215(a0) { // fn#78215, offset: 0x00fcba1c, size: 16 bytes, params: 2, frame: 2 return a0 === env0_0; } function _fun78217(a0) { // fn#78217, offset: 0x0136dddc, size: 16 bytes, params: 2, frame: 2 return a0 === env0_1; } function _fun78219(a0) { // fn#78219, offset: 0x00e41b78, size: 16 bytes, params: 2, frame: 2 return a0 === env0_2; } } } } function getPollExpiryLabel({expiry}) { // fn#78221, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:3028, offset: 0x01e21a20, size: 108 bytes, params: 2, frame: 15 var r0; var intl; const value2 = (UseFormattedExpirationLabelModule).formatExpirationLabel(expiry); if (value2 != null) { r0 = value2; } else { intl = (require(1244) /* metro dependency 1244: indexNative */).intl; r0 = intl.string((require(1244) /* metro dependency 1244: indexNative */).t['e+J3JZ']); } return r0; } function getPosterUrl(a0) { // fn#78222, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:3184, offset: 0x01e21a8c, size: 87 bytes, params: 2, frame: 15 var r0; let value = URLUtils; value = value.toURLSafe(a0); const value2 = null; if (value2 == value) { r0 = value2; } else { value.searchParams.append('format', 'webp'); value = value.toString(); r0 = value; } return r0; } } function _fun78209(a0) { // fn#78209, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:517, offset: 0x0100659f, size: 10 bytes, params: 2, frame: 1 return a0.content; } function _fun78214(a0) { // fn#78214, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:1408, offset: 0x01e219e0, size: 30 bytes, params: 2, frame: 4 return a0.video != null && a0.thumbnail != null; } function _fun78216({image}) { // fn#78216, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:1644, offset: 0x01e219fe, size: 17 bytes, params: 2, frame: 2 return image != null; } function _fun78218({thumbnail}) { // fn#78218, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10198:1853, offset: 0x01e21a0f, size: 17 bytes, params: 2, frame: 2 return thumbnail != null; } global.__d(_fun78204, 10012, [3794, 1909, 4630, 4631, 10013, 4625, 8433, 1244, 1471, 2]) /* metro module 10012, dependencies: [3794, 1909, 4630, 4631, 10013, 4625, 8433, 1244, 1471, 2] */;