/* Metro module 6860; source: modules/threads/ThreadHooks.tsx; dependencies: [57, 4249, 1383, 1226, 1379, 3784, 5071, 661, 566, 483, 5216, 21, 22, 6861, 6862, 5072, 2] */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import PermissionStore from '../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */ import CreateExperiment from '../experiments/createExperiment.tsx'; /* Metro dependency 4249 */ import ActiveJoinedThreadsStore from './ActiveJoinedThreadsStore.tsx'; /* Metro dependency 5071 */ import UseIsRemote from '../game_console/hooks/useIsRemote.tsx'; /* Metro dependency 6861 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as BigFlagUtilsModule from '../../external/discord_common/js/shared/utils/BigFlagUtils.tsx'; /* Metro dependency 483 */ import * as FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as ChannelRecordModule from '../../records/ChannelRecord.tsx'; /* Metro dependency 1383 */ import * as GameInvitesChannelUtilsModule from '../game_invite_channels/GameInvitesChannelUtils.tsx'; /* Metro dependency 6862 */ function _fun54107(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#54107, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:6, offset: 0x0135ce52, size: 592 bytes, params: 8, frame: 25 let env0_0 = require; const useCanStartPublicThread2 = useCanStartPublicThread; const useCanStartPrivateThread2 = useCanStartPrivateThread; const _canUnarchiveThread = function(a0, a1, a2) { var r0; var value = a1; var value2 = a2; r0 = a0 == null || !a0.isThread(); r0 = !r0 ? a0.isMediaThread() : r0; r0 = !r0 && (a0.threadMetadata == null ? value : a0.threadMetadata.locked ? value2 : value); return r0; }; const useIsActiveChannelOrUnarchivableThread2 = useIsActiveChannelOrUnarchivableThread; const closure4 = function(a0) { var env0_0 = a0; return require(dependencyMap[8]).useStateFromStores([PermissionStore], _fun54118); }; const isThreadModerator2 = isThreadModerator; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); let value = CreateExperiment; value = value({'id': '2022-07_voice_in_threads', 'label': 'Voice in Threads', 'kind': 'guild', defaultConfig: {enabled: false}, treatments: [{'id': 1, 'label': 'On', config: {enabled: true}}]}); (FileImportTrackerModule).fileFinishedImporting('modules/threads/ThreadHooks.tsx'); exports.VoiceInThreadsExperiment = value; exports.useCanStartPublicThread = useCanStartPublicThread2; exports.computeCanStartPublicThread = function(a0, a1) { var r2; var value = a0.isForumLikeChannel(); if (value) { r2 = Permissions.SEND_MESSAGES; } else { value = importAll(dependencyMap[9]); value = value.combine(Permissions.CREATE_PUBLIC_THREADS, Permissions.READ_MESSAGE_HISTORY); r2 = value; } return canStartThread(PermissionStore.can(r2, a0), a0, a1); }; exports.useCanStartPrivateThread = useCanStartPrivateThread2; exports.computeCanStartPrivateThread = computeCanStartPrivateThread; exports.useCanStartThread = useCanStartThread; exports.useCanViewThreadForMessage = useCanViewThreadForMessage; exports.useHasActiveThreads = function(a0) { var env0_0 = a0; return require(dependencyMap[8]).useStateFromStoresObject([ActiveJoinedThreadsStore, PermissionStore], _fun54127); }; exports.useCanManageThread = useCanManageThread; exports.useCanUnarchiveThread = function(a0) { var env0_0 = a0; return _canUnarchiveThread(a0, require(dependencyMap[8]).useStateFromStores([PermissionStore], _fun54136), useIsThreadModerator(a0)); }; exports.canUnarchiveThread = function(a0) { return _canUnarchiveThread(a0, hasSendPermission(a0, PermissionStore), isThreadModerator(a0)); }; exports.useIsActiveChannelOrUnarchivableThread = useIsActiveChannelOrUnarchivableThread2; exports.getIsActiveChannelOrUnarchivableThread = getIsActiveChannelOrUnarchivableThread; exports.computeIsReadOnlyThread = computeIsReadOnlyThread; exports.useIsThreadModerator = closure4; exports.isThreadModerator = isThreadModerator2; exports.useCanRemoveThreadMember = function(a0) { var env0_0 = a0; return require(dependencyMap[8]).useStateFromStores([ChannelStore, PermissionStore, AuthenticationStore], _fun54141); }; exports.useCanJoinThreadVoice = useCanJoinThreadVoice; exports.useIsNonModInLockedThread = useIsNonModInLockedThread; exports.isNonModInLockedThread = isNonModInLockedThread; function useCanStartPublicThread(a0, a1) { // fn#54108, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:402, offset: 0x0135d0a2, size: 87 bytes, params: 3, frame: 19 const env0_0 = a0; const canStartThreadBinding = canStartThread; const useStateFromStores = FluxModule.useStateFromStores; return canStartThreadBinding(Reflect.apply(useStateFromStores, FluxModule, [[PermissionStore], _fun54109, [a0]]), a0, a1); function _fun54109() { // fn#54109, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:494, offset: 0x0135d0f9, size: 111 bytes, params: 1, frame: 15 var r3; var moduleValue; if (env0_0.isForumLikeChannel()) { r3 = Permissions.SEND_MESSAGES; } else { moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */; r3 = moduleValue.combine(Permissions.CREATE_PUBLIC_THREADS, Permissions.READ_MESSAGE_HISTORY); } return PermissionStore.can(r3, env0_0); } } function useCanStartPrivateThread(a0) { // fn#54110, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:638, offset: 0x0135d168, size: 105 bytes, params: 2, frame: 19 const env0_0 = a0; const value2 = (FluxModule).useStateFromStores([PermissionStore], _fun54111, [a0]); const type = a0.type; const GUILD_TEXT = ChannelTypes.GUILD_TEXT; return type === GUILD_TEXT && canStartThread(value2, a0); function _fun54111() { // fn#54111, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:713, offset: 0x0135d1d1, size: 71 bytes, params: 1, frame: 15 const value = environment.__proto__; const permissionStoreBinding = PermissionStore; const can = permissionStoreBinding.can; const combine = BigFlagUtilsModule.combine; const CREATE_PRIVATE_THREADS = Permissions.CREATE_PRIVATE_THREADS; return Reflect.apply(can, permissionStoreBinding, [Reflect.apply(combine, BigFlagUtilsModule, [CREATE_PRIVATE_THREADS]), env0_0]); } } function canStartThread(a0, a1, a2) { // fn#54112, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:824, offset: 0x0135d218, size: 117 bytes, params: 4, frame: 13 if (a0) { if (THREADED_CHANNEL_TYPES.has(a1.type)) { if (a2 == null) { return true; } if (a2.hasFlag(MessageFlags.HAS_THREAD)) { return false; } if ((importDefault(5216) /* metro dependency 5216: isSystemMessage */)(a2)) { return false; } return true; } } return false; } function hasSendPermission(a0, a1) { // fn#54113, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:978, offset: 0x0135d28d, size: 42 bytes, params: 3, frame: 14 return a0 != null && a1.can(Permissions.SEND_MESSAGES_IN_THREADS, a0); } function useIsActiveChannelOrUnarchivableThread(a0) { // fn#54115, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:1199, offset: 0x0135d30a, size: 154 bytes, params: 2, frame: 17 var r1; var r2; var r0; var isThread2; const env0_0 = a0; const value2 = undefined; const value = (FluxModule).useStateFromStores([PermissionStore], _fun54116); const value3 = a0 != null; if (value3) { isThread2 = a0.isThread(); r1 = isThread2 ? a0.isActiveThread() : !isThread2; if (!r1) { r2 = a0.isArchivedThread() && (a0.threadMetadata == null ? value2 : a0.threadMetadata.locked) !== true; r2 = r2 && value; r1 = r2; } r0 = r1; } else { r0 = value3; } return r0; function _fun54116() { // fn#54116, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:1290, offset: 0x0135d3a4, size: 51 bytes, params: 1, frame: 14 return env0_0 != null && PermissionStore.can(Permissions.SEND_MESSAGES_IN_THREADS, env0_0); } } function useIsThreadModerator(a0) { // fn#54117, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:1469, offset: 0x0135d3d7, size: 64 bytes, params: 2, frame: 14 const env0_0 = a0; return (FluxModule).useStateFromStores([PermissionStore], _fun54118); function _fun54118() { // fn#54118, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:1541, offset: 0x0135d417, size: 36 bytes, params: 1, frame: 13 return isThreadModerator(env0_0, [PermissionStore]); } } function isThreadModerator(a0) { // fn#54119, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:1572, offset: 0x0135d43b, size: 85 bytes, params: 2, frame: 15 const value = a1; const property = Module00057(value !== undefined ? value : [PermissionStore], 1)[0]; return a0 != null && property.can(Permissions.MANAGE_THREADS, a0); } function computeCanStartPrivateThread(a0, a1) { // fn#54121, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2160, offset: 0x0135d507, size: 50 bytes, params: 3, frame: 15 const canStartThreadBinding = canStartThread; const permissionStoreBinding = PermissionStore; const can = permissionStoreBinding.can; const CREATE_PRIVATE_THREADS = Permissions.CREATE_PRIVATE_THREADS; return canStartThreadBinding(Reflect.apply(can, permissionStoreBinding, [CREATE_PRIVATE_THREADS, a0]), a0, a1); } function useCanStartThread(a0) { // fn#54122, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2285, offset: 0x0135d539, size: 34 bytes, params: 2, frame: 12 return useCanStartPublicThread(a0) || useCanStartPrivateThread(a0); } function useCanViewThreadForMessage(a0) { // fn#54123, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2420, offset: 0x0135d55b, size: 171 bytes, params: 2, frame: 22 const env0_0 = a0; const value2 = (FluxModule).useStateFromStores([ChannelStore], _fun54124, [a0]); const value3 = (FluxModule).useStateFromStores([PermissionStore], _fun54125, [value2]); const hasFlag = a0.hasFlag; const HAS_THREAD = MessageFlags.HAS_THREAD; const value = Reflect.apply(hasFlag, a0, [HAS_THREAD]); return value ? value2 != null && !!value3 : !!value; function _fun54124() { // fn#54124, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2497, offset: 0x0135d606, size: 64 bytes, params: 1, frame: 13 let value = environment.__proto__; const channelStoreBinding = ChannelStore; const getChannel = channelStoreBinding.getChannel; value = importDefault(21) /* metro dependency 21: SnowflakeUtils */; return Reflect.apply(getChannel, channelStoreBinding, [value.castMessageIdAsChannelId(env0_0.id)]); } function _fun54125() { // fn#54125, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2679, offset: 0x0135d646, size: 38 bytes, params: 1, frame: 13 const permissionStoreBinding = PermissionStore; const can = permissionStoreBinding.can; const VIEW_CHANNEL = Permissions.VIEW_CHANNEL; return Reflect.apply(can, permissionStoreBinding, [VIEW_CHANNEL, env0_1]); } } function useHasActiveThreads(a0) { // fn#54126, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2741, offset: 0x0135d66c, size: 73 bytes, params: 2, frame: 15 const env0_0 = a0; return (FluxModule).useStateFromStoresObject([ActiveJoinedThreadsStore, PermissionStore], _fun54127); function _fun54127() { // fn#54127, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:2820, offset: 0x0135d6b5, size: 225 bytes, params: 1, frame: 19 var environment; let value = environment.__proto__; const activeJoinedThreadsStoreBinding = ActiveJoinedThreadsStore; const getActiveJoinedThreadsForParent = activeJoinedThreadsStoreBinding.getActiveJoinedThreadsForParent; const binding = env0_0; const value3 = Reflect.apply(getActiveJoinedThreadsForParent, activeJoinedThreadsStoreBinding, [binding.guild_id, binding.id]); const activeJoinedRelevantThreadsForParent = activeJoinedThreadsStoreBinding.getActiveJoinedRelevantThreadsForParent(binding.guild_id, binding.id); const activeUnjoinedThreadsForParent = activeJoinedThreadsStoreBinding.getActiveUnjoinedThreadsForParent(binding.guild_id, binding.id); value = (importDefault(22) /* metro dependency 22 */)(activeJoinedRelevantThreadsForParent); value = value.some(function(a0) { var permissionStoreBinding = PermissionStore; var VIEW_CHANNEL = Permissions.VIEW_CHANNEL; return permissionStoreBinding.can(VIEW_CHANNEL, a0.channel); }); const value7 = (importDefault(22) /* metro dependency 22 */)(value3).some(_fun54129); const value9 = (importDefault(22) /* metro dependency 22 */)(activeUnjoinedThreadsForParent).some(function(a0) { return PermissionStore.can(Permissions.VIEW_CHANNEL, a0); }); let r3 = value || value7; r3 = !r3 ? value9 : r3; return {hasActiveThreads: r3, hasMoreActiveThreads: value9 || value7}; function _fun54129(a0) { // fn#54129, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:3075, offset: 0x0135d7bd, size: 66 bytes, params: 2, frame: 14 var r0; var permissionStoreBinding; const id = a0.channel.id; var value; if (value) { r0 = !(id in env0_0); } else { value = environment.__proto__.__proto__; permissionStoreBinding = PermissionStore; value = permissionStoreBinding.can(Permissions.VIEW_CHANNEL, a0.channel); r0 = value; } return r0; } } } function useCanManageThread(a0) { // fn#54131, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:3267, offset: 0x0135d821, size: 230 bytes, params: 2, frame: 23 const env0_0 = a0; var isThread; const channel = (require(566) /* metro dependency 566: flux */).useStateFromStores([ChannelStore], _fun54132); const value2 = (require(566) /* metro dependency 566: flux */).useStateFromStores([PermissionStore], _fun54133, [channel]); const id = (require(566) /* metro dependency 566: flux */).useStateFromStores([AuthenticationStore], function() { return AuthenticationStore.getId(); }); let r0 = a0 != null && channel != null; if (r0) { isThread = a0.isThread(); r0 = isThread ? value2 ? !!value2 : !a0.isLockedThread() && a0.ownerId === id : !!isThread; } return r0; function _fun54132() { // fn#54132, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:3336, offset: 0x0135d907, size: 47 bytes, params: 1, frame: 13 return ChannelStore.getChannel(env0_0?.parent_id); } function _fun54133() { // fn#54133, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:3417, offset: 0x0135d936, size: 51 bytes, params: 1, frame: 14 return channel != null && PermissionStore.can(Permissions.MANAGE_THREADS, channel); } } function useCanUnarchiveThread(a0) { // fn#54135, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:3622, offset: 0x0135d97c, size: 84 bytes, params: 2, frame: 18 const env0_0 = a0; const useStateFromStores = FluxModule.useStateFromStores; return _canUnarchiveThread(a0, Reflect.apply(useStateFromStores, FluxModule, [[PermissionStore], _fun54136]), useIsThreadModerator(a0)); function _fun54136() { // fn#54136, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:3694, offset: 0x0135d9d0, size: 28 bytes, params: 1, frame: 13 return hasSendPermission(env0_0, PermissionStore); } } function getIsActiveChannelOrUnarchivableThread(a0) { // fn#54138, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:4032, offset: 0x0135da18, size: 121 bytes, params: 2, frame: 16 var r1; var r2; var r0; var threadMetadata; let value = a0 != null; if (value) { value = a0.isThread(); r1 = value ? a0.isActiveThread() : !value; if (!r1) { value = a0.isArchivedThread(); if (value) { threadMetadata = a0.threadMetadata; value = undefined; value = (threadMetadata == null ? value : threadMetadata.locked) !== true; r2 = value; } else { r2 = value; } r2 = r2 && PermissionStore.can(Permissions.SEND_MESSAGES_IN_THREADS, a0); r1 = r2; } r0 = r1; } else { r0 = value; } return r0; } function computeIsReadOnlyThread(a0) { // fn#54139, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:4278, offset: 0x0135da91, size: 67 bytes, params: 2, frame: 13 if (a0.isMediaThread()) { return true; } const permissionStoreBinding = PermissionStore; const can = permissionStoreBinding.can; const MANAGE_THREADS = Permissions.MANAGE_THREADS; return a0.isArchivedLockedThread() && !Reflect.apply(can, permissionStoreBinding, [MANAGE_THREADS, a0]); } function useCanRemoveThreadMember(a0) { // fn#54140, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:4524, offset: 0x0135dad4, size: 80 bytes, params: 2, frame: 15 const env0_0 = a0; return (FluxModule).useStateFromStores([ChannelStore, PermissionStore, AuthenticationStore], _fun54141); function _fun54141() { // fn#54141, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:4604, offset: 0x0135db24, size: 109 bytes, params: 1, frame: 14 const value = environment.__proto__; const channel = ChannelStore.getChannel(env0_0); if (channel == null) { return false; } const id = AuthenticationStore.getId(); const type = channel.type; const PRIVATE_THREAD = ChannelTypes.PRIVATE_THREAD; let r0 = type === PRIVATE_THREAD && channel.ownerId === id; r0 = !r0 ? isThreadModerator(channel, [PermissionStore]) : r0; return r0; } } function useCanJoinThreadVoice(a0) { // fn#54142, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:4769, offset: 0x0135db91, size: 271 bytes, params: 2, frame: 22 var r1; const env0_0 = a0; var value; const value2 = (UseIsRemote)(); const value3 = (FluxModule).useStateFromStores([PermissionStore], _fun54143); const value4 = useIsActiveChannelOrUnarchivableThread(a0); const binding = env0_13; const useExperiment = binding.useExperiment; const enabled = Reflect.apply(useExperiment, binding, [{guildId: a0.guild_id, location: 'e791ea_1'}, {autoTrackExposure: false}]).enabled; const value5 = (GameInvitesChannelUtilsModule).useIsGameInvitesPost(a0); const value6 = (require(5072) /* metro dependency 5072: AgeGateUtils */).useShouldAgeVerifyForAgeGate(); if (value6) { value = require(5072) /* metro dependency 5072: AgeGateUtils */; value = value.shouldShowAgeGateForChannelId(a0.id); r1 = value; } else { r1 = value6; } let r0 = !value2 && a0.isVocalThread() && (enabled || value5); r0 = r0 && value3 && value4 && !r1; return r0; function _fun54143() { // fn#54143, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:4854, offset: 0x0135dca0, size: 38 bytes, params: 1, frame: 13 const permissionStoreBinding = PermissionStore; const can = permissionStoreBinding.can; const CONNECT = Permissions.CONNECT; return Reflect.apply(can, permissionStoreBinding, [CONNECT, env0_0]); } } function useIsNonModInLockedThread(a0) { // fn#54144, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:5212, offset: 0x0135dcc6, size: 35 bytes, params: 2, frame: 11 return a0.isLockedThread() && !useIsThreadModerator(a0); } function isNonModInLockedThread(a0) { // fn#54145, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7038:5336, offset: 0x0135dce9, size: 35 bytes, params: 2, frame: 11 return a0.isLockedThread() && !isThreadModerator(a0); } } global.__d(_fun54107, 6860, [57, 4249, 1383, 1226, 1379, 3784, 5071, 661, 566, 483, 5216, 21, 22, 6861, 6862, 5072, 2]) /* metro module 6860, dependencies: [57, 4249, 1383, 1226, 1379, 3784, 5071, 661, 566, 483, 5216, 21, 22, 6861, 6862, 5072, 2] */;