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

190 lines
6.3 KiB
TypeScript
Raw Normal View History

2026-07-24 07:16:23 +00:00
// Module ID: 12533
// Function ID: 97059
2026-07-21 22:01:30 +00:00
// Name: getViewerProductId
2026-07-24 07:16:23 +00:00
// Dependencies: [31, 6663, 5619, 1851, 6648, 5622, 477, 5616, 3791, 566, 2]
2026-07-21 22:01:30 +00:00
// Exports: usePremiumTier2DeltaPriceString
2026-07-24 07:16:23 +00:00
// Module 12533 (getViewerProductId)
2026-07-23 10:11:24 +00:00
import result from "result";
import { useNativeCheckoutStore } from "context";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import GuildFeatures from "GuildFeatures";
let closure_5;
let closure_6;
const require = arg1;
2026-07-21 22:01:30 +00:00
function getViewerProductId(subscription) {
if (null == subscription) {
return null;
} else {
2026-07-23 10:11:24 +00:00
return require(6648) /* _createForOfIteratorHelperLoose */.getProductIdFromSubscription(tmp, false);
2026-07-21 22:01:30 +00:00
}
}
2026-07-23 10:11:24 +00:00
({ PremiumTypes: closure_5, SubscriptionIntervalTypes: closure_6 } = GuildFeatures);
let closure_7 = { priceString: null, failure: null };
let result = require("_isNativeReflectConstruct").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-23 10:11:24 +00:00
const tmp = useNativeCheckoutStore((orderRequired) => ({ orderRequired: orderRequired.orderRequired, checkoutContext: orderRequired.getCheckoutContextRecord() }));
const checkoutContext = tmp.checkoutContext;
const _require = getViewerProductId(subscription);
let obj = _require(566);
let items = [_isNativeReflectConstruct];
2026-07-21 22:01:30 +00:00
const stateFromStores = obj.useStateFromStores(items, () => {
let product = null;
if (null != closure_0) {
2026-07-23 10:11:24 +00:00
product = outer1_4.getProduct(closure_0);
2026-07-21 22:01:30 +00:00
}
return product;
});
2026-07-23 10:11:24 +00:00
let obj1 = _require(477);
2026-07-21 22:01:30 +00:00
let flag = false;
if (flag3) {
flag = false;
2026-07-23 10:11:24 +00:00
if (plan.premiumTier === TIER_2.TIER_2) {
2026-07-21 22:01:30 +00:00
flag = false;
2026-07-23 10:11:24 +00:00
if (plan.interval === constants.MONTH) {
2026-07-21 22:01:30 +00:00
flag = false;
2026-07-23 10:11:24 +00:00
if (plan.numPremiumGuild >= 1) {
let tmp6 = getViewerProductId(subscription);
let tmp8 = null;
if (null != tmp6) {
2026-07-24 07:16:23 +00:00
tmp8 = _require(5622).AppStorePremiumProductIdsToPremiumBundledItems[tmp6];
2026-07-23 10:11:24 +00:00
}
let tmp11 = null != tmp8 && tmp8.basePlanId === plan.basePlanId;
if (tmp11) {
tmp11 = 0 === tmp8.numPremiumGuild;
2026-07-21 22:01:30 +00:00
}
2026-07-23 10:11:24 +00:00
flag = tmp11;
2026-07-21 22:01:30 +00:00
}
}
}
}
if (flag) {
2026-07-23 10:11:24 +00:00
if (!tmp3) {
if (null != first) {
if (null != stateFromStores) {
const platformName = _require(477).getPlatformName();
if (first.currencyCode !== stateFromStores.currencyCode) {
obj = { priceString: null };
obj = { kind: "currency_mismatch", platform: platformName, productId: plan.productId, currencyCode: first.currencyCode };
obj.failure = obj;
let obj3 = obj;
} else {
const diff = first.price - stateFromStores.price;
if (diff > 0) {
if (diff < first.price) {
let obj4 = _require(477);
let result = diff;
if (obj4.isAndroid()) {
result = diff / 100;
}
obj1 = {};
2026-07-24 07:16:23 +00:00
let obj6 = _require(5616);
2026-07-23 10:11:24 +00:00
const obj2 = { convertToMajorUnits: false };
obj1.priceString = obj6.formatPrice(result, first.currencyCode, obj2);
obj1.failure = null;
obj3 = obj1;
2026-07-21 22:01:30 +00:00
}
}
2026-07-23 10:11:24 +00:00
obj3 = { priceString: null };
obj4 = { kind: "delta_out_of_range", platform: platformName, productId: plan.productId, currencyCode: first.currencyCode };
obj3.failure = obj4;
}
const obj14 = _require(477);
}
}
obj3 = closure_7;
}
if (null == checkoutContext) {
let tmp20 = closure_7;
} else {
const availablePlanForItems = checkoutContext.getAvailablePlanForItems(_require(6648).getSubscriptionItemsForProduct(plan.productId));
if (null != availablePlanForItems) {
const addOnPrice = availablePlanForItems.getAddOnPrice();
if (null != addOnPrice) {
if (addOnPrice.majorUnits > 0) {
const obj5 = {};
obj6 = { convertToMajorUnits: false };
2026-07-24 07:16:23 +00:00
obj5.priceString = _require(5616).formatPrice(addOnPrice.majorUnits, addOnPrice.currency, obj6);
2026-07-23 10:11:24 +00:00
obj5.failure = null;
tmp20 = obj5;
2026-07-24 07:16:23 +00:00
const obj12 = _require(5616);
2026-07-21 22:01:30 +00:00
}
}
2026-07-23 10:11:24 +00:00
tmp20 = closure_7;
2026-07-21 22:01:30 +00:00
}
2026-07-23 10:11:24 +00:00
const obj15 = _require(6648);
2026-07-21 22:01:30 +00:00
}
2026-07-23 10:11:24 +00:00
tmp20 = closure_7;
2026-07-21 22:01:30 +00:00
} else {
2026-07-23 10:11:24 +00:00
(function useReportDeltaFailure(failure) {
2026-07-21 22:01:30 +00:00
let kind;
if (null != failure) {
kind = failure.kind;
}
let tmp2 = null;
if (null != kind) {
tmp2 = kind;
}
let closure_0 = tmp2;
let platform;
if (null != failure) {
platform = failure.platform;
}
let tmp4 = null;
if (null != platform) {
tmp4 = platform;
}
2026-07-23 10:11:24 +00:00
let closure_1 = tmp4;
2026-07-21 22:01:30 +00:00
let currencyCode;
if (null != failure) {
currencyCode = failure.currencyCode;
}
let tmp6 = null;
if (null != currencyCode) {
tmp6 = currencyCode;
}
2026-07-23 10:11:24 +00:00
let result = tmp6;
2026-07-21 22:01:30 +00:00
let productId;
if (null != failure) {
productId = failure.productId;
}
let tmp8 = null;
if (null != productId) {
tmp8 = productId;
}
2026-07-23 10:11:24 +00:00
let closure_3 = tmp8;
2026-07-21 22:01:30 +00:00
const items = [tmp2, tmp4, tmp6, tmp8];
2026-07-23 10:11:24 +00:00
const effect = outer1_2.useEffect(() => {
2026-07-21 22:01:30 +00:00
if (null != tmp2) {
2026-07-23 10:11:24 +00:00
let obj = tmp2(outer2_1[8]);
2026-07-21 22:01:30 +00:00
const _Error = Error;
const _HermesInternal = HermesInternal;
const error = new Error("delta_price_integrity_" + tmp2);
obj = {};
obj = { source: "usePremiumTier2DeltaPriceString", delta_failure_kind: tmp2 };
let str2 = "unknown";
let str = "unknown";
2026-07-23 10:11:24 +00:00
if (null != closure_1) {
str = closure_1;
2026-07-21 22:01:30 +00:00
}
obj.delta_platform = str;
2026-07-23 10:11:24 +00:00
tmp2 = str2;
if (null != result) {
tmp2 = result;
2026-07-21 22:01:30 +00:00
}
obj.delta_currency_code = tmp2;
2026-07-23 10:11:24 +00:00
if (null != closure_3) {
str2 = closure_3;
2026-07-21 22:01:30 +00:00
}
obj.delta_product_id = str2;
obj.tags = obj;
const result = obj.captureBillingException(error, obj);
}
}, items);
2026-07-23 10:11:24 +00:00
})(closure_7.failure);
return closure_7.priceString;
2026-07-21 22:01:30 +00:00
}
};