// Metro module 8521 (f8522).
import { useCallback } from "react";
import { Image as Image2, Pressable, View } from "react-native";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import useOpenExternalUrlFromGameProfile from "../../hooks/useOpenExternalUrlFromGameProfile";
import Linking from "../../../../lib/native/Linking";
import { calculateSteamReviewScoreDescription } from "../../../game_detection/calculateSteamReviewScoreDescription";
import * as _GameProfileReviewUtils from "../../GameProfileReviewUtils";
import { getSteamReviewScoreDescriptionColor, getSteamReviewScoreDescriptionIntl } from "../../GameProfileReviewUtils";
import { GameProfileTrackActionActions } from "../../GameProfileAnalyticUtils";
import { intl, t } from "../../../../intl/index.native";
import { SteamNeutralIcon } from "../../../../design/components/Icon/native/redesign/generated/SteamNeutralIcon";
import { Text } from "../../../../design/components/Text/native/Text";
import { SteamReviewScoreDescription } from "../../../game_detection/GameDetectionTypes";
import { getOpenCriticTierText, getOpenCriticCircleRatingColor, getOpenCriticTierImage } from "../../hooks/useGameProfileOpenCritic";
import OpenCriticRatingCircle from "./OpenCriticRatingCircle";
import { useSteamWebsiteUrl } from "../../hooks/useSteamWebsiteUrl";
import { SteamReleaseStatus } from "../../../../_bundle/Module8492";
let useStyles, OpenCriticReview;
const SteamReviewRow = function SteamReviewRow(props) {
const url = props.url;
let showBorderBottom = props.showBorderBottom;
const { trackAction, title, rating, ratingCount, isRecentRating } = props;
const styles = useStyles();
const openExternalUrlFromGameProfile = useOpenExternalUrlFromGameProfile(Linking.openURL);
let c16625_2 = openExternalUrlFromGameProfile;
const r11 = calculateSteamReviewScoreDescription(rating, ratingCount, isRecentRating);
const steamReviewScoreDescriptionColor = getSteamReviewScoreDescriptionColor(r11);
const props2 = {
onPress: useCallback(() => {
trackAction(GameProfileTrackActionActions.SteamReviews);
c16625_2(url);
}, [openExternalUrlFromGameProfile, url, trackAction]),
accessibilityRole: "link",
accessibilityLabel: intl.string(t.YNC5Di),
style: null,
children: null
};
const style = [styles.reviewRow, ,];
if (showBorderBottom) {
showBorderBottom = styles.reviewRowNotLast;
}
style[1] = showBorderBottom;
props2.style = style;
props2.children = [
{title}
,
{getSteamReviewScoreDescriptionIntl(r11)}
{ratingCount != null && r11 !== SteamReviewScoreDescription.NO_USER_REVIEWS &&
{intl.format(t.sgIoin, {
rating_count: ratingCount.toLocaleString()
}).toString()}
}
];
return ;
};
OpenCriticReview = function OpenCriticReview(props) {
const { game, url: url2, trackAction: trackAction2 } = props;
const styles = useStyles();
let r30 = game.reviews?.opencritic;
if (r30 == null) {
r30 = {
topCriticRating: void 0,
topCriticRatingCount: void 0,
tier: void 0
};
}
const tier = r30.tier;
let topCriticRating = r30.topCriticRating;
if (topCriticRating == null) {
topCriticRating = -1;
}
let topCriticRatingCount = r30.topCriticRatingCount;
if (topCriticRatingCount == null) {
topCriticRatingCount = -1;
}
const openExternalUrlFromGameProfile = useOpenExternalUrlFromGameProfile(Linking.openURL);
let c16626_2 = openExternalUrlFromGameProfile;
const callback = useCallback(() => {
trackAction2(GameProfileTrackActionActions.OpenCriticReviews);
c16626_2(url2);
}, [openExternalUrlFromGameProfile, url2, trackAction2]);
const accessibilityLabel = tier != null ? getOpenCriticTierText(tier) : "";
const r45 = tier != null ? getOpenCriticCircleRatingColor(tier) : {
foregroundColor: "",
backgroundColor: ""
};
const { foregroundColor, backgroundColor } = r45;
const props2 = {
onPress: callback,
accessibilityRole: "link",
accessibilityLabel: intl.string(t.aLNBAw),
style: styles.reviewRow,
children: null
};
const children = [
{intl.string(t["UxvER+"])}
, ,];
const r89 = [tier != null ?
: null, tier != null ? topCriticRating > 0 ? topCriticRatingCount > 0 ?
{Math.floor(topCriticRating)}
: null : null : null, topCriticRating <= 0 ? tier == null ?
{intl.string(t["0xYzpO"])}
: null : topCriticRatingCount <= 0 ? tier == null ?
{intl.string(t["0xYzpO"])}
: null : null];
children[1] = {r89};
props2.children = children;
return ;
};
useStyles = createStyles({
container: {
gap: Module712.space.PX_8
},
headerText: {
paddingHorizontal: Module712.space.PX_8
},
reviewContainer: {
borderRadius: Module712.radii.lg,
borderWidth: 1,
borderColor: Module712.colors.BORDER_SUBTLE,
overflow: "hidden"
},
reviewRow: {
height: 56,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: Module712.space.PX_12
},
reviewRowNotLast: {
borderBottomWidth: 1,
borderBottomColor: Module712.colors.BACKGROUND_MOD_SUBTLE
},
steamNameContainer: {
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_8
},
steamRatingContainer: {
flexDirection: "row",
alignItems: "flex-end",
flexShrink: 1,
paddingLeft: Module712.space.PX_32,
gap: Module712.space.PX_4
},
opencriticRightContainer: {
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_12
},
opencriticTopCriticContainer: {
width: 32,
height: 32,
borderRadius: Module712.radii.round,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
alignItems: "center",
justifyContent: "center"
},
opencriticTopCriticImage: {
width: 32,
height: 32
},
opencriticTopCriticRatingContainer: {
position: "absolute",
top: 0,
left: 1,
right: 0,
bottom: 0,
alignItems: "center",
justifyContent: "center"
}
});
export default function GameProfileReviews(props) {
let r68;
const { game, trackAction: trackAction3 } = props;
const styles = useStyles();
const steamWebsiteUrl = useSteamWebsiteUrl(game?.id);
const opencriticUrl = game?.opencriticUrl;
if (game == null) {
return null;
}
const r4 = game.steamReleaseStatus !== SteamReleaseStatus.RETIRED_ABANDONED && steamWebsiteUrl != null;
const steam = game.reviews?.steam;
const r48 = calculateSteamReviewScoreDescription(steam?.recentRating, steam?.recentRatingCount, true);
const r3 = r4 ? r48 !== SteamReviewScoreDescription.NO_USER_REVIEWS : r4;
const canShowLocalizedSteamReview = _GameProfileReviewUtils.canShowLocalizedSteamReview(steam);
const r57 = steam == null;
const rating = canShowLocalizedSteamReview ? r57 ? void 0 : steam.localizedRating : r57 ? void 0 : steam.rating;
const r59 = steam == null;
const ratingCount = canShowLocalizedSteamReview ? r59 ? void 0 : steam.localizedRatingCount : r59 ? void 0 : steam.ratingCount;
const r25 = canShowLocalizedSteamReview ? t["aWb+V4"] : t["8e4LiB"];
const showBorderBottom = game.reviews?.opencritic != null && opencriticUrl != null;
L55: {
if (!r4 && !r3) {
r68 = null;
if (!showBorderBottom) {
break L55;
}
}
r68 =
{intl.string(t.GaAQXP)}
{r3 ? steamWebsiteUrl != null ? : null : null}
{r4 ? steamWebsiteUrl != null ? : null : null}
{showBorderBottom ? opencriticUrl != null ? : null : null}
;
}
return r68;
};