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

222 lines
8.2 KiB
TypeScript
Raw Normal View History

// Module ID: 13636
// Function ID: 13637
// Name: usePremiumTier2DeltaPriceString
// Dependencies: [19, 7527, 7340, 1373, 7512, 7343, 1150, 7337, 4309, 504, 2]
2026-07-21 22:01:30 +00:00
// Exports: usePremiumTier2DeltaPriceString
// Module 13636 (usePremiumTier2DeltaPriceString)
import BillingUtils from "BillingUtils" /* 4309 */;
import PremiumBundledPlansUtils from "PremiumBundledPlansUtils" /* 7512 */;
import noop from "module_19" /* 19 */;
import IAPStore from "IAPStore" /* 7340 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
require = fn;
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 {
const productIdFromSubscription = PremiumBundledPlansUtils.getProductIdFromSubscription(subscription, false);
2026-08-06 08:05:19 +00:00
try {
const productIdFromSubscription1 = tmp3(7512).getProductIdFromSubscription(subscription, true);
const tmp8 = tmp3(7343).AppStorePremiumProductIdsToPremiumBundledItems[productIdFromSubscription];
const tmp10 = tmp3(7343).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;
const tmp3Result = tmp3(7512);
2026-08-06 08:05:19 +00:00
} catch (err) {
return tmp2;
}
2026-07-29 08:29:29 +00:00
} catch (err) {
return tmp;
}
2026-07-21 22:01:30 +00:00
}
}
const useNativeCheckoutStore = fn(7527).useNativeCheckoutStore;
const PremiumTypes = fn(1373).PremiumTypes;
const priceString = { priceString: null, failure: null };
const size = fn(2);
let result = size.fileFinishedImporting("modules/premium/native/hooks/usePremiumTier2DeltaPriceString.tsx");
2026-07-21 22:01:30 +00:00
export const usePremiumTier2DeltaPriceString = function usePremiumTier2DeltaPriceString(plan, subscription, currencyCode, flag4) {
const tmp = useNativeCheckoutStore((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);
_require = tmp3;
const items = [IAPStore];
const stateFromStores = require("initialize").useStateFromStores(items, () => {
2026-07-21 22:01:30 +00:00
let product = null;
if (null != closure_0) {
product = IAPStore.getProduct(tmp);
2026-07-21 22:01:30 +00:00
}
return product;
});
let obj = require("initialize");
const tmp2 = getViewerProductId;
let obj2 = require("PlatformUtils");
2026-07-21 22:01:30 +00:00
let flag = false;
2026-08-31 15:47:37 +00:00
if (flag4) {
2026-07-21 22:01:30 +00:00
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 = tmp2(subscription);
2026-08-03 11:20:01 +00:00
let tmp11 = null;
2026-07-31 08:44:05 +00:00
if (null != tmp2Result) {
tmp11 = tmp4(7343).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) {
if (null != currencyCode) {
2026-07-23 10:11:24 +00:00
if (null != stateFromStores) {
const platformName = tmp4(1150).getPlatformName();
if (currencyCode.currencyCode !== stateFromStores.currencyCode) {
let obj3 = { priceString: null, failure: null };
const obj4 = { kind: "currency_mismatch", platform: platformName, productId: plan.productId, currencyCode: currencyCode.currencyCode };
obj3.failure = obj4;
let obj6 = obj3;
2026-07-23 10:11:24 +00:00
} else {
const diff = currencyCode.price - stateFromStores.price;
2026-07-23 10:11:24 +00:00
if (diff > 0) {
if (diff < currencyCode.price) {
2026-07-23 10:11:24 +00:00
let result = diff;
if (tmp4Result7.isAndroid()) {
2026-07-23 10:11:24 +00:00
result = diff / 100;
}
const obj5 = { priceString: null, failure: null };
tmp4Result7 = tmp4(1150);
obj5.priceString = tmp4(7337).formatPrice(result, currencyCode.currencyCode, { convertToMajorUnits: false });
obj6 = obj5;
const tmp4Result8 = tmp4(7337);
2026-07-21 22:01:30 +00:00
}
}
obj6 = { priceString: null, failure: null };
const obj7 = { kind: "delta_out_of_range", platform: platformName, productId: plan.productId, currencyCode: currencyCode.currencyCode };
obj6.failure = obj7;
2026-07-23 10:11:24 +00:00
}
const tmp4Result = tmp4(1150);
2026-07-23 10:11:24 +00:00
}
}
obj6 = priceString;
2026-07-23 10:11:24 +00:00
}
if (null == checkoutContext) {
} else {
const availablePlanForItems = checkoutContext.getAvailablePlanForItems(tmp4(7512).getSubscriptionItemsForProduct(plan.productId));
2026-08-03 11:20:01 +00:00
if (null == availablePlanForItems) {
} 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(7343).AppStorePremiumProductIdsToPremiumBundledItems[tmp3];
2026-08-03 11:20:01 +00:00
}
if (null != tmp3) {
if (null != tmp17) {
if (0 !== tmp17.numPremiumGuild) {
const availablePlanForItems1 = checkoutContext.getAvailablePlanForItems(tmp4(7512).getSubscriptionItemsForProduct(tmp3));
2026-08-03 11:20:01 +00:00
let addOnPrice1;
if (availablePlanForItems1 != null) {
addOnPrice1 = availablePlanForItems1.getAddOnPrice();
}
if (null != addOnPrice1) {
const diff1 = addOnPrice.majorUnits - addOnPrice1.majorUnits;
if (diff1 > 0) {
const obj8 = { priceString: tmp4(7337).formatPrice(diff1, addOnPrice.currency, { convertToMajorUnits: false }), failure: null };
const tmp4Result11 = tmp4(7337);
2026-08-03 11:20:01 +00:00
}
}
const tmp4Result10 = tmp4(7512);
2026-08-03 11:20:01 +00:00
}
}
}
const obj9 = { priceString: tmp4(7337).formatPrice(addOnPrice.majorUnits, addOnPrice.currency, { convertToMajorUnits: false }), failure: null };
const tmp4Result12 = tmp4(7337);
2026-07-21 22:01:30 +00:00
}
}
}
const tmp4Result9 = tmp4(7512);
2026-07-21 22:01:30 +00:00
}
} else {
2026-08-03 11:20:01 +00:00
const failure = tmp13.failure;
closure_129_0 = undefined;
closure_129_1 = undefined;
closure_129_2 = undefined;
closure_129_3 = undefined;
let kind;
2026-07-29 08:29:29 +00:00
if (failure != null) {
kind = failure.kind;
}
if (kind == null) {
kind = null;
}
closure_129_0 = kind;
let platform;
2026-07-29 08:29:29 +00:00
if (failure != null) {
platform = failure.platform;
}
if (platform == null) {
platform = null;
}
closure_129_1 = platform;
2026-07-29 08:29:29 +00:00
currencyCode = undefined;
if (failure != null) {
currencyCode = failure.currencyCode;
}
if (currencyCode == null) {
currencyCode = null;
}
closure_129_2 = currencyCode;
let productId;
2026-07-29 08:29:29 +00:00
if (failure != null) {
productId = failure.productId;
}
if (productId == null) {
productId = null;
}
closure_129_3 = productId;
2026-07-29 08:29:29 +00:00
const items1 = [kind, platform, currencyCode, productId];
const effect = noop.useEffect(() => {
if (null != closure_0) {
2026-07-29 08:29:29 +00:00
const _Error = Error;
const _HermesInternal = HermesInternal;
const error = new Error("delta_price_integrity_" + tmp);
const obj3 = { source: "usePremiumTier2DeltaPriceString", delta_failure_kind: tmp, delta_platform: null, delta_currency_code: null, delta_product_id: null };
let str = dependencyMap;
if (dependencyMap == null) {
2026-07-29 08:29:29 +00:00
str = "unknown";
2026-07-21 22:01:30 +00:00
}
obj3.delta_platform = str;
let str2 = noop;
if (noop == null) {
2026-07-29 08:29:29 +00:00
str2 = "unknown";
}
obj3.delta_currency_code = str2;
let str3 = useNativeCheckoutStore;
if (useNativeCheckoutStore == null) {
2026-07-29 08:29:29 +00:00
str3 = "unknown";
}
const obj = { tags: null };
obj3.delta_product_id = str3;
obj.tags = obj3;
const result = BillingUtils.captureBillingException(error, obj);
2026-07-29 08:29:29 +00:00
}
}, items1);
return priceString.priceString;
2026-07-21 22:01:30 +00:00
}
};