decord/source/modules/rewards/ProgramRewardsUtils.tsx

143 lines
5 KiB
TypeScript
Raw Normal View History

// Module ID: 13753
// Function ID: 13754
// Name: ProgramRewardsUtils
// Dependencies: [1371, 1373, 4007, 13754, 13757, 7570, 13758, 4231, 2]
2026-07-29 08:29:29 +00:00
// Exports: canFetchAnyProgramReward, canFetchNitroProgramReward, canFetchXboxProgramReward, hasNecessaryPremiumSubscriptionStatus, isEligibleForProgramReward, isProgramRewardStale, useIsEligibleForProgramReward
2026-07-20 16:05:17 +00:00
// Module 13753 (ProgramRewardsUtils)
import _modDef4007 from "module_4007" /* 4007 */;
import PremiumUtils from "PremiumUtils" /* 4231 */;
import XboxGamePassPerksExperiment from "XboxGamePassPerksExperiment" /* 7570 */;
import ProgramRewardsTypes from "ProgramRewardsTypes" /* 13754 */;
import PremiumRewardsOrbsExperiment from "PremiumRewardsOrbsExperiment" /* 13757 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-23 10:11:24 +00:00
require = fn;
function canFetchNitroProgramReward(ProgramRewardsUtils) {
let str = ProgramRewardsUtils;
if (ProgramRewardsUtils === undefined) {
2026-07-20 16:05:17 +00:00
str = "ProgramRewardsUtils";
}
const NITRO = ProgramRewardsTypes.RewardProgram.NITRO;
2026-07-29 08:29:29 +00:00
if (str === undefined) {
2026-07-20 16:05:17 +00:00
str = "ProgramRewardsUtils";
}
if (ProgramRewardsTypes.RewardProgram.NITRO === NITRO) {
let flag = tmp(13757).getPremiumRewardsOrbsExperiment(str).isInTreatment;
const tmpResult = tmp(13757);
2026-07-29 08:29:29 +00:00
} else {
flag = false;
if (tmp(13754).RewardProgram.XBOX === NITRO) {
flag = tmp(7570).getIsXboxGamePassPerksEnabled(str);
const tmpResult3 = tmp(7570);
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag) {
const currentUser = UserStore.getCurrentUser();
flag = tmp(4231).isPremiumExactly(currentUser, PremiumTypes.TIER_2);
const tmpResult4 = tmp(4231);
2026-07-29 08:29:29 +00:00
}
return flag;
2026-07-20 16:05:17 +00:00
}
function canFetchXboxProgramReward(ProgramRewardsUtils) {
let str = ProgramRewardsUtils;
if (ProgramRewardsUtils === undefined) {
2026-07-20 16:05:17 +00:00
str = "ProgramRewardsUtils";
}
const XBOX = ProgramRewardsTypes.RewardProgram.XBOX;
2026-07-29 08:29:29 +00:00
if (str === undefined) {
str = "ProgramRewardsUtils";
2026-07-20 16:05:17 +00:00
}
if (ProgramRewardsTypes.RewardProgram.NITRO === XBOX) {
let flag = tmp(13757).getPremiumRewardsOrbsExperiment(str).isInTreatment;
const tmpResult = tmp(13757);
2026-07-29 08:29:29 +00:00
} else {
flag = false;
if (tmp(13754).RewardProgram.XBOX === XBOX) {
flag = tmp(7570).getIsXboxGamePassPerksEnabled(str);
const tmpResult3 = tmp(7570);
2026-07-29 08:29:29 +00:00
}
}
if (flag) {
flag = tmp(13758).hasCrepeMonthlyOrbsPerk(UserStore.getCurrentUser());
const tmpResult4 = tmp(13758);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return flag;
2026-07-20 16:05:17 +00:00
}
const PremiumTypes = fn(1373).PremiumTypes;
const dependencyMap = { [fn(13754).RewardProgram.NITRO]: canFetchNitroProgramReward, [fn(13754).RewardProgram.XBOX]: canFetchXboxProgramReward };
const size = fn(2);
const result = size.fileFinishedImporting("modules/rewards/ProgramRewardsUtils.tsx");
2026-07-20 16:05:17 +00:00
export const isProgramRewardStale = function isProgramRewardStale(next_reward_date) {
if (null == next_reward_date) {
return true;
} else {
next_reward_date = next_reward_date.next_reward_date;
let tmp = null != next_reward_date;
if (tmp) {
tmp = "" !== next_reward_date;
}
if (tmp) {
const _Date = Date;
const date = new Date(next_reward_date);
tmp = _modDef4007(date);
2026-07-20 16:05:17 +00:00
}
return tmp;
}
};
export const isEligibleForProgramReward = function isEligibleForProgramReward(arg0, ProgramRewardsUtils) {
let str = ProgramRewardsUtils;
if (ProgramRewardsUtils === undefined) {
2026-07-29 08:29:29 +00:00
str = "ProgramRewardsUtils";
}
if (ProgramRewardsTypes.RewardProgram.NITRO === arg0) {
return tmp(13757).getPremiumRewardsOrbsExperiment(str).isInTreatment;
} else if (tmp(13754).RewardProgram.XBOX === arg0) {
return tmp(7570).getIsXboxGamePassPerksEnabled(str);
2026-07-29 08:29:29 +00:00
} else {
return false;
}
};
export const useIsEligibleForProgramReward = function useIsEligibleForProgramReward(arg0, ProgramRewardsUtils) {
let str = ProgramRewardsUtils;
if (ProgramRewardsUtils === undefined) {
2026-07-20 16:05:17 +00:00
str = "ProgramRewardsUtils";
}
const obj = PremiumRewardsOrbsExperiment;
const isXboxGamePassPerksEnabled = XboxGamePassPerksExperiment.useIsXboxGamePassPerksEnabled(str);
if (ProgramRewardsTypes.RewardProgram.NITRO === arg0) {
2026-07-20 16:05:17 +00:00
return obj.usePremiumRewardsOrbsExperiment(str).isInTreatment;
} else if (ProgramRewardsTypes.RewardProgram.XBOX === arg0) {
2026-08-31 15:47:37 +00:00
return isXboxGamePassPerksEnabled;
2026-07-20 16:05:17 +00:00
} else {
return false;
}
};
export { canFetchNitroProgramReward };
export { canFetchXboxProgramReward };
export const canFetchAnyProgramReward = function canFetchAnyProgramReward(ProgramRewardsStore) {
let str = ProgramRewardsStore;
if (ProgramRewardsStore === undefined) {
str = "ProgramRewardsUtils";
}
const values = Object.values(ProgramRewardsTypes.RewardProgram);
2026-07-29 08:29:29 +00:00
for (const item10015 of values) {
2026-08-04 21:03:28 +00:00
if (typeof item10015 === "number") {
2026-07-29 08:29:29 +00:00
if (dependencyMap[tmp2](str)) {
obj.return();
let flag = true;
return true;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
return false;
};
2026-07-29 08:29:29 +00:00
export const hasNecessaryPremiumSubscriptionStatus = function hasNecessaryPremiumSubscriptionStatus(currentUser) {
if (currentUser == null) {
currentUser = UserStore.getCurrentUser();
2026-07-29 08:29:29 +00:00
}
return PremiumUtils.isPremiumExactly(currentUser, PremiumTypes.TIER_2);
2026-07-29 08:29:29 +00:00
};