import _Upload from "antd/es/upload";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["fileList", "matter", "action", "accept", "authorization", "tenantId", "preview", "flag", "style"];
/* eslint-disable @typescript-eslint/no-shadow */
import * as React from 'react';
import { PlusOutlined } from '@ant-design/icons/es/index';
import "./index.less";
var antUploadWall = function antUploadWall(_ref) {
  var fileList = _ref.fileList,
    matter = _ref.matter,
    action = _ref.action,
    accept = _ref.accept,
    authorization = _ref.authorization,
    tenantId = _ref.tenantId,
    preview = _ref.preview,
    flag = _ref.flag,
    style = _ref.style,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;

  // const getBase64 = (file) =>
  //   new Promise((resolve, reject) => {
  //     const reader = new FileReader();
  //     reader.readAsDataURL(file);
  //     reader.onload = () => resolve(reader.result);
  //     reader.onerror = (error) => reject(error);
  //   });
  // const [previewOpen, setPreviewOpen] = useState(false);
  // const [previewImage, setPreviewImage] = useState('');
  // const [previewTitle, setPreviewTitle] = useState('');
  // const [fileList, setFileList] = useState([...dataSource]);
  // const handleCancel = () => {
  //   console.log(111111111111)
  //   return setPreviewOpen(false);
  // }
  // const handlePreview = async (file) => {
  //   console.log(222222222222)

  //   if (!file.url && !file.preview) {
  //     file.preview = await getBase64(file.originFileObj);
  //   }
  //   setPreviewImage(file.url || file.preview);
  //   setPreviewOpen(true);
  //   setPreviewTitle(file.name || file.url.substring(file.url.lastIndexOf('/') + 1));
  // };
  // const handleChange = ({ fileList: newFileList }) => {
  //   console.log(newFileList, 33333333333333)

  //   // return setFileList(newFileList);
  // }

  var props = {
    label: "文件上传",
    name: "file",
    title: "上传文件",
    action: action,
    accept: accept,
    headers: {
      Authorization: "Bearer " + authorization,
      'TENANT-ID': tenantId
    }
  };
  var uploadButton = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("div", {
    style: {
      marginTop: 8
    }
  }, "Upload"));
  return (
    /*#__PURE__*/
    // <div style={{ width: _otherProps.style.width, height: _otherProps.style.height, display: flag ? 'none' : 'inline-block' }}>
    //   <Upload
    //     listType="picture-card"
    //     fileList={fileList}
    //     {...props}
    //     showUploadList={{ showPreviewIcon: false }}
    //     {..._otherProps}
    //   >
    //     {fileList.length >= 8 ? null : uploadButton}
    //   </Upload>
    //   {/* <Modal open={true} title={'详情'} footer={null}>
    //     <img
    //       alt="example"
    //       style={{
    //         width: '100%',
    //       }}
    //       src={""}
    //     />
    //   </Modal> */}
    // </div >
    React.createElement(_Upload, _extends({
      className: flag ? "isflag" : "",
      listType: "picture-card",
      fileList: fileList
    }, props, {
      showUploadList: {
        showPreviewIcon: false
      }
    }, _otherProps), fileList.length >= 8 ? null : uploadButton)
  );
};
antUploadWall.displayName = 'antUploadWall';
export default antUploadWall;