"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useFile = void 0;
var _react = require("react");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _imageSizeState = require("../enums/imageSizeState");
var _index = require("../../core/assets/index");
const useFile = () => {
  const getImage = (0, _react.useCallback)(async ({
    fileId,
    imageSize = _imageSizeState.ImageSizeState.medium,
    type = 'user'
  }) => {
    if (!fileId) return type === 'community' ? _index.defaultCommunityAvatarUri : _index.defaultAvatarUri;
    const file = await _tsSdkReactNative.FileRepository.getFile(fileId);
    if (!file) return type === 'community' ? _index.defaultCommunityAvatarUri : _index.defaultAvatarUri;
    const newImageUrl = _tsSdkReactNative.FileRepository.fileUrlWithSize(file.data.fileUrl, imageSize) ?? (type === 'community' ? _index.defaultCommunityAvatarUri : _index.defaultAvatarUri);
    return newImageUrl;
  }, []);
  return {
    getImage
  };
};
exports.useFile = useFile;
//# sourceMappingURL=useFile.js.map