import { Download as DownloadIcon } from "@sofa-design/icons";
import { Button, Typography } from "antd";
import classNames from "clsx";
import React from "react";
import { formatFileSize, formatLastModified } from "../../../utils";
import { fileTypeProcessor } from "../../FileTypeProcessor";
import { getFileTypeIcon } from "../../utils";
import { PlaceholderContent } from "./PlaceholderContent";
/**
 * 「无法预览」卡片
 *
 * 复用 `${filePrefixCls}-item-*` 的视觉 token，与列表页文件卡保持一致；
 * 当存在下载源时展示「下载」按钮，否则仅展示提示文案。
 */ export var UnsupportedFileCard = function UnsupportedFileCard(param) {
    var file = param.file, canDownload = param.canDownload, onDownload = param.onDownload, filePrefixCls = param.filePrefixCls, prefixCls = param.prefixCls, hashId = param.hashId, locale = param.locale;
    var typeInfo = fileTypeProcessor.inferFileType(file);
    var showDownload = canDownload && Boolean(onDownload);
    return /*#__PURE__*/ React.createElement(PlaceholderContent, {
        prefixCls: prefixCls,
        hashId: hashId
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-unsupported"), hashId)
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(filePrefixCls, "-item"), "".concat(prefixCls, "-unsupported-item"), hashId)
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(filePrefixCls, "-item-icon"), hashId)
    }, getFileTypeIcon(typeInfo.fileType, file.icon, file.name)), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(filePrefixCls, "-item-info"), hashId),
        style: {
            textAlign: 'left'
        }
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(filePrefixCls, "-item-name"), hashId)
    }, /*#__PURE__*/ React.createElement(Typography.Text, {
        ellipsis: {
            tooltip: file.name
        },
        style: {
            font: 'var(--font-text-h6-base)'
        }
    }, file.name)), (typeInfo.displayType || file.size || file.lastModified) && /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(filePrefixCls, "-item-details"), hashId)
    }, /*#__PURE__*/ React.createElement(Typography.Text, {
        type: "secondary",
        ellipsis: true
    }, typeInfo.displayType && /*#__PURE__*/ React.createElement("span", {
        className: classNames("".concat(filePrefixCls, "-item-type"), hashId)
    }, typeInfo.displayType), file.size && /*#__PURE__*/ React.createElement(React.Fragment, null, typeInfo.displayType && /*#__PURE__*/ React.createElement("span", {
        className: classNames("".concat(filePrefixCls, "-item-separator"), hashId)
    }, "|"), /*#__PURE__*/ React.createElement("span", {
        className: classNames("".concat(filePrefixCls, "-item-size"), hashId)
    }, formatFileSize(file.size))), file.lastModified && /*#__PURE__*/ React.createElement(React.Fragment, null, (typeInfo.displayType || file.size) && /*#__PURE__*/ React.createElement("span", {
        className: classNames("".concat(filePrefixCls, "-item-separator"), hashId)
    }, "|"), /*#__PURE__*/ React.createElement("span", {
        className: classNames("".concat(filePrefixCls, "-item-time"), hashId)
    }, formatLastModified(file.lastModified))))))), showDownload ? /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-unsupported-text"), hashId)
    }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unsupportedPreview']) || '此文件无法预览，请下载查看。'), /*#__PURE__*/ React.createElement(Button, {
        color: "default",
        variant: "solid",
        icon: /*#__PURE__*/ React.createElement(DownloadIcon, null),
        onClick: onDownload,
        "aria-label": (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载'
    }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.downloadButton']) || '下载')) : /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-unsupported-text"), hashId)
    }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unsupportedPreviewNoDownload']) || '此文件无法预览。')));
};
