382 lines
16 KiB
TypeScript
382 lines
16 KiB
TypeScript
/* Metro module 7286; source: modules/premium/promotions/PromotionUtils.tsx; dependencies: [5, 1348, 7262, 3808, 7064, 7261, 1880, 661, 4237, 4002, 507, 477, 683, 1391, 1365, 21, 1367, 7263, 3802, 2] */
|
|
function _fun58765(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#58765, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:6, offset: 0x016d65f5, size: 475 bytes, params: 8, frame: 24
|
|
let env0_0 = require;
|
|
const _arrayLikeToArray_58768 = function(a0, a1) {
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var value3;
|
|
var length;
|
|
var value5;
|
|
var value = undefined;
|
|
var value2 = value == null;
|
|
reducibleJoin2: while (true) {
|
|
if (value2) {
|
|
r0 = value2;
|
|
break reducibleJoin2;
|
|
}
|
|
value3 = value > a0.length;
|
|
r0 = value3;
|
|
break reducibleJoin2;
|
|
}
|
|
reducibleJoin4: while (true) {
|
|
if (r0) {
|
|
length = a0.length;
|
|
r1 = length;
|
|
break reducibleJoin4;
|
|
}
|
|
r1 = value;
|
|
break reducibleJoin4;
|
|
}
|
|
value = (0, global.Array)(r1);
|
|
var value4 = 0;
|
|
if (value4 < r1) {
|
|
r2 = value4;
|
|
reducibleLoop5: while (true) {
|
|
value[r2] = a0[r2];
|
|
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
if (value5 < r1) {
|
|
r2 = value5;
|
|
continue reducibleLoop5;
|
|
}
|
|
break reducibleLoop5;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
const closure = function(a0) {
|
|
var object = {code: a0.code, userId: a0.user_id, claimedAt: a0.claimed_at};
|
|
object.promotion = PromotionRecord.createFromServer(a0.promotion);
|
|
return object;
|
|
};
|
|
const closure2 = getNextUnseenOutboundPromotionId;
|
|
const closure3 = function({partnerId}) {
|
|
return partnerId === require(dependencyMap[17]).LOGITECH_PARTNER_ID;
|
|
};
|
|
const closure4 = shouldShowOutboundPromotionOnPlatform;
|
|
const closure5 = function({promotionType}) {
|
|
return promotionType === require(dependencyMap[17]).PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING;
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(5) /* metro dependency 5 */;
|
|
const userSettingsProtoStore = importDefault(1348) /* metro dependency 1348: UserSettingsProtoStore */;
|
|
const promotionRecord = importDefault(7262) /* metro dependency 7262: PromotionRecord */;
|
|
const subscriptionStore = importDefault(3808) /* metro dependency 3808: SubscriptionStore */;
|
|
const userOfferStore = importDefault(7064) /* metro dependency 7064: UserOfferStore */;
|
|
const promotionsStore = importDefault(7261) /* metro dependency 7261: PromotionsStore */;
|
|
let value = require(1880) /* metro dependency 1880: PremiumConstants */;
|
|
const env0_9 = value.PremiumTypes;
|
|
const env0_10 = value.PromotionFlags;
|
|
value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_11 = value.AnalyticEvents;
|
|
const env0_12 = value.Endpoints;
|
|
const env0_13 = value.Platforms;
|
|
(require(4237) /* metro dependency 4237: Constants */).ActivityPlatform;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/premium/promotions/PromotionUtils.tsx');
|
|
exports.getPromotionImageURL = getPromotionImageURL;
|
|
exports.claimedOutboundPromotionCodeFromServer = closure;
|
|
exports.claimOutboundPromotion = function() {
|
|
return _claimOutboundPromotion.apply(this, arguments);
|
|
};
|
|
exports.getOutboundPromotionRedemptionUrl = function(a0, a1) {
|
|
var r0;
|
|
var property;
|
|
var value;
|
|
if (a1.outboundRedemptionUrlFormat == null) {
|
|
r0 = a1.outboundRedemptionPageLink ?? '';
|
|
} else if (a1.outboundRedemptionUrlFormat !== '') {
|
|
property = a1.outboundRedemptionUrlFormat;
|
|
value = (0, global.encodeURIComponent)(a0);
|
|
value = property.replace('{code}', value);
|
|
r0 = value;
|
|
} else {
|
|
r0 = a1.outboundRedemptionPageLink ?? '';
|
|
}
|
|
return r0;
|
|
};
|
|
exports.getNextUnseenOutboundPromotionId = closure2;
|
|
exports.shouldShowOutboundPromotionNotice = shouldShowOutboundPromotionNotice;
|
|
exports.isLogitechPromotion = closure3;
|
|
exports.shouldShowOutboundPromotionOnPlatform = closure4;
|
|
exports.isTrialUserEligibleToSeeOutboundPromotion = function(a0, a1) {
|
|
return a1[a0.id] != null || a0.isRedeemableByTrialUsers();
|
|
};
|
|
exports.getClaimedOutboundPromotionCodeMap = getClaimedOutboundPromotionCodeMap;
|
|
exports.getClaimedEndedOutboundPromotions = function(a0, a1) {
|
|
var Set = global.Set;
|
|
var value = a1.map(_fun58788);
|
|
value = new Set(value);
|
|
var env0_0 = value;
|
|
return a0.filter(_fun58789);
|
|
};
|
|
exports.isRecurringPromotion = closure5;
|
|
exports.isRecurring3PRewardsLocked = isRecurring3PRewardsLocked;
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_58766(a0, a1) { // fn#58766, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:291, offset: 0x016d67d0, size: 370 bytes, params: 3, frame: 20
|
|
var r6;
|
|
var r9;
|
|
var r5;
|
|
var value3;
|
|
var regexp;
|
|
const env0_0 = a0;
|
|
const Symbol = global.Symbol;
|
|
let value = typeof Symbol !== 'undefined';
|
|
let r1 = value && a0[global.Symbol.iterator];
|
|
r1 = !r1 ? a0['@@iterator'] : r1;
|
|
if (r1) {
|
|
value = r1.call(a0);
|
|
return value.next.bind(value);
|
|
}
|
|
const Array = global.Array;
|
|
if (Array.isArray(a0)) {
|
|
if (r1) {
|
|
}
|
|
return _fun58767;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_58768(a0, value);
|
|
r5 = value;
|
|
} else {
|
|
value3 = ({}).toString.call(a0).slice(8, -1);
|
|
r6 = value3 === 'Object' && a0.constructor;
|
|
r9 = r6 ? a0.constructor.name : value3;
|
|
if (r9 === 'Map') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Set') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Arguments') {
|
|
value = _arrayLikeToArray_58768(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_58768(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun58767;
|
|
}
|
|
const TypeError = global.TypeError;
|
|
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
|
|
}
|
|
|
|
function _claimOutboundPromotion() { // fn#58770, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:1354, offset: 0x016d6984, size: 48 bytes, params: 1, frame: 14
|
|
return env0_3(_fun58772).apply(this, arguments);
|
|
}
|
|
|
|
function getNextUnseenOutboundPromotionId() { // fn#58773, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:1862, offset: 0x016d6afe, size: 264 bytes, params: 1, frame: 18
|
|
var lastDismissedObjectId;
|
|
var property;
|
|
const outboundPromotions = PromotionsStore.outboundPromotions;
|
|
const env0_0 = PromotionsStore.consumedInboundPromotionId;
|
|
let value2 = outboundPromotions.filter(_fun58774);
|
|
const userContent = UserSettingsProtoStore.settings.userContent;
|
|
const value3 = null;
|
|
let value4 = undefined;
|
|
if (value3 == userContent) {
|
|
lastDismissedObjectId = value4;
|
|
} else {
|
|
property = userContent.recurringDismissibleContentStates[(require(1365) /* metro dependency 1365: dismissible_content */).DismissibleContent.THIRD_PARTY_OUTBOUND_PROMO_NAGBAR];
|
|
lastDismissedObjectId = value3 == property ? value4 : property.lastDismissedObjectId;
|
|
}
|
|
const r5 = value3 == lastDismissedObjectId ? value2 : value2.filter(_fun58775);
|
|
const premiumTypeSubscription = SubscriptionStore.getPremiumTypeSubscription();
|
|
const r4 = value3 == premiumTypeSubscription || !premiumTypeSubscription.hasActiveTrial ? UserOfferStore.hasAnyUnexpiredOffer() ? r5.filter(function(a0) {
|
|
return a0.isRedeemableByTrialUsers();
|
|
}) : r5 : r5.filter(_fun58776);
|
|
return r4.length === 0 ? value3 : r4.sort(function(a0, a1) {
|
|
var Date = global.Date;
|
|
var value2 = new Date(a0.startDate);
|
|
Date = global.Date;
|
|
var value4 = new Date(a1.startDate);
|
|
value2 = 1;
|
|
return value2 < value4 ? -1 : value2;
|
|
})[0].id;
|
|
}
|
|
|
|
function shouldShowOutboundPromotionOnPlatform(a0) { // fn#58779, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:2632, offset: 0x016d6d3d, size: 70 bytes, params: 2, frame: 13
|
|
const isIOS2 = (require(477) /* metro dependency 477: PlatformUtils */).isIOS();
|
|
return isIOS2 ? !a0.hasFlag(PromotionFlags.IS_BLOCKED_IOS) : !isIOS2;
|
|
}
|
|
|
|
function getPromotionImageURL(a0, a1) { // fn#58781, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:2958, offset: 0x016d6db7, size: 204 bytes, params: 3, frame: 25
|
|
let value = require(4002) /* metro dependency 4002: shared */;
|
|
value = value.isThemeDark(a1);
|
|
const r7 = value ? 'logo-dark' : 'logo-light';
|
|
const GLOBAL_ENV = global.window.GLOBAL_ENV;
|
|
const CDN_HOST = GLOBAL_ENV.CDN_HOST;
|
|
return CDN_HOST != null ? 'https://' + CDN_HOST + '/promotions/' + a0 + '/' + r7 + '?size=256' : '' + global.location.protocol + global.window.GLOBAL_ENV.API_ENDPOINT + '/promotions/' + a0 + '/' + r7 + '?size=256';
|
|
}
|
|
|
|
function shouldShowOutboundPromotionNotice() { // fn#58784, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:3814, offset: 0x016d6ee1, size: 97 bytes, params: 1, frame: 18
|
|
var r0;
|
|
var value;
|
|
const nextUnseenOutboundPromotionId = getNextUnseenOutboundPromotionId();
|
|
const value3 = nextUnseenOutboundPromotionId != null;
|
|
if (value3) {
|
|
value = require(1367) /* metro dependency 1367: DismissibleContentUtils */;
|
|
value = !value.isTimeRecurringSnowflakeBoundDismissibleContentDismissed((require(1365) /* metro dependency 1365: dismissible_content */).DismissibleContent.THIRD_PARTY_OUTBOUND_PROMO_NAGBAR,
|
|
|
|
nextUnseenOutboundPromotionId, {cooldownDurationMs: 259200000});
|
|
r0 = value;
|
|
} else {
|
|
r0 = value3;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getClaimedOutboundPromotionCodeMap(a0) { // fn#58786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:4392, offset: 0x016d6f66, size: 73 bytes, params: 2, frame: 14
|
|
var r2;
|
|
var value3;
|
|
var code;
|
|
var promotion;
|
|
var id;
|
|
var value4;
|
|
const object2 = {};
|
|
const value = _createForOfIteratorHelperLoose_58766(a0);
|
|
const value2 = value();
|
|
let done = value2.done;
|
|
if (!done) {
|
|
for (r2 = value2; true; r2 = value4) {
|
|
value3 = r2.value;
|
|
code = value3.code;
|
|
promotion = value3.promotion;
|
|
id = promotion.id;
|
|
object2[id] = code;
|
|
value4 = value();
|
|
done = value4.done;
|
|
if (done) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return object2;
|
|
}
|
|
|
|
function getClaimedEndedOutboundPromotions(a0, a1) { // fn#58787, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:4597, offset: 0x016d6faf, size: 72 bytes, params: 3, frame: 14
|
|
const Set = global.Set;
|
|
const set = new Set(a1.map(function(a0) {
|
|
return a0.id;
|
|
}));
|
|
return a0.filter(_fun58789);
|
|
}
|
|
|
|
function isRecurring3PRewardsLocked(a0) { // fn#58790, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:4899, offset: 0x016d7054, size: 80 bytes, params: 2, frame: 15
|
|
var r0;
|
|
var defaultImport;
|
|
let value = a0 == null;
|
|
if (value) {
|
|
r0 = value;
|
|
} else {
|
|
defaultImport = importDefault(3802) /* metro dependency 3802: PremiumUtils */;
|
|
value = defaultImport.isPremiumExactly(a0, PremiumTypes.TIER_2);
|
|
value = value === false;
|
|
r0 = value;
|
|
}
|
|
r0 = !r0 ? a0.isFractionalPremiumWithNoStandardSub() : r0;
|
|
return r0;
|
|
}
|
|
|
|
async function _fun58772({promotionId, promotionTitle, partnerId, analyticsLocations}) { // fn#58772, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:1423, offset: 0x016d69c6, size: 312 bytes, params: 2, frame: 24
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
await undefined;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
value = environment.__proto__.__proto__;
|
|
let binding = env2_0;
|
|
const HTTP = binding(env2_2[10]).HTTP;
|
|
const post = HTTP.post;
|
|
const object2 = {};
|
|
object2.url = env2_12.CLAIM_OUTBOUND_PROMOTION_CODE(promotionId);
|
|
object2.rejectWithError = false;
|
|
await Reflect.apply(post, HTTP, [object2]);
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
const body = undefined.body;
|
|
const isIOS2 = env2_0(env2_2[11]).isIOS();
|
|
binding = env2_13;
|
|
const r14 = isIOS2 ? binding.IOS : binding.ANDROID;
|
|
const value7 = env2_1(env2_2[12]);
|
|
const track = value7.track;
|
|
const OUTBOUND_PROMOTION_CLAIMED = env2_11.OUTBOUND_PROMOTION_CLAIMED;
|
|
Reflect.apply(track, value7, [OUTBOUND_PROMOTION_CLAIMED, {platform: r14, status: undefined.status,
|
|
location_stack: analyticsLocations, promotion_id: promotionId, name: promotionTitle ?? null,
|
|
partner: partnerId ?? null}]);
|
|
return env2_16(body);
|
|
}
|
|
|
|
function _fun58774(a0) { // fn#58774, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:1978, offset: 0x016d6c06, size: 99 bytes, params: 2, frame: 15
|
|
var r0;
|
|
var moduleValue;
|
|
const id = a0.id;
|
|
let value = id !== consumedInboundPromotionId;
|
|
if (value) {
|
|
value = environment.__proto__;
|
|
moduleValue = require(1391) /* metro dependency 1391: FlagUtils */;
|
|
value = !moduleValue.hasFlag(a0.flags, PromotionFlags.SUPPRESS_NOTIFICATION);
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
if (r0) {
|
|
value = environment.__proto__;
|
|
value = !isLogitechPromotion(a0);
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function _fun58775({id}) { // fn#58775, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:2269, offset: 0x016d6c69, size: 61 bytes, params: 2, frame: 13
|
|
let value = environment.__proto__;
|
|
value = Reflect.apply((importDefault(21) /* metro dependency 21: SnowflakeUtils */).compare, value, [id,
|
|
lastDismissedObjectId]);
|
|
return value === 1;
|
|
}
|
|
|
|
function _fun58776(a0) { // fn#58776, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:2416, offset: 0x016d6ca6, size: 15 bytes, params: 2, frame: 9
|
|
return a0.isRedeemableByTrialUsers();
|
|
}
|
|
|
|
function _fun58789({promotion}) { // fn#58789, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7464:4698, offset: 0x016d6ff7, size: 93 bytes, params: 2, frame: 12
|
|
var r0;
|
|
const binding = env0_0;
|
|
let value = binding.has(promotion.id);
|
|
if (value) {
|
|
r0 = !value;
|
|
} else {
|
|
value = environment.__proto__;
|
|
value = !isRecurringPromotion(promotion);
|
|
r0 = value;
|
|
}
|
|
if (r0) {
|
|
value = environment.__proto__;
|
|
value = !isLogitechPromotion(promotion);
|
|
r0 = value;
|
|
}
|
|
if (r0) {
|
|
value = environment.__proto__;
|
|
value = shouldShowOutboundPromotionOnPlatform(promotion);
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|