import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import { useState, useRef, memo, forwardRef, useMemo, useImperativeHandle, createElement, Suspense, lazy } from 'react';
import classnames from 'classnames';
import { removeBy, noop, isPresent, isNotEmpty } from '@bigbinary/neeto-cist';
import Button from '@bigbinary/neetoui/Button';
import Toastr from '@bigbinary/neetoui/Toastr';
import { mergeRight, isEmpty, assoc } from 'ramda';
import { useTranslation, Trans } from 'react-i18next';
import { F as File, d as directUploadsApi, a as FileIcon, u as useFileUploader, b as useDropFiles } from './chunk-zRPC4lVr.js';
import { n } from './chunk-C2dztUxs.js';
import useOnClickOutside from '@bigbinary/neeto-commons-frontend/react-utils/useOnClickOutside';
import { withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
import MenuVertical from '@bigbinary/neeto-icons/MenuVertical';
import Close from '@bigbinary/neeto-icons/Close';
import Check from '@bigbinary/neeto-icons/Check';
import Dropdown from '@bigbinary/neetoui/Dropdown';
import Input from '@bigbinary/neetoui/Input';
import Spinner from '@bigbinary/neetoui/Spinner';
import Tooltip from '@bigbinary/neetoui/Tooltip';
import Typography from '@bigbinary/neetoui/Typography';
import Alert from '@bigbinary/neetoui/Alert';
import { t } from 'i18next';
import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
import { D as DIRECT_UPLOAD_ENDPOINT } from './chunk-DNMH2cJJ.js';
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';

var css = ".ne-attachments{display:flex;flex-direction:column;gap:8px}.ne-attachments__items{display:flex;flex-wrap:wrap;gap:8px}.ne-attachments__preview{align-items:center;background-color:rgb(var(--neeto-ui-white));border:1px solid rgb(var(--neeto-ui-gray-200));border-radius:var(--neeto-ui-rounded-sm);display:flex;justify-content:space-between;padding-block:4px;padding-inline:8px 2px;width:256px}.ne-attachments__preview-wrapper{display:flex;gap:8px;width:88%}.ne-attachments__preview-wrapper__icon{height:auto;width:15px}.ne-attachments__preview-wrapper p{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:92%}.ne-attachments__preview-wrapper:hover{cursor:pointer}.ne-attachments__preview__progress{display:flex;gap:4px;justify-content:space-between;opacity:.5;width:76%}.ne-attachments__preview__progress p{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:85%}.ne-attachments__preview__progress p:nth-child(2){flex-shrink:0;width:-moz-fit-content;width:fit-content}.ne-attachments__preview__progress-icon{height:auto;width:15px}.ne-attachments__preview:hover{box-shadow:0 0 0 1px rgb(var(--neeto-ui-gray-400))}.ne-attachments input[type=file]{display:none}.ne-attachments-preview{display:flex;flex-direction:column;gap:8px}.ne-attachments-preview .neeto-ui-modal__close{inset-inline-end:16px!important;top:9px!important}.ne-attachments-preview__header{border-bottom:1px solid rgb(var(--neeto-ui-gray-200));display:flex;flex-direction:row;gap:8px;margin-bottom:8px;min-height:58px;padding:16px!important}.ne-attachments-preview__header__fileinfo{align-items:center;border-inline-end:1px solid rgb(var(--neeto-ui-gray-200));display:flex;gap:8px;padding-inline-end:6px}.ne-attachments-preview__body{align-items:center;display:flex;flex-grow:1;justify-content:center;min-height:10px;padding-bottom:8px!important;position:relative;width:100vw}.ne-attachments-preview__body-download{color:rgb(var(--neeto-ui-accent-800));cursor:pointer}.ne-attachments-preview__body-docviewer{height:100%;width:100%}.ne-attachments-preview__body img{max-height:100%;max-width:100%}.ne-attachments-preview__body video{height:100%;width:100%}.ne-attachments-preview__body iframe{height:100%;padding:0 8px;width:100%}.ne-attachments-preview__body-left,.ne-attachments-preview__body-right{position:absolute!important;top:50%;transform:translateY(-50%);z-index:1}.ne-attachments-preview__body-left{inset-inline-start:16px}.ne-attachments-preview__body-right{inset-inline-end:16px}.ne-attachments .attachment-button-loader{scale:.5;width:26px!important}.ne-attachments--integrated{background-color:rgb(var(--neeto-ui-white));border:1px solid rgb(var(--neeto-ui-gray-300));border-radius:0 0 var(--neeto-ui-rounded) var(--neeto-ui-rounded);border-top:none;padding-inline:6px}.ne-attachments__wrapper{position:relative}.ne-attachments__wrapper.is-dragging-over-files:after{align-items:center;background-color:rgba(var(--neeto-ui-gray-300),.5);border:3px dashed rgb(var(--neeto-ui-gray-500));border-radius:5px;color:rgb(var(--neeto-ui-gray-600));content:\"Drop the file here\";display:flex;font-size:1.2rem;font-weight:700;inset:7px;justify-content:center;pointer-events:none;position:absolute}";
n(css,{});

var DEFAULT_FILE_UPLOAD_CONFIG = {
  directUploadEndpoint: DIRECT_UPLOAD_ENDPOINT,
  restrictions: {
    maxFileSize: globalProps.endUserUploadedFileSizeLimitInMb * 1024 * 1024
  }
};
var ATTACHMENT_OPTIONS = {
  OPEN_IN_NEW_TAB: t("neetoEditor.common.openInNewTab"),
  DOWNLOAD: t("neetoEditor.common.download"),
  RENAME: t("neetoEditor.attachments.rename"),
  DELETE: t("neetoEditor.menu.delete")
};
var ATTACHMENTS_PREVIEW_DATA_CY = "ne-attachments-preview-content";

var buildFileUploadConfig = function buildFileUploadConfig(config) {
  return mergeRight(DEFAULT_FILE_UPLOAD_CONFIG, config);
};
var downloadFile = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(fileUrl, filename) {
    var response, blob, blobUrl, a;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _context.prev = 0;
          _context.next = 3;
          return fetch(fileUrl);
        case 3:
          response = _context.sent;
          _context.next = 6;
          return response.blob();
        case 6:
          blob = _context.sent;
          blobUrl = URL.createObjectURL(blob);
          a = document.createElement("a");
          a.href = blobUrl;
          a.setAttribute("download", filename);
          a.style.display = "none";
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
          URL.revokeObjectURL(blobUrl);
          _context.next = 21;
          break;
        case 18:
          _context.prev = 18;
          _context.t0 = _context["catch"](0);
          Toastr.error(_context.t0);
        case 21:
        case "end":
          return _context.stop();
      }
    }, _callee, null, [[0, 18]]);
  }));
  return function downloadFile(_x, _x2) {
    return _ref.apply(this, arguments);
  };
}();
var checkPreviewAvailability = function checkPreviewAvailability(contentType) {
  return contentType && (contentType.startsWith("video/") || contentType === "application/pdf" || contentType === "image/jpeg" || contentType === "image/gif" || contentType === "image/png" || contentType === "image/webp" || contentType === "text/plain" || contentType === "image/bmp" || contentType === "application/msword" || contentType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || contentType === "image/jpg" || contentType === "application/vnd.ms-powerpoint" || contentType === "application/vnd.openxmlformats-officedocument.presentationml.presentation" || contentType === "image/tiff" || contentType === "application/vnd.ms-excel" || contentType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
};

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Menu = Dropdown.Menu,
  MenuItem = Dropdown.MenuItem;
var Attachment = function Attachment(_ref) {
  var attachment = _ref.attachment,
    attachments = _ref.attachments,
    disabled = _ref.disabled,
    onChange = _ref.onChange,
    setSelectedAttachment = _ref.setSelectedAttachment,
    isLoading = _ref.isLoading,
    allowDelete = _ref.allowDelete,
    allowOpenInNewTab = _ref.allowOpenInNewTab;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isRenaming = _useState2[0],
    setIsRenaming = _useState2[1];
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    isUpdating = _useState4[0],
    setIsUpdating = _useState4[1];
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    isDeleteAlertOpen = _useState6[0],
    setIsDeleteAlertOpen = _useState6[1];
  var _useState7 = useState(false),
    _useState8 = _slicedToArray(_useState7, 2),
    isDeleting = _useState8[0],
    setIsDeleting = _useState8[1];
  var _useState9 = useState(""),
    _useState0 = _slicedToArray(_useState9, 2),
    newFilename = _useState0[0],
    setNewFilename = _useState0[1];
  var renameRef = useRef(null);
  useOnClickOutside(renameRef, function () {
    if (!isRenaming) return;
    setIsRenaming(false);
    setNewFilename("");
  });
  var handleDownload = function handleDownload() {
    return downloadFile(attachment.url, attachment.filename);
  };
  var handleOpenInNewTab = function handleOpenInNewTab() {
    return window.open(attachment.url, "_blank", "noopener,noreferrer");
  };
  var handleRename = /*#__PURE__*/function () {
    var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
      var _response$data, signedId, payload, response, filename;
      return _regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            setIsUpdating(true);
            signedId = attachment.signedId;
            payload = {
              blob: {
                filename: newFilename
              }
            };
            _context.next = 6;
            return directUploadsApi.update({
              signedId: signedId,
              payload: payload
            });
          case 6:
            response = _context.sent;
            filename = ((_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.blob) === null || _response$data === void 0 ? void 0 : _response$data.filename) || response.blob.filename;
            onChange(attachments.map(function (attachment) {
              return attachment.signedId === signedId ? assoc("filename", filename, attachment) : attachment;
            }));
            _context.next = 14;
            break;
          case 11:
            _context.prev = 11;
            _context.t0 = _context["catch"](0);
            Toastr.error(_context.t0);
          case 14:
            _context.prev = 14;
            setIsRenaming(false);
            setIsUpdating(false);
            setNewFilename("");
            return _context.finish(14);
          case 19:
          case "end":
            return _context.stop();
        }
      }, _callee, null, [[0, 11, 14, 19]]);
    }));
    return function handleRename() {
      return _ref2.apply(this, arguments);
    };
  }();
  var handleDelete = /*#__PURE__*/function () {
    var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
      var signedId;
      return _regeneratorRuntime.wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            if (allowDelete) {
              _context2.next = 2;
              break;
            }
            return _context2.abrupt("return");
          case 2:
            setIsDeleting(true);
            _context2.prev = 3;
            signedId = attachment.signedId;
            _context2.next = 7;
            return directUploadsApi.destroy(signedId);
          case 7:
            onChange(removeBy({
              signedId: signedId
            }, attachments));
            _context2.next = 13;
            break;
          case 10:
            _context2.prev = 10;
            _context2.t0 = _context2["catch"](3);
            Toastr.error(_context2.t0);
          case 13:
          case "end":
            return _context2.stop();
        }
      }, _callee2, null, [[3, 10]]);
    }));
    return function handleDelete() {
      return _ref3.apply(this, arguments);
    };
  }();
  var handlers = _objectSpread(_objectSpread({}, allowOpenInNewTab && _defineProperty({}, ATTACHMENT_OPTIONS.OPEN_IN_NEW_TAB, handleOpenInNewTab)), {}, _defineProperty(_defineProperty({}, ATTACHMENT_OPTIONS.DOWNLOAD, handleDownload), ATTACHMENT_OPTIONS.RENAME, handleRename), allowDelete && _defineProperty({}, ATTACHMENT_OPTIONS.DELETE, handleDelete));
  var onMenuItemClick = function onMenuItemClick(_ref6) {
    var key = _ref6.key,
      handler = _ref6.handler;
    if (key === ATTACHMENT_OPTIONS.RENAME) {
      setIsRenaming(true);
      setNewFilename(attachment.filename);
    } else if (key === ATTACHMENT_OPTIONS.DELETE) {
      setNewFilename(attachment.filename);
      setIsDeleteAlertOpen(true);
    } else {
      handler();
    }
  };
  var handleKeyDown = function handleKeyDown(_ref7) {
    var event = _ref7.event,
      key = _ref7.key;
    var handler = handlers[key];
    if (event.key === "Enter" && handler && !isEmpty(newFilename)) {
      event.stopPropagation();
      event.preventDefault();
      handler();
    }
    if (event.key === "Escape") {
      setIsRenaming(false);
      setNewFilename("");
    }
  };
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsx("div", {
      className: "ne-attachments__preview",
      "data-testid": "ne-attachments-wrapper",
      children: isRenaming ? /*#__PURE__*/jsx("div", {
        ref: renameRef,
        children: /*#__PURE__*/jsx(Tooltip, {
          content: newFilename,
          position: "top",
          children: /*#__PURE__*/jsx(Input, {
            autoFocus: true,
            "data-testid": "neeto-editor-preview-rename-input",
            size: "small",
            value: newFilename,
            error: isEmpty(newFilename) ? t("neetoEditor.attachments.nameEmpty") : "",
            suffix: /*#__PURE__*/jsxs("div", {
              className: "flex items-center justify-end",
              children: [/*#__PURE__*/jsx(Button, {
                "data-testid": "neeto-editor-preview-rename-submit-button",
                disabled: isEmpty(newFilename) || isUpdating,
                icon: Check,
                loading: isUpdating,
                size: "small",
                style: "text",
                onClick: handleRename
              }), /*#__PURE__*/jsx(Button, {
                "data-testid": "neeto-editor-preview-rename-cancel-button",
                disabled: isUpdating,
                icon: Close,
                size: "small",
                style: "text",
                onClick: function onClick() {
                  setIsRenaming(false);
                  setNewFilename("");
                }
              })]
            }),
            onChange: withEventTargetValue(setNewFilename),
            onKeyDown: function onKeyDown(event) {
              return handleKeyDown({
                event: event,
                key: ATTACHMENT_OPTIONS.RENAME
              });
            }
          })
        })
      }) : /*#__PURE__*/jsxs(Fragment, {
        children: [/*#__PURE__*/jsxs("div", {
          className: "ne-attachments__preview-wrapper",
          onClick: function onClick() {
            return setSelectedAttachment(attachment);
          },
          children: [/*#__PURE__*/jsx(File, {
            className: "ne-attachments__preview-wrapper__icon",
            fileName: attachment.filename
          }), /*#__PURE__*/jsx(Tooltip, {
            content: attachment.filename,
            position: "top",
            children: /*#__PURE__*/jsx(Typography, {
              style: "body2",
              children: attachment.filename
            })
          }), isLoading && /*#__PURE__*/jsx(Spinner, {
            className: "attachment-button-loader"
          })]
        }), /*#__PURE__*/jsx(Tooltip, {
          content: t("neetoEditor.attachments.actionsBlocked"),
          disabled: !disabled,
          position: "top",
          children: /*#__PURE__*/jsx(Dropdown, {
            disabled: disabled,
            buttonSize: "small",
            buttonStyle: "text",
            icon: MenuVertical,
            children: /*#__PURE__*/jsx(Menu, {
              children: Object.entries(handlers).map(function (_ref8) {
                var _ref9 = _slicedToArray(_ref8, 2),
                  label = _ref9[0],
                  handler = _ref9[1];
                return /*#__PURE__*/jsx(MenuItem.Button, {
                  "data-testid": "neeto-editor-preview-".concat(label.toLowerCase(), "-button"),
                  onClick: function onClick() {
                    return onMenuItemClick({
                      key: label,
                      handler: handler
                    });
                  },
                  children: label
                }, label);
              })
            })
          })
        })]
      })
    }), /*#__PURE__*/jsx(Alert, {
      isOpen: isDeleteAlertOpen,
      isSubmitting: isDeleting,
      submitButtonLabel: t("neetoEditor.menu.delete"),
      title: t("neetoEditor.attachments.deleteTitle"),
      message: /*#__PURE__*/jsx(Trans, {
        i18nKey: "neetoEditor.attachments.deleteConfirmation",
        values: {
          entity: newFilename
        }
      }),
      onClose: function onClose() {
        return setIsDeleteAlertOpen(false);
      },
      onSubmit: handleDelete
    })]
  });
};

