decord/source/modules/premium/powerups/hooks/useFeaturedExpiringPowerup.tsx

109 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 11724
// Function ID: 11725
2026-07-20 16:05:17 +00:00
// Name: useFeaturedExpiringPowerup
2026-08-24 06:08:38 +00:00
// Dependencies: [19, 4286, 4265, 589, 11725, 5318, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-24 06:08:38 +00:00
// Module 11724 (useFeaturedExpiringPowerup)
import closure_2 from "noop" /* 19 */;
import closure_3 from "handleGameServerInstanceCreated" /* 4286 */;
import closure_4 from "calculateAppliedBoosts" /* 4265 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/premium/powerups/hooks/useFeaturedExpiringPowerup.tsx");
2026-07-20 16:05:17 +00:00
export default function useFeaturedExpiringPowerup(arg0) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-08-24 06:08:38 +00:00
let items = [closure_4];
stateFromStores = _require(stateFromStores[3]).useStateFromStores(items, () => closure_1_4.getStateForGuild(closure_0));
2026-07-23 10:11:24 +00:00
let obj = _require(stateFromStores[3]);
const items1 = [expiringPowerupCoachmarkEnabled];
const stateFromStores1 = _require(stateFromStores[3]).useStateFromStores(items1, () => expiringPowerupCoachmarkEnabled.getStateForGuild(closure_0));
const obj2 = _require(stateFromStores[3]);
expiringPowerupCoachmarkEnabled = _require(stateFromStores[4]).useExpiringPowerupCoachmarkEnabled("useFeaturedExpiringPowerup");
2026-07-20 16:05:17 +00:00
const items2 = [stateFromStores, stateFromStores1, expiringPowerupCoachmarkEnabled];
2026-07-23 10:11:24 +00:00
return stateFromStores1.useMemo(() => {
2026-07-20 16:05:17 +00:00
if (expiringPowerupCoachmarkEnabled) {
let unlockedPowerups;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
unlockedPowerups = tmp2.unlockedPowerups;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (unlockedPowerups == null) {
2026-07-20 16:05:17 +00:00
unlockedPowerups = {};
}
const items = [];
let arraySpreadResult = HermesBuiltin.arraySpread(Object.values(unlockedPowerups), 0);
let entitlements;
2026-07-29 08:29:29 +00:00
if (stateFromStores1 != null) {
2026-07-20 16:05:17 +00:00
entitlements = stateFromStores1.entitlements;
}
2026-07-29 08:29:29 +00:00
if (entitlements == null) {
2026-07-20 16:05:17 +00:00
entitlements = {};
}
arraySpreadResult = HermesBuiltin.arraySpread(Object.values(entitlements), arraySpreadResult);
const found = items.filter((ends_at) => {
let tmp = null != ends_at.ends_at;
if (tmp) {
const metadata = ends_at.metadata;
2026-07-29 08:29:29 +00:00
let num;
if (metadata != null) {
num = metadata.num_expiring_boosts;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = num > 0;
2026-07-20 16:05:17 +00:00
}
return tmp;
});
if (0 !== found.length) {
const reduced = found.reduce((ends_at, ends_at2) => {
let tmp = ends_at;
if (ends_at2.ends_at > ends_at.ends_at) {
tmp = ends_at2;
}
return tmp;
});
let title;
2026-07-29 08:29:29 +00:00
if (tmp2 != null) {
if (tmp2.allPowerups[reduced.sku_id] != null) {
title = tmp9.title;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (title == null) {
title = null;
2026-07-20 16:05:17 +00:00
}
const sku = reduced.sku;
let game_server;
2026-07-29 08:29:29 +00:00
if (sku != null) {
2026-07-20 16:05:17 +00:00
const tenant_metadata = sku.tenant_metadata;
2026-07-29 08:29:29 +00:00
if (tenant_metadata != null) {
2026-07-20 16:05:17 +00:00
const guild_monetization = tenant_metadata.guild_monetization;
2026-07-29 08:29:29 +00:00
if (guild_monetization != null) {
2026-07-20 16:05:17 +00:00
game_server = guild_monetization.game_server;
}
}
}
2026-07-29 08:29:29 +00:00
const obj = { name: null, daysUntilExpiry: null, numExpiringBoosts: null, isGameServer: null, skuId: null };
obj[0] = title;
2026-07-20 16:05:17 +00:00
const _Math = Math;
const _Date = Date;
const date = new Date(reduced.ends_at);
2026-07-29 08:29:29 +00:00
obj[1] = Math.max(0, callback(stateFromStores[5]).getDaysRemaining(date));
2026-07-23 10:11:24 +00:00
let metadata = reduced.metadata;
2026-07-29 08:29:29 +00:00
let num3;
if (metadata != null) {
num3 = metadata.num_expiring_boosts;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num3 == null) {
num3 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[2] = num3;
obj[3] = null != game_server;
obj[4] = reduced.sku_id;
2026-07-20 16:05:17 +00:00
return obj;
}
}
}, items2);
};