Files
discord-decomp/sources/modules/markup/MarkupChannelMentionRule.tsx
2026-07-28 01:06:53 +03:00

342 lines
18 KiB
TypeScript

/* Metro module 6631; source: modules/markup/MarkupChannelMentionRule.tsx; dependencies: [1936, 1379, 1867, 3784, 3793, 1878, 661, 1861, 1423, 1244, 6632, 4800, 4805, 6633, 4246, 6629, 3855, 2] */
import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import GatedChannelStore from '../channel/GatedChannelStore.tsx'; /* Metro dependency 1936 */
import PermissionStore from '../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */
import RelationshipStore from '../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as StringUtilsModule from '../../utils/StringUtils.tsx'; /* Metro dependency 1861 */
import * as LinkUtilsModule from '../links/LinkUtils.tsx'; /* Metro dependency 4246 */
import * as ChannelUtilsModule from '../../utils/ChannelUtils.tsx'; /* Metro dependency 4800 */
import * as UseChannelRoleSubscriptionStatusModule from '../guild_role_subscriptions/useChannelRoleSubscriptionStatus.tsx'; /* Metro dependency 6632 */
function _fun52498(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#52498, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:6, offset: 0x0132e236, size: 547 bytes, params: 8, frame: 21
const env0_0 = require;
const makeLink = function(a0) {
return {type: 'link', content: [{type: 'text', content: a0}], target: a0, title: undefined};
};
const makeText = function(a0) {
return {type: 'text', content: a0};
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {};
const object2 = {};
object2.order = (importDefault(6629) /* metro dependency 6629: MarkupTextRule */).order;
object2.requiredFirstCharacters = ['<'];
object2.match = function(a0) {
return RegExp('^<#(\\d+)>', '').exec(a0);
};
object2.parse = parse_52511;
object.channelMention = object2;
const object3 = {};
object3.order = (importDefault(3855) /* metro dependency 3855 */).defaultRules.url.order - 0.5;
object3.requiredFirstCharacters = ['h'];
object3.match = match_52512;
object3.parse = parse_52513;
object.channelOrMessageUrl = object3;
const object4 = {};
object4.order = (importDefault(3855) /* metro dependency 3855 */).defaultRules.url.order - 0.5;
object4.requiredFirstCharacters = ['h'];
object4.match = function(a0) {
var MEDIA_POST_URL_RE = require(dependencyMap[14]).MEDIA_POST_URL_RE;
return MEDIA_POST_URL_RE.exec(a0);
};
object4.parse = parse_52515;
object.mediaPostLink = object4;
(FileImportTrackerModule).fileFinishedImporting('modules/markup/MarkupChannelMentionRule.tsx');
exports.default = object;
function makeGuild(a0) { // fn#52499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:278, offset: 0x0132e459, size: 131 bytes, params: 2, frame: 18
const object = {type: 'guild'};
object.guildId = a0.id;
object.content = StringUtilsModule.truncateText(a0.name, 32);
object.icon = (importDefault(1423) /* metro dependency 1423: AvatarUtils */).getGuildIconURL({id: a0.id,
icon: a0.icon, size: 40});
return object;
}
function makeChannel({name, type, iconType}, a1) { // fn#52500, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:434, offset: 0x0132e4dc, size: 141 bytes, params: 3, frame: 16
const makeTextBinding = makeText;
let value = StringUtilsModule;
value = makeTextBinding(value.truncateText(name, 32));
return {type: 'channel', content: [a1 !== 'italics' ? value : {type: 'em', content: [value]}], channelType: type,
iconType: iconType};
}
function makeMessage(a0) { // fn#52501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:620, offset: 0x0132e569, size: 61 bytes, params: 2, frame: 12
const object = {type: 'channel'};
object.content = [makeText('')];
object.iconType = a0 ? 'post' : 'message';
return object;
}
function getChannel(a0, a1) { // fn#52502, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:718, offset: 0x0132e5a6, size: 480 bytes, params: 3, frame: 25
var r0;
var r6;
var object;
var type;
var moduleValue3;
var isChannelTypeMentionable;
const env0_0 = a0;
var value;
const channel = ChannelStore.getChannel(a0);
const value3 = undefined;
const getChannelRoleSubscriptionStatus = UseChannelRoleSubscriptionStatusModule.getChannelRoleSubscriptionStatus;
const isSubscriptionGated = Reflect.apply(getChannelRoleSubscriptionStatus, UseChannelRoleSubscriptionStatusModule,
[a0, ChannelStore, GatedChannelStore, PermissionStore]).isSubscriptionGated;
const mentionIconType = (ChannelUtilsModule).getMentionIconType(channel);
const value5 = null;
const r4 = value5 != mentionIconType ? mentionIconType : 'text';
if (value5 != a1) {
var value7 = a1.find(_fun52503);
if (value5 != value7) {
object = {};
object.type = value7.type;
object.id = value7.id;
object.guildId = value7.guild_id;
object.name = value7.name;
value = value5 != channel;
r6 = value && channel.isPrivate();
object.isDm = r6;
value = value5 != channel;
r6 = value && channel.isForumPost();
object.isForumPost = r6;
object.isMentionable = true;
object.canViewChannel = true;
object.roleSubscriptionGated = isSubscriptionGated;
object.iconType = r4;
object.parentId = value5 == channel ? value3 : channel.parent_id;
return object;
}
}
if (value5 != channel) {
object = {};
type = channel.type;
object.type = type;
object.id = channel.id;
object.guildId = channel.guild_id;
moduleValue3 = require(4805) /* metro dependency 4805: useChannelName */;
object.name = moduleValue3.computeChannelName(channel, UserStore, RelationshipStore);
object.isDm = channel.isPrivate();
object.isForumPost = channel.isForumPost();
value = require(6633) /* metro dependency 6633: ChannelUtils */;
isChannelTypeMentionable = value.isChannelTypeMentionable;
type = channel.type;
object.isMentionable = Reflect.apply(isChannelTypeMentionable, value, [type]);
value = require(4246) /* metro dependency 4246: LinkUtils */;
object.canViewChannel = value.canViewChannel(channel);
object.roleSubscriptionGated = isSubscriptionGated;
object.iconType = r4;
object.parentId = channel.parent_id;
r0 = object;
} else {
r0 = value5;
}
return r0;
function _fun52503({id}) { // fn#52503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:918, offset: 0x00db0c48, size: 21 bytes, params: 2, frame: 2
return id === env0_0;
}
}
function handleUnknownChannel(a0, a1, a2, a3, a4) { // fn#52506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:1623, offset: 0x0132e7cd, size: 240 bytes, params: 6, frame: 19
const guild = GuildStore.getGuild(a0);
const value3 = null;
const id = value3 == guild ? undefined : guild.id;
const object = {type: 'channelMention', guildId: a0, channelId: a1, messageId: a2, originalLink: a4};
object.inContent = value3 == guild || id === a3 ? value3 : [makeGuild(guild)];
const makeChannelBinding = makeChannel;
const object2 = {};
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
object2.name = intl.string((require(1244) /* metro dependency 1244: indexNative */).t.zLZPmk).toLowerCase();
const UNKNOWN = ChannelTypes.UNKNOWN;
object2.type = UNKNOWN;
object2.iconType = 'text';
object.content = [makeChannelBinding(object2, 'italics')];
return object;
}
function formatChannelMentionContent(a0, a1, a2, a3) { // fn#52507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:1955, offset: 0x0132e8bd, size: 388 bytes, params: 5, frame: 23
var channelStoreBinding;
var value3;
var object2;
var moduleValue;
var value;
const makeGuildBinding = makeGuild;
const value2 = undefined;
const guild = makeGuildBinding(a0);
const channel = makeChannel(a1);
const message = makeMessage(a1.isForumPost);
if (a2) {
if (a3) {
if (a1.isForumPost) {
channelStoreBinding = ChannelStore;
value3 = channelStoreBinding.getChannel(a1.parentId);
if (value3 != null) {
makeChannelBinding = makeChannel;
object2 = {};
moduleValue = require(4805) /* metro dependency 4805: useChannelName */;
object2.name = moduleValue.computeChannelName(value3, UserStore, RelationshipStore);
object2.type = value3.type;
value = require(4800) /* metro dependency 4800: ChannelUtils */;
value = value.getMentionIconType(value3);
object2.iconType = value ?? 'forum';
value = makeChannelBinding(object2);
return {inContent: [value], content: [channel]};
}
return {inContent: [channel], content: [message]};
}
return {inContent: [channel], content: [message]};
}
}
return a2 ? a3 ? a2 ? a2 || a3 ? value2 : {inContent: [guild], content: [channel]} : a3 ? {inContent: [guild],
content: [a1.isForumPost ? channel : message]} : a2 || a3 ? value2 : {inContent: [guild],
content: [channel]} : {inContent: null, content: [channel]} : a2 ? a2 || a3 ? value2 : {inContent: [guild],
content: [channel]} : a3 ? {inContent: [guild],
content: [a1.isForumPost ? channel : message]} : a2 || a3 ? value2 : {inContent: [guild], content: [channel]};
}
function parseChannel(a0, a1, a2, a3) { // fn#52508, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:2462, offset: 0x0132ea41, size: 596 bytes, params: 5, frame: 23
var r0;
var object;
var value;
var makeTextBinding;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
var guildId;
var guildStoreBinding;
var getGuild;
var value3;
var object3;
var formatChannelMentionContentBinding;
var object4;
if (a0.canViewChannel) {
if (a0.isMentionable) {
object = {type: 'channelMention'};
object.channelId = a0.id;
guildId = a0.guildId;
object.guildId = guildId;
object.messageId = a1;
object.originalLink = a3;
guildStoreBinding = GuildStore;
getGuild = guildStoreBinding.getGuild;
guildId = a0.guildId;
value3 = Reflect.apply(getGuild, guildStoreBinding, [guildId]);
if (value3 == null) {
if (a0.isDm) {
object4 = {};
copyDataProperties(object4, object, undefined);
object4['guildId'] = ME;
object = [makeChannel(a0)];
object4['inContent'] = object;
object = [makeMessage(false)];
object4['content'] = object;
r0 = object4;
} else if (a3 != null) {
r0 = makeLink(a3);
} else {
makeTextBinding = makeText;
value = intl.string(t.J90oLW);
value = makeTextBinding('#' + value);
r0 = value;
}
return r0;
}
guildId = a0.guildId;
object3 = {};
copyDataProperties(object3, object, undefined);
formatChannelMentionContentBinding = formatChannelMentionContent;
value = guildId === a2;
copyDataProperties(object3, formatChannelMentionContentBinding(value3, a0, value, a1 != null), value);
return object3;
}
makeTextBinding = makeText;
value = '#' + a0.name;
return makeTextBinding(value);
}
object = {type: 'channel'};
object.content = [makeText(a0.roleSubscriptionGated ? a0.name : intl.string(t['/YzI63']))];
object.channelType = a0.roleSubscriptionGated ? a0.type : ChannelTypes.UNKNOWN;
object.iconType = 'locked';
return {type: 'channelMention', guildId: a0.guildId, channelId: a0.id, messageId: a1, inContent: null,
content: [object]};
}
function getGuildIdFromChannelId_52509(a0) { // fn#52509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:214, offset: 0x0132ec95, size: 43 bytes, params: 2, frame: 11
var r0;
let value = ChannelStore.getChannel(a0);
if (value == null) {
r0 = undefined;
} else {
value = value.getGuildId();
r0 = value;
}
return r0;
}
function parse_52511([, property], a1, a2) { // fn#52511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:3390, offset: 0x0132ecde, size: 125 bytes, params: 4, frame: 20
if (a2.returnMentionIds) {
return {type: 'channelMention', id: property};
}
const channel = getChannel(property, a2.mentionChannels);
return channel == null ? handleUnknownChannel(null, property, null,
getGuildIdFromChannelId_52509(a2.channelId)) : parseChannel(channel, null,
getGuildIdFromChannelId_52509(a2.channelId));
}
function match_52512(a0) { // fn#52512, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:3747, offset: 0x0132ed5b, size: 141 bytes, params: 2, frame: 13
var regexp;
const CHANNEL_OR_MESSAGES_URL_RE = (LinkUtilsModule).CHANNEL_OR_MESSAGES_URL_RE;
const value = CHANNEL_OR_MESSAGES_URL_RE.exec(a0);
if (value == null) {
return value;
}
if (value[2] != null) {
regexp = RegExp('\\D', '');
if (regexp.test(value[2])) {
return null;
}
}
if (value[3] == null) {
return value;
}
regexp = RegExp('\\D', '');
return regexp.test(value[3]) ? null : value;
}
function parse_52513([property, property2, property3, property4], a1, a2) { // fn#52513, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:3914, offset: 0x0132ede8, size: 147 bytes, params: 4, frame: 23
if (property3 == null) {
return makeLink(property);
}
const channel = getChannel(property3, null);
return channel == null ? handleUnknownChannel(property2, property3, property4,
getGuildIdFromChannelId_52509(a2.channelId), property) : parseChannel(channel, property4,
getGuildIdFromChannelId_52509(a2.channelId), property);
}
function parse_52515([property, property2, property3, property4, property5], a1, a2) { // fn#52515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:4285, offset: 0x0132eeaa, size: 213 bytes, params: 4, frame: 24
if (property3 == null) {
return makeLink(property);
}
if (property4 == null) {
return makeLink(property);
}
const channel = getChannel(property4, null);
if (channel != null) {
return parseChannel(channel, property5, getGuildIdFromChannelId_52509(a2.channelId), property);
}
const channel2 = getChannel(property3, null);
return channel2 != null ? parseChannel(channel2, property5, getGuildIdFromChannelId_52509(a2.channelId),
property) : handleUnknownChannel(property2, property3, property5, getGuildIdFromChannelId_52509(a2.channelId),
property);
}
}
global.__d(_fun52498, 6631, [1936, 1379, 1867, 3784, 3793, 1878, 661, 1861, 1423, 1244, 6632, 4800, 4805, 6633,
4246, 6629, 3855,
2]) /* metro module 6631, dependencies: [1936, 1379, 1867, 3784, 3793, 1878, 661, 1861, 1423, 1244, 6632, 4800, 4805, 6633, 4246, 6629, 3855, 2] */;