834 lines
23 KiB
TypeScript
834 lines
23 KiB
TypeScript
// Metro module 5967 (f5968).
|
|
import EmojiStore from "../emojis/EmojiStore";
|
|
import ActiveJoinedThreadsStore from "../threads/ActiveJoinedThreadsStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import GuildChannelStore, { GUILD_SELECTABLE_CHANNELS_KEY } from "../../stores/GuildChannelStore";
|
|
import GuildMemberStore from "../../stores/GuildMemberStore";
|
|
import GuildRoleStore from "../../stores/GuildRoleStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import RelationshipStore from "../../stores/RelationshipStore";
|
|
import StreamerModeStore from "../../stores/StreamerModeStore";
|
|
import UserStore from "../../stores/UserStore";
|
|
import * as _Constants from "../../Constants";
|
|
import { Permissions } from "../../Constants";
|
|
import { GAME_MENTION_SENTINEL, extractGameMentionIds } from "../channel_autocomplete/ChannelAutocompleteConstants";
|
|
import { EmojiIntention } from "../emojis/EmojiConstants";
|
|
import { computeChannelName, unescapeChannelName } from "../channel/useChannelName";
|
|
import Module3888 from "../../_bundle/Module3888";
|
|
import MarkupRules from "../markup/MarkupRules";
|
|
import { SILENT_RE } from "../suppress_notifications/parseContentForSuppressNotifications";
|
|
import { ConvertEmoticons } from "../user_settings/UserSettings";
|
|
import UnicodeEmojis from "../emojis/UnicodeEmojis";
|
|
import MarkupTextRule, { textMarkupPatternWithExclusions } from "../markup/MarkupTextRule";
|
|
import UserUtils from "../../utils/UserUtils";
|
|
import NicknameUtils from "../../utils/NicknameUtils";
|
|
import Module12 from "../../_bundle/Module12";
|
|
import { soundmojiRawFormatRegex } from "../premium/sounds/soundmoji/utils/getSoundmojiASTFromString";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import { COMMAND_SUPPORTED_CHANNEL_TYPE_KEYS } from "../../utils/AutocompleteUtils";
|
|
import { isNotNullish } from "../../utils/GlobalUtils";
|
|
import EmojiUtils from "../../utils/EmojiUtils";
|
|
function $mk77526() {
|
|
return (a0) => -a0.text.length;
|
|
}
|
|
function $mk77527($env) {
|
|
return ({ text }) => $env[1].toLowerCase().indexOf(text.toLowerCase()) === 1;
|
|
}
|
|
function $mk77528($env) {
|
|
return (a0) => a0.text === $env[3] ? 0 : 1;
|
|
}
|
|
function $mk77529($env) {
|
|
return (a0) => {
|
|
const r1 = $env;
|
|
return [r1[0] + a0.text, a0.id, r1[2]];
|
|
};
|
|
}
|
|
function $mk77530($env) {
|
|
return (a0) => ({
|
|
type: $env[0].type,
|
|
content: a0[0]
|
|
});
|
|
}
|
|
function $mk77531() {
|
|
return (a0) => ({
|
|
type: "text",
|
|
content: a0[0]
|
|
});
|
|
}
|
|
function $mk77532($env) {
|
|
return (a0) => {
|
|
L19: {
|
|
const r1 = $env;
|
|
const r2 = $env.$parent;
|
|
const r3 = r1[0];
|
|
const r8 = r1[2];
|
|
$mk104821(r2)(r3, a0, r8);
|
|
if (typeof a0.content === "string") {
|
|
const type = a0.type;
|
|
if (type === "emoji") {
|
|
r1[4].push({
|
|
position: r1[3].length,
|
|
length: a0.content.length,
|
|
id: a0.id
|
|
});
|
|
r1[3] = r1[3] + a0.content;
|
|
} else {
|
|
if (type !== "codeBlock" && type !== "inlineCode" && type !== "mention" && type !== "roleMention" && type !== "gameMention" && type !== "channel") {
|
|
r1[3] = r1[3] + (0, r1[1])(a0.content);
|
|
break L19;
|
|
}
|
|
if (r3.isNotification === true) {
|
|
r1[3] = r1[3] + (0, r2[0])(r2[2][26]).isolate(a0.content);
|
|
} else {
|
|
r1[3] = r1[3] + a0.content;
|
|
}
|
|
}
|
|
} else if (a0.content.constructor === Array) {
|
|
const r33 = (0, r2[24])(a0.content, r3, r1[1], r8);
|
|
const content = r33.content;
|
|
for (const item of r33.emoji) {
|
|
r1[4].push({
|
|
position: r1[3].length + item.position,
|
|
length: item.length,
|
|
id: item.id
|
|
});
|
|
}
|
|
r1[3] = r1[3] + content;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function $mk104821($env) {
|
|
return function handleEmoji(a0, a1, a2) {
|
|
let r36;
|
|
L16: {
|
|
if (a2 != null) {
|
|
if (a1.type === "customEmoticon") {
|
|
a2(a1.emoji, false);
|
|
}
|
|
if (a1.type !== "emoticon" && a1.type !== "text") {
|
|
break L16;
|
|
}
|
|
const r6 = $env;
|
|
const r26 = (0, r6[1])(r6[2][19]).translateSurrogatesToInlineEmoji(a1.content);
|
|
let r29 = r6[23].exec(r26);
|
|
while (r29 !== null) {
|
|
L11: {
|
|
const r11 = r29[1];
|
|
const r10 = r29;
|
|
if (r11 != null && r10[1] !== "") {
|
|
const emojiContext = a0.emojiContext;
|
|
r36 = void 0;
|
|
if (!emojiContext) {
|
|
break L11;
|
|
}
|
|
r36 = a0.emojiContext.getById(r10[1]);
|
|
} else {
|
|
r36 = (0, r6[1])(r6[2][19]).getByName(r10[2]);
|
|
}
|
|
}
|
|
if (r36) {
|
|
a2(r36, a1.isShortcut || false);
|
|
}
|
|
r29 = r6[23].exec(r26);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
let parseAndRebuild, createParserState, NOOP, unparseWithMeta, c3757_19, c3757_20, link, autolink, url, inlineCode, codeBlock, inlineCode2, codeBlock2, c3757_21, c3757_22, c3757_23;
|
|
let env3758;
|
|
let env3759;
|
|
let env3760;
|
|
let env3761;
|
|
let env3762;
|
|
let env3763;
|
|
let env3764;
|
|
let env3757 = {};
|
|
const rebuild = function rebuild(a0, a1, a2, a3) {
|
|
let env15323;
|
|
const r2 = env15323 = {
|
|
$parent: env3757
|
|
};
|
|
env15323[0] = a1;
|
|
env15323[1] = a2;
|
|
env15323[2] = a3;
|
|
env15323[3] = "";
|
|
const emoji = [];
|
|
env15323[4] = emoji;
|
|
a0.forEach($mk77532(r2));
|
|
return {
|
|
content: env15323[3],
|
|
emoji
|
|
};
|
|
};
|
|
parseAndRebuild = function parseAndRebuild(a0, a1, a2) {
|
|
let env15324;
|
|
const r5 = c3757_22(a0, a1);
|
|
const r11 = env15324 = {
|
|
$parent: env3757
|
|
};
|
|
env15324[0] = a1;
|
|
env15324[1] = UnicodeEmojis.translateInlineEmojiToSurrogates;
|
|
env15324[2] = a2;
|
|
env15324[3] = "";
|
|
env15324[4] = [];
|
|
r5.forEach($mk77532(r11));
|
|
return env15324[3];
|
|
};
|
|
createParserState = function createParserState(a0, a1) {
|
|
let r11;
|
|
const guildId = a0 == null ? void 0 : a0.getGuildId();
|
|
const guild = guildId != null ? GuildStore.getGuild(guildId) : null;
|
|
let c15325_1 = PermissionStore.can(Permissions.MENTION_EVERYONE, a0);
|
|
if (a0 == null ? void 0 : a0.isPrivate()) {
|
|
const r34 = a0.recipients.map((recipient) => ({
|
|
userId: recipient,
|
|
nick: null
|
|
}));
|
|
const currentUser = UserStore.getCurrentUser();
|
|
r11 = r34;
|
|
if (currentUser != null) {
|
|
r34.push({
|
|
userId: currentUser.id,
|
|
nick: null
|
|
});
|
|
r11 = r34;
|
|
}
|
|
} else {
|
|
r11 = guildId != null ? GuildMemberStore.getMembers(guildId).map((item) => ({
|
|
userId: item.userId,
|
|
nick: item.nick
|
|
})) : [];
|
|
}
|
|
const users = Module12(r11.reduce((acc, { userId }) => {
|
|
const user = UserStore.getUser(userId);
|
|
if (user != null) {
|
|
acc.push({
|
|
id: userId,
|
|
text: user.tag
|
|
});
|
|
}
|
|
return acc;
|
|
}, []));
|
|
const mentionableRoles = Module12(guild != null ? GuildRoleStore.getSortedRoles(guild.id) : []).filter(({ mentionable }) => c15325_1 || mentionable).map((item) => ({
|
|
id: item.id,
|
|
text: item.name
|
|
}));
|
|
const r68 = Module12(GuildChannelStore.getTextChannelNameDisambiguations(guildId)).map((item) => ({
|
|
id: item.id,
|
|
text: item.name
|
|
}));
|
|
const r69 = guildId != null ? Module12(COMMAND_SUPPORTED_CHANNEL_TYPE_KEYS).filter((item) => item !== GUILD_SELECTABLE_CHANNELS_KEY).flatMap((item) => GuildChannelStore.getChannels(guildId)[item].map((item) => item.channel.isCategory() ? PermissionStore.can(Permissions.VIEW_CHANNEL, item.channel) ? {
|
|
id: item.channel.id,
|
|
text: computeChannelName(item.channel, UserStore, RelationshipStore)
|
|
} : null : {
|
|
id: item.channel.id,
|
|
text: computeChannelName(item.channel, UserStore, RelationshipStore)
|
|
})).filter(isNotNullish).value() : [];
|
|
const r94 = ActiveJoinedThreadsStore.computeAllActiveJoinedThreads(guildId).map((item) => ({
|
|
id: item.id,
|
|
text: computeChannelName(item, UserStore, RelationshipStore)
|
|
}));
|
|
const disambiguatedEmojiContext = EmojiStore.getDisambiguatedEmojiContext(guildId);
|
|
const escapedCustomEmoticonNames = disambiguatedEmojiContext.getEscapedCustomEmoticonNames();
|
|
const customEmoji = disambiguatedEmojiContext.getCustomEmoji();
|
|
const customEmoticonRegex = disambiguatedEmojiContext.getCustomEmoticonRegex();
|
|
return {
|
|
inline: true,
|
|
mentionableRoles,
|
|
guild,
|
|
users,
|
|
games: Module12(a1 != null ? Array.from(a1.values()) : []).map((item) => ({
|
|
id: item.id,
|
|
text: item.name
|
|
})),
|
|
channels: r68.concat(r69).concat(r94),
|
|
emojiContext: disambiguatedEmojiContext,
|
|
customEmoticonsRegex: customEmoticonRegex,
|
|
customEmoji,
|
|
textExclusions: escapedCustomEmoticonNames,
|
|
isNotification: false
|
|
};
|
|
};
|
|
NOOP = function NOOP(a0) {
|
|
return a0;
|
|
};
|
|
unparseWithMeta = function unparseWithMeta(a0, a1, a2) {
|
|
const channel2 = ChannelStore.getChannel(a1);
|
|
const r4 = channel2 != null ? channel2.getGuildId() : null;
|
|
const guild = r4 != null ? GuildStore.getGuild(r4) : null;
|
|
const r22 = a2 ? c3757_21 : Module12.omit(c3757_21, ["spoiler", "timestamp"]);
|
|
const r28 = a2 ? NOOP : UnicodeEmojis.translateSurrogatesToInlineEmoji;
|
|
let env15326;
|
|
const r30 = {
|
|
inline: true,
|
|
guild,
|
|
channelId: a1,
|
|
isNotification: a2
|
|
};
|
|
const r38 = Module3888.parserFor(r22)(a0, r30);
|
|
const r39 = env15326 = {
|
|
$parent: env3757
|
|
};
|
|
env15326[0] = r30;
|
|
env15326[1] = r28;
|
|
env15326[2] = void 0;
|
|
env15326[3] = "";
|
|
const emoji = [];
|
|
env15326[4] = emoji;
|
|
r38.forEach($mk77532(r39));
|
|
return {
|
|
content: env15326[3],
|
|
emoji
|
|
};
|
|
};
|
|
const { MARKDOWN_SPOILER_REGEXP, MARKDOWN_STATIC_ROUTE_NAME_REGEXP } = _Constants;
|
|
const r19 = /^<@!?(\d+)>/;
|
|
const r18 = /^<@&(\d+)>/;
|
|
const r17 = /^<#(\d+)>/;
|
|
const r16 = /^<a?:(\w+):(\d+)>/;
|
|
c3757_19 = /(@everyone|@here|@Clyde)\b/;
|
|
c3757_20 = /^[^\s]+@[^\s]+\.[^\s.]+/;
|
|
const link2 = Module3888.defaultRules.link;
|
|
const r69 = env3758 = {};
|
|
link = link2;
|
|
const r73 = {
|
|
link: {
|
|
order: link2.order,
|
|
match: link2.match,
|
|
parse: $mk77530(r69)
|
|
},
|
|
autolink: null,
|
|
url: null,
|
|
inlineCode: null,
|
|
codeBlock: null,
|
|
rawUserMention: null,
|
|
rawRoleMention: null,
|
|
rawChannelMention: null,
|
|
rawEmoji: null,
|
|
mention: null,
|
|
channel: null,
|
|
emoticon: null,
|
|
emoji: null,
|
|
customEmoticons: null,
|
|
text: null
|
|
};
|
|
const autolink2 = Module3888.defaultRules.autolink;
|
|
const r78 = env3759 = {};
|
|
autolink = autolink2;
|
|
r73.autolink = {
|
|
order: autolink2.order,
|
|
match: autolink2.match,
|
|
parse: $mk77530(r78)
|
|
};
|
|
const url2 = Module3888.defaultRules.url;
|
|
const r87 = env3760 = {};
|
|
url = url2;
|
|
r73.url = {
|
|
order: url2.order,
|
|
match: url2.match,
|
|
parse: $mk77530(r87)
|
|
};
|
|
const inlineCode3 = MarkupRules.RULES.inlineCode;
|
|
const r96 = env3761 = {};
|
|
inlineCode = inlineCode3;
|
|
r73.inlineCode = {
|
|
order: inlineCode3.order,
|
|
match: inlineCode3.match,
|
|
parse: $mk77530(r96)
|
|
};
|
|
const codeBlock3 = MarkupRules.RULES.codeBlock;
|
|
const r105 = env3762 = {};
|
|
codeBlock = codeBlock3;
|
|
r73.codeBlock = {
|
|
order: codeBlock3.order,
|
|
match: codeBlock3.match,
|
|
parse: $mk77530(r105)
|
|
};
|
|
r73.rawUserMention = {
|
|
match: Module3888.anyScopeRegex(r19),
|
|
parse: $mk77531()
|
|
};
|
|
r73.rawRoleMention = {
|
|
match: Module3888.anyScopeRegex(r18),
|
|
parse: $mk77531()
|
|
};
|
|
r73.rawChannelMention = {
|
|
match: Module3888.anyScopeRegex(r17),
|
|
parse: $mk77531()
|
|
};
|
|
r73.rawEmoji = {
|
|
match: Module3888.anyScopeRegex(r16),
|
|
parse: $mk77531()
|
|
};
|
|
r73.mention = {
|
|
match: (a0, a1, a2) => {
|
|
if (c3757_20.test(a2.split(" ").pop() + a0)) {
|
|
return null;
|
|
}
|
|
let env15327;
|
|
const games = a1.games;
|
|
const r22 = env15327 = {};
|
|
env15327[0] = GAME_MENTION_SENTINEL;
|
|
env15327[1] = a0;
|
|
env15327[2] = "gameMention";
|
|
env15327[3] = void 0;
|
|
const r5 = a0[0];
|
|
let r24 = void 0;
|
|
if (r5 === GAME_MENTION_SENTINEL) {
|
|
env15327[3] = a0.substring(GAME_MENTION_SENTINEL.length);
|
|
r24 = games.sortBy($mk77526()).filter($mk77527(r22)).sortBy($mk77528(r22)).map($mk77529(r22)).first();
|
|
}
|
|
if (r24 != null) {
|
|
return r24;
|
|
}
|
|
let env15328;
|
|
const users = a1.users;
|
|
const r41 = env15328 = {};
|
|
env15328[0] = "@";
|
|
env15328[1] = a0;
|
|
env15328[2] = "mention";
|
|
env15328[3] = void 0;
|
|
const r11 = a0[0];
|
|
let r44 = void 0;
|
|
if (r11 === "@") {
|
|
env15328[3] = a0.substring("@".length);
|
|
r44 = users.sortBy($mk77526()).filter($mk77527(r41)).sortBy($mk77528(r41)).map($mk77529(r41)).first();
|
|
}
|
|
if (r44 != null) {
|
|
return r44;
|
|
}
|
|
let env15329;
|
|
const mentionableRoles = a1.mentionableRoles;
|
|
const r60 = env15329 = {};
|
|
env15329[0] = "@";
|
|
env15329[1] = a0;
|
|
env15329[2] = "roleMention";
|
|
env15329[3] = void 0;
|
|
const r62 = a0[0];
|
|
let r63 = void 0;
|
|
if (r62 === "@") {
|
|
env15329[3] = a0.substring("@".length);
|
|
r63 = mentionableRoles.sortBy($mk77526()).filter($mk77527(r60)).sortBy($mk77528(r60)).map($mk77529(r60)).first();
|
|
}
|
|
if (r63 != null) {
|
|
return r63;
|
|
}
|
|
let env15330;
|
|
const r83 = a1.users.map((user) => ({
|
|
...user,
|
|
text: user.text.split("#")[0]
|
|
}));
|
|
const r84 = env15330 = {};
|
|
env15330[0] = "@";
|
|
env15330[1] = a0;
|
|
env15330[2] = "mention";
|
|
env15330[3] = void 0;
|
|
const r85 = a0[0];
|
|
let r86 = void 0;
|
|
if (r85 === "@") {
|
|
env15330[3] = a0.substring("@".length);
|
|
r86 = r83.sortBy($mk77526()).filter($mk77527(r84)).sortBy($mk77528(r84)).map($mk77529(r84)).first();
|
|
}
|
|
if (r86 == null) {
|
|
return null;
|
|
}
|
|
const r105 = c3757_19.exec(a0);
|
|
if (r105 != null && r86[0].length <= r105[0].length) {
|
|
return null;
|
|
}
|
|
if (a2 === "") {
|
|
const r117 = SILENT_RE.exec(a0);
|
|
if (r117 != null && r86[0].length <= r117[0].length) {
|
|
return null;
|
|
}
|
|
}
|
|
return r86;
|
|
},
|
|
parse: (a0) => {
|
|
const [, r5, type] = a0;
|
|
if (type === "gameMention") {
|
|
return {
|
|
type,
|
|
content: `<@\$${r5}>`
|
|
};
|
|
}
|
|
return {
|
|
type,
|
|
content: `<${type === "roleMention" ? "@&" : "@"}${r5}>`
|
|
};
|
|
}
|
|
};
|
|
r73.channel = {
|
|
match: (a0, { channels }) => {
|
|
let r0, length;
|
|
let c15331_0, c15331_1;
|
|
c15331_0 = void 0;
|
|
c15331_1 = void 0;
|
|
const r10 = a0[0];
|
|
let r16 = void 0;
|
|
if (r10 === "#") {
|
|
if (a0[1] !== "\"") {
|
|
let env15332;
|
|
const r45 = env15332 = {};
|
|
env15332[0] = "#";
|
|
env15332[1] = a0;
|
|
env15332[2] = "channel";
|
|
const r47 = a0[0];
|
|
let r48 = void 0;
|
|
if (r47 === "#") {
|
|
env15332[3] = a0.substring("#".length);
|
|
r48 = channels.sortBy($mk77526()).filter($mk77527(r45)).sortBy($mk77528(r45)).map($mk77529(r45)).first();
|
|
}
|
|
r16 = r48;
|
|
} else {
|
|
const r7 = 2 < a0.length;
|
|
let r1 = 2;
|
|
let r3 = 2;
|
|
if (r7) {
|
|
do {
|
|
const r19 = a0[r1];
|
|
const r2 = r1;
|
|
if (r19 !== "\\") {
|
|
const r20 = a0[r2];
|
|
r0 = r2;
|
|
r3 = r0;
|
|
if (r20 === "\"") {
|
|
break;
|
|
}
|
|
} else {
|
|
r0 = r2 + 1;
|
|
}
|
|
r1 = r0 + 1;
|
|
length = a0.length;
|
|
r3 = r1;
|
|
} while (r3 < length);
|
|
}
|
|
c15331_0 = a0.substring(0, r3 + 1);
|
|
c15331_1 = unescapeChannelName(a0.substring(2, r3));
|
|
r16 = channels.sortBy((channel) => -channel.text.length).filter((item) => c15331_1 === item.text).map((item) => [c15331_0, item.id, "channel"]).first();
|
|
}
|
|
}
|
|
if (r16 == null) {
|
|
r16 = null;
|
|
}
|
|
return r16;
|
|
},
|
|
parse: (a0) => ({
|
|
type: "text",
|
|
content: `<#${a0[1]}>`
|
|
})
|
|
};
|
|
r73.emoticon = {
|
|
match: (a0, a1, a2) => {
|
|
let r26;
|
|
if (ConvertEmoticons.getSetting()) {
|
|
if (a2.length !== 0 && !/\s$/.test(a2)) {
|
|
return null;
|
|
}
|
|
L10: {
|
|
const r23 = UnicodeEmojis.EMOJI_SHORTCUT_RE.exec(a0);
|
|
const r25 = r23 == null;
|
|
r26 = null;
|
|
if (!r25) {
|
|
if (r23[0].length !== a0.length && a0[r23[0].length] !== " ") {
|
|
const r36 = a0[r23[0].length];
|
|
r26 = null;
|
|
if (r36 !== "\n") {
|
|
break L10;
|
|
}
|
|
}
|
|
r26 = r23;
|
|
}
|
|
}
|
|
return r26;
|
|
}
|
|
return null;
|
|
},
|
|
parse: (a0) => ({
|
|
type: "emoticon",
|
|
content: UnicodeEmojis.convertShortcutToName(a0[1]),
|
|
isShortcut: true
|
|
})
|
|
};
|
|
r73.emoji = {
|
|
order: MarkupRules.RULES.emoji.order,
|
|
match: (a0) => UnicodeEmojis.EMOJI_NAME_RE.exec(a0),
|
|
parse: (a0, a1, a2) => {
|
|
let r40;
|
|
const [content, r33] = a0;
|
|
let emoji = a2.customEmoji.get(r33);
|
|
if (emoji == null) {
|
|
emoji = null;
|
|
}
|
|
if (emoji != null) {
|
|
const r12 = emoji.animated === true ? "a" : "";
|
|
let originalName = emoji.originalName;
|
|
if (originalName == null) {
|
|
originalName = emoji.name;
|
|
}
|
|
r40 = {
|
|
type: "customEmoticon",
|
|
content: `<${r12}:${originalName}:${emoji.id}>`,
|
|
emoji
|
|
};
|
|
} else {
|
|
r40 = {
|
|
type: "text",
|
|
content
|
|
};
|
|
}
|
|
return r40;
|
|
}
|
|
};
|
|
r73.customEmoticons = {
|
|
match: (a0, { customEmoticonsRegex }) => {
|
|
let r6 = customEmoticonsRegex == null ? void 0 : customEmoticonsRegex.exec(a0);
|
|
if (r6 == null) {
|
|
r6 = null;
|
|
}
|
|
return r6;
|
|
},
|
|
parse: (a0, a1, a2) => {
|
|
const [content, r33] = a0;
|
|
const emoticonByName = a2.emojiContext.getEmoticonByName(r33);
|
|
return emoticonByName != null ? {
|
|
type: "customEmoticon",
|
|
content: `<${emoticonByName.animated === true ? "a" : ""}:${emoticonByName.name}:${emoticonByName.id}>`,
|
|
emoji: emoticonByName
|
|
} : {
|
|
type: "text",
|
|
content
|
|
};
|
|
}
|
|
};
|
|
r73.text = {
|
|
...MarkupTextRule,
|
|
match: (a0, a1) => typeof a1.textExclusions === "string" && a1.textExclusions !== "" ? textMarkupPatternWithExclusions(a1.textExclusions).exec(a0) : MarkupTextRule.match != null ? MarkupTextRule.match(a0, a1, "") : null
|
|
};
|
|
const inlineCode4 = MarkupRules.RULES.inlineCode;
|
|
const r162 = env3763 = {};
|
|
inlineCode2 = inlineCode4;
|
|
const r166 = {
|
|
inlineCode: {
|
|
order: inlineCode4.order,
|
|
match: inlineCode4.match,
|
|
parse: $mk77530(r162)
|
|
},
|
|
codeBlock: null,
|
|
mention: null,
|
|
roleMention: null,
|
|
channel: null,
|
|
emoji: null,
|
|
soundboard: null,
|
|
spoiler: null,
|
|
staticRouteLink: null,
|
|
timestamp: null,
|
|
text: null
|
|
};
|
|
const codeBlock4 = MarkupRules.RULES.codeBlock;
|
|
const r171 = env3764 = {};
|
|
codeBlock2 = codeBlock4;
|
|
r166.codeBlock = {
|
|
order: codeBlock4.order,
|
|
match: codeBlock4.match,
|
|
parse: $mk77530(r171)
|
|
};
|
|
r166.mention = {
|
|
match: Module3888.anyScopeRegex(r19),
|
|
parse: (a0, a1, { isNotification, guild, channelId }) => {
|
|
let c15333_0;
|
|
c15333_0 = void 0;
|
|
const user = UserStore.getUser(a0[1]);
|
|
if (user == null) {
|
|
return {
|
|
content: a0[0]
|
|
};
|
|
}
|
|
const userTag = UserUtils.getUserTag(user, {
|
|
identifiable: isNotification ? StreamerModeStore.enabled ? "never" : "always" : "always"
|
|
});
|
|
if (isNotification) {
|
|
let r71 = NicknameUtils.getNickname(guild?.id, channelId, user);
|
|
if (r71 == null) {
|
|
r71 = UserUtils.getGlobalName(user);
|
|
}
|
|
return {
|
|
content: r71 != null ? `@${r71}` : `@${userTag}`
|
|
};
|
|
}
|
|
if (user.bot) {
|
|
return {
|
|
content: `@${userTag}`
|
|
};
|
|
}
|
|
const r29 = guild?.id != null;
|
|
let r31 = "";
|
|
if (r29) {
|
|
c15333_0 = userTag.toLowerCase();
|
|
r31 = Module12.some(GuildRoleStore.getUnsafeMutableRoles(guild.id), (a0) => c15333_0.startsWith(a0.name.toLowerCase())) ? `#${`${user.discriminator}`.padStart(4, "0")}` : "";
|
|
}
|
|
return {
|
|
content: `@${userTag}${r31}`
|
|
};
|
|
}
|
|
};
|
|
r166.roleMention = {
|
|
match: Module3888.anyScopeRegex(r18),
|
|
parse: (a0, a1, { guild }) => {
|
|
if (guild != null) {
|
|
const role = GuildRoleStore.getRole(guild.id, a0[1]);
|
|
if (role != null) {
|
|
return {
|
|
content: `@${role.name}`
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
content: a0[0]
|
|
};
|
|
}
|
|
};
|
|
r166.channel = {
|
|
match: Module3888.anyScopeRegex(r17),
|
|
parse: (a0) => {
|
|
const channel2 = ChannelStore.getChannel(a0[1]);
|
|
return {
|
|
content: channel2 == null ? a0[0] : computeChannelName(channel2, UserStore, RelationshipStore, true, true)
|
|
};
|
|
}
|
|
};
|
|
r166.emoji = {
|
|
match: Module3888.anyScopeRegex(r16),
|
|
parse: (a0, a1, a2) => {
|
|
let [, r7, id] = a0;
|
|
const guild = a2.guild;
|
|
const byId = EmojiStore.getDisambiguatedEmojiContext(guild ? guild.id : null).getById(id);
|
|
if (byId != null) {
|
|
r7 = byId.name;
|
|
}
|
|
return {
|
|
content: `:${r7}:`,
|
|
id
|
|
};
|
|
}
|
|
};
|
|
r166.soundboard = {
|
|
match: Module3888.anyScopeRegex(soundmojiRawFormatRegex),
|
|
parse: (a0) => {
|
|
const [, r9, r8] = a0;
|
|
return {
|
|
content: `<sound:${r9}:${r8}>`
|
|
};
|
|
}
|
|
};
|
|
r166.spoiler = {
|
|
match: Module3888.anyScopeRegex(MARKDOWN_SPOILER_REGEXP),
|
|
parse: () => ({
|
|
content: `<${intl.string(t["F+x38C"]).toLowerCase()}>`
|
|
})
|
|
};
|
|
r166.staticRouteLink = {
|
|
match: Module3888.anyScopeRegex(MARKDOWN_STATIC_ROUTE_NAME_REGEXP),
|
|
parse: (a0) => ({
|
|
content: `<id:${a0[1]}>`
|
|
})
|
|
};
|
|
r166.timestamp = {
|
|
...MarkupRules.RULES.timestamp,
|
|
parse: function parse(...args) {
|
|
const timestamp = MarkupRules.RULES.timestamp;
|
|
const r19 = timestamp.parse.apply(timestamp, [...args]);
|
|
return r19.type === "text" ? {
|
|
content: r19.content
|
|
} : {
|
|
content: r19.formatted
|
|
};
|
|
}
|
|
};
|
|
r166.text = {
|
|
...MarkupTextRule
|
|
};
|
|
c3757_21 = r166;
|
|
[r73, r166].forEach((item) => {
|
|
let c15334_0 = item;
|
|
Object.keys(item).forEach((item, index) => {
|
|
c15334_0[item].order = index;
|
|
});
|
|
});
|
|
c3757_22 = Module3888.parserFor(r73);
|
|
c3757_23 = /(?:<a?:\w+:(\d+)>)|:(?:([^\s:]+?)(?:::skin-tone-\d)?:)/g;
|
|
const r244 = {
|
|
parse: function parse(a0, a1) {
|
|
let r24;
|
|
const channel = a0;
|
|
let r9 = arguments[2];
|
|
if (r9 === void 0) {
|
|
r9 = void 0;
|
|
}
|
|
const r4 = arguments[3];
|
|
if (r9 == null) {
|
|
r9 = createParserState(a0, r4);
|
|
}
|
|
const r27 = {
|
|
content: a1,
|
|
tts: false,
|
|
invalidEmojis: [],
|
|
validNonShortcutEmojis: []
|
|
};
|
|
let c15335_1 = r27;
|
|
r27.content = parseAndRebuild(r27.content, r9, (a0, a1) => {
|
|
if (EmojiUtils.isEmojiPremiumLocked({
|
|
emoji: a0,
|
|
channel,
|
|
intention: EmojiIntention.CHAT
|
|
})) {
|
|
c15335_1.invalidEmojis.push(a0);
|
|
} else if (!a1) {
|
|
c15335_1.validNonShortcutEmojis.push(a0);
|
|
}
|
|
});
|
|
if (r4 != null && r4.size > 0) {
|
|
const set = new Set((0, extractGameMentionIds)(r27.content));
|
|
const mentionGames = [];
|
|
let r45 = r4.values()[Symbol.iterator]();
|
|
const next = r45.next;
|
|
while (true) {
|
|
const r48 = r45 === void 0 ? void 0 : (r24 = next.call(r45)).done ? r45 = void 0 : r24.value;
|
|
if (r45 === void 0) {
|
|
if (!(mentionGames.length > 0)) {
|
|
break;
|
|
}
|
|
r27.mentionGames = mentionGames;
|
|
break;
|
|
}
|
|
try {
|
|
if (set.has(r48.id)) {
|
|
mentionGames.push({
|
|
id: r48.id,
|
|
name: r48.name,
|
|
icon: r48.icon
|
|
});
|
|
}
|
|
} catch (r59) {
|
|
if (r45 !== void 0 && typeof r45.return === "function") {
|
|
try {
|
|
r45.return();
|
|
} catch {}
|
|
}
|
|
throw r59;
|
|
}
|
|
}
|
|
}
|
|
return r27;
|
|
},
|
|
parsePreprocessor: (a0, a1) => c3757_22(a1, createParserState(a0)),
|
|
unparse: (a0, a1, a2) => unparseWithMeta(a0, a1, a2).content,
|
|
unparseWithMeta
|
|
};
|
|
export default r244;
|
|
export { parseAndRebuild };
|
|
export { createParserState };
|