decord/source/utils/SubscriptionUtils.tsx

193 lines
7.9 KiB
TypeScript
Raw Normal View History

2026-08-15 05:55:55 +00:00
// Module ID: 10648
// Function ID: 10649
2026-07-29 08:29:29 +00:00
// Name: getSubscriptionPlans
2026-08-15 05:55:55 +00:00
// Dependencies: [32, 19, 4044, 676, 1924, 38, 10649, 4039, 7223, 589, 10651, 3975, 2]
2026-07-29 08:29:29 +00:00
// Exports: didBeginPurchaseFlowOnFractionalPremium, getOrFetchSubscriptionPlan, getSubscriptionPauseDurations, getSubscriptionPlans, getSubscriptionSKUs, subscriptionCanDowngrade, subscriptionCanSwitchImmediately, useGetOrFetchSubscriptionPlan
2026-07-20 16:05:17 +00:00
2026-08-15 05:55:55 +00:00
// Module 10648 (getSubscriptionPlans)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
2026-07-29 08:29:29 +00:00
import noop from "noop";
import addSubscriptionPlan from "addSubscriptionPlan";
2026-07-23 10:11:24 +00:00
import ME from "ME";
import GuildFeatures from "GuildFeatures";
2026-07-29 08:29:29 +00:00
let c9;
2026-07-23 10:11:24 +00:00
let closure_6;
2026-07-29 08:29:29 +00:00
let error;
let metroImportAll;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
({ SubscriptionStatusTypes: closure_6, SubscriptionTypes: error } = ME);
({ SubscriptionPlans: metroImportAll, SubscriptionPlanInfo: c9 } = GuildFeatures);
let result = require("addSubscriptionPlan").fileFinishedImporting("utils/SubscriptionUtils.tsx");
export const getSubscriptionPlans = function getSubscriptionPlans(items) {
2026-07-20 16:05:17 +00:00
items = items.items;
return items.map((planId) => {
2026-07-29 08:29:29 +00:00
const value = addSubscriptionPlan.get(planId.planId);
callback(table[5])(null != value, "Unable to fetch plan");
return value;
});
};
export const getSubscriptionSKUs = function getSubscriptionSKUs(items) {
items = items.items;
const mapped = items.map((planId) => {
const value = addSubscriptionPlan.get(planId.planId);
callback(table[5])(null != value, "Unable to fetch plan");
2026-07-20 16:05:17 +00:00
return value;
});
2026-07-29 08:29:29 +00:00
return mapped.map((skuId) => skuId.skuId);
};
export const subscriptionCanSwitchImmediately = function subscriptionCanSwitchImmediately(getCurrentSubscriptionPlanIdForGroup, newPlanId, arr) {
2026-07-20 16:05:17 +00:00
const currentSubscriptionPlanIdForGroup = getCurrentSubscriptionPlanIdForGroup.getCurrentSubscriptionPlanIdForGroup(arr);
if (getCurrentSubscriptionPlanIdForGroup.type === constants2.PREMIUM) {
if (null == currentSubscriptionPlanIdForGroup) {
return true;
}
}
let obj = { oldPlanId: currentSubscriptionPlanIdForGroup, newPlanId };
if (null == currentSubscriptionPlanIdForGroup) {
2026-07-29 08:29:29 +00:00
obj = { message: "Current subscription has no plan in group", extraSentryInformation: null };
obj[1] = obj;
2026-08-15 05:55:55 +00:00
const checkoutError = new require(10649) /* prototype */.CheckoutError(obj);
2026-07-29 08:29:29 +00:00
throw checkoutError;
2026-07-20 16:05:17 +00:00
} else {
if (currentSubscriptionPlanIdForGroup === closure_8.PREMIUM_YEAR_TIER_1) {
if (newPlanId === closure_8.PREMIUM_MONTH_TIER_2) {
2026-07-29 08:29:29 +00:00
obj = { message: "Unexpected plan switch", extraSentryInformation: null };
obj[1] = obj;
2026-08-15 05:55:55 +00:00
const checkoutError1 = new require(10649) /* prototype */.CheckoutError(obj);
2026-07-29 08:29:29 +00:00
throw checkoutError1;
2026-07-20 16:05:17 +00:00
}
}
const index = arr.indexOf(currentSubscriptionPlanIdForGroup);
return index < arr.indexOf(newPlanId);
}
};
2026-07-29 08:29:29 +00:00
export const subscriptionCanDowngrade = function subscriptionCanDowngrade(getCurrentSubscriptionPlanIdForGroup, arg1, arr) {
const currentSubscriptionPlanIdForGroup = getCurrentSubscriptionPlanIdForGroup.getCurrentSubscriptionPlanIdForGroup(arr);
if (getCurrentSubscriptionPlanIdForGroup.type !== constants2.PREMIUM) {
let obj = { oldPlanId: null, newPlanId: null };
obj[0] = currentSubscriptionPlanIdForGroup;
obj[1] = arg1;
if (null == currentSubscriptionPlanIdForGroup) {
obj = { message: "Current subscription has no plan in group", extraSentryInformation: null };
obj[1] = obj;
2026-08-15 05:55:55 +00:00
const checkoutError = new require(10649) /* prototype */.CheckoutError(obj);
2026-07-29 08:29:29 +00:00
throw checkoutError;
} else {
if (currentSubscriptionPlanIdForGroup === closure_8.PREMIUM_YEAR_TIER_1) {
if (arg1 === closure_8.PREMIUM_MONTH_TIER_2) {
obj = { message: "Unexpected plan switch", extraSentryInformation: null };
obj[1] = obj;
2026-08-15 05:55:55 +00:00
const checkoutError1 = new require(10649) /* prototype */.CheckoutError(obj);
2026-07-29 08:29:29 +00:00
throw checkoutError1;
}
}
const index = arr.indexOf(currentSubscriptionPlanIdForGroup);
let flag = index < arr.indexOf(arg1);
}
} else {
flag = true;
}
return !flag;
2026-07-20 16:05:17 +00:00
};
2026-07-23 10:11:24 +00:00
export const getOrFetchSubscriptionPlan = function getOrFetchSubscriptionPlan(subscriptionPlanId, closure_1) {
2026-07-29 08:29:29 +00:00
const value = addSubscriptionPlan.get(subscriptionPlanId);
2026-07-20 16:05:17 +00:00
if (null == value) {
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
importDefault(38)(null != table[subscriptionPlanId], "Missing hardcoded subscriptionPlan: " + subscriptionPlanId);
const tmp12 = require;
const tmp8 = importDefault(38);
const tmp9 = null != table[subscriptionPlanId];
2026-08-15 05:55:55 +00:00
const result = require(4039) /* getPremiumPlanItem */.castPremiumSubscriptionAsSkuId(tmp5.skuId);
2026-07-29 08:29:29 +00:00
if (!addSubscriptionPlan.isFetchingForSKU(result)) {
2026-08-15 05:55:55 +00:00
const subscriptionPlansForSKU = tmp12(7223).fetchSubscriptionPlansForSKU(result, closure_1);
const tmp12Result = tmp12(7223);
2026-07-20 16:05:17 +00:00
}
2026-08-15 05:55:55 +00:00
const obj3 = require(4039) /* getPremiumPlanItem */;
2026-07-20 16:05:17 +00:00
}
return value;
};
export const useGetOrFetchSubscriptionPlan = function useGetOrFetchSubscriptionPlan(subscriptionPlanId) {
2026-07-23 10:11:24 +00:00
const _require = subscriptionPlanId;
let closure_1 = arg1;
2026-07-29 08:29:29 +00:00
let items = [addSubscriptionPlan];
2026-07-23 10:11:24 +00:00
const tmp = callback(_require(first[9]).useStateFromStoresArray(items, () => {
2026-07-20 16:05:17 +00:00
let value = null;
2026-07-23 10:11:24 +00:00
if (null != closure_0) {
2026-07-29 08:29:29 +00:00
value = outer1_5.get(tmp);
2026-07-20 16:05:17 +00:00
}
const items = [value, ];
let isFetchingForSKUResult = null != value;
if (isFetchingForSKUResult) {
2026-07-23 10:11:24 +00:00
isFetchingForSKUResult = outer1_5.isFetchingForSKU(value.skuId);
2026-07-20 16:05:17 +00:00
}
items[1] = isFetchingForSKUResult;
return items;
}), 2);
2026-07-23 10:11:24 +00:00
first = tmp[0];
callback = tmp3;
2026-07-20 16:05:17 +00:00
const items1 = [first, subscriptionPlanId, arg1, tmp[1]];
const effect = React.useEffect(() => {
if (null == first) {
2026-07-23 10:11:24 +00:00
if (null != subscriptionPlanId) {
if (!_slicedToArray) {
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
callback(first[5])(null != outer1_9[tmp12], "Missing hardcoded subscriptionPlan: " + tmp12);
const tmp5 = callback(first[5]);
const tmp6 = null != outer1_9[tmp12];
2026-07-23 10:11:24 +00:00
const obj = subscriptionPlanId(first[8]);
2026-07-29 08:29:29 +00:00
const subscriptionPlansForSKU = obj.fetchSubscriptionPlansForSKU(subscriptionPlanId(first[7]).castPremiumSubscriptionAsSkuId(tmp2.skuId), callback);
2026-07-23 10:11:24 +00:00
const obj2 = subscriptionPlanId(first[7]);
2026-07-20 16:05:17 +00:00
}
}
}
}, items1);
return first;
};
export const getSubscriptionPauseDurations = function getSubscriptionPauseDurations(status) {
2026-08-15 05:55:55 +00:00
const keys = Object.keys(require(10651) /* PauseDuration */.PauseDuration);
2026-07-20 16:05:17 +00:00
const found = keys.filter((arg0) => isNaN(Number(arg0)));
if (status.status !== constants.PAUSED) {
2026-07-29 08:29:29 +00:00
let obj = { durations: null, currentDaysPaused: 0 };
obj[0] = found;
2026-07-20 16:05:17 +00:00
return obj;
} else if (null != status.pauseEndsAt) {
2026-08-15 05:55:55 +00:00
const tmp6 = importDefault(3975)(status.currentPeriodStart);
2026-07-20 16:05:17 +00:00
const _Math = Math;
2026-08-15 05:55:55 +00:00
const rounded = Math.round(importDefault(3975)(status.pauseEndsAt).diff(tmp6, "days", true));
2026-07-20 16:05:17 +00:00
const items = [];
2026-07-29 08:29:29 +00:00
for (const item10042 of found) {
let tmp11 = require;
let tmp12 = dependencyMap;
let tmp13 = dependencyMap;
let tmp10 = item10042;
2026-08-15 05:55:55 +00:00
if (require(10651) /* PauseDuration */.PauseDuration[item10042] > rounded) {
2026-07-29 08:29:29 +00:00
let tmp14 = item10042;
let arr = items.push(tmp10);
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { durations: null, currentDaysPaused: null };
obj[0] = items;
obj[1] = rounded;
2026-07-20 16:05:17 +00:00
return obj;
} else {
2026-07-29 08:29:29 +00:00
obj = { durations: null, currentDaysPaused: 0 };
obj[0] = [];
2026-07-20 16:05:17 +00:00
return obj;
}
2026-07-29 08:29:29 +00:00
const tmp = dependencyMap;
2026-07-20 16:05:17 +00:00
};
export const didBeginPurchaseFlowOnFractionalPremium = function didBeginPurchaseFlowOnFractionalPremium(isSameOrAfter) {
let isMomentResult = null != isSameOrAfter;
if (isMomentResult) {
2026-08-15 05:55:55 +00:00
isMomentResult = importDefault(3975).isMoment(isSameOrAfter);
const obj = importDefault(3975);
2026-07-20 16:05:17 +00:00
}
if (isMomentResult) {
2026-08-15 05:55:55 +00:00
isMomentResult = isSameOrAfter.isSameOrAfter(importDefault(3975)());
2026-07-20 16:05:17 +00:00
}
return isMomentResult;
};