820 lines
28 KiB
TypeScript
820 lines
28 KiB
TypeScript
// Metro module 10104 (f10105).
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildChannelStore, { GUILD_SELECTABLE_CHANNELS_KEY, GUILD_VOCAL_CHANNELS_KEY } from "../../../stores/GuildChannelStore";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
|
|
import StreamerModeStore from "../../../stores/StreamerModeStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import SearchAutocompleteStore from "../SearchAutocompleteStore";
|
|
import SearchRecentMessageStore from "../SearchRecentMessageStore";
|
|
import { ID_REGEX, ME, SEARCH_DATE_FORMAT, SearchTypes, SearchTokenTypes, IS_SEARCH_FILTER_TOKEN } from "../../../Constants";
|
|
import Module3771 from "../../../_bundle/Module3771";
|
|
import Module12 from "../../../_bundle/Module12";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { computeChannelName } from "../../channel/useChannelName";
|
|
import UserUtils from "../../../utils/UserUtils";
|
|
import { isGuildLikeSearchContext } from "../SearchUtils";
|
|
import { validateForMapWithNegation, makeRegexForOptionsWithNegation, GENERIC_REGEX, ANSWER_IN_REGEX } from "./SearchTokensUtils";
|
|
import AutocompleteUtils, { getBoosterMap } from "../../../utils/AutocompleteUtils";
|
|
import { AutocompleterResultTypes, sortByMatchScore } from "../../autocompleter/index";
|
|
import { isFromUserFilterSupported, isMentionsUserFilterSupported, isInChannelFilterSupported } from "./SearchTokenStreamerModeUtils";
|
|
import { Token } from "../../../lib/QueryTokenizer";
|
|
function $mk83959() {
|
|
return (a0) => a0.toLowerCase();
|
|
}
|
|
function $mk83960() {
|
|
return (a0) => a0.toLowerCase();
|
|
}
|
|
function $mk83961() {
|
|
return (a0) => a0.toString();
|
|
}
|
|
function $mk83968($env) {
|
|
return (a0) => {
|
|
const [, r2] = a0;
|
|
return r2 === $env[0];
|
|
};
|
|
}
|
|
function $mk83969($env) {
|
|
return (a0) => {
|
|
const group = $env[0];
|
|
return {
|
|
...a0,
|
|
group,
|
|
key: `${group}-${a0.text}`
|
|
};
|
|
};
|
|
}
|
|
function $mk83970($env) {
|
|
return (a0) => {
|
|
const r1 = $env.$parent;
|
|
return (0, r1[1])(r1[2][17])($env[0], a0.toLocaleLowerCase());
|
|
};
|
|
}
|
|
function $mk83971() {
|
|
return (a0) => ({
|
|
text: a0
|
|
});
|
|
}
|
|
let isValidUserAutocomplete, dateValidator, isValidChannelAutocomplete, getHasMap, isValidHasAutocomplete, isValidAuthorTypeAutocomplete, isValidPinnedAutocomplete, generateDateAutocompletions, getUserAutocompletions, getChannelAutocompletions, makeSearchTokenConfigs, c6724_21, c6724_22, c6724_33, c6724_34, c6724_36, c6724_37;
|
|
let env6724 = {};
|
|
const getShortcuts = function getShortcuts() {
|
|
const r1 = {};
|
|
r1[intl.string(t.HYiVEQ)] = () => {
|
|
const r4 = Module3771().startOf("day").add(0, "day");
|
|
return [r4, r4.clone().add(1, "day")];
|
|
};
|
|
r1[intl.string(t.cu86KC)] = () => {
|
|
const r4 = Module3771().startOf("day").add(-1, "day");
|
|
return [r4, r4.clone().add(1, "day")];
|
|
};
|
|
r1[intl.string(t["FvBj/6"])] = () => {
|
|
const r4 = Module3771().startOf("week").add(0, "week");
|
|
return [r4, r4.clone().add(1, "week")];
|
|
};
|
|
r1[intl.string(t["20uWCw"])] = () => {
|
|
const r4 = Module3771().startOf("month").add(0, "month");
|
|
return [r4, r4.clone().add(1, "month")];
|
|
};
|
|
r1[intl.string(t["dXC/hn"])] = () => {
|
|
const r4 = Module3771().startOf("year").add(0, "year");
|
|
return [r4, r4.clone().add(1, "year")];
|
|
};
|
|
return r1;
|
|
};
|
|
isValidUserAutocomplete = function isValidUserAutocomplete(a0) {
|
|
let r24;
|
|
const match = a0.getMatch(1);
|
|
const r12 = ID_REGEX.test(match);
|
|
let r13 = match;
|
|
if (!r12) {
|
|
if (match === ME) {
|
|
const currentUser2 = UserStore.getCurrentUser();
|
|
r24 = currentUser2 != null ? currentUser2?.id : null;
|
|
} else if (a0.getMatch(4) != null) {
|
|
const r31 = UserStore.findByTag(a0.getMatch(4));
|
|
r24 = r31 != null ? r31?.id : null;
|
|
} else {
|
|
const r23 = UserStore.findByTag(a0.getMatch(2), a0.getMatch(3));
|
|
r24 = r23 != null ? r23?.id : null;
|
|
}
|
|
r13 = r24;
|
|
}
|
|
let r45 = r13 != null;
|
|
if (r45) {
|
|
a0.setData("userId", r13);
|
|
r45 = true;
|
|
}
|
|
return r45;
|
|
};
|
|
dateValidator = function dateValidator(a0, a1) {
|
|
let r87, r88;
|
|
const r12 = a0.getFullMatch().trim().toLowerCase();
|
|
const r9 = getShortcuts()[r12];
|
|
if (r9 != null) {
|
|
[r87, r88] = r9();
|
|
} else if (new Set(Module3771.months().map($mk83959())).has(r12)) {
|
|
const r124 = Module3771(r12, "MMMM").local();
|
|
[r87, r88] = [r124, r124.clone().add(1, "month")];
|
|
} else if (new Set(Module3771.weekdays().map($mk83960())).has(r12)) {
|
|
const r108 = Module3771(r12, "dddd").local();
|
|
[r87, r88] = [r108, r108.clone().add(1, "day")];
|
|
} else if (new Set(Module12.range(2015, new Date().getFullYear() + 1).map($mk83961())).has(r12)) {
|
|
const r94 = Module3771(r12, "YYYY").local();
|
|
[r87, r88] = [r94, r94.clone().add(1, "year")];
|
|
} else {
|
|
const r77 = Module3771(r12, SEARCH_DATE_FORMAT).local();
|
|
[r87, r88] = [r77, r77.clone().add(1, "day")];
|
|
}
|
|
const isValid = r87.isValid();
|
|
let r3 = !isValid;
|
|
const r142 = r87;
|
|
if (isValid) {
|
|
r3 = !r88.isValid();
|
|
}
|
|
let r145 = !r3;
|
|
if (!r3) {
|
|
let r148 = r142;
|
|
let r149 = null;
|
|
if (a1 !== "before") {
|
|
r148 = r88;
|
|
r149 = r142;
|
|
if (a1 === "after") {
|
|
r148 = null;
|
|
r149 = r88;
|
|
}
|
|
}
|
|
a0.setData("start", r149);
|
|
a0.setData("end", r148);
|
|
r145 = true;
|
|
}
|
|
return r145;
|
|
};
|
|
isValidChannelAutocomplete = function isValidChannelAutocomplete(a0, a1) {
|
|
let r37;
|
|
const match = a0.getMatch(1);
|
|
if (ID_REGEX.test(match)) {
|
|
a0.setData("channelIds", [match]);
|
|
r37 = true;
|
|
} else {
|
|
const r22 = match.startsWith("\"") && match.endsWith("\"") ? match.substring(1, match.length - 1).replaceAll(/\\(.)/g, (a0, a1) => a1) : match;
|
|
if (isGuildLikeSearchContext(a1)) {
|
|
const guildId = a1.guildId;
|
|
let c17693_0 = r22;
|
|
const r70 = GuildChannelStore.getChannels(guildId)[GUILD_SELECTABLE_CHANNELS_KEY].concat(GuildChannelStore.getChannels(guildId)[GUILD_VOCAL_CHANNELS_KEY]);
|
|
const textChannelNameDisambiguations = GuildChannelStore.getTextChannelNameDisambiguations(guildId);
|
|
const r91 = Module12.chain(r70).map((item) => item.channel).concat(guildId != null ? ChannelStore.getAllThreadsForGuild(guildId) : []).filter((item) => {
|
|
let r12 = textChannelNameDisambiguations[item.id]?.name;
|
|
if (r12 == null) {
|
|
r12 = computeChannelName(item, UserStore, RelationshipStore);
|
|
}
|
|
return c17693_0 === r12;
|
|
}).value();
|
|
let r95 = r91?.length > 0;
|
|
if (r95) {
|
|
a0.setData("channelIds", r91.map((item) => item.id));
|
|
r95 = true;
|
|
}
|
|
r37 = r95;
|
|
} else {
|
|
r37 = a1.type === SearchTypes.DMS && !StreamerModeStore.hidePersonalInformation;
|
|
if (r37) {
|
|
let c17692_0 = r22;
|
|
const r47 = Object.values(ChannelStore.getMutablePrivateChannels()).filter((item) => {
|
|
if (item.isGroupDM() && c17692_0 === computeChannelName(item, UserStore, RelationshipStore)) {
|
|
return true;
|
|
}
|
|
if (item.isDM()) {
|
|
const user = UserStore.getUser(item.getRecipientId());
|
|
if (user == null) {
|
|
return false;
|
|
}
|
|
return c17692_0 === UserUtils.getUserTag(user);
|
|
}
|
|
return false;
|
|
});
|
|
let r51 = r47?.length > 0;
|
|
if (r51) {
|
|
a0.setData("channelIds", r47.map((item) => item.id));
|
|
r51 = true;
|
|
}
|
|
r37 = r51;
|
|
}
|
|
}
|
|
}
|
|
return r37;
|
|
};
|
|
getHasMap = function getHasMap() {
|
|
const r1 = {};
|
|
r1[intl.string(t.ZNR2fi)] = "link";
|
|
r1[intl.string(t["20uQR3"])] = "embed";
|
|
r1[intl.string(t.L4lxyE)] = "poll";
|
|
r1[intl.string(t.nrpA5E)] = "snapshot";
|
|
r1[intl.string(t["AV/v6i"])] = "file";
|
|
r1[intl.string(t.XM9XGP)] = "video";
|
|
r1[intl.string(t.TNLcpx)] = "image";
|
|
r1[intl.string(t.F8Wf0e)] = "sound";
|
|
r1[intl.string(t.PJgX2h)] = "sticker";
|
|
return r1;
|
|
};
|
|
isValidHasAutocomplete = function isValidHasAutocomplete(a0) {
|
|
return validateForMapWithNegation("has", getHasMap(), a0);
|
|
};
|
|
isValidAuthorTypeAutocomplete = function isValidAuthorTypeAutocomplete(a0) {
|
|
const r3 = {};
|
|
r3[intl.string(t.tPZo4p)] = "user";
|
|
r3[intl.string(t.JL7sRS)] = "bot";
|
|
r3[intl.string(t.WjkIKU)] = "webhook";
|
|
return validateForMapWithNegation("author_type", r3, a0);
|
|
};
|
|
isValidPinnedAutocomplete = function isValidPinnedAutocomplete(a0) {
|
|
let r1;
|
|
const match = a0.getMatch(1);
|
|
if (match === "true") {
|
|
a0.setData("pinned", true);
|
|
r1 = true;
|
|
} else {
|
|
r1 = match === "false";
|
|
if (r1) {
|
|
a0.setData("pinned", false);
|
|
r1 = true;
|
|
}
|
|
}
|
|
return r1;
|
|
};
|
|
generateDateAutocompletions = function generateDateAutocompletions() {
|
|
return [...Array.from(new Set(Module3771.months().map($mk83959()))), ...Array.from(new Set(Module3771.weekdays().map($mk83960()))), ...Array.from(new Set(Module12.range(2015, new Date().getFullYear() + 1).map($mk83961()))), ...Object.keys(getShortcuts())];
|
|
};
|
|
getUserAutocompletions = function getUserAutocompletions(a0) {
|
|
let r61, query2, users;
|
|
const { query, searchContext, maxResults = 10 } = a0;
|
|
let c17694_0, c17694_1, currentUser, c17694_3;
|
|
L21: {
|
|
let tokens = a0.tokens;
|
|
c17694_0 = void 0;
|
|
c17694_1 = void 0;
|
|
currentUser = void 0;
|
|
c17694_3 = void 0;
|
|
query2 = query.trim().split("#")[0];
|
|
const r14 = {
|
|
query: query2,
|
|
limit: maxResults,
|
|
request: false,
|
|
boosters: getBoosterMap(AutocompleterResultTypes.USER)
|
|
};
|
|
const type = searchContext.type;
|
|
if (SearchTypes.GUILD !== type && SearchTypes.GUILD_CHANNEL !== type && SearchTypes.THREAD !== type) {
|
|
if (SearchTypes.CHANNEL === type) {
|
|
r61 = AutocompleteUtils.queryChannelUsers({
|
|
...r14,
|
|
channelId: searchContext.channelId
|
|
});
|
|
break L21;
|
|
}
|
|
if (SearchTypes.DMS === type) {
|
|
if (tokens == null) {
|
|
tokens = [];
|
|
}
|
|
if (tokens == null) {
|
|
users = [];
|
|
} else {
|
|
let c17695_2;
|
|
let c17695_0 = new Set();
|
|
const r47 = [];
|
|
let c17695_1 = r47;
|
|
tokens.forEach((token) => {
|
|
const data = token.getData("channelIds");
|
|
if (data != null) {
|
|
data.forEach((item) => c17695_1.push(item));
|
|
}
|
|
});
|
|
users = [];
|
|
c17695_2 = users;
|
|
r47.forEach((item) => {
|
|
const channel = ChannelStore.getChannel(item);
|
|
if (channel != null) {
|
|
if (channel.isDM()) {
|
|
const user = UserStore.getUser(channel.getRecipientId());
|
|
if (!(user == null || c17695_0.has(user.id))) {
|
|
c17695_2.push(user);
|
|
c17695_0.add(user.id);
|
|
}
|
|
} else if (channel.isGroupDM()) {
|
|
channel.recipients.forEach((recipient) => {
|
|
const user = UserStore.getUser(recipient);
|
|
if (!(user == null || c17695_0.has(user.id))) {
|
|
c17695_2.push(user);
|
|
c17695_0.add(user.id);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
if (users.length > 0) {
|
|
const currentUser2 = UserStore.getCurrentUser();
|
|
if (currentUser2 != null) {
|
|
users.push(currentUser2);
|
|
}
|
|
r61 = AutocompleteUtils.queryUsers({
|
|
...r14,
|
|
users
|
|
});
|
|
break L21;
|
|
}
|
|
r61 = AutocompleteUtils.queryAllUsers({
|
|
...r14
|
|
});
|
|
break L21;
|
|
}
|
|
return [];
|
|
}
|
|
if (query2.length === 0) {
|
|
const r132 = [];
|
|
c17694_0 = r132;
|
|
c17694_1 = new Set();
|
|
AutocompleteUtils.getRecentlyTalked(SelectedChannelStore.getCurrentlySelectedChannelId(searchContext.guildId), maxResults).forEach(({ record }) => {
|
|
if (!(record == null || c17694_1.has(record.id) || RelationshipStore.isBlockedOrIgnored(record.id))) {
|
|
c17694_0.push({
|
|
user: record,
|
|
text: UserUtils.getUserTag(record)
|
|
});
|
|
c17694_1.add(record.id);
|
|
}
|
|
});
|
|
SearchRecentMessageStore.getRecentMessageAuthorIds(searchContext.guildId).forEach((item) => {
|
|
const user = UserStore.getUser(item);
|
|
if (!(user == null || c17694_1.has(user.id) || RelationshipStore.isBlockedOrIgnored(user.id))) {
|
|
c17694_0.push({
|
|
user,
|
|
text: UserUtils.getUserTag(user)
|
|
});
|
|
c17694_1.add(user.id);
|
|
}
|
|
});
|
|
return r132.slice(0, maxResults);
|
|
}
|
|
r61 = AutocompleteUtils.queryGuildUsers({
|
|
...r14,
|
|
guildId: searchContext.guildId
|
|
});
|
|
}
|
|
currentUser = UserStore.getCurrentUser();
|
|
const r102 = query2.toLowerCase().replace(/^@/, "");
|
|
const r104 = currentUser != null && query2.length > 0 && (intl.string(t.Qf3ptv).startsWith(r102) || ME.substr(1).startsWith(r102));
|
|
c17694_3 = r104;
|
|
const r127 = r61.filter(({ record }) => !(RelationshipStore.isBlockedOrIgnored(record.id) || c17694_3 && record.id === currentUser?.id)).map(({ record }) => ({
|
|
text: UserUtils.getUserTag(record),
|
|
user: record
|
|
}));
|
|
if (r104) {
|
|
r127.unshift({
|
|
text: ME,
|
|
user: currentUser
|
|
});
|
|
}
|
|
return r127;
|
|
};
|
|
getChannelAutocompletions = function getChannelAutocompletions({ query, searchContext, maxResults }) {
|
|
let r100;
|
|
const r7 = query.trim();
|
|
const r29 = r7.startsWith("\"") && r7.endsWith("\"") ? r7.substring(1, r7.length - 1).replaceAll(/\\(.)/g, (a0, a1) => a1) : r7.startsWith("\"") ? r7.substring(1).replaceAll(/\\(.)/g, (a0, a1) => a1) : r7;
|
|
const query2 = r29[0] === "#" ? r29.substring(1) : r29;
|
|
L17: {
|
|
if (isGuildLikeSearchContext(searchContext)) {
|
|
let channelId, textChannelNameDisambiguations2;
|
|
const guildId = searchContext.guildId;
|
|
channelId = void 0;
|
|
textChannelNameDisambiguations2 = void 0;
|
|
const r133 = AutocompleteUtils.queryChannels({
|
|
query: query2,
|
|
type: GUILD_SELECTABLE_CHANNELS_KEY,
|
|
guildId,
|
|
limit: Infinity,
|
|
allowEmptyQueries: true,
|
|
allowSnowflake: true,
|
|
includeAllThreads: true,
|
|
boosters: getBoosterMap(AutocompleterResultTypes.TEXT_CHANNEL)
|
|
}).concat(AutocompleteUtils.queryChannels({
|
|
query: query2,
|
|
type: GUILD_VOCAL_CHANNELS_KEY,
|
|
guildId,
|
|
limit: Infinity,
|
|
allowEmptyQueries: true,
|
|
allowSnowflake: true,
|
|
boosters: getBoosterMap(AutocompleterResultTypes.VOICE_CHANNEL)
|
|
})).map((item) => item.record);
|
|
if (query2.length === 0) {
|
|
channelId = SelectedChannelStore.getChannelId(guildId);
|
|
const r141 = r133.find((item) => item.id === channelId);
|
|
if (r141 != null) {
|
|
r133.splice(r133.indexOf(r141), 1);
|
|
r133.unshift(r141);
|
|
}
|
|
}
|
|
textChannelNameDisambiguations2 = GuildChannelStore.getTextChannelNameDisambiguations(guildId);
|
|
r100 = Module12(r133).take(maxResults).map((item) => {
|
|
let r7 = textChannelNameDisambiguations2[item.id]?.name;
|
|
if (r7 == null) {
|
|
r7 = computeChannelName(item, UserStore, RelationshipStore);
|
|
}
|
|
return {
|
|
text: `${r7}`,
|
|
channel: item,
|
|
key: item.id
|
|
};
|
|
}).value();
|
|
} else {
|
|
if (searchContext.type === SearchTypes.DMS && !StreamerModeStore.hidePersonalInformation) {
|
|
const r96 = Module12(AutocompleteUtils.queryGroupDMs({
|
|
query: query2,
|
|
limit: maxResults,
|
|
fuzzy: true,
|
|
boosters: getBoosterMap(AutocompleterResultTypes.GROUP_DM)
|
|
}).concat(AutocompleteUtils.queryDMChannels({
|
|
query: query2,
|
|
limit: maxResults,
|
|
boosters: getBoosterMap(AutocompleterResultTypes.USER)
|
|
}))).sort(sortByMatchScore).map((item) => {
|
|
const record = item.record;
|
|
return {
|
|
text: item.comparator,
|
|
channel: record,
|
|
key: record?.id
|
|
};
|
|
}).filter((item) => item.text != null && item.channel != null && item.key != null).value();
|
|
query2.length;
|
|
r100 = r96.slice(0, maxResults);
|
|
break L17;
|
|
}
|
|
r100 = [];
|
|
}
|
|
}
|
|
return r100;
|
|
};
|
|
makeSearchTokenConfigs = function makeSearchTokenConfigs(c17697_0) {
|
|
const r9 = [intl.string(t.tPZo4p), intl.string(t.JL7sRS), intl.string(t.WjkIKU)];
|
|
let c17697_1 = r9;
|
|
const r16 = [intl.string(t.TNLcpx), intl.string(t.XM9XGP), intl.string(t.ZNR2fi), intl.string(t["AV/v6i"]), intl.string(t["20uQR3"]), intl.string(t.F8Wf0e), intl.string(t.L4lxyE), intl.string(t.PJgX2h), intl.string(t.nrpA5E)];
|
|
let c17697_2 = r16;
|
|
const r133 = {};
|
|
const FILTER_FROM = SearchTokenTypes.FILTER_FROM;
|
|
const r140 = intl.string(t["1TUdFo"]);
|
|
const r147 = {
|
|
regex: new RegExp(`${r140}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t["1TUdFo"])}:`,
|
|
plainText: intl.string(t["1TUdFo"]),
|
|
validator: () => isFromUserFilterSupported(),
|
|
getAutocompletions: null
|
|
};
|
|
r147.getAutocompletions = getUserAutocompletions;
|
|
r133[FILTER_FROM] = r147;
|
|
const ANSWER_USERNAME_FROM = SearchTokenTypes.ANSWER_USERNAME_FROM;
|
|
const follows = [SearchTokenTypes.FILTER_FROM];
|
|
const regex = c6724_33;
|
|
r133[ANSWER_USERNAME_FROM] = {
|
|
follows,
|
|
regex,
|
|
validator: isValidUserAutocomplete,
|
|
mutable: true,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "author_id"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_MENTIONS] = {
|
|
regex: new RegExp(`${intl.string(t["i96lO+"])}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t["i96lO+"])}:`,
|
|
plainText: intl.string(t["i96lO+"]),
|
|
validator: () => isMentionsUserFilterSupported(),
|
|
getAutocompletions: getUserAutocompletions
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_USERNAME_MENTIONS] = {
|
|
follows: [SearchTokenTypes.FILTER_MENTIONS],
|
|
regex,
|
|
validator: isValidUserAutocomplete,
|
|
mutable: true,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "mentions"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_HAS] = {
|
|
regex: new RegExp(`${intl.string(t.CqCvir)}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t.CqCvir)}:`,
|
|
plainText: intl.string(t.CqCvir),
|
|
getAutocompletions: ({ query, maxResults }) => {
|
|
let env26616;
|
|
const r2 = env6724;
|
|
const r8 = env26616 = {
|
|
$parent: r2
|
|
};
|
|
env26616[0] = void 0;
|
|
env26616[0] = query.toLocaleLowerCase();
|
|
return Module12(c17697_2).filter($mk83970(r8)).take(maxResults).map($mk83971()).value();
|
|
}
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_HAS] = {
|
|
regex: makeRegexForOptionsWithNegation(r16),
|
|
follows: [SearchTokenTypes.FILTER_HAS],
|
|
validator: isValidHasAutocomplete,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "has"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_LINK_FROM] = {
|
|
regex: new RegExp(`${intl.string(t.RpRAZD)}:`, "i"),
|
|
key: `${intl.string(t.RpRAZD)}:`,
|
|
plainText: intl.string(t.RpRAZD),
|
|
componentType: c6724_34.FILTER
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_LINK_FROM] = {
|
|
regex: GENERIC_REGEX,
|
|
follows: [SearchTokenTypes.FILTER_LINK_FROM],
|
|
mutable: true,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "link_hostname"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_FILE_TYPE] = {
|
|
regex: new RegExp(`${intl.string(t.TMNjFm)}:`, "i"),
|
|
key: `${intl.string(t.TMNjFm)}:`,
|
|
plainText: intl.string(t.TMNjFm),
|
|
componentType: c6724_34.FILTER
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_FILE_TYPE] = {
|
|
regex: GENERIC_REGEX,
|
|
follows: [SearchTokenTypes.FILTER_FILE_TYPE],
|
|
mutable: true,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "attachment_extension"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_FILE_NAME] = {
|
|
regex: new RegExp(`${intl.string(t["5xtLRC"])}:`, "i"),
|
|
key: `${intl.string(t["5xtLRC"])}:`,
|
|
plainText: intl.string(t["5xtLRC"]),
|
|
componentType: c6724_34.FILTER
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_FILE_NAME] = {
|
|
regex: GENERIC_REGEX,
|
|
follows: [SearchTokenTypes.FILTER_FILE_NAME],
|
|
mutable: true,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "attachment_filename"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_BEFORE] = {
|
|
regex: new RegExp(`${intl.string(t["qZ+7BA"])}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t["qZ+7BA"])}:`,
|
|
plainText: intl.string(t["qZ+7BA"]),
|
|
getAutocompletions: ({ query, maxResults }) => {
|
|
let env26617;
|
|
let env26618;
|
|
const FILTER_BEFORE = SearchTokenTypes.FILTER_BEFORE;
|
|
const r10 = env26617 = {};
|
|
env26617[0] = FILTER_BEFORE;
|
|
const r6 = generateDateAutocompletions();
|
|
const r12 = env26618 = {
|
|
$parent: env6724
|
|
};
|
|
env26618[0] = void 0;
|
|
env26618[0] = query.toLocaleLowerCase();
|
|
return Module12(r6).filter($mk83970(r12)).take(maxResults).map($mk83971()).value().map($mk83969(r10));
|
|
}
|
|
};
|
|
r133[SearchTokenTypes.FILTER_ON] = {
|
|
regex: new RegExp(`${`(${intl.string(t.tIxkOo)}|${intl.string(t.h2NzSd)})`}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t.h2NzSd)}:`,
|
|
plainText: intl.string(t.h2NzSd),
|
|
getAutocompletions: ({ query, maxResults }) => {
|
|
let env26619;
|
|
let env26620;
|
|
const FILTER_ON = SearchTokenTypes.FILTER_ON;
|
|
const r10 = env26619 = {};
|
|
env26619[0] = FILTER_ON;
|
|
const r6 = generateDateAutocompletions();
|
|
const r12 = env26620 = {
|
|
$parent: env6724
|
|
};
|
|
env26620[0] = void 0;
|
|
env26620[0] = query.toLocaleLowerCase();
|
|
return Module12(r6).filter($mk83970(r12)).take(maxResults).map($mk83971()).value().map($mk83969(r10));
|
|
}
|
|
};
|
|
r133[SearchTokenTypes.FILTER_AFTER] = {
|
|
regex: new RegExp(`${intl.string(t.KSDx7M)}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t.KSDx7M)}:`,
|
|
plainText: intl.string(t.KSDx7M),
|
|
getAutocompletions: ({ query, maxResults }) => {
|
|
let env26621;
|
|
let env26622;
|
|
const FILTER_AFTER = SearchTokenTypes.FILTER_AFTER;
|
|
const r10 = env26621 = {};
|
|
env26621[0] = FILTER_AFTER;
|
|
const r6 = generateDateAutocompletions();
|
|
const r12 = env26622 = {
|
|
$parent: env6724
|
|
};
|
|
env26622[0] = void 0;
|
|
env26622[0] = query.toLocaleLowerCase();
|
|
return Module12(r6).filter($mk83970(r12)).take(maxResults).map($mk83971()).value().map($mk83969(r10));
|
|
}
|
|
};
|
|
const ANSWER_BEFORE = SearchTokenTypes.ANSWER_BEFORE;
|
|
r133[ANSWER_BEFORE] = {
|
|
regex: c6724_21,
|
|
follows: [SearchTokenTypes.FILTER_BEFORE],
|
|
componentType: c6724_34.ANSWER,
|
|
mutable: true,
|
|
validator: (a0) => dateValidator(a0, "before")
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_ON] = {
|
|
regex: c6724_21,
|
|
follows: [SearchTokenTypes.FILTER_ON],
|
|
componentType: c6724_34.ANSWER,
|
|
mutable: true,
|
|
validator: (a0) => dateValidator(a0, "on")
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_AFTER] = {
|
|
regex: c6724_21,
|
|
follows: [SearchTokenTypes.FILTER_AFTER],
|
|
componentType: c6724_34.ANSWER,
|
|
mutable: true,
|
|
validator: (a0) => dateValidator(a0, "after")
|
|
};
|
|
r133[SearchTokenTypes.FILTER_IN] = {
|
|
regex: new RegExp(`${intl.string(t.WNpFHa)}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t.WNpFHa)}:`,
|
|
plainText: intl.string(t.WNpFHa),
|
|
validator: () => {
|
|
let r4 = c17697_0;
|
|
if (r4 == null) {
|
|
r4 = SearchAutocompleteStore.getSelectedSearchContext();
|
|
}
|
|
return r4 != null && isInChannelFilterSupported(r4);
|
|
},
|
|
getAutocompletions: getChannelAutocompletions
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_IN] = {
|
|
regex: ANSWER_IN_REGEX,
|
|
mutable: true,
|
|
follows: [SearchTokenTypes.FILTER_IN],
|
|
componentType: c6724_34.ANSWER,
|
|
validator: (a0) => {
|
|
let r4 = c17697_0;
|
|
if (r4 == null) {
|
|
r4 = SearchAutocompleteStore.getSelectedSearchContext();
|
|
}
|
|
return r4 != null && isValidChannelAutocomplete(a0, r4);
|
|
},
|
|
queryKey: "channel_id"
|
|
};
|
|
r133[SearchTokenTypes.FILTER_PINNED] = {
|
|
regex: new RegExp(`${intl.string(t["0B74eY"])}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t["0B74eY"])}:`,
|
|
plainText: intl.string(t["0B74eY"]),
|
|
getAutocompletions: () => [{
|
|
text: "true"
|
|
}, {
|
|
text: "false"
|
|
}]
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_PINNED] = {
|
|
regex: c6724_22,
|
|
componentType: c6724_34.ANSWER,
|
|
follows: [SearchTokenTypes.FILTER_PINNED],
|
|
queryKey: "pinned",
|
|
validator: isValidPinnedAutocomplete
|
|
};
|
|
r133[SearchTokenTypes.FILTER_AUTHOR_TYPE] = {
|
|
regex: new RegExp(`${intl.string(t.us8IQi)}:`, "i"),
|
|
componentType: c6724_34.FILTER,
|
|
key: `${intl.string(t.us8IQi)}:`,
|
|
plainText: intl.string(t.us8IQi),
|
|
getAutocompletions: ({ query, maxResults }) => {
|
|
let env26623;
|
|
const r2 = env6724;
|
|
const r8 = env26623 = {
|
|
$parent: r2
|
|
};
|
|
env26623[0] = void 0;
|
|
env26623[0] = query.toLocaleLowerCase();
|
|
return Module12(c17697_1).filter($mk83970(r8)).take(maxResults).map($mk83971()).value();
|
|
}
|
|
};
|
|
r133[SearchTokenTypes.ANSWER_AUTHOR_TYPE] = {
|
|
regex: makeRegexForOptionsWithNegation(r9),
|
|
follows: [SearchTokenTypes.FILTER_AUTHOR_TYPE],
|
|
validator: isValidAuthorTypeAutocomplete,
|
|
componentType: c6724_34.ANSWER,
|
|
queryKey: "author_type"
|
|
};
|
|
return r133;
|
|
};
|
|
const SearchTokenTypes2 = SearchTokenTypes;
|
|
c6724_21 = new RegExp("(?:\\s*(([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})|([0-9]{4})-([0-9]{1,2})|\\d{4}|([^\\d\\s]+)))", "i");
|
|
c6724_22 = new RegExp("\\s*(true|false)", "i");
|
|
c6724_33 = /^(?:\s*(\d{17,20}|@me|([^@#:]+)#([0-9]{4})|([a-z0-9_.]{2,32})))/i;
|
|
c6724_34 = {
|
|
FILTER: "FILTER",
|
|
ANSWER: "ANSWER"
|
|
};
|
|
c6724_36 = {};
|
|
const r74 = {};
|
|
r74[SearchTokenTypes2.FILTER_HAS] = SearchTokenTypes2.ANSWER_HAS;
|
|
r74[SearchTokenTypes2.FILTER_AUTHOR_TYPE] = SearchTokenTypes2.ANSWER_AUTHOR_TYPE;
|
|
r74[SearchTokenTypes2.FILTER_PINNED] = SearchTokenTypes2.ANSWER_PINNED;
|
|
c6724_37 = r74;
|
|
export default c6724_36;
|
|
export { isValidUserAutocomplete };
|
|
export { isValidChannelAutocomplete };
|
|
export function getLocalizedHasAnswer(a0) {
|
|
let env17698;
|
|
const hasMap = getHasMap();
|
|
const r8 = env17698 = {};
|
|
env17698[0] = void 0;
|
|
const r7 = a0.startsWith("-");
|
|
const r14 = r7 ? a0.slice(1) : a0;
|
|
env17698[0] = r14;
|
|
const r21 = Object.entries(hasMap).find($mk83968(r8));
|
|
let r22 = r21 == null ? void 0 : r21[0];
|
|
if (r22 == null) {
|
|
r22 = r14;
|
|
}
|
|
return r7 ? `-${r22}` : r22;
|
|
}
|
|
export function getLocalizedAuthorTypeAnswer(a0) {
|
|
let env17699;
|
|
const r11 = {};
|
|
r11[intl.string(t.tPZo4p)] = "user";
|
|
r11[intl.string(t.JL7sRS)] = "bot";
|
|
r11[intl.string(t.WjkIKU)] = "webhook";
|
|
const r40 = env17699 = {};
|
|
env17699[0] = void 0;
|
|
const r43 = a0.startsWith("-");
|
|
const r44 = r43 ? a0.slice(1) : a0;
|
|
env17699[0] = r44;
|
|
const r51 = Object.entries(r11).find($mk83968(r40));
|
|
let r52 = r51 == null ? void 0 : r51[0];
|
|
if (r52 == null) {
|
|
r52 = r44;
|
|
}
|
|
return r43 ? `-${r52}` : r52;
|
|
}
|
|
export function getRandomDateShortcut() {
|
|
return Module12.sample(generateDateAutocompletions());
|
|
}
|
|
export { getUserAutocompletions };
|
|
export { c6724_34 as ComponentTypes };
|
|
export function buildCrossDMSearchTokensConfig() {
|
|
return makeSearchTokenConfigs({
|
|
type: SearchTypes.DMS
|
|
});
|
|
}
|
|
export function rebuildSearchTokenConfigs() {
|
|
Object.assign(c6724_36, makeSearchTokenConfigs());
|
|
}
|
|
export function isSearchFilterTokenType(a0) {
|
|
return IS_SEARCH_FILTER_TOKEN.test(a0);
|
|
}
|
|
export function isMeAutcompleteAnswer(a0) {
|
|
if (a0.length === 0) {
|
|
return false;
|
|
}
|
|
const r11 = a0.toLowerCase().replace(/^@/, "");
|
|
return intl.string(t.Qf3ptv).startsWith(r11) || ME.substring(1).startsWith(r11);
|
|
}
|
|
export function isValidFilterAnswerForSubmit(a0, a1) {
|
|
let r38;
|
|
const r9 = c6724_37[a0];
|
|
if (r9 == null) {
|
|
return true;
|
|
}
|
|
const token = new Token([`filter:${a1}`, a1], r9);
|
|
if (SearchTokenTypes.ANSWER_HAS === r9) {
|
|
return validateForMapWithNegation("has", getHasMap(), token);
|
|
}
|
|
if (SearchTokenTypes.ANSWER_AUTHOR_TYPE === r9) {
|
|
const r49 = {};
|
|
r49[intl.string(t.tPZo4p)] = "user";
|
|
r49[intl.string(t.JL7sRS)] = "bot";
|
|
r49[intl.string(t.WjkIKU)] = "webhook";
|
|
return validateForMapWithNegation("author_type", r49, token);
|
|
}
|
|
if (SearchTokenTypes.ANSWER_PINNED === r9) {
|
|
const match = token.getMatch(1);
|
|
if (match === "true") {
|
|
token.setData("pinned", true);
|
|
r38 = true;
|
|
} else {
|
|
r38 = match === "false";
|
|
if (r38) {
|
|
token.setData("pinned", false);
|
|
r38 = true;
|
|
}
|
|
}
|
|
return r38;
|
|
}
|
|
return false;
|
|
}
|