Files
discord-decomp/sources/utils/PermissionUtils.tsx
T
2026-07-27 16:20:00 +03:00

979 lines
42 KiB
TypeScript

/* Metro module 3789; source: utils/PermissionUtils.tsx; dependencies: [1937, 3785, 3786, 1383, 1422, 1939, 1226, 1379, 1945, 1938, 1867, 1878, 661, 483, 22, 3790, 3773, 21, 1940, 1909, 2] */
function _fun28801(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#28801, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:6, offset: 0x00f82c5e, size: 1232 bytes, params: 8, frame: 75
const env0_0 = require;
const closure = computePermissions;
const closure2 = applyThreadPermissions;
const closure3 = makeEveryoneOverwrite;
const closure4 = function({permission, user, context, overwrites, roles, excludeGuildPermissions}) {
return importAll(dependencyMap[13]).has(computePermissions({user: user, context: context,
overwrites: overwrites,
roles: roles, checkElevated: true, excludeGuildPermissions: excludeGuildPermissions}), permission);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const impersonateStore = importDefault(1937) /* metro dependency 1937: ImpersonateStore */;
const lurkingStore = importDefault(3785) /* metro dependency 3785: LurkingStore */;
const joinedThreadsStore = importDefault(3786) /* metro dependency 3786: JoinedThreadsStore */;
let value = require(1383) /* metro dependency 1383: ChannelRecord */;
const env0_7 = value.THREAD_CHANNEL_TYPES;
const env0_8 = value.ChannelRecordBase;
value = require(1422) /* metro dependency 1422: GuildRecord */;
const env0_9 = value.getGuildEveryoneRoleId;
const env0_10 = value.isGuildOwner;
const env0_11 = (require(1939) /* metro dependency 1939: GuildRoleRecord */).hasPermission;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */;
const guildMemberStore = importDefault(1945) /* metro dependency 1945: GuildMemberStore */;
const guildRoleStore = importDefault(1938) /* metro dependency 1938: GuildRoleStore */;
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
value = require(661) /* metro dependency 661: Constants */;
const Permissions = value.Permissions;
const env0_19 = value.ElevatedPermissions;
const env0_20 = value.MFALevels;
const env0_21 = value.ChannelTypes;
const env0_22 = value.EMPTY_STRING_SNOWFLAKE_ID;
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = value.deserialize(0);
const bigFlagUtilsModule = importAll(483) /* metro dependency 483: BigFlagUtils */;
let combine = bigFlagUtilsModule.combine;
const value4 = (importDefault(22) /* metro dependency 22 */).values(Permissions);
items = [];
arraySpread(items, value4, 0, undefined);
const value5 = apply(combine, items, bigFlagUtilsModule, undefined);
const value6 = bigFlagUtilsModule;
combine = value6.combine;
const CREATE_INSTANT_INVITE = Permissions.CREATE_INSTANT_INVITE;
let CHANGE_NICKNAME = Permissions.CHANGE_NICKNAME;
let VIEW_CHANNEL = Permissions.VIEW_CHANNEL;
let SEND_MESSAGES = Permissions.SEND_MESSAGES;
let EMBED_LINKS = Permissions.EMBED_LINKS;
let ATTACH_FILES = Permissions.ATTACH_FILES;
let READ_MESSAGE_HISTORY = Permissions.READ_MESSAGE_HISTORY;
const MENTION_EVERYONE = Permissions.MENTION_EVERYONE;
let USE_EXTERNAL_EMOJIS = Permissions.USE_EXTERNAL_EMOJIS;
let USE_EXTERNAL_STICKERS = Permissions.USE_EXTERNAL_STICKERS;
let ADD_REACTIONS = Permissions.ADD_REACTIONS;
const CREATE_PUBLIC_THREADS = Permissions.CREATE_PUBLIC_THREADS;
const CREATE_PRIVATE_THREADS = Permissions.CREATE_PRIVATE_THREADS;
let SEND_MESSAGES_IN_THREADS = Permissions.SEND_MESSAGES_IN_THREADS;
const SEND_POLLS = Permissions.SEND_POLLS;
let CONNECT = Permissions.CONNECT;
let SPEAK = Permissions.SPEAK;
let USE_VAD = Permissions.USE_VAD;
let STREAM = Permissions.STREAM;
let USE_EMBEDDED_ACTIVITIES = Permissions.USE_EMBEDDED_ACTIVITIES;
let USE_SOUNDBOARD = Permissions.USE_SOUNDBOARD;
const REQUEST_TO_SPEAK = Permissions.REQUEST_TO_SPEAK;
const USE_APPLICATION_COMMANDS = Permissions.USE_APPLICATION_COMMANDS;
let CREATE_GUILD_EXPRESSIONS = Permissions.CREATE_GUILD_EXPRESSIONS;
const CREATE_EVENTS = Permissions.CREATE_EVENTS;
let USE_EXTERNAL_APPS = Permissions.USE_EXTERNAL_APPS;
const value7 = Reflect.apply(combine, value6, [CREATE_INSTANT_INVITE, CHANGE_NICKNAME, VIEW_CHANNEL, SEND_MESSAGES,
EMBED_LINKS, ATTACH_FILES, READ_MESSAGE_HISTORY, MENTION_EVERYONE, USE_EXTERNAL_EMOJIS, USE_EXTERNAL_STICKERS,
ADD_REACTIONS, CREATE_PUBLIC_THREADS, CREATE_PRIVATE_THREADS, SEND_MESSAGES_IN_THREADS, SEND_POLLS, CONNECT,
SPEAK, USE_VAD, STREAM, USE_EMBEDDED_ACTIVITIES, USE_SOUNDBOARD, REQUEST_TO_SPEAK, USE_APPLICATION_COMMANDS,
CREATE_GUILD_EXPRESSIONS, CREATE_EVENTS, USE_EXTERNAL_APPS]);
const value8 = bigFlagUtilsModule;
combine = value8.combine;
VIEW_CHANNEL = Permissions.VIEW_CHANNEL;
READ_MESSAGE_HISTORY = Permissions.READ_MESSAGE_HISTORY;
const env0_26 = Reflect.apply(combine, value8, [VIEW_CHANNEL, READ_MESSAGE_HISTORY]);
const value9 = bigFlagUtilsModule;
combine = value9.combine;
VIEW_CHANNEL = Permissions.VIEW_CHANNEL;
SEND_MESSAGES = Permissions.SEND_MESSAGES;
CONNECT = Permissions.CONNECT;
SPEAK = Permissions.SPEAK;
STREAM = Permissions.STREAM;
USE_EMBEDDED_ACTIVITIES = Permissions.USE_EMBEDDED_ACTIVITIES;
USE_EXTERNAL_APPS = Permissions.USE_EXTERNAL_APPS;
USE_EXTERNAL_EMOJIS = Permissions.USE_EXTERNAL_EMOJIS;
const USE_EXTERNAL_SOUNDS = Permissions.USE_EXTERNAL_SOUNDS;
USE_EXTERNAL_STICKERS = Permissions.USE_EXTERNAL_STICKERS;
USE_SOUNDBOARD = Permissions.USE_SOUNDBOARD;
USE_VAD = Permissions.USE_VAD;
SEND_MESSAGES_IN_THREADS = Permissions.SEND_MESSAGES_IN_THREADS;
EMBED_LINKS = Permissions.EMBED_LINKS;
ATTACH_FILES = Permissions.ATTACH_FILES;
ADD_REACTIONS = Permissions.ADD_REACTIONS;
const env0_27 = Reflect.apply(combine, value9, [VIEW_CHANNEL, SEND_MESSAGES, CONNECT, SPEAK, STREAM,
USE_EMBEDDED_ACTIVITIES, USE_EXTERNAL_APPS, USE_EXTERNAL_EMOJIS, USE_EXTERNAL_SOUNDS, USE_EXTERNAL_STICKERS,
USE_SOUNDBOARD, USE_VAD, SEND_MESSAGES_IN_THREADS, EMBED_LINKS, ATTACH_FILES, ADD_REACTIONS]);
const value11 = bigFlagUtilsModule;
combine = value11.combine;
VIEW_CHANNEL = Permissions.VIEW_CHANNEL;
READ_MESSAGE_HISTORY = Permissions.READ_MESSAGE_HISTORY;
const env0_28 = Reflect.apply(combine, value11, [VIEW_CHANNEL, READ_MESSAGE_HISTORY]);
const value12 = bigFlagUtilsModule;
combine = value12.combine;
VIEW_CHANNEL = Permissions.VIEW_CHANNEL;
READ_MESSAGE_HISTORY = Permissions.READ_MESSAGE_HISTORY;
CHANGE_NICKNAME = Permissions.CHANGE_NICKNAME;
const env0_29 = Reflect.apply(combine, value12, [VIEW_CHANNEL, READ_MESSAGE_HISTORY, CHANGE_NICKNAME]);
const value13 = bigFlagUtilsModule;
combine = value13.combine;
const MANAGE_GUILD = Permissions.MANAGE_GUILD;
const MANAGE_ROLES = Permissions.MANAGE_ROLES;
const ADMINISTRATOR = Permissions.ADMINISTRATOR;
const BAN_MEMBERS = Permissions.BAN_MEMBERS;
const MANAGE_NICKNAMES = Permissions.MANAGE_NICKNAMES;
CREATE_GUILD_EXPRESSIONS = Permissions.CREATE_GUILD_EXPRESSIONS;
const MANAGE_GUILD_EXPRESSIONS = Permissions.MANAGE_GUILD_EXPRESSIONS;
const MANAGE_WEBHOOKS = Permissions.MANAGE_WEBHOOKS;
const VIEW_AUDIT_LOG = Permissions.VIEW_AUDIT_LOG;
const VIEW_GUILD_ANALYTICS = Permissions.VIEW_GUILD_ANALYTICS;
const value14 = Reflect.apply(combine, value13, [MANAGE_GUILD, MANAGE_ROLES, ADMINISTRATOR, BAN_MEMBERS,
MANAGE_NICKNAMES, CREATE_GUILD_EXPRESSIONS, MANAGE_GUILD_EXPRESSIONS, MANAGE_WEBHOOKS, VIEW_AUDIT_LOG,
VIEW_GUILD_ANALYTICS]);
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/PermissionUtils.tsx');
exports.NONE = value;
exports.ALL = value5;
exports.DEFAULT = value7;
exports.VIEW_GUILD_SETTINGS = value14;
exports.computePermissionsForRoles = computePermissionsForRoles;
exports.computePermissions = closure;
exports.applyThreadPermissions = closure2;
exports.areChannelsLocked = areChannelsLocked;
exports.getGuildVisualOwnerId = getGuildVisualOwnerId;
exports.isRoleHigher = isRoleHigher;
exports.getHighestRole = getHighestRole;
exports.getHighestHoistedRole = getHighestHoistedRole;
exports.makeEveryoneOverwrite = closure3;
exports.canManageACategory = canManageACategory;
exports.can = closure4;
exports.ALLOW = 'ALLOW';
exports.DENY = 'DENY';
exports.PASSTHROUGH = 'PASSTHROUGH';
exports.canEveryoneRole = canEveryoneRole;
exports.canEveryone = canEveryone;
}
function calculateElevatedPermissions(a0, a1, a2) { // fn#28802, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:1721, offset: 0x00f8312e, size: 154 bytes, params: 4, frame: 17
var r0;
var currentUser;
let value = a0;
const value2 = a3;
let r1 = (!(value2 !== undefined) || value2) && a1.mfaLevel === MFALevels.ELEVATED && a2 === AuthenticationStore.getId();
if (r1) {
currentUser = UserStore.getCurrentUser();
if (currentUser != null && currentUser.mfaEnabled) {
r1 = value;
} else {
value = (importAll(483) /* metro dependency 483: BigFlagUtils */).remove(value, ElevatedPermissions);
r1 = value;
}
r0 = r1;
} else {
r0 = value;
}
return r0;
}
function applyOverwrites(a0, a1, a2, a3) { // fn#28803, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:1901, offset: 0x00f831c8, size: 574 bytes, params: 5, frame: 30
var r13;
var r7;
var r9;
var r11;
var r14;
var r15;
var r10;
var r12;
var r4;
var r2;
var r0;
var moduleValue;
var remove;
var deny;
var moduleValue2;
var add;
var allow;
var binding;
var roles;
var length;
var value3;
var moduleValue3;
var value4;
var moduleValue4;
var value5;
var value6;
var value8;
var moduleValue7;
var value9;
var moduleValue8;
var moduleValue9;
var value11;
let value = a2;
let property = a3[a0];
if (property == null) {
r13 = value;
} else {
moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */;
remove = moduleValue.remove;
deny = property.deny;
value = Reflect.apply(remove, moduleValue, [value, deny]);
moduleValue2 = importAll(483) /* metro dependency 483: BigFlagUtils */;
add = moduleValue2.add;
allow = property.allow;
value = Reflect.apply(add, moduleValue2, [value, allow]);
r13 = value;
}
if (a1 == null) {
r0 = r13;
} else {
binding = env0_23;
roles = a1.roles;
length = roles.length;
value3 = 0;
if (value3 < length) {
r7 = binding;
r9 = binding;
r11 = value3;
while (true) {
roles = a1.roles;
property = a3[roles[r11]];
if (property == null) {
r14 = r7;
r15 = r9;
} else {
moduleValue3 = importAll(483) /* metro dependency 483: BigFlagUtils */;
add = moduleValue3.add;
allow = property.allow;
value4 = Reflect.apply(add, moduleValue3, [r9, allow]);
moduleValue4 = importAll(483) /* metro dependency 483: BigFlagUtils */;
add = moduleValue4.add;
deny = property.deny;
value5 = Reflect.apply(add, moduleValue4, [r7, deny]);
r14 = value5;
r15 = value4;
}
value6 = typeof r11 === 'bigint' ? r11 + 1n : +r11 + 1;
roles = a1.roles;
length = roles.length;
if (value6 < length) {
r7 = r14;
r9 = r15;
r11 = value6;
continue;
}
r10 = r15;
r12 = r14;
break;
}
} else {
r10 = binding;
r12 = binding;
}
value8 = (importAll(483) /* metro dependency 483: BigFlagUtils */).add((importAll(483) /* metro dependency 483: BigFlagUtils */).remove(r13,
r12), r10);
property = a3[a1.userId];
if (property == null) {
r4 = value8;
} else {
moduleValue7 = importAll(483) /* metro dependency 483: BigFlagUtils */;
value9 = moduleValue7.remove(value8, property.deny);
moduleValue8 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r4 = moduleValue8.add(value9, property.allow);
}
moduleValue9 = importAll(483) /* metro dependency 483: BigFlagUtils */;
value11 = moduleValue9.has(r4, Permissions.ADMINISTRATOR);
r2 = (require(3790) /* metro dependency 3790: AutomodPermissionUtils */).hasAutomodQuarantinedProfile(a1) && !value11;
r4 = r2 ? (importAll(483) /* metro dependency 483: BigFlagUtils */).filter(r4, env0_29) : r4;
r2 = (require(3773) /* metro dependency 3773: CommunicationDisabledUtils */).isMemberCommunicationDisabled(a1) && !value11;
r0 = r2 ? (importAll(483) /* metro dependency 483: BigFlagUtils */).filter(r4, env0_28) : r4;
}
return r0;
}
function computePermissionsForMember({userId, member, guild, overwrites, roles, checkElevated, excludeGuildPermissions, lurkerPermissionsMask}) { // fn#28804, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:2474, offset: 0x00f83406, size: 565 bytes, params: 2, frame: 29
var r14;
var r15;
var r10;
var r13;
var r9;
var object2;
var permissions;
var length;
var value2;
var moduleValue;
var add;
var value3;
var value4;
checkElevated = checkElevated === undefined || checkElevated;
excludeGuildPermissions = !(excludeGuildPermissions === undefined) && excludeGuildPermissions;
const r12 = lurkerPermissionsMask !== undefined ? lurkerPermissionsMask : env0_26;
if (excludeGuildPermissions) {
return applyOverwrites(guild.id, member, env0_23, overwrites);
}
if (roles != null) {
object2 = {};
copyDataProperties(object2, GuildRoleStore.getUnsafeMutableRoles(guild.id), undefined);
copyDataProperties(object2, roles, undefined);
r14 = object2;
} else {
r14 = GuildRoleStore.getUnsafeMutableRoles(guild.id);
}
let property = r14[getGuildEveryoneRoleId(guild)];
if (property != null) {
permissions = property.permissions;
r15 = permissions;
} else {
r15 = env0_25;
}
if (member == null) {
r9 = r15;
} else {
roles = member.roles;
length = roles.length;
value2 = 0;
if (value2 < length) {
r10 = r15;
r13 = value2;
while (true) {
roles = member.roles;
property = r14[roles[r13]];
if (property === undefined) {
r15 = r10;
} else {
moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */;
add = moduleValue.add;
permissions = property.permissions;
value3 = Reflect.apply(add, moduleValue, [r10, permissions]);
r15 = value3;
}
value4 = typeof r13 === 'bigint' ? r13 + 1n : +r13 + 1;
roles = member.roles;
length = roles.length;
if (value4 < length) {
r10 = r15;
r13 = value4;
continue;
}
r9 = r15;
break;
}
} else {
r9 = r15;
}
}
const bigFlagUtilsModule = importAll(483) /* metro dependency 483: BigFlagUtils */;
const has = bigFlagUtilsModule.has;
const ADMINISTRATOR = Permissions.ADMINISTRATOR;
r9 = Reflect.apply(has, bigFlagUtilsModule, [r9, ADMINISTRATOR]) ? env0_24 : applyOverwrites(guild.id, member, r9,
overwrites);
const r11 = LurkingStore.isLurking(guild.id) || member != null && member.isPending ? bigFlagUtilsModule.filter(r9,
r12) : r9;
return calculateElevatedPermissions(GuildMemberStore.isCurrentUserGuest(guild.id) ? bigFlagUtilsModule.filter(r11,
env0_27) : r11, guild, userId, checkElevated);
}
function computePermissions({user, context, overwrites, roles, checkElevated, excludeGuildPermissions}) { // fn#28805, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:3140, offset: 0x00f8363b, size: 630 bytes, params: 2, frame: 30
var r14;
var r3;
var r11;
var r4;
var r13;
var r15;
var object2;
var guildId;
var currentUser;
var value9;
var currentUser2;
let value = undefined;
checkElevated = checkElevated === value || checkElevated;
excludeGuildPermissions = !(excludeGuildPermissions === value) && excludeGuildPermissions;
if (user == null) {
value = environment;
return env0_23;
}
const r2 = typeof user === 'string' ? user : user.id;
const binding = env0_26;
if (context instanceof ChannelRecordBase) {
if (context.isScheduledForDeletion()) {
return env0_23;
}
if (THREAD_CHANNEL_TYPES.has(context.type)) {
value9 = ChannelStore.getChannel(context.parent_id);
if (value9 == null) {
return env0_23;
}
if (value9.isScheduledForDeletion()) {
return env0_23;
}
currentUser2 = UserStore.getCurrentUser();
return applyThreadPermissions(context, computePermissions({user: user, context: value9,
overwrites: overwrites,
roles: roles, checkElevated: checkElevated, excludeGuildPermissions: excludeGuildPermissions}),
r2 === (currentUser2 == null ? value : currentUser2.id) && JoinedThreadsStore.hasJoined(context.id),
GuildMemberStore.isCurrentUserGuest(context.guild_id));
}
r3 = context.computeLurkerPermissionsAllowList() ?? binding;
if (overwrites != null) {
object2 = {};
copyDataProperties(object2, context.permissionOverwrites, undefined);
copyDataProperties(object2, overwrites, undefined);
r11 = object2;
} else {
r11 = context.permissionOverwrites;
}
guildId = context.getGuildId();
r4 = guildId != null ? GuildStore.getGuild(guildId) : null;
r13 = r3;
r14 = r11;
r15 = r4;
} else {
r14 = overwrites ?? ({});
r13 = binding;
r15 = context;
}
if (r15 == null) {
r3 = env0_23;
} else {
currentUser = UserStore.getCurrentUser();
r3 = r2 !== (currentUser == null ? value : currentUser.id) ? isGuildOwner(r15,
r2) ? calculateElevatedPermissions(env0_24, r15, r2,
checkElevated) : computePermissionsForMember({userId: r2,
member: GuildMemberStore.getMember(r15.id, r2), guild: r15, overwrites: r14, roles: roles,
checkElevated: checkElevated, excludeGuildPermissions: excludeGuildPermissions,
lurkerPermissionsMask: r13}) : ImpersonateStore.isViewingRoles(r15.id) ? computePermissionsForMember({userId: r2,
member: GuildMemberStore.getMember(r15.id, r2), guild: r15, overwrites: r14, roles: roles,
checkElevated: checkElevated, excludeGuildPermissions: excludeGuildPermissions,
lurkerPermissionsMask: r13}) : isGuildOwner(r15, r2) ? calculateElevatedPermissions(env0_24, r15, r2,
checkElevated) : computePermissionsForMember({userId: r2, member: GuildMemberStore.getMember(r15.id, r2),
guild: r15, overwrites: r14, roles: roles, checkElevated: checkElevated,
excludeGuildPermissions: excludeGuildPermissions, lurkerPermissionsMask: r13});
}
return r3;
}
function applyThreadPermissions(a0, a1, a2, a3) { // fn#28806, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:4218, offset: 0x00f838b1, size: 405 bytes, params: 5, frame: 18
var r3;
var r2;
var r0;
var moduleValue;
var moduleValue2;
var moduleValue3;
var moduleValue4;
var moduleValue5;
var moduleValue6;
var moduleValue7;
const type = a0.type;
const MEDIA_THREAD = ChannelTypes.MEDIA_THREAD;
if (type === MEDIA_THREAD) {
moduleValue7 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r0 = moduleValue7.combine(Permissions.READ_MESSAGE_HISTORY, Permissions.VIEW_CHANNEL);
} else if (a0.type !== ChannelTypes.PRIVATE_THREAD) {
moduleValue2 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue2.has(a1, Permissions.SEND_MESSAGES_IN_THREADS)) {
if (a0.isLockedThread()) {
moduleValue4 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue4.has(a1, Permissions.MANAGE_THREADS)) {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
} else {
moduleValue5 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue5.remove(a1, Permissions.SEND_MESSAGES);
}
} else {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
}
r2 = r3;
} else {
moduleValue3 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r2 = moduleValue3.remove(a1, Permissions.SEND_MESSAGES);
}
r0 = r2;
} else if (a2) {
moduleValue2 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue2.has(a1, Permissions.SEND_MESSAGES_IN_THREADS)) {
if (a0.isLockedThread()) {
moduleValue4 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue4.has(a1, Permissions.MANAGE_THREADS)) {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
} else {
moduleValue5 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue5.remove(a1, Permissions.SEND_MESSAGES);
}
} else {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
}
r2 = r3;
} else {
moduleValue3 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r2 = moduleValue3.remove(a1, Permissions.SEND_MESSAGES);
}
r0 = r2;
} else if (a3) {
moduleValue2 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue2.has(a1, Permissions.SEND_MESSAGES_IN_THREADS)) {
if (a0.isLockedThread()) {
moduleValue4 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue4.has(a1, Permissions.MANAGE_THREADS)) {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
} else {
moduleValue5 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue5.remove(a1, Permissions.SEND_MESSAGES);
}
} else {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
}
r2 = r3;
} else {
moduleValue3 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r2 = moduleValue3.remove(a1, Permissions.SEND_MESSAGES);
}
r0 = r2;
} else {
moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue.has(a1, Permissions.MANAGE_THREADS)) {
moduleValue2 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue2.has(a1, Permissions.SEND_MESSAGES_IN_THREADS)) {
if (a0.isLockedThread()) {
moduleValue4 = importAll(483) /* metro dependency 483: BigFlagUtils */;
if (moduleValue4.has(a1, Permissions.MANAGE_THREADS)) {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
} else {
moduleValue5 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue5.remove(a1, Permissions.SEND_MESSAGES);
}
} else {
moduleValue6 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r3 = moduleValue6.combine(a1, Permissions.SEND_MESSAGES);
}
r2 = r3;
} else {
moduleValue3 = importAll(483) /* metro dependency 483: BigFlagUtils */;
r2 = moduleValue3.remove(a1, Permissions.SEND_MESSAGES);
}
r0 = r2;
} else {
r0 = env0_23;
}
}
return r0;
}
function makeEveryoneOverwrite(a0) { // fn#28807, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:4624, offset: 0x00f83a46, size: 70 bytes, params: 2, frame: 13
const PermissionOverwriteType = (require(1909) /* metro dependency 1909: Server */).PermissionOverwriteType;
const ROLE = PermissionOverwriteType.ROLE;
return {id: a0, type: ROLE, allow: env0_23, deny: env0_23};
}
function computePermissionsForRoles({forceRoles, context, overwrites, roles, checkElevated, excludeGuildPermissions}) { // fn#28809, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:5091, offset: 0x00f83b00, size: 511 bytes, params: 2, frame: 28
var r10;
var r1;
var r13;
var r2;
var r3;
var r12;
var value;
var object2;
var lurkerPermissionsAllowList;
var value2;
var guildId;
var value7;
var applyThreadPermissionsBinding;
checkElevated = checkElevated === undefined || checkElevated;
const binding = env0_26;
if (context instanceof ChannelRecordBase) {
if (context.isScheduledForDeletion()) {
return env0_23;
}
if (THREAD_CHANNEL_TYPES.has(context.type)) {
value7 = ChannelStore.getChannel(context.parent_id);
if (value7 == null) {
r1 = env0_23;
} else {
applyThreadPermissionsBinding = applyThreadPermissions;
value = computePermissionsForRoles({forceRoles: forceRoles, context: value7, overwrites: overwrites,
roles: roles,
checkElevated: checkElevated, excludeGuildPermissions: excludeGuildPermissions});
value = applyThreadPermissionsBinding(context, value, false, false);
r1 = value;
}
return r1;
}
lurkerPermissionsAllowList = context.computeLurkerPermissionsAllowList();
value2 = null;
r1 = value2 == lurkerPermissionsAllowList ? binding : lurkerPermissionsAllowList;
if (value2 != overwrites) {
object2 = {};
copyDataProperties(object2, context.permissionOverwrites, undefined);
copyDataProperties(object2, overwrites, undefined);
r13 = object2;
} else {
r13 = context.permissionOverwrites;
}
guildId = context.getGuildId();
r2 = value2 != guildId ? GuildStore.getGuild(guildId) : value2;
r3 = r1;
r10 = r13;
r12 = r2;
} else {
r10 = overwrites ?? ({});
r3 = binding;
r12 = context;
}
if (r12 == null) {
return env0_23;
}
object2 = {'userId': null, 'nick': '', 'guildId': null, 'guildMemberAvatar': null, 'roles': null,
'colorString': null, 'colorStrings': null, 'hoistRoleId': null, 'premiumSince': null, 'isPending': false};
object2.userId = EMPTY_STRING_SNOWFLAKE_ID;
object2.guildId = r12.id;
object2.roles = (importDefault(21) /* metro dependency 21: SnowflakeUtils */).keys(forceRoles);
const Date = global.Date;
const value5 = Object.create(Date.prototype, {constructor: {value: Date}});
const date = new Date();
object2.joinedAt = (date instanceof Object ? date : value5).toISOString();
object2.communicationDisabledUntil = null;
return computePermissionsForMember({userId: EMPTY_STRING_SNOWFLAKE_ID, member: object2, guild: r12, overwrites: r10,
roles: roles, checkElevated: checkElevated, excludeGuildPermissions: excludeGuildPermissions,
lurkerPermissionsMask: r3});
}
function areChannelsLocked({type, guild_id, permissionOverwrites}, a1) { // fn#28810, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:6216, offset: 0x00f83cff, size: 249 bytes, params: 3, frame: 17
var r0;
if (THREAD_CHANNEL_TYPES.has(type)) {
return true;
}
if (a1 == null) {
return false;
}
if (guild_id == null) {
return false;
}
if (guild_id !== a1.guild_id) {
return false;
}
const object3 = {};
copyDataProperties(object3, permissionOverwrites, undefined);
const object4 = {};
copyDataProperties(object4, a1.permissionOverwrites, undefined);
if (object3[guild_id] == null) {
object3[guild_id] = makeEveryoneOverwrite(guild_id);
}
if (object4[guild_id] == null) {
object4[guild_id] = makeEveryoneOverwrite(guild_id);
}
let Object = global.Object;
const length = Object.keys(object3).length;
Object = global.Object;
let value = length === Object.keys(object4).length;
if (value) {
value = global.Object.keys(object3);
value = !value.some(_fun28811);
r0 = value;
} else {
r0 = value;
}
return r0;
}
function getGuildVisualOwnerId(a0) { // fn#28812, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:6699, offset: 0x00f83e84, size: 97 bytes, params: 2, frame: 16
const value2 = undefined;
const defaultImport = importDefault(22) /* metro dependency 22 */;
const some = defaultImport.some;
const getUnsafeMutableRoles = GuildRoleStore.getUnsafeMutableRoles;
return Reflect.apply(some, defaultImport, [Reflect.apply(getUnsafeMutableRoles, GuildRoleStore, [a0.id]),
_fun28813]) ? value2 : a0.ownerId ?? value2;
}
function isRoleHigher(a0, a1, a2, a3) { // fn#28814, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:6879, offset: 0x00f83f0c, size: 104 bytes, params: 5, frame: 17
var r1;
var r2;
var r0;
value = !(a1 == null || !isGuildOwner(a0, a1));
if (r1) {
value = a2 != null;
if (value) {
value = a3 == null;
if (value) {
r2 = value;
} else {
value = require(1940) /* metro dependency 1940: GuildRoleUtils */;
value = value.doesRoleSortHigher(a2, a3);
r2 = value;
}
r1 = r2;
} else {
r1 = value;
}
r0 = r1;
} else {
r0 = value;
}
return r0;
}
function getHighestRole(a0, a1) { // fn#28815, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:7008, offset: 0x00f83f74, size: 84 bytes, params: 3, frame: 16
const getMember = GuildMemberStore.getMember;
if (Reflect.apply(getMember, GuildMemberStore, [a0.id, a1]) != null) {
return GuildRoleStore.getSortedRoles(a0.id).find(_fun28816);
}
}
function getHighestHoistedRole(a0, a1) { // fn#28817, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:7163, offset: 0x00f83fe9, size: 53 bytes, params: 3, frame: 14
const hoistRoleId = a1.hoistRoleId;
const value = null;
return value == hoistRoleId ? value : GuildRoleStore.getRole(a0.id, a1.hoistRoleId);
}
function canManageACategory(a0, a1, a2) { // fn#28818, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:7329, offset: 0x00f8401e, size: 81 bytes, params: 4, frame: 14
const env0_0 = a0;
const canBinding = can;
const MANAGE_CHANNELS = Permissions.MANAGE_CHANNELS;
const canBinding2 = canBinding({permission: MANAGE_CHANNELS, user: a0, context: a1});
return canBinding2 ? !!canBinding2 : a2.some(_fun28819);
}
function canEveryoneRole(a0, a1) { // fn#28820, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:7606, offset: 0x00f840b7, size: 309 bytes, params: 3, frame: 20
var r5;
var r4;
var r1;
var r3;
var type;
var has;
var permissionOverwrites;
var value3;
var permissions;
var property;
var moduleValue;
let value = a1;
if (value instanceof ChannelRecordBase) {
type = value.type;
if (type === ChannelTypes.PRIVATE_THREAD) {
return false;
}
has = THREAD_CHANNEL_TYPES.has;
type = value.type;
if (Reflect.apply(has, THREAD_CHANNEL_TYPES, [type])) {
value = ChannelStore.getChannel(value.parent_id);
if (value == null) {
return false;
}
r5 = value;
permissionOverwrites = r5.permissionOverwrites;
value = r5.getGuildId();
value3 = null;
if (value3 != value) {
value = GuildStore.getGuild(value);
r4 = value;
} else {
r4 = value3;
}
r1 = r4;
r3 = permissionOverwrites;
if (r1 == null) {
return false;
}
permissions = GuildRoleStore.getEveryoneRole(r1).permissions;
property = r3[r1.id];
if (property == null) {
r3 = permissions;
} else {
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = value.remove(permissions, property.deny);
moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = moduleValue.add(value, property.allow);
r3 = value;
}
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
return value.has(r3, a0);
}
r5 = value;
permissionOverwrites = r5.permissionOverwrites;
value = r5.getGuildId();
value3 = null;
if (value3 != value) {
value = GuildStore.getGuild(value);
r4 = value;
} else {
r4 = value3;
}
r1 = r4;
r3 = permissionOverwrites;
if (r1 == null) {
return false;
}
permissions = GuildRoleStore.getEveryoneRole(r1).permissions;
property = r3[r1.id];
if (property == null) {
r3 = permissions;
} else {
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = value.remove(permissions, property.deny);
moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = moduleValue.add(value, property.allow);
r3 = value;
}
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
return value.has(r3, a0);
}
r1 = value;
if (r1 == null) {
return false;
}
const getEveryoneRole = GuildRoleStore.getEveryoneRole;
permissions = Reflect.apply(getEveryoneRole, GuildRoleStore, [r1]).permissions;
property = ({})[r1.id];
if (property == null) {
r3 = permissions;
} else {
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = value.remove(permissions, property.deny);
moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = moduleValue.add(value, property.allow);
r3 = value;
}
return (importAll(483) /* metro dependency 483: BigFlagUtils */).has(r3, a0);
}
function canEveryone(a0, a1) { // fn#28821, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:8028, offset: 0x00f841ec, size: 252 bytes, params: 3, frame: 19
var r7;
var r3;
var r4;
var r5;
var r0;
var type;
var has;
var permissionOverwrites;
var value3;
let value = a1;
const env0_0 = a0;
if (value instanceof ChannelRecordBase) {
type = value.type;
if (type === ChannelTypes.PRIVATE_THREAD) {
return false;
}
has = THREAD_CHANNEL_TYPES.has;
type = value.type;
if (Reflect.apply(has, THREAD_CHANNEL_TYPES, [type])) {
value = ChannelStore.getChannel(value.parent_id);
if (value == null) {
return false;
}
r7 = value;
permissionOverwrites = r7.permissionOverwrites;
value = r7.getGuildId();
value3 = null;
if (value3 != value) {
value = GuildStore.getGuild(value);
r3 = value;
} else {
r3 = value3;
}
r4 = permissionOverwrites;
r5 = r3;
if (r5 == null) {
return false;
}
value = GuildRoleStore.getEveryoneRole(r5);
value = hasPermission(value, a0);
if (value) {
value = importDefault(22) /* metro dependency 22 */;
value = !value.some(r4, _fun28822);
r0 = value;
} else {
r0 = !!value;
}
return r0;
}
r7 = value;
permissionOverwrites = r7.permissionOverwrites;
value = r7.getGuildId();
value3 = null;
if (value3 != value) {
value = GuildStore.getGuild(value);
r3 = value;
} else {
r3 = value3;
}
r4 = permissionOverwrites;
r5 = r3;
} else {
r4 = {};
r5 = value;
}
if (r5 == null) {
return false;
}
value = GuildRoleStore.getEveryoneRole(r5);
value = hasPermission(value, a0);
if (value) {
value = importDefault(22) /* metro dependency 22 */;
value = !value.some(r4, _fun28822);
r0 = value;
} else {
r0 = !!value;
}
return r0;
}
function _fun28811(a0) { // fn#28811, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:6564, offset: 0x00f83df8, size: 140 bytes, params: 2, frame: 16
var r0;
const property = env0_0[a0];
const property2 = env0_1[a0];
let value = property2 == null;
if (value) {
r0 = value;
} else {
value = environment.__proto__;
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = !value.equals(property2.deny, property.deny);
r0 = value;
}
if (!r0) {
value = environment.__proto__;
value = importAll(483) /* metro dependency 483: BigFlagUtils */;
value = !value.equals(property2.allow, property.allow);
r0 = value;
}
return r0;
}
function _fun28813(a0) { // fn#28813, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:6792, offset: 0x00f83ee5, size: 39 bytes, params: 2, frame: 14
var r0;
var value;
const hoist = a0.hoist;
if (hoist) {
value = environment.__proto__;
value = hasPermission(a0, Permissions.ADMINISTRATOR);
r0 = value;
} else {
r0 = hoist;
}
return r0;
}
function _fun28816({id}) { // fn#28816, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:7110, offset: 0x00f83fc8, size: 33 bytes, params: 2, frame: 11
return env0_0.roles.includes(id);
}
function _fun28819({channel}) { // fn#28819, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:7434, offset: 0x00f8406f, size: 72 bytes, params: 2, frame: 13
var r0;
let value = channel.id !== 'null';
if (value) {
value = environment.__proto__;
value = can({permission: Permissions.MANAGE_CHANNELS, user: env0_0, context: channel});
r0 = value;
} else {
r0 = value;
}
return r0;
}
function _fun28822({deny}) { // fn#28822, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3916:8351, offset: 0x00f842e8, size: 54 bytes, params: 2, frame: 13
const value = environment.__proto__;
return (importAll(483) /* metro dependency 483: BigFlagUtils */).has(deny, env0_0);
}