// Metro module 13748 (f13749).
import { useCallback } from "react";
import GuildMemberStore from "../../../stores/GuildMemberStore";
import UserStore from "../../../stores/UserStore";
import { AnalyticsObjects, AnalyticsSections, UpsellTypes } from "../../../Constants";
import { PremiumUpsellTypes } from "../../premium/PremiumConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../_bundle/Module589";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import usePendingAvatarSettings from "../../user_profile/hooks/usePendingAvatarSettings";
import useUploadAvatar from "../../user_profile/hooks/native/useUploadAvatar";
import { getPendingAvatarSrc } from "../../recent_avatars/RecentAvatarUtils";
import PremiumUtils from "../../../utils/PremiumUtils";
import * as _ProfileCustomizationUtils from "../../profile_customization/ProfileCustomizationUtils";
import PremiumUpsellUtils from "../../../utils/native/PremiumUpsellUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { ProfileAssetType, GIFSelectionContext } from "../../user_profile/native/ProfileGIFSelectActionSheet";
import { openAvatarDecorationActionSheet } from "../../collectibles/avatar_decorations/native/AvatarDecorationUtils";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import { intl, t } from "../../../intl/index.native";
import HeaderAvatar from "../../profile_customization/native/HeaderAvatar";
import EditIcon from "../../profile_customization/native/EditIcon";
const useStyles = createStyles({
editAvatarIcon: {
position: "absolute",
right: 0
}
});
export default function EditGuildIdentityAvatar(props) {
let stateFromStores2, analyticsLocations, setPendingAvatar, handleUploadAvatarSelect, canUsePremiumGuildMemberProfile, showAnimatedAvatarUpsell, showRemoveAvatar, avatarDecoration;
const { userId, guildId, disabled, disableStatus = true, style, statusStyle, avatarStyle } = props;
stateFromStores2 = void 0;
analyticsLocations = void 0;
setPendingAvatar = void 0;
handleUploadAvatarSelect = void 0;
canUsePremiumGuildMemberProfile = void 0;
showAnimatedAvatarUpsell = void 0;
showRemoveAvatar = void 0;
avatarDecoration = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
stateFromStores2 = useStateFromStores([GuildMemberStore], () => stateFromStores != null ? GuildMemberStore.getMember(guildId, stateFromStores?.id) : null);
analyticsLocations = useAnalyticsLocations(AnalyticsLocation.EDIT_AVATAR).analyticsLocations;
const pendingAvatarSettings = usePendingAvatarSettings({
guildId,
analyticsLocations
});
const { pendingAvatar, pendingAvatarDecoration } = pendingAvatarSettings;
setPendingAvatar = pendingAvatarSettings.setPendingAvatar;
handleUploadAvatarSelect = useUploadAvatar({
guildId,
analyticsLocations
});
const pendingAvatarSrc = getPendingAvatarSrc({
userId,
image: pendingAvatar
});
canUsePremiumGuildMemberProfile = PremiumUtils.canUsePremiumGuildMemberProfile(stateFromStores);
showAnimatedAvatarUpsell = !PremiumUtils.canUseAnimatedAvatar(stateFromStores);
showRemoveAvatar = _ProfileCustomizationUtils.showRemoveAvatar(pendingAvatar, stateFromStores2?.avatar);
let r26 = pendingAvatarDecoration;
if (r26 === void 0) {
r26 = stateFromStores2?.avatarDecoration;
}
avatarDecoration = r26;
const callback = useCallback(() => {
if (stateFromStores2 != null && stateFromStores != null) {
if (canUsePremiumGuildMemberProfile) {
ActionSheetActionCreators.openLazy(import("../../user_profile/native/ChangeAvatarActionSheet"), "Change Avatar", {
handleUploadAvatarSelect,
handleRemoveAvatarSelect: function handleRemoveAvatarSelect() {
ActionSheetActionCreators.hideActionSheet();
setPendingAvatar(null);
},
handleUploadGIFAvatarSelect: function handleUploadGIFAvatarSelect() {
ActionSheetActionCreators.hideActionSheet();
ActionSheetActionCreators.openLazy(import("../../user_profile/native/ProfileGIFSelectActionSheet"), "Select GIF Avatar", {
profileAssetType: ProfileAssetType.AVATAR,
selectionContext: GIFSelectionContext.PROFILE_EDIT,
guildId
});
},
handleEditAvatarDecorationSelect: function handleEditAvatarDecorationSelect() {
if (stateFromStores != null) {
openAvatarDecorationActionSheet({
user: stateFromStores,
guildId,
currentAvatarDecoration: avatarDecoration,
analyticsLocations
});
}
},
showAnimatedAvatarUpsell,
showRemoveAvatar
});
} else {
PremiumUpsellUtils.handleShowUpsellAlert({
initialUpsellKey: UpsellTypes.PREMIUM_GUILD_PROFILE,
analyticsLocation: {
section: AnalyticsSections.PREMIUM_GUILD_MEMBER_PROFILE,
object: AnalyticsObjects.EDIT_GUILD_PROFILE_AVATAR
},
analyticsLocations,
analyticsProperties: {
type: PremiumUpsellTypes.PREMIUM_GUILD_IDENTITY_MODAL
}
});
}
}
}, [guildId, stateFromStores2, stateFromStores, canUsePremiumGuildMemberProfile, showAnimatedAvatarUpsell, showRemoveAvatar, avatarDecoration, analyticsLocations, handleUploadAvatarSelect, setPendingAvatar]);
const r77 = stateFromStores == null;
let r78 = null;
if (!r77) {
const props2 = {
style,
disabled,
onPress: callback,
accessibilityRole: "button",
accessibilityLabel: intl.string(t["70lEQe"]),
children: null
};
const r97 = pendingAvatar === null;
props2.children = [, disabled ? !disabled : ];
r78 = ;
}
return r78;
};