// Metro module 9700 (f9701).
import { useMemo, useCallback, useState } from "react";
import UserStore from "../../../../stores/UserStore";
import { PaymentFlowStep, getBasePurchaseFlowAnalyticsFields } from "../PremiumAnalyticsUtils";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import { useStateFromStores } from "../../../../_bundle/Module589";
import { useFetchWishlistAndProfileInfoForUser, useShouldShowWishlistInDMGifting } from "../../../wishlists/hooks/useWishlistHooks";
import { intl, t } from "../../../../intl/index.native";
import { getHeaderCloseButton, getHeaderBackButton } from "../../../../design/components/Navigator/native/NavigatorHeader.native";
import PremiumGiftPlanSelect from "./PremiumGiftPlanSelect";
import GiftingSKUSelectScreen from "../../gifting/native/views/promotions/GiftingSKUSelectScreen";
import PremiumGiftCustomization from "./PremiumGiftCustomization";
import PremiumGiftSuccess from "./PremiumGiftSuccess";
import GiftingBadge_messages from "../../gifting/GiftingBadge.messages";
import GiftBadgePostPurchase from "./GiftBadgePostPurchase";
import { openGiftModal } from "../utils/openGiftModal";
import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../../app_analytics/useAnalyticsLocations";
import useInitialValue from "../../../../hooks/useInitialValue";
import { v4 } from "../../../../_bundle/Module514";
import ModalActionCreators from "../../../../actions/ModalActionCreators";
import { isPremiumGiftingSupported } from "../../../device/BillingPlatformUtils";
import UnsupportedFeatureModal from "../../../billing/native/UnsupportedFeatureModal";
import { NativeGiftContextProvider } from "../../../payments/native/NativeGiftContext";
import PremiumGiftAnalytics from "./PremiumGiftAnalytics";
import { Navigator } from "../../../../design/components/Navigator/native/Navigator.native";
let c6417_7 = {
PLAN_SELECT: "PremiumGiftPlanSelect",
REWARD_SELECT: "GiftingSKUSelect",
CUSTOMIZATION: "PremiumGiftCustomization",
SUCCESS: "PremiumGiftSuccess",
GIFTING_BADGE: "GiftingBadgePostPurchase"
};
const r30 = {};
r30[c6417_7.PLAN_SELECT] = PaymentFlowStep.SKU_SELECT;
r30[c6417_7.REWARD_SELECT] = PaymentFlowStep.REWARD_SKU_SELECT;
r30[c6417_7.CUSTOMIZATION] = PaymentFlowStep.PLAN_SELECT;
r30[c6417_7.SUCCESS] = PaymentFlowStep.CONFIRM;
r30[c6417_7.GIFTING_BADGE] = PaymentFlowStep.CONFIRM;
let c6417_8 = r30;
const useStyles = createStyles({
header: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
shadowColor: "transparent"
}
});
export default function PremiumGiftModal(props) {
let setState;
const { recipientUserId: recipientUserId2, premiumType, planInterval, analyticsLocation, analyticsLocations } = props;
let initialRoute = props.initialRoute;
const { order, onDismiss } = props;
setState = void 0;
const analyticsLocations2 = useAnalyticsLocations(analyticsLocations).analyticsLocations;
const analyticsLoadId = useInitialValue(() => v4());
const memo = useMemo(() => getBasePurchaseFlowAnalyticsFields({
isGift: true,
analyticsLoadId,
analyticsLocation,
analyticsLocations
}), [analyticsLoadId, analyticsLocation, analyticsLocations]);
if (initialRoute == null) {
initialRoute = premiumType != null ? c6417_7.CUSTOMIZATION : c6417_7.PLAN_SELECT;
}
let recipientUserId, wishlist, userProfile, wishlistId, error, shouldShowWishlistInDMGifting;
const callback = useCallback(() => {
ModalActionCreators.pop();
if (onDismiss != null) {
onDismiss();
}
}, [onDismiss]);
recipientUserId = recipientUserId2;
wishlist = void 0;
userProfile = void 0;
wishlistId = void 0;
error = void 0;
shouldShowWishlistInDMGifting = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([UserStore], () => recipientUserId != null ? UserStore.getUser(recipientUserId) : null);
const fetchWishlistAndProfileInfoForUser = useFetchWishlistAndProfileInfoForUser(recipientUserId);
wishlist = fetchWishlistAndProfileInfoForUser.wishlist;
userProfile = fetchWishlistAndProfileInfoForUser.userProfile;
wishlistId = fetchWishlistAndProfileInfoForUser.wishlistId;
error = fetchWishlistAndProfileInfoForUser.error;
shouldShowWishlistInDMGifting = useShouldShowWishlistInDMGifting({
isGift: true,
giftRecipient: stateFromStores,
isSocialLayerStorefrontEnabled: false
});
const PLAN_SELECT = c6417_7.PLAN_SELECT;
const r65 = shouldShowWishlistInDMGifting ? {
title: intl.string(t["JCFN/y"]),
headerLeft: getHeaderCloseButton(callback),
headerStyle: styles.header,
render: () =>
} : {
title: "",
headerShown: false,
render: () =>
};
const screens = {};
screens[PLAN_SELECT] = r65;
screens[c6417_7.REWARD_SELECT] = {
title: "",
headerLeft: initialRoute === c6417_7.REWARD_SELECT ? getHeaderCloseButton(callback) : getHeaderBackButton(),
headerStyle: styles.header,
render: (a0) =>
};
screens[c6417_7.CUSTOMIZATION] = {
title: "",
headerLeft: initialRoute === c6417_7.CUSTOMIZATION ? getHeaderCloseButton(callback) : getHeaderBackButton(),
headerStyle: styles.header,
render: () =>
};
screens[c6417_7.SUCCESS] = {
title: "",
headerLeft: getHeaderCloseButton(callback),
headerStyle: styles.header,
render: () =>
};
screens[c6417_7.GIFTING_BADGE] = {
title: intl.string(GiftingBadge_messages.roVAey),
headerLeft: getHeaderCloseButton(callback),
headerTransparent: true,
headerStyle: {
backgroundColor: "transparent",
shadowColor: "transparent"
},
render: (a0) => {
openGiftModal({
analyticsLocations: [AnalyticsLocation.GIFTING_BADGE_POST_PURCHASE]
});
}} />
};
let currentStep;
[currentStep, setState] = useState(c6417_8[initialRoute]);
return isPremiumGiftingSupported() ?
{
if (event != null) {
setState(c6417_8[event.routes[event.index].name]);
}
}} />
: ;
};
export { c6417_7 as PremiumGiftScreens };