import { TouchableOpacity, View } from 'react-native';
import { BrandBadge } from '../../../../../elements/BrandBadge';
import { useStyles } from './styles';
import Avatar from '../../../../../components/Avatar';
import { Typography } from '../../../../../../core/components/Typography/Typography';
import Skeleton from '../../../../../../core/components/Skeleton/Skeleton';
import { useBlockUser } from '../../../../../hooks';
import { useNavigation } from '@react-navigation/native';
import { useBehaviour } from '../../../../../providers/BehaviourProvider';
import { UnblockUserButton } from '../../elements';
export function UserItem({
  user
}) {
  var _user$avatar;
  const {
    styles
  } = useStyles();
  const {
    unBlockUser
  } = useBlockUser();
  const {
    AmityBlockedUsersPageBehavior
  } = useBehaviour();
  const navigation = useNavigation();
  const handleUnblock = () => {
    unBlockUser(user.userId, user.displayName);
  };
  return /*#__PURE__*/React.createElement(TouchableOpacity, {
    activeOpacity: 0.7,
    accessibilityRole: "button",
    accessibilityLabel: `View ${user.displayName}'s profile`,
    style: styles.container,
    onPress: () => {
      if (AmityBlockedUsersPageBehavior !== null && AmityBlockedUsersPageBehavior !== void 0 && AmityBlockedUsersPageBehavior.goToUserProfilePage) {
        AmityBlockedUsersPageBehavior.goToUserProfilePage({
          userId: user.userId
        });
      } else {
        navigation.navigate('UserProfile', {
          userId: user.userId
        });
      }
    }
  }, /*#__PURE__*/React.createElement(Avatar.User, {
    userId: user.userId,
    imageStyle: styles.avatar,
    userName: user.displayName,
    uri: user.avatarCustomUrl ?? ((_user$avatar = user.avatar) === null || _user$avatar === void 0 ? void 0 : _user$avatar.fileUrl)
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.nameContainer
  }, /*#__PURE__*/React.createElement(Typography.BodyBold, {
    numberOfLines: 1,
    ellipsizeMode: "tail",
    style: styles.displayName
  }, user.displayName), user.isBrand && /*#__PURE__*/React.createElement(BrandBadge, {
    accessible: true,
    accessibilityLabel: "Brand verified",
    width: 16,
    height: 16
  })), /*#__PURE__*/React.createElement(UnblockUserButton, {
    accessibilityLabel: `Unblock ${user.displayName}`,
    onPress: handleUnblock
  }));
}
function UserItemSkeleton() {
  const {
    styles
  } = useStyles();
  return /*#__PURE__*/React.createElement(Skeleton, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(Skeleton.Circle, {
    width: 40,
    height: 40
  }), /*#__PURE__*/React.createElement(Skeleton.Line, {
    width: 140,
    height: 10
  }));
}
UserItem.Skeleton = UserItemSkeleton;
//# sourceMappingURL=UserItem.js.map