Files
discord-decomp/sources/records/GiftCodeRecord.tsx
T
2026-07-28 01:06:53 +03:00

196 lines
11 KiB
TypeScript

/* Metro module 7671; source: records/GiftCodeRecord.tsx; dependencies: [6, 7, 15, 17, 18, 1886, 7262, 3803, 1880, 3738, 1391, 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 SubscriptionPlanRecord from './SubscriptionPlanRecord.tsx'; /* Metro dependency 3803 */
import PromotionRecord from './PromotionRecord.tsx'; /* Metro dependency 7262 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as FlagUtilsModule from '../external/discord_common/js/shared/utils/FlagUtils.tsx'; /* Metro dependency 1391 */
import * as PremiumConstantsModule from '../modules/premium/PremiumConstants.tsx'; /* Metro dependency 1880 */
function _fun61286(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#61286, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:6, offset: 0x01b3a52b, size: 303 bytes, params: 8, frame: 20
const env0_0 = require;
let Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = Record;
Object = global.Object;
const value2 = Object.freeze({'PAYMENT_SOURCE_REQUIRED': 1, 'EXISTING_PREMIUM_SUBSCRIPTION_DISALLOWED': 2,
'NOT_SELF_REDEEMABLE': 4});
value = _fun61290(value);
(FileImportTrackerModule).fileFinishedImporting('records/GiftCodeRecord.tsx');
exports.default = value;
exports.GiftCodeFlags = value2;
function _isNativeReflectConstruct_61287() { // fn#61287, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:224, offset: 0x01b3a65a, 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_61287_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun61290(a0) { // fn#61290, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:533, offset: 0x01b3a6b8, size: 311 bytes, params: 2, frame: 17
const GiftCodeRecord2 = GiftCodeRecord;
Inherits(GiftCodeRecord2, a0);
return CreateClass(GiftCodeRecord2, [{key: 'isExpired', value: value_61292}, {key: 'hasMultipleCopies', get: function() {
return this.maxUses > 1;
}}, {key: 'isClaimed', get: function() {
var uses = this.uses;
return uses >= this.maxUses;
}}, {key: 'remainingUses', get: function() {
return this.maxUses - this.uses;
}}, {key: 'isSubscription', get: function() {
return this.subscriptionPlanId != null;
}}, {key: 'premiumSubscriptionType', get: function() {
var value = null;
return this.isSubscription && value != PremiumSubscriptionSKUToPremiumType[this.skuId] ? PremiumSubscriptionSKUToPremiumType[this.skuId] : value;
}}, {key: 'isSelfRedeemable', get: get_61298}, {key: 'isExistingPremiumSubscriptionDisallowed', get: get_61299},
{key: 'analyticsData', get: function() {
return {gift_code: this.code, gift_code_max_uses: this.maxUses};
}}, {key: 'toString', value: function() {
return this.code;
}}], [{key: 'createFromServer', value: value_61302}]);
function GiftCodeRecord({userId, code, skuId, applicationId, uses, maxUses, expiresAt, redeemed, storeListingId, subscriptionPlanId, subscriptionPlan, revoked, entitlementBranches, flags, subscriptionTrial, promotion, giftStyle}) { // fn#61291, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:545, offset: 0x01b3a7ef, size: 310 bytes, params: 2, frame: 20
let value = environment.__proto__;
env1_3(this, GiftCodeRecord);
const value3 = env1_6(GiftCodeRecord);
value = env1_5(this, _isNativeReflectConstruct_61287() ? global.Reflect.construct(value3, [],
env1_6(this).constructor) : value3.apply(this, undefined));
value.userId = userId;
value.code = code;
value.skuId = skuId;
value.applicationId = applicationId;
value.uses = uses;
value.maxUses = maxUses;
value.expiresAt = expiresAt;
value.redeemed = redeemed;
value.storeListingId = storeListingId;
value.subscriptionPlanId = subscriptionPlanId;
value.subscriptionPlan = subscriptionPlan;
value.revoked = revoked;
value.entitlementBranches = entitlementBranches;
value.flags = flags;
value.subscriptionTrial = subscriptionTrial;
value.promotion = promotion;
value.giftStyle = giftStyle;
return value;
}
function value_61292() { // fn#61292, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:1275, offset: 0x01b3a925, size: 60 bytes, params: 1, frame: 13
var r0;
const expiresAt = this.expiresAt;
let value = expiresAt != null;
if (value) {
value = environment.__proto__;
value = (importDefault(3738) /* metro dependency 3738 */)();
value = value.isAfter(expiresAt);
r0 = value;
} else {
r0 = value;
}
return r0;
}
function get_61298() { // fn#61298, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:1760, offset: 0x01b3a9dc, size: 60 bytes, params: 1, frame: 13
const hasFlag = FlagUtilsModule.hasFlag;
const flags = this.flags;
const NOT_SELF_REDEEMABLE = env1_11.NOT_SELF_REDEEMABLE;
return !Reflect.apply(hasFlag, FlagUtilsModule, [flags, NOT_SELF_REDEEMABLE]);
}
function get_61299() { // fn#61299, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:1882, offset: 0x01b3aa18, size: 57 bytes, params: 1, frame: 13
const hasFlag = FlagUtilsModule.hasFlag;
const flags = this.flags;
const EXISTING_PREMIUM_SUBSCRIPTION_DISALLOWED = env1_11.EXISTING_PREMIUM_SUBSCRIPTION_DISALLOWED;
return Reflect.apply(hasFlag, FlagUtilsModule, [flags, EXISTING_PREMIUM_SUBSCRIPTION_DISALLOWED]);
}
function value_61302(a0) { // fn#61302, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7849:2156, offset: 0x01b3aa77, size: 495 bytes, params: 2, frame: 16
var r4;
var r1;
var object;
var promotionRecordBinding;
const object2 = {};
const user = a0.user;
let value = null;
object2.userId = value != user ? a0.user.id : value;
object2.code = a0.code;
object2.skuId = a0.sku_id;
object2.applicationId = a0.application_id;
const uses = a0.uses;
object2.uses = uses;
object2.maxUses = a0.max_uses;
object2.storeListingId = value != a0.store_listing ? a0.store_listing.id : value;
object2.expiresAt = value != a0.expires_at ? (importDefault(3738) /* metro dependency 3738 */)(a0.expires_at) : value;
object2.redeemed = a0.redeemed;
object2.subscriptionPlanId = value != a0.subscription_plan ? a0.subscription_plan.id : a0.subscription_plan_id;
object2.subscriptionPlan = value != a0.subscription_plan ? SubscriptionPlanRecord.createFromServer(a0.subscription_plan) : value;
object2.revoked = false;
let entitlement_branches = a0.entitlement_branches;
entitlement_branches = value != entitlement_branches ? a0.entitlement_branches : value;
object2.entitlementBranches = entitlement_branches;
let flags = a0.flags;
flags = value != flags ? a0.flags : 0;
object2.flags = flags;
object2.giftStyle = a0.gift_style;
let subscription_trial = a0.subscription_trial;
if (value != subscription_trial) {
object = {};
subscription_trial = a0.subscription_trial;
object.id = subscription_trial.id;
subscription_trial = a0.subscription_trial;
object.interval = subscription_trial.interval;
subscription_trial = a0.subscription_trial;
object.intervalCount = subscription_trial.interval_count;
subscription_trial = a0.subscription_trial;
object.skuId = subscription_trial.sku_id;
r4 = object;
} else {
r4 = value;
}
object2.subscriptionTrial = r4;
if (value != a0.promotion) {
value = environment.__proto__;
promotionRecordBinding = PromotionRecord;
value = promotionRecordBinding.createFromServer(a0.promotion);
r1 = value;
} else {
r1 = value;
}
object2.promotion = r1;
value = Object.create(GiftCodeRecord.prototype, {constructor: {value: GiftCodeRecord}});
const giftCodeRecord = new GiftCodeRecord(object2);
return giftCodeRecord instanceof Object ? giftCodeRecord : value;
}
}
}
global.__d(_fun61286, 7671, [6, 7, 15, 17, 18, 1886, 7262, 3803, 1880, 3738, 1391,
2]) /* metro module 7671, dependencies: [6, 7, 15, 17, 18, 1886, 7262, 3803, 1880, 3738, 1391, 2] */;