416 lines
20 KiB
TypeScript
416 lines
20 KiB
TypeScript
/* Metro module 3808; source: stores/billing/SubscriptionStore.tsx; dependencies: [6, 7, 15, 17, 18, 3803, 3809, 1226, 661, 566, 694, 2] */
|
|
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
|
|
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
|
|
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
|
|
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
|
|
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
|
|
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
|
|
import AuthenticationStore from '../AuthenticationStore.tsx'; /* Metro dependency 1226 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as SubscriptionPlanRecordModule from '../../records/SubscriptionPlanRecord.tsx'; /* Metro dependency 3803 */
|
|
import * as SubscriptionRecordModule from '../../records/SubscriptionRecord.tsx'; /* Metro dependency 3809 */
|
|
|
|
function _fun29375(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#29375, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:6, offset: 0x00fc0d9c, size: 547 bytes, params: 8, frame: 21
|
|
const closure = function() {
|
|
env0_10 = null;
|
|
env0_11 = null;
|
|
env0_12 = null;
|
|
env0_13 = null;
|
|
env0_14 = null;
|
|
env0_15 = false;
|
|
env0_16 = null;
|
|
env0_17 = false;
|
|
env0_18 = false;
|
|
env0_20 = false;
|
|
env0_21 = null;
|
|
};
|
|
const isPaid = function({status}) {
|
|
return status !== SubscriptionStatusTypes.UNPAID;
|
|
};
|
|
const getSubscriptionOfType2 = getSubscriptionOfType;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let env0_4 = Inherits;
|
|
let value = ConstantsModule;
|
|
const env0_8 = value.SubscriptionStatusTypes;
|
|
const env0_9 = value.SubscriptionTypes;
|
|
const Store = (Flux).Store;
|
|
_fun29384(Store).displayName = 'SubscriptionStore';
|
|
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */,
|
|
{BILLING_SUBSCRIPTION_FETCH_SUCCESS: function({subscriptions, lastLazyPerkSync}) {
|
|
var env0_4 = AuthenticationStore.getId();
|
|
subscriptions.forEach(_fun29409);
|
|
env0_10 = {};
|
|
env0_11 = {};
|
|
env0_13 = [];
|
|
env0_14 = [];
|
|
env0_21 = lastLazyPerkSync;
|
|
}, BILLING_SUBSCRIPTION_UPDATE_SUCCESS: BILLING_SUBSCRIPTION_UPDATE_SUCCESS,
|
|
BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_START: function() {
|
|
env0_20 = true;
|
|
}, BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_SUCCESS: function({subscription}) {
|
|
env0_15 = true;
|
|
env0_20 = false;
|
|
if (subscription != null) {
|
|
var user_id = subscription.user_id;
|
|
if (user_id !== AuthenticationStore.getId()) {
|
|
env0_15 = false;
|
|
return undefined;
|
|
}
|
|
env0_12 = SubscriptionRecord.createFromServer(subscription);
|
|
}
|
|
}, BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_FAIL: function() {
|
|
env0_20 = false;
|
|
}, BILLING_PREVIOUS_PREMIUM_SUBSCRIPTION_FETCH_SUCCESS: function({subscription}) {
|
|
env0_17 = true;
|
|
if (subscription != null) {
|
|
var user_id = subscription.user_id;
|
|
if (user_id !== AuthenticationStore.getId()) {
|
|
env0_17 = false;
|
|
return undefined;
|
|
}
|
|
env0_16 = SubscriptionRecord.createFromServer(subscription);
|
|
}
|
|
}, BILLING_SUBSCRIPTION_RESET: closure, BILLING_SUBSCRIPTION_REWARD_ELIGIBILITY_FETCH_START: function() {
|
|
env0_18 = true;
|
|
}, BILLING_SUBSCRIPTION_REWARD_ELIGIBILITY_FETCH_SUCCESS: function(a0) {
|
|
env0_19 = a0.eligible;
|
|
env0_18 = false;
|
|
}, BILLING_SUBSCRIPTION_REWARD_ELIGIBILITY_FETCH_FAILURE: function(a0) {
|
|
var r3;
|
|
if (a0 == null) {
|
|
throwTypeError(a0, "Cannot destructure 'undefined' or 'null'.", r3);
|
|
throw undefined;
|
|
}
|
|
env0_19 = false;
|
|
env0_18 = false;
|
|
}, LOGOUT: closure});
|
|
(FileImportTrackerModule).fileFinishedImporting('stores/billing/SubscriptionStore.tsx');
|
|
exports.default = value;
|
|
exports.getSubscriptionOfType = getSubscriptionOfType2;
|
|
function _isNativeReflectConstruct_29376() { // fn#29376, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:276, offset: 0x00fc0fbf, size: 94 bytes, params: 1, frame: 18
|
|
var Boolean;
|
|
var prototype;
|
|
var valueOf;
|
|
var call;
|
|
var Reflect;
|
|
var construct;
|
|
var closure;
|
|
var value;
|
|
var error;
|
|
try {
|
|
Boolean = global.Boolean;
|
|
prototype = Boolean.prototype;
|
|
valueOf = prototype.valueOf;
|
|
call = valueOf.call;
|
|
Reflect = global.Reflect;
|
|
construct = Reflect.construct;
|
|
Boolean = global.Boolean;
|
|
closure = function() {
|
|
};
|
|
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
|
|
value = Reflect.apply(call, valueOf, [value]);
|
|
var result = !value;
|
|
} catch (error) {
|
|
}
|
|
return (_isNativeReflectConstruct_29376_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function getUpdatedActiveSubscriptions({activeSubscriptions, record}) { // fn#29379, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:549, offset: 0x00fc101d, size: 145 bytes, params: 2, frame: 17
|
|
var items2;
|
|
const index = activeSubscriptions.findIndex(function({id}) {
|
|
return id === record.id;
|
|
});
|
|
if (index === -1) {
|
|
arraySpread([record], activeSubscriptions, 1, undefined);
|
|
} else {
|
|
items2 = [];
|
|
arraySpread(items2, activeSubscriptions, 0, undefined);
|
|
if (isPaid(record)) {
|
|
if (record.status !== SubscriptionStatusTypes.ENDED) {
|
|
items2[index] = record;
|
|
} else {
|
|
items2.splice(index, 1);
|
|
}
|
|
} else {
|
|
items2.splice(index, 1);
|
|
}
|
|
}
|
|
return items2;
|
|
}
|
|
|
|
function getSubscriptionOfType(a0, a1) { // fn#29383, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:888, offset: 0x00fc111a, size: 118 bytes, params: 3, frame: 23
|
|
var propertyName;
|
|
var propertyName2;
|
|
var property;
|
|
var userId;
|
|
var authenticationStoreBinding;
|
|
var getId;
|
|
var type;
|
|
const value = a2;
|
|
const r8 = !(value !== undefined) || value ? env0_11 : env0_10;
|
|
if (r8 == null) {
|
|
return null;
|
|
}
|
|
const properties = Object.keys(r8);
|
|
const properties2 = 0;
|
|
const properties3 = properties.length;
|
|
if (properties === undefined) {
|
|
return null;
|
|
}
|
|
let r5 = properties2;
|
|
loopExit7: while (true) {
|
|
propertyName = properties[r5];
|
|
propertyName2 = r5 + 1;
|
|
if (propertyName === undefined) {
|
|
return null;
|
|
}
|
|
property = r8[propertyName];
|
|
userId = property.userId;
|
|
authenticationStoreBinding = AuthenticationStore;
|
|
getId = authenticationStoreBinding.getId;
|
|
if (userId !== Reflect.apply(getId, authenticationStoreBinding, [])) {
|
|
return null;
|
|
}
|
|
type = property.type;
|
|
if (type !== a0) {
|
|
r5 = propertyName2;
|
|
continue;
|
|
}
|
|
if (a1 == null) {
|
|
break loopExit7;
|
|
}
|
|
if (a1(property)) {
|
|
break loopExit7;
|
|
}
|
|
r5 = propertyName2;
|
|
continue;
|
|
}
|
|
return property;
|
|
}
|
|
|
|
function _fun29384(a0) { // fn#29384, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:1085, offset: 0x00fc1190, size: 477 bytes, params: 2, frame: 16
|
|
const SubscriptionStore2 = SubscriptionStore;
|
|
env0_4(SubscriptionStore2, a0);
|
|
return CreateClass(SubscriptionStore2, [{key: 'initialize', value: function() {
|
|
this.waitFor(AuthenticationStore);
|
|
}}, {key: 'hasFetchedSubscriptions', value: value_29387}, {key: 'hasFetchedMostRecentPremiumTypeSubscription',
|
|
value: value_29388}, {key: 'hasFetchedPreviousPremiumTypeSubscription', value: value_29389},
|
|
{key: 'getPremiumSubscription', value: value_29390}, {key: 'getPremiumTypeSubscription', value: value_29392},
|
|
{key: 'getSubscriptions', value: value_29393}, {key: 'getSubscriptionById', value: value_29394},
|
|
{key: 'getActiveGuildSubscriptions', value: value_29395}, {key: 'getActiveApplicationSubscriptions',
|
|
value: value_29396}, {key: 'getSubscriptionForPlanIds', value: value_29397},
|
|
{key: 'getMostRecentPremiumTypeSubscription', value: value_29400}, {key: 'getPreviousPremiumTypeSubscription',
|
|
value: value_29401}, {key: 'getIsSubscriptionEligibleForReward', value: value_29402},
|
|
{key: 'getIsFetchingSubscriptionRewardEligibility', value: value_29403},
|
|
{key: 'getIsFetchingMostRecentSubscription', value: value_29404}, {key: 'getLastLazyPerkSync',
|
|
value: value_29405}, {key: 'getPremiumGroupSubscription', value: function() {
|
|
var getSubscriptionOfTypeBinding = getSubscriptionOfType;
|
|
var PREMIUM = SubscriptionTypes.PREMIUM;
|
|
return getSubscriptionOfTypeBinding(PREMIUM, _fun29407, true);
|
|
}}]);
|
|
function SubscriptionStore() { // fn#29385, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:1097, offset: 0x00fc136d, size: 113 bytes, params: 1, frame: 20
|
|
const value = environment.__proto__;
|
|
env1_0(this, SubscriptionStore);
|
|
const value3 = env1_3(SubscriptionStore);
|
|
return env1_2(this, _isNativeReflectConstruct_29376() ? global.Reflect.construct(value3, arguments,
|
|
env1_3(this).constructor) : value3.apply(this, arguments));
|
|
}
|
|
|
|
function value_29387() { // fn#29387, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:1466, offset: 0x00fc13f7, size: 15 bytes, params: 1, frame: 2
|
|
return env1_10 != null;
|
|
}
|
|
|
|
function value_29388() { // fn#29388, offset: 0x00df0e8b, size: 9 bytes, params: 1, frame: 1
|
|
return env1_15;
|
|
}
|
|
|
|
function value_29389() { // fn#29389, offset: 0x00e07553, size: 9 bytes, params: 1, frame: 1
|
|
return env1_17;
|
|
}
|
|
|
|
function value_29390() { // fn#29390, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:1686, offset: 0x00fc1406, size: 44 bytes, params: 1, frame: 15
|
|
var environment;
|
|
let value = a0;
|
|
const r4 = !(value !== undefined) || value;
|
|
value = environment.__proto__;
|
|
const getSubscriptionOfTypeBinding = getSubscriptionOfType;
|
|
const PREMIUM = SubscriptionTypes.PREMIUM;
|
|
return getSubscriptionOfTypeBinding(PREMIUM, function(a0) {
|
|
return !isNoneSubscription(a0.planId);
|
|
}, r4);
|
|
}
|
|
|
|
function value_29392() { // fn#29392, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:1803, offset: 0x00fc144e, size: 37 bytes, params: 1, frame: 14
|
|
let value = a0;
|
|
const r3 = !(value !== undefined) || value;
|
|
value = environment.__proto__;
|
|
const getSubscriptionOfTypeBinding = getSubscriptionOfType;
|
|
const PREMIUM = SubscriptionTypes.PREMIUM;
|
|
return getSubscriptionOfTypeBinding(PREMIUM, undefined, r3);
|
|
}
|
|
|
|
function value_29393() { // fn#29393, offset: 0x00fc1473, size: 29 bytes, params: 1, frame: 3
|
|
let value = a0;
|
|
let r0 = !(value !== undefined) || value;
|
|
value = environment.__proto__;
|
|
r0 = r0 ? env1_11 : env1_10;
|
|
return r0;
|
|
}
|
|
|
|
function value_29394(a0) { // fn#29394, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:1962, offset: 0x00fc1490, size: 39 bytes, params: 2, frame: 5
|
|
let value = environment.__proto__;
|
|
const binding = env1_10;
|
|
value = undefined;
|
|
return (binding == null ? value : binding[a0]) ?? value;
|
|
}
|
|
|
|
function value_29395() { // fn#29395, offset: 0x00e2f9d5, size: 9 bytes, params: 1, frame: 1
|
|
return env1_13;
|
|
}
|
|
|
|
function value_29396() { // fn#29396, offset: 0x00df0f5a, size: 9 bytes, params: 1, frame: 1
|
|
return env1_14;
|
|
}
|
|
|
|
function value_29397(a0) { // fn#29397, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:2205, offset: 0x00fc14b7, size: 128 bytes, params: 2, frame: 14
|
|
var environment;
|
|
var r0;
|
|
var value3;
|
|
const value = a1;
|
|
const r1 = !(value !== undefined) || value;
|
|
const Set = global.Set;
|
|
let set = new Set(a0);
|
|
set = environment.__proto__;
|
|
const r5 = r1 ? env1_11 : env1_10;
|
|
set = null;
|
|
if (set == r5) {
|
|
r0 = set;
|
|
} else {
|
|
value3 = global.Object.values(r5).find(function({items}) {
|
|
return items.some(_fun29399);
|
|
});
|
|
r0 = set != value3 ? value3 : set;
|
|
}
|
|
return r0;
|
|
function _fun29398({items}) { // fn#29398, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:2301, offset: 0x00fc1537, size: 29 bytes, params: 2, frame: 11
|
|
return items.some(_fun29399);
|
|
function _fun29399({planId}) { // fn#29399, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:2318, offset: 0x00fc1554, size: 28 bytes, params: 2, frame: 11
|
|
return env1_0.has(planId);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function value_29400() { // fn#29400, offset: 0x00e2f9de, size: 9 bytes, params: 1, frame: 1
|
|
return env1_12;
|
|
}
|
|
|
|
function value_29401() { // fn#29401, offset: 0x00df0e94, size: 9 bytes, params: 1, frame: 1
|
|
return env1_16;
|
|
}
|
|
|
|
function value_29402() { // fn#29402, offset: 0x00d406a2, size: 9 bytes, params: 1, frame: 1
|
|
return env1_19;
|
|
}
|
|
|
|
function value_29403() { // fn#29403, offset: 0x00df0e82, size: 9 bytes, params: 1, frame: 1
|
|
return env1_18;
|
|
}
|
|
|
|
function value_29404() { // fn#29404, offset: 0x00e4253a, size: 9 bytes, params: 1, frame: 1
|
|
return env1_20;
|
|
}
|
|
|
|
function value_29405() { // fn#29405, offset: 0x00f854d6, size: 9 bytes, params: 1, frame: 1
|
|
return env1_21;
|
|
}
|
|
|
|
function value_29406() { // fn#29406, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:2808, offset: 0x00fc1570, size: 37 bytes, params: 1, frame: 15
|
|
const getSubscriptionOfTypeBinding = getSubscriptionOfType;
|
|
const PREMIUM = SubscriptionTypes.PREMIUM;
|
|
return getSubscriptionOfTypeBinding(PREMIUM, function(a0) {
|
|
return a0.hasAnyPremiumGroup && a0.statusAllowsPerks;
|
|
}, true);
|
|
}
|
|
|
|
}
|
|
|
|
function BILLING_SUBSCRIPTION_FETCH_SUCCESS({subscriptions, lastLazyPerkSync}) { // fn#29408, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:3020, offset: 0x00fc15ab, size: 105 bytes, params: 2, frame: 18
|
|
const object = {};
|
|
const object2 = {};
|
|
const items = [];
|
|
const items2 = [];
|
|
const env0_4 = AuthenticationStore.getId();
|
|
subscriptions.forEach(_fun29409);
|
|
function _fun29409(a0) { // fn#29409, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:3139, offset: 0x00fc1614, size: 204 bytes, params: 2, frame: 14
|
|
var r1;
|
|
var value2;
|
|
var fromServer;
|
|
var type;
|
|
const user_id = a0.user_id;
|
|
if (user_id === env0_4) {
|
|
value2 = environment.__proto__;
|
|
fromServer = SubscriptionRecord.createFromServer(a0);
|
|
ClassCallCheck[fromServer.id] = fromServer;
|
|
if (isPaid(fromServer)) {
|
|
CreateClass[fromServer.id] = fromServer;
|
|
type = fromServer.type;
|
|
r1 = type === SubscriptionTypes.GUILD && fromServer.status !== SubscriptionStatusTypes.ENDED;
|
|
if (r1) {
|
|
PossibleConstructorReturn.push(fromServer);
|
|
}
|
|
type = fromServer.type;
|
|
r1 = type === SubscriptionTypes.APPLICATION && fromServer.status !== SubscriptionStatusTypes.ENDED;
|
|
if (r1) {
|
|
Module00017.push(fromServer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function BILLING_SUBSCRIPTION_UPDATE_SUCCESS({subscription}) { // fn#29410, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:3385, offset: 0x00fc16e0, size: 252 bytes, params: 2, frame: 16
|
|
var r0;
|
|
var fromServer;
|
|
var object;
|
|
const user_id = subscription.user_id;
|
|
const authenticationStoreBinding = AuthenticationStore;
|
|
const getId = authenticationStoreBinding.getId;
|
|
if (user_id === Reflect.apply(getId, authenticationStoreBinding, [])) {
|
|
fromServer = SubscriptionRecord.createFromServer(subscription);
|
|
object = {};
|
|
copyDataProperties(object, env0_10, undefined);
|
|
object[fromServer.id] = fromServer;
|
|
if (isPaid(fromServer)) {
|
|
object = {};
|
|
copyDataProperties(object, env0_11, undefined);
|
|
object[fromServer.id] = fromServer;
|
|
}
|
|
r0 = updatedActiveSubscriptions != null && fromServer.type === SubscriptionTypes.GUILD;
|
|
if (r0) {
|
|
updatedActiveSubscriptions = getUpdatedActiveSubscriptions({activeSubscriptions: updatedActiveSubscriptions,
|
|
record: fromServer});
|
|
}
|
|
r0 = env0_14 != null && fromServer.type === SubscriptionTypes.APPLICATION;
|
|
if (r0) {
|
|
updatedActiveSubscriptions = getUpdatedActiveSubscriptions({activeSubscriptions: env0_14,
|
|
record: fromServer});
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function _fun29407(a0) { // fn#29407, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3935:2859, offset: 0x00fc1595, size: 22 bytes, params: 2, frame: 3
|
|
return a0.hasAnyPremiumGroup && a0.statusAllowsPerks;
|
|
}
|
|
|
|
global.__d(_fun29375, 3808, [6, 7, 15, 17, 18, 3803, 3809, 1226, 661, 566, 694,
|
|
2]) /* metro module 3808, dependencies: [6, 7, 15, 17, 18, 3803, 3809, 1226, 661, 566, 694, 2] */;
|