UNPKG

@trap_stevo/legendarybuilderproreact-ui

Version:

The legendary UI & utility API that makes your application a legendary application. ~ Created by Steven Compton

1,003 lines 61.1 kB
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } import _regeneratorRuntime from "@babel/runtime/regenerator"; 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), !0).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; } import React, { useState, useEffect, createContext, useContext } from "react"; import { Fade } from "react-awesome-reveal"; import { useDropzone } from "react-dropzone"; import { ConvertFileSizeToDisplay, ConvertFileSizeToBytes, ConvertNumberToMoneyFormat, ConvertSecondsToETATime } from "../HUDManagers/HUDUniversalHUDUtilityManager.js"; import { useTimeout } from "../HUDManagers/HUDUniversalHUDEventEffectsManager.js"; import HUDAnimatedBackground from "./HUDAnimatedBackground.js"; import { useHUDDropZone } from "./HUDDropZoneProvider.js"; import HUDIcon from "./HUDIcon.js"; var DropZoneContext = /*#__PURE__*/createContext(); var defaultStyles = { container: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", backdropFilter: "blur(10px)", borderRadius: "10px", boxShadow: "0 4px 6px rgba(0,0,0,0.1)", background: "rgba(255, 255, 255, 0.15)", maxWidth: "769px", width: "calc(100%)", padding: "20px", margin: "0 auto" }, dropzone: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", overflowY: "hidden", overflowX: "hidden", cursor: "pointer", outline: "none", transition: "border 0.24s ease-in-out", borderColor: "#00BFFF", borderStyle: "dashed", borderWidth: "2px", borderRadius: "10px", backgroundColor: "rgba(255, 255, 255, 0.1)", color: "#00BFFF", height: "300px", width: "calc(100%)" }, dropzoneBlur: { position: "absolute", display: "flex", backdropFilter: "blur(5px)", height: "100%", width: "100%", zIndex: 999 }, progressContainer: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", width: "80%", padding: "20px", backgroundColor: "rgba(255, 255, 255, 0.9)", borderRadius: "10px", boxShadow: "0 4px 6px rgba(0,0,0,0.1)", zIndex: 1000, marginBottom: "10px" }, progressBar: { overflow: "hidden", transition: "width 0.1069s ease-out", borderRadius: "5px", backgroundColor: "#e0e0e0", height: "10px", width: "100%", marginBottom: "10px", marginTop: "10px" }, progress: { transition: "width 0.1069s ease-out", borderRadius: "5px", backgroundColor: "#00BFFF", height: "100%" }, condensedTab: { position: "absolute", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", borderRadius: "50%", boxShadow: "0 4px 6px rgba(0, 0, 0, 0.169)", backgroundColor: "#00BFFF", color: "white", height: "40px", width: "40px", zIndex: 1569, bottom: "10px", right: "10px" }, icon: { fontSize: "24px" }, text: { textAlign: "center", marginTop: "10px", fontSize: "18px", color: "#e0f7fa" }, errorContainer: { position: "fixed", bottom: "20px", right: "20px", zIndex: 2000, display: "flex", flexDirection: "column", gap: "10px", maxWidth: "300px" }, errorBadge: { display: "flex", alignItems: "center", justifyContent: "space-between", backgroundColor: "#FF4136", color: "#FFFFFF", borderRadius: "10px", padding: "10px 15px", boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)", marginBottom: "10px", fontSize: "14px" }, fileListContainer: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", overflowY: "auto", width: "calc(100%)", zIndex: 1269, padding: "10px", marginRight: "20px", marginLeft: "50px" }, fileItem: { display: "flex", flexDirection: "row", justifyContent: "space-between", alignItems: "center", transition: "all 0.369s ease", borderRadius: "4px", boxShadow: "0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.269)", background: "rgba(255, 255, 255, 0.569)", width: "calc(92.69%)", zIndex: 869, padding: "10px", marginBottom: "10px" }, fileDetails: { display: "flex", flexDirection: "column", color: "#e0f7fa" }, fileName: { fontWeight: "bold", fontSize: "16px" }, fileSize: { marginTop: "5px", fontSize: "14px" }, fileDate: { marginTop: "5px", fontSize: "14px" }, fileCreationDate: { marginTop: "5px", fontSize: "14px" }, fileActions: { display: "flex", flexDirection: "row", alignItems: "center" }, fileActionButton: { cursor: "pointer", fontSize: "16px", border: "none", borderRadius: "4px", backgroundColor: "transparent", color: "#00BFFF", zIndex: 1569, padding: "5px 10px", marginLeft: "10px" }, foregroundAnimationContainer: { position: "absolute", display: "flex", alignItems: "center", justifyContent: "center", pointerEvents: "none", height: "auto", width: "auto", left: "calc(50%)", top: "calc(105.69%)" }, foregroundAnimation: { position: "absolute", background: "radial-gradient(circle, rgba(0, 187.69, 255, 0.3) 30%, rgba(0, 187.69, 255, 0) 60%)", borderRadius: "50%", transform: "translate(-50%, -50%)", animation: "signalRipple 4.69s infinite", opacity: 0, transition: "opacity 0.369s ease-in-out", pointerEvents: "none", height: "200px", width: "200px", left: "50%", top: "50%" } }; var mimeTypeDisplays = { "video/mp4": "MP4", "video/x-msvideo": "AVI", "video/x-matroska": "MKV", "video/quicktime": "MOV", "video/x-m4v": "M4V", "video/x-flv": "FLV", "video/webm": "WebM", "video/ogg": "OGG", "image/jpeg": "JPEG", "image/png": "PNG", "image/gif": "GIF", "image/webp": "WebP", "image/svg+xml": "SVG", "image/bmp": "BMP", "image/tiff": "TIFF", "audio/mpeg": "MP3", "audio/ogg": "OGG Audio", "audio/wav": "WAV", "audio/flac": "FLAC", "audio/aac": "AAC", "audio/x-aiff": "AIFF", "audio/webm": "WebM Audio", "application/pdf": "PDF", "application/msword": "DOC", "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "DOCX", "application/vnd.ms-excel": "XLS", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "XLSX", "application/vnd.ms-powerpoint": "PPT", "application/vnd.openxmlformats-officedocument.presentationml.presentation": "PPTX", "text/plain": "Text File", "text/csv": "CSV", "application/json": "JSON", "application/zip": "ZIP", "application/x-rar-compressed": "RAR", "application/x-7z-compressed": "7Z", "application/x-tar": "TAR", "application/octet-stream": "Binary File", "application/x-sh": "Shell Script", "application/javascript": "JavaScript File", "application/x-python-code": "Python File", "application/java-archive": "Java Archive (JAR)", "application/x-msdownload": "Executable (EXE)", "application/x-dosexec": "DOS Executable" }; var getMimeTypeDisplay = function getMimeTypeDisplay(mimeType) { return mimeTypeDisplays[mimeType] || mimeType; }; var AcceptedTypesBadgeList = function AcceptedTypesBadgeList(_ref) { var _ref$badgeListContain = _ref.badgeListContainerConfigurationSettings, badgeListContainerConfigurationSettings = _ref$badgeListContain === void 0 ? {} : _ref$badgeListContain, _ref$badgeConfigurati = _ref.badgeConfigurationSettings, badgeConfigurationSettings = _ref$badgeConfigurati === void 0 ? {} : _ref$badgeConfigurati, _ref$acceptedFileType = _ref.acceptedFileTypes, acceptedFileTypes = _ref$acceptedFileType === void 0 ? [] : _ref$acceptedFileType; var defaultContainerStyles = { position: "absolute", display: "flex", flexWrap: "wrap", transition: "all 0.369s ease-out", scale: "0.869", gap: "5.69px", zIndex: 1000, bottom: "10px", right: "0px" }; var defaultBadgeStyles = { display: "inline-flex", alignItems: "center", justifyContent: "center", padding: "5px 10px", backgroundColor: "#00BFFF", color: "#FFFFFF", fontSize: "12px", borderRadius: "10px", boxShadow: "0 2px 4px rgba(0, 0, 0, 0.2)" }; return /*#__PURE__*/React.createElement("div", { style: _objectSpread(_objectSpread({}, defaultContainerStyles), badgeListContainerConfigurationSettings) }, acceptedFileTypes ? /*#__PURE__*/React.createElement(React.Fragment, null, acceptedFileTypes.map(function (type, index) { return /*#__PURE__*/React.createElement("div", { key: index, style: _objectSpread(_objectSpread({}, defaultBadgeStyles), badgeConfigurationSettings) }, getMimeTypeDisplay(type)); })) : /*#__PURE__*/React.createElement("div", { style: _objectSpread(_objectSpread({}, defaultBadgeStyles), badgeConfigurationSettings) }, "Any")); }; var FloatingErrorDisplay = function FloatingErrorDisplay(_ref2) { var _ref2$errorContainerC = _ref2.errorContainerConfigurationSettings, errorContainerConfigurationSettings = _ref2$errorContainerC === void 0 ? defaultStyles.errorContainer : _ref2$errorContainerC, _ref2$errorBadgeConfi = _ref2.errorBadgeConfigurationSettings, errorBadgeConfigurationSettings = _ref2$errorBadgeConfi === void 0 ? defaultStyles.errorBadge : _ref2$errorBadgeConfi, _ref2$errorDismissIco = _ref2.errorDismissIconConfigurationSettings, errorDismissIconConfigurationSettings = _ref2$errorDismissIco === void 0 ? {} : _ref2$errorDismissIco, _ref2$errorDismissIco2 = _ref2.errorDismissIconConfigurations, errorDismissIconConfigurations = _ref2$errorDismissIco2 === void 0 ? {} : _ref2$errorDismissIco2, _ref2$floatDirection = _ref2.floatDirection, floatDirection = _ref2$floatDirection === void 0 ? "right" : _ref2$floatDirection, _ref2$floatDuration = _ref2.floatDuration, floatDuration = _ref2$floatDuration === void 0 ? 269 : _ref2$floatDuration, errors = _ref2.errors, onDismiss = _ref2.onDismiss; return /*#__PURE__*/React.createElement("div", { style: errorContainerConfigurationSettings }, errors.map(function (error, index) { return /*#__PURE__*/React.createElement(Fade, { key: index, direction: floatDirection, duration: floatDuration }, /*#__PURE__*/React.createElement("div", { style: _objectSpread({ gap: "0.69rem" }, errorBadgeConfigurationSettings) }, /*#__PURE__*/React.createElement("span", null, error.message), /*#__PURE__*/React.createElement(HUDIcon, _extends({ iconConfigurationSettings: _objectSpread({ cursor: "pointer", border: "none", background: "transparent" }, errorDismissIconConfigurationSettings), onClick: function onClick() { return onDismiss(index); }, color: "#FFFFFF", name: "close" }, errorDismissIconConfigurations)))); })); }; function HUDDropZone(hudDropZoneConfigurationSettings) { var _hudDropZoneConfigura = hudDropZoneConfigurationSettings.acceptedFileTypesListContainerConfigurationSettings, acceptedFileTypesListContainerConfigurationSettings = _hudDropZoneConfigura === void 0 ? {} : _hudDropZoneConfigura, _hudDropZoneConfigura2 = hudDropZoneConfigurationSettings.foregroundAnimationContainerConfigurationSettings, foregroundAnimationContainerConfigurationSettings = _hudDropZoneConfigura2 === void 0 ? {} : _hudDropZoneConfigura2, _hudDropZoneConfigura3 = hudDropZoneConfigurationSettings.acceptedFileTypeBadgeConfigurationSettings, acceptedFileTypeBadgeConfigurationSettings = _hudDropZoneConfigura3 === void 0 ? {} : _hudDropZoneConfigura3, _hudDropZoneConfigura4 = hudDropZoneConfigurationSettings.errorBadgeDismissIconConfigurationSettings, errorBadgeDismissIconConfigurationSettings = _hudDropZoneConfigura4 === void 0 ? {} : _hudDropZoneConfigura4, _hudDropZoneConfigura5 = hudDropZoneConfigurationSettings.foregroundAnimationConfigurationSettings, foregroundAnimationConfigurationSettings = _hudDropZoneConfigura5 === void 0 ? {} : _hudDropZoneConfigura5, _hudDropZoneConfigura6 = hudDropZoneConfigurationSettings.descriptionViewIconConfigurationSettings, descriptionViewIconConfigurationSettings = _hudDropZoneConfigura6 === void 0 ? {} : _hudDropZoneConfigura6, _hudDropZoneConfigura7 = hudDropZoneConfigurationSettings.descriptionViewTextConfigurationSettings, descriptionViewTextConfigurationSettings = _hudDropZoneConfigura7 === void 0 ? {} : _hudDropZoneConfigura7, _hudDropZoneConfigura8 = hudDropZoneConfigurationSettings.progressContainerConfigurationSettings, progressContainerConfigurationSettings = _hudDropZoneConfigura8 === void 0 ? {} : _hudDropZoneConfigura8, _hudDropZoneConfigura9 = hudDropZoneConfigurationSettings.fileListContainerConfigurationSettings, fileListContainerConfigurationSettings = _hudDropZoneConfigura9 === void 0 ? {} : _hudDropZoneConfigura9, _hudDropZoneConfigura10 = hudDropZoneConfigurationSettings.fileCreationDateConfigurationSettings, fileCreationDateConfigurationSettings = _hudDropZoneConfigura10 === void 0 ? {} : _hudDropZoneConfigura10, _hudDropZoneConfigura11 = hudDropZoneConfigurationSettings.fileActionButtonConfigurationSettings, fileActionButtonConfigurationSettings = _hudDropZoneConfigura11 === void 0 ? {} : _hudDropZoneConfigura11, _hudDropZoneConfigura12 = hudDropZoneConfigurationSettings.errorContainerConfigurationSettings, errorContainerConfigurationSettings = _hudDropZoneConfigura12 === void 0 ? {} : _hudDropZoneConfigura12, _hudDropZoneConfigura13 = hudDropZoneConfigurationSettings.fileItemHoverConfigurationSettings, fileItemHoverConfigurationSettings = _hudDropZoneConfigura13 === void 0 ? {} : _hudDropZoneConfigura13, _hudDropZoneConfigura14 = hudDropZoneConfigurationSettings.dropzoneBlurConfigurationSettings, dropzoneBlurConfigurationSettings = _hudDropZoneConfigura14 === void 0 ? {} : _hudDropZoneConfigura14, _hudDropZoneConfigura15 = hudDropZoneConfigurationSettings.condensedTabConfigurationSettings, condensedTabConfigurationSettings = _hudDropZoneConfigura15 === void 0 ? {} : _hudDropZoneConfigura15, _hudDropZoneConfigura16 = hudDropZoneConfigurationSettings.progressBarConfigurationSettings, progressBarConfigurationSettings = _hudDropZoneConfigura16 === void 0 ? {} : _hudDropZoneConfigura16, _hudDropZoneConfigura17 = hudDropZoneConfigurationSettings.fileActionsConfigurationSettings, fileActionsConfigurationSettings = _hudDropZoneConfigura17 === void 0 ? {} : _hudDropZoneConfigura17, _hudDropZoneConfigura18 = hudDropZoneConfigurationSettings.fileDetailsConfigurationSettings, fileDetailsConfigurationSettings = _hudDropZoneConfigura18 === void 0 ? {} : _hudDropZoneConfigura18, _hudDropZoneConfigura19 = hudDropZoneConfigurationSettings.errorBadgeConfigurationSettings, errorBadgeConfigurationSettings = _hudDropZoneConfigura19 === void 0 ? {} : _hudDropZoneConfigura19, _hudDropZoneConfigura20 = hudDropZoneConfigurationSettings.containerConfigurationSettings, containerConfigurationSettings = _hudDropZoneConfigura20 === void 0 ? {} : _hudDropZoneConfigura20, _hudDropZoneConfigura21 = hudDropZoneConfigurationSettings.fileItemConfigurationSettings, fileItemConfigurationSettings = _hudDropZoneConfigura21 === void 0 ? {} : _hudDropZoneConfigura21, _hudDropZoneConfigura22 = hudDropZoneConfigurationSettings.fileNameConfigurationSettings, fileNameConfigurationSettings = _hudDropZoneConfigura22 === void 0 ? {} : _hudDropZoneConfigura22, _hudDropZoneConfigura23 = hudDropZoneConfigurationSettings.fileSizeConfigurationSettings, fileSizeConfigurationSettings = _hudDropZoneConfigura23 === void 0 ? {} : _hudDropZoneConfigura23, _hudDropZoneConfigura24 = hudDropZoneConfigurationSettings.fileDateConfigurationSettings, fileDateConfigurationSettings = _hudDropZoneConfigura24 === void 0 ? {} : _hudDropZoneConfigura24, _hudDropZoneConfigura25 = hudDropZoneConfigurationSettings.dropzoneConfigurationSettings, dropzoneConfigurationSettings = _hudDropZoneConfigura25 === void 0 ? {} : _hudDropZoneConfigura25, _hudDropZoneConfigura26 = hudDropZoneConfigurationSettings.progressConfigurationSettings, progressConfigurationSettings = _hudDropZoneConfigura26 === void 0 ? {} : _hudDropZoneConfigura26, _hudDropZoneConfigura27 = hudDropZoneConfigurationSettings.dropzoneDescriptionViewIconConfigurations, dropzoneDescriptionViewIconConfigurations = _hudDropZoneConfigura27 === void 0 ? {} : _hudDropZoneConfigura27, _hudDropZoneConfigura28 = hudDropZoneConfigurationSettings.dropzoneDescriptionViewTextConfigurations, dropzoneDescriptionViewTextConfigurations = _hudDropZoneConfigura28 === void 0 ? {} : _hudDropZoneConfigura28, _hudDropZoneConfigura29 = hudDropZoneConfigurationSettings.dropzoneForegroundContainerConfigurations, dropzoneForegroundContainerConfigurations = _hudDropZoneConfigura29 === void 0 ? {} : _hudDropZoneConfigura29, _hudDropZoneConfigura30 = hudDropZoneConfigurationSettings.dropzoneAnimatedBackgroundConfigurations, dropzoneAnimatedBackgroundConfigurations = _hudDropZoneConfigura30 === void 0 ? {} : _hudDropZoneConfigura30, _hudDropZoneConfigura31 = hudDropZoneConfigurationSettings.acceptedFileTypesBadgeListConfigurations, acceptedFileTypesBadgeListConfigurations = _hudDropZoneConfigura31 === void 0 ? {} : _hudDropZoneConfigura31, _hudDropZoneConfigura32 = hudDropZoneConfigurationSettings.droppedFileDeleteButtonConfigurations, droppedFileDeleteButtonConfigurations = _hudDropZoneConfigura32 === void 0 ? {} : _hudDropZoneConfigura32, _hudDropZoneConfigura33 = hudDropZoneConfigurationSettings.droppedFileSwapButtonConfigurations, droppedFileSwapButtonConfigurations = _hudDropZoneConfigura33 === void 0 ? {} : _hudDropZoneConfigura33, _hudDropZoneConfigura34 = hudDropZoneConfigurationSettings.errorBadgeDismissIconConfigurations, errorBadgeDismissIconConfigurations = _hudDropZoneConfigura34 === void 0 ? {} : _hudDropZoneConfigura34, _hudDropZoneConfigura35 = hudDropZoneConfigurationSettings.dropzoneContainerConfigurations, dropzoneContainerConfigurations = _hudDropZoneConfigura35 === void 0 ? {} : _hudDropZoneConfigura35, _hudDropZoneConfigura36 = hudDropZoneConfigurationSettings.dropzoneAnimatedBackgroundHoverContent, dropzoneAnimatedBackgroundHoverContent = _hudDropZoneConfigura36 === void 0 ? [/*#__PURE__*/React.createElement(HUDIcon, { name: "fa-file", color: "rgba(177.69, 227, 237, 0.869)" }), /*#__PURE__*/React.createElement(HUDIcon, { name: "fa-folder", color: "rgba(177.69, 227, 237, 0.869)" })] : _hudDropZoneConfigura36, _hudDropZoneConfigura37 = hudDropZoneConfigurationSettings.dropzoneAnimatedBackgroundContent, dropzoneAnimatedBackgroundContent = _hudDropZoneConfigura37 === void 0 ? [] : _hudDropZoneConfigura37, _hudDropZoneConfigura38 = hudDropZoneConfigurationSettings.dropzoneDescriptionViewContent, dropzoneDescriptionViewContent = _hudDropZoneConfigura38 === void 0 ? null : _hudDropZoneConfigura38, _hudDropZoneConfigura39 = hudDropZoneConfigurationSettings.droppedFileItemActionContent, droppedFileItemActionContent = _hudDropZoneConfigura39 === void 0 ? null : _hudDropZoneConfigura39, _hudDropZoneConfigura40 = hudDropZoneConfigurationSettings.droppedFileItemCenterContent, droppedFileItemCenterContent = _hudDropZoneConfigura40 === void 0 ? null : _hudDropZoneConfigura40, _hudDropZoneConfigura41 = hudDropZoneConfigurationSettings.droppedFileItemContent, droppedFileItemContent = _hudDropZoneConfigura41 === void 0 ? null : _hudDropZoneConfigura41, _hudDropZoneConfigura42 = hudDropZoneConfigurationSettings.upperDropzoneContent, upperDropzoneContent = _hudDropZoneConfigura42 === void 0 ? null : _hudDropZoneConfigura42, _hudDropZoneConfigura43 = hudDropZoneConfigurationSettings.lowerDropzoneContent, lowerDropzoneContent = _hudDropZoneConfigura43 === void 0 ? null : _hudDropZoneConfigura43, _hudDropZoneConfigura44 = hudDropZoneConfigurationSettings.uploadProgressRenderer, uploadProgressRenderer = _hudDropZoneConfigura44 === void 0 ? null : _hudDropZoneConfigura44, _hudDropZoneConfigura45 = hudDropZoneConfigurationSettings.droppedFilesRenderer, droppedFilesRenderer = _hudDropZoneConfigura45 === void 0 ? null : _hudDropZoneConfigura45, _hudDropZoneConfigura46 = hudDropZoneConfigurationSettings.errorNotification, errorNotification = _hudDropZoneConfigura46 === void 0 ? null : _hudDropZoneConfigura46, _hudDropZoneConfigura47 = hudDropZoneConfigurationSettings.acceptedFileTypes, acceptedFileTypes = _hudDropZoneConfigura47 === void 0 ? ["image/jpeg", "image/png", "application/pdf", "text/plain", "video/mp4"] : _hudDropZoneConfigura47, _hudDropZoneConfigura48 = hudDropZoneConfigurationSettings.dropzoneDescription, dropzoneDescription = _hudDropZoneConfigura48 === void 0 ? "Drag 'n' drop some files here, or click to select files" : _hudDropZoneConfigura48, _hudDropZoneConfigura49 = hudDropZoneConfigurationSettings.switchToAnimatedBackgroundHoverContentOnHover, switchToAnimatedBackgroundHoverContentOnHover = _hudDropZoneConfigura49 === void 0 ? true : _hudDropZoneConfigura49, _hudDropZoneConfigura50 = hudDropZoneConfigurationSettings.showInternalDropzoneDescriptionView, showInternalDropzoneDescriptionView = _hudDropZoneConfigura50 === void 0 ? true : _hudDropZoneConfigura50, _hudDropZoneConfigura51 = hudDropZoneConfigurationSettings.showDropzoneBackgroundAnimation, showDropzoneBackgroundAnimation = _hudDropZoneConfigura51 === void 0 ? true : _hudDropZoneConfigura51, _hudDropZoneConfigura52 = hudDropZoneConfigurationSettings.showDropzoneForegroundAnimation, showDropzoneForegroundAnimation = _hudDropZoneConfigura52 === void 0 ? true : _hudDropZoneConfigura52, _hudDropZoneConfigura53 = hudDropZoneConfigurationSettings.showUploadOverlayOnUpload, showUploadOverlayOnUpload = _hudDropZoneConfigura53 === void 0 ? true : _hudDropZoneConfigura53, _hudDropZoneConfigura54 = hudDropZoneConfigurationSettings.showAcceptedFileTypes, showAcceptedFileTypes = _hudDropZoneConfigura54 === void 0 ? true : _hudDropZoneConfigura54, _hudDropZoneConfigura55 = hudDropZoneConfigurationSettings.dropzoneForegroundAnimation, dropzoneForegroundAnimation = _hudDropZoneConfigura55 === void 0 ? "signalRipple" : _hudDropZoneConfigura55, _hudDropZoneConfigura56 = hudDropZoneConfigurationSettings.errorBadgeFloatDirection, errorBadgeFloatDirection = _hudDropZoneConfigura56 === void 0 ? "right" : _hudDropZoneConfigura56, _hudDropZoneConfigura57 = hudDropZoneConfigurationSettings.errorBadgeFloatDuration, errorBadgeFloatDuration = _hudDropZoneConfigura57 === void 0 ? 269 : _hudDropZoneConfigura57, _hudDropZoneConfigura58 = hudDropZoneConfigurationSettings.includeFileData, includeFileData = _hudDropZoneConfigura58 === void 0 ? true : _hudDropZoneConfigura58, _hudDropZoneConfigura59 = hudDropZoneConfigurationSettings.maxBase64FileSize, maxBase64FileSize = _hudDropZoneConfigura59 === void 0 ? "5GB" : _hudDropZoneConfigura59, _hudDropZoneConfigura60 = hudDropZoneConfigurationSettings.maxFiles, maxFiles = _hudDropZoneConfigura60 === void 0 ? 1 : _hudDropZoneConfigura60, _hudDropZoneConfigura61 = hudDropZoneConfigurationSettings.maxSize, maxSize = _hudDropZoneConfigura61 === void 0 ? "5GB" : _hudDropZoneConfigura61, _hudDropZoneConfigura62 = hudDropZoneConfigurationSettings.dropzoneFileRestrictions, dropzoneFileRestrictions = _hudDropZoneConfigura62 === void 0 ? [] : _hudDropZoneConfigura62, _hudDropZoneConfigura63 = hudDropZoneConfigurationSettings.fileBlackList, fileBlackList = _hudDropZoneConfigura63 === void 0 ? [] : _hudDropZoneConfigura63, _hudDropZoneConfigura64 = hudDropZoneConfigurationSettings.defaultErrorDisplayTime, defaultErrorDisplayTime = _hudDropZoneConfigura64 === void 0 ? 5000 : _hudDropZoneConfigura64, _hudDropZoneConfigura65 = hudDropZoneConfigurationSettings.onDroppedFileHover, onDroppedFileHover = _hudDropZoneConfigura65 === void 0 ? null : _hudDropZoneConfigura65, _hudDropZoneConfigura66 = hudDropZoneConfigurationSettings.onFileRestriction, onFileRestriction = _hudDropZoneConfigura66 === void 0 ? null : _hudDropZoneConfigura66, _hudDropZoneConfigura67 = hudDropZoneConfigurationSettings.onFileUpload, onFileUpload = _hudDropZoneConfigura67 === void 0 ? function () {} : _hudDropZoneConfigura67, _hudDropZoneConfigura68 = hudDropZoneConfigurationSettings.uploadIcon, uploadIcon = _hudDropZoneConfigura68 === void 0 ? "📁" : _hudDropZoneConfigura68; var _useHUDDropZone = useHUDDropZone(), files = _useHUDDropZone.files, addFiles = _useHUDDropZone.addFiles, removeFile = _useHUDDropZone.removeFile, replaceFile = _useHUDDropZone.replaceFile; var _useTimeout = useTimeout(), schedule = _useTimeout.schedule; var _useState = useState([]), _useState2 = _slicedToArray(_useState, 2), fileUnauthorizations = _useState2[0], setFileUnauthorizations = _useState2[1]; var _useState3 = useState(null), _useState4 = _slicedToArray(_useState3, 2), droppedFileHovered = _useState4[0], setDroppedFileHovered = _useState4[1]; var _useState5 = useState([]), _useState6 = _slicedToArray(_useState5, 2), uploadProgress = _useState6[0], setUploadProgress = _useState6[1]; var _useState7 = useState(false), _useState8 = _slicedToArray(_useState7, 2), uploading = _useState8[0], setUploading = _useState8[1]; var _useState9 = useState(false), _useState10 = _slicedToArray(_useState9, 2), hovering = _useState10[0], setHovering = _useState10[1]; var _useState11 = useState(null), _useState12 = _slicedToArray(_useState11, 2), error = _useState12[0], setError = _useState12[1]; var mergedStyles = { container: _objectSpread(_objectSpread({}, defaultStyles.container), containerConfigurationSettings), dropzone: _objectSpread(_objectSpread({}, defaultStyles.dropzone), dropzoneConfigurationSettings), dropzoneBlur: _objectSpread(_objectSpread({}, defaultStyles.dropzoneBlur), dropzoneBlurConfigurationSettings), progressContainer: _objectSpread(_objectSpread({}, defaultStyles.progressContainer), progressContainerConfigurationSettings), progressBar: _objectSpread(_objectSpread({}, defaultStyles.progressBar), progressBarConfigurationSettings), progress: _objectSpread(_objectSpread({}, defaultStyles.progress), progressConfigurationSettings), condensedTab: _objectSpread(_objectSpread({}, defaultStyles.condensedTab), condensedTabConfigurationSettings), icon: _objectSpread(_objectSpread({}, defaultStyles.icon), descriptionViewIconConfigurationSettings), text: _objectSpread(_objectSpread({}, defaultStyles.text), descriptionViewTextConfigurationSettings), errorContainer: _objectSpread(_objectSpread({}, defaultStyles.errorContainer), errorContainerConfigurationSettings), errorBadge: _objectSpread(_objectSpread({}, defaultStyles.errorBadge), errorBadgeConfigurationSettings), fileListContainer: _objectSpread(_objectSpread({}, defaultStyles.fileListContainer), fileListContainerConfigurationSettings), fileItem: _objectSpread(_objectSpread({}, defaultStyles.fileItem), fileItemConfigurationSettings), fileDetails: _objectSpread(_objectSpread({}, defaultStyles.fileDetails), fileDetailsConfigurationSettings), fileName: _objectSpread(_objectSpread({}, defaultStyles.fileName), fileNameConfigurationSettings), fileSize: _objectSpread(_objectSpread({}, defaultStyles.fileSize), fileSizeConfigurationSettings), fileDate: _objectSpread(_objectSpread({}, defaultStyles.fileDate), fileDateConfigurationSettings), fileCreationDate: _objectSpread(_objectSpread({}, defaultStyles.fileCreationDate), fileCreationDateConfigurationSettings), fileActions: _objectSpread(_objectSpread({}, defaultStyles.fileActions), fileActionsConfigurationSettings), fileActionButton: _objectSpread(_objectSpread({}, defaultStyles.fileActionButton), fileActionButtonConfigurationSettings), foregroundAnimationContainer: _objectSpread(_objectSpread({}, defaultStyles.foregroundAnimationContainer), foregroundAnimationContainerConfigurationSettings), foregroundAnimation: _objectSpread(_objectSpread(_objectSpread({}, defaultStyles.foregroundAnimation), hovering ? { opacity: 1 } : { opacity: 0 }), foregroundAnimationConfigurationSettings) }; var renderUploadProgress = function renderUploadProgress() { if (uploadProgressRenderer) { return uploadProgressRenderer(uploadProgress, handleRemoveFile); } return uploadProgress.map(function (progress, index) { return /*#__PURE__*/React.createElement("div", { key: index, style: mergedStyles.progressContainer }, /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileName }, progress.name), /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileSize }, ConvertFileSizeToDisplay(progress.size, 2)), /*#__PURE__*/React.createElement("div", { style: mergedStyles.progressBar }, /*#__PURE__*/React.createElement("div", { style: _objectSpread(_objectSpread({}, mergedStyles.progress), {}, { width: "".concat(progress.progress, "%") }) })), /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileSize }, progress.progress.toFixed(2), "%"), /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileSize }, "Estimated Time Remaining: ", progress.eta !== null && progress.eta !== undefined ? ConvertSecondsToETATime(progress.eta) : "Calculating...")); }); }; var renderDroppedFiles = function renderDroppedFiles() { if (droppedFilesRenderer) { return droppedFilesRenderer(files, handleRemoveFile, handleReplaceFile); } return files.map(function (file, index) { return /*#__PURE__*/React.createElement("div", { key: index, style: _objectSpread(_objectSpread({}, mergedStyles.fileItem), droppedFileHovered === index ? fileItemHoverConfigurationSettings : {}), onMouseLeave: function onMouseLeave() { setDroppedFileHovered(null); if (onDroppedFileHover) { onDroppedFileHover(false, file, index); } }, onMouseEnter: function onMouseEnter() { setDroppedFileHovered(index); if (onDroppedFileHover) { onDroppedFileHover(true, file, index); } } }, droppedFileItemContent, /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileDetails }, /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileName }, file.name), /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileSize }, ConvertFileSizeToDisplay(file.size, 2)), /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileDate }, "Uploaded: ", file.dateUploaded, " ", file.uploadTime), /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileCreationDate }, "Created: ", file.creationDate)), droppedFileItemCenterContent, /*#__PURE__*/React.createElement("div", { style: mergedStyles.fileActions }, droppedFileItemActionContent, /*#__PURE__*/React.createElement(HUDIcon, _extends({ iconConfigurationSettings: mergedStyles.fileActionButton, name: "fa-trash", onClick: function onClick(event) { event.stopPropagation(); handleRemoveFile(index); } }, droppedFileDeleteButtonConfigurations)), /*#__PURE__*/React.createElement(HUDIcon, _extends({ iconConfigurationSettings: mergedStyles.fileActionButton, name: "fa-redo", onClick: function onClick(event) { event.stopPropagation(); handleReplaceFile(index); } }, droppedFileSwapButtonConfigurations)), /*#__PURE__*/React.createElement("input", _extends({ id: "file-input-".concat(index) }, getInputProps(), { style: { display: "none" }, onChange: function onChange(e) { return handleFileReplace(e, index); }, accept: acceptedFileTypes && acceptedFileTypes.length > 0 ? acceptedFileTypes.join(",") : acceptedFileTypes && acceptedFileTypes.length === 0 ? "" : undefined, type: "file" })))); }); }; var readFileDataFromURL = function readFileDataFromURL(file) { return new Promise(function (resolve, reject) { var reader = new FileReader(); reader.onload = function () { return resolve(reader.result); }; reader.onerror = function (error) { reject(new Error("Did not read file. Possibly due to browser memory limits ~ ".concat(error))); }; try { reader.readAsDataURL(file); } catch (error) { reject(new Error("FileReader crashed ~ ".concat(error))); } }); }; var onDrop = /*#__PURE__*/function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(acceptedFiles) { var authorizedFiles, validFiles, excessFiles, updatedFiles; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return Promise.all(acceptedFiles.map(handleFileValidation)); case 2: authorizedFiles = _context2.sent; validFiles = authorizedFiles.filter(function (file) { return file !== null; }); if (files.length + validFiles.length > maxFiles) { excessFiles = files.length + validFiles.length - maxFiles; setFileUnauthorizations(function (unauthFiles) { return [].concat(_toConsumableArray(unauthFiles), [{ file: excessFiles, errors: [{ code: "exceeded-file-limit", message: "Exceeded maximum file limit (".concat(ConvertNumberToMoneyFormat(maxFiles, false), ").") }] }]); }); onFileRestrictionActivation(excessFiles, { code: "exceeded-file-limit", message: "Exceeded maximum file limit (".concat(ConvertNumberToMoneyFormat(maxFiles, false), ").") }, "auth-sync"); validFiles.splice(validFiles.length - excessFiles, excessFiles); } _context2.next = 7; return Promise.all(Array.from(validFiles).map( /*#__PURE__*/function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) { var resolvedMaxBase64Size, fileData, fileURL; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.prev = 0; resolvedMaxBase64Size = ConvertFileSizeToBytes(maxBase64FileSize); fileData = null; fileURL = null; if (!(file.size <= resolvedMaxBase64Size && includeFileData)) { _context.next = 14; break; } _context.prev = 5; _context.next = 8; return readFileDataFromURL(file); case 8: fileData = _context.sent; _context.next = 14; break; case 11: _context.prev = 11; _context.t0 = _context["catch"](5); setFileUnauthorizations(function (prev) { return [].concat(_toConsumableArray(prev), [{ file: file, errors: [{ code: "file-read-error", message: "We could not load \"".concat(file.name, "\". Try a smaller file or check file permissions.") }] }]); }); case 14: try { fileURL = URL.createObjectURL(file); } catch (urlError) { setFileUnauthorizations(function (prev) { return [].concat(_toConsumableArray(prev), [{ file: file, errors: [{ code: "file-url-error", message: "We could not preview \"".concat(file.name, "\" \u2014 Please try reselecting the file or using a different one.") }] }]); }); } if (!(!fileData && !fileURL)) { _context.next = 17; break; } return _context.abrupt("return", null); case 17: return _context.abrupt("return", { webkitRelativePath: file.webkitRelativePath || "", creationDate: file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() : "N/A", dateUploaded: new Date().toLocaleDateString(), uploadTime: new Date().toLocaleTimeString(), lastModified: file.lastModified, type: file.type || "Unknown", path: file.path, name: file.name, size: file.size, data: fileData, url: fileURL }); case 20: _context.prev = 20; _context.t1 = _context["catch"](0); setFileUnauthorizations(function (prev) { return [].concat(_toConsumableArray(prev), [{ file: file, errors: [{ code: "file-processing-error", message: "Something went wrong while processing \"".concat(file.name, "\". Please try again.") }] }]); }); return _context.abrupt("return", null); case 24: case "end": return _context.stop(); } }, _callee, null, [[0, 20], [5, 11]]); })); return function (_x2) { return _ref4.apply(this, arguments); }; }())); case 7: updatedFiles = _context2.sent; addFiles(updatedFiles); onFileUpload(updatedFiles); if (updatedFiles.length > 0 && updatedFiles[0].size > 1000000) { setUploading(true); updatedFiles.forEach(function (file) { return simulateUploadProgress(file); }); } case 11: case "end": return _context2.stop(); } }, _callee2); })); return function onDrop(_x) { return _ref3.apply(this, arguments); }; }(); var onFileRestrictionActivation = function onFileRestrictionActivation(file, restrictionData) { var authorizationMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "auth-sync"; if (!onFileRestriction) { return; } onFileRestriction(file, restrictionData, authorizationMethod); }; var validateFileAsync = /*#__PURE__*/function () { var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(file) { var _iterator, _step, _loop, _ret; return _regeneratorRuntime.wrap(function _callee3$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!file.name) { _context4.next = 20; break; } _iterator = _createForOfIteratorHelper(dropzoneFileRestrictions); _context4.prev = 2; _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() { var restriction, restrictionResult; return _regeneratorRuntime.wrap(function _loop$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: restriction = _step.value; _context3.next = 3; return restriction(file); case 3: restrictionResult = _context3.sent; if (!(restrictionResult && restrictionResult.code)) { _context3.next = 7; break; } setFileUnauthorizations(function (unauthFiles) { return [].concat(_toConsumableArray(unauthFiles), [{ file: file, errors: [restrictionResult] }]); }); return _context3.abrupt("return", { v: restrictionResult }); case 7: case "end": return _context3.stop(); } }, _loop); }); _iterator.s(); case 5: if ((_step = _iterator.n()).done) { _context4.next = 12; break; } return _context4.delegateYield(_loop(), "t0", 7); case 7: _ret = _context4.t0; if (!_ret) { _context4.next = 10; break; } return _context4.abrupt("return", _ret.v); case 10: _context4.next = 5; break; case 12: _context4.next = 17; break; case 14: _context4.prev = 14; _context4.t1 = _context4["catch"](2); _iterator.e(_context4.t1); case 17: _context4.prev = 17; _iterator.f(); return _context4.finish(17); case 20: return _context4.abrupt("return", null); case 21: case "end": return _context4.stop(); } }, _callee3, null, [[2, 14, 17, 20]]); })); return function validateFileAsync(_x3) { return _ref5.apply(this, arguments); }; }(); var validateFileSync = function validateFileSync(file) { if (fileBlackList.includes(file.name)) { var fileBlacklistedData = { code: "file-blacklisted", message: "File restricted." }; onFileRestrictionActivation(file, fileBlacklistedData, "auth-sync"); return fileBlacklistedData; } if (acceptedFileTypes && acceptedFileTypes.length <= 0) { var fileInvalidTypeData = { code: "file-invalid-type", message: "No file types accepted." }; onFileRestrictionActivation(file, fileInvalidTypeData, "auth-sync"); return fileInvalidTypeData; } if (acceptedFileTypes && !acceptedFileTypes.includes("*") && !acceptedFileTypes.includes(file.type)) { var _fileInvalidTypeData = { code: "file-invalid-type", message: "Only ".concat(acceptedFileTypes.map(function (type) { return getMimeTypeDisplay(type); }).join(", "), " files accepted.") }; onFileRestrictionActivation(file, _fileInvalidTypeData, "auth-sync"); return _fileInvalidTypeData; } var currentMaxSize = ConvertFileSizeToBytes(maxSize); if (files.length + 1 > maxFiles) { var fileLimitData = { code: "exceeded-file-limit", message: "Exceeded maximum file limit (".concat(ConvertNumberToMoneyFormat(maxFiles, false), ").") }; onFileRestrictionActivation(file, fileLimitData, "auth-sync"); return fileLimitData; } if (file.size > currentMaxSize) { var fileTooLargeData = { code: "file-too-large", message: "File size exceeds ".concat(ConvertFileSizeToDisplay(currentMaxSize, 2), ".") }; onFileRestrictionActivation(file, fileTooLargeData, "auth-sync"); return fileTooLargeData; } return null; }; var fileRestrictions = function fileRestrictions(file) { var fileAuthorizationResponse = validateFileSync(file); if (fileAuthorizationResponse) { setFileUnauthorizations(function (unauthFiles) { return [].concat(_toConsumableArray(unauthFiles), [{ file: file, errors: [fileAuthorizationResponse] }]); }); } return fileAuthorizationResponse || null; }; var _useDropzone = useDropzone({ onDrop: onDrop, onDragLeave: function onDragLeave() { return setHovering(false); }, onDragEnter: function onDragEnter() { return setHovering(true); }, validator: fileRestrictions }), getRootProps = _useDropzone.getRootProps, getInputProps = _useDropzone.getInputProps, fileRejections = _useDropzone.fileRejections; var handleFileValidation = /*#__PURE__*/function () { var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(file) { var fileAuthorizationResponse; return _regeneratorRuntime.wrap(function _callee4$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return validateFileAsync(file); case 2: fileAuthorizationResponse = _context5.sent; if (!fileAuthorizationResponse) { _context5.next = 7; break; } console.warn("".concat(file.name, ": ").concat(fileAuthorizationResponse.message)); onFileRestrictionActivation(file, fileAuthorizationResponse, "auth-async"); return _context5.abrupt("return", null); case 7: return _context5.abrupt("return", file); case 8: case "end": return _context5.stop(); } }, _callee4); })); return function handleFileValidation(_x4) { return _ref6.apply(this, arguments); }; }(); var handleRemoveFile = function handleRemoveFile(index) { removeFile(index); setUploadProgress(function (prevProgress) { return prevProgress.filter(function (_, i) { return i !== index; }); }); }; var handleReplaceFile = function handleReplaceFile(index) { var fileInput = document.getElementById("file-input-".concat(index)); if (fileInput) { fileInput.click(); } }; var handleFileReplace = /*#__PURE__*/function () { var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark