'use client';
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
import { getBestFitFromSizes, isImage } from 'payload/shared';
import React from 'react';
import './index.scss';
import { Thumbnail } from '../../../../Thumbnail/index.js';
const baseClass = 'file';
export const FileCell = ({ cellData: filename, collectionConfig, field, rowData })=>{
    const fieldPreviewAllowed = 'displayPreview' in field ? field.displayPreview : undefined;
    const previewAllowed = fieldPreviewAllowed ?? collectionConfig.upload?.displayPreview ?? true;
    if (previewAllowed) {
        const isFileImage = isImage(rowData?.mimeType);
        let fileSrc = isFileImage ? rowData?.thumbnailURL || rowData?.url : rowData?.thumbnailURL;
        if (isFileImage) {
            fileSrc = getBestFitFromSizes({
                sizes: rowData?.sizes,
                thumbnailURL: rowData?.thumbnailURL,
                url: rowData?.url,
                width: rowData?.width
            });
        }
        return /*#__PURE__*/ _jsxDEV("div", {
            className: baseClass,
            children: [
                /*#__PURE__*/ _jsxDEV(Thumbnail, {
                    className: `${baseClass}__thumbnail`,
                    collectionSlug: collectionConfig?.slug,
                    doc: {
                        ...rowData,
                        filename
                    },
                    fileSrc: fileSrc,
                    size: "small",
                    uploadConfig: collectionConfig?.upload
                }, void 0, false, {
                    fileName: "src/elements/Table/DefaultCell/fields/File/index.tsx",
                    lineNumber: 48,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV("span", {
                    className: `${baseClass}__filename`,
                    children: String(filename)
                }, void 0, false, {
                    fileName: "src/elements/Table/DefaultCell/fields/File/index.tsx",
                    lineNumber: 59,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/elements/Table/DefaultCell/fields/File/index.tsx",
            lineNumber: 47,
            columnNumber: 7
        }, this);
    } else {
        return /*#__PURE__*/ _jsxDEV(_Fragment, {
            children: String(filename)
        }, void 0, false);
    }
};

//# sourceMappingURL=index.js.map