"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isNil2 = _interopRequireDefault(require("lodash/fp/isNil"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _dragAndDrop = _interopRequireDefault(require("../drag-and-drop"));
var _buttonLink = _interopRequireDefault(require("../button-link"));
var _proptypes = require("../../util/proptypes");
var _style = _interopRequireDefault(require("./style.css"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const InputFileDraggable = ({
  title,
  description,
  previewLabel,
  previewContent,
  uploadLabel,
  loading,
  modified,
  disabled = false,
  disableHoverTooltip = false,
  onChange,
  onReset = null,
  name,
  labelLink,
  labelButtonLink,
  hrefLink,
  filesTypes = '',
  error = '',
  buttonAriaLabel,
  errorButtonLabel,
  pdfButtonLabel,
  pdfButtonAriaLabel,
  filesNumber = 0,
  multiple = false,
  required = false,
  onClick
}) => {
  const handleReset = (0, _react.useCallback)(e => {
    if ((0, _isNil2.default)(onReset)) return;
    e.preventDefault();
    return onReset(e);
  }, [onReset]);
  const linkCustomStyle = {
    width: '40px',
    color: '#FF541F'
  };
  const onClick_ = (0, _react.useCallback)(e => {
    e.preventDefault();
    return onClick(e);
  }, [onClick]);
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dragAndDrop.default, {
    title: title,
    description: description,
    previewLabel: previewLabel,
    previewContent: previewContent,
    uploadLabel: uploadLabel,
    loading: loading,
    modified: modified,
    onReset: handleReset,
    error: error,
    disabled: disabled,
    disableHoverTooltip: disableHoverTooltip,
    buttonAriaLabel: buttonAriaLabel,
    errorButtonLabel: errorButtonLabel,
    pdfButtonLabel: pdfButtonLabel,
    pdfButtonAriaLabel: pdfButtonAriaLabel,
    multiple: multiple
  }, (onDragStart, onDragStop) => /*#__PURE__*/_react.default.createElement("input", _extends({}, disableHoverTooltip ? {
    title: ''
  } : {}, {
    type: "file",
    name: name,
    accept: filesTypes,
    disabled: loading || disabled,
    className: _style.default.input,
    onChange: onChange,
    onDragEnter: onDragStart,
    onDrop: onDragStop,
    onDragLeave: onDragStop,
    multiple: multiple,
    required: required
  }))), labelLink && hrefLink ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.templateLink
  }, labelLink, /*#__PURE__*/_react.default.createElement(_buttonLink.default, {
    type: "text",
    customStyle: linkCustomStyle,
    link: {
      href: hrefLink,
      download: true
    },
    label: labelButtonLink
  })) : null, multiple && filesNumber > 0 ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.multipleFilesContainer
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.filesNumber
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidFilesBasicFileLines, {
    className: _style.default.icon
  }), /*#__PURE__*/_react.default.createElement("div", null, filesNumber, " files")), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.seeDetailsButton,
    onClick: onClick_
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyEye, {
    className: _style.default.seeIcon
  }), /*#__PURE__*/_react.default.createElement("div", null, "See details"))) : null);
};
InputFileDraggable.propTypes = process.env.NODE_ENV !== "production" ? {
  ..._dragAndDrop.default.propTypes,
  disableHoverTooltip: _propTypes.default.bool,
  name: _propTypes.default.string,
  onChange: _propTypes.default.func,
  onReset: _propTypes.default.func,
  filesTypes: _proptypes.FilesPropType,
  error: _propTypes.default.string,
  buttonAriaLabel: _propTypes.default.string,
  errorButtonLabel: _propTypes.default.string,
  labelLink: _propTypes.default.string,
  hrefLink: _propTypes.default.string
} : {};
var _default = exports.default = InputFileDraggable;
//# sourceMappingURL=index.js.map