decord/source/modules/permissions/useManageResourcePermissions.tsx

178 lines
5.5 KiB
TypeScript
Raw Normal View History

2026-07-23 10:11:24 +00:00
// Module ID: 8402
// Function ID: 66864
2026-07-20 16:05:17 +00:00
// Name: canManageResource
2026-07-23 10:11:24 +00:00
// Dependencies: [57, 31, 3758, 1849, 8401, 482, 483, 1387, 566, 2]
2026-07-20 16:05:17 +00:00
// Exports: getManageResourcePermissions, useManageResourcePermissions
2026-07-23 10:11:24 +00:00
// Module 8402 (canManageResource)
import _slicedToArray from "_slicedToArray";
import result from "result";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import closure_6 from "_isNativeReflectConstruct";
import VIEW_CHANNEL from "VIEW_CHANNEL";
import { Permissions } from "sum";
let closure_7;
let closure_8;
let closure_9;
const require = arg1;
2026-07-20 16:05:17 +00:00
function canManageResource(arg0, arg1, arg2, arg3) {
let creator_id = arg0;
let id = arg1;
let tmp = arg3;
let tmp2 = null != arg0;
if (tmp2) {
if (!!arg2) {
tmp2 = !tmp4;
} else if ("creator_id" in creator_id) {
if (tmp) {
tmp = null != id;
}
if (tmp) {
creator_id = creator_id.creator_id;
id = id.id;
tmp = creator_id === id;
}
let tmp5 = tmp;
} else if ("userId" in creator_id) {
let tmp8 = tmp;
if (tmp) {
tmp8 = null != id;
}
if (tmp8) {
tmp8 = creator_id.userId === id.id;
}
tmp5 = tmp8;
} else {
tmp5 = "user" in creator_id;
if (tmp5) {
let tmp6 = tmp;
if (tmp) {
tmp6 = null != id;
}
if (tmp6) {
const user = creator_id.user;
id = undefined;
if (null != user) {
id = user.id;
}
tmp6 = id === id.id;
}
tmp5 = tmp6;
}
}
}
return tmp2;
}
function attachChannelPermissions(channel) {
if (null == channel) {
const items = [Permissions.CREATE_EVENTS, Permissions.MANAGE_EVENTS];
return items;
} else {
let tmp = closure_7;
if (channel.isGuildStageVoice()) {
tmp = closure_8;
} else if (channel.isGuildVoice()) {
tmp = closure_9;
}
2026-07-23 10:11:24 +00:00
const items1 = [importAll(483).combine(tmp, Permissions.CREATE_EVENTS), ];
const obj = importAll(483);
items1[1] = importAll(483).combine(tmp, Permissions.MANAGE_EVENTS);
2026-07-20 16:05:17 +00:00
return items1;
}
}
2026-07-23 10:11:24 +00:00
({ CREATE_GUILD_EVENT_CORE_PERMISSIONS: closure_7, CREATE_GUILD_EVENT_STAGE_CHANNEL_PERMISSIONS: closure_8, CREATE_GUILD_EVENT_VOICE_CHANNEL_PERMISSIONS: closure_9 } = VIEW_CHANNEL);
let obj = {
canCreateExpressions: false,
canCreateGuildEvent: false,
canManageAllExpressions: false,
canManageAllEvents: false,
2026-07-20 16:05:17 +00:00
canManageGuildExpression() {
return false;
},
canManageGuildEvent() {
return false;
}
};
2026-07-23 10:11:24 +00:00
const result = require("_isNativeReflectConstruct").fileFinishedImporting("modules/permissions/useManageResourcePermissions.tsx");
2026-07-20 16:05:17 +00:00
export { attachChannelPermissions };
export const useManageResourcePermissions = function useManageResourcePermissions(channel) {
2026-07-23 10:11:24 +00:00
const _require = channel;
let obj = _require(1387);
2026-07-20 16:05:17 +00:00
if (obj.isGuildRecord(channel)) {
2026-07-23 10:11:24 +00:00
let items = [Permissions.CREATE_EVENTS, Permissions.MANAGE_EVENTS];
2026-07-20 16:05:17 +00:00
let tmp2 = items;
} else {
tmp2 = attachChannelPermissions(channel);
}
2026-07-23 10:11:24 +00:00
const tmp5 = first(tmp2, 2);
2026-07-20 16:05:17 +00:00
let closure_1 = tmp5[0];
2026-07-23 10:11:24 +00:00
const dependencyMap = tmp5[1];
const items1 = [_isNativeReflectConstruct];
const tmp6 = first(_require(566).useStateFromStoresArray(items1, () => {
const items = [tmp9.can(outer1_10.CREATE_GUILD_EXPRESSIONS, closure_0), tmp9.can(outer1_10.MANAGE_GUILD_EXPRESSIONS, closure_0), tmp9.can(closure_1, closure_0), tmp9.can(closure_2, closure_0)];
2026-07-20 16:05:17 +00:00
return items;
}), 4);
2026-07-23 10:11:24 +00:00
first = tmp6[0];
2026-07-20 16:05:17 +00:00
const React = tmp8;
2026-07-23 10:11:24 +00:00
_isNativeReflectConstruct = tmp9;
2026-07-20 16:05:17 +00:00
let closure_6 = tmp10;
2026-07-23 10:11:24 +00:00
const obj2 = _require(566);
2026-07-20 16:05:17 +00:00
const items2 = [closure_6];
2026-07-23 10:11:24 +00:00
const stateFromStores = _require(566).useStateFromStores(items2, () => tmp10.getCurrentUser());
2026-07-20 16:05:17 +00:00
const items3 = [first, tmp6[1], stateFromStores];
const items4 = [tmp6[3], tmp6[2], stateFromStores];
2026-07-23 10:11:24 +00:00
const callback = React.useCallback((arg0) => outer1_12(arg0, stateFromStores, result, first), items3);
2026-07-21 22:01:30 +00:00
if (null != channel) {
2026-07-20 16:05:17 +00:00
obj = { canCreateExpressions: first, canCreateGuildEvent: tmp9, canManageAllExpressions: tmp8, canManageAllEvents: tmp10, canManageGuildExpression: callback, canManageGuildEvent: tmp13 };
}
return obj;
};
2026-07-23 10:11:24 +00:00
export const getManageResourcePermissions = function getManageResourcePermissions(guild, c6, closure_7) {
2026-07-20 16:05:17 +00:00
let tmp6;
let tmp7;
2026-07-23 10:11:24 +00:00
let obj = c6;
2026-07-20 16:05:17 +00:00
let obj2 = closure_7;
2026-07-23 10:11:24 +00:00
if (c6 === undefined) {
obj = _isNativeReflectConstruct;
2026-07-20 16:05:17 +00:00
}
if (obj2 === undefined) {
obj2 = closure_6;
}
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)) {
const items = [Permissions.CREATE_EVENTS, Permissions.MANAGE_EVENTS];
let tmp2 = items;
} else {
tmp2 = attachChannelPermissions(guild);
}
2026-07-23 10:11:24 +00:00
obj3 = _require(canResult2[7]);
[tmp6, tmp7] = canResult3(tmp2, 2);
2026-07-20 16:05:17 +00:00
const canResult = obj.can(Permissions.CREATE_GUILD_EXPRESSIONS, guild);
2026-07-23 10:11:24 +00:00
_require = canResult;
canResult1 = obj.can(Permissions.MANAGE_GUILD_EXPRESSIONS, guild);
canResult2 = obj.can(tmp6, guild);
canResult3 = obj.can(tmp7, guild);
2026-07-20 16:05:17 +00:00
currentUser = obj2.getCurrentUser();
2026-07-21 22:01:30 +00:00
if (null != guild) {
2026-07-20 16:05:17 +00:00
obj = {
canCreateExpressions: canResult,
canCreateGuildEvent: canResult2,
canManageAllExpressions: canResult1,
canManageAllEvents: canResult3,
canManageGuildExpression(arg0) {
2026-07-23 10:11:24 +00:00
return outer1_12(arg0, result, canResult1, c0);
2026-07-20 16:05:17 +00:00
},
canManageGuildEvent(arg0) {
2026-07-23 10:11:24 +00:00
return outer1_12(arg0, result, canResult3, canResult2);
2026-07-20 16:05:17 +00:00
}
};
}
return obj;
};