434 lines
20 KiB
TypeScript
434 lines
20 KiB
TypeScript
/* Metro module 7027; source: modules/premium/native/PremiumBundledPlansUtils.tsx; dependencies: [57, 1880, 5143, 2] */
|
|
import Module00057 from '../../../by-id/module-00057.js'; /* Metro dependency 57 */
|
|
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as PremiumConstantsModule from '../PremiumConstants.tsx'; /* Metro dependency 1880 */
|
|
import * as ProductIdsAndroidModule from './ProductIds.android.tsx'; /* Metro dependency 5143 */
|
|
|
|
function _fun55675(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#55675, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:6, offset: 0x013adcbf, size: 343 bytes, params: 8, frame: 25
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_55678 = 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 getPremiumBundleWithPredicate2 = getPremiumBundleWithPredicate;
|
|
const getPremiumBundledItemsFromProductId2 = getPremiumBundledItemsFromProductId;
|
|
const getToggledIntervalProduct2 = getToggledIntervalProduct;
|
|
const isValidBundleProductId2 = isValidBundleProductId;
|
|
const getSubscriptionItemsForProduct2 = getSubscriptionItemsForProduct;
|
|
const makeExternalPaymentGatewayPlanIdOrThrow2 = makeExternalPaymentGatewayPlanIdOrThrow;
|
|
const getProductIdFromSubscriptionItems2 = getProductIdFromSubscriptionItems;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/premium/native/PremiumBundledPlansUtils.tsx');
|
|
exports.getPremiumBundlesWithPredicate = getPremiumBundlesWithPredicate;
|
|
exports.getPremiumBundleWithPredicate = getPremiumBundleWithPredicate2;
|
|
exports.getPremiumBundledItemsFromProductId = getPremiumBundledItemsFromProductId2;
|
|
exports.getToggledIntervalProduct = getToggledIntervalProduct2;
|
|
exports.getProductIdsForBothIntervals = function(a0) {
|
|
var r0;
|
|
var object;
|
|
var interval;
|
|
var value = a0;
|
|
var value3 = getPremiumBundledItemsFromProductId(value);
|
|
var value4 = getToggledIntervalProduct(value);
|
|
if (value4 == null) {
|
|
r0 = {monthly: value, yearly: null};
|
|
} else {
|
|
object = {};
|
|
interval = value3.interval;
|
|
object.monthly = interval !== SubscriptionIntervalTypes.MONTH ? value4 : value;
|
|
interval = value3.interval;
|
|
object.yearly = interval !== SubscriptionIntervalTypes.YEAR ? value4 : value;
|
|
r0 = object;
|
|
}
|
|
return r0;
|
|
};
|
|
exports.productsHaveSamePerks = productsHaveSamePerks;
|
|
exports.isValidBundleProductId = isValidBundleProductId2;
|
|
exports.shouldAlwaysExcludeFromPlanSelect = shouldAlwaysExcludeFromPlanSelect;
|
|
exports.getSubscriptionItemsForProduct = getSubscriptionItemsForProduct2;
|
|
exports.makeExternalPaymentGatewayPlanIdOrThrow = makeExternalPaymentGatewayPlanIdOrThrow2;
|
|
exports.getProductIdFromSubscriptionItems = getProductIdFromSubscriptionItems2;
|
|
exports.getProductIdFromSubscription = getProductIdFromSubscription;
|
|
function _createForOfIteratorHelperLoose_55676(a0, a1) { // fn#55676, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:190, offset: 0x013ade16, 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 _fun55677;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_55678(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_55678(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_55678(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun55677;
|
|
}
|
|
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 _fun55677() { // fn#55677, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:761, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
|
|
return env0_1 >= env0_0.length ? {done: true} : {done: false,
|
|
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
|
|
}
|
|
|
|
}
|
|
|
|
function getPremiumBundleWithPredicate(a0) { // fn#55679, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:1100, offset: 0x013adf88, size: 65 bytes, params: 2, frame: 13
|
|
const Object = global.Object;
|
|
const values = Object.values;
|
|
const AppStorePremiumProductIdsToPremiumBundledItems = (ProductIdsAndroidModule).AppStorePremiumProductIdsToPremiumBundledItems;
|
|
return Reflect.apply(values, Object, [AppStorePremiumProductIdsToPremiumBundledItems]).find(a0);
|
|
}
|
|
|
|
function getPremiumBundledItemsFromProductId(a0) { // fn#55680, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:1228, offset: 0x013adfc9, size: 122 bytes, params: 2, frame: 15
|
|
const AppStorePremiumProductIdsToPremiumBundledItems = (ProductIdsAndroidModule).AppStorePremiumProductIdsToPremiumBundledItems;
|
|
if (a0 in AppStorePremiumProductIdsToPremiumBundledItems) {
|
|
return AppStorePremiumProductIdsToPremiumBundledItems[a0];
|
|
}
|
|
const Error = global.Error;
|
|
const value = 'Invalid bundled product ID ' + a0;
|
|
const value2 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
const error = new Error();
|
|
throw error instanceof Object ? error : value2;
|
|
}
|
|
|
|
function getToggledIntervalProduct(a0) { // fn#55681, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:1460, offset: 0x013ae043, size: 81 bytes, params: 2, frame: 15
|
|
var r0;
|
|
var premiumBundleWithPredicate;
|
|
const getPremiumBundledItemsFromProductIdBinding = getPremiumBundledItemsFromProductId;
|
|
const value2 = undefined;
|
|
const premiumTier = getPremiumBundledItemsFromProductIdBinding(a0).premiumTier;
|
|
const TIER_1 = PremiumTypes.TIER_1;
|
|
const value4 = null;
|
|
if (premiumTier === TIER_1) {
|
|
r0 = value4;
|
|
} else {
|
|
premiumBundleWithPredicate = getPremiumBundleWithPredicate(_fun55682);
|
|
r0 = value4 == premiumBundleWithPredicate ? value2 : premiumBundleWithPredicate.productId;
|
|
}
|
|
return r0;
|
|
function _fun55682(a0) { // fn#55682, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:1622, offset: 0x013ae094, size: 86 bytes, params: 2, frame: 5
|
|
return a0.numPremiumGuild === env0_0.numPremiumGuild && a0.premiumTier === env0_0.premiumTier && a0.interval !== env0_0.interval && !a0.isDeprecated;
|
|
}
|
|
|
|
}
|
|
|
|
function isValidBundleProductId(a0) { // fn#55683, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:1758, offset: 0x013ae0ea, size: 49 bytes, params: 2, frame: 13
|
|
return a0 != null && a0 in (require(5143) /* metro dependency 5143: ProductIdsAndroid */).AppStorePremiumProductIdsToPremiumBundledItems;
|
|
}
|
|
|
|
function getSubscriptionItemsForProduct(a0) { // fn#55684, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:1870, offset: 0x013ae11b, size: 219 bytes, params: 2, frame: 16
|
|
var r2;
|
|
var premiumBundledItemsFromProductId;
|
|
var items2;
|
|
var basePlanId;
|
|
var push;
|
|
var value4;
|
|
var done;
|
|
var value5;
|
|
var planId;
|
|
var quantity;
|
|
var value6;
|
|
var value;
|
|
if (isValidBundleProductId(a0)) {
|
|
premiumBundledItemsFromProductId = getPremiumBundledItemsFromProductId(a0);
|
|
items2 = [];
|
|
basePlanId = premiumBundledItemsFromProductId.basePlanId;
|
|
reducibleJoin4: while (true) {
|
|
if (basePlanId === SubscriptionPlans.NONE_MONTH) {
|
|
break reducibleJoin4;
|
|
}
|
|
push = items2.push;
|
|
basePlanId = premiumBundledItemsFromProductId.basePlanId;
|
|
Reflect.apply(push, items2, [{planId: basePlanId, quantity: 1}]);
|
|
break reducibleJoin4;
|
|
}
|
|
value = _createForOfIteratorHelperLoose_55676(premiumBundledItemsFromProductId.additionalPlans);
|
|
value4 = value();
|
|
done = value4.done;
|
|
if (!done) {
|
|
r2 = value4;
|
|
reducibleLoop5: while (true) {
|
|
value5 = r2.value;
|
|
push = items2.push;
|
|
planId = value5.planId;
|
|
quantity = value5.quantity;
|
|
Reflect.apply(push, items2, [{planId: planId, quantity: quantity}]);
|
|
value6 = value();
|
|
done = value6.done;
|
|
if (done) {
|
|
break reducibleLoop5;
|
|
}
|
|
r2 = value6;
|
|
continue reducibleLoop5;
|
|
}
|
|
}
|
|
return items2;
|
|
}
|
|
const Error = global.Error;
|
|
value = 'Invalid product ' + a0;
|
|
const value2 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
const error = new Error();
|
|
throw error instanceof Object ? error : value2;
|
|
}
|
|
|
|
function makeExternalPaymentGatewayPlanIdOrThrow(a0) { // fn#55685, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:2251, offset: 0x013ae1f6, size: 140 bytes, params: 2, frame: 13
|
|
if (a0 == null) {
|
|
throw new global.Error('Invalid null plan ID');
|
|
}
|
|
if (isValidBundleProductId(a0)) {
|
|
return a0;
|
|
}
|
|
const value2 = a0 + '.1';
|
|
if (isValidBundleProductId(value2)) {
|
|
return value2;
|
|
}
|
|
const Error = global.Error;
|
|
const value = 'Invalid plan ID ' + a0;
|
|
const value3 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
const error = new Error();
|
|
throw error instanceof Object ? error : value3;
|
|
}
|
|
|
|
function aggregateQuantitiesByPlanId(a0) { // fn#55686, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:2483, offset: 0x013ae282, size: 130 bytes, params: 2, frame: 21
|
|
var r2;
|
|
var r1;
|
|
var value5;
|
|
var planId;
|
|
var quantity;
|
|
var set;
|
|
var value6;
|
|
var value7;
|
|
var value8;
|
|
const Map = global.Map;
|
|
const map = new Map();
|
|
const value3 = _createForOfIteratorHelperLoose_55676(a0);
|
|
const value4 = value3();
|
|
let done = value4.done;
|
|
if (!done) {
|
|
r2 = value4;
|
|
while (true) {
|
|
value5 = r2.value;
|
|
planId = value5.planId;
|
|
quantity = value5.quantity;
|
|
set = map.set;
|
|
value6 = map.get(planId);
|
|
value7 = 0;
|
|
r1 = value6 ?? value7;
|
|
Reflect.apply(set, map, [planId, r1 + quantity]);
|
|
value8 = value3();
|
|
done = value8.done;
|
|
if (done) {
|
|
break;
|
|
}
|
|
r2 = value8;
|
|
continue;
|
|
}
|
|
}
|
|
return map;
|
|
}
|
|
|
|
function planQuantityMapsEqual(a0, a1) { // fn#55687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:2681, offset: 0x013ae304, size: 120 bytes, params: 3, frame: 20
|
|
var value4;
|
|
var value5;
|
|
var property;
|
|
var property2;
|
|
var get;
|
|
var value6;
|
|
if (a0.size === a1.size) {
|
|
var value2 = _createForOfIteratorHelperLoose_55676(a0);
|
|
var value3 = value2();
|
|
var done = value3.done;
|
|
if (done) {
|
|
return true;
|
|
}
|
|
var r1 = value3;
|
|
loopExit2: while (true) {
|
|
value4 = r1.value;
|
|
value5 = Module00057(value4, 2);
|
|
property = value5[0];
|
|
property2 = value5[1];
|
|
get = a1.get;
|
|
if (Reflect.apply(get, a1, [property]) !== property2) {
|
|
break loopExit2;
|
|
}
|
|
value6 = value2();
|
|
done = value6.done;
|
|
if (done) {
|
|
return true;
|
|
}
|
|
r1 = value6;
|
|
continue;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function getProductIdFromSubscriptionItems(a0) { // fn#55688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:2879, offset: 0x013ae37c, size: 158 bytes, params: 2, frame: 19
|
|
var r3;
|
|
var property;
|
|
var value5;
|
|
const value2 = aggregateQuantitiesByPlanId(a0);
|
|
const Object = global.Object;
|
|
const keys = Object.keys;
|
|
const AppStorePremiumProductIdsToPremiumBundledItems = (ProductIdsAndroidModule).AppStorePremiumProductIdsToPremiumBundledItems;
|
|
const value3 = Reflect.apply(keys, Object, [AppStorePremiumProductIdsToPremiumBundledItems]);
|
|
let length = value3.length;
|
|
const value4 = 0;
|
|
if (value4 < length) {
|
|
r3 = value4;
|
|
loopExit1: while (true) {
|
|
property = value3[r3];
|
|
if (planQuantityMapsEqual(value2, aggregateQuantitiesByPlanId(getSubscriptionItemsForProduct(property)))) {
|
|
return property;
|
|
}
|
|
value5 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
|
|
length = value3.length;
|
|
if (value5 < length) {
|
|
r3 = value5;
|
|
continue;
|
|
}
|
|
break loopExit1;
|
|
}
|
|
}
|
|
const Error = global.Error;
|
|
throw new Error('No App Store bundled product matches the subscription items');
|
|
}
|
|
|
|
function getPremiumBundlesWithPredicate(a0) { // fn#55689, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:3367, offset: 0x013ae41a, size: 64 bytes, params: 2, frame: 13
|
|
const Object = global.Object;
|
|
const values = Object.values;
|
|
const AppStorePremiumProductIdsToPremiumBundledItems = (ProductIdsAndroidModule).AppStorePremiumProductIdsToPremiumBundledItems;
|
|
return Reflect.apply(values, Object, [AppStorePremiumProductIdsToPremiumBundledItems]).filter(a0);
|
|
}
|
|
|
|
function productsHaveSamePerks(a0, a1) { // fn#55691, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:3974, offset: 0x013ae4ca, size: 116 bytes, params: 3, frame: 14
|
|
var getPremiumBundledItemsFromProductIdBinding;
|
|
var premiumBundledItemsFromProductIdBinding;
|
|
var premiumBundledItemsFromProductIdBinding2;
|
|
if (isValidBundleProductId(a0)) {
|
|
if (isValidBundleProductId(a1)) {
|
|
if (a0 == null) {
|
|
return a0 === a1;
|
|
}
|
|
if (a1 == null) {
|
|
return a0 === a1;
|
|
}
|
|
if (a0 === a1) {
|
|
return true;
|
|
}
|
|
getPremiumBundledItemsFromProductIdBinding = getPremiumBundledItemsFromProductId;
|
|
premiumBundledItemsFromProductIdBinding2 = getPremiumBundledItemsFromProductIdBinding(a0);
|
|
premiumBundledItemsFromProductIdBinding = getPremiumBundledItemsFromProductIdBinding(a1);
|
|
return premiumBundledItemsFromProductIdBinding2.numPremiumGuild === premiumBundledItemsFromProductIdBinding.numPremiumGuild && premiumBundledItemsFromProductIdBinding2.premiumTier === premiumBundledItemsFromProductIdBinding.premiumTier;
|
|
}
|
|
}
|
|
return a0 === a1;
|
|
}
|
|
|
|
function shouldAlwaysExcludeFromPlanSelect(a0) { // fn#55692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:4381, offset: 0x013ae53e, size: 37 bytes, params: 2, frame: 3
|
|
return a0.isDeprecated || a0.interval === SubscriptionIntervalTypes.YEAR;
|
|
}
|
|
|
|
function getProductIdFromSubscription(a0, a1) { // fn#55693, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7205:4722, offset: 0x013ae563, size: 127 bytes, params: 3, frame: 15
|
|
var r2;
|
|
var getProductIdFromSubscriptionItemsBinding;
|
|
const isACOM = a0.isACOM;
|
|
const value = null;
|
|
if (isACOM) {
|
|
r2 = a1 ? value == a0.renewalMutations ? undefined : a0.renewalMutations.items : value;
|
|
getProductIdFromSubscriptionItemsBinding = getProductIdFromSubscriptionItems;
|
|
r2 = value == r2 ? a0.items : r2;
|
|
return getProductIdFromSubscriptionItemsBinding(r2);
|
|
}
|
|
let r5 = a1 ? value == a0.renewalMutations ? undefined : a0.renewalMutations.paymentGatewayPlanId : value;
|
|
const makeExternalPaymentGatewayPlanIdOrThrowBinding = makeExternalPaymentGatewayPlanIdOrThrow;
|
|
r5 = value == r5 ? a0.paymentGatewayPlanId : r5;
|
|
return makeExternalPaymentGatewayPlanIdOrThrowBinding(r5);
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun55675, 7027, [57, 1880, 5143, 2]) /* metro module 7027, dependencies: [57, 1880, 5143, 2] */;
|