This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,36 @@
// Metro module 14104 (f14105).
import { useCallback } from "react";
import UserStore from "../../../stores/UserStore";
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import PremiumUtils from "../../../utils/PremiumUtils";
import { getProductPurchaseState } from "./useProductPurchaseState";
import { isBundleProduct, isFreeCollectiblesProduct, getDefaultPriceSetAssignmentPurchaseType, extractPriceByPurchaseTypes } from "../CollectiblesUtils";
import { isOrbsExclusiveProduct, getProductOrbPrice } from "../utils/CollectiblesProductUtils";
export function useBadBundleFilter() {
const canUseShopDiscounts = PremiumUtils.canUseShopDiscounts(useStateFromStores([UserStore], () => UserStore.getCurrentUser()));
return useCallback((a0) => a0 != null ? a0.length !== 0 ? a0.filter((item) => {
const isPurchased = getProductPurchaseState(CollectiblesPurchaseStore, item).isPurchased;
if (isBundleProduct(item) && !isFreeCollectiblesProduct(item) && !isPurchased) {
if (isOrbsExclusiveProduct(item)) {
return getProductOrbPrice({
product: item,
hasShopDiscount: canUseShopDiscounts
}) != null;
}
const defaultPriceSetAssignmentPurchaseType = getDefaultPriceSetAssignmentPurchaseType(canUseShopDiscounts);
const r36 = extractPriceByPurchaseTypes(item, defaultPriceSetAssignmentPurchaseType);
if (r36 != null && r36.amount !== 0) {
return r36.amount < (item.bundledProducts != null ? item.bundledProducts.reduce((acc, bundledProduct) => {
let r14 = extractPriceByPurchaseTypes(bundledProduct, defaultPriceSetAssignmentPurchaseType)?.amount;
if (r14 == null) {
r14 = 0;
}
return acc + r14;
}, 0) : 0);
}
return true;
}
return true;
}) : a0 : a0, [canUseShopDiscounts]);
}
@@ -0,0 +1,37 @@
// Metro module 11913 (f11914).
import { useCurrentUser } from "./useCurrentUser";
import { useIsProfileFrameGiftingEnabled } from "../experiments/CollectiblesProfileFrameGiftingExperiment";
import * as _CollectiblesUtils from "../CollectiblesUtils";
import { isPremiumCollectiblesProduct, extractPriceByPurchaseTypes, getDefaultPriceSetAssignmentPurchaseType, shouldHideGiftingForCurrency } from "../CollectiblesUtils";
import * as _CollectiblesProductUtils from "../utils/CollectiblesProductUtils";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import PremiumUtils from "../../../utils/PremiumUtils";
import { isCollectibleGiftingSupported } from "../../device/BillingPlatformUtils";
export function useCanGiftProduct(a0) {
const currentUser = useCurrentUser();
const isProfileFrameGiftingEnabled = useIsProfileFrameGiftingEnabled("useCanGiftProduct");
let r21 = isPremiumCollectiblesProduct(a0);
const isFreeCollectiblesProduct = _CollectiblesUtils.isFreeCollectiblesProduct(a0);
const isOrbsExclusiveProduct = _CollectiblesProductUtils.isOrbsExclusiveProduct(a0);
const r1 = a0.type === CollectiblesItemType.PROFILE_FRAME && !isProfileFrameGiftingEnabled;
const r45 = extractPriceByPurchaseTypes(a0, getDefaultPriceSetAssignmentPurchaseType(PremiumUtils.canUseShopDiscounts(currentUser)));
if (!r21) {
r21 = isFreeCollectiblesProduct;
}
if (!r21) {
r21 = isOrbsExclusiveProduct;
}
if (!r21) {
r21 = r1;
}
if (!r21) {
r21 = a0.type === CollectiblesItemType.EXTERNAL_SKU;
}
if (!r21) {
r21 = shouldHideGiftingForCurrency(r45?.currency);
}
if (!r21) {
r21 = !isCollectibleGiftingSupported();
}
return !r21;
}
@@ -0,0 +1,46 @@
// Metro module 8700 (f8701).
import UserStore from "../../../stores/UserStore";
import { PremiumTypes } from "../../premium/PremiumConstants";
import { useIsProfileFramesEnabled } from "../experiments/CollectiblesProfileFramesExperiment";
import CollectiblesProfileFramesPurchaseExperiment, { ProfileFramesPurchaseBucket } from "../experiments/CollectiblesProfileFramesPurchaseExperiment";
import { isPremiumExactly } from "../../../utils/PremiumTypeUtils";
import { PremiumSubscriptionType } from "../../../_bundle/Module1892";
import { useStateFromStores } from "../../../_bundle/Module589";
export default function useCanPurchaseFrames(a0) {
let r11 = useIsProfileFramesEnabled(a0);
const bucket = CollectiblesProfileFramesPurchaseExperiment.useConfig({
location: a0
}).bucket;
const stateFromStores = useStateFromStores([UserStore], () => {
const currentUser = UserStore.getCurrentUser();
return isPremiumExactly(currentUser, PremiumTypes.TIER_2) && currentUser?.premiumState != null && currentUser.premiumState.premiumSubscriptionType === PremiumSubscriptionType.TIER_2;
});
const r27 = bucket === ProfileFramesPurchaseBucket.OPEN_PURCHASE || bucket === ProfileFramesPurchaseBucket.PAID_PREMIUM_SUBSCRIBERS_ONLY && stateFromStores;
if (r11) {
r11 = r27;
}
return r11;
};
export function useCanViewProfileFramesInCollectiblesShop(a0) {
let r9 = useIsProfileFramesEnabled(a0);
const bucket = CollectiblesProfileFramesPurchaseExperiment.useConfig({
location: a0
}).bucket;
if (r9) {
r9 = bucket !== ProfileFramesPurchaseBucket.CONTROL;
}
return r9;
}
export function useIsProfileFramesEarlyAccessPhase(a0) {
let r9 = useIsProfileFramesEnabled(a0);
const bucket = CollectiblesProfileFramesPurchaseExperiment.useConfig({
location: a0
}).bucket;
if (r9) {
r9 = bucket === ProfileFramesPurchaseBucket.PAID_PREMIUM_SUBSCRIBERS_ONLY;
}
return r9;
}
export function isUserPaidTier2(a0) {
return isPremiumExactly(a0, PremiumTypes.TIER_2) && a0?.premiumState != null && a0.premiumState.premiumSubscriptionType === PremiumSubscriptionType.TIER_2;
}
@@ -0,0 +1,13 @@
// Metro module 7955 (f7956).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
export default function useCollectiblesData(c16126_0) {
const r15 = _slicedToArray(useStateFromStoresArray([CollectiblesCategoryStore], () => [CollectiblesCategoryStore.getCategoryForProduct(c16126_0), CollectiblesCategoryStore.getProduct(c16126_0)]), 2);
return {
category: r15[0],
product: r15[1],
purchase: useStateFromStores([CollectiblesPurchaseStore], () => CollectiblesPurchaseStore.getPurchase(c16126_0))
};
};
@@ -0,0 +1,12 @@
// Metro module 8664 (f8665).
import UserStore from "../../../stores/UserStore";
import { useStateFromStores } from "../../../_bundle/Module589";
import Module38 from "../../../_bundle/Module38";
export function useCurrentUser() {
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
Module38(stateFromStores != null, "user has to be signed in before accessing shop");
return stateFromStores;
}
export function useCurrentUserIfAvailable() {
return useStateFromStores([UserStore], () => UserStore.getCurrentUser());
}
@@ -0,0 +1,8 @@
// Metro module 8661 (f8662).
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
import { useStateFromStores } from "../../../_bundle/Module589";
import { getIsVariantProduct } from "../utils/CollectiblesProductUtils";
export function useDefaultVariantIndex(a0) {
const stateFromStores = useStateFromStores([CollectiblesPurchaseStore], () => CollectiblesPurchaseStore.purchases);
return a0 != null ? getIsVariantProduct(a0) ? Math.max(0, a0.variants.findIndex((variant) => !stateFromStores.has(variant.skuId))) : 0 : 0;
}
@@ -0,0 +1,85 @@
// Metro module 7957 (f7958).
import { useEffect, useRef } from "react";
import ExperimentStore from "../../experiments/ExperimentStore";
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/defaultAreStatesEqual";
import { fetchCollectiblesPurchases } from "../CollectiblesActionCreators";
import useMaybeFetchCollectiblesCategories from "./useMaybeFetchCollectiblesCategories";
let useFetchCollectiblesCategoriesAndPurchases;
const useFetchPurchases = function useFetchPurchases(r13 = false) {
let current, current2, current3, ref, ref2, ref3;
let c16127_0 = r13;
current = void 0;
current2 = void 0;
current3 = void 0;
ref = void 0;
ref2 = void 0;
ref3 = void 0;
const stateFromStores = useStateFromStores([ExperimentStore], () => ExperimentStore.hasLoadedExperiments);
let isClaiming, claimError, purchases;
[current, isClaiming, current2, claimError, purchases, current3] = useStateFromStoresArray([CollectiblesPurchaseStore], () => [CollectiblesPurchaseStore.isFetching, CollectiblesPurchaseStore.isClaiming, CollectiblesPurchaseStore.fetchError, CollectiblesPurchaseStore.claimError, CollectiblesPurchaseStore.purchases, CollectiblesPurchaseStore.hasPreviouslyFetched]);
ref = useRef(CollectiblesPurchaseStore.hasPreviouslyFetched);
useEffect(() => {
ref.current = current3;
}, [current3]);
ref2 = useRef(CollectiblesPurchaseStore.fetchError);
useEffect(() => {
ref2.current = current2;
}, [current2]);
ref3 = useRef(CollectiblesPurchaseStore.isFetching);
useEffect(() => {
ref3.current = current;
}, [current]);
useEffect(() => {
if (!((stateFromStores ? ref3.current : !stateFromStores) || c16127_0 === true && ref.current && ref2.current == null)) {
fetchCollectiblesPurchases();
}
}, [r13, stateFromStores]);
return {
isClaiming,
fetchPurchasesError: current2,
claimError,
isFetching: current,
purchases,
hasPreviouslyFetched: current3
};
};
useFetchCollectiblesCategoriesAndPurchases = function useFetchCollectiblesCategoriesAndPurchases(a0, a1) {
const maybeFetchCollectiblesCategories = useMaybeFetchCollectiblesCategories({
paymentGateway: a0?.paymentGateway,
noOp: a0?.noOp,
logPerf: a0?.logPerf,
countryCode: a0?.countryCode
}, a1);
const { isFetching: isFetching2, categories, fetchCategoriesError, refreshCategories } = maybeFetchCollectiblesCategories;
const fetchPurchases = useFetchPurchases(a0?.stalePurchasesOK);
const { isClaiming, fetchPurchasesError, claimError, isFetching } = fetchPurchases;
return {
isFetching: isFetching2 || isFetching,
isFetchingCategories: isFetching2,
isFetchingPurchases: isFetching,
isClaiming,
categories,
purchases: fetchPurchases.purchases,
fetchCategoriesError,
fetchPurchasesError,
claimError,
refreshCategories,
hasPreviouslyFetched: fetchPurchases.hasPreviouslyFetched
};
};
export default useFetchCollectiblesCategoriesAndPurchases;
export { useFetchPurchases };
export function useGetOrFetchPurchases() {
return useFetchPurchases(true);
}
export function useGetOrFetchPurchase(a0, r3 = true) {
const purchases = useFetchPurchases(r3).purchases;
return a0 != null ? purchases.get(a0) : void 0;
}
export function useGetOrFetchCollectiblesCategoriesAndPurchases(a0) {
return useFetchCollectiblesCategoriesAndPurchases({
...a0 == null ? {} : a0,
stalePurchasesOK: true
});
}
@@ -0,0 +1,32 @@
// Metro module 8045 (f8046).
import { useEffect } from "react";
import SKUStore from "../../../stores/game_store/SKUStore";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { SKUProductLines } from "../../../Constants";
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/defaultAreStatesEqual";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { fetchCollectiblesProduct } from "../CollectiblesActionCreators";
export function useFetchCollectiblesProduct(a0, a1) {
let c16211_2, c16211_3, c16211_4, stateFromStores, c16211_6;
const includeBundles = a1;
const stateFromStores2 = useStateFromStores([SKUStore], () => a0 != null ? SKUStore.get(a0) : null);
const r2 = stateFromStores2 != null && stateFromStores2.productLine !== SKUProductLines.COLLECTIBLES;
c16211_2 = r2;
const [product, r33] = useStateFromStoresArray([CollectiblesCategoryStore], () => [CollectiblesCategoryStore.getProduct(a0), CollectiblesCategoryStore.getProductFetch(a0)]);
c16211_3 = product;
c16211_4 = r33;
stateFromStores = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.isProductFetchBackedOff(a0));
const r39 = a1 === true && product?.type === CollectiblesItemType.BUNDLE && product.items.length === 0;
c16211_6 = r39;
useEffect(() => {
if (!(a0 == null || c16211_3 != null && !c16211_6 || c16211_2 || c16211_4?.state === "fetching" || stateFromStores)) {
fetchCollectiblesProduct(a0, {
includeBundles
});
}
}, [a0, product, r2, r33, a1, r39, stateFromStores]);
return {
product,
isFetching: r33?.state === "fetching"
};
}
@@ -0,0 +1,13 @@
// Metro module 9795 (f9796).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import useMaybeFetchCollectiblesCategories from "./useMaybeFetchCollectiblesCategories";
import { useStateFromStoresArray } from "../../../_bundle/defaultAreStatesEqual";
export function useFetchCollectiblesProductCategory(c17498_0) {
useMaybeFetchCollectiblesCategories();
const r19 = _slicedToArray(useStateFromStoresArray([CollectiblesCategoryStore], () => [CollectiblesCategoryStore.isFetchingCategories, CollectiblesCategoryStore.getCategoryForProduct(c17498_0)]), 2);
return {
isFetching: r19[0],
category: r19[1]
};
}
@@ -0,0 +1,31 @@
// Metro module 11921 (f11922).
import { useEffect } from "react";
import SKUStore from "../../../stores/game_store/SKUStore";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { SKUProductLines } from "../../../Constants";
import { useStateFromStoresArray } from "../../../_bundle/defaultAreStatesEqual";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { fetchCollectiblesProduct } from "../CollectiblesActionCreators";
export function useFetchCollectiblesProducts(a0, a1) {
let stateFromStoresArray2, stateFromStoresArray3, stateFromStoresArray4;
const includeBundles = a1;
const stateFromStoresArray = useStateFromStoresArray([SKUStore], () => a0.map((item) => SKUStore.get(item)));
stateFromStoresArray2 = useStateFromStoresArray([CollectiblesCategoryStore], () => a0.map((item) => CollectiblesCategoryStore.getProduct(item)));
stateFromStoresArray3 = useStateFromStoresArray([CollectiblesCategoryStore], () => a0.map((item) => CollectiblesCategoryStore.getProductFetch(item)));
stateFromStoresArray4 = useStateFromStoresArray([CollectiblesCategoryStore], () => a0.map((item) => CollectiblesCategoryStore.isProductFetchBackedOff(item)));
useEffect(() => {
for (const item of a0.entries()) {
const [r40, r42] = item;
const r44 = stateFromStoresArray[r40];
const r46 = stateFromStoresArray2[r40];
const r48 = stateFromStoresArray3[r40];
const r49 = includeBundles === true && r46?.type === CollectiblesItemType.BUNDLE && r46.items.length === 0;
if (!(r46 != null && !r49 || r44 != null && r44.productLine !== SKUProductLines.COLLECTIBLES || r48?.state === "fetching" || stateFromStoresArray4[r40])) {
fetchCollectiblesProduct(r42, {
includeBundles
});
}
}
}, [a0, stateFromStoresArray, stateFromStoresArray3, stateFromStoresArray2, a1, stateFromStoresArray4]);
return stateFromStoresArray2.some((item, index) => stateFromStoresArray3[index]?.state === "fetching" || item == null && stateFromStoresArray3[index]?.state !== "error");
}
@@ -0,0 +1,12 @@
// Metro module 14101 (f14102).
import { useCallback } from "react";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { useStateFromStores } from "../../../_bundle/Module589";
import uniqBy from "../../../_bundle/uniqBy";
export default function useGetProductsFromSkus() {
const stateFromStores = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.products);
return useCallback((a0) => uniqBy(a0.map((item) => {
const r6 = stateFromStores.get(item);
return r6 != null ? r6.variantGroupStoreListingId != null ? CollectiblesCategoryStore.getProductByStoreListingId(r6.variantGroupStoreListingId) : r6 : r6;
}).filter((item) => item != null), "storeListingId"), [stateFromStores]);
};
@@ -0,0 +1,154 @@
// Metro module 9797 (f9798).
import { useState, useMemo, useCallback } from "react";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { intl, t } from "../../../intl/index.native";
import { useShopProductItems } from "./useShopProductItems";
import { getProfileChangesForUpdateRequest } from "../../user_profile/ProfileUpdateRequestUtils";
import { saveProfileChanges } from "../../user_profile/UserProfileActionCreators";
import { saveProfileAndAccountChanges } from "../../../actions/UserSettingsAccountActionCreators";
export function useHandleUseNow({ product, onSuccess, onError }) {
let r56;
const [isApplying, setState] = useState(false);
const shopProductItems = useShopProductItems(product);
const { firstAvatarDecoration, firstProfileEffect, firstNameplate, firstProfileFrame } = shopProductItems;
const type = product.type;
if (CollectiblesItemType.AVATAR_DECORATION === type) {
r56 = intl.string(t.zOA4ax);
} else if (CollectiblesItemType.NAMEPLATE === type) {
r56 = intl.string(t.gOzMvx);
} else if (CollectiblesItemType.PROFILE_FRAME === type) {
r56 = intl.string(t.lOF4zR);
} else if (CollectiblesItemType.PROFILE_EFFECT === type) {
r56 = intl.string(t.SWm2ai);
} else {
CollectiblesItemType.BUNDLE;
r56 = intl.string(t.tf1ZZ4);
}
const memo = useMemo(() => (function computeCanUseNow(a0) {
if (a0.type !== CollectiblesItemType.BUNDLE) {
return true;
}
const set = new Set();
for (const item of a0.items) {
if (!set.has(item.type)) {
set.add(item.type);
continue;
}
return false;
}
return true;
})(product), [product]);
return {
handleUseNow: useCallback(async () => {
let firstProfileEffect2, firstProfileFrame2, c26539_4;
let c26539_5 = 0;
let c30145_0, c30145_1;
L38: {
L27: {
try {
c30145_0 = void 0;
if (!memo) {
break L38;
}
setState(true);
const r38 = {};
c30145_0 = r38;
c26539_5 = 2;
if (firstAvatarDecoration != null) {
r38.avatarDecoration = firstAvatarDecoration;
}
L22: {
if (firstProfileEffect == null && firstProfileFrame == null) {
if (firstNameplate != null) {
c30145_0.nameplate = firstNameplate;
}
if (Object.keys(c30145_0).length > 0) {
await saveProfileAndAccountChanges(c30145_0);
break L22;
}
if (onSuccess != null) {
onSuccess();
}
c26539_5 = 1;
c26539_5 = 0;
(0, setState)(false);
break L38;
}
firstProfileEffect2 = firstProfileEffect;
if (firstProfileEffect == null) {
firstProfileEffect2 = void 0;
}
firstProfileFrame2 = firstProfileFrame;
if (firstProfileFrame == null) {
firstProfileFrame2 = void 0;
}
await saveProfileChanges(getProfileChangesForUpdateRequest({
pendingProfileEffect: firstProfileEffect2,
pendingProfileFrame: firstProfileFrame2
}));
if (firstNameplate != null) {
c30145_0.nameplate = firstNameplate;
}
if (Object.keys(c30145_0).length > 0) {
await saveProfileAndAccountChanges(c30145_0);
}
}
if (onSuccess != null) {
onSuccess();
}
c26539_5 = 1;
c26539_5 = 0;
(0, setState)(false);
} catch ($e) {
const r32 = $e;
let r7 = r32;
c26539_4 = r32;
let r33 = c26539_5;
if (r33 !== 0) {
while (true) {
if (r33 === 1) {
try {
const r193 = c26539_4;
c26539_5 = 0;
(0, setState)(false);
throw r193;
} catch (r191) {
r7 = r191;
c26539_4 = r191;
r33 = c26539_5;
if (r33 === 0) {
break;
}
}
} else {
try {
const r179 = c26539_4;
c26539_5 = 1;
c30145_1 = r179;
if (onError != null) {
onError(c30145_1);
}
c26539_5 = 0;
(0, setState)(false);
break L27;
} catch (r176) {
r7 = r176;
c26539_4 = r176;
r33 = c26539_5;
if (r33 === 0) {
break;
}
}
}
}
}
throw r7;
}
}
return void 0;
}
}, [memo, firstAvatarDecoration, firstProfileEffect, firstNameplate, firstProfileFrame, onSuccess, r56, onError]),
isApplying,
canUseNow: memo
};
}
@@ -0,0 +1,33 @@
// Metro module 14607 (f14608).
import { useEffect, useState } from "react";
import { MAX_TIMEOUT_MS } from "../../../Constants";
import { ShopBlockType } from "../../../_bundle/Module5829";
export const useHasExpiredShopBlocks = (a0, a1, a2) => {
const [state, setState] = useState(false);
useEffect(() => {
let time;
L7: {
time = null;
a0.forEach((item) => {
const r18 = item.type === ShopBlockType.IMMERSIVE_BANNER ? item.endTime != null ? item.endTime.getTime() : null : item.type === ShopBlockType.COUNTDOWN_TIMER ? item.endTime.getTime() : null;
if (time == null || r18 != null && r18 < time) {
time = r18;
}
});
if (!a1 && !a2 && time != null) {
const r9 = time - Date.now();
if (r9 <= 0) {
setState(true);
break L7;
}
setState(false);
let c27781_0 = setTimeout(() => {
setState(true);
}, Math.min(MAX_TIMEOUT_MS, r9));
return () => clearTimeout(c27781_0);
}
setState(false);
}
}, [a1, a2, a0]);
return state;
};
@@ -0,0 +1,6 @@
// Metro module 8728 (f8729).
import { useMemo } from "react";
import { isValidHex, getDarkness, hex2int } from "../../../_bundle/int2hslRaw";
export default function useIsVariantColorLight(a0) {
return useMemo(() => isValidHex(a0.variantValue) && getDarkness(hex2int(a0.variantValue)) < 0.3, [a0.variantValue]);
};
@@ -0,0 +1,18 @@
// Metro module 7959 (f7960).
import DevSettingsStore from "../../devtools/dev_settings/DevSettingsStore";
import { useStateFromStoresObject } from "../../../_bundle/Module589";
import { useMaybeFetchCollectiblesCategoriesShared } from "./useMaybeFetchCollectiblesCategoriesShared";
export default function useMaybeFetchCollectiblesCategories(a0, a1) {
const paymentGateway = a0?.paymentGateway;
const stateFromStoresObject = useStateFromStoresObject([DevSettingsStore], () => ({
noCache: DevSettingsStore.get("shop_disable_cache"),
includeUnpublished: DevSettingsStore.get("shop_include_unpublished")
}));
return useMaybeFetchCollectiblesCategoriesShared({
noCache: stateFromStoresObject.noCache,
includeUnpublished: stateFromStoresObject.includeUnpublished,
paymentGateway,
countryCode: a0?.countryCode,
logPerf: a0?.logPerf
}, a0?.noOp, a1);
};
@@ -0,0 +1,3 @@
// Metro module 7958 (f7959).
import useMaybeFetchCollectiblesCategories_mobile from "./useMaybeFetchCollectiblesCategories.mobile";
export default useMaybeFetchCollectiblesCategories_mobile;
@@ -0,0 +1,67 @@
// Metro module 7960 (f7961).
import { useCallback, useEffect } from "react";
import ExperimentStore from "../../experiments/ExperimentStore";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { COLLECTIBLES_SHOP_CACHE_DURATION_MS, COLLECTIBLES_SHOP_FETCH_ERROR_RETRY_THRESHOLD_MS } from "../CollectiblesShopConstants";
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/Module589";
import { ShopVariantsReturnStyle } from "../../../_bundle/Module5847";
import { areRequestOptionsEqual, fetchCollectiblesCategories } from "../CollectiblesActionCreators";
export function useMaybeFetchCollectiblesCategoriesShared(a0, a1, a2) {
let c16128_4, c16128_5, c16128_6, c16128_7;
const stateFromStores = useStateFromStores([ExperimentStore], () => ExperimentStore.hasLoadedExperiments);
let [isFetching, r15, fetchCategoriesError, r13, r14, categories, skipNumCategories] = useStateFromStoresArray([CollectiblesCategoryStore], () => {
const r5 = [CollectiblesCategoryStore.isFetchingCategories, CollectiblesCategoryStore.lastFetchOptions, CollectiblesCategoryStore.error, , , , ,];
let lastErrorTimestamp = CollectiblesCategoryStore.lastErrorTimestamp;
if (lastErrorTimestamp == null) {
lastErrorTimestamp = 0;
}
r5[3] = lastErrorTimestamp;
let lastSuccessfulFetch = CollectiblesCategoryStore.lastSuccessfulFetch;
if (lastSuccessfulFetch == null) {
lastSuccessfulFetch = 0;
}
r5[4] = lastSuccessfulFetch;
r5[5] = CollectiblesCategoryStore.categories;
r5[6] = CollectiblesCategoryStore.skipNumCategories;
return r5;
});
c16128_4 = r15;
c16128_5 = fetchCategoriesError;
c16128_6 = r13;
c16128_7 = r14;
useEffect(() => {
L8: {
if (stateFromStores && !CollectiblesCategoryStore.isFetchingCategories) {
const r0 = Date.now() - c16128_6 < COLLECTIBLES_SHOP_FETCH_ERROR_RETRY_THRESHOLD_MS;
if (Boolean(c16128_5) && r0) {
break L8;
}
const r7 = {
...a0,
variantsReturnStyle: ShopVariantsReturnStyle.VARIANTS_GROUP,
includeBundles: true,
skipNumCategories
};
const r35 = areRequestOptionsEqual(c16128_4, r7);
const r36 = !r35;
const r2 = Date.now() - c16128_7 < COLLECTIBLES_SHOP_CACHE_DURATION_MS;
if (!(r35 ? r2 : !r36)) {
fetchCollectiblesCategories(r7, a1, a2);
}
}
}
}, [stateFromStores, r15, r14, a0, fetchCategoriesError, r13, a1, a2, skipNumCategories]);
return {
isFetching,
categories,
fetchCategoriesError,
refreshCategories: useCallback(() => {
fetchCollectiblesCategories({
...a0,
variantsReturnStyle: ShopVariantsReturnStyle.VARIANTS_GROUP,
includeBundles: true,
skipNumCategories
}, void 0, a2);
}, [a0, a2, skipNumCategories])
};
}
@@ -0,0 +1,97 @@
// Metro module 14606 (f14607).
import { useCallback, useEffect, useMemo } from "react";
import ExperimentStore from "../../experiments/ExperimentStore";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import CollectiblesShopHomeStore from "../CollectiblesShopHomeStore";
import { COLLECTIBLES_SHOP_CACHE_DURATION_MS, COLLECTIBLES_SHOP_FETCH_ERROR_RETRY_THRESHOLD_MS } from "../CollectiblesShopConstants";
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/Module589";
import { ShopVariantsReturnStyle } from "../../../_bundle/Module5847";
import { areRequestOptionsEqual, fetchCollectiblesShopHome } from "../CollectiblesActionCreators";
import { useHasExpiredShopBlocks } from "./useHasExpiredShopBlocks";
export function useMaybeFetchCollectiblesShopHome(a0, a1, a2) {
let stateFromStores2, c21248_5, c21248_6, c21248_7, c21248_8, c21248_9, c21248_10, shopHomeConfig, memo, memo2, hasExpiredShopBlocks, memo3;
let r20 = arguments[3];
if (r20 === void 0) {
r20 = false;
}
stateFromStores2 = void 0;
c21248_5 = void 0;
c21248_6 = void 0;
c21248_7 = void 0;
c21248_8 = void 0;
c21248_9 = void 0;
c21248_10 = void 0;
shopHomeConfig = void 0;
memo = void 0;
memo2 = void 0;
hasExpiredShopBlocks = void 0;
memo3 = void 0;
const stateFromStores = useStateFromStores([ExperimentStore], () => ExperimentStore.hasLoadedExperiments);
stateFromStores2 = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.skipNumCategories);
let shopBlocks, r18, r16, r40, fetchShopHomeError, isFetchingShopHome, r14;
[shopBlocks, r18, r16, r40, fetchShopHomeError, isFetchingShopHome, r14, shopHomeConfig] = useStateFromStoresArray([CollectiblesShopHomeStore], () => {
const r8 = [CollectiblesShopHomeStore.getShopBlocks(a0), , , , , , , ,];
let r10 = CollectiblesShopHomeStore.getLastSuccessfulFetch(a0);
if (r10 == null) {
r10 = 0;
}
r8[1] = r10;
let r12 = CollectiblesShopHomeStore.getLastErrorTimestamp(a0);
if (r12 == null) {
r12 = 0;
}
r8[2] = r12;
r8[3] = CollectiblesShopHomeStore.getLastFetchOptions(a0);
r8[4] = CollectiblesShopHomeStore.getFetchShopHomeError(a0);
r8[5] = CollectiblesShopHomeStore.getIsFetchingShopHome(a0);
r8[6] = CollectiblesShopHomeStore.getHasKnownStaleData(a0);
r8[7] = CollectiblesShopHomeStore.getShopHomeConfigOverride();
return r8;
});
c21248_5 = r18;
c21248_6 = r16;
c21248_7 = r40;
c21248_8 = fetchShopHomeError;
c21248_9 = isFetchingShopHome;
c21248_10 = r14;
memo = useMemo(() => ({
...a1,
variantsReturnStyle: ShopVariantsReturnStyle.VARIANTS_GROUP,
includeBundles: true,
includeDynamicBlocks: true,
shopHomeConfig,
skipNumCategories: stateFromStores2
}), [a1, shopHomeConfig, stateFromStores2]);
memo2 = useMemo(() => !areRequestOptionsEqual(c21248_7, memo), [r40, memo]);
let r52 = isFetchingShopHome;
if (r52 == null) {
r52 = false;
}
hasExpiredShopBlocks = useHasExpiredShopBlocks(shopBlocks, r52, r20);
memo3 = useMemo(() => hasExpiredShopBlocks ? !hasExpiredShopBlocks : Date.now() - c21248_5 < COLLECTIBLES_SHOP_CACHE_DURATION_MS, [r18, hasExpiredShopBlocks]);
useEffect(() => {
if (stateFromStores && !c21248_9) {
const r1 = Date.now() - c21248_6 < COLLECTIBLES_SHOP_FETCH_ERROR_RETRY_THRESHOLD_MS;
if (!(c21248_8 != null && r1)) {
let r16 = memo2;
if (!memo2) {
r16 = !memo3;
}
if (!r16) {
r16 = c21248_10;
}
if (r16) {
fetchCollectiblesShopHome(a0, memo, a2);
}
}
}
}, [stateFromStores, isFetchingShopHome, fetchShopHomeError, r16, memo3, r14, memo2, memo, a0, a2]);
return {
isFetchingShopHome,
fetchShopHomeError,
shopBlocks,
refreshShopHome: useCallback(() => {
fetchCollectiblesShopHome(a0, memo, a2);
}, [a0, memo, a2])
};
}
@@ -0,0 +1,72 @@
// Metro module 8737 (f8738).
import { useEffect } from "react";
import { isAvatarDecorationRecord } from "../records/AvatarDecorationRecord";
import { isNameplateRecord } from "../records/NameplateRecord";
import { isProfileEffectRecord } from "../records/ProfileEffectRecord";
import { isProfileFrameRecord } from "../records/ProfileFrameRecord";
import { useShopProductItems } from "./useShopProductItems";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { setPendingChanges } from "../../user_profile/UserProfileSettingsActionCreators";
export function usePreviewCollectibleProduct(a0, a1, a2) {
const profileFrame = a2;
const shopProductItems = useShopProductItems(a0);
const { firstProfileEffect, firstAvatarDecoration, firstNameplate, firstProfileFrame } = shopProductItems;
useEffect(() => {
if (a0.type === CollectiblesItemType.BUNDLE) {
const r45 = {};
if (firstAvatarDecoration != null) {
r45.avatarDecoration = firstAvatarDecoration;
}
if (firstProfileEffect != null) {
r45.profileEffect = firstProfileEffect;
}
if (firstNameplate != null) {
r45.nameplate = firstNameplate;
}
if (firstProfileFrame != null) {
r45.profileFrame = firstProfileFrame;
}
if (profileFrame != null) {
if (isAvatarDecorationRecord(profileFrame)) {
r45.avatarDecoration = profileFrame;
} else if (isProfileEffectRecord(profileFrame)) {
r45.profileEffect = profileFrame;
} else if (isNameplateRecord(profileFrame)) {
r45.nameplate = profileFrame;
} else if (isProfileFrameRecord(profileFrame)) {
r45.profileFrame = profileFrame;
}
}
setPendingChanges(r45);
} else {
const [avatarDecoration] = a0.items;
if (isAvatarDecorationRecord(avatarDecoration)) {
setPendingChanges({
avatarDecoration
});
} else if (isProfileEffectRecord(avatarDecoration)) {
setPendingChanges({
profileEffect: avatarDecoration
});
} else if (isNameplateRecord(avatarDecoration)) {
setPendingChanges({
nameplate: avatarDecoration
});
} else if (isProfileFrameRecord(avatarDecoration)) {
setPendingChanges({
profileFrame: avatarDecoration
});
}
}
return () => {
if (a1) {
setPendingChanges({
avatarDecoration: void 0,
profileEffect: void 0,
nameplate: void 0,
profileFrame: void 0
});
}
};
}, [a0, a1, firstProfileEffect, firstAvatarDecoration, firstNameplate, firstProfileFrame, a2]);
}
@@ -0,0 +1,74 @@
// Metro module 8758 (f8759).
import { useMemo } from "react";
import { intl, t } from "../../../intl/index.native";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
const getBundleDescription = function getBundleDescription(a0, r6 = false) {
if (r6) {
return intl.formatToPlainString(t["/0Yndu"], {
num: a0.bundledProducts?.length
});
}
let bundledProducts = a0.bundledProducts;
if (bundledProducts == null) {
bundledProducts = [];
}
const r30 = [];
let r31 = false;
for (const item of bundledProducts) {
const type = item.type;
if (CollectiblesItemType.AVATAR_DECORATION === type) {
r30.push(intl.formatToPlainString(t.Ntv9Jt, {
itemName: item.name
}));
} else if (CollectiblesItemType.PROFILE_EFFECT === type) {
r30.push(intl.formatToPlainString(t["3Y8q7a"], {
itemName: item.name
}));
} else if (CollectiblesItemType.NAMEPLATE === type) {
r30.push(intl.formatToPlainString(t["2keXky"], {
itemName: item.name
}));
r31 = true;
}
}
if (r31) {
return intl.formatToPlainString(t.Ofrqj6, {
joinedItems: r30.join(", ").replace(/, ([^,]*)$/, " & $1")
});
}
return intl.formatToPlainString(t.Ofrqj6, {
joinedItems: r30.join(" & ")
});
};
export function useProductDescription(a0) {
let r5 = arguments[1];
if (r5 === void 0) {
r5 = false;
}
let c16772_1 = r5;
return useMemo(() => {
if (a0 != null && a0.summary != null && a0.summary !== "") {
if (a0.type === CollectiblesItemType.BUNDLE && a0.summary.includes("{joinedItems}")) {
return a0.summary.replace("{joinedItems}", getBundleDescription(a0, c16772_1));
}
return a0.summary;
}
const type = a0?.type;
if (CollectiblesItemType.AVATAR_DECORATION === type) {
return intl.string(t["3lv7q2"]);
}
if (CollectiblesItemType.PROFILE_EFFECT === type) {
return intl.string(t.VhJL72);
}
if (CollectiblesItemType.NAMEPLATE === type) {
return intl.string(t.ik37EZ);
}
if (CollectiblesItemType.PROFILE_FRAME === type) {
return intl.string(t.fWzWPp);
}
if (CollectiblesItemType.BUNDLE === type) {
return getBundleDescription(a0, c16772_1);
}
return "";
}, [a0, r5]);
}
@@ -0,0 +1,15 @@
// Metro module 8761 (f8762).
import SubscriptionStore from "../../../stores/billing/SubscriptionStore";
import { useStateFromStores } from "../../../_bundle/Module589";
import { FractionalPremiumSKUsSets } from "../../../_bundle/Module679";
import { intl, t } from "../../../intl/index.native";
export function useProductDisableState(a0) {
const stateFromStores = useStateFromStores([SubscriptionStore], () => SubscriptionStore.getPremiumSubscription()?.isPurchasedExternally === true);
return FractionalPremiumSKUsSets.ALL.has(a0) ? {
isDisabled: stateFromStores,
disabledReason: stateFromStores ? intl.string(t.NbveHD) : null
} : {
isDisabled: false,
disabledReason: null
};
}
@@ -0,0 +1,51 @@
// Metro module 8710 (f8711).
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
import compact from "../../../_bundle/compact";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { useStateFromStoresObject } from "../../../_bundle/Module589";
const getProductPurchaseState = function getProductPurchaseState(a0, a1) {
let isPurchased = a0.getPurchase(a1.skuId) != null;
let items = a1.items;
if (items == null) {
items = [];
}
const r20 = compact(items.map((item) => a0.getPurchase(item.skuId)));
const type = a1?.type;
if (CollectiblesItemType.BUNDLE === type) {
if (!isPurchased) {
isPurchased = items.length > 0 && r20.length === items.length;
}
return {
isPurchased,
isPartiallyOwnedBundle: r20.length > 0 && r20.length < items.length,
isPartiallyOwnedVariantsGroup: false
};
}
if (CollectiblesItemType.VARIANTS_GROUP === type) {
const variants = a1.variants;
const r34 = variants == null ? void 0 : variants.every((variant) => a0.getPurchase(variant.skuId) != null);
let isPurchased2 = r34;
if (isPurchased2 == null) {
isPurchased2 = false;
}
const variants2 = a1.variants;
let isPartiallyOwnedVariantsGroup = (variants2 == null ? void 0 : variants2.some((item) => a0.getPurchase(item.skuId) != null)) && !r34;
if (isPartiallyOwnedVariantsGroup == null) {
isPartiallyOwnedVariantsGroup = false;
}
return {
isPurchased: isPurchased2,
isPartiallyOwnedBundle: false,
isPartiallyOwnedVariantsGroup
};
}
return {
isPurchased,
isPartiallyOwnedBundle: false,
isPartiallyOwnedVariantsGroup: false
};
};
export { getProductPurchaseState };
export function useProductPurchaseState(c16739_0) {
return useStateFromStoresObject([CollectiblesPurchaseStore], () => getProductPurchaseState(CollectiblesPurchaseStore, c16739_0));
}
@@ -0,0 +1,100 @@
// Metro module 15774 (f15775).
import UserStore from "../../../stores/UserStore";
import * as _useCanPurchaseFrames from "./useCanPurchaseFrames";
import { useCanViewProfileFramesInCollectiblesShop, useIsProfileFramesEarlyAccessPhase } from "./useCanPurchaseFrames";
import { useIsProfileFramesEAMarketingEnabled, getIsProfileFramesEAMarketingEnabled } from "../experiments/CollectiblesProfileFramesEAMarketingExperiment";
import { useIsProfileFrameGiftingEnabled, getIsProfileFrameGiftingEnabled } from "../experiments/CollectiblesProfileFrameGiftingExperiment";
import { useStateFromStores } from "../../../_bundle/Module589";
import CollectiblesProfileFramesExperiment from "../experiments/CollectiblesProfileFramesExperiment";
import CollectiblesProfileFramesPurchaseExperiment, { ProfileFramesPurchaseBucket } from "../experiments/CollectiblesProfileFramesPurchaseExperiment";
export function deriveProfileFramesMarketing(a0) {
let canViewProfileFramesInCollectiblesShop = a0.canViewProfileFramesInCollectiblesShop;
let isEarlyAccess = a0.isEarlyAccess;
const { isFramesEAMarketingEnabled, isFrameGiftingEnabled, hasPaidTier2 } = a0;
if (canViewProfileFramesInCollectiblesShop) {
canViewProfileFramesInCollectiblesShop = !isEarlyAccess;
}
const isAnnouncementEligible = canViewProfileFramesInCollectiblesShop ? canViewProfileFramesInCollectiblesShop : isEarlyAccess ? isFramesEAMarketingEnabled : isEarlyAccess;
if (canViewProfileFramesInCollectiblesShop) {
canViewProfileFramesInCollectiblesShop = isFrameGiftingEnabled;
}
const r9 = {
isAnnouncementEligible,
isEarlyAccess,
showGiftingMarketing: canViewProfileFramesInCollectiblesShop,
showEaPremiumMarketing: (isEarlyAccess ? isFramesEAMarketingEnabled : isEarlyAccess) && hasPaidTier2,
showEaNonPremiumMarketing: null
};
if (isEarlyAccess) {
isEarlyAccess = isFramesEAMarketingEnabled;
}
if (isEarlyAccess) {
isEarlyAccess = !hasPaidTier2;
}
r9.showEaNonPremiumMarketing = isEarlyAccess;
return r9;
}
export function useProfileFramesMarketing(a0) {
const canViewProfileFramesInCollectiblesShop = useCanViewProfileFramesInCollectiblesShop(a0);
let isEarlyAccess = useIsProfileFramesEarlyAccessPhase(a0);
const isProfileFramesEAMarketingEnabled = useIsProfileFramesEAMarketingEnabled(a0);
const isProfileFrameGiftingEnabled = useIsProfileFrameGiftingEnabled(a0);
const stateFromStores = useStateFromStores([UserStore], () => _useCanPurchaseFrames.isUserPaidTier2(UserStore.getCurrentUser()));
let showGiftingMarketing = canViewProfileFramesInCollectiblesShop && !isEarlyAccess;
const isAnnouncementEligible = showGiftingMarketing ? showGiftingMarketing : isEarlyAccess ? isProfileFramesEAMarketingEnabled : isEarlyAccess;
if (showGiftingMarketing) {
showGiftingMarketing = isProfileFrameGiftingEnabled;
}
const r31 = {
isAnnouncementEligible,
isEarlyAccess,
showGiftingMarketing,
showEaPremiumMarketing: (isEarlyAccess ? isProfileFramesEAMarketingEnabled : isEarlyAccess) && stateFromStores,
showEaNonPremiumMarketing: null
};
if (isEarlyAccess) {
isEarlyAccess = isProfileFramesEAMarketingEnabled;
}
if (isEarlyAccess) {
isEarlyAccess = !stateFromStores;
}
r31.showEaNonPremiumMarketing = isEarlyAccess;
return r31;
}
export function getProfileFramesMarketing(a0) {
let enableProfileFrames = CollectiblesProfileFramesExperiment.getConfig({
location: a0
}).enableProfileFrames;
const bucket = CollectiblesProfileFramesPurchaseExperiment.getConfig({
location: a0
}).bucket;
let showGiftingMarketing = enableProfileFrames ? bucket !== ProfileFramesPurchaseBucket.CONTROL : enableProfileFrames;
if (enableProfileFrames) {
enableProfileFrames = bucket === ProfileFramesPurchaseBucket.PAID_PREMIUM_SUBSCRIBERS_ONLY;
}
const isProfileFramesEAMarketingEnabled = getIsProfileFramesEAMarketingEnabled(a0);
const isProfileFrameGiftingEnabled = getIsProfileFrameGiftingEnabled(a0);
const isUserPaidTier2 = _useCanPurchaseFrames.isUserPaidTier2(UserStore.getCurrentUser());
if (showGiftingMarketing) {
showGiftingMarketing = !enableProfileFrames;
}
const isAnnouncementEligible = showGiftingMarketing ? showGiftingMarketing : enableProfileFrames ? isProfileFramesEAMarketingEnabled : enableProfileFrames;
if (showGiftingMarketing) {
showGiftingMarketing = isProfileFrameGiftingEnabled;
}
const r47 = {
isAnnouncementEligible,
isEarlyAccess: enableProfileFrames,
showGiftingMarketing,
showEaPremiumMarketing: (enableProfileFrames ? isProfileFramesEAMarketingEnabled : enableProfileFrames) && isUserPaidTier2,
showEaNonPremiumMarketing: null
};
if (enableProfileFrames) {
enableProfileFrames = isProfileFramesEAMarketingEnabled;
}
if (enableProfileFrames) {
enableProfileFrames = !isUserPaidTier2;
}
r47.showEaNonPremiumMarketing = enableProfileFrames;
return r47;
}
@@ -0,0 +1,38 @@
// Metro module 14106 (f14107).
import { useMemo } from "react";
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { getIsVariantProduct } from "../utils/CollectiblesProductUtils";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
function $mk92782($env) {
return (a0) => $env[0].includes(a0.skuId);
}
function $mk92783($env) {
return (a0) => $env[0].includes(a0.skuId);
}
let c9870_4 = {
NOT_PURCHASED: 0,
0: "NOT_PURCHASED",
PARTIAL_OWNED_BUNDLE: 1,
1: "PARTIAL_OWNED_BUNDLE",
PURCHASED: 2,
2: "PURCHASED"
};
export function usePurchasedProductsSort(a0) {
let memo;
const stateFromStores = useStateFromStores([CollectiblesPurchaseStore], () => CollectiblesPurchaseStore.purchases);
memo = useMemo(() => [...stateFromStores].map((item) => {
const [r8] = item;
return r8;
}), [stateFromStores]);
return useMemo(() => [...a0].sort((a, b) => {
let env30705;
const r5 = env30705 = {};
env30705[0] = memo;
const r25 = a.type === CollectiblesItemType.BUNDLE && a.items.some($mk92782(r5)) ? c9870_4.PARTIAL_OWNED_BUNDLE : getIsVariantProduct(a) ? a.variants.every($mk92783(r5)) ? c9870_4.PURCHASED : c9870_4.NOT_PURCHASED : memo.includes(a.skuId) ? c9870_4.PURCHASED : c9870_4.NOT_PURCHASED;
let env30706;
const r40 = env30706 = {};
env30706[0] = memo;
return r25 - (b.type === CollectiblesItemType.BUNDLE && b.items.some($mk92782(r40)) ? c9870_4.PARTIAL_OWNED_BUNDLE : getIsVariantProduct(b) ? b.variants.every($mk92783(r40)) ? c9870_4.PURCHASED : c9870_4.NOT_PURCHASED : memo.includes(b.skuId) ? c9870_4.PURCHASED : c9870_4.NOT_PURCHASED);
}), [a0, memo]);
}
@@ -0,0 +1,86 @@
// Metro module 8046 (f8047).
import { useMemo } from "react";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { intl, t } from "../../../intl/index.native";
class ItemsSortingHat {
constructor(a0) {
this.itemsByTypes = this.sortByTypes(a0);
}
get firstAvatarDecoration() {
return this.getFirstItemByType(CollectiblesItemType.AVATAR_DECORATION);
}
get firstProfileEffect() {
return this.getFirstItemByType(CollectiblesItemType.PROFILE_EFFECT);
}
get firstNameplate() {
return this.getFirstItemByType(CollectiblesItemType.NAMEPLATE);
}
get firstProfileFrame() {
return this.getFirstItemByType(CollectiblesItemType.PROFILE_FRAME);
}
getFirstItemByType(a0) {
let r5 = this.itemsByTypes.get(a0);
if (r5 == null) {
r5 = [];
}
const r6 = r5[0];
if (r6 != null) {
return r6;
}
}
sortByTypes(a0) {
return a0.reduce((acc, item) => {
const r7 = acc.get(item.type);
if (r7 != null) {
r7.push(item);
} else {
acc.set(item.type, [item]);
}
return acc;
}, new Map());
}
}
export { ItemsSortingHat };
export function useShopProductItems(a0) {
return useMemo(() => {
const items = a0.items;
const r9 = {
__proto__: ItemsSortingHat.prototype
};
r9.itemsByTypes = r9.sortByTypes(items);
return {
firstProfileEffect: r9.firstProfileEffect,
firstAvatarDecoration: r9.firstAvatarDecoration,
firstNameplate: r9.firstNameplate,
firstProfileFrame: r9.firstProfileFrame
};
}, [a0]);
}
export function getBundleItemNames(a0) {
let r19 = intl.string(t["7v0T9P"]);
let r27 = intl.string(t.wR5wOo);
let r36 = intl.string(t.x5CoXR);
const bundledProducts = a0.bundledProducts;
let itemThreeName = r36;
let itemTwoName = r27;
let itemOneName = r19;
if (bundledProducts != null) {
if (a0.bundledProducts.length > 0) {
r19 = a0.bundledProducts[0]?.name;
}
if (a0.bundledProducts.length > 1) {
r27 = a0.bundledProducts[1]?.name;
}
if (a0.bundledProducts.length > 2) {
r36 = a0.bundledProducts[2]?.name;
}
itemThreeName = r36;
itemTwoName = r27;
itemOneName = r19;
}
return {
itemOneName,
itemTwoName,
itemThreeName
};
}
@@ -0,0 +1,15 @@
// Metro module 11911 (f11912).
import useShouldShowPremiumProfileFrameEA from "./useShouldShowPremiumProfileFrameEA";
import useCanPurchaseFrames from "./useCanPurchaseFrames";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
export default function useShouldShowPremiumProfileFrameCTA({ location: location2, product }) {
let r11 = useShouldShowPremiumProfileFrameEA(location2);
const canPurchaseFrames = useCanPurchaseFrames(location2);
if (r11) {
r11 = !canPurchaseFrames;
}
if (r11) {
r11 = product.type === CollectiblesItemType.PROFILE_FRAME;
}
return r11;
};
@@ -0,0 +1,13 @@
// Metro module 11912 (f11913).
import { useIsProfileFramesEnabled } from "../experiments/CollectiblesProfileFramesExperiment";
import CollectiblesProfileFramesPurchaseExperiment, { ProfileFramesPurchaseBucket } from "../experiments/CollectiblesProfileFramesPurchaseExperiment";
export default function useShouldShowPremiumProfileFrameEA(a0) {
let r9 = useIsProfileFramesEnabled(a0);
const bucket = CollectiblesProfileFramesPurchaseExperiment.useConfig({
location: a0
}).bucket;
if (r9) {
r9 = bucket === ProfileFramesPurchaseBucket.PAID_PREMIUM_SUBSCRIBERS_ONLY;
}
return r9;
};
@@ -0,0 +1,33 @@
// Metro module 7940 (f7941).
import { useCallback } from "react";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { AnalyticEvents } from "../../../Constants";
import { AnalyticsPremiumFeatureTiers, AnalyticsPremiumFeatureNames } from "../../premium/PremiumConstants";
import { CollectiblesItemType } from "../../../_bundle/Module1901";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { isPremiumCollectiblesProduct } from "../CollectiblesUtils";
const r24 = {};
r24[CollectiblesItemType.AVATAR_DECORATION] = AnalyticsPremiumFeatureNames.AVATAR_DECORATION;
r24[CollectiblesItemType.PROFILE_EFFECT] = AnalyticsPremiumFeatureNames.PROFILE_EFFECT;
r24[CollectiblesItemType.PROFILE_FRAME] = void 0;
r24[CollectiblesItemType.NAMEPLATE] = void 0;
r24[CollectiblesItemType.NONE] = void 0;
r24[CollectiblesItemType.BUNDLE] = void 0;
r24[CollectiblesItemType.VARIANTS_GROUP] = void 0;
r24[CollectiblesItemType.EXTERNAL_SKU] = void 0;
let c5013_7 = r24;
export default function useTrackCollectiblesItemTryOut(a0) {
const location_stack = a0;
const stateFromStores = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.products);
return useCallback((a0) => {
const type = a0.type;
const r8 = stateFromStores.get(a0.skuId);
AnalyticsUtils.track(AnalyticEvents.PREMIUM_FEATURE_TRY_OUT, {
feature_name: c5013_7[type],
feature_tier: isPremiumCollectiblesProduct(r8) ? AnalyticsPremiumFeatureTiers.FREE : AnalyticsPremiumFeatureTiers.PREMIUM_STANDARD,
feature_selection: r8?.name,
location_stack
});
}, [stateFromStores, a0]);
};
@@ -0,0 +1,31 @@
// Metro module 8736 (f8737).
import { useCallback } from "react";
import { AnalyticEvents } from "../../../Constants";
import { useCollectiblesAnalyticsContext } from "../CollectiblesAnalyticsContext";
import { useCurrentUserIfAvailable } from "./useCurrentUser";
import { getShopDiscountSource, getAnalyticsShopDiscountSource } from "../CollectiblesUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
export function useTrackPdpClick({ skuId, productSkuIds, analyticsLocations }) {
let r15 = useCollectiblesAnalyticsContext();
if (r15 == null) {
r15 = {};
}
const { cardId, sessionId } = r15;
const shopDiscountSource = getShopDiscountSource(useCurrentUserIfAvailable());
return useCallback((a0, a1) => {
let sku_id = a1;
const SHOP_PRODUCT_DETAIL_PAGE_CLICKED = AnalyticEvents.SHOP_PRODUCT_DETAIL_PAGE_CLICKED;
if (a1 == null) {
sku_id = skuId;
}
AnalyticsUtils.track(SHOP_PRODUCT_DETAIL_PAGE_CLICKED, {
sku_id,
cta: a0,
shop_session_id: sessionId,
card_id: cardId,
product_sku_ids: productSkuIds,
location_stack: analyticsLocations,
discount_source: getAnalyticsShopDiscountSource(shopDiscountSource)
});
}, [skuId, analyticsLocations, cardId, productSkuIds, sessionId, shopDiscountSource]);
}
@@ -0,0 +1,77 @@
// Metro module 11916 (f11917).
import { useRef, useCallback, useEffect } from "react";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { AnalyticEvents } from "../../../Constants";
import { useCollectiblesAnalyticsContext } from "../CollectiblesAnalyticsContext";
import { useStateFromStores } from "../../../_bundle/Module589";
import { useCurrentUser } from "./useCurrentUser";
import PremiumUtils from "../../../utils/PremiumUtils";
import { getPriceForCollectiblesProduct, getStrikeThroughPriceAmountForCollectiblesProduct } from "../CollectiblesUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
export function useTrackProductCardImpression(a0, a1) {
let canUseShopDiscounts, ref, callback;
const sku_id = a0;
const page_type = a1;
let r9 = arguments[2];
if (r9 === void 0) {
r9 = "product";
}
const type = r9;
canUseShopDiscounts = void 0;
ref = void 0;
callback = void 0;
const collectiblesAnalyticsContext = useCollectiblesAnalyticsContext();
const stateFromStores = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.getProduct(sku_id));
canUseShopDiscounts = PremiumUtils.canUseShopDiscounts(useCurrentUser());
ref = useRef(null);
const r35 = [collectiblesAnalyticsContext?.sessionId, collectiblesAnalyticsContext?.categoryPosition, collectiblesAnalyticsContext?.pageCategory, collectiblesAnalyticsContext?.pageSection, , , , , , ,];
const tilePosition = collectiblesAnalyticsContext?.tilePosition;
const r44 = () => {
const r11 = stateFromStores != null ? getPriceForCollectiblesProduct(stateFromStores, canUseShopDiscounts, true) : null;
const display_price_strikethrough = stateFromStores != null ? getStrikeThroughPriceAmountForCollectiblesProduct(stateFromStores, canUseShopDiscounts, true) : void 0;
const COLLECTIBLES_TILE_IMPRESSION = AnalyticEvents.COLLECTIBLES_TILE_IMPRESSION;
AnalyticsUtils.track(COLLECTIBLES_TILE_IMPRESSION, {
collectibles_shop_session_id: collectiblesAnalyticsContext?.sessionId,
sku_id,
display_price: r11?.amount,
display_price_currency: r11 == null ? void 0 : r11.currency.toString(),
display_price_strikethrough,
position: collectiblesAnalyticsContext?.tilePosition,
page_type,
page_category: collectiblesAnalyticsContext?.pageCategory,
page_section: collectiblesAnalyticsContext?.pageSection,
type,
category_position: collectiblesAnalyticsContext?.categoryPosition
});
};
r35[4] = tilePosition;
r35[5] = canUseShopDiscounts;
r35[6] = a1;
r35[7] = stateFromStores;
r35[8] = a0;
r35[9] = type;
callback = useCallback(r44, r35);
const callback2 = useCallback((a0) => {
const current = ref.current;
if (a0) {
if (current === null) {
ref.current = setTimeout(() => {
callback();
ref.current = null;
}, 1000);
}
} else if (current !== null) {
clearTimeout(ref.current);
ref.current = null;
}
}, [callback]);
useEffect(() => () => {
if (ref.current !== null) {
clearTimeout(ref.current);
ref.current = null;
}
}, [a0]);
return {
handleCardVisibilityChange: callback2
};
}
@@ -0,0 +1,45 @@
// Metro module 8697 (f8698).
import { useCallback } from "react";
import { useSelectedVariantIndex } from "../CollectiblesShopVariantsUIStore";
import { AnalyticEvents } from "../../../Constants";
import { useCollectiblesAnalyticsContext } from "../CollectiblesAnalyticsContext";
import { useCurrentUserIfAvailable } from "./useCurrentUser";
import { getShopDiscountSource, getAnalyticsShopDiscountSource } from "../CollectiblesUtils";
import { getIsVariantProduct, getProductSkuIds } from "../utils/CollectiblesProductUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
export function useTrackShopCardClick({ product, analyticsLocations }) {
let r16 = useCollectiblesAnalyticsContext();
if (r16 == null) {
r16 = {};
}
const { cardId, sessionId, tilePosition } = r16;
const selectedVariantIndex = useSelectedVariantIndex(product);
const shopDiscountSource = getShopDiscountSource(useCurrentUserIfAvailable());
return useCallback((a0, a1) => {
let sku_id;
if (getIsVariantProduct(product)) {
let r15 = a1;
const variants = product.variants;
if (a1 == null) {
r15 = selectedVariantIndex;
}
let r18 = variants[r15]?.skuId;
if (r18 == null) {
r18 = product.skuId;
}
sku_id = r18;
} else {
sku_id = product.skuId;
}
AnalyticsUtils.track(AnalyticEvents.SHOP_CARD_CLICKED, {
sku_id,
cta: a0,
shop_session_id: sessionId,
card_id: cardId,
product_sku_ids: getProductSkuIds(product),
location_stack: analyticsLocations,
position_in_section: tilePosition,
discount_source: getAnalyticsShopDiscountSource(shopDiscountSource)
});
}, [product, selectedVariantIndex, sessionId, cardId, analyticsLocations, tilePosition, shopDiscountSource]);
}
@@ -0,0 +1,159 @@
// Metro module 8699 (f8700).
import { useState, useEffect, useCallback } from "react";
import UserProfileStore from "../../user_profile/UserProfileStore";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import { isNullOrEmpty } from "../../../utils/StringUtils";
import { useStateFromStores } from "../../../_bundle/Module589";
import { useIsSkuInWishlist } from "../../wishlists/hooks/useWishlistHooks";
import WishlistActionCreators from "../../wishlists/WishlistActionCreators";
import { AccessibilityAnnouncer } from "../../../design/shared";
import { intl, t } from "../../../intl/index.native";
export function useWishlistButtonState({ userId, skuId, location: location2, onAddSuccess, onRemoveSuccess, onError, skipAddAnnouncement }) {
let setState, state, setState2, state2;
setState = void 0;
state = void 0;
setState2 = void 0;
state2 = void 0;
const analyticsLocations = useAnalyticsLocations(isNullOrEmpty(location2) ? [] : [location2]).analyticsLocations;
const stateFromStores = useStateFromStores([UserProfileStore], () => UserProfileStore.getFirstWishlistId(userId));
let r37 = useIsSkuInWishlist(stateFromStores, skuId);
let state3;
[state3, setState] = useState(null);
[state, setState2] = useState(false);
if (state3 !== null) {
r37 = state3;
}
state2 = r37;
useEffect(() => {
setState(null);
setState2(false);
}, [skuId]);
return {
isWishlisted: state2,
isBusy: state,
handleToggle: useCallback(async () => {
let c26272_2;
let c26272_3 = 0;
let c29972_0, c29972_1;
L26: {
L18: {
try {
if (state) {
break L26;
}
setState2(true);
if (state2 && stateFromStores != null) {
setState(false);
c26272_3 = 3;
await WishlistActionCreators.removeSkuFromWishlist(stateFromStores, skuId, analyticsLocations);
AccessibilityAnnouncer.announce(intl.string(t.DSXOiP));
if (onRemoveSuccess != null) {
onRemoveSuccess();
}
c26272_3 = 1;
c26272_3 = 0;
(0, setState)(null);
(0, setState2)(false);
break L18;
}
setState(true);
c26272_3 = 4;
await WishlistActionCreators.addSkuToWishlist(skuId, analyticsLocations);
if (!skipAddAnnouncement) {
AccessibilityAnnouncer.announce(intl.string(t["3T2jbf"]));
}
if (onAddSuccess != null) {
onAddSuccess();
}
c26272_3 = 2;
c26272_3 = 0;
(0, setState)(null);
(0, setState2)(false);
} catch ($e) {
const r35 = $e;
let r7 = r35;
c26272_2 = r35;
let r36 = c26272_3;
if (r36 !== 0) {
while (true) {
if (r36 === 1) {
try {
const r212 = c26272_2;
c26272_3 = 0;
(0, setState)(null);
(0, setState2)(false);
throw r212;
} catch (r210) {
r7 = r210;
c26272_2 = r210;
r36 = c26272_3;
if (r36 === 0) {
break;
}
}
} else if (r36 === 2) {
try {
const r202 = c26272_2;
c26272_3 = 0;
(0, setState)(null);
(0, setState2)(false);
throw r202;
} catch (r200) {
r7 = r200;
c26272_2 = r200;
r36 = c26272_3;
if (r36 === 0) {
break;
}
}
} else if (r36 === 3) {
try {
const r186 = c26272_2;
c26272_3 = 1;
c29972_0 = r186;
if (onError != null) {
onError(c29972_0);
}
c26272_3 = 0;
(0, setState)(null);
(0, setState2)(false);
break L18;
} catch (r183) {
r7 = r183;
c26272_2 = r183;
r36 = c26272_3;
if (r36 === 0) {
break;
}
}
} else {
try {
const r169 = c26272_2;
c26272_3 = 2;
c29972_1 = r169;
if (onError != null) {
onError(c29972_1);
}
c26272_3 = 0;
(0, setState)(null);
(0, setState2)(false);
break L18;
} catch (r166) {
r7 = r166;
c26272_2 = r166;
r36 = c26272_3;
if (r36 === 0) {
break;
}
}
}
}
}
throw r7;
}
}
return void 0;
}
}, [state, state2, stateFromStores, skuId, analyticsLocations, onAddSuccess, onRemoveSuccess, onError, skipAddAnnouncement])
};
}