"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _enums = require("../enums");
const useFile = ({
  fileId,
  imageSize = _enums.ImageSizeState.medium
}) => {
  const [imageUrl, setImageUrl] = (0, _react.useState)(undefined);
  (0, _react.useEffect)(() => {
    async function run() {
      if (!fileId) return;
      const file = await _tsSdkReactNative.FileRepository.getFile(fileId);
      if (!file) return;
      const newImageUrl = await _tsSdkReactNative.FileRepository.fileUrlWithSize(file.data.fileUrl, imageSize);
      setImageUrl(newImageUrl);
    }
    run();
  }, [fileId, imageSize]);
  return imageUrl;
};
var _default = exports.default = useFile;
//# sourceMappingURL=useFile.js.map