/* Metro module 3809; source: records/SubscriptionRecord.tsx; dependencies: [6, 7, 15, 17, 18, 1886, 3810, 3811, 661, 3813, 1880, 3814, 44, 477, 3815, 1900, 2] */ function _fun29418(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#29418, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:6, offset: 0x00fc18ee, size: 379 bytes, params: 8, frame: 19 const env0_0 = require; const createSubscriptionItemFromServer = function(a0) { return {id: a0.id, planId: a0.plan_id, quantity: a0.quantity}; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(6) /* metro dependency 6 */; const env0_4 = importDefault(7) /* metro dependency 7 */; const env0_5 = importDefault(15) /* metro dependency 15 */; const env0_6 = importDefault(17) /* metro dependency 17 */; const env0_7 = importDefault(18) /* metro dependency 18 */; let value = importDefault(1886) /* metro dependency 1886: Record */; const googlePlayPriceChangeRecord = importDefault(3810) /* metro dependency 3810: GooglePlayPriceChangeRecord */; const invoiceRecord = importDefault(3811) /* metro dependency 3811: InvoiceRecord */; const constantsModule = require(661) /* metro dependency 661: Constants */; const env0_10 = constantsModule.PaymentGateways; const env0_11 = constantsModule.SubscriptionStatusTypes; const env0_12 = constantsModule.SubscriptionStatusTypesSets; const env0_13 = constantsModule.SubscriptionTypes; const billingConstantsModule = require(3813) /* metro dependency 3813: BillingConstants */; const env0_14 = billingConstantsModule.SubscriptionPauseReason; const env0_15 = billingConstantsModule.SubscriptionPauseReasonSets; const premiumConstantsModule = require(1880) /* metro dependency 1880: PremiumConstants */; const env0_16 = premiumConstantsModule.PREMIUM_PLANS; const env0_17 = premiumConstantsModule.SubscriptionPlanInfo; const env0_18 = premiumConstantsModule.SubscriptionPlans; value = _fun29423(value); (require(2) /* metro dependency 2 */).fileFinishedImporting('records/SubscriptionRecord.tsx'); exports.default = value; exports.SubscriptionRecord = value; } function _isNativeReflectConstruct_29419() { // fn#29419, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:436, offset: 0x00fc1a69, 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_29419_isNativeReflectConstruct = function() { return !!result; })(); } function _fun29423(a0) { // fn#29423, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:733, offset: 0x00fc1aed, size: 785 bytes, params: 2, frame: 17 const closure = SubscriptionRecord; env0_7(closure, a0); return env0_4(closure, [{key: 'getCurrentSubscriptionPlanIdForGroup', value: function(a0) { var env0_0 = a0; return this.items.find(_fun29428)?.planId; }}, {key: 'isPremium', get: function() { return this.type === SubscriptionTypes.PREMIUM; }}, {key: 'isACOM', get: function() { return this.paymentGateway === PaymentGateways.APPLE_ADVANCED_COMMERCE; }}, {key: 'planIdForCurrencies', get: get_29431}, {key: 'planIdFromItems', get: function() { var Object = global.Object; return this.getCurrentSubscriptionPlanIdForGroup(Object.values(SubscriptionPlans)); }}, {key: 'premiumPlanIdFromItems', get: function() { var r4; var items = []; arraySpread(items, PREMIUM_PLANS, 0, r4); return this.getCurrentSubscriptionPlanIdForGroup(items); }}, {key: 'isPurchasedViaDesktop', get: function() { return this.paymentGateway == null; }}, {key: 'isPurchasedViaAppleGeneric', get: get_29435}, {key: 'isPurchasedViaApple', get: get_29436}, {key: 'isPurchasedViaGoogle', get: function() { return this.paymentGateway === PaymentGateways.GOOGLE; }}, {key: 'isPurchasedExternally', get: function() { return this.isPurchasedViaApple || this.isPurchasedViaGoogle; }}, {key: 'isOnPlatformMatchingExternalPaymentGateway', get: get_29439}, {key: 'hasExternalPlanChange', get: function() { return this.isPurchasedExternally && this.renewalMutations != null && this.paymentGatewayPlanId !== this.renewalMutations.paymentGatewayPlanId; }}, {key: 'hasPremiumNitroMonthly', get: function() { return this.items.find(_fun29442) != null; }}, {key: 'isBoostOnly', get: function() { return this.items.every(_fun29444); }}, {key: 'isPausedOrPausePending', get: function() { var ALL_PAUSE = SubscriptionStatusTypesSets.ALL_PAUSE; return ALL_PAUSE.has(this.status); }}, {key: 'isPaused', get: function() { return this.status === SubscriptionStatusTypes.PAUSED; }}, {key: 'isPausedForFractionalPremium', get: get_29447}, {key: 'isPausedAllowsUpdatesButNotResume', get: get_29448}, {key: 'isPausedAllowsResumeButNotUpdates', get: get_29449}, {key: 'isEnded', get: function() { return this.status === SubscriptionStatusTypes.ENDED; }}, {key: 'endedAt', get: get_29451}, {key: 'isActive', get: function() { return this.status === SubscriptionStatusTypes.ACTIVE; }}, {key: 'statusAllowsPerks', get: function() { var ALLOW_PERKS = SubscriptionStatusTypesSets.ALLOW_PERKS; return ALLOW_PERKS.has(this.status); }}, {key: 'hasActiveTrial', get: function() { var r0; var value2; r0 = this.trialId != null && this.trialEndsAt != null; if (r0) { value2 = new global.Date(); value2 = value2 < this.trialEndsAt; r0 = value2; } return r0; }}, {key: 'hasActiveDiscount', get: function() { var r0; var value2; var value3; var value4; if (this.metadata == null) { return false; } var property = this.metadata.active_discount_id; var active_discount_expires_at = this.metadata.active_discount_expires_at; r0 = property != null && active_discount_expires_at != null; if (r0) { property = global.Date; value2 = new property(); property = global.Date; value3 = Object.create(property.prototype, {constructor: {value: property}}); value4 = new property(active_discount_expires_at); value2 = value2 <= (value4 instanceof Object ? value4 : value3); r0 = value2; } return r0; }}, {key: 'premiumSince', get: function() { return this.streakStartedAt ?? this.createdAt; }}, {key: 'hasAnyPremiumNitro', get: function() { return this.items.some(_fun29458); }}, {key: 'hasAnyPremiumGroup', get: function() { return this.items.some(_fun29460); }}, {key: 'hasPremiumAtLeast', value: function(a0) { var env0_0 = a0; var property = this.isPremium; return property ? this.items.some(_fun29462) : !!property; }}], [{key: 'createFromServer', value: value_29463}]); } function SubscriptionRecord(a0) { // fn#29424, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:745, offset: 0x00fc1dfe, size: 755 bytes, params: 2, frame: 25 var environment; var r3; var r6; var property; var interval; var intervalCount; var moduleValue; var getBasePlanIdForSubscriptionItems; var value8; let value = environment.__proto__; env1_3(this, SubscriptionRecord); const value3 = env1_6(SubscriptionRecord); const value6 = env1_5(this, _isNativeReflectConstruct_29419() ? global.Reflect.construct(value3, [], env1_6(this).constructor) : value3.apply(this, undefined)); value6.id = a0.id; let type = a0.type; value6.type = type; let items2 = a0.items; value6.items = items2; value6.createdAt = a0.createdAt; value6.canceledAt = a0.canceledAt; value6.currentPeriodStart = a0.currentPeriodStart; value6.currentPeriodEnd = a0.currentPeriodEnd; value6.status = a0.status; value6.paymentSourceId = a0.paymentSourceId; value6.paymentGateway = a0.paymentGateway; value6.paymentGatewayPlanId = a0.paymentGatewayPlanId; value6.paymentGatewaySubscriptionId = a0.paymentGatewaySubscriptionId; value6.trialId = a0.trialId; value6.trialEndsAt = a0.trialEndsAt; let renewalMutations = a0.renewalMutations; value6.renewalMutations = renewalMutations; value6.currency = a0.currency; value6.pauseEndsAt = a0.pauseEndsAt; value6.pauseReason = a0.pauseReason; value6.metadata = a0.metadata; value6.latestInvoice = a0.latestInvoice; const useStorekitResubscribe = a0.useStorekitResubscribe; value6.useStorekitResubscribe = useStorekitResubscribe; value6.price = a0.price; const userId = a0.userId; value6.userId = userId; value6.streakStartedAt = a0.streakStartedAt; value6.eligiblePaymentGateways = a0.eligiblePaymentGateways; value6.priceChange = a0.priceChange; renewalMutations = value6.renewalMutations; const planId = a0.items[0].planId; const value7 = null; type = a0.type; const PREMIUM = SubscriptionTypes.PREMIUM; if (type === PREMIUM) { items2 = a0.items; property = SubscriptionPlanInfo[items2[0].planId]; interval = property.interval; intervalCount = property.intervalCount; moduleValue = require(3814) /* metro dependency 3814: PremiumSubscription */; getBasePlanIdForSubscriptionItems = moduleValue.getBasePlanIdForSubscriptionItems; items2 = a0.items; value8 = Reflect.apply(getBasePlanIdForSubscriptionItems, moduleValue, [items2, interval, intervalCount]); if (value7 != renewalMutations) { value = require(3814) /* metro dependency 3814: PremiumSubscription */; value = value.getBasePlanIdForSubscriptionItems(renewalMutations.items, interval, intervalCount); r3 = value; r6 = value8; } else { r3 = value7; r6 = value8; } } else if (value7 != renewalMutations && renewalMutations.items.length > 0) { r3 = renewalMutations.items[0].planId; r6 = planId; } else { r3 = value7; r6 = planId; } value6.planId = r6; value6.additionalPlans = a0.items.filter(function({planId}) { return planId !== planId; }); if (value7 != renewalMutations && value7 != r3) { renewalMutations.planId = r3; renewalMutations.additionalPlans = renewalMutations.items.filter(function({planId}) { return planId !== planId; }); } return value6; } function value_29427(a0) { // fn#29427, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:2324, offset: 0x00fc211d, size: 53 bytes, params: 2, frame: 11 const env0_0 = a0; return this.items.find(_fun29428)?.planId; } function get_29431() { // fn#29431, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:2600, offset: 0x00fc21a5, size: 71 bytes, params: 1, frame: 15 var r0; var value; var planIdFromItems; if (this.isPremium) { value = environment.__proto__; value = importDefault(44) /* metro dependency 44 */; planIdFromItems = this.planIdFromItems; value(planIdFromItems, 'Premium subscription has no planId for currencies'); planIdFromItems = this.planIdFromItems; r0 = planIdFromItems; } else { r0 = this.planId; } return r0; } function get_29435() { // fn#29435, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3093, offset: 0x00fc224a, size: 37 bytes, params: 1, frame: 3 const paymentGateway = this.paymentGateway; const value = environment.__proto__; const APPLE_PARTNER = PaymentGateways.APPLE_PARTNER; return paymentGateway === APPLE_PARTNER || this.isACOM; } function get_29436() { // fn#29436, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3195, offset: 0x00fc226f, size: 37 bytes, params: 1, frame: 3 const paymentGateway = this.paymentGateway; const value = environment.__proto__; const APPLE = PaymentGateways.APPLE; return paymentGateway === APPLE || this.isACOM; } function get_29439() { // fn#29439, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3500, offset: 0x00fc22c4, size: 99 bytes, params: 1, frame: 13 var r0; var r1; var value; var isPurchasedViaGoogle; const isPurchasedViaApple = this.isPurchasedViaApple; if (isPurchasedViaApple) { value = environment.__proto__; value = require(477) /* metro dependency 477: PlatformUtils */; value = value.isIOS(); r0 = value; } else { r0 = isPurchasedViaApple; } if (!r0) { isPurchasedViaGoogle = this.isPurchasedViaGoogle; if (isPurchasedViaGoogle) { value = environment.__proto__; value = require(3815) /* metro dependency 3815: BillingPlatformUtils */; value = value.isGooglePlayBillingSupported(); r1 = value; } else { r1 = isPurchasedViaGoogle; } r0 = r1; } return r0; } function get_29441() { // fn#29441, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3846, offset: 0x00fc235a, size: 35 bytes, params: 1, frame: 11 return this.items.find(function({planId}) { return planId === SubscriptionPlans.PREMIUM_MONTH_TIER_2; }) != null; } function get_29443() { // fn#29443, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3951, offset: 0x00fc2399, size: 29 bytes, params: 1, frame: 11 return this.items.every(function(a0) { var PREMIUM_MONTH_GUILD = SubscriptionPlans.PREMIUM_MONTH_GUILD; return [PREMIUM_MONTH_GUILD, SubscriptionPlans.PREMIUM_YEAR_GUILD].includes(a0.planId); }); } function get_29447() { // fn#29447, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:4244, offset: 0x00fc2426, size: 50 bytes, params: 1, frame: 4 const status = this.status; const value = environment.__proto__; const PAUSED = SubscriptionStatusTypes.PAUSED; return status === PAUSED && this.pauseReason === SubscriptionPauseReason.FRACTIONAL_PREMIUM; } function get_29448() { // fn#29448, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:4373, offset: 0x00fc2458, size: 56 bytes, params: 1, frame: 12 const status = this.status; const value = environment.__proto__; const PAUSED = SubscriptionStatusTypes.PAUSED; return status === PAUSED && SubscriptionPauseReasonSets.CAN_MAKE_SUBSCRIPTION_UPDATES.has(this.pauseReason); } function get_29449() { // fn#29449, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:4516, offset: 0x00fc2490, size: 77 bytes, params: 1, frame: 13 const status = this.status; const value = environment.__proto__; const PAUSED = SubscriptionStatusTypes.PAUSED; return status === PAUSED && (this.pauseReason === null || !SubscriptionPauseReasonSets.CAN_MAKE_SUBSCRIPTION_UPDATES.has(this.pauseReason)); } function get_29451() { // fn#29451, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:4722, offset: 0x00fc24f8, size: 107 bytes, params: 1, frame: 14 const status = this.status; let value = environment.__proto__; const ENDED = SubscriptionStatusTypes.ENDED; value = null; return status !== ENDED ? value : value != (value == this.metadata ? undefined : this.metadata.ended_at) ? new global.Date() : this.currentPeriodEnd; } function get_29457() { // fn#29457, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5470, offset: 0x00fc2675, size: 29 bytes, params: 1, frame: 11 return this.items.some(function(a0) { return PREMIUM_PLANS.has(a0.planId); }); } function get_29459() { // fn#29459, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5558, offset: 0x00fc26ae, size: 29 bytes, params: 1, frame: 11 return this.items.some(function({planId}) { return planId === SubscriptionPlans.PREMIUM_GROUP_MONTH; }); } function value_29461(a0) { // fn#29461, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5664, offset: 0x00fc26e7, size: 51 bytes, params: 2, frame: 12 const env0_0 = a0; const isPremium = this.isPremium; return isPremium ? this.items.some(_fun29462) : !!isPremium; } function value_29463(a0) { // fn#29463, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5826, offset: 0x00fc275f, size: 741 bytes, params: 2, frame: 20 var r10; var r4; var r5; const object2 = {}; object2.id = a0.id; object2.type = a0.type; let Date = global.Date; let date = new Date(a0.created_at); object2.createdAt = date; const canceled_at = a0.canceled_at; date = null; if (date != canceled_at) { date = new global.Date(a0.canceled_at); } else { r4 = date; } object2.canceledAt = r4; Date = global.Date; const current_period_start = a0.current_period_start; const value4 = Object.create(Date.prototype, {constructor: {value: Date}}); date = new Date(current_period_start); object2.currentPeriodStart = date instanceof Object ? date : value4; Date = global.Date; const current_period_end = a0.current_period_end; const value6 = Object.create(Date.prototype, {constructor: {value: Date}}); date = new Date(current_period_end); object2.currentPeriodEnd = date instanceof Object ? date : value6; object2.status = a0.status; object2.paymentSourceId = a0.payment_source_id; object2.paymentGateway = a0.payment_gateway; object2.paymentGatewayPlanId = a0.payment_gateway_plan_id; object2.paymentGatewaySubscriptionId = a0.payment_gateway_subscription_id; object2.trialId = a0.trial_id; if (date != a0.trial_ends_at) { date = new global.Date(a0.trial_ends_at); } else { r4 = date; } object2.trialEndsAt = r4; let items2 = a0.items; object2.items = items2.map(createSubscriptionItemFromServer); let renewal_mutations = a0.renewal_mutations; if (date != renewal_mutations) { renewal_mutations = a0.renewal_mutations; items2 = renewal_mutations.items; renewal_mutations = a0.renewal_mutations; r5 = {items: items2.map(createSubscriptionItemFromServer), paymentGatewayPlanId: renewal_mutations.payment_gateway_plan_id}; r10 = items2; } else { r5 = date; } object2.renewalMutations = r5; if (date != a0.streak_started_at) { date = new global.Date(a0.streak_started_at); } else { r5 = date; } object2.streakStartedAt = r5; object2.currency = a0.currency; if (date != a0.pause_ends_at) { date = new global.Date(a0.pause_ends_at); } else { r5 = date; } object2.pauseEndsAt = r5; object2.pauseReason = a0.pause_reason; object2.metadata = a0.metadata; const use_storekit_resubscribe = a0.use_storekit_resubscribe; object2.useStorekitResubscribe = use_storekit_resubscribe; object2.price = a0.price; const user_id = a0.user_id; object2.userId = user_id; copyDataProperties(object2, date != a0.latest_invoice ? {latestInvoice: InvoiceRecord.createInvoiceFromServer(a0.latest_invoice)} : {}, r10); const eligible_payment_gateways = a0.eligible_payment_gateways; object2['eligiblePaymentGateways'] = date != eligible_payment_gateways ? eligible_payment_gateways : date; object2['priceChange'] = date != a0.price_change ? GooglePlayPriceChangeRecord.createFromServer(a0.price_change) : date; date = Object.create(SubscriptionRecord.prototype, {constructor: {value: SubscriptionRecord}}); const subscriptionRecord = new SubscriptionRecord(object2); return subscriptionRecord instanceof Object ? subscriptionRecord : date; } function _fun29428({planId}) { // fn#29428, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:2375, offset: 0x00fc2152, size: 28 bytes, params: 2, frame: 11 return env0_0.includes(planId); } function _fun29462({planId}) { // fn#29462, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5717, offset: 0x00fc271a, size: 69 bytes, params: 2, frame: 13 let value = environment.__proto__.__proto__; const property = SubscriptionPlanInfo[planId]; value = require(1900) /* metro dependency 1900: PremiumTypeUtils */; return value.isPremiumAtLeast(property.premiumType, env0_0); }