747 lines
26 KiB
TypeScript
747 lines
26 KiB
TypeScript
// Module ID: 12559
|
|
// Function ID: 12560
|
|
// Name: SearchUtils
|
|
// Dependencies: [32, 2065, 4748, 5925, 2087, 4760, 2116, 1390, 9313, 1085, 4702, 1126, 12560, 11, 12558, 12, 584, 5421, 4962, 12563, 2]
|
|
// Exports: clearTokenCache, filterHasAnswer, getAutocompleteMode, getChannelActiveAgoTimestamp, getChannelDisplayName, getChannelIdFromSearchContext, getChannelPlaceholderName, getFlattenedAutocompleteResults, getGuildIdFromSearchContext, getIndexingErrorText, getNonTokenQuery, getQueryContentString, getQueryFromTokens, getSearchAnalyticsIds, getSearchContextId, getSearchHistoryStateId, getSearchOptionAnswer, getSearchQueryFromTokens, getSearchTabFetchId, getSelectionScope, getTabTitle, queryHasFilter, quoteChannelName, refreshSearchTokens, removeInvalidPrivateChannelSearchTokens, searchModeToSearchQueryParams, searchQueryParamsToSearchMode, setIncludeNSFW, showDatePicker, tokenizeQuery
|
|
|
|
// Module 12559 (SearchUtils)
|
|
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
|
|
import _modDef12 from "module_12" /* 12 */;
|
|
import DispatcherDefault from "Dispatcher" /* 584 */;
|
|
import intl11 from "intl" /* 1126 */;
|
|
import _modDef4702 from "module_4702" /* 4702 */;
|
|
import UserUtilsDefault from "UserUtils" /* 4962 */;
|
|
import useChannelName from "useChannelName" /* 5421 */;
|
|
import SearchConstants from "SearchConstants" /* 9313 */;
|
|
import QueryTokenizerDefault from "QueryTokenizer" /* 12558 */;
|
|
import SearchTokens from "SearchTokens" /* 12560 */;
|
|
import isGuildLikeSearchContext from "isGuildLikeSearchContext" /* 12563 */;
|
|
import _slicedToArray from "_slicedToArray" /* 32 */;
|
|
import ChannelStore from "ChannelStore" /* 2065 */;
|
|
import GuildChannelStore from "GuildChannelStore" /* 4748 */;
|
|
import GuildNSFWAgreeStore from "GuildNSFWAgreeStore" /* 5925 */;
|
|
import GuildStore from "GuildStore" /* 2087 */;
|
|
import RelationshipStore from "RelationshipStore" /* 4760 */;
|
|
import SelectedChannelStore from "SelectedChannelStore" /* 2116 */;
|
|
import UserStore from "UserStore" /* 1390 */;
|
|
import Constants from "Constants" /* 1085 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const SearchTokensDefault = SearchTokens;
|
|
let addRule, closure_4, importDefault, results, set;
|
|
|
|
let ME;
|
|
let SearchTokenTypes;
|
|
let closure_14;
|
|
let closure_15;
|
|
let closure_16;
|
|
let closure_17;
|
|
let map1;
|
|
let unpackModuleId;
|
|
const f113442 = (arg0, arg1) => "\\" + arg1;
|
|
const SearchTabs = SearchConstants.SearchTabs;
|
|
({ SearchTypes: unpackModuleId, SearchTokenTypes } = Constants);
|
|
({ SearchPopoutModes: map1, IS_SEARCH_ANSWER_TOKEN: closure_14, IS_SEARCH_FILTER_TOKEN: closure_15, SearchModes: closure_16, ME, GuildFeatures: closure_17 } = Constants);
|
|
let c18 = 2592000;
|
|
let c19 = 31536000;
|
|
const ShowDatePicker = { [SearchTokenTypes.FILTER_BEFORE]: true, [SearchTokenTypes.FILTER_AFTER]: true, [SearchTokenTypes.FILTER_ON]: true };
|
|
let tmp4 = new QueryTokenizerDefault();
|
|
const navigation = tmp4;
|
|
let tmp5 = new QueryTokenizerDefault();
|
|
const navigation2 = tmp5;
|
|
let result = size.fileFinishedImporting("modules/search/SearchUtils.tsx");
|
|
|
|
export const getSearchContextId = function getSearchContextId(searchContext) {
|
|
const type = searchContext.type;
|
|
if (unpackModuleId.GUILD === type) {
|
|
return searchContext.guildId;
|
|
} else {
|
|
if (unpackModuleId.GUILD_CHANNEL !== type) {
|
|
if (unpackModuleId.CHANNEL !== type) {
|
|
if (unpackModuleId.THREAD !== type) {
|
|
return unpackModuleId.DMS === type ? searchContext.type : undefined;
|
|
}
|
|
}
|
|
}
|
|
return searchContext.channelId;
|
|
}
|
|
};
|
|
export const getSearchHistoryStateId = function getSearchHistoryStateId(type) {
|
|
let channelId;
|
|
type = type.type;
|
|
if (unpackModuleId.GUILD === type) {
|
|
channelId = type.guildId;
|
|
} else {
|
|
if (unpackModuleId.GUILD_CHANNEL !== type) {
|
|
if (unpackModuleId.CHANNEL !== type) {
|
|
if (unpackModuleId.THREAD !== type) {
|
|
if (unpackModuleId.DMS === type) {
|
|
channelId = type.type;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
channelId = type.channelId;
|
|
}
|
|
return channelId;
|
|
};
|
|
export const getSearchTabFetchId = function getSearchTabFetchId(searchContext, tab, searchResultsQuery) {
|
|
let channelId;
|
|
const type = searchContext.type;
|
|
if (unpackModuleId.GUILD === type) {
|
|
channelId = searchContext.guildId;
|
|
} else {
|
|
if (unpackModuleId.GUILD_CHANNEL !== type) {
|
|
if (unpackModuleId.CHANNEL !== type) {
|
|
if (unpackModuleId.THREAD !== type) {
|
|
if (unpackModuleId.DMS === type) {
|
|
channelId = searchContext.type;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
channelId = searchContext.channelId;
|
|
}
|
|
return "" + channelId + "-" + tab + "-" + searchResultsQuery;
|
|
};
|
|
export const getChannelActiveAgoTimestamp = function getChannelActiveAgoTimestamp(cResult) {
|
|
const obj = _modDef4702();
|
|
const diffResult = obj.diff(_modDef4702(cResult), "s");
|
|
if (diffResult > c19) {
|
|
const _Math5 = Math;
|
|
const rounded = Math.round(diffResult / tmp3);
|
|
const intl7 = intl11.intl;
|
|
const obj2 = { count: rounded };
|
|
return intl7.formatToPlainString(intl11.t["7th+Mf"], obj2);
|
|
} else if (diffResult > c18) {
|
|
const _Math4 = Math;
|
|
const rounded1 = Math.round(diffResult / tmp21);
|
|
const intl6 = intl11.intl;
|
|
const obj3 = { count: rounded1 };
|
|
return intl6.formatToPlainString(intl11.t.g2uHTD, obj3);
|
|
} else if (diffResult > 172800) {
|
|
const _Math3 = Math;
|
|
const rounded2 = Math.round(diffResult / 86400);
|
|
const intl5 = intl11.intl;
|
|
const obj4 = { count: rounded2 };
|
|
return intl5.formatToPlainString(intl11.t.HNgi95, obj4);
|
|
} else if (diffResult > 86400) {
|
|
const intl4 = intl11.intl;
|
|
return intl4.string(intl11.t.uNkIhT);
|
|
} else if (diffResult > 3600) {
|
|
const _Math2 = Math;
|
|
const rounded3 = Math.round(diffResult / 3600);
|
|
const intl3 = intl11.intl;
|
|
const obj5 = { count: rounded3 };
|
|
return intl3.formatToPlainString(intl11.t.WJBWP1, obj5);
|
|
} else if (diffResult > 60) {
|
|
const _Math = Math;
|
|
const rounded4 = Math.round(diffResult / 60);
|
|
const intl2 = intl11.intl;
|
|
const obj6 = { count: rounded4 };
|
|
return intl2.formatToPlainString(intl11.t.CbRfwg, obj6);
|
|
} else {
|
|
const intl = intl11.intl;
|
|
return intl.string(intl11.t["5Ldpkc"]);
|
|
}
|
|
};
|
|
export const getIndexingErrorText = function getIndexingErrorText(searchContext) {
|
|
const type = searchContext.type;
|
|
if (unpackModuleId.CHANNEL === type) {
|
|
const intl3 = intl11.intl;
|
|
return intl3.string(intl11.t.Q0JJjv);
|
|
} else if (unpackModuleId.DMS === type) {
|
|
const intl2 = intl11.intl;
|
|
return intl2.string(intl11.t.Br0xJA);
|
|
} else {
|
|
const intl = intl11.intl;
|
|
return intl.string(intl11.t.AXPbZr);
|
|
}
|
|
};
|
|
export const getGuildIdFromSearchContext = function getGuildIdFromSearchContext(searchContext) {
|
|
const type = searchContext.type;
|
|
if (unpackModuleId.GUILD_CHANNEL !== type) {
|
|
if (unpackModuleId.GUILD !== type) {
|
|
if (unpackModuleId.THREAD !== type) {
|
|
if (unpackModuleId.CHANNEL === type) {
|
|
const channel = ChannelStore.getChannel(searchContext.channelId);
|
|
let guild_id;
|
|
if (channel != null) {
|
|
guild_id = channel.guild_id;
|
|
}
|
|
if (guild_id == null) {
|
|
guild_id = null;
|
|
}
|
|
return guild_id;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return searchContext.guildId;
|
|
};
|
|
export const getChannelIdFromSearchContext = function getChannelIdFromSearchContext(searchContext) {
|
|
const type = searchContext.type;
|
|
if (unpackModuleId.GUILD_CHANNEL !== type) {
|
|
if (unpackModuleId.CHANNEL !== type) {
|
|
if (unpackModuleId.THREAD !== type) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
return searchContext.channelId;
|
|
};
|
|
export const getTabTitle = function getTabTitle(id) {
|
|
if (SearchTabs.RECENT === id) {
|
|
const intl10 = intl11.intl;
|
|
return intl10.string(intl11.t.tWnHcL);
|
|
} else if (SearchTabs.MESSAGES === id) {
|
|
const intl9 = intl11.intl;
|
|
return intl9.string(intl11.t.dvZAkp);
|
|
} else if (SearchTabs.PEOPLE === id) {
|
|
const intl8 = intl11.intl;
|
|
return intl8.string(intl11.t["GFd/I5"]);
|
|
} else if (SearchTabs.MEDIA === id) {
|
|
const intl7 = intl11.intl;
|
|
return intl7.string(intl11.t["Aw9+/M"]);
|
|
} else if (SearchTabs.PINS === id) {
|
|
const intl6 = intl11.intl;
|
|
return intl6.string(intl11.t["/MoGoB"]);
|
|
} else if (SearchTabs.LINKS === id) {
|
|
const intl5 = intl11.intl;
|
|
return intl5.string(intl11.t.DFSvTt);
|
|
} else if (SearchTabs.FILES === id) {
|
|
const intl4 = intl11.intl;
|
|
return intl4.string(intl11.t["WgVYR/"]);
|
|
} else if (SearchTabs.GUILD_CHANNELS === id) {
|
|
const intl3 = intl11.intl;
|
|
return intl3.string(intl11.t.OGiMXJ);
|
|
} else if (SearchTabs.MEMBERS === id) {
|
|
const intl2 = intl11.intl;
|
|
return intl2.string(intl11.t["9Oq93m"]);
|
|
} else if (SearchTabs.THREADS === id) {
|
|
const intl = intl11.intl;
|
|
return intl.string(intl11.t.B2panI);
|
|
}
|
|
};
|
|
export const searchModeToSearchQueryParams = function searchModeToSearchQueryParams(searchMode) {
|
|
if (constants3.MOST_RELEVANT === searchMode) {
|
|
return { sort_by: "relevance", sort_order: "desc" };
|
|
} else if (constants3.OLDEST === searchMode) {
|
|
return { sort_by: "timestamp", sort_order: "asc" };
|
|
} else {
|
|
const NEWEST = tmp.NEWEST;
|
|
return { sort_by: "timestamp", sort_order: "desc" };
|
|
}
|
|
};
|
|
export const searchQueryParamsToSearchMode = function searchQueryParamsToSearchMode(sort_by) {
|
|
if (null != sort_by.sort_by) {
|
|
let NEWEST;
|
|
if (null != sort_by.sort_order) {
|
|
if ("relevance" === sort_by.sort_by) {
|
|
NEWEST = constants3.MOST_RELEVANT;
|
|
} else if ("asc" === sort_by.sort_order) {
|
|
NEWEST = constants3.OLDEST;
|
|
} else {
|
|
NEWEST = constants3.NEWEST;
|
|
}
|
|
}
|
|
return NEWEST;
|
|
}
|
|
NEWEST = constants3.NEWEST;
|
|
};
|
|
export const getSearchOptionAnswer = function getSearchOptionAnswer(arg0) {
|
|
if (SearchTokenTypes.FILTER_FROM === arg0) {
|
|
const intl10 = intl11.intl;
|
|
return intl10.string(intl11.t.E466pL);
|
|
} else if (SearchTokenTypes.FILTER_MENTIONS === arg0) {
|
|
const intl9 = intl11.intl;
|
|
return intl9.string(intl11.t.BYvFWl);
|
|
} else if (SearchTokenTypes.FILTER_HAS === arg0) {
|
|
const intl8 = intl11.intl;
|
|
return intl8.string(intl11.t.bhSYbc);
|
|
} else {
|
|
if (SearchTokenTypes.FILTER_BEFORE !== arg0) {
|
|
if (SearchTokenTypes.FILTER_ON !== arg0) {
|
|
if (SearchTokenTypes.FILTER_AFTER !== arg0) {
|
|
if (SearchTokenTypes.FILTER_IN === arg0) {
|
|
const intl6 = intl11.intl;
|
|
return intl6.string(intl11.t["GpM+/7"]);
|
|
} else if (SearchTokenTypes.FILTER_LINK_FROM === arg0) {
|
|
const intl5 = intl11.intl;
|
|
return intl5.string(intl11.t.FdDTni);
|
|
} else if (SearchTokenTypes.FILTER_FILE_TYPE === arg0) {
|
|
const intl4 = intl11.intl;
|
|
return intl4.string(intl11.t.FXcAFe);
|
|
} else if (SearchTokenTypes.FILTER_FILE_NAME === arg0) {
|
|
const intl3 = intl11.intl;
|
|
return intl3.string(intl11.t.uAbFDM);
|
|
} else if (SearchTokenTypes.FILTER_PINNED === arg0) {
|
|
const intl2 = intl11.intl;
|
|
return intl2.string(intl11.t.UJxL3V);
|
|
} else if (SearchTokenTypes.FILTER_AUTHOR_TYPE === arg0) {
|
|
const intl = intl11.intl;
|
|
return intl.string(intl11.t.qCQzBl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const intl7 = intl11.intl;
|
|
return intl7.string(intl11.t.Zbbc1E);
|
|
}
|
|
};
|
|
export { ShowDatePicker };
|
|
export const setIncludeNSFW = function setIncludeNSFW(arg0, guildIdFromSearchContext) {
|
|
if (GuildNSFWAgreeStore.didAgree(guildIdFromSearchContext)) {
|
|
const currentUser = UserStore.getCurrentUser();
|
|
if (null != currentUser) {
|
|
const tmp4 = null == currentUser.nsfwAllowed || currentUser.nsfwAllowed;
|
|
arg0.include_nsfw = tmp4;
|
|
}
|
|
}
|
|
};
|
|
export const getSearchQueryFromTokens = function getSearchQueryFromTokens(tokenizeQueryResult) {
|
|
let tmp7;
|
|
let tmp8;
|
|
const obj = {};
|
|
const item = tokenizeQueryResult.forEach(function(type) {
|
|
function getQueryKey(type) {
|
|
const tmp = closure_1_1(closure_1_2[12])[type];
|
|
let str = null;
|
|
if (null != tmp) {
|
|
str = tmp.queryKey;
|
|
}
|
|
if (null == str) {
|
|
str = "content";
|
|
}
|
|
return str;
|
|
}
|
|
type = type.type;
|
|
if (!regex.test(type)) {
|
|
let tmp = SearchTokenTypes;
|
|
if (SearchTokenTypes.ANSWER_BEFORE !== type) {
|
|
if (tmp.ANSWER_ON !== type) {
|
|
if (tmp.ANSWER_AFTER !== type) {
|
|
const tmp25 = getQueryKey(type);
|
|
if (null == obj[tmp25]) {
|
|
const _Set = Set;
|
|
const self = this;
|
|
const self2 = this;
|
|
obj[tmp25] = new Set();
|
|
set = new Set();
|
|
}
|
|
if (tmp.ANSWER_USERNAME_FROM !== type) {
|
|
if (tmp.ANSWER_USERNAME_MENTIONS !== type) {
|
|
if (tmp.ANSWER_LINK_FROM !== type) {
|
|
if (tmp.ANSWER_FILE_TYPE !== type) {
|
|
if (tmp.ANSWER_FILE_NAME !== type) {
|
|
if (tmp.ANSWER_IN === type) {
|
|
let data = type.getData("channelIds");
|
|
if (data == null) {
|
|
data = [];
|
|
}
|
|
for (const item10045 of data) {
|
|
let addResult = obj.add(item10045);
|
|
continue;
|
|
}
|
|
} else if (tmp.ANSWER_HAS === type) {
|
|
obj[tmp25].add(type.getData("has"));
|
|
} else if (tmp.ANSWER_PINNED === type) {
|
|
obj[tmp25].add(type.getData("pinned"));
|
|
} else if (tmp.ANSWER_AUTHOR_TYPE === type) {
|
|
obj[tmp25].add(type.getData("author_type"));
|
|
} else {
|
|
const add = obj.add;
|
|
let str = type.getFullMatch();
|
|
add(str.trim());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
obj[tmp25].add(type.getMatch(1));
|
|
}
|
|
}
|
|
obj[tmp25].add(type.getData("userId"));
|
|
}
|
|
}
|
|
}
|
|
const data1 = type.getData("start");
|
|
const data2 = type.getData("end");
|
|
if (data1) {
|
|
const obj2 = SnowflakeUtilsDefault;
|
|
obj.min_id = obj2.fromTimestamp(data1);
|
|
}
|
|
const tmp19 = data2;
|
|
if (tmp19) {
|
|
const obj3 = SnowflakeUtilsDefault;
|
|
obj.max_id = obj3.fromTimestamp(data2);
|
|
const fromTimestampResult = obj3.fromTimestamp(data2);
|
|
}
|
|
}
|
|
});
|
|
const entries = Object.entries(obj);
|
|
const tmp3 = entries[Symbol.iterator]();
|
|
while (tmp3 !== undefined) {
|
|
let tmp6 = _slicedToArray(tmp4, 2);
|
|
[tmp7, tmp8] = tmp6;
|
|
let _Set = Set;
|
|
if (tmp8 instanceof Set) {
|
|
let _Array = Array;
|
|
obj[tmp7] = Array.from(tmp9);
|
|
}
|
|
continue;
|
|
}
|
|
if (obj.content) {
|
|
delete obj["contents"];
|
|
const content = obj.content;
|
|
let str = " ";
|
|
const str2 = content.join(" ");
|
|
obj.content = str2.trim();
|
|
if (!obj.content) {
|
|
delete obj["content"];
|
|
}
|
|
}
|
|
return obj;
|
|
};
|
|
export const getQueryContentString = function getQueryContentString(searchQueryFromTokens) {
|
|
let content;
|
|
let contents;
|
|
if (searchQueryFromTokens != null) {
|
|
contents = searchQueryFromTokens.contents;
|
|
}
|
|
if (null != contents) {
|
|
if (searchQueryFromTokens.contents.length > 0) {
|
|
let joined;
|
|
if (searchQueryFromTokens != null) {
|
|
const contents1 = searchQueryFromTokens.contents;
|
|
if (contents1 != null) {
|
|
const mapped = contents1.map((item) => {
|
|
const parts = item.split("|");
|
|
const substr = parts.slice(1);
|
|
return substr.join("|");
|
|
});
|
|
joined = mapped.join(" ");
|
|
}
|
|
}
|
|
content = joined;
|
|
}
|
|
return content;
|
|
}
|
|
if (searchQueryFromTokens != null) {
|
|
content = searchQueryFromTokens.content;
|
|
}
|
|
};
|
|
export const getNonTokenQuery = function getNonTokenQuery(tokenizeQueryResult) {
|
|
const mapped = tokenizeQueryResult.map((type) => {
|
|
let str = "";
|
|
if (type.type === QueryTokenizerDefault.NON_TOKEN_TYPE) {
|
|
str = type.getFullMatch();
|
|
}
|
|
return str;
|
|
});
|
|
let str = mapped.join(" ");
|
|
return str.trim();
|
|
};
|
|
export const getSelectionScope = function getSelectionScope(tokenizeQueryResult, focusOffset, anchorOffset) {
|
|
let closure_1 = focusOffset;
|
|
let closure_2 = anchorOffset;
|
|
const found = tokenizeQueryResult.find((start, index) => {
|
|
if (focusOffset >= start.start) {
|
|
if (tmp <= start.end) {
|
|
if (anchorOffset >= start.start) {
|
|
let flag;
|
|
if (tmp2 <= start.end) {
|
|
flag = true;
|
|
if (null != tokenizeQueryResult[index + 1]) {
|
|
closure_4 = tmp4[index + 1];
|
|
flag = true;
|
|
}
|
|
}
|
|
return flag;
|
|
}
|
|
}
|
|
}
|
|
let closure_1_3 = start;
|
|
flag = false;
|
|
});
|
|
let tmp2 = null;
|
|
if (null != found) {
|
|
const tmp4 = nextToken;
|
|
tmp2 = { previousToken: _slicedToArray, currentToken: found, nextToken, focusOffset, anchorOffset };
|
|
const obj = { previousToken: _slicedToArray, currentToken: found, nextToken, focusOffset, anchorOffset };
|
|
}
|
|
return tmp2;
|
|
};
|
|
export const getAutocompleteMode = function getAutocompleteMode(cursorScope, tokens) {
|
|
let currentToken;
|
|
let previousToken;
|
|
let obj = cursorScope;
|
|
if (cursorScope == null) {
|
|
obj = {};
|
|
}
|
|
({ currentToken, nextToken, previousToken } = obj);
|
|
if (0 === tokens.length) {
|
|
return { type: map1.EMPTY, filter: null, token: null };
|
|
} else if (null == currentToken) {
|
|
return { type: map1.FILTER_ALL, filter: null, token: null };
|
|
} else {
|
|
const obj9 = SearchTokens;
|
|
const tmp10 = require;
|
|
if (obj9.isSearchFilterTokenType(currentToken.type)) {
|
|
if (null != nextToken) {
|
|
if (nextToken.type !== QueryTokenizerDefault.NON_TOKEN_TYPE) {
|
|
if (null != nextToken) {
|
|
if (!regex.test(nextToken.type)) {
|
|
return { type: map1.FILTER, filter: currentToken.type, token: null };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return { type: map1.FILTER, filter: currentToken.type, token: nextToken };
|
|
}
|
|
const tmp3 = importDefault;
|
|
if (currentToken.type === QueryTokenizerDefault.NON_TOKEN_TYPE) {
|
|
if (null != previousToken) {
|
|
let obj7;
|
|
const tmp10Result = tmp10(12560);
|
|
if (tmp10Result.isSearchFilterTokenType(previousToken.type)) {
|
|
obj7 = { type: map1.FILTER, filter: previousToken.type, token: currentToken };
|
|
const obj6 = { type: map1.FILTER, filter: previousToken.type, token: currentToken };
|
|
}
|
|
return obj7;
|
|
}
|
|
}
|
|
let tmp4;
|
|
if (currentToken.type === tmp3(12558).NON_TOKEN_TYPE) {
|
|
tmp4 = currentToken;
|
|
}
|
|
obj7 = { type: map1.FILTER_ALL, filter: null, token: tmp4 };
|
|
}
|
|
};
|
|
export const quoteChannelName = function quoteChannelName(channelName) {
|
|
let combined = channelName;
|
|
if (null != channelName.match(/([\\" ])/g)) {
|
|
const _HermesInternal = HermesInternal;
|
|
combined = "\"" + channelName.replaceAll(/([\\"])/g, f113442) + "\"";
|
|
}
|
|
return combined;
|
|
};
|
|
export const getFlattenedAutocompleteResults = function getFlattenedAutocompleteResults(arg0, arg1) {
|
|
let closure_1;
|
|
let closure_0 = arg1;
|
|
importDefault = [];
|
|
const arr = _modDef12(arg0);
|
|
const item = arr.forEach((results) => {
|
|
if (null != results) {
|
|
if (0 !== results.results.length) {
|
|
let group = results.group;
|
|
let tmp = group;
|
|
results = results.results;
|
|
group = group.concat(results.map((text) => {
|
|
let tmp = str;
|
|
if (null != text.channel) {
|
|
let combined = str;
|
|
if (null != text.text.match(/([\\" ])/g)) {
|
|
const _HermesInternal = HermesInternal;
|
|
combined = "\"" + str.replaceAll(/([\\"])/g, f113442) + "\"";
|
|
}
|
|
tmp = combined;
|
|
}
|
|
let combined1 = tmp;
|
|
if (results.type === map1.FILTER_ALL) {
|
|
group = text.group;
|
|
const tmp8 = SearchTokensDefault[group];
|
|
let key;
|
|
if (tmp8 != null) {
|
|
key = tmp8.key;
|
|
}
|
|
let tmp10 = null != key;
|
|
if (tmp10) {
|
|
let key1;
|
|
if (tmp8 != null) {
|
|
key1 = tmp8.key;
|
|
}
|
|
tmp10 = "" !== key1;
|
|
}
|
|
combined1 = tmp;
|
|
if (tmp10) {
|
|
const _HermesInternal2 = HermesInternal;
|
|
combined1 = "" + tmp8.key + " " + tmp;
|
|
}
|
|
}
|
|
return { result: text, group: results.group, resultText: combined1 };
|
|
}));
|
|
}
|
|
}
|
|
});
|
|
return importDefault.filter((resultText) => "" !== resultText.resultText);
|
|
};
|
|
export const getQueryFromTokens = function getQueryFromTokens(tokens) {
|
|
let str = "";
|
|
if (null != tokens) {
|
|
const mapped = tokens.map((getFullMatch) => getFullMatch.getFullMatch());
|
|
str = mapped.join("");
|
|
}
|
|
return str;
|
|
};
|
|
export const queryHasFilter = function queryHasFilter(errorcode, arg1) {
|
|
let closure_0 = arg1;
|
|
const tokenizeResult = navigation.tokenize(errorcode);
|
|
return tokenizeResult.some((type) => type.type === closure_0);
|
|
};
|
|
export const tokenizeQuery = function tokenizeQuery(searchQueryString) {
|
|
return navigation.tokenize(searchQueryString);
|
|
};
|
|
export const clearTokenCache = function clearTokenCache() {
|
|
navigation.clearCache();
|
|
navigation2.clearCache();
|
|
};
|
|
export const showDatePicker = function showDatePicker(arg0) {
|
|
let tmp = null;
|
|
if (null != arg0) {
|
|
tmp = obj[arg0];
|
|
}
|
|
return tmp;
|
|
};
|
|
export const filterHasAnswer = function filterHasAnswer(type, type2) {
|
|
const isMatch = regex2.test(type.type);
|
|
let tmp2 = null == type2 && isMatch;
|
|
if (!tmp2) {
|
|
tmp2 = null != type2 && isMatch && !regex.test(type2.type);
|
|
const tmp3 = null != type2 && isMatch && !regex.test(type2.type);
|
|
}
|
|
return !tmp2;
|
|
};
|
|
export const refreshSearchTokens = function refreshSearchTokens() {
|
|
let addRule2;
|
|
let obj = SearchTokens;
|
|
const result = obj.rebuildSearchTokenConfigs();
|
|
navigation.reset();
|
|
const tmp3 = _modDef12;
|
|
const tmp3Result = tmp3(SearchTokensDefault);
|
|
tmp3Result.forOwn((arg0, type) => {
|
|
addRule = addRule.addRule;
|
|
const obj = { type };
|
|
const merged = Object.assign(arg0);
|
|
return addRule(obj);
|
|
});
|
|
navigation2.reset();
|
|
const obj3 = SearchTokens;
|
|
const crossDMSearchTokensConfig = obj3.buildCrossDMSearchTokensConfig();
|
|
const obj4 = _modDef12(crossDMSearchTokensConfig);
|
|
obj4.forOwn((arg0, type) => {
|
|
addRule = addRule2.addRule;
|
|
const obj = { type };
|
|
const merged = Object.assign(arg0);
|
|
return addRule(obj);
|
|
});
|
|
const obj5 = DispatcherDefault;
|
|
obj5.dispatch({ type: "SEARCH_TOKENS_REFRESHED" });
|
|
};
|
|
export const getChannelDisplayName = function getChannelDisplayName(isDM) {
|
|
let flag;
|
|
let str;
|
|
const obj = useChannelName;
|
|
const channelName = obj.computeChannelName(isDM, UserStore, RelationshipStore);
|
|
const obj2 = UserStore;
|
|
if (isDM.isDM()) {
|
|
const user = obj2.getUser(isDM.getRecipientId());
|
|
const obj3 = UserUtilsDefault;
|
|
const userTag = obj3.getUserTag(user);
|
|
flag = false;
|
|
str = userTag;
|
|
if (null == userTag) {
|
|
return null;
|
|
}
|
|
} else {
|
|
flag = false;
|
|
str = channelName;
|
|
if (!isDM.isGroupDM()) {
|
|
const tmp3 = !isDM.isThread();
|
|
const tmp5 = GuildChannelStore.getTextChannelNameDisambiguations(isDM.getGuildId())[isDM.id];
|
|
let name;
|
|
if (tmp5 != null) {
|
|
name = tmp5.name;
|
|
}
|
|
flag = tmp3;
|
|
str = channelName;
|
|
if (null != name) {
|
|
str = tmp5.name;
|
|
flag = tmp3;
|
|
}
|
|
}
|
|
}
|
|
let combined = str;
|
|
if (null != str.match(/([\\" ])/g)) {
|
|
const _HermesInternal = HermesInternal;
|
|
combined = "\"" + str.replaceAll(/([\\"])/g, f113442) + "\"";
|
|
}
|
|
let combined1 = combined;
|
|
if (flag) {
|
|
const _HermesInternal2 = HermesInternal;
|
|
combined1 = "#" + combined;
|
|
}
|
|
return combined1;
|
|
};
|
|
export const getChannelPlaceholderName = function getChannelPlaceholderName(isGroupDM) {
|
|
if (isGroupDM.isGroupDM()) {
|
|
const obj3 = useChannelName;
|
|
return obj3.computeChannelName(isGroupDM, UserStore, RelationshipStore);
|
|
} else if (isGroupDM.isDM()) {
|
|
const user = UserStore.getUser(isGroupDM.getRecipientId());
|
|
const obj2 = UserUtilsDefault;
|
|
return obj2.getUserTag(user);
|
|
} else {
|
|
const tmp2 = GuildChannelStore.getTextChannelNameDisambiguations(isGroupDM.getGuildId())[isGroupDM.id];
|
|
let name;
|
|
if (tmp2 != null) {
|
|
name = tmp2.name;
|
|
}
|
|
if (name == null) {
|
|
const obj = useChannelName;
|
|
name = obj.computeChannelName(isGroupDM, UserStore, RelationshipStore);
|
|
}
|
|
return name;
|
|
}
|
|
};
|
|
export const removeInvalidPrivateChannelSearchTokens = function removeInvalidPrivateChannelSearchTokens(errorcode) {
|
|
const items = [];
|
|
const tokenizeResult = navigation2.tokenize(errorcode);
|
|
const item = tokenizeResult.forEach((type) => {
|
|
const tmp2 = type.type === SearchTokenTypes.FILTER_IN || type.type === tmp.ANSWER_IN;
|
|
if (!tmp2) {
|
|
items.push(type);
|
|
}
|
|
});
|
|
importDefault = "";
|
|
const item1 = items.forEach((getFullMatch) => {
|
|
closure_1 = closure_1 + getFullMatch.getFullMatch();
|
|
});
|
|
return importDefault.trim();
|
|
};
|
|
export const getSearchAnalyticsIds = function getSearchAnalyticsIds(guildId, getSessionId) {
|
|
const obj = isGuildLikeSearchContext;
|
|
if (obj.isGuildLikeSearchContext(guildId)) {
|
|
const guild = GuildStore.getGuild(guildId.guildId);
|
|
let hasItem;
|
|
if (guild != null) {
|
|
const features = guild.features;
|
|
hasItem = features.has(constants4.DISCOVERABLE);
|
|
}
|
|
if (hasItem) {
|
|
const sessionId = getSessionId.getSessionId(guildId);
|
|
const queryId = getSessionId.getQueryId(guildId);
|
|
let tmp9 = null;
|
|
if (null != sessionId) {
|
|
tmp9 = null;
|
|
if (null != queryId) {
|
|
tmp9 = { search_session_id: sessionId, search_query_id: queryId };
|
|
const obj2 = { search_session_id: sessionId, search_query_id: queryId };
|
|
}
|
|
}
|
|
return tmp9;
|
|
}
|
|
}
|
|
return null;
|
|
};
|