"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CommunityCover = CommunityCover;
var _react = require("react");
var _enums = require("../../../../enums");
var _hooks = require("../../../../hooks");
var _reactNativeLinearGradient = _interopRequireDefault(require("react-native-linear-gradient"));
var _reactNative = require("react-native");
var _components = require("../../components");
var _useAuth = _interopRequireDefault(require("../../../../../core/hooks/useAuth"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function CommunityCover({
  pageId = _enums.PageID.WildCardPage,
  componentId = _enums.ComponentID.WildCardComponent,
  community,
  smallHeader = false,
  hideButtons = false,
  isFromComponent
}) {
  const {
    apiRegion
  } = (0, _useAuth.default)();
  const elementId = _enums.ElementID.community_cover;
  const {
    accessibilityId,
    themeStyles
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId
  });
  const styles = _reactNative.StyleSheet.create({
    smallContainer: {
      height: 100
    },
    placehoder: {
      width: '100%',
      height: 187.5
    },
    coverImage: {
      width: '100%',
      height: 187.5
    }
  });
  const renderImage = (0, _react.useCallback)(() => {
    if (community.avatarFileId) {
      return /*#__PURE__*/React.createElement(_reactNative.Image, {
        source: {
          uri: `https://api.${apiRegion}.amity.co/api/v3/files/${community.avatarFileId}/download?size=medium`
        },
        style: [styles.coverImage, smallHeader ? styles.smallContainer : {}],
        blurRadius: smallHeader ? 10 : 0
      });
    } else {
      return /*#__PURE__*/React.createElement(_reactNativeLinearGradient.default, {
        colors: [themeStyles.colors.baseShade3, themeStyles.colors.baseShade2],
        style: [styles.placehoder, smallHeader ? styles.smallContainer : {}],
        start: {
          x: 0,
          y: 1
        },
        end: {
          x: 0,
          y: 0
        }
      });
    }
  }, [community.avatarFileId, smallHeader, styles, themeStyles, apiRegion]);
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    testID: accessibilityId
  }, renderImage(), !hideButtons && /*#__PURE__*/React.createElement(_components.TopBar, {
    pageId: pageId,
    componentId: componentId,
    communityId: community.communityId,
    isFromComponent: isFromComponent
  }));
}
//# sourceMappingURL=CommunityCover.js.map