326 lines
15 KiB
TypeScript
326 lines
15 KiB
TypeScript
/* Metro module 7561; source: modules/premium/PremiumSubscriptionOfferUtil.tsx; dependencies: [57, 31, 3808, 1880, 7062, 7287, 7258, 566, 3738, 7259, 7507, 1909, 7288, 2] */
|
|
function _fun60777(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#60777, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:6, offset: 0x0170e8ca, size: 381 bytes, params: 8, frame: 19
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_60780 = function(a0, a1) {
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var value3;
|
|
var length;
|
|
var value5;
|
|
var value = undefined;
|
|
var value2 = value == null;
|
|
reducibleJoin2: while (true) {
|
|
if (value2) {
|
|
r0 = value2;
|
|
break reducibleJoin2;
|
|
}
|
|
value3 = value > a0.length;
|
|
r0 = value3;
|
|
break reducibleJoin2;
|
|
}
|
|
reducibleJoin4: while (true) {
|
|
if (r0) {
|
|
length = a0.length;
|
|
r1 = length;
|
|
break reducibleJoin4;
|
|
}
|
|
r1 = value;
|
|
break reducibleJoin4;
|
|
}
|
|
value = (0, global.Array)(r1);
|
|
var value4 = 0;
|
|
if (value4 < r1) {
|
|
r2 = value4;
|
|
reducibleLoop5: while (true) {
|
|
value[r2] = a0[r2];
|
|
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
if (value5 < r1) {
|
|
r2 = value5;
|
|
continue reducibleLoop5;
|
|
}
|
|
break reducibleLoop5;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(57) /* metro dependency 57 */;
|
|
const env0_4 = importAll(31) /* metro dependency 31 */;
|
|
const subscriptionStore = importDefault(3808) /* metro dependency 3808: SubscriptionStore */;
|
|
const premiumConstantsModule = require(1880) /* metro dependency 1880: PremiumConstants */;
|
|
const env0_6 = premiumConstantsModule.PREMIUM_TIER_2_ANNUAL_20_PERCENT_DISCOUNT_ID;
|
|
const env0_7 = premiumConstantsModule.PREMIUM_TIER_2_ANNUAL_25_PERCENT_DISCOUNT_ID;
|
|
const env0_8 = premiumConstantsModule.PREMIUM_TIER_2_ANNUAL_V2_20_PERCENT_DISCOUNT_ID;
|
|
const env0_9 = premiumConstantsModule.PREMIUM_TIER_2_ANNUAL_V2_30_PERCENT_DISCOUNT_ID;
|
|
const env0_10 = premiumConstantsModule.PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID;
|
|
const env0_11 = premiumConstantsModule.PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID;
|
|
const env0_12 = premiumConstantsModule.PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_30_PERCENT_DISCOUNT_ID;
|
|
const env0_13 = premiumConstantsModule.PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_40_PERCENT_DISCOUNT_ID;
|
|
const env0_14 = premiumConstantsModule.PREMIUM_TIER_2_LIKELIHOOD_DISCOUNT_ID;
|
|
const env0_15 = premiumConstantsModule.PREMIUM_TIER_2_REACTIVATION_DISCOUNT_ID;
|
|
const env0_16 = premiumConstantsModule.PREMIUM_TIER_2_REENGAGEMENT_1_MONTH_40_PERCENT_DISCOUNT_ID;
|
|
const env0_17 = premiumConstantsModule.PREMIUM_GROUP_30_PERCENT_3_MONTH_DISCOUNT_ID;
|
|
const closure = useHasDiscountApplied;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/premium/PremiumSubscriptionOfferUtil.tsx');
|
|
exports.useIsInPremiumOfferExperience = useIsInPremiumOfferExperience;
|
|
exports.useHasDiscountApplied = closure;
|
|
exports.useActiveDiscountInfo = useActiveDiscountInfo;
|
|
exports.useFetchChurnUserDiscountOffer = useFetchChurnUserDiscountOffer;
|
|
exports.useShouldFetchChurnOffer = useShouldFetchChurnOffer;
|
|
exports.renewalInvoiceChurnDiscountInfo = renewalInvoiceChurnDiscountInfo;
|
|
exports.useIsNUXEligible = useIsNUXEligible;
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_60778(a0, a1) { // fn#60778, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:754, offset: 0x0170ea47, size: 370 bytes, params: 3, frame: 20
|
|
var r6;
|
|
var r9;
|
|
var r5;
|
|
var value3;
|
|
var regexp;
|
|
const env0_0 = a0;
|
|
const Symbol = global.Symbol;
|
|
let value = typeof Symbol !== 'undefined';
|
|
let r1 = value && a0[global.Symbol.iterator];
|
|
r1 = !r1 ? a0['@@iterator'] : r1;
|
|
if (r1) {
|
|
value = r1.call(a0);
|
|
return value.next.bind(value);
|
|
}
|
|
const Array = global.Array;
|
|
if (Array.isArray(a0)) {
|
|
if (r1) {
|
|
}
|
|
return _fun60779;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_60780(a0, value);
|
|
r5 = value;
|
|
} else {
|
|
value3 = ({}).toString.call(a0).slice(8, -1);
|
|
r6 = value3 === 'Object' && a0.constructor;
|
|
r9 = r6 ? a0.constructor.name : value3;
|
|
if (r9 === 'Map') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Set') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Arguments') {
|
|
value = _arrayLikeToArray_60780(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_60780(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun60779;
|
|
}
|
|
const TypeError = global.TypeError;
|
|
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
|
|
}
|
|
|
|
function useHasDiscountApplied() { // fn#60781, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:1690, offset: 0x0170ebb9, size: 156 bytes, params: 1, frame: 18
|
|
var r0;
|
|
var Date;
|
|
var value;
|
|
const value2 = undefined;
|
|
const premiumTypeSubscription = (require(566) /* metro dependency 566: flux */).useStateFromStores([SubscriptionStore],
|
|
function() {
|
|
return SubscriptionStore.getPremiumTypeSubscription();
|
|
});
|
|
const active_discount_expires_at = premiumTypeSubscription == null || premiumTypeSubscription.metadata == null ? value2 : premiumTypeSubscription.metadata.active_discount_expires_at;
|
|
const value3 = active_discount_expires_at != null;
|
|
if (value3) {
|
|
value = importDefault(3738) /* metro dependency 3738 */;
|
|
Date = global.Date;
|
|
value = value(Date.now());
|
|
value = value <= (importDefault(3738) /* metro dependency 3738 */)(active_discount_expires_at);
|
|
r0 = value;
|
|
} else {
|
|
r0 = value3;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function useIsInPremiumOfferExperience() { // fn#60783, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:2007, offset: 0x0170ec68, size: 140 bytes, params: 1, frame: 17
|
|
const value2 = (require(7062) /* metro dependency 7062: usePremiumTrialOfferNative */).usePremiumTrialOffer();
|
|
const value3 = (require(7287) /* metro dependency 7287: PremiumSubscriptionTrialUtil */).useHasActiveTrial();
|
|
const value4 = (require(7258) /* metro dependency 7258: usePremiumDiscountOfferAndroid */).usePremiumDiscountOffer();
|
|
const value5 = (require(7258) /* metro dependency 7258: usePremiumDiscountOfferAndroid */).usePremiumGroupDiscountOffer();
|
|
const value = useHasDiscountApplied();
|
|
let r0 = value2 != null || value3;
|
|
r0 = !r0 ? value4 != null : r0;
|
|
r0 = !r0 ? value5 != null : r0;
|
|
r0 = !r0 ? value : r0;
|
|
return r0;
|
|
}
|
|
|
|
function useActiveDiscountInfo() { // fn#60784, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:2334, offset: 0x0170ecf4, size: 395 bytes, params: 1, frame: 15
|
|
const value2 = undefined;
|
|
const premiumTypeSubscription = (require(566) /* metro dependency 566: flux */).useStateFromStores([SubscriptionStore],
|
|
function() {
|
|
return SubscriptionStore.getPremiumTypeSubscription();
|
|
});
|
|
const active_discount_id = premiumTypeSubscription == null || premiumTypeSubscription.metadata == null ? value2 : premiumTypeSubscription.metadata.active_discount_id;
|
|
if (PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 1, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_30_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 1, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 3, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_LIKELIHOOD_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 3, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_REACTIVATION_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 3, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_40_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 1, 'percentage': 40, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_ANNUAL_20_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 1, 'percentage': 20, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_ANNUAL_25_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 1, 'percentage': 25, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_ANNUAL_V2_20_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 12, 'percentage': 20, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_ANNUAL_V2_30_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 12, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_TIER_2_REENGAGEMENT_1_MONTH_40_PERCENT_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 1, 'percentage': 40, discountId: active_discount_id};
|
|
}
|
|
if (PREMIUM_GROUP_30_PERCENT_3_MONTH_DISCOUNT_ID === active_discount_id) {
|
|
return {'duration': 3, 'percentage': 30, discountId: active_discount_id};
|
|
}
|
|
return value2;
|
|
}
|
|
|
|
function useFetchChurnUserDiscountOffer(a0) { // fn#60786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:3038, offset: 0x0170ee7f, size: 321 bytes, params: 2, frame: 25
|
|
var value;
|
|
const value2 = (importDefault(7259) /* metro dependency 7259: useDiscountOffer */)(PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID);
|
|
const value3 = (importDefault(7259) /* metro dependency 7259: useDiscountOffer */)(PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID);
|
|
const binding = env0_4;
|
|
let useState = binding.useState;
|
|
const value4 = Reflect.apply(useState, binding, [false]);
|
|
const binding2 = env0_3;
|
|
const value5 = binding2(value4, 2);
|
|
const property = value5[0];
|
|
const env0_0 = value5[1];
|
|
useState = binding.useState;
|
|
const value6 = binding2(Reflect.apply(useState, binding, [false]), 2);
|
|
const property2 = value6[0];
|
|
const property3 = value6[1];
|
|
useState = binding.useState;
|
|
const value7 = null;
|
|
const value8 = binding2(Reflect.apply(useState, binding, [value7]), 2);
|
|
const property4 = value8[0];
|
|
const env0_2 = value8[1];
|
|
const r10 = value7 == value2 ? value3 : value2;
|
|
const r2 = value7 != r10 ? r10 : value7;
|
|
if (value7 != r2) {
|
|
return {churnUserDiscountOffer: r2, isFetchingChurnDiscountOffer: false};
|
|
}
|
|
if (!a0) {
|
|
if (!(property2 || property)) {
|
|
property3(true);
|
|
value = require(7507) /* metro dependency 7507: UserOfferActionCreators */;
|
|
value = value.fetchChurnDiscountOffer();
|
|
value = value.then(_fun60788);
|
|
value.catch(function() {
|
|
onFetchComplete();
|
|
});
|
|
}
|
|
}
|
|
return {churnUserDiscountOffer: property4, isFetchingChurnDiscountOffer: property2};
|
|
}
|
|
|
|
function useShouldFetchChurnOffer() { // fn#60790, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:3623, offset: 0x0170eff8, size: 113 bytes, params: 1, frame: 15
|
|
const premiumTypeSubscription = (require(566) /* metro dependency 566: flux */).useStateFromStores([SubscriptionStore],
|
|
function() {
|
|
return SubscriptionStore.getPremiumTypeSubscription();
|
|
});
|
|
const value = useHasDiscountApplied();
|
|
let r0 = premiumTypeSubscription !== null && premiumTypeSubscription.hasPremiumNitroMonthly;
|
|
r0 = r0 && !value && !!(premiumTypeSubscription == null || !premiumTypeSubscription.hasActiveTrial);
|
|
return r0;
|
|
}
|
|
|
|
function renewalInvoiceChurnDiscountInfo({invoiceItems}) { // fn#60792, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:3852, offset: 0x0170f069, size: 183 bytes, params: 2, frame: 17
|
|
var r3;
|
|
var value4;
|
|
var discounts;
|
|
var find;
|
|
var value5;
|
|
var discount_id;
|
|
var value6;
|
|
const value2 = _createForOfIteratorHelperLoose_60778(invoiceItems);
|
|
const value3 = value2();
|
|
let done = value3.done;
|
|
if (!done) {
|
|
r3 = value3;
|
|
reducibleLoop1: while (true) {
|
|
value4 = r3.value;
|
|
discounts = value4.discounts;
|
|
find = discounts.find;
|
|
value5 = Reflect.apply(find, discounts, [function({type}) {
|
|
return type === require(dependencyMap[11]).InvoiceDiscountTypes.SUBSCRIPTION_PLAN;
|
|
}]);
|
|
if (value5 != null) {
|
|
discount_id = value5.discount_id;
|
|
if (PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID === discount_id) {
|
|
return {duration: 1, percentage: value5.percentage_amount, discountId: value5.discount_id};
|
|
}
|
|
reducibleJoin4: while (true) {
|
|
if (PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID === discount_id) {
|
|
return {duration: 3, percentage: value5.percentage_amount, discountId: value5.discount_id};
|
|
}
|
|
break reducibleJoin4;
|
|
}
|
|
}
|
|
value6 = value2();
|
|
done = value6.done;
|
|
if (done) {
|
|
return null;
|
|
}
|
|
r3 = value6;
|
|
continue reducibleLoop1;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function useIsNUXEligible() { // fn#60794, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:4256, offset: 0x0170f153, size: 37 bytes, params: 1, frame: 11
|
|
return (require(7288) /* metro dependency 7288: ReverseTrialUtilsNative */).useIsInReverseTrial();
|
|
}
|
|
|
|
function onFetchComplete() { // fn#60787, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:3392, owner: useFetchChurnUserDiscountOffer.onFetchComplete, offset: 0x0170efc0, size: 29 bytes, params: 1, frame: 12
|
|
env0_0(true);
|
|
env0_1(false);
|
|
}
|
|
|
|
function _fun60788(a0) { // fn#60788, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7739:3472, offset: 0x0170efdd, size: 27 bytes, params: 2, frame: 12
|
|
env0_2(a0);
|
|
onFetchComplete();
|
|
}
|
|
|