/* 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] */ 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 Record from '../lib/Record.tsx'; /* Metro dependency 1886 */ import GooglePlayPriceChangeRecord from '../modules/premium/native/google_play_price_changes/GooglePlayPriceChangeRecord.tsx'; /* Metro dependency 3810 */ import InvoiceRecord from './InvoiceRecord.tsx'; /* Metro dependency 3811 */ import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */ import * as PremiumConstantsModule from '../modules/premium/PremiumConstants.tsx'; /* Metro dependency 1880 */ import * as BillingConstantsModule from '../components/billing/BillingConstants.tsx'; /* Metro dependency 3813 */ 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}); let value = Record; value = _fun29423(value); (FileImportTrackerModule).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 SubscriptionRecord2 = SubscriptionRecord; Inherits(SubscriptionRecord2, a0); return CreateClass(SubscriptionRecord2, [{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 _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 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 _fun29442({planId}) { // fn#29442, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3887, offset: 0x00fc237d, size: 28 bytes, params: 2, frame: 2 const PREMIUM_MONTH_TIER_2 = SubscriptionPlans.PREMIUM_MONTH_TIER_2; return planId === PREMIUM_MONTH_TIER_2; } } 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 _fun29444({planId}) { // fn#29444, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:3987, offset: 0x00fc23b6, size: 52 bytes, params: 2, frame: 11 const PREMIUM_MONTH_GUILD = SubscriptionPlans.PREMIUM_MONTH_GUILD; const PREMIUM_YEAR_GUILD = SubscriptionPlans.PREMIUM_YEAR_GUILD; return [PREMIUM_MONTH_GUILD, PREMIUM_YEAR_GUILD].includes(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 _fun29458({planId}) { // fn#29458, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5505, offset: 0x00fc2692, size: 28 bytes, params: 2, frame: 11 return PREMIUM_PLANS.has(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 _fun29460({planId}) { // fn#29460, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3936:5593, offset: 0x00fc26cb, size: 28 bytes, params: 2, frame: 2 const PREMIUM_GROUP_MONTH = SubscriptionPlans.PREMIUM_GROUP_MONTH; return planId === 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 _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); } } 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 object = {}; object.id = a0.id; object.type = a0.type; let Date = global.Date; let date = new Date(a0.created_at); object.createdAt = date; const canceled_at = a0.canceled_at; date = null; if (date != canceled_at) { date = new global.Date(a0.canceled_at); } else { r4 = date; } object.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); object.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); object.currentPeriodEnd = date instanceof Object ? date : value6; object.status = a0.status; object.paymentSourceId = a0.payment_source_id; object.paymentGateway = a0.payment_gateway; object.paymentGatewayPlanId = a0.payment_gateway_plan_id; object.paymentGatewaySubscriptionId = a0.payment_gateway_subscription_id; object.trialId = a0.trial_id; if (date != a0.trial_ends_at) { date = new global.Date(a0.trial_ends_at); } else { r4 = date; } object.trialEndsAt = r4; let items2 = a0.items; object.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; } object.renewalMutations = r5; if (date != a0.streak_started_at) { date = new global.Date(a0.streak_started_at); } else { r5 = date; } object.streakStartedAt = r5; object.currency = a0.currency; if (date != a0.pause_ends_at) { date = new global.Date(a0.pause_ends_at); } else { r5 = date; } object.pauseEndsAt = r5; object.pauseReason = a0.pause_reason; object.metadata = a0.metadata; const use_storekit_resubscribe = a0.use_storekit_resubscribe; object.useStorekitResubscribe = use_storekit_resubscribe; object.price = a0.price; const user_id = a0.user_id; object.userId = user_id; copyDataProperties(object, date != a0.latest_invoice ? {latestInvoice: InvoiceRecord.createInvoiceFromServer(a0.latest_invoice)} : {}, r10); const eligible_payment_gateways = a0.eligible_payment_gateways; object['eligiblePaymentGateways'] = date != eligible_payment_gateways ? eligible_payment_gateways : date; object['priceChange'] = date != a0.price_change ? GooglePlayPriceChangeRecord.createFromServer(a0.price_change) : date; date = Object.create(SubscriptionRecord.prototype, {constructor: {value: SubscriptionRecord}}); const subscriptionRecord = new SubscriptionRecord(object); return subscriptionRecord instanceof Object ? subscriptionRecord : date; } } } global.__d(_fun29418, 3809, [6, 7, 15, 17, 18, 1886, 3810, 3811, 661, 3813, 1880, 3814, 44, 477, 3815, 1900, 2]) /* metro module 3809, dependencies: [6, 7, 15, 17, 18, 1886, 3810, 3811, 661, 3813, 1880, 3814, 44, 477, 3815, 1900, 2] */;