decord/source/modules/premium/native/hooks/usePremiumTier2DeltaPriceString.tsx

232 lines
8.4 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 13036
// Function ID: 13037
2026-07-21 22:01:30 +00:00
// Name: getViewerProductId
2026-08-24 06:08:38 +00:00
// Dependencies: [19, 7433, 5324, 1924, 7416, 5327, 500, 5321, 4057, 589, 2]
2026-07-21 22:01:30 +00:00
// Exports: usePremiumTier2DeltaPriceString
2026-08-24 06:08:38 +00:00
// Module 13036 (getViewerProductId)
import getPremiumBundledItemsFromProductId from "getPremiumBundledItemsFromProductId" /* 7416 */;
import closure_2 from "noop" /* 19 */;
import { useNativeCheckoutStore } from "context" /* 7433 */;
import closure_4 from "updateProduct" /* 5324 */;
import { PremiumTypes } from "GuildFeatures" /* 1924 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-21 22:01:30 +00:00
function getViewerProductId(subscription) {
if (null == subscription) {
return null;
} else {
2026-07-29 08:29:29 +00:00
try {
2026-08-24 06:08:38 +00:00
const productIdFromSubscription = getPremiumBundledItemsFromProductId.getProductIdFromSubscription(subscription, false);
2026-08-06 08:05:19 +00:00
try {
2026-08-24 06:08:38 +00:00
const productIdFromSubscription1 = tmp3(7416).getProductIdFromSubscription(subscription, true);
const tmp8 = tmp3(5327).AppStorePremiumProductIdsToPremiumBundledItems[productIdFromSubscription];
const tmp10 = tmp3(5327).AppStorePremiumProductIdsToPremiumBundledItems[productIdFromSubscription1];
2026-08-06 08:05:19 +00:00
if (null != tmp8) {
if (null != tmp10) {
if (tmp8.numPremiumGuild === tmp10.numPremiumGuild) {
let tmp11 = productIdFromSubscription1;
}
return tmp11;
}
}
tmp11 = productIdFromSubscription;
2026-08-24 06:08:38 +00:00
const tmp3Result = tmp3(7416);
2026-08-06 08:05:19 +00:00
} catch (err) {
return tmp2;
}
2026-08-24 06:08:38 +00:00
const obj = getPremiumBundledItemsFromProductId;
2026-07-29 08:29:29 +00:00
} catch (err) {
return tmp;
}
2026-07-21 22:01:30 +00:00
}
}
2026-07-31 08:44:05 +00:00
let closure_6 = { priceString: null, failure: null };
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/premium/native/hooks/usePremiumTier2DeltaPriceString.tsx");
2026-07-21 22:01:30 +00:00
export const usePremiumTier2DeltaPriceString = function usePremiumTier2DeltaPriceString(plan, subscription, first, flag3) {
2026-07-29 08:29:29 +00:00
const tmp = productId((orderRequired) => ({ orderRequired: orderRequired.orderRequired, checkoutContext: orderRequired.getCheckoutContextRecord() }));
2026-07-23 10:11:24 +00:00
const checkoutContext = tmp.checkoutContext;
2026-08-03 11:20:01 +00:00
const tmp3 = getViewerProductId(subscription);
let kind = tmp3;
2026-07-29 08:29:29 +00:00
let obj = kind(platform[9]);
2026-08-24 06:08:38 +00:00
const items = [closure_4];
2026-07-21 22:01:30 +00:00
const stateFromStores = obj.useStateFromStores(items, () => {
let product = null;
2026-07-29 08:29:29 +00:00
if (null != kind) {
2026-08-24 06:08:38 +00:00
product = closure_1_4.getProduct(tmp);
2026-07-21 22:01:30 +00:00
}
return product;
});
2026-08-24 06:08:38 +00:00
obj1 = kind(platform[6]);
2026-07-21 22:01:30 +00:00
let flag = false;
if (flag3) {
flag = false;
2026-07-31 08:44:05 +00:00
if (plan.premiumTier === PremiumTypes.TIER_2) {
2026-07-21 22:01:30 +00:00
flag = false;
2026-07-31 08:44:05 +00:00
if (plan.numPremiumGuild >= 1) {
const tmp2Result = getViewerProductId(subscription);
2026-08-03 11:20:01 +00:00
let tmp11 = null;
2026-07-31 08:44:05 +00:00
if (null != tmp2Result) {
2026-08-03 11:20:01 +00:00
tmp11 = tmp4(tmp5[5]).AppStorePremiumProductIdsToPremiumBundledItems[tmp2Result];
2026-07-21 22:01:30 +00:00
}
2026-08-03 11:20:01 +00:00
flag = null != tmp11 && tmp11.basePlanId === plan.basePlanId && tmp11.numPremiumGuild < plan.numPremiumGuild;
const tmp12 = null != tmp11 && tmp11.basePlanId === plan.basePlanId && tmp11.numPremiumGuild < plan.numPremiumGuild;
2026-07-21 22:01:30 +00:00
}
}
}
if (flag) {
2026-08-03 11:20:01 +00:00
if (!tmp7) {
2026-07-23 10:11:24 +00:00
if (null != first) {
if (null != stateFromStores) {
2026-08-03 11:20:01 +00:00
let tmp4Result = tmp4(tmp5[6]);
const platformName = tmp4Result.getPlatformName();
2026-07-23 10:11:24 +00:00
if (first.currencyCode !== stateFromStores.currencyCode) {
2026-07-29 08:29:29 +00:00
obj = { priceString: null, failure: null };
obj = { kind: "currency_mismatch", platform: null, productId: null, currencyCode: null };
obj[1] = platformName;
obj[2] = plan.productId;
obj[3] = first.currencyCode;
obj[1] = obj;
let obj2 = obj;
2026-07-23 10:11:24 +00:00
} else {
const diff = first.price - stateFromStores.price;
if (diff > 0) {
if (diff < first.price) {
2026-08-03 11:20:01 +00:00
tmp4Result = tmp4(tmp5[6]);
2026-07-23 10:11:24 +00:00
let result = diff;
2026-08-03 11:20:01 +00:00
if (tmp4Result.isAndroid()) {
2026-07-23 10:11:24 +00:00
result = diff / 100;
}
2026-07-29 08:29:29 +00:00
obj1 = { priceString: null, failure: null };
2026-08-03 11:20:01 +00:00
obj1[0] = tmp4(tmp5[7]).formatPrice(result, first.currencyCode, { convertToMajorUnits: false });
2026-07-29 08:29:29 +00:00
obj2 = obj1;
2026-08-03 11:20:01 +00:00
const tmp4Result1 = tmp4(tmp5[7]);
2026-07-21 22:01:30 +00:00
}
}
2026-07-29 08:29:29 +00:00
obj2 = { priceString: null, failure: null };
const obj3 = { kind: "delta_out_of_range", platform: null, productId: null, currencyCode: null };
obj3[1] = platformName;
obj3[2] = plan.productId;
obj3[3] = first.currencyCode;
obj2[1] = obj3;
2026-07-23 10:11:24 +00:00
}
}
}
2026-07-31 08:44:05 +00:00
obj2 = closure_6;
2026-07-23 10:11:24 +00:00
}
if (null == checkoutContext) {
2026-08-03 11:20:01 +00:00
let tmp20 = closure_6;
2026-07-23 10:11:24 +00:00
} else {
2026-08-03 11:20:01 +00:00
const availablePlanForItems = checkoutContext.getAvailablePlanForItems(tmp4(tmp5[4]).getSubscriptionItemsForProduct(plan.productId));
if (null == availablePlanForItems) {
tmp20 = closure_6;
} else {
2026-07-23 10:11:24 +00:00
const addOnPrice = availablePlanForItems.getAddOnPrice();
if (null != addOnPrice) {
if (addOnPrice.majorUnits > 0) {
2026-08-03 11:20:01 +00:00
let tmp17 = null;
if (null != tmp3) {
tmp17 = tmp4(tmp5[5]).AppStorePremiumProductIdsToPremiumBundledItems[tmp3];
}
if (null != tmp3) {
if (null != tmp17) {
if (0 !== tmp17.numPremiumGuild) {
const availablePlanForItems1 = checkoutContext.getAvailablePlanForItems(tmp4(tmp5[4]).getSubscriptionItemsForProduct(tmp3));
let addOnPrice1;
if (availablePlanForItems1 != null) {
addOnPrice1 = availablePlanForItems1.getAddOnPrice();
}
if (null != addOnPrice1) {
const diff1 = addOnPrice.majorUnits - addOnPrice1.majorUnits;
if (diff1 > 0) {
const obj4 = { priceString: null, failure: null };
obj4[0] = tmp4(tmp5[7]).formatPrice(diff1, addOnPrice.currency, { convertToMajorUnits: false });
tmp20 = obj4;
const tmp4Result4 = tmp4(tmp5[7]);
} else {
tmp20 = closure_6;
}
}
const tmp4Result3 = tmp4(tmp5[4]);
}
tmp20 = closure_6;
}
}
const obj5 = { priceString: null, failure: null };
obj5[0] = tmp4(tmp5[7]).formatPrice(addOnPrice.majorUnits, addOnPrice.currency, { convertToMajorUnits: false });
tmp20 = obj5;
const tmp4Result5 = tmp4(tmp5[7]);
2026-07-21 22:01:30 +00:00
}
}
2026-08-03 11:20:01 +00:00
tmp20 = closure_6;
2026-07-21 22:01:30 +00:00
}
2026-08-03 11:20:01 +00:00
const tmp4Result2 = tmp4(tmp5[4]);
2026-07-21 22:01:30 +00:00
}
} else {
2026-08-03 11:20:01 +00:00
const failure = tmp13.failure;
2026-07-29 08:29:29 +00:00
kind = undefined;
platform = undefined;
let currencyCode;
productId = undefined;
kind = undefined;
if (failure != null) {
kind = failure.kind;
}
if (kind == null) {
kind = null;
}
platform = undefined;
if (failure != null) {
platform = failure.platform;
}
if (platform == null) {
platform = null;
}
currencyCode = undefined;
if (failure != null) {
currencyCode = failure.currencyCode;
}
if (currencyCode == null) {
currencyCode = null;
}
productId = undefined;
if (failure != null) {
productId = failure.productId;
}
if (productId == null) {
productId = null;
}
const items1 = [kind, platform, currencyCode, productId];
const effect = currencyCode.useEffect(() => {
2026-07-21 22:01:30 +00:00
if (null != kind) {
2026-07-29 08:29:29 +00:00
const _Error = Error;
const _HermesInternal = HermesInternal;
2026-08-24 06:08:38 +00:00
error = new Error("delta_price_integrity_" + tmp);
2026-07-29 08:29:29 +00:00
let obj = { source: "usePremiumTier2DeltaPriceString", delta_failure_kind: null, delta_platform: null, delta_currency_code: null, delta_product_id: null };
obj[1] = tmp;
let str = platform;
if (platform == null) {
str = "unknown";
2026-07-21 22:01:30 +00:00
}
2026-07-29 08:29:29 +00:00
obj[2] = str;
let str2 = currencyCode;
if (currencyCode == null) {
str2 = "unknown";
}
obj[3] = str2;
let str3 = productId;
if (productId == null) {
str3 = "unknown";
}
obj = { tags: null };
obj[4] = str3;
obj[0] = obj;
const result = kind(platform[8]).captureBillingException(error, obj);
const obj2 = kind(platform[8]);
}
}, items1);
2026-07-31 08:44:05 +00:00
return closure_6.priceString;
2026-07-21 22:01:30 +00:00
}
};