// Metro module 11214 (f11215). import { useMemo } from "react"; import UserStore from "../../stores/UserStore"; import TestModeStore from "../../stores/game_store/TestModeStore"; import EmbeddedActivitiesStore from "./EmbeddedActivitiesStore"; import { useStateFromStores, useStateFromStoresArray } from "../../_bundle/Module589"; import useGetOrFetchApplications from "../applications/useGetOrFetchApplications"; import { isNotNullish } from "../../utils/GlobalUtils"; import getPlatform from "./utils/getPlatform"; import { getOS } from "../../utils/PlatformUtils"; import isApplicationAgeRestricted from "../applications/utils/isApplicationAgeRestricted"; export function useActivityShelfData(c18627_0) { let stateFromStores2, c18627_4, memo, memo2, memo3; const stateFromStores = useStateFromStores([UserStore], UserStore.getCurrentUser); const stateFromStoresArray = useStateFromStoresArray([EmbeddedActivitiesStore], () => EmbeddedActivitiesStore.getShelfActivities(c18627_0)); stateFromStores2 = useStateFromStores([TestModeStore], () => TestModeStore.testModeEmbeddedApplicationId); const r34 = stateFromStoresArray.map((item) => item.application_id); const getOrFetchApplications = useGetOrFetchApplications(stateFromStores2 != null ? [stateFromStores2, ...r34] : r34); c18627_4 = getOrFetchApplications; memo = useMemo(() => c18627_4.filter(isNotNullish), [getOrFetchApplications]); memo2 = useMemo(() => stateFromStores2 != null && (memo.length > 0 && (memo[0].id === stateFromStores2 && memo[0].embeddedActivityConfig != null)) ? [{ activity: memo[0].embeddedActivityConfig, application: memo[0] }] : [], [memo, stateFromStores2]); memo3 = useMemo(() => stateFromStoresArray.map((a0) => { const application = memo.find((item) => item.id === a0.application_id); return application != null ? { activity: a0, application } : null; }).filter(isNotNullish), [stateFromStoresArray, memo]); return useMemo(() => [...memo2, ...memo3].filter((item) => { let supported_platforms = item.activity.supported_platforms; if (supported_platforms == null) { supported_platforms = []; } return supported_platforms.includes(getPlatform(getOS())); }).filter((item) => { const requires_age_gate = item.activity.requires_age_gate; return (requires_age_gate ? stateFromStores?.nsfwAllowed === true : !requires_age_gate) || stateFromStores?.nsfwAllowed == null; }).filter(({ application }) => !(stateFromStores?.nsfwAllowed === false && isApplicationAgeRestricted(application.id))), [stateFromStores?.nsfwAllowed, memo3, memo2]); }