559 lines
19 KiB
TypeScript
559 lines
19 KiB
TypeScript
// Metro module 5810 (f5811).
|
|
import { isAvatarDecorationRecord } from "./records/AvatarDecorationRecord";
|
|
import { isNameplateRecord } from "./records/NameplateRecord";
|
|
import { isProfileEffectRecord } from "./records/ProfileEffectRecord";
|
|
import { isProfileFrameRecord } from "./records/ProfileFrameRecord";
|
|
import { AssetDisplayConfigRecord } from "./records/ShopAssetConfigRecord";
|
|
import { LIMITED_TIME_BADGE_DAYS_THRESHOLD, SHOP_CARD_PER_PRODUCT_NEW_BADGE_EXPIRY_SETTINGS, EXTERNAL_PRODUCT_SKU_IDS } from "./CollectiblesShopConstants";
|
|
import { EntitlementTypes, PriceSetAssignmentPurchaseTypes, COLLECTIBLES_APPLICATION_ID } from "../../Constants";
|
|
import { CurrencyCodes } from "../../_bundle/Module505";
|
|
import PremiumUtils from "../../utils/PremiumUtils";
|
|
import { getPerkSource } from "../premium/perks_state/PerksStateUtils";
|
|
import { Perk, PerkSource } from "../../_bundle/Module1892";
|
|
import { getIsCrepeEnabled } from "../croissant/crepe/CrepeExperiment";
|
|
import { formatPrice } from "../../utils/PriceUtils";
|
|
import { isAndroid, isIOS } from "../../utils/PlatformUtils";
|
|
import { CollectiblesItemType } from "../../_bundle/Module1901";
|
|
import { concat, uniqBy, flatMap } from "../../_bundle/Module12";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import { getProductOrbPrice } from "./utils/CollectiblesProductUtils";
|
|
function $mk77182($env) {
|
|
return (a0, a1) => {
|
|
let env25626;
|
|
const r3 = $env;
|
|
const r4 = r3[1];
|
|
const r7 = r3[0];
|
|
const r5 = env25626 = {};
|
|
env25626[0] = r7;
|
|
const r10 = a1.prices[r4];
|
|
const r6 = r10 == null ? void 0 : r10.countryPrices?.prices;
|
|
const r13 = r6 == null;
|
|
let r14 = null;
|
|
if (!r13) {
|
|
let r17 = r7 == null ? r6[0] : r6.find($mk77183(r5));
|
|
if (r17 == null) {
|
|
r17 = null;
|
|
}
|
|
r14 = r17;
|
|
}
|
|
let r19 = r14?.amount;
|
|
if (r19 == null) {
|
|
r19 = 0;
|
|
}
|
|
return a0 + r19;
|
|
};
|
|
}
|
|
function $mk77183($env) {
|
|
return (a0) => a0.currency === $env[0];
|
|
}
|
|
let getItemRecordsFromCategories, c3623_15, c3623_16, c3623_17, c3623_20;
|
|
let $mk77184 = function() {
|
|
return (a0, a1) => {
|
|
let r16;
|
|
if (a1 != null) {
|
|
if (a1.type === CollectiblesItemType.VARIANTS_GROUP && a1.variants != null) {
|
|
r16 = concat(a0, a1.variants.map((variant) => ({
|
|
...variant,
|
|
variantGroupStoreListingId: a1.storeListingId,
|
|
eligibleOffers: a1.eligibleOffers
|
|
})));
|
|
} else {
|
|
a0.push(a1);
|
|
r16 = a0;
|
|
}
|
|
} else {
|
|
a0.push(a1);
|
|
r16 = a0;
|
|
}
|
|
return r16;
|
|
};
|
|
};
|
|
let env3623 = {};
|
|
export function getItemRecordsFromPurchases(a0, a1) {
|
|
if (a1 === CollectiblesItemType.AVATAR_DECORATION) {
|
|
return uniqBy(flatMap([...a0.values()], "items").filter(isAvatarDecorationRecord), "skuId");
|
|
}
|
|
if (a1 === CollectiblesItemType.NAMEPLATE) {
|
|
return uniqBy(flatMap([...a0.values()], "items").filter(isNameplateRecord), "skuId");
|
|
}
|
|
if (a1 === CollectiblesItemType.PROFILE_EFFECT) {
|
|
return uniqBy(flatMap([...a0.values()], "items").filter(isProfileEffectRecord), "skuId");
|
|
}
|
|
if (a1 === CollectiblesItemType.PROFILE_FRAME) {
|
|
return uniqBy(flatMap([...a0.values()], "items").filter(isProfileFrameRecord), "skuId");
|
|
}
|
|
return [];
|
|
}
|
|
getItemRecordsFromCategories = function getItemRecordsFromCategories(a0, a1) {
|
|
const r25 = uniqBy(flatMap([...a0.values()], "products").reduce($mk77184(), []), "storeListingId");
|
|
if (a1 === CollectiblesItemType.AVATAR_DECORATION) {
|
|
return uniqBy(flatMap(r25, "items").filter(isAvatarDecorationRecord), "skuId");
|
|
}
|
|
if (a1 === CollectiblesItemType.NAMEPLATE) {
|
|
return uniqBy(flatMap(r25, "items").filter(isNameplateRecord), "skuId");
|
|
}
|
|
if (a1 === CollectiblesItemType.PROFILE_EFFECT) {
|
|
return uniqBy(flatMap(r25, "items").filter(isProfileEffectRecord), "skuId");
|
|
}
|
|
if (a1 === CollectiblesItemType.PROFILE_FRAME) {
|
|
return uniqBy(flatMap(r25, "items").filter(isProfileFrameRecord), "skuId");
|
|
}
|
|
return [];
|
|
};
|
|
c3623_15 = {
|
|
NITRO: "nitro",
|
|
THIRDPARTY: "thirdparty"
|
|
};
|
|
const r46 = {};
|
|
r46[c3623_15.NITRO] = "nitro";
|
|
r46[c3623_15.THIRDPARTY] = "xbox";
|
|
c3623_16 = r46;
|
|
c3623_17 = {
|
|
original: -1,
|
|
discountPercentage: -1
|
|
};
|
|
c3623_20 = [CurrencyCodes.KZT, CurrencyCodes.NGN, CurrencyCodes.EGP];
|
|
export { c3623_15 as ShopDiscountSource };
|
|
export function getAnalyticsShopDiscountSource(a0) {
|
|
return a0 != null ? c3623_16[a0] : null;
|
|
}
|
|
export function getShopDiscountSource(a0) {
|
|
if (PremiumUtils.canUseShopDiscounts(a0)) {
|
|
if (PremiumUtils.canUseCollectibles(a0)) {
|
|
return c3623_15.NITRO;
|
|
}
|
|
const perkSource = getPerkSource(a0?.perks, Perk.SHOP_DISCOUNTS);
|
|
return (perkSource == null ? void 0 : perkSource.includes(PerkSource.SOURCE_NITRO)) ? c3623_15.NITRO : getIsCrepeEnabled("getShopDiscountSource") ? (perkSource == null ? void 0 : perkSource.includes(PerkSource.SOURCE_THIRDPARTY_CROISSANT)) ? c3623_15.THIRDPARTY : null : null;
|
|
}
|
|
return null;
|
|
}
|
|
export function isPremiumCollectiblesProduct(a0) {
|
|
return a0?.premiumType != null;
|
|
}
|
|
export function isPremiumCollectiblesPurchase(a0) {
|
|
return a0?.purchaseType === EntitlementTypes.PREMIUM_PURCHASE;
|
|
}
|
|
export function getAssetForAvatarDecorationProduct(a0) {
|
|
return a0.items.find(isAvatarDecorationRecord)?.asset;
|
|
}
|
|
export function getPriceForCollectiblesProduct(a0, a1, a2) {
|
|
const r11 = a0.prices[a2 ? a1 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE : a1 ? PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.DEFAULT];
|
|
const r12 = r11 == null ? void 0 : r11.countryPrices?.prices;
|
|
const r15 = r12 == null;
|
|
let r16 = null;
|
|
if (!r15) {
|
|
let r17 = r12[0];
|
|
if (r17 == null) {
|
|
r17 = null;
|
|
}
|
|
r16 = r17;
|
|
}
|
|
return r16;
|
|
}
|
|
export function getFormattedPriceForCollectiblesProduct(a0, a1, a2) {
|
|
const r13 = a0.prices[a2 ? a1 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE : a1 ? PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.DEFAULT];
|
|
const r14 = r13 == null ? void 0 : r13.countryPrices?.prices;
|
|
const r17 = r14 == null;
|
|
let r8 = null;
|
|
if (!r17) {
|
|
let r18 = r14[0];
|
|
if (r18 == null) {
|
|
r18 = null;
|
|
}
|
|
r8 = r18;
|
|
}
|
|
return r8 == null ? "" : formatPrice(r8?.amount, r8?.currency);
|
|
}
|
|
export function getDefaultPriceSetAssignmentPurchaseType(a0, a1) {
|
|
return !(!isAndroid() && !isIOS()) && a1 !== CurrencyCodes.DISCORD_ORB ? a0 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE : a0 ? PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.DEFAULT;
|
|
}
|
|
export function getBundleItemsPriceSum(a0, a1) {
|
|
let env15193;
|
|
const r2 = env15193 = {
|
|
$parent: env3623
|
|
};
|
|
env15193[0] = a1;
|
|
const bundledProducts = a0.bundledProducts;
|
|
if (bundledProducts == null) {
|
|
return 0;
|
|
}
|
|
env15193[1] = !(!isAndroid() && !isIOS()) && a1 !== CurrencyCodes.DISCORD_ORB ? PriceSetAssignmentPurchaseTypes.MOBILE : PriceSetAssignmentPurchaseTypes.DEFAULT;
|
|
return bundledProducts.reduce($mk77182(r2), 0);
|
|
}
|
|
export function extractPriceByPurchaseTypes(a0, a1, a2) {
|
|
let env15194;
|
|
const r4 = env15194 = {};
|
|
env15194[0] = a2;
|
|
const r8 = a0.prices[a1];
|
|
const r9 = r8 == null ? void 0 : r8.countryPrices?.prices;
|
|
const r12 = r9 == null;
|
|
let r13 = null;
|
|
if (!r12) {
|
|
let r16 = a2 == null ? r9[0] : r9.find($mk77183(r4));
|
|
if (r16 == null) {
|
|
r16 = null;
|
|
}
|
|
r13 = r16;
|
|
}
|
|
return r13;
|
|
}
|
|
export { c3623_17 as NoDiscount };
|
|
export const DISCOUNT_DISPLAY_MINIMUM_THRESHOLD = 5;
|
|
export function getProductDiscount(a0, a1, a2) {
|
|
if (a0 == null) {
|
|
return c3623_17;
|
|
}
|
|
let env15195;
|
|
const r5 = env15195 = {
|
|
$parent: env3623
|
|
};
|
|
env15195[0] = a2;
|
|
const bundledProducts = a0.bundledProducts;
|
|
const r1 = bundledProducts == null;
|
|
let original = 0;
|
|
if (!r1) {
|
|
env15195[1] = !(!isAndroid() && !isIOS()) && a2 !== CurrencyCodes.DISCORD_ORB ? PriceSetAssignmentPurchaseTypes.MOBILE : PriceSetAssignmentPurchaseTypes.DEFAULT;
|
|
original = bundledProducts.reduce($mk77182(r5), 0);
|
|
}
|
|
if (original <= 0) {
|
|
return c3623_17;
|
|
}
|
|
const r42 = !(!isAndroid() && !isIOS()) && a2 !== CurrencyCodes.DISCORD_ORB ? a1 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE : a1 ? PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.DEFAULT;
|
|
let env15196;
|
|
const r45 = env15196 = {};
|
|
env15196[0] = a2;
|
|
const r47 = a0.prices[r42];
|
|
const r49 = r47 == null ? void 0 : r47.countryPrices?.prices;
|
|
const r52 = r49 == null;
|
|
let r53 = null;
|
|
if (!r52) {
|
|
let r56 = a2 == null ? r49[0] : r49.find($mk77183(r45));
|
|
if (r56 == null) {
|
|
r56 = null;
|
|
}
|
|
r53 = r56;
|
|
}
|
|
return r53 == null ? c3623_17 : {
|
|
original,
|
|
discountPercentage: Math.round((original - r53.amount) / original * 100)
|
|
};
|
|
}
|
|
export function getCollectiblesProductPriceComparisons(a0, a1) {
|
|
let hasShopDiscount2 = a1.hasShopDiscount;
|
|
const discount = a1.discount;
|
|
const r15 = a0.prices[PriceSetAssignmentPurchaseTypes.DEFAULT];
|
|
const r16 = r15 == null ? void 0 : r15.countryPrices?.prices;
|
|
const r19 = r16 == null;
|
|
let defaultPrice = null;
|
|
if (!r19) {
|
|
let r21 = r16[0];
|
|
if (r21 == null) {
|
|
r21 = null;
|
|
}
|
|
defaultPrice = r21;
|
|
}
|
|
if (defaultPrice == null) {
|
|
return null;
|
|
}
|
|
if (defaultPrice.amount <= 0) {
|
|
return {
|
|
defaultPrice,
|
|
showDefaultPriceOnly: true
|
|
};
|
|
}
|
|
const r26 = a0.prices[PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2];
|
|
const r28 = r26 == null ? void 0 : r26.countryPrices?.prices;
|
|
const r31 = r28 == null;
|
|
let premiumPrice = null;
|
|
if (!r31) {
|
|
let r33 = r28[0];
|
|
if (r33 == null) {
|
|
r33 = null;
|
|
}
|
|
premiumPrice = r33;
|
|
}
|
|
const originalPrice = a0?.type === CollectiblesItemType.BUNDLE ? hasShopDiscount2 ? {
|
|
...defaultPrice,
|
|
amount: discount.original
|
|
} : defaultPrice : defaultPrice;
|
|
if (hasShopDiscount2) {
|
|
hasShopDiscount2 = premiumPrice != null;
|
|
}
|
|
const finalPrice = hasShopDiscount2 ? premiumPrice : originalPrice;
|
|
return {
|
|
defaultPrice,
|
|
originalPrice,
|
|
premiumPrice,
|
|
finalPrice,
|
|
showDiscountPrice: hasShopDiscount2,
|
|
finalPriceIsDifferent: finalPrice.amount !== originalPrice.amount,
|
|
showDefaultPriceOnly: false
|
|
};
|
|
}
|
|
export function isFreeCollectiblesProduct(a0) {
|
|
const r10 = a0.prices[PriceSetAssignmentPurchaseTypes.DEFAULT];
|
|
const r11 = r10 == null ? void 0 : r10.countryPrices?.prices;
|
|
const r14 = r11 == null;
|
|
let r15 = null;
|
|
if (!r14) {
|
|
let r16 = r11[0];
|
|
if (r16 == null) {
|
|
r16 = null;
|
|
}
|
|
r15 = r16;
|
|
}
|
|
return r15?.amount === 0;
|
|
}
|
|
export function extendVariantsProducts(a0) {
|
|
return a0.reduce($mk77184(), []);
|
|
}
|
|
export function getProductsFromCategories(a0, a1) {
|
|
const r15 = flatMap([...a0.values()], "products");
|
|
return uniqBy(a1 ? r15.reduce($mk77184(), []) : r15, "storeListingId");
|
|
}
|
|
export { getItemRecordsFromCategories };
|
|
export function getCollectibleTypeLabel(a0) {
|
|
if (CollectiblesItemType.AVATAR_DECORATION === a0) {
|
|
return intl.string(t["7v0T9P"]);
|
|
}
|
|
if (CollectiblesItemType.PROFILE_EFFECT === a0) {
|
|
return intl.string(t.wR5wOo);
|
|
}
|
|
if (CollectiblesItemType.NAMEPLATE === a0) {
|
|
return intl.string(t.x5CoXR);
|
|
}
|
|
if (CollectiblesItemType.PROFILE_FRAME === a0) {
|
|
return intl.string(t.GWrZOd);
|
|
}
|
|
return null;
|
|
}
|
|
export function getAssetDisplayConfig(a0) {
|
|
return a0 != null ? AssetDisplayConfigRecord.fromServer(a0) : void 0;
|
|
}
|
|
export function getAvatarDecorationsFromPurchases(a0) {
|
|
return getItemRecordsFromPurchases(a0, CollectiblesItemType.AVATAR_DECORATION);
|
|
}
|
|
export function getAvatarDecorationsFromCategories(a0) {
|
|
return getItemRecordsFromCategories(a0, CollectiblesItemType.AVATAR_DECORATION);
|
|
}
|
|
export function getAvatarDecorations(a0, a1) {
|
|
return uniqBy([...getItemRecordsFromPurchases(a0, CollectiblesItemType.AVATAR_DECORATION), ...getItemRecordsFromCategories(a1, CollectiblesItemType.AVATAR_DECORATION)], "skuId");
|
|
}
|
|
export function getNameplatesFromPurchases(a0) {
|
|
return getItemRecordsFromPurchases(a0, CollectiblesItemType.NAMEPLATE);
|
|
}
|
|
export function getNameplatesFromCategories(a0) {
|
|
return getItemRecordsFromCategories(a0, CollectiblesItemType.NAMEPLATE);
|
|
}
|
|
export function getNameplates(a0, a1) {
|
|
return uniqBy([...getItemRecordsFromPurchases(a0, CollectiblesItemType.NAMEPLATE), ...getItemRecordsFromCategories(a1, CollectiblesItemType.NAMEPLATE)], "skuId");
|
|
}
|
|
export function getProfileEffectsFromPurchases(a0) {
|
|
return getItemRecordsFromPurchases(a0, CollectiblesItemType.PROFILE_EFFECT);
|
|
}
|
|
export function getProfileEffectsFromCategories(a0) {
|
|
return getItemRecordsFromCategories(a0, CollectiblesItemType.PROFILE_EFFECT);
|
|
}
|
|
export function getProfileEffects(a0, a1) {
|
|
return uniqBy([...getItemRecordsFromPurchases(a0, CollectiblesItemType.PROFILE_EFFECT), ...getItemRecordsFromCategories(a1, CollectiblesItemType.PROFILE_EFFECT)], "skuId");
|
|
}
|
|
export function groupProfileEffects(a0, a1) {
|
|
const itemRecordsFromPurchases = getItemRecordsFromPurchases(a1, CollectiblesItemType.PROFILE_EFFECT);
|
|
let c15200_0 = itemRecordsFromPurchases;
|
|
return {
|
|
purchased: itemRecordsFromPurchases,
|
|
shopPreviews: getItemRecordsFromCategories(a0, CollectiblesItemType.PROFILE_EFFECT).filter(({ skuId }) => !c15200_0.some((item) => item.skuId === skuId))
|
|
};
|
|
}
|
|
export function getProfileFramesFromPurchases(a0) {
|
|
return getItemRecordsFromPurchases(a0, CollectiblesItemType.PROFILE_FRAME);
|
|
}
|
|
export function getProfileFramesFromCategories(a0) {
|
|
return getItemRecordsFromCategories(a0, CollectiblesItemType.PROFILE_FRAME);
|
|
}
|
|
export function getProfileFrames(a0, a1) {
|
|
return uniqBy([...getItemRecordsFromPurchases(a0, CollectiblesItemType.PROFILE_FRAME), ...getItemRecordsFromCategories(a1, CollectiblesItemType.PROFILE_FRAME)], "skuId");
|
|
}
|
|
export function isCollectiblesGiftCode(a0) {
|
|
return a0.applicationId === COLLECTIBLES_APPLICATION_ID;
|
|
}
|
|
export const LOGO_ASPECT_RATIO = 3.8;
|
|
export function getLogoSize(a0) {
|
|
return 3.8 * a0;
|
|
}
|
|
export function getDaysRemaining(a0) {
|
|
const date = new Date();
|
|
const r19 = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
return Math.floor((Date.UTC(a0.getFullYear(), a0.getMonth(), a0.getDate()) - r19) / 86400000);
|
|
}
|
|
export function shouldShowLimitedTimeBadge(a0) {
|
|
let r16 = a0 != null;
|
|
if (r16) {
|
|
const date = new Date();
|
|
const r23 = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
r16 = Math.floor((Date.UTC(a0.getFullYear(), a0.getMonth(), a0.getDate()) - r23) / 86400000) <= LIMITED_TIME_BADGE_DAYS_THRESHOLD;
|
|
}
|
|
return r16;
|
|
}
|
|
export function isProductNew(a0) {
|
|
const r7 = SHOP_CARD_PER_PRODUCT_NEW_BADGE_EXPIRY_SETTINGS[a0];
|
|
return r7 != null && new Date().getTime() < r7;
|
|
}
|
|
export function isBundleProduct(a0) {
|
|
return a0?.type === CollectiblesItemType.BUNDLE;
|
|
}
|
|
export function getCollectiblesItemTypeForDisplay(a0) {
|
|
let BUNDLE;
|
|
if (a0 != null) {
|
|
if (a0.type === CollectiblesItemType.BUNDLE) {
|
|
BUNDLE = CollectiblesItemType.BUNDLE;
|
|
} else {
|
|
const items = a0.items;
|
|
BUNDLE = items == null ? void 0 : items[0]?.type;
|
|
}
|
|
return BUNDLE;
|
|
}
|
|
}
|
|
export function getCollectiblesPrice({ invoicePreview, selectedSkuId, skusById }) {
|
|
const r1 = invoicePreview == null;
|
|
let r7 = void 0;
|
|
if (!r1) {
|
|
const invoiceItems = invoicePreview.invoiceItems;
|
|
r7 = invoiceItems == null ? void 0 : invoiceItems[0]?.unitPrice;
|
|
}
|
|
const r5 = r7 != null ? {
|
|
amount: r7.amount,
|
|
currency: r7.currency
|
|
} : void 0;
|
|
let r16 = r5;
|
|
if (r16 == null) {
|
|
r16 = r5;
|
|
if (selectedSkuId != null) {
|
|
const r17 = skusById[selectedSkuId];
|
|
r16 = r17?.price != null ? {
|
|
amount: r17.price.amount,
|
|
currency: r17.price.currency
|
|
} : r5;
|
|
}
|
|
}
|
|
return r16;
|
|
}
|
|
export function shouldHideGiftingForCurrency(a0) {
|
|
return a0 != null && c3623_20.includes(a0);
|
|
}
|
|
export function getStrikeThroughPriceAmountForCollectiblesProduct(a0, a1, a2) {
|
|
if (a0?.type === CollectiblesItemType.BUNDLE) {
|
|
const bundledProducts = a0.bundledProducts;
|
|
const r30 = bundledProducts == null;
|
|
let r31 = 0;
|
|
if (!r30) {
|
|
const r43 = !(!isAndroid() && !isIOS()) && CurrencyCodes.DISCORD_ORB !== void 0 ? PriceSetAssignmentPurchaseTypes.MOBILE : PriceSetAssignmentPurchaseTypes.DEFAULT;
|
|
let env15201;
|
|
const r45 = env15201 = {
|
|
$parent: env3623
|
|
};
|
|
env15201[1] = r43;
|
|
r31 = bundledProducts.reduce($mk77182(r45), 0);
|
|
}
|
|
return r31;
|
|
}
|
|
const r19 = a0.prices[a1 ? a2 ? PriceSetAssignmentPurchaseTypes.MOBILE : PriceSetAssignmentPurchaseTypes.DEFAULT : a2 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2];
|
|
const r21 = r19 == null ? void 0 : r19.countryPrices?.prices;
|
|
const r24 = r21 == null;
|
|
let r25 = null;
|
|
if (!r24) {
|
|
let r26 = r21[0];
|
|
if (r26 == null) {
|
|
r26 = null;
|
|
}
|
|
r25 = r26;
|
|
}
|
|
return r25?.amount;
|
|
}
|
|
export function canActionOnProduct(a0) {
|
|
const product = a0.product;
|
|
let isPartiallyOwnedBundle = a0.isPartiallyOwnedBundle;
|
|
const isPurchased = a0.isPurchased;
|
|
if (!isPartiallyOwnedBundle) {
|
|
isPartiallyOwnedBundle = EXTERNAL_PRODUCT_SKU_IDS.ORB_PROFILE_BADGE === product?.skuId && isPurchased;
|
|
}
|
|
return !isPartiallyOwnedBundle;
|
|
}
|
|
export function getProductTypeNameForLogging(a0, a1) {
|
|
if (CollectiblesItemType.AVATAR_DECORATION === a0) {
|
|
return "avatar decoration";
|
|
}
|
|
if (CollectiblesItemType.PROFILE_EFFECT === a0) {
|
|
return "profile effect";
|
|
}
|
|
if (CollectiblesItemType.NAMEPLATE === a0) {
|
|
return "nameplate";
|
|
}
|
|
if (CollectiblesItemType.PROFILE_FRAME === a0) {
|
|
return "profile frame";
|
|
}
|
|
if (CollectiblesItemType.BUNDLE === a0) {
|
|
return "bundle";
|
|
}
|
|
if (CollectiblesItemType.EXTERNAL_SKU === a0) {
|
|
return a1 !== EXTERNAL_PRODUCT_SKU_IDS.FRACTIONAL_PREMIUM ? a1 !== EXTERNAL_PRODUCT_SKU_IDS.FRACTIONAL_PREMIUM_1_DAY ? a1 === EXTERNAL_PRODUCT_SKU_IDS.ORB_PROFILE_BADGE ? "orb profile badge" : "unknown" : "1-day nitro credit" : "3-day nitro credit";
|
|
}
|
|
if (CollectiblesItemType.VARIANTS_GROUP === a0) {
|
|
return "variants group";
|
|
}
|
|
return "unknown";
|
|
}
|
|
export function sortProductsByPrice(a0, hasShopDiscount, c15202_1) {
|
|
return a0.sort((a, b) => {
|
|
let r19, r39;
|
|
if (c15202_1) {
|
|
r19 = getProductOrbPrice({
|
|
product: a,
|
|
hasShopDiscount
|
|
});
|
|
} else {
|
|
const r14 = a.prices[hasShopDiscount ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE];
|
|
const r15 = r14 == null ? void 0 : r14.countryPrices?.prices;
|
|
const r18 = r15 == null;
|
|
r19 = null;
|
|
if (!r18) {
|
|
let r20 = r15[0];
|
|
if (r20 == null) {
|
|
r20 = null;
|
|
}
|
|
r19 = r20;
|
|
}
|
|
}
|
|
if (c15202_1) {
|
|
r39 = getProductOrbPrice({
|
|
product: b,
|
|
hasShopDiscount
|
|
});
|
|
} else {
|
|
const r32 = b.prices[hasShopDiscount ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE];
|
|
const r35 = r32 == null ? void 0 : r32.countryPrices?.prices;
|
|
const r38 = r35 == null;
|
|
r39 = null;
|
|
if (!r38) {
|
|
let r40 = r35[0];
|
|
if (r40 == null) {
|
|
r40 = null;
|
|
}
|
|
r39 = r40;
|
|
}
|
|
}
|
|
let r50 = r19?.amount;
|
|
if (r50 == null) {
|
|
r50 = 0;
|
|
}
|
|
let r52 = r39?.amount;
|
|
if (r52 == null) {
|
|
r52 = 0;
|
|
}
|
|
return r50 - r52;
|
|
});
|
|
}
|
|
export function removeRewardProductsFilter(a0) {
|
|
return a0.filter((item) => !item.isCategoryReward);
|
|
}
|