/* Metro module 15882; source: modules/guild_automod/AutomodRuleUtils.tsx; dependencies: [1226, 15883, 11454, 15885, 15886, 1244, 7246, 5065, 2] */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */ import * as ApplicationCommandUtilsModule from '../application_commands/ApplicationCommandUtils.tsx'; /* Metro dependency 5065 */ import * as AutomodErrorUtilsModule from './AutomodErrorUtils.tsx'; /* Metro dependency 7246 */ import * as ConstantsModule from './Constants.tsx'; /* Metro dependency 11454 */ import * as AutomodStoreModule from './AutomodStore.tsx'; /* Metro dependency 15883 */ import * as AutomodTriggerConfigsModule from './AutomodTriggerConfigs.tsx'; /* Metro dependency 15885 */ function _fun122517(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#122517, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:6, offset: 0x0256ab85, size: 464 bytes, params: 8, frame: 21 const env0_0 = require; const validateKeywordsOrThrow2 = validateKeywordsOrThrow; const validateRegexPatternsOrThrow2 = validateRegexPatternsOrThrow; const isBackendPersistedRule2 = isBackendPersistedRule; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const closure4 = function(a0, a1) { return '' + a0 + '-' + a1 + '-new-rule'; }; const isRuleKeywordFilter2 = isRuleKeywordFilter; (FileImportTrackerModule).fileFinishedImporting('modules/guild_automod/AutomodRuleUtils.tsx'); exports.getNewAutomodRuleMockId = closure4; exports.isRuleKeywordFilter = isRuleKeywordFilter2; exports.isRuleMLSpamFilter = isRuleMLSpamFilter; exports.isRuleDefaultKeywordListFilter = isRuleDefaultKeywordListFilter; exports.isRuleMentionSpamFilter = isRuleMentionSpamFilter; exports.isRuleServerPolicyFilter = isRuleServerPolicyFilter; exports.isRuleUserProfileFilter = isRuleUserProfileFilter; exports.createDefaultRule = createDefaultRule; exports.validateKeywordsOrThrow = validateKeywordsOrThrow2; exports.validateRegexPatternsOrThrow = validateRegexPatternsOrThrow2; exports.validateRuleBeforeSaveOrThrow = validateRuleBeforeSaveOrThrow; exports.isBackendPersistedRule = isBackendPersistedRule2; exports.eventTypeToName = eventTypeToName; exports.actionTypeToName = actionTypeToName; exports.triggerTypeToName = triggerTypeToName; function validateKeywordsOrThrow(a0, a1) { // fn#122518, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:534, offset: 0x0256ad55, size: 137 bytes, params: 3, frame: 17 var Error; var value; var intl; if (a0.length > a1) { Error = global.Error; intl = (require(1244) /* metro dependency 1244: indexNative */).intl; value = intl.formatToPlainString((require(1244) /* metro dependency 1244: indexNative */).t.mee4qd, {limit: a1}); throw new Error(); } a0.forEach(_fun122519); function _fun122519(a0) { // fn#122519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:675, offset: 0x0256adde, size: 159 bytes, params: 2, frame: 18 const InvalidKeywordError = (AutomodErrorUtilsModule).InvalidKeywordError; const intl = (IndexNativeModule).intl; const t = (IndexNativeModule).t; const length = a0.length; const value = environment.__proto__; if (length > MAX_CHARACTERS_PER_KEYWORD) { throw new InvalidKeywordError(intl.formatToPlainString(t.rbRvGe, {keyword: a0, max: MAX_CHARACTERS_PER_KEYWORD, min: MIN_CHARACTERS_PER_KEYWORD})); } if (a0.length < MIN_CHARACTERS_PER_KEYWORD) { throw new InvalidKeywordError(intl.formatToPlainString(t.rbRvGe, {keyword: a0, max: MAX_CHARACTERS_PER_KEYWORD, min: MIN_CHARACTERS_PER_KEYWORD})); } } } function validateRegexPatternsOrThrow(a0) { // fn#122520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:823, offset: 0x0256ae7d, size: 142 bytes, params: 2, frame: 17 var Error; var intl; const length = a0.length; var value; if (length > MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER) { Error = global.Error; intl = (require(1244) /* metro dependency 1244: indexNative */).intl; value = intl.formatToPlainString((require(1244) /* metro dependency 1244: indexNative */).t.tDjhF1, {limit: MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER}); throw new Error(); } a0.forEach(_fun122521); function _fun122521(a0) { // fn#122521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:967, offset: 0x0256af0b, size: 159 bytes, params: 2, frame: 18 const InvalidRegexPatternError = (AutomodErrorUtilsModule).InvalidRegexPatternError; const intl = (IndexNativeModule).intl; const t = (IndexNativeModule).t; const length = a0.length; const value = environment.__proto__; if (length > MAX_REGEX_PATTERN_LENGTH) { throw new InvalidRegexPatternError(intl.formatToPlainString(t.WR0m9w, {regex: a0, max: MAX_REGEX_PATTERN_LENGTH, min: MIN_REGEX_PATTERN_LENGTH})); } if (a0.length < MIN_REGEX_PATTERN_LENGTH) { throw new InvalidRegexPatternError(intl.formatToPlainString(t.WR0m9w, {regex: a0, max: MAX_REGEX_PATTERN_LENGTH, min: MIN_REGEX_PATTERN_LENGTH})); } } } function isBackendPersistedRule(a0) { // fn#122522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1118, offset: 0x0256afaa, size: 71 bytes, params: 2, frame: 14 const value = undefined; return ApplicationCommandUtilsModule.isSnowflake((a0 == null ? value : a0.id) ?? 'INVALID_SNOWFLAKE'); } function isRuleKeywordFilter(a0) { // fn#122524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:488, offset: 0x0256b018, size: 39 bytes, params: 2, frame: 3 const triggerType = a0?.triggerType; const KEYWORD = AutomodTriggerType.KEYWORD; return triggerType === KEYWORD; } function isRuleMLSpamFilter(a0) { // fn#122525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1428, offset: 0x0256b03f, size: 39 bytes, params: 2, frame: 3 const triggerType = a0?.triggerType; const ML_SPAM = AutomodTriggerType.ML_SPAM; return triggerType === ML_SPAM; } function isRuleDefaultKeywordListFilter(a0) { // fn#122526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1507, offset: 0x0256b066, size: 39 bytes, params: 2, frame: 3 const triggerType = a0?.triggerType; const DEFAULT_KEYWORD_LIST = AutomodTriggerType.DEFAULT_KEYWORD_LIST; return triggerType === DEFAULT_KEYWORD_LIST; } function isRuleMentionSpamFilter(a0) { // fn#122527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1592, offset: 0x0256b08d, size: 39 bytes, params: 2, frame: 3 const triggerType = a0?.triggerType; const MENTION_SPAM = AutomodTriggerType.MENTION_SPAM; return triggerType === MENTION_SPAM; } function isRuleServerPolicyFilter(a0) { // fn#122528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1670, offset: 0x0256b0b4, size: 39 bytes, params: 2, frame: 3 const triggerType = a0?.triggerType; const SERVER_POLICY = AutomodTriggerType.SERVER_POLICY; return triggerType === SERVER_POLICY; } function isRuleUserProfileFilter(a0) { // fn#122529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1748, offset: 0x0256b0db, size: 39 bytes, params: 2, frame: 3 const triggerType = a0?.triggerType; const USER_PROFILE = AutomodTriggerType.USER_PROFILE; return triggerType === USER_PROFILE; } function createDefaultRule(a0, a1) { // fn#122530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1819, offset: 0x0256b102, size: 397 bytes, params: 3, frame: 19 var name; var Error; var intl; var value; const property = (AutomodTriggerConfigsModule).triggerConfigs[a1]; const defaultTriggerMetadataForTriggerType = (AutomodTriggerConfigsModule).getDefaultTriggerMetadataForTriggerType(a1, a0); const object = {}; object.id = getNewAutomodRuleMockId(a0, a1); object.name = property.getDefaultRuleName(); object.guildId = a0; object.eventType = property.eventType; object.triggerType = a1; object.triggerMetadata = defaultTriggerMetadataForTriggerType; object.enabled = true; object.creatorId = AuthenticationStore.getId(); object.actions = (require(15886) /* metro dependency 15886: AutomodActionUtils */).getRuleDefaultActionsFromConfig(property); object.position = 0; let Set = global.Set; const value3 = Object.create(Set.prototype, {constructor: {value: Set}}); let set = new Set(); object.exemptChannels = set instanceof Object ? set : value3; Set = global.Set; const value5 = Object.create(Set.prototype, {constructor: {value: Set}}); set = new Set(); object.exemptRoles = set instanceof Object ? set : value5; if (isBackendPersistedRule(object)) { Error = global.Error; intl = (require(1244) /* metro dependency 1244: indexNative */).intl; value = intl.string((require(1244) /* metro dependency 1244: indexNative */).t['A/nX8D']); throw new Error(); } value = getRuleCountByTriggerType(a0, a1); if (value > 0) { name = object.name; value += 1; object.name = name + (' ' + value); } return object; } function validateRuleBeforeSaveOrThrow(a0) { // fn#122531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:2479, offset: 0x0256b28f, size: 301 bytes, params: 2, frame: 17 var r6; var r3; var triggerMetadata; var length; var Error; const intl = (IndexNativeModule).intl; const t = (IndexNativeModule).t; var value; if (isRuleKeywordFilter(a0)) { triggerMetadata = a0.triggerMetadata; r6 = triggerMetadata.keywordFilter ?? []; triggerMetadata = a0.triggerMetadata; r3 = triggerMetadata.regexPatterns ?? []; length = r6.length; if (length !== 0) { validateKeywordsOrThrow(r6, MAX_KEYWORDS_PER_KEYWORD_FILTER); validateRegexPatternsOrThrow(r3); if (a0.actions.length === 0) { Error = global.Error; value = intl.string(t['t+gj5V']); throw new Error(); } return undefined; } length = r3.length; if (length === 0) { Error = global.Error; value = intl.string(t.kz2Av3); throw new Error(); } validateKeywordsOrThrow(r6, MAX_KEYWORDS_PER_KEYWORD_FILTER); validateRegexPatternsOrThrow(r3); length = a0.actions.length; if (length === 0) { Error = global.Error; value = intl.string(t['t+gj5V']); throw new Error(); } } else if (a0.actions.length === 0) { Error = global.Error; value = intl.string(t['t+gj5V']); throw new Error(); } } function eventTypeToName(a0) { // fn#122532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:2949, offset: 0x0256b3bc, size: 218 bytes, params: 2, frame: 15 const intl = (IndexNativeModule).intl; const t = (IndexNativeModule).t; const MESSAGE_SEND = AutomodEventType.MESSAGE_SEND; if (MESSAGE_SEND === a0) { return intl.string(t.NlQW4P); } const GUILD_MEMBER_JOIN_OR_UPDATE = AutomodEventType.GUILD_MEMBER_JOIN_OR_UPDATE; if (GUILD_MEMBER_JOIN_OR_UPDATE === a0) { return intl.string(t['Q+68IX']); } const string = intl.string; const SP9BBx = t.SP9BBx; return Reflect.apply(string, intl, [SP9BBx]); } function actionTypeToName(a0) { // fn#122533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:3209, offset: 0x0256b496, size: 374 bytes, params: 2, frame: 15 const intl = (IndexNativeModule).intl; const t = (IndexNativeModule).t; const BLOCK_MESSAGE = AutomodActionType.BLOCK_MESSAGE; if (BLOCK_MESSAGE === a0) { return intl.string(t.d1ab8n); } const FLAG_TO_CHANNEL = AutomodActionType.FLAG_TO_CHANNEL; if (FLAG_TO_CHANNEL === a0) { return intl.string(t['Y+VmvU']); } const USER_COMMUNICATION_DISABLED = AutomodActionType.USER_COMMUNICATION_DISABLED; if (USER_COMMUNICATION_DISABLED === a0) { return intl.string(t['6WPxY2']); } const QUARANTINE_USER = AutomodActionType.QUARANTINE_USER; if (QUARANTINE_USER === a0) { return intl.string(t.NPO8ee); } const string = intl.string; const SP9BBx = t.SP9BBx; return Reflect.apply(string, intl, [SP9BBx]); } function triggerTypeToName(a0) { // fn#122534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:3611, offset: 0x0256b60c, size: 442 bytes, params: 2, frame: 15 const intl = (IndexNativeModule).intl; const t = (IndexNativeModule).t; const KEYWORD = AutomodTriggerType.KEYWORD; if (KEYWORD === a0) { return intl.string(t.ffR2cM); } const ML_SPAM = AutomodTriggerType.ML_SPAM; if (ML_SPAM === a0) { return intl.string(t['puF/Os']); } const DEFAULT_KEYWORD_LIST = AutomodTriggerType.DEFAULT_KEYWORD_LIST; if (DEFAULT_KEYWORD_LIST === a0) { return intl.string(t.LnGhZv); } const MENTION_SPAM = AutomodTriggerType.MENTION_SPAM; if (MENTION_SPAM === a0) { return intl.string(t.pX7i6n); } const USER_PROFILE = AutomodTriggerType.USER_PROFILE; if (USER_PROFILE === a0) { return intl.string(t.q1L2v8); } const string = intl.string; const SP9BBx = t.SP9BBx; return Reflect.apply(string, intl, [SP9BBx]); } } global.__d(_fun122517, 15882, [1226, 15883, 11454, 15885, 15886, 1244, 7246, 5065, 2]) /* metro module 15882, dependencies: [1226, 15883, 11454, 15885, 15886, 1244, 7246, 5065, 2] */;