decord/source/modules/permissions/useManageResourcePermissions.tsx

215 lines
6.9 KiB
TypeScript
Raw Normal View History

2026-09-02 09:53:35 +00:00
// Module ID: 9653
// Function ID: 9654
2026-07-20 16:05:17 +00:00
// Name: canManageResource
2026-09-02 09:53:35 +00:00
// Dependencies: [32, 19, 4120, 1921, 9654, 502, 503, 1425, 586, 2]
2026-07-29 08:29:29 +00:00
// Exports: attachChannelPermissions, getManageResourcePermissions, useManageResourcePermissions
2026-07-20 16:05:17 +00:00
2026-09-02 09:53:35 +00:00
// Module 9653 (canManageResource)
import fromStringAll from "fromString" /* 503 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "noop" /* 19 */;
2026-09-02 09:53:35 +00:00
import closure_5 from "getUncachedChannelPermissions" /* 4120 */;
import closure_6 from "mergeGuildAvatar" /* 1921 */;
import VIEW_CHANNEL from "VIEW_CHANNEL" /* 9654 */;
import { Permissions } from "sum" /* 502 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-20 16:05:17 +00:00
function canManageResource(arg0, arg1, arg2, arg3) {
let creator_id = arg0;
2026-07-29 08:29:29 +00:00
let tmp = null != arg0;
if (tmp) {
if (arg2) {
tmp = tmp3;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let id = arg1;
let tmp4 = arg3;
if ("creator_id" in creator_id) {
if (tmp4) {
tmp4 = null != id;
}
if (tmp4) {
creator_id = creator_id.creator_id;
id = id.id;
tmp4 = creator_id === id;
}
let tmp5 = tmp4;
} else if ("userId" in creator_id) {
let tmp8 = tmp4;
if (tmp4) {
tmp8 = null != id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp8) {
tmp8 = creator_id.userId === id.id;
}
tmp5 = tmp8;
} else {
tmp5 = "user" in creator_id;
if (tmp5) {
let tmp6 = tmp4;
if (tmp4) {
tmp6 = null != id;
}
if (tmp6) {
const user = creator_id.user;
id = undefined;
if (user != null) {
id = user.id;
}
tmp6 = id === id.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp5 = tmp6;
2026-07-20 16:05:17 +00:00
}
}
}
}
2026-07-29 08:29:29 +00:00
return tmp;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
({ CREATE_GUILD_EVENT_CORE_PERMISSIONS: error, CREATE_GUILD_EVENT_STAGE_CHANNEL_PERMISSIONS: closure_8, CREATE_GUILD_EVENT_VOICE_CHANNEL_PERMISSIONS: c9 } = VIEW_CHANNEL);
2026-07-29 08:29:29 +00:00
let closure_11 = {
2026-07-23 10:11:24 +00:00
canCreateExpressions: false,
canCreateGuildEvent: false,
canManageAllExpressions: false,
canManageAllEvents: false,
2026-07-20 16:05:17 +00:00
canManageGuildExpression() {
return false;
},
canManageGuildEvent() {
return false;
}
};
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/permissions/useManageResourcePermissions.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const attachChannelPermissions = function attachChannelPermissions(channel) {
if (null == channel) {
const items = [, ];
({ CREATE_EVENTS: arr2[0], MANAGE_EVENTS: arr2[1] } = Permissions);
return items;
} else {
let tmp = closure_7;
if (channel.isGuildStageVoice()) {
tmp = closure_8;
} else if (channel.isGuildVoice()) {
tmp = closure_9;
}
2026-08-24 06:08:38 +00:00
const items1 = [fromStringAll.combine(tmp, Permissions.CREATE_EVENTS), ];
const obj = fromStringAll;
items1[1] = fromStringAll.combine(tmp, Permissions.MANAGE_EVENTS);
2026-07-29 08:29:29 +00:00
return items1;
}
};
2026-07-20 16:05:17 +00:00
export const useManageResourcePermissions = function useManageResourcePermissions(channel) {
2026-07-23 10:11:24 +00:00
const _require = channel;
2026-09-02 09:53:35 +00:00
let obj = _require(1425);
2026-07-20 16:05:17 +00:00
if (obj.isGuildRecord(channel)) {
2026-07-29 08:29:29 +00:00
let items = [, ];
({ CREATE_EVENTS: arr3[0], MANAGE_EVENTS: arr3[1] } = Permissions);
let items2 = items;
} else if (null == channel) {
const items1 = [, ];
({ CREATE_EVENTS: arr2[0], MANAGE_EVENTS: arr2[1] } = Permissions);
items2 = items1;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let tmp4 = stateFromStores;
if (channel.isGuildStageVoice()) {
tmp4 = closure_8;
} else if (channel.isGuildVoice()) {
tmp4 = closure_9;
}
2026-08-24 06:08:38 +00:00
items2 = [fromStringAll.combine(tmp4, Permissions.CREATE_EVENTS), ];
const obj2 = fromStringAll;
items2[1] = fromStringAll.combine(tmp4, Permissions.MANAGE_EVENTS);
const obj3 = fromStringAll;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
[importAll, dependencyMap] = first(items2, 2);
2026-09-02 09:53:35 +00:00
let tmpResult = tmp(586);
2026-08-24 06:08:38 +00:00
const items3 = [closure_5];
2026-07-29 08:29:29 +00:00
const tmp10 = first(tmpResult.useStateFromStoresArray(items3, () => {
2026-08-24 06:08:38 +00:00
const items = [closure_5.can(closure_1_10.CREATE_GUILD_EXPRESSIONS, closure_0), closure_5.can(closure_1_10.MANAGE_GUILD_EXPRESSIONS, closure_0), closure_5.can(closure_1, closure_0), closure_5.can(closure_2, closure_0)];
2026-07-20 16:05:17 +00:00
return items;
}), 4);
2026-07-29 08:29:29 +00:00
first = tmp10[0];
const React = tmp12;
2026-08-24 06:08:38 +00:00
closure_5 = tmp13;
closure_6 = tmp14;
2026-09-02 09:53:35 +00:00
tmpResult = tmp(586);
2026-08-24 06:08:38 +00:00
const items4 = [closure_6];
stateFromStores = tmpResult.useStateFromStores(items4, () => currentUser.getCurrentUser());
2026-07-29 08:29:29 +00:00
const items5 = [first, tmp10[1], stateFromStores];
const items6 = [tmp10[3], tmp10[2], stateFromStores];
2026-08-24 06:08:38 +00:00
const callback = React.useCallback((arg0) => closure_1_12(arg0, stateFromStores, closure_4, first), items5);
2026-07-29 08:29:29 +00:00
if (null == channel) {
obj = closure_11;
} else {
obj = { canCreateExpressions: null, canCreateGuildEvent: null, canManageAllExpressions: null, canManageAllEvents: null, canManageGuildExpression: null, canManageGuildEvent: null };
obj[0] = first;
obj[1] = tmp13;
obj[2] = tmp12;
obj[3] = tmp14;
obj[4] = callback;
obj[5] = tmp17;
2026-07-20 16:05:17 +00:00
}
return obj;
};
2026-07-23 10:11:24 +00:00
export const getManageResourcePermissions = function getManageResourcePermissions(guild, c6, closure_7) {
let obj = c6;
if (c6 === undefined) {
2026-08-24 06:08:38 +00:00
obj = closure_5;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let obj2 = closure_7;
if (closure_7 === undefined) {
2026-08-24 06:08:38 +00:00
obj2 = closure_6;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let _require;
let canResult1;
let canResult2;
let canResult3;
2026-07-20 16:05:17 +00:00
let currentUser;
if (obj3.isGuildRecord(guild)) {
2026-07-29 08:29:29 +00:00
const items = [, ];
({ CREATE_EVENTS: arr3[0], MANAGE_EVENTS: arr3[1] } = Permissions);
let tmp5 = Permissions;
let items2 = items;
} else if (null == guild) {
const items1 = [, ];
({ CREATE_EVENTS: arr2[0], MANAGE_EVENTS: arr2[1] } = Permissions);
tmp5 = Permissions;
items2 = items1;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let tmp3 = closure_7;
if (guild.isGuildStageVoice()) {
tmp3 = closure_8;
} else if (guild.isGuildVoice()) {
tmp3 = closure_9;
}
tmp5 = Permissions;
items2 = [canResult1(tmp[6]).combine(tmp3, Permissions.CREATE_EVENTS), ];
const obj4 = canResult1(tmp[6]);
items2[1] = canResult1(tmp[6]).combine(tmp3, Permissions.MANAGE_EVENTS);
const obj5 = canResult1(tmp[6]);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
obj3 = _require(canResult2[7]);
2026-07-29 08:29:29 +00:00
[tmp9, tmp10] = canResult3(items2, 2);
const canResult = obj.can(tmp5.CREATE_GUILD_EXPRESSIONS, guild);
2026-07-23 10:11:24 +00:00
_require = canResult;
2026-07-29 08:29:29 +00:00
canResult1 = obj.can(tmp5.MANAGE_GUILD_EXPRESSIONS, guild);
canResult2 = obj.can(tmp9, guild);
canResult3 = obj.can(tmp10, guild);
2026-07-20 16:05:17 +00:00
currentUser = obj2.getCurrentUser();
2026-07-29 08:29:29 +00:00
if (null == guild) {
obj = closure_11;
} else {
obj = { canCreateExpressions: null, canCreateGuildEvent: null, canManageAllExpressions: null, canManageAllEvents: null, canManageGuildExpression: null, canManageGuildEvent: null };
obj[0] = canResult;
obj[1] = canResult2;
obj[2] = canResult1;
obj[3] = canResult3;
obj[4] = function canManageGuildExpression(arg0) {
2026-08-24 06:08:38 +00:00
return closure_1_12(arg0, closure_4, canResult1, c0);
2026-07-29 08:29:29 +00:00
};
obj[5] = function canManageGuildEvent(arg0) {
2026-08-24 06:08:38 +00:00
return closure_1_12(arg0, closure_4, canResult3, canResult2);
2026-07-20 16:05:17 +00:00
};
}
return obj;
};