decord/source/modules/premium/perks_state/PerksStateUtils.tsx

123 lines
3.9 KiB
TypeScript
Raw Normal View History

2026-08-11 06:20:06 +00:00
// Module ID: 1938
// Function ID: 1939
2026-07-20 16:05:17 +00:00
// Name: parseServerPerkConfigKind
2026-08-11 06:20:06 +00:00
// Dependencies: [32, 1939, 506, 1940, 2]
2026-07-29 08:29:29 +00:00
// Exports: getPerkConfig, hasPerk, parseServerPerks
2026-07-20 16:05:17 +00:00
2026-08-11 06:20:06 +00:00
// Module 1938 (parseServerPerkConfigKind)
2026-08-24 06:08:38 +00:00
import fromStringAll from "fromString" /* 506 */;
import PerkConfigType from "PerkConfigType" /* 1939 */;
import create from "create" /* 1940 */;
import closure_3 from "_slicedToArray" /* 32 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function parseServerPerkConfigKind(kind) {
if (null != kind.kind) {
const type = kind.kind.type;
2026-08-24 06:08:38 +00:00
if (PerkConfigType.PerkConfigType.INCREASED_FILE_UPLOAD_SIZE === type) {
2026-07-29 08:29:29 +00:00
let obj = { type: null, maxSize: null };
2026-08-11 06:20:06 +00:00
obj[0] = tmp(1939).PerkConfigType.INCREASED_FILE_UPLOAD_SIZE;
2026-07-29 08:29:29 +00:00
obj[1] = kind.kind.max_size;
2026-07-20 16:05:17 +00:00
return obj;
2026-08-11 06:20:06 +00:00
} else if (tmp(1939).PerkConfigType.INCREASED_GUILD_LIMIT === type) {
2026-07-29 08:29:29 +00:00
obj = { type: null, maxGuilds: null };
2026-08-11 06:20:06 +00:00
obj[0] = tmp(1939).PerkConfigType.INCREASED_GUILD_LIMIT;
2026-07-29 08:29:29 +00:00
obj[1] = kind.kind.max_guilds;
2026-07-20 16:05:17 +00:00
return obj;
}
}
}
function getPerkSource(perks, MONTHLY_ORBS) {
if (null != perks) {
const _String = String;
2026-07-29 08:29:29 +00:00
const tmp3 = perks.configByPerk[String(undefined, MONTHLY_ORBS)];
2026-07-20 16:05:17 +00:00
let source;
2026-07-29 08:29:29 +00:00
if (tmp3 != null) {
source = tmp3.source;
2026-07-20 16:05:17 +00:00
}
if (null != source) {
2026-07-29 08:29:29 +00:00
source = tmp3.source;
} else {
let flag = false;
if (null != perks) {
const activePerksBitmask = perks.activePerksBitmask;
const _Math = Math;
const rounded = Math.floor(MONTHLY_ORBS / 64);
let hasItem = rounded < activePerksBitmask.length;
if (hasItem) {
2026-08-24 06:08:38 +00:00
const obj = fromStringAll;
const obj2 = fromStringAll;
const deserializeResult = fromStringAll.deserialize(activePerksBitmask[rounded]);
hasItem = obj.has(deserializeResult, fromStringAll.getFlag(MONTHLY_ORBS % 64));
const obj3 = fromStringAll;
2026-07-29 08:29:29 +00:00
}
flag = hasItem;
}
if (flag) {
2026-08-24 06:08:38 +00:00
const items = [create.PerkSource.SOURCE_NITRO];
2026-07-29 08:29:29 +00:00
source = items;
}
2026-07-20 16:05:17 +00:00
}
return source;
}
}
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/premium/perks_state/PerksStateUtils.tsx");
2026-07-20 16:05:17 +00:00
export const parseServerPerks = function parseServerPerks(perks) {
if (null == perks) {
return null;
} else {
let obj = {};
const _Object = Object;
const entries = Object.entries(perks.config_by_perk);
2026-07-29 08:29:29 +00:00
const tmp11 = entries[Symbol.iterator]();
while (tmp11 !== undefined) {
let tmp4 = callback;
let tmp5 = callback(tmp2, 2);
let tmp6 = tmp5[1];
obj = { source: null, kind: null };
obj[0] = tmp6.source;
let tmp7 = parseServerPerkConfigKind;
obj[1] = parseServerPerkConfigKind(tmp6);
obj[tmp5[0]] = obj;
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { activePerksBitmask: null, configByPerk: null, rulesVersion: null };
obj[0] = perks.active_perks_bitmask;
obj[1] = obj;
obj[2] = perks.rules_version;
2026-07-20 16:05:17 +00:00
return obj;
}
};
2026-07-29 08:29:29 +00:00
export const hasPerk = function hasPerk(perks, MONTHLY_ORBS) {
if (null == perks) {
return false;
} else {
const activePerksBitmask = perks.activePerksBitmask;
const _Math = Math;
const rounded = Math.floor(MONTHLY_ORBS / 64);
let hasItem = rounded < activePerksBitmask.length;
if (hasItem) {
2026-08-24 06:08:38 +00:00
const obj = fromStringAll;
const obj2 = fromStringAll;
const deserializeResult = fromStringAll.deserialize(activePerksBitmask[rounded]);
hasItem = obj.has(deserializeResult, fromStringAll.getFlag(MONTHLY_ORBS % 64));
const obj3 = fromStringAll;
2026-07-29 08:29:29 +00:00
}
return hasItem;
}
};
2026-07-20 16:05:17 +00:00
export { getPerkSource };
export const getPerkConfig = function getPerkConfig(perks, MONTHLY_ORBS) {
if (null != perks) {
const _String = String;
2026-07-29 08:29:29 +00:00
const tmp3 = perks.configByPerk[String(undefined, MONTHLY_ORBS)];
if (null != tmp3) {
const obj = { source: null, kind: null };
obj[0] = getPerkSource(perks, MONTHLY_ORBS);
obj[1] = tmp3.kind;
2026-07-20 16:05:17 +00:00
return obj;
}
}
};