/* Metro module 3808; source: stores/billing/SubscriptionStore.tsx; dependencies: [6, 7, 15, 17, 18, 3803, 3809, 1226, 661, 566, 694, 2] */ 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 closure2 = getSubscriptionOfType; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_0 = importDefault(6) /* metro dependency 6 */; const env0_1 = importDefault(7) /* metro dependency 7 */; const env0_2 = importDefault(15) /* metro dependency 15 */; const env0_3 = importDefault(17) /* metro dependency 17 */; let env0_4 = importDefault(18) /* metro dependency 18 */; const env0_5 = (require(3803) /* metro dependency 3803: SubscriptionPlanRecord */).isNoneSubscription; const env0_6 = (require(3809) /* metro dependency 3809: SubscriptionRecord */).SubscriptionRecord; const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */; let value = require(661) /* metro dependency 661: Constants */; const env0_8 = value.SubscriptionStatusTypes; const env0_9 = value.SubscriptionTypes; const Store = (importDefault(566) /* metro dependency 566: 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}); (require(2) /* metro dependency 2 */).fileFinishedImporting('stores/billing/SubscriptionStore.tsx'); exports.default = value; exports.getSubscriptionOfType = closure2; } 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 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; getId = AuthenticationStore.getId; if (userId !== Reflect.apply(getId, AuthenticationStore, [])) { 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 closure = SubscriptionStore; env0_4(closure, a0); return env0_1(closure, [{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 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 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 object2; const user_id = subscription.user_id; const getId = AuthenticationStore.getId; if (user_id === Reflect.apply(getId, AuthenticationStore, [])) { fromServer = SubscriptionRecord.createFromServer(subscription); object2 = {}; copyDataProperties(object2, env0_10, undefined); object2[fromServer.id] = fromServer; if (isPaid(fromServer)) { object2 = {}; copyDataProperties(object2, env0_11, undefined); object2[fromServer.id] = fromServer; } r0 = env0_13 != null && fromServer.type === SubscriptionTypes.GUILD; if (r0) { env0_13 = getUpdatedActiveSubscriptions({activeSubscriptions: env0_13, record: fromServer}); } r0 = env0_14 != null && fromServer.type === SubscriptionTypes.APPLICATION; if (r0) { env0_13 = getUpdatedActiveSubscriptions({activeSubscriptions: env0_14, record: fromServer}); } } } 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_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_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 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 _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); env0_0[fromServer.id] = fromServer; if (isPaid(fromServer)) { env0_1[fromServer.id] = fromServer; type = fromServer.type; r1 = type === SubscriptionTypes.GUILD && fromServer.status !== SubscriptionStatusTypes.ENDED; if (r1) { env0_2.push(fromServer); } type = fromServer.type; r1 = type === SubscriptionTypes.APPLICATION && fromServer.status !== SubscriptionStatusTypes.ENDED; if (r1) { env0_3.push(fromServer); } } } } 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); }