'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "default", {
    enumerable: true,
    get: function() {
        return _default;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _File = /*#__PURE__*/ _interop_require_default(require("../../graphics/File"));
const _useThumbnail = /*#__PURE__*/ _interop_require_default(require("../../hooks/useThumbnail"));
require("./index.scss");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const baseClass = 'thumbnail';
const Thumbnail = (props)=>{
    const { className = '', collectionSlug, doc: { filename } = {}, doc, fileSrc, imageCacheTag, size, uploadConfig } = props;
    const thumbnailSRC = (0, _useThumbnail.default)(collectionSlug, uploadConfig, doc) || fileSrc;
    const [src, setSrc] = (0, _react.useState)(thumbnailSRC);
    const classes = [
        baseClass,
        `${baseClass}--size-${size || 'medium'}`,
        className
    ].join(' ');
    (0, _react.useEffect)(()=>{
        if (thumbnailSRC) {
            setSrc(`${thumbnailSRC}${imageCacheTag ? `?${imageCacheTag}` : ''}`);
        }
    }, [
        thumbnailSRC,
        imageCacheTag
    ]);
    return /*#__PURE__*/ _react.default.createElement("div", {
        className: classes
    }, src && /*#__PURE__*/ _react.default.createElement("img", {
        alt: filename,
        src: src
    }), !src && /*#__PURE__*/ _react.default.createElement(_File.default, null));
};
const _default = Thumbnail;

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9lbGVtZW50cy9UaHVtYm5haWwvaW5kZXgudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIid1c2UgY2xpZW50J1xuaW1wb3J0IFJlYWN0LCB7IHVzZUVmZmVjdCwgdXNlU3RhdGUgfSBmcm9tICdyZWFjdCdcblxuaW1wb3J0IHR5cGUgeyBQcm9wcyB9IGZyb20gJy4vdHlwZXMnXG5cbmltcG9ydCBGaWxlR3JhcGhpYyBmcm9tICcuLi8uLi9ncmFwaGljcy9GaWxlJ1xuaW1wb3J0IHVzZVRodW1ibmFpbCBmcm9tICcuLi8uLi9ob29rcy91c2VUaHVtYm5haWwnXG5pbXBvcnQgJy4vaW5kZXguc2NzcydcblxuY29uc3QgYmFzZUNsYXNzID0gJ3RodW1ibmFpbCdcblxuY29uc3QgVGh1bWJuYWlsOiBSZWFjdC5GQzxQcm9wcz4gPSAocHJvcHMpID0+IHtcbiAgY29uc3Qge1xuICAgIGNsYXNzTmFtZSA9ICcnLFxuICAgIGNvbGxlY3Rpb25TbHVnLFxuICAgIGRvYzogeyBmaWxlbmFtZSB9ID0ge30sXG4gICAgZG9jLFxuICAgIGZpbGVTcmMsXG4gICAgaW1hZ2VDYWNoZVRhZyxcbiAgICBzaXplLFxuICAgIHVwbG9hZENvbmZpZyxcbiAgfSA9IHByb3BzXG5cbiAgY29uc3QgdGh1bWJuYWlsU1JDID0gdXN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