"use strict";
require("react");
const index$7 = require("../../../icon/react-icon/IconFile/index.js");
const index$4 = require("../../../icon/react-icon/IconFilePdf/index.js");
const index = require("../../../icon/react-icon/IconFileImage/index.js");
const index$6 = require("../../../icon/react-icon/IconFileVideo/index.js");
const index$5 = require("../../../icon/react-icon/IconFileAudio/index.js");
const index$2 = require("../../Tooltip/index.js");
const _interface = require("../interface.js");
const is = require("../../_util/is.js");
const uploadProgress = require("./uploadProgress.js");
const index$1 = require("../../../icon/react-icon/IconExclamationCircleFill/index.js");
const index$3 = require("../../../icon/react-icon/IconDelete/index.js");
const iconHover = require("../../_class/icon-hover.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var getIconType = function(file) {
  var type = "";
  if (file.originFile && file.originFile.type) {
    type = file.originFile.type;
  } else {
    var name_1 = file.name || "";
    var fileExtension = name_1.split(".").pop() || "";
    type = fileExtension;
    if (["png", "jpg", "jpeg", "bmp", "gif"].indexOf(fileExtension) > -1) {
      type = "image";
    } else if (["mp4", "m2v", "mkv"].indexOf(fileExtension) > -1) {
      type = "video";
    } else if (["mp3", "wav", "wmv"].indexOf(fileExtension) > -1) {
      type = "audio";
    }
  }
  if (type.indexOf("image") > -1) {
    return index;
  }
  if (type.indexOf("pdf") > -1) {
    return index$4;
  }
  if (type.indexOf("audio") > -1) {
    return index$5;
  }
  if (type.indexOf("video") > -1) {
    return index$6;
  }
  return index$7;
};
var TextItem = function(props) {
  var prefixCls = props.prefixCls, disabled = props.disabled, file = props.file, locale = props.locale;
  var cls = prefixCls + "-list-item-text";
  var Icon = getIconType(file);
  var showUploadList = is.isObject(props.showUploadList) ? props.showUploadList : {};
  var actionIcons = is.isObject(showUploadList) ? showUploadList : {};
  var fileName = file.name || file.originFile && file.originFile.name;
  var url = file.url !== void 0 ? file.url : file.originFile && is.isFunction(URL.createObjectURL) && URL.createObjectURL(file.originFile);
  var triggerProps = {};
  if (file.status !== _interface.STATUS.fail) {
    triggerProps = {
      popupVisible: false
    };
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
    className: prefixCls + "-list-item " + prefixCls + "-list-item-" + file.status,
    children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
      className: cls,
      children: [props.listType === "picture-list" && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
        className: cls + "-thumbnail",
        children: is.isFunction(showUploadList.imageRender) ? showUploadList.imageRender(file) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("img", {
          src: url
        })
      }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
        className: cls + "-content",
        children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
          className: cls + "-name",
          children: [props.listType === "text" && actionIcons.fileIcon !== null && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
            className: prefixCls + "-list-file-icon",
            children: actionIcons.fileIcon || /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(Icon, {})
          }), is.isFunction(showUploadList.fileName) ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
            className: cls + "-name-text",
            children: showUploadList.fileName(file)
          }) : file.url ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("a", {
            href: file.url,
            target: "_blank",
            rel: "noreferrer",
            className: cls + "-name-link",
            children: fileName
          }) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
            className: cls + "-name-text",
            children: fileName
          }), file.status === _interface.STATUS.fail && actionIcons.errorIcon !== null && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {
            ...__assign({
              content: file.response || locale.Upload.error
            }, triggerProps, {
              disabled: file.status !== _interface.STATUS.fail
            }),
            children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
              className: props.prefixCls + "-list-error-icon",
              children: actionIcons.errorIcon || (props.listType === "picture-card" ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index, {}) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {}))
            })
          })]
        }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(uploadProgress, {
          ...__assign({
            file,
            prefixCls,
            progressProps: props.progressProps,
            onReupload: props.onReupload,
            onUpload: props.onUpload,
            onAbort: props.onAbort
          }, actionIcons)
        })]
      })]
    }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: prefixCls + "-list-item-operation",
      children: !disabled && actionIcons.removeIcon !== null && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(iconHover, {
        onClick: function() {
          props.onRemove && props.onRemove(file);
        },
        children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
          className: prefixCls + "-list-remove-icon",
          children: actionIcons.removeIcon || /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {})
        })
      })
    })]
  });
};
const TextItem$1 = TextItem;
module.exports = TextItem$1;
//# sourceMappingURL=textItem.js.map
