/* Metro module 9077; source: modules/permissions/useManageResourcePermissions.tsx; dependencies: [57, 31, 3784, 1878, 9076, 482, 483, 1418, 566, 2] */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import PermissionStore from '../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as ConstantsModule from '../../external/discord_common/js/shared/Constants.tsx'; /* Metro dependency 482 */ 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 GuildRecordUtilsModule from '../../utils/GuildRecordUtils.tsx'; /* Metro dependency 1418 */ import * as PermissionsConstantsModule from '../guild_scheduled_events/PermissionsConstants.tsx'; /* Metro dependency 9076 */ function _fun70925(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#70925, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:6, offset: 0x01d0d4a6, size: 316 bytes, params: 8, frame: 20 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); object = {'canCreateExpressions': false, 'canCreateGuildEvent': false, 'canManageAllExpressions': false, 'canManageAllEvents': false}; object.canManageGuildExpression = function() { return false; }; object.canManageGuildEvent = function() { return false; }; const attachChannelPermissions2 = attachChannelPermissions; (FileImportTrackerModule).fileFinishedImporting('modules/permissions/useManageResourcePermissions.tsx'); exports.attachChannelPermissions = attachChannelPermissions2; exports.useManageResourcePermissions = useManageResourcePermissions; exports.getManageResourcePermissions = getManageResourcePermissions; function attachChannelPermissions(a0) { // fn#70929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:706, offset: 0x01d0d699, size: 173 bytes, params: 2, frame: 18 if (a0 == null) { return [Permissions.CREATE_EVENTS, Permissions.MANAGE_EVENTS]; } const r4 = a0.isGuildStageVoice() ? CREATE_GUILD_EVENT_STAGE_CHANNEL_PERMISSIONS : a0.isGuildVoice() ? CREATE_GUILD_EVENT_VOICE_CHANNEL_PERMISSIONS : CREATE_GUILD_EVENT_CORE_PERMISSIONS; let combine = BigFlagUtilsModule.combine; const CREATE_EVENTS = Permissions.CREATE_EVENTS; const items2 = [Reflect.apply(combine, BigFlagUtilsModule, [r4, CREATE_EVENTS])]; combine = BigFlagUtilsModule.combine; const MANAGE_EVENTS = Permissions.MANAGE_EVENTS; items2[1] = Reflect.apply(combine, BigFlagUtilsModule, [r4, MANAGE_EVENTS]); return items2; } function useManageResourcePermissions(a0) { // fn#70930, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:1068, offset: 0x01d0d746, size: 380 bytes, params: 2, frame: 24 const env0_0 = a0; const r2 = GuildRecordUtilsModule.isGuildRecord(a0) ? [Permissions.CREATE_EVENTS, Permissions.MANAGE_EVENTS] : attachChannelPermissions(a0); let binding = Module00057; const value3 = binding(r2, 2); const env0_1 = value3[0]; const env0_2 = value3[1]; const useStateFromStoresArray = FluxModule.useStateFromStoresArray; const value5 = binding(Reflect.apply(useStateFromStoresArray, FluxModule, [[PermissionStore], _fun70931]), 4); const property = value5[0]; const property2 = value5[1]; const property22 = property2; const property3 = value5[2]; const property4 = value5[3]; const currentUser = FluxModule.useStateFromStores([UserStore], function() { return UserStore.getCurrentUser(); }); binding = property22; let useCallback = binding.useCallback; const value6 = Reflect.apply(useCallback, binding, [_fun70933, [property, property2, currentUser]]); useCallback = binding.useCallback; return a0 == null ? env0_11 : {canCreateExpressions: property, canCreateGuildEvent: property3, canManageAllExpressions: property2, canManageAllEvents: property4, canManageGuildExpression: value6, canManageGuildEvent: Reflect.apply(useCallback, binding, [_fun70934, [property4, property3, currentUser]])}; function _fun70931() { // fn#70931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:1227, offset: 0x01d0d8c2, size: 108 bytes, params: 1, frame: 15 const permissionStoreBinding = PermissionStore; let can = permissionStoreBinding.can; const CREATE_GUILD_EXPRESSIONS = Permissions.CREATE_GUILD_EXPRESSIONS; const binding = env0_0; const items2 = [Reflect.apply(can, permissionStoreBinding, [CREATE_GUILD_EXPRESSIONS, binding])]; can = permissionStoreBinding.can; const MANAGE_GUILD_EXPRESSIONS = Permissions.MANAGE_GUILD_EXPRESSIONS; items2[1] = Reflect.apply(can, permissionStoreBinding, [MANAGE_GUILD_EXPRESSIONS, binding]); items2[2] = permissionStoreBinding.can(env0_1, binding); items2[3] = permissionStoreBinding.can(env0_2, binding); return items2; } function _fun70933(a0) { // fn#70933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:1442, offset: 0x01d0d92e, size: 33 bytes, params: 2, frame: 17 return canManageResource(a0, currentUser, ReactModule, Module00057); } function _fun70934(a0) { // fn#70934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:1499, offset: 0x01d0d94f, size: 33 bytes, params: 2, frame: 17 return canManageResource(a0, currentUser, env0_6, env0_5); } } function getManageResourcePermissions(a0) { // fn#70935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:1731, offset: 0x01d0d970, size: 313 bytes, params: 2, frame: 19 const value = a1; const value2 = a2; const r9 = value !== undefined ? value : PermissionStore; const r8 = value2 !== undefined ? value2 : UserStore; const env0_3 = undefined; const value4 = env0_3(GuildRecordUtilsModule.isGuildRecord(a0) ? [Permissions.CREATE_EVENTS, Permissions.MANAGE_EVENTS] : attachChannelPermissions(a0), 2); const property = value4[0]; const property2 = value4[1]; let can = r9.can; const CREATE_GUILD_EXPRESSIONS = Permissions.CREATE_GUILD_EXPRESSIONS; const value5 = Reflect.apply(can, r9, [CREATE_GUILD_EXPRESSIONS, a0]); can = r9.can; const MANAGE_GUILD_EXPRESSIONS = Permissions.MANAGE_GUILD_EXPRESSIONS; const value6 = Reflect.apply(can, r9, [MANAGE_GUILD_EXPRESSIONS, a0]); const value7 = r9.can(property, a0); const value8 = r9.can(property2, a0); const env0_4 = r8.getCurrentUser(); return a0 == null ? env0_11 : {canCreateExpressions: value5, canCreateGuildEvent: value7, canManageAllExpressions: value6, canManageAllEvents: value8, canManageGuildExpression: canManageGuildExpression_70936, canManageGuildEvent: canManageGuildEvent_70937}; function getManageResourcePermissionsCanManageGuildExpression(a0) { // fn#70936, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:2119, owner: getManageResourcePermissions.canManageGuildExpression, offset: 0x01d0daa9, size: 33 bytes, params: 2, frame: 17 return canManageResource(a0, env0_4, env0_1, env0_0); } function getManageResourcePermissionsCanManageGuildEvent(a0) { // fn#70937, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:2169, owner: getManageResourcePermissions.canManageGuildEvent, offset: 0x01d0daca, size: 33 bytes, params: 2, frame: 17 return canManageResource(a0, env0_4, env0_3, env0_2); } } } function canManageResource(a0, a1, a2, a3) { // fn#70928, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9262:483, offset: 0x01d0d5e2, size: 183 bytes, params: 5, frame: 11 var r7; var r2; var r3; var r1; var r0; var value4; var user; let value = a3; const value2 = a0 != null; if (value2) { if (a2) { r1 = !!a2; } else { if ('creator_id' in a0) { r3 = value && a1 != null; r3 = r3 && a0.creator_id === a1.id; r2 = r3; } else if ('userId' in a0) { r7 = value && a1 != null; r7 = r7 && a0.userId === a1.id; r2 = r7; } else { value4 = 'user' in a0; if (value4) { r7 = value && a1 != null; if (r7) { user = a0.user; value = undefined; value = (user == null ? value : user.id) === a1.id; r7 = value; } r2 = r7; } else { r2 = value4; } } r1 = r2; } r0 = r1; } else { r0 = value2; } return r0; } global.__d(_fun70925, 9077, [57, 31, 3784, 1878, 9076, 482, 483, 1418, 566, 2]) /* metro module 9077, dependencies: [57, 31, 3784, 1878, 9076, 482, 483, 1418, 566, 2] */;