var AttachmentProgress = function AttachmentProgress(_ref) {
  var _attachment$progress;
  var attachment = _ref.attachment,
    cancelUpload = _ref.cancelUpload;
  var progressPercentage = "".concat((_attachment$progress = attachment.progress) !== null && _attachment$progress !== void 0 ? _attachment$progress : 0, "%");
  var handleCancel = function handleCancel() {
    cancelUpload(attachment.id);
  };
  return /*#__PURE__*/jsxs("div", {
    className: "ne-attachments__preview",
    children: [/*#__PURE__*/jsx("div", {
      className: "ne-attachments__preview__progress-icon",
      children: /*#__PURE__*/jsx(FileIcon, {})
    }), /*#__PURE__*/jsxs("div", {
      className: "ne-attachments__preview__progress",
      children: [/*#__PURE__*/jsx(Typography, {
        style: "body2",
        children: attachment.filename
      }), /*#__PURE__*/jsx(Typography, {
        style: "body2",
        children: progressPercentage
      })]
    }), /*#__PURE__*/jsx(Button, {
      "data-testid": "neeto-editor-preview-upload-cancel-button",
      icon: Close,
      size: "small",
      style: "text",
      onClick: handleCancel
    })]
  });
};

var Preview = /*#__PURE__*/lazy(function () {
  return import('./chunk-BJhk4N3E.js');
});
var Attachments = function Attachments(_ref, ref) {
  var _fileUploadConfig$all;
  var _ref$attachments = _ref.attachments,
    attachments = _ref$attachments === void 0 ? [] : _ref$attachments,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    _ref$onChange = _ref.onChange,
    onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
    _ref$isIndependent = _ref.isIndependent,
    isIndependent = _ref$isIndependent === void 0 ? true : _ref$isIndependent,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    _ref$dragDropRef = _ref.dragDropRef,
    dragDropRef = _ref$dragDropRef === void 0 ? null : _ref$dragDropRef,
    _ref$config = _ref.config,
    config = _ref$config === void 0 ? {} : _ref$config,
    _ref$setIsUploading = _ref.setIsUploading,
    setIsUploading = _ref$setIsUploading === void 0 ? noop : _ref$setIsUploading,
    _ref$allowDelete = _ref.allowDelete,
    allowDelete = _ref$allowDelete === void 0 ? true : _ref$allowDelete,
    _ref$allowOpenInNewTa = _ref.allowOpenInNewTab,
    allowOpenInNewTab = _ref$allowOpenInNewTa === void 0 ? true : _ref$allowOpenInNewTa;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState({}),
    _useState2 = _slicedToArray(_useState, 2),
    selectedAttachment = _useState2[0],
    setSelectedAttachment = _useState2[1];
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    didFetchPreviewBundle = _useState4[0],
    setDidFetchPreviewBundle = _useState4[1];
  var attachmentInputRef = useRef(null);
  var fileUploadConfig = useMemo(function () {
    return buildFileUploadConfig(config);
  }, [config]);
  var _useFileUploader = useFileUploader({
      config: fileUploadConfig,
      setIsUploadingOnHost: setIsUploading,
      attachments: attachments
    }),
    addFiles = _useFileUploader.addFiles,
    uploadFiles = _useFileUploader.uploadFiles,
    queuedFiles = _useFileUploader.queuedFiles,
    cancelUpload = _useFileUploader.cancelUpload,
    isUploading = _useFileUploader.isUploading;
  var handleAddFile = /*#__PURE__*/function () {
    var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
      var uploadedFiles;
      return _regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            addFiles(event.target.files);
            _context.next = 3;
            return uploadFiles();
          case 3:
            uploadedFiles = _context.sent;
            isNotEmpty(uploadedFiles) && onChange([].concat(_toConsumableArray(attachments), _toConsumableArray(uploadedFiles)));
            attachmentInputRef.current.value = null;
          case 6:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
    return function handleAddFile(_x) {
      return _ref2.apply(this, arguments);
    };
  }();
  var handleUploadAttachments = function handleUploadAttachments() {
    return attachmentInputRef.current.click();
  };
  var handleFileInputClick = function handleFileInputClick(event) {
    if (!(!isEmpty(attachments) && fileUploadConfig.maxNumberOfFiles === 1)) {
      return;
    }
    event.preventDefault();
    Toastr.warning(t("neetoEditor.attachments.oneAttachmentAllowed"));
  };
  useImperativeHandle(ref, function () {
    return {
      handleUploadAttachments: handleUploadAttachments
    };
  }, []);
  var handleFilesDrop = /*#__PURE__*/function () {
    var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(files) {
      var uploadedFiles;
      return _regeneratorRuntime.wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            addFiles(files);
            _context2.next = 3;
            return uploadFiles();
          case 3:
            uploadedFiles = _context2.sent;
            isNotEmpty(uploadedFiles) && onChange([].concat(_toConsumableArray(attachments), _toConsumableArray(uploadedFiles)));
          case 5:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    }));
    return function handleFilesDrop(_x2) {
      return _ref3.apply(this, arguments);
    };
  }();
  useDropFiles({
    dropTargetRef: dragDropRef,
    attachments: attachments,
    onDrop: handleFilesDrop
  });
  return /*#__PURE__*/jsxs("div", {
    className: classnames("ne-attachments", _defineProperty({}, className, className)),
    children: [/*#__PURE__*/jsxs("div", {
      className: "ne-attachments__items",
      children: [attachments.map(function (attachment) {
        return /*#__PURE__*/createElement(Attachment, {
          allowDelete: allowDelete,
          allowOpenInNewTab: allowOpenInNewTab,
          attachment: attachment,
          attachments: attachments,
          disabled: disabled,
          onChange: onChange,
          setSelectedAttachment: setSelectedAttachment,
          key: attachment.signedId,
          isLoading: !didFetchPreviewBundle && selectedAttachment.url === attachment.url
        });
      }), queuedFiles.map(function (attachment) {
        return /*#__PURE__*/createElement(AttachmentProgress, {
          attachment: attachment,
          cancelUpload: cancelUpload,
          key: attachment.id
        });
      })]
    }), /*#__PURE__*/jsxs("div", {
      children: [isIndependent && /*#__PURE__*/jsx(Button, {
        "data-testid": "neeto-editor-attachments-upload-button",
        disabled: isUploading,
        label: t("neetoEditor.attachments.add"),
        loading: isUploading,
        size: "medium",
        style: "link",
        onClick: handleUploadAttachments
      }), /*#__PURE__*/jsx("input", {
        accept: (_fileUploadConfig$all = fileUploadConfig.allowedFileTypes) === null || _fileUploadConfig$all === void 0 ? void 0 : _fileUploadConfig$all.join(","),
        multiple: fileUploadConfig.maxNumberOfFiles !== 1,
        ref: attachmentInputRef,
        type: "file",
        onChange: handleAddFile,
        onClick: handleFileInputClick
      }), /*#__PURE__*/jsx(Suspense, {
        fallback: /*#__PURE__*/jsx("span", {}),
        children: isPresent(selectedAttachment) && /*#__PURE__*/jsx(Preview, {
          attachments: attachments,
          selectedAttachment: selectedAttachment,
          setDidFetchPreviewBundle: setDidFetchPreviewBundle,
          setSelectedAttachment: setSelectedAttachment,
          onClose: function onClose() {
            return setSelectedAttachment({});
          }
        })
      })]
    })]
  });
};
Attachments.displayName = "NeetoEditorAttachments";
var Attachments$1 = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(Attachments));

export { Attachments$1 as A, ATTACHMENTS_PREVIEW_DATA_CY as a, checkPreviewAvailability as c, downloadFile as d };
//# sourceMappingURL=chunk-CAGz17QN.js.map
