@zydon/common 2.6.95 → 2.6.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ var s=(i=>(i.SENT="SENT",i.DELIVERED="DELIVERED",i.READ="READ",i))(s||{});
2
+
3
+ export { s as a };
@@ -0,0 +1,3 @@
1
+ function c(n){let a="=".repeat((4-n.length%4)%4),o=(n+a).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(o),e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t);return e}
2
+
3
+ export { c as a };
@@ -1,8 +1,8 @@
1
1
  import { c } from '../../chunk-QQB3DGHT.js';
2
+ import { a } from '../../chunk-EBTRMUBS.js';
2
3
  import { a as a$1 } from '../../chunk-FK7DDO5L.js';
3
4
  import { a as a$2 } from '../../chunk-7TWT67RG.js';
4
5
  import '../../chunk-U26IUEAG.js';
5
- import { a } from '../../chunk-EBTRMUBS.js';
6
6
  import '../../chunk-7J53ZUIF.js';
7
7
  import ct from '@mui/material/Pagination';
8
8
  import g from '@mui/material/Stack';
@@ -1,12 +1,334 @@
1
1
  import * as react from 'react';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { H as HelperTextProps, M as MultiFilePreviewProps, S as SingleFilePreviewProps, F as FileThumbnailProps, U as UseDropzoneUploaderProps, a as UseDropzoneUploaderReturn, b as MultiFileUploadProps, c as MultiImageUploadProps, d as SingleFileUploadProps, e as SingleImageUploadProps } from '../../useFileUploadService-1a2d0cf5.js';
4
- export { C as ContentType, j as CreateFilesMutation, i as CropSize, D as DropZoneProps, E as ExtendFile, f as FileContentType, k as FileCreateRequest, m as FileCreateResponse, g as FileDetails, l as FileGetResponse, n as FileQueryRequest, o as FileQueryResponse, h as FileUpload, p as FileUploadProps, L as LoadingPreviewImageProps, P as PlaceholderProps, R as RejectionFilesProps, q as SortableItemProps, r as StyledDropZoneProps, s as StyledDropZonePropsType, T as ThumbnailBadgeProps, u as useFileUploadService } from '../../useFileUploadService-1a2d0cf5.js';
5
- import 'react-dropzone';
6
- import 'react-easy-crop';
7
- import '@dnd-kit/core';
8
- import '@mui/material/Stack';
9
- import '@mui/material/styles';
3
+ import { DropzoneOptions, DropzoneRootProps, FileRejection, DropzoneInputProps, useDropzone } from 'react-dropzone';
4
+ import { Area } from 'react-easy-crop';
5
+ import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
6
+ import { StackProps } from '@mui/material/Stack';
7
+ import { SxProps, Theme } from '@mui/material/styles';
8
+
9
+ interface ExtendFile extends File {
10
+ id: string;
11
+ url: string;
12
+ }
13
+ interface FileDetails {
14
+ id: string;
15
+ url: string;
16
+ name?: string;
17
+ }
18
+ interface FileUpload {
19
+ url: string;
20
+ file: ExtendFile;
21
+ contentType: string;
22
+ resourceIds: string[];
23
+ }
24
+ type CropSize = {
25
+ width: number;
26
+ height: number;
27
+ } | number;
28
+ type CreateFilesMutation = (files: ExtendFile[]) => Promise<string[] | undefined>;
29
+ interface FileCreateRequest {
30
+ files: Array<{
31
+ content_type: keyof typeof ContentType;
32
+ name: string;
33
+ }>;
34
+ }
35
+ interface FileGetResponse {
36
+ id: string;
37
+ name: string;
38
+ organization_id: string;
39
+ url: string;
40
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
41
+ content_type: string;
42
+ content_length: number;
43
+ created_by: string;
44
+ created_at: string;
45
+ updated_by: string;
46
+ updated_at: string;
47
+ }
48
+ interface FileCreateResponse {
49
+ files: FileGetResponse[];
50
+ }
51
+ interface FileQueryRequest {
52
+ ids: string[];
53
+ }
54
+ interface FileQueryResponse {
55
+ files: FileGetResponse[];
56
+ }
57
+ interface SingleFilePreviewProps extends StackProps {
58
+ file: ExtendFile;
59
+ aspectRatio?: number;
60
+ isLoading?: boolean;
61
+ cropSize?: CropSize;
62
+ onLoading?: (isLoading: boolean) => void;
63
+ isUploading?: boolean;
64
+ maxWidth?: number;
65
+ maxHeight?: number;
66
+ }
67
+ interface LoadingPreviewImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
68
+ aspectRatio: number;
69
+ maxWidth?: number | string;
70
+ maxHeight?: number | string;
71
+ isLoading?: boolean;
72
+ isUploading?: boolean;
73
+ cropSize?: CropSize;
74
+ onLoading?: (isLoading: boolean) => void;
75
+ alt?: string;
76
+ src?: string;
77
+ loading: 'lazy';
78
+ }
79
+ interface PlaceholderProps extends StackProps {
80
+ header?: React.ReactNode;
81
+ description?: React.ReactNode;
82
+ }
83
+ interface FileUploadProps {
84
+ createFilesMutation: (params: FileCreateRequest) => {
85
+ unwrap: () => Promise<FileCreateResponse>;
86
+ };
87
+ filesDetails: FileDetails[];
88
+ }
89
+ interface SingleFileUploadProps extends DropzoneOptions {
90
+ onRemove?: (file?: ExtendFile) => void;
91
+ onFileSelect?: (file: ExtendFile) => void;
92
+ createFilesMutation: FileUploadProps['createFilesMutation'];
93
+ fileDetails?: FileDetails;
94
+ placeholderProps?: PlaceholderProps;
95
+ placeholderAlt?: React.ReactNode;
96
+ name?: string;
97
+ label?: string;
98
+ id?: string;
99
+ disabled?: boolean;
100
+ error?: string;
101
+ helperText?: string | React.ReactNode;
102
+ sx?: SxProps<Theme>;
103
+ dropZoneSxProps?: SxProps<Theme>;
104
+ uploading?: boolean;
105
+ tabIndex?: number;
106
+ maxSize?: number;
107
+ }
108
+ interface SingleImageUploadProps extends SingleFileUploadProps {
109
+ aspectRatio?: number;
110
+ enableCrop?: boolean;
111
+ convertToWebp?: boolean;
112
+ cropSize?: CropSize;
113
+ maxWidth?: number;
114
+ maxHeight?: number;
115
+ compressionQuality?: number;
116
+ maxCompressedWidth?: number;
117
+ maxCompressedHeight?: number;
118
+ }
119
+ interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'filesDetails' | 'onFileSelect'> {
120
+ onFilesSelect?: (files: ExtendFile[]) => void;
121
+ onRemoveAll?: (files?: ExtendFile[]) => void;
122
+ onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
123
+ filesDetails?: FileDetails[];
124
+ maxFiles?: number;
125
+ thumbnail?: boolean;
126
+ }
127
+ interface MultiImageUploadProps extends MultiFileUploadProps {
128
+ aspectRatio?: number;
129
+ enableCrop?: boolean;
130
+ convertToWebp?: boolean;
131
+ cropSize?: CropSize;
132
+ maxWidth?: number;
133
+ maxHeight?: number;
134
+ compressionQuality?: number;
135
+ maxCompressedWidth?: number;
136
+ maxCompressedHeight?: number;
137
+ }
138
+ interface SortableItemProps extends StackProps {
139
+ onRemove?: (file?: ExtendFile) => void;
140
+ file: ExtendFile;
141
+ thumbnail?: boolean;
142
+ disableDrag?: boolean;
143
+ }
144
+ interface MultiFilePreviewProps extends StackProps {
145
+ onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
146
+ onRemove?: (file?: ExtendFile) => void;
147
+ files: ExtendFile[];
148
+ lastNode?: React.ReactNode;
149
+ firstNode?: React.ReactNode;
150
+ thumbnail: boolean;
151
+ slotProps?: {
152
+ thumbnail?: Omit<FileThumbnailProps, 'file'>;
153
+ };
154
+ }
155
+ interface StyledDropZoneProps extends StackProps {
156
+ isDragActive: boolean;
157
+ isError: boolean;
158
+ disabled: boolean;
159
+ }
160
+ type StyledDropZonePropsType = Omit<DropzoneRootProps, 'children' | 'onDrop' | 'onError'> & StyledDropZoneProps;
161
+ interface RejectionFilesProps extends StackProps {
162
+ files: FileRejection[];
163
+ }
164
+ interface ThumbnailBadgeProps {
165
+ onRemove?: (file?: ExtendFile) => void;
166
+ file: ExtendFile;
167
+ attributes: DraggableAttributes;
168
+ listeners: DraggableSyntheticListeners;
169
+ innerWidth: number;
170
+ isDragging: boolean;
171
+ disableDrag?: boolean;
172
+ sx?: SxProps<Theme>;
173
+ }
174
+ interface DropZoneProps {
175
+ sx?: SxProps;
176
+ uploading?: boolean;
177
+ id?: string;
178
+ tabIndex?: number;
179
+ getRootProps: () => DropzoneRootProps;
180
+ getInputProps: () => DropzoneInputProps;
181
+ isDragActive: boolean;
182
+ isError: boolean;
183
+ disabled?: boolean;
184
+ dropZoneSxProps?: SxProps<Theme>;
185
+ dropZoneContent?: React.ReactNode;
186
+ children?: React.ReactNode;
187
+ name?: string;
188
+ }
189
+ interface HelperTextProps {
190
+ helperText?: string | React.ReactNode;
191
+ disabled?: boolean;
192
+ isError?: boolean;
193
+ }
194
+ interface UseDropzoneUploaderProps {
195
+ onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
196
+ onFileSelect?: (file: ExtendFile) => void;
197
+ onFilesSelect?: (files: ExtendFile[]) => void;
198
+ onRemove?: (file?: ExtendFile) => void;
199
+ uploadFiles: (files: File[]) => Promise<ExtendFile[] | undefined>;
200
+ filesPreview?: ExtendFile[];
201
+ dropzoneOptions?: Omit<DropzoneOptions, 'onDrop' | 'onDropRejected'>;
202
+ enableCrop?: boolean;
203
+ customAspectRatio?: number;
204
+ convertToWebp?: boolean;
205
+ maxFiles?: number;
206
+ cropSize?: {
207
+ width: number;
208
+ height: number;
209
+ } | number;
210
+ compressionQuality?: number;
211
+ maxCompressedWidth?: number;
212
+ maxCompressedHeight?: number;
213
+ }
214
+ interface UseDropzoneUploaderReturn {
215
+ file: ExtendFile | null;
216
+ files: ExtendFile[];
217
+ aspectRatio: number;
218
+ dropzoneProps: {
219
+ getRootProps: ReturnType<typeof useDropzone>['getRootProps'];
220
+ getInputProps: ReturnType<typeof useDropzone>['getInputProps'];
221
+ isDragActive: boolean;
222
+ isDragReject: boolean;
223
+ fileRejections: readonly FileRejection[];
224
+ };
225
+ cropState: {
226
+ cropModalOpen: boolean;
227
+ imagePreview: string;
228
+ cropLoading: boolean;
229
+ setCropModalOpen: React.Dispatch<React.SetStateAction<boolean>>;
230
+ onCropInitialized: (croppedArea: Area, croppedAreaPixels: Area) => void;
231
+ handleCropSave: () => Promise<void>;
232
+ handleCropCancel: () => void;
233
+ currentImageIndex: number;
234
+ totalPendingImages: number;
235
+ };
236
+ setInitialFiles?: (files: ExtendFile[]) => void;
237
+ handleRemove: (fileToRemove?: ExtendFile) => void;
238
+ handleReorder: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
239
+ }
240
+ declare enum ContentType {
241
+ APPLICATION_OCTET_STREAM = "application/octet-stream",
242
+ IMAGE_JPEG = "image/jpeg",
243
+ IMAGE_JPG = "image/jpg",
244
+ IMAGE_PNG = "image/png",
245
+ IMAGE_GIF = "image/gif",
246
+ IMAGE_WEBP = "image/webp",
247
+ IMAGE_SVG = "image/svg+xml",
248
+ IMAGE_BMP = "image/bmp",
249
+ IMAGE_TIFF = "image/tiff",
250
+ IMAGE_ICO = "image/x-icon",
251
+ IMAGE_AVIF = "image/avif",
252
+ APPLICATION_PDF = "application/pdf",
253
+ TEXT_PLAIN = "text/plain",
254
+ TEXT_CSV = "text/csv",
255
+ APPLICATION_RTF = "application/rtf",
256
+ APPLICATION_MSWORD = "application/msword",
257
+ APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
258
+ APPLICATION_MSEXCEL = "application/vnd.ms-excel",
259
+ APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
260
+ APPLICATION_MSPOWERPOINT = "application/vnd.ms-powerpoint",
261
+ APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
262
+ APPLICATION_ODT = "application/vnd.oasis.opendocument.text",
263
+ APPLICATION_ODS = "application/vnd.oasis.opendocument.spreadsheet",
264
+ APPLICATION_ODP = "application/vnd.oasis.opendocument.presentation",
265
+ APPLICATION_XML = "application/xml",
266
+ TEXT_XML = "text/xml",
267
+ TEXT_HTML = "text/html",
268
+ TEXT_CSS = "text/css",
269
+ APPLICATION_JSON = "application/json",
270
+ TEXT_JAVASCRIPT = "text/javascript",
271
+ APPLICATION_ZIP = "application/zip",
272
+ APPLICATION_GZIP = "application/gzip",
273
+ APPLICATION_RAR = "application/vnd.rar",
274
+ APPLICATION_7Z = "application/x-7z-compressed",
275
+ AUDIO_MPEG = "audio/mpeg",
276
+ AUDIO_WAV = "audio/wav",
277
+ AUDIO_OGG = "audio/ogg",
278
+ AUDIO_WEBM = "audio/webm",
279
+ AUDIO_AAC = "audio/aac",
280
+ VIDEO_MP4 = "video/mp4",
281
+ VIDEO_MPEG = "video/mpeg",
282
+ VIDEO_OGG = "video/ogg",
283
+ VIDEO_WEBM = "video/webm",
284
+ VIDEO_QUICKTIME = "video/quicktime"
285
+ }
286
+ declare enum FileContentType {
287
+ 'application/octet-stream' = "APPLICATION_OCTET_STREAM",
288
+ 'image/jpeg' = "IMAGE_JPEG",
289
+ 'image/jpg' = "IMAGE_JPG",
290
+ 'image/png' = "IMAGE_PNG",
291
+ 'image/gif' = "IMAGE_GIF",
292
+ 'image/webp' = "IMAGE_WEBP",
293
+ 'image/svg+xml' = "IMAGE_SVG",
294
+ 'image/bmp' = "IMAGE_BMP",
295
+ 'image/tiff' = "IMAGE_TIFF",
296
+ 'image/x-icon' = "IMAGE_ICO",
297
+ 'image/avif' = "IMAGE_AVIF",
298
+ 'application/pdf' = "APPLICATION_PDF",
299
+ 'text/plain' = "TEXT_PLAIN",
300
+ 'text/csv' = "TEXT_CSV",
301
+ 'application/rtf' = "APPLICATION_RTF",
302
+ 'application/msword' = "APPLICATION_MSWORD",
303
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' = "APPLICATION_DOCX",
304
+ 'application/vnd.ms-excel' = "APPLICATION_MSEXCEL",
305
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' = "APPLICATION_XLSX",
306
+ 'application/vnd.ms-powerpoint' = "APPLICATION_MSPOWERPOINT",
307
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' = "APPLICATION_PPTX",
308
+ 'application/vnd.oasis.opendocument.text' = "APPLICATION_ODT",
309
+ 'application/vnd.oasis.opendocument.spreadsheet' = "APPLICATION_ODS",
310
+ 'application/vnd.oasis.opendocument.presentation' = "APPLICATION_ODP",
311
+ 'application/xml' = "APPLICATION_XML",
312
+ 'text/xml' = "TEXT_XML",
313
+ 'text/html' = "TEXT_HTML",
314
+ 'text/css' = "TEXT_CSS",
315
+ 'application/json' = "APPLICATION_JSON",
316
+ 'text/javascript' = "TEXT_JAVASCRIPT",
317
+ 'application/zip' = "APPLICATION_ZIP",
318
+ 'application/gzip' = "APPLICATION_GZIP",
319
+ 'application/vnd.rar' = "APPLICATION_RAR",
320
+ 'application/x-7z-compressed' = "APPLICATION_7Z",
321
+ 'audio/mpeg' = "AUDIO_MPEG",
322
+ 'audio/wav' = "AUDIO_WAV",
323
+ 'audio/ogg' = "AUDIO_OGG",
324
+ 'audio/webm' = "AUDIO_WEBM",
325
+ 'audio/aac' = "AUDIO_AAC",
326
+ 'video/mp4' = "VIDEO_MP4",
327
+ 'video/mpeg' = "VIDEO_MPEG",
328
+ 'video/ogg' = "VIDEO_OGG",
329
+ 'video/webm' = "VIDEO_WEBM",
330
+ 'video/quicktime' = "VIDEO_QUICKTIME"
331
+ }
10
332
 
11
333
  declare const _default$8: react.MemoExoticComponent<({ helperText, disabled, isError }: HelperTextProps) => react_jsx_runtime.JSX.Element | null>;
12
334
 
@@ -14,6 +336,21 @@ declare const _default$7: react.MemoExoticComponent<({ thumbnail, files, onRemov
14
336
 
15
337
  declare const _default$6: react.MemoExoticComponent<({ file, aspectRatio, isUploading, isLoading, onLoading, cropSize, maxWidth, maxHeight, }: SingleFilePreviewProps) => react_jsx_runtime.JSX.Element | null>;
16
338
 
339
+ type FileThumbnailProps = StackProps & {
340
+ tooltip?: boolean;
341
+ file: ExtendFile;
342
+ imageView?: boolean;
343
+ sx?: SxProps<Theme>;
344
+ onDownload?: () => void;
345
+ onRemove?: () => void;
346
+ slotProps?: {
347
+ img?: SxProps<Theme>;
348
+ icon?: SxProps<Theme>;
349
+ removeBtn?: SxProps<Theme>;
350
+ downloadBtn?: SxProps<Theme>;
351
+ };
352
+ };
353
+
17
354
  declare const fileThumbnailClasses: {
18
355
  root: string;
19
356
  img: string;
@@ -30,6 +367,17 @@ declare function fileNameByUrl(fileUrl: string): string | undefined;
30
367
 
31
368
  declare const useDropzoneUploader: ({ onFilesSelect, onFileSelect, onReorder, onRemove, uploadFiles, filesPreview, dropzoneOptions, enableCrop, customAspectRatio, convertToWebp, cropSize, maxFiles, compressionQuality, maxCompressedWidth, maxCompressedHeight, }: UseDropzoneUploaderProps) => UseDropzoneUploaderReturn;
32
369
 
370
+ declare const useFileUploadService: ({ createFilesMutation, filesDetails, }: FileUploadProps) => {
371
+ setFilesPreview: react.Dispatch<react.SetStateAction<ExtendFile[]>>;
372
+ uploadFiles: (files: File[]) => Promise<ExtendFile[] | undefined>;
373
+ filesPreview: ExtendFile[];
374
+ filePreview: ExtendFile;
375
+ isLoadingPreview: boolean;
376
+ isUploadingFiles: boolean;
377
+ isUploadOrLoadingFiles: boolean;
378
+ uploadErrorText: string;
379
+ };
380
+
33
381
  declare const _default$5: react.MemoExoticComponent<({ onRemove, onReorder, onFilesSelect, createFilesMutation, filesDetails, id, disabled, error, helperText, thumbnail, dropZoneSxProps, uploading, tabIndex, maxFiles, placeholderAlt, placeholderProps, ...other }: MultiFileUploadProps) => react_jsx_runtime.JSX.Element>;
34
382
 
35
383
  declare const _default$4: react.MemoExoticComponent<({ onRemove, onReorder, onFilesSelect, createFilesMutation, filesDetails, id, disabled, error, helperText, dropZoneSxProps, placeholderProps, placeholderAlt, uploading, tabIndex, maxFiles, aspectRatio: customAspectRatio, enableCrop, convertToWebp, cropSize, name, label: customLabel, ...other }: MultiImageUploadProps) => react_jsx_runtime.JSX.Element>;
@@ -48,4 +396,4 @@ declare const compressImageWithoutCrop: (file: File, quality?: number, maxWidth?
48
396
  declare const getFileNameFromContentDisposition: (contentDisposition: string) => string;
49
397
  declare const encodeFilenameForHeader: (filename: string) => string;
50
398
 
51
- export { FileThumbnail, FileThumbnailProps, _default$8 as HelperText, HelperTextProps, _default$7 as MultiFilePreview, MultiFilePreviewProps, MultiFileUploadProps, MultiImageUploadProps, _default$5 as MultipleFileUpload, _default$4 as MultipleImageUpload, _default$6 as SingleFilePreview, SingleFilePreviewProps, _default$3 as SingleFileUpload, SingleFileUploadProps, _default$2 as SingleImageUpload, SingleImageUploadProps, _default$1 as UploadAvatar, _default as UploadSimpleBox, UseDropzoneUploaderProps, UseDropzoneUploaderReturn, compressImageWithoutCrop, convertToWebP, encodeFilenameForHeader, fileFormat, fileNameByUrl, fileThumb, fileThumbnailClasses, fileTypeByUrl, getFileNameFromContentDisposition, isImageFile, useDropzoneUploader };
399
+ export { ContentType, CreateFilesMutation, CropSize, DropZoneProps, ExtendFile, FileContentType, FileCreateRequest, FileCreateResponse, FileDetails, FileGetResponse, FileQueryRequest, FileQueryResponse, FileThumbnail, FileThumbnailProps, FileUpload, FileUploadProps, _default$8 as HelperText, HelperTextProps, LoadingPreviewImageProps, _default$7 as MultiFilePreview, MultiFilePreviewProps, MultiFileUploadProps, MultiImageUploadProps, _default$5 as MultipleFileUpload, _default$4 as MultipleImageUpload, PlaceholderProps, RejectionFilesProps, _default$6 as SingleFilePreview, SingleFilePreviewProps, _default$3 as SingleFileUpload, SingleFileUploadProps, _default$2 as SingleImageUpload, SingleImageUploadProps, SortableItemProps, StyledDropZoneProps, StyledDropZonePropsType, ThumbnailBadgeProps, _default$1 as UploadAvatar, _default as UploadSimpleBox, UseDropzoneUploaderProps, UseDropzoneUploaderReturn, compressImageWithoutCrop, convertToWebP, encodeFilenameForHeader, fileFormat, fileNameByUrl, fileThumb, fileThumbnailClasses, fileTypeByUrl, getFileNameFromContentDisposition, isImageFile, useDropzoneUploader, useFileUploadService };
@@ -2,8 +2,6 @@ import { a as a$5 } from '../../chunk-H5L4ARDB.js';
2
2
  import { a } from '../../chunk-4UVACODQ.js';
3
3
  import { e } from '../../chunk-ANAHA3L6.js';
4
4
  import { a as a$3 } from '../../chunk-2FXBVVBD.js';
5
- import { h, c, b } from '../../chunk-ORQNUG2V.js';
6
- export { f as ContentType, g as FileContentType, c as compressImageWithoutCrop, b as convertToWebP, e as encodeFilenameForHeader, d as getFileNameFromContentDisposition, a as isImageFile, h as useFileUploadService } from '../../chunk-ORQNUG2V.js';
7
5
  import { a as a$6 } from '../../chunk-RQ4T6IDM.js';
8
6
  import '../../chunk-BPY2UXIB.js';
9
7
  import '../../chunk-7AZX7L27.js';
@@ -18,24 +16,24 @@ import '../../chunk-ILHUUK4X.js';
18
16
  import { a as a$8 } from '../../chunk-GFJT57TO.js';
19
17
  import { a as a$1 } from '../../chunk-S7QQBC4I.js';
20
18
  import { memo, forwardRef, useMemo, useLayoutEffect, useCallback, useRef, useState, useEffect } from 'react';
21
- import jo from '@mui/material/FormHelperText';
19
+ import Ho from '@mui/material/FormHelperText';
22
20
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
23
21
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
24
22
  import { restrictToHorizontalAxis, restrictToParentElement, restrictToWindowEdges } from '@dnd-kit/modifiers';
25
23
  import { useSortable, sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
26
24
  import { m, AnimatePresence } from 'framer-motion';
27
25
  import he from '@mui/material/Stack';
28
- import Ke from '@mui/material/Typography';
29
- import Ee from '@mui/material/Box';
30
- import Ho from '@mui/material/IconButton';
31
- import No from '@mui/material/Paper';
26
+ import Je from '@mui/material/Typography';
27
+ import De from '@mui/material/Box';
28
+ import qo from '@mui/material/IconButton';
29
+ import Vo from '@mui/material/Paper';
32
30
  import { styled, alpha } from '@mui/material/styles';
33
- import Go from '@mui/material/Badge';
34
- import Lr from '@mui/material/ButtonBase';
35
- import zr from '@mui/material/Tooltip';
31
+ import Qo from '@mui/material/Badge';
32
+ import Br from '@mui/material/ButtonBase';
33
+ import jr from '@mui/material/Tooltip';
36
34
  import { useDropzone } from 'react-dropzone';
37
- import St from '@mui/material/CircularProgress';
35
+ import Nt from '@mui/material/CircularProgress';
38
36
 
39
- var Zo=({helperText:e,disabled:o,isError:r})=>e?jsx(jo,{error:r,sx:t=>({mx:"14px",color:o?t.palette.grey[500]:void 0}),children:e}):null,I=memo(Zo);var Be=styled(he)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),Le=styled(he)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),io=styled(Ee,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:o,isError:r,disabled:t})=>({outline:"none",cursor:"pointer",overflow:"hidden",position:"relative",padding:e.spacing(5),borderRadius:e.shape.borderRadius,transition:e.transitions.create("padding"),backgroundColor:e.palette.background.neutral,border:`dashed 1px ${e.palette.divider}`,...o&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...t&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(he)(({theme:e})=>({display:"none",position:"absolute",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:12,width:"100%",height:"100%",backgroundColor:alpha(e.palette.primary.main,.9),zIndex:999,button:{"&, &:hover, &:focus":{backgroundColor:e.palette.background.paper}}}));var ao=styled(Ho)(({theme:e})=>({position:"relative",zIndex:999,pointerEvents:"auto",color:e.palette.grey[700],backgroundColor:e.palette.grey[100],"&:hover":{color:e.palette.grey[900],backgroundColor:e.palette.grey[300]}})),Ze=styled("div")({position:"relative",zIndex:1,userSelect:"none","&:hover":{zIndex:2}}),no=styled(he,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:o,isDragging:r})=>({width:o,height:100,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2,1,2,1),gap:e.spacing(1),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),so=styled(m.div)(({theme:e,width:o,isDragging:r})=>({width:o,height:60,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),lo=styled(a)(({theme:e})=>({top:16,right:16,zIndex:9,position:"absolute",color:e.palette.common.white,backgroundColor:alpha(e.palette.grey[900],.72),"&:hover":{backgroundColor:alpha(e.palette.grey[900],.48)}})),po=styled(Ee,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:o,disabled:r,hasError:t})=>({width:64,height:64,flexShrink:0,display:"flex",borderRadius:1,cursor:"pointer",alignItems:"center",color:e.palette.text.disabled,justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),border:`dashed 1px ${alpha(e.palette.grey[500],.16)}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...t&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),mo=styled(Ee)(({theme:e})=>({padding:e.spacing(1),top:0,left:0,width:"100%",height:"100%",position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",transition:"all 0.3s ease-in-out",filter:"blur(0)","&:hover":{filter:"blur(3px)"}})),co=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"&&e!=="maxWidth"&&e!=="maxHeight"&&e!=="cropSize"})(({theme:e,aspectRatio:o,maxWidth:r,maxHeight:t,isLoading:i,isUploading:a})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,maxWidth:r,maxHeight:t,backgroundColor:e.palette.background.paper,aspectRatio:Math.abs(o),...Math.abs(o)>1?{width:"calc(100% - 16px)",height:void 0}:{width:void 0,height:"calc(100% - 16px)"},transition:"all 0.5s ease-in-out",...i||a?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),go=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:o})=>({width:"100%",height:"100%",objectFit:"cover",top:0,left:0,filter:"blur(1.5rem)",transform:"scale(1.1)",position:"absolute",zIndex:0,transition:"opacity 0.3s ease-in-out",...e&&{opacity:0},...o&&{opacity:.7,filter:"blur(2rem)"}})),uo=styled(he)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(No)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var $e=styled(Ee,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:o,hasFile:r})=>({top:0,gap:e.spacing(1),left:0,width:"100%",height:"100%",zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:e.palette.text.disabled,flexDirection:"column",justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.shorter}),"&:hover":{opacity:.92},...o&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),fo=styled(he)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center",opacity:.8});styled(he)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.divider,color:e.palette.text.disabled,height:160}));var xo=styled(Ee,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:o,disabled:r,isError:t,hasFile:i})=>({padding:e.spacing(1),margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${e.palette.divider}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...t&&{borderColor:"error.main"},...i&&{...t&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),ho=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),bo=styled(a)(({theme:e})=>({backgroundColor:alpha(e.palette.grey[900],.72),color:e.palette.common.white,"&:hover":{backgroundColor:alpha(e.palette.grey[600],.64),color:e.palette.common.white},"& svg":{width:14,height:14}}));var Xo=({onRemove:e,sx:o,file:r,disableDrag:t,attributes:i,listeners:a,innerWidth:n,isDragging:p})=>{let s=r?.id;return s?jsx(Go,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(so,{width:n,isDragging:p,"data-testid":`preview-multi-img-${s}`,...j().inUp,sx:o,children:[jsx(a$2,{disableDrag:t,...i,...a}),jsx(Pe,{imageView:!0,file:r}),jsx(Le,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(bo,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${s}`):null},vo=memo(Xo);var er=({file:e$1,thumbnail:o,onRemove:r,sx:t,disableDrag:i=!1})=>{let a$1=e$1.size||0,n=e$1.name||e$1.id,p=e$1.id,s=typeof e$1=="string",d=i?70:80,{attributes:l,listeners:c,setNodeRef:h,transform:v,transition:P,isDragging:f}=useSortable({id:p,disabled:i}),T={transform:x.Transform.toString(v),transition:P,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${d+8}px`,height:"68px"};return o&&e$1?jsx(Ze,{ref:h,style:T,children:jsx(vo,{innerWidth:d,isDragging:f,sx:t,file:e$1,disableDrag:i,attributes:l,listeners:c,onRemove:r})}):jsx(Ze,{ref:h,style:{...T,height:"80px",width:`${d+38}px`},children:jsxs(no,{width:d+30,isDragging:f,"data-testid":`preview-multi-img-${p}`,...j().inUp,sx:t,children:[jsx(a$2,{disableDrag:i,...l,...c}),e$1&&jsx(Pe,{file:e$1}),jsxs(he,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:n,children:jsx(Ke,{variant:"subtitle2",noWrap:!0,children:n})}),jsx(Ke,{variant:"caption",sx:{color:"text.secondary"},children:s?"":e(a$1)})]}),jsx(Le,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},Po=memo(er);var fr=({thumbnail:e,files:o,onRemove:r,onReorder:t,sx:i})=>{let a=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),n=useCallback(s=>{let{active:d,over:l}=s;if(!(!d||!l||d.id===l.id)&&t){let c=o.findIndex(({id:v})=>v===d.id),h=o.findIndex(({id:v})=>v===l.id);c!==-1&&h!==-1&&t(c,h,o);}},[o,t]),p=jsx(AnimatePresence,{initial:!1,children:o.map(s=>jsx(Po,{sx:i,id:`preview-file-${s.id}`,file:s,onRemove:r,thumbnail:e,disableDrag:!t},`preview-file-${s.id}`))});return t?jsx(DndContext,{sensors:a,collisionDetection:closestCenter,onDragEnd:n,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:o.map(s=>s.id),strategy:horizontalListSortingStrategy,children:p})}):p},De=memo(fr);var Fo=forwardRef(({onLoading:e,aspectRatio:o,cropSize:r,...t},i)=>{let{maxWidth:a,maxHeight:n}=useMemo(()=>r&&typeof r=="object"?{maxWidth:r.width,maxHeight:r.height}:r&&typeof r=="number"?{maxWidth:r,maxHeight:r}:{maxWidth:"100%",maxHeight:"100%"},[r]);a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof i=="object"&&i?.current?e?.(!i.current.complete):e?.(!1);},[i,e]);function p(){e?.(!1);}return jsx(co,{...t,maxWidth:a,maxHeight:n,ref:i,aspectRatio:o,onLoad:p,onError:p})});Fo.displayName="LoadingPreviewImage";var Co=Fo;var Pr=({file:e,aspectRatio:o=1,isUploading:r,isLoading:t,onLoading:i,cropSize:a,maxWidth:n,maxHeight:p})=>{let s=useRef(null),d=e?.id||"",l=e?.name||"",c=URL.createObjectURL(e);return d?jsxs(mo,{className:"single-file-preview-box",children:[jsx(Co,{className:"single-file-preview-img",aspectRatio:o,cropSize:a,isLoading:t,isUploading:r,alt:l,src:c,ref:s,loading:"lazy",onLoading:i,onLoad:()=>i?.(!1),onError:()=>i?.(!1),maxWidth:n,maxHeight:p},`image-preview-${d}`),jsx(go,{className:"single-file-preview-bg",alt:l,src:c,isLoading:t,isUploading:r})]}):null},He=memo(Pr);var Fr=["pdf"],Cr=["txt"],Er=["psd"],Tr=["doc","docx"],Dr=["xls","xlsx"],Rr=["zip","rar","iso"],Ur=["ai","eps"],Sr=["ppt","pptx"],Ar=["wav","aif","mp3","aac"],_r=["jpg","jpeg","gif","bmp","png","svg","webp"],kr=["m4v","avi","mpg","mp4","webm"];function Ne(e){let o,r=To(e);return Cr.includes(r)?o="txt":Rr.includes(r)?o="zip":Ar.includes(r)?o="audio":_r.includes(r)?o="image":kr.includes(r)?o="video":Tr.includes(r)?o="word":Dr.includes(r)?o="excel":Sr.includes(r)?o="powerpoint":Fr.includes(r)?o="pdf":Er.includes(r)?o="photoshop":Ur.includes(r)?o="illustrator":e?.startsWith("http")?o="image":o=To(e),o}function Do(e){let o;switch(Ne(e)){case"folder":o="IC_FOLDER";break;case"txt":o="IC_TXT";break;case"zip":o="IC_ZIP";break;case"audio":o="IC_AUDIO";break;case"video":o="IC_VIDEO";break;case"word":o="IC_WORD";break;case"excel":o="IC_EXCEL";break;case"powerpoint":o="IC_POWER_POINT";break;case"pdf":o="IC_PDF";break;case"photoshop":o="IC_PTS";break;case"illustrator":o="IC_AI";break;case"image":o="IC_IMG";break;default:o="IC_FILE";}return o}function To(e){return e&&e.split(".").pop()||""}function Xi(e){return e.split("/").pop()}var Oe={root:"mnl__file__thumbnail__root",img:"mnl__file__thumbnail__img",icon:"mnl__file__thumbnail__icon",removeBtn:"mnl__file__thumbnail__remove__button",downloadBtn:"mnl__file__thumbnail__download__button"},Pe=({sx:e,file:o,tooltip:r,onRemove:t,imageView:i,slotProps:a,onDownload:n,...p})=>{let s=URL.createObjectURL(o),d=o?.name||"",c=o.type.startsWith("image/")?"image":Ne(s),h=jsx(Ee,{component:"img",src:s,className:Oe.img,sx:{width:1,height:1,objectFit:"cover",borderRadius:"inherit",...a?.img}}),v=jsx(a$4,{icon:Do(c),sx:{width:32,height:32,flexShrink:0,...e}}),P=jsxs(he,{component:"span",className:Oe.root,sx:{width:36,height:36,flexShrink:0,borderRadius:1.25,alignItems:"center",position:"relative",display:"inline-flex",justifyContent:"center",...e},...p,children:[c==="image"&&i?h:v,t&&jsx(Lr,{onClick:t,className:Oe.removeBtn,sx:a?.removeBtn,children:jsx(a$4,{icon:"CLOSE_MARK_BUTTON",width:24})}),n&&jsx(Ho,{onClick:n,className:Oe.downloadBtn,sx:a?.downloadBtn,size:"small",children:jsx(a$4,{icon:"ARROW_DOWN_CICLE",width:12})})]});return r?jsx(zr,{arrow:!0,title:d,slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,-12]}}]}},children:P}):P};var Nr=({onFilesSelect:e$1,onFileSelect:o,onReorder:r,onRemove:t,uploadFiles:i,filesPreview:a,dropzoneOptions:n,enableCrop:p=!1,customAspectRatio:s,convertToWebp:d=!0,cropSize:l,maxFiles:c$1,compressionQuality:h=.8,maxCompressedWidth:v,maxCompressedHeight:P})=>{let{showErrorMessage:f}=a$8(),T=useMemo(()=>s||(l&&typeof l!="number"?l.width/l.height:1),[s,l]),[D,g]=useState([]),[k,C]=useState(!1),[R,B]=useState(null),[U,L]=useState(null),[x,S]=useState(""),[M,w]=useState(!1),[E,O]=useState([]),[G,j]=useState(0),[se,ee]=useState(0),oe=m=>{if(m.length<1)return;let u=m[0];B(u),j(F=>F+1);let b=new FileReader;b.onload=()=>{S(b.result),C(!0);},b.readAsDataURL(u);},le=(m,u)=>{L(u);},ge=async m=>!R||!U?null:new Promise(u=>{let b$1=document.createElement("canvas"),F=b$1.getContext("2d"),A=new Image;A.onload=async()=>{let{width:z,height:pe,x:Re,y:Bo}=U,Lo=Math.abs(T),Ue=z,Se=pe;l&&typeof l=="object"?(Ue=l.width,Se=l.height):l&&typeof l=="number"&&(Ue=l,Se=l/Lo),b$1.width=Ue,b$1.height=Se,F?(F.drawImage(A,Re,Bo,z,pe,0,0,Ue,Se),b$1.toBlob(async Ve=>{if(Ve){let je=new File([Ve],R.name,{type:R.type,lastModified:Date.now()});if(d)try{je=await b(je,h);}catch(Mo){f(Mo,"Erro ao converter para WebP");}let Je=je;Je.id=m,u(Je);}else u(null);},"image/png")):u(null);},A.src=x;}),ue=async()=>{if(!(!R||!U||E.length===0)){w(!0);try{let m=E[0],u=await ge(m.id);if(u){let F=await i([u]);F&&(!e$1&&!o&&g(A=>[...A,...F]),e$1?.([...a||[],...F]),o?.(u));}C(!1),w(!1),S(""),B(null);let b=E.slice(1);O(b),oe(b);}catch(m){f(m,"Erro ao processar imagem"),w(!1);}}},Z=()=>{C(!1),w(!1),S(""),B(null),O([]),j(0),ee(0);},X=async m=>{if(m.length===0)return;let u=Object.keys(n?.accept||{}).some(F=>F.includes("image/")),b=D.length+m.length;if(c$1&&b>c$1){f(new Error(`M\xE1ximo de ${c$1} arquivos`),"Erro ao fazer upload");return}try{if(u&&p){let A=m.filter(z=>z.type.startsWith("image/")).map((z,pe)=>{let Re=z;return Re.id=`temp-crop-${Date.now()}-${pe}`,Re});ee(A.length),j(0),O(A),oe(A);}else {let F=[];for(let z of m)if(z.type.startsWith("image/")&&d)try{let pe=await c(z,h,v,P);F.push(pe);}catch(pe){f(pe,"Erro ao comprimir imagem"),F.push(z);}else F.push(z);let A=await i(F);A&&(!e$1&&!o&&g(z=>[...z,...A]),e$1?.([...a||[],...A]),o?.(A[0]));}}catch(F){f(F,"Erro ao processar arquivos");}},V=m=>{if(!m.length)return;let u=m[0]?.errors[0]?.code,b=n?.maxSize||3145728;f(u==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(b)}`):u==="file-invalid-type"?new Error("Formato de arquivo n\xE3o suportado"):m[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},{getRootProps:re,getInputProps:$,isDragActive:te,isDragReject:fe,fileRejections:ie}=useDropzone({onDrop:X,onDropRejected:V,...n}),Fe=m=>{if(!m){t||g([]),t?.(void 0);return}let u=D.filter(b=>b.id!==m.id);t||g(u),t?.(m);},H=(m,u,b)=>{r?.(m,u,b);},xe=useRef("");return useEffect(()=>{let m=a?.map(u=>u.id).join(",")||"";m!==xe.current&&(xe.current=m,g(a||[]));},[a]),{file:D?.[0],files:D,aspectRatio:T,dropzoneProps:{getRootProps:re,getInputProps:$,isDragActive:te,isDragReject:fe,fileRejections:ie},cropState:{cropModalOpen:k,imagePreview:x,cropLoading:M,setCropModalOpen:C,onCropInitialized:le,handleCropSave:ue,handleCropCancel:Z,currentImageIndex:G,totalPendingImages:se},setInitialFiles:g,handleRemove:Fe,handleReorder:H}},K=Nr;var Kr=({sx:e,id:o,name:r,tabIndex:t,uploading:i,getRootProps:a,getInputProps:n,isDragActive:p,isError:s,disabled:d,dropZoneSxProps:l,dropZoneContent:c,children:h,...v})=>jsxs(Be,{children:[i&&jsx(a$7,{"data-testid":"uploading-progress-bar",sx:{zIndex:1}}),jsxs(Ee,{sx:{width:1,position:"relative",...e},children:[jsxs(io,{...a(),"data-testid":"drop-zone-styled-area",isError:s,isDragActive:p,disabled:!!d,sx:l,...v,children:[jsx("input",{...n(),id:o,tabIndex:t,name:r}),c]}),h]})]}),de=Kr;var Vr=({header:e,description:o,sx:r,...t})=>jsxs(he,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...t,children:[jsx(a$5,{sx:{width:220}}),jsxs("div",{children:[jsx(Ke,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(Ke,{variant:"body2",sx:{color:"text.secondary"},children:o||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(Ke,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),me=memo(Vr);var ot=({onRemove:e,onReorder:o,onFilesSelect:r,createFilesMutation:t,filesDetails:i=[],id:a,disabled:n,error:p,helperText:s,thumbnail:d,dropZoneSxProps:l,uploading:c,tabIndex:h$1,maxFiles:v,placeholderAlt:P,placeholderProps:f,...T})=>{let{filesPreview:D,isUploadOrLoadingFiles:g,uploadErrorText:k,uploadFiles:C}=h({createFilesMutation:t,filesDetails:i}),{files:R,dropzoneProps:B,handleRemove:U,handleReorder:L}=K({onFilesSelect:r,onReorder:o,onRemove:e,filesPreview:D,dropzoneOptions:{multiple:!0,disabled:n,...T},maxFiles:v,uploadFiles:C}),{getRootProps:x,getInputProps:S,isDragActive:M,isDragReject:w}=B,E=!!R?.filter(G=>!!G.id).length,O=w||!!p||!!k;return jsxs(de,{id:a,uploading:c||g,disabled:n,dropZoneSxProps:l,tabIndex:h$1,getRootProps:x,getInputProps:S,isDragActive:M,isError:O,dropZoneContent:jsx(Fragment,{children:P?jsx(he,{children:P}):jsx(me,{header:f?.header,description:f?.description})}),children:[jsx(I,{disabled:n,helperText:s,isError:O}),p?jsx(I,{helperText:p,isError:!0}):null,k?jsx(I,{helperText:k,isError:!0}):null,E&&jsx(Ee,{sx:{my:3},children:jsx(De,{files:R,thumbnail:!!d,onRemove:e?U:void 0,onReorder:o?L:void 0})})]})},rt=memo(ot);var pt=({onRemove:e,onReorder:o,onFilesSelect:r,createFilesMutation:t,filesDetails:i=[],id:a,disabled:n,error:p,helperText:s,dropZoneSxProps:d,placeholderProps:l,placeholderAlt:c,uploading:h$1,tabIndex:v,maxFiles:P,aspectRatio:f,enableCrop:T=!0,convertToWebp:D=!0,cropSize:g,name:k,label:C,...R})=>{let{filesPreview:B,isUploadOrLoadingFiles:U,uploadErrorText:L,uploadFiles:x}=h({createFilesMutation:t,filesDetails:i}),S=h$1||U,{files:M,dropzoneProps:w,cropState:E,aspectRatio:O,handleRemove:G,handleReorder:j}=K({onFilesSelect:r,onReorder:o,onRemove:e,filesPreview:B,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:n,...R},enableCrop:T,customAspectRatio:f,convertToWebp:D,maxFiles:P,cropSize:g,uploadFiles:x}),{getRootProps:se,getInputProps:ee,isDragActive:oe,isDragReject:le}=w,{cropModalOpen:ge,imagePreview:ue,cropLoading:Z,onCropInitialized:X,handleCropSave:V,handleCropCancel:re,currentImageIndex:$,totalPendingImages:te}=E,fe=!!M?.filter(H=>!!H.id).length,ie=le||!!p||!!L,Fe=useMemo(()=>{let H=C??"Ajustar Imagem",xe=te>1||$>1?` (${$} de ${te})`:"";return `${H}${xe}`},[C,te,$]);return jsxs(de,{id:a,name:k,uploading:S,disabled:n,dropZoneSxProps:d,tabIndex:v,getRootProps:se,getInputProps:ee,isDragActive:oe,isError:ie,dropZoneContent:jsx(Fragment,{children:c?jsx(he,{children:c}):jsx(me,{header:l?.header,description:l?.description})}),children:[jsx(I,{disabled:n,helperText:s,isError:ie}),p?jsx(I,{helperText:p,isError:!0}):null,L?jsx(I,{helperText:L,isError:!0}):null,fe&&jsx(Ee,{sx:{my:3,ml:.5},children:jsx(De,{files:M,thumbnail:!0,onRemove:G,onReorder:o?j:void 0})}),jsx(a$6,{open:ge,onClose:re,label:Fe,imageSrc:ue,aspectRatio:O,onInitialized:X,onSave:V,loading:Z,cropSize:g})]})},dt=memo(pt);var xt=({onFileSelect:e$1,onRemove:o,createFilesMutation:r,fileDetails:t,id:i,disabled:a,error:n,helperText:p,sx:s,dropZoneSxProps:d,uploading:l,tabIndex:c,...h$1})=>{let{filesPreview:v,isUploadOrLoadingFiles:P,uploadErrorText:f,uploadFiles:T}=h({createFilesMutation:r,filesDetails:t?[t]:[]}),D=P||l,{file:g,dropzoneProps:k,handleRemove:C}=K({uploadFiles:T,onFileSelect:e$1,onRemove:o,filesPreview:v,dropzoneOptions:{multiple:!1,disabled:a,...h$1}}),{getRootProps:R,getInputProps:B,isDragActive:U,isDragReject:L}=k,x=useCallback(E=>{E.stopPropagation(),C(g||void 0);},[g,C]),S=!!g,M=typeof g=="string",w=L||!!n||!!f;return jsxs(de,{id:i,uploading:D,disabled:a,dropZoneSxProps:d,tabIndex:c,getRootProps:R,getInputProps:B,isDragActive:U,isError:w,dropZoneContent:jsxs(Fragment,{children:[!S&&jsx(me,{}),S&&jsxs(he,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:E=>`solid 1px ${E.palette.divider}`,...s},children:[jsx(Pe,{file:g}),jsxs(he,{flexGrow:1,sx:{minWidth:0},children:[jsx(Ke,{variant:"subtitle2",noWrap:!0,children:M?g:g.name}),jsx(Ke,{variant:"caption",sx:{color:"text.secondary"},children:M?"":e(g.size)})]}),o&&jsx(a$3,{title:"Remover arquivo",children:jsx(ao,{edge:"end",size:"small",disabled:a,"aria-label":"Remover arquivo",onClick:x,children:jsx(a$4,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:[jsx(I,{disabled:a,helperText:p,isError:w}),n?jsx(I,{helperText:n,isError:!0}):null,f?jsx(I,{helperText:f,isError:!0}):null]})},ht=memo(xt);var Ft=({onRemove:e,onFileSelect:o,createFilesMutation:r,fileDetails:t,id:i,disabled:a,error:n,helperText:p,dropZoneSxProps:s,placeholderProps:d,placeholderAlt:l,uploading:c,tabIndex:h$1,aspectRatio:v,enableCrop:P=!0,convertToWebp:f=!0,name:T,label:D,cropSize:g,sx:k,maxWidth:C,maxHeight:R,compressionQuality:B=.8,maxCompressedWidth:U,maxCompressedHeight:L,...x})=>{let{filesPreview:S,isUploadOrLoadingFiles:M,uploadErrorText:w,uploadFiles:E}=h({createFilesMutation:r,filesDetails:t?[t]:[]}),[O,G]=useState(!1),{file:j,dropzoneProps:se,cropState:ee,handleRemove:oe,aspectRatio:le}=K({onFileSelect:o,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,...x},filesPreview:S,enableCrop:P,customAspectRatio:v,convertToWebp:f,cropSize:g,uploadFiles:E,compressionQuality:B,maxCompressedWidth:U,maxCompressedHeight:L}),{getRootProps:ge,getInputProps:ue,isDragActive:Z,isDragReject:X}=se,{cropModalOpen:V,imagePreview:re,cropLoading:$,onCropInitialized:te,handleCropSave:fe,handleCropCancel:ie}=ee,Fe=useCallback(()=>{oe(j||void 0);},[j,oe]),H=!!j,xe=X||!!n||!!w,m=c||M,u=H?{opacity:0}:{opacity:1},b=s?.width;return useEffect(()=>{H||G(!1);},[H]),jsxs(Be,{sx:{...k,...b&&{width:b}},children:[(m||O)&&jsx(a$7,{}),jsxs(de,{id:i,uploading:m,disabled:a,dropZoneSxProps:s,tabIndex:h$1,getRootProps:ge,getInputProps:ue,isDragActive:Z,isError:xe,name:T,dropZoneContent:jsxs(Fragment,{children:[l?jsx(he,{sx:u,children:l}):jsx(me,{sx:u,header:d?.title,description:d?.description}),H&&jsx(He,{file:j,cropSize:g,isLoading:O,isUploading:m,onLoading:G,aspectRatio:le,maxWidth:C,maxHeight:R})]}),children:[jsx(I,{disabled:a,helperText:p,isError:xe}),n?jsx(I,{helperText:n,isError:!0}):null,w?jsx(I,{helperText:w,isError:!0}):null,H&&e&&jsx(lo,{size:"small",onClick:Fe,disabled:a,label:"Remover arquivo",children:jsx(a$4,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$6,{open:V,onClose:ie,label:D??"Ajustar Imagem",imageSrc:re,aspectRatio:le,onInitialized:te,onSave:fe,loading:$,cropSize:g})]})]})},Ct=memo(Ft);var At=({onRemove:e,onFileSelect:o,createFilesMutation:r,fileDetails:t,disabled:i,label:a,id:n,tabIndex:p,error:s,helperText:d,sx:l,name:c,maxSize:h$1,uploading:v,aspectRatio:P=1,enableCrop:f=!0,convertToWebp:T=!0,cropSize:D,...g})=>{let[k,C]=useState(!1),{filesPreview:R,isUploadOrLoadingFiles:B,uploadErrorText:U,uploadFiles:L}=h({createFilesMutation:r,filesDetails:t?[t]:[]}),{file:x,dropzoneProps:S,cropState:M,handleRemove:w}=K({filesPreview:R,onFileSelect:o,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,maxSize:h$1,...g},enableCrop:f,customAspectRatio:P,convertToWebp:T,cropSize:D,uploadFiles:L}),{getRootProps:E,getInputProps:O,isDragActive:G,isDragReject:j}=S,{cropModalOpen:se,imagePreview:ee,cropLoading:oe,onCropInitialized:le,handleCropSave:ge,handleCropCancel:ue}=M,Z=j||!!s||!!U,X=k||B||v,V=!!e,re=useRef(t?.url||""),$=useRef();useEffect(()=>{if(!x){re.current="",$.current=void 0;return}if($.current===x.id)return;$.current=x.id,C(!0);let ie=URL.createObjectURL(x);return re.current=ie,()=>{URL.revokeObjectURL(ie);}},[x]);let te=()=>{C(!1);},fe=useCallback(()=>V&&x?()=>w(x):E().onClick,[V,x,E,w]);return jsxs(Fragment,{children:[jsxs(he,{sx:{alignItems:"center"},children:[jsxs(xo,{sx:l,isError:Z,isDragActive:G,hasFile:!!x,...E(),onClick:fe(),children:[jsxs(uo,{children:[X&&jsx(fo,{children:jsx(St,{size:135,thickness:2,color:"primary"})}),x&&jsx(ho,{alt:"Avatar Preview",src:re.current,onLoad:te,...X&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),!x&&!X&&jsxs($e,{isError:Z,hasFile:!1,children:[jsx(a$4,{icon:"ADD_IMAGE",width:32}),jsx(Ke,{variant:"caption",textAlign:"center",sx:{color:Z?"error.main":"text.disabled"},children:"Adicionar foto"})]}),x&&!X&&jsxs($e,{isError:Z,hasFile:!0,children:[jsx(a$4,{icon:V?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(Ke,{variant:"caption",textAlign:"center",sx:{color:Z?"error.main":"common.white"},children:V?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:c,id:n,tabIndex:p,...O()})]}),jsx(he,{sx:{alignItems:"center",mt:-.5},children:jsx(I,{helperText:d,disabled:i,isError:Z})}),U?jsx(I,{helperText:U,isError:!0}):null,s?jsx(I,{helperText:s,isError:!0}):null]}),se&&ee&&jsx(a$6,{open:se,onClose:ue,label:a??"Ajustar Imagem",imageSrc:ee,aspectRatio:P,onInitialized:le,onSave:ge,loading:oe,cropSize:D,cropShape:"round"})]})},_t=memo(At);var Mt=({error:e,name:o,disabled:r,sx:t,...i})=>{let{getRootProps:a,getInputProps:n,isDragActive:p,isDragReject:s}=useDropzone({disabled:r,...i}),d=s||e;return jsxs(po,{...a(),isDragActive:p,hasError:!!d,disabled:!!r,sx:t,"data-testid":"upload-box",children:[jsx("input",{name:o,...n()}),"Selecionar arquivo"]})},Ot=memo(Mt);
37
+ var $o=({helperText:e,disabled:o,isError:r})=>e?jsx(Ho,{error:r,sx:t=>({mx:"14px",color:o?t.palette.grey[500]:void 0}),children:e}):null,O=memo($o);var Me=styled(he)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),ke=styled(he)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),ao=styled(De,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:o,isError:r,disabled:t})=>({outline:"none",cursor:"pointer",overflow:"hidden",position:"relative",padding:e.spacing(5),borderRadius:e.shape.borderRadius,transition:e.transitions.create("padding"),backgroundColor:e.palette.background.neutral,border:`dashed 1px ${e.palette.divider}`,...o&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...t&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(he)(({theme:e})=>({display:"none",position:"absolute",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:12,width:"100%",height:"100%",backgroundColor:alpha(e.palette.primary.main,.9),zIndex:999,button:{"&, &:hover, &:focus":{backgroundColor:e.palette.background.paper}}}));var no=styled(qo)(({theme:e})=>({position:"relative",zIndex:999,pointerEvents:"auto",color:e.palette.grey[700],backgroundColor:e.palette.grey[100],"&:hover":{color:e.palette.grey[900],backgroundColor:e.palette.grey[300]}})),He=styled("div")({position:"relative",zIndex:1,userSelect:"none","&:hover":{zIndex:2}}),so=styled(he,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:o,isDragging:r})=>({width:o,height:100,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2,1,2,1),gap:e.spacing(1),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),lo=styled(m.div)(({theme:e,width:o,isDragging:r})=>({width:o,height:60,alignItems:"center",display:"inline-flex",justifyContent:"center",margin:e.spacing(.5),padding:e.spacing(2),borderRadius:e.spacing(1.25),overflow:"hidden",position:"relative",border:`solid 1px ${e.palette.divider}`,backgroundColor:e.palette.common.white,zIndex:1,transition:"box-shadow 150ms ease-in-out",boxShadow:r?`0 0 0 2px ${e.palette.primary.main}, ${e.customShadows.z8}, inset 0 0 0 1000px ${alpha(e.palette.primary.main,.06)}`:"0px 0px 0px 0px rgba(0, 0, 0, 0)"})),po=styled(a)(({theme:e})=>({top:16,right:16,zIndex:9,position:"absolute",color:e.palette.common.white,backgroundColor:alpha(e.palette.grey[900],.72),"&:hover":{backgroundColor:alpha(e.palette.grey[900],.48)}})),mo=styled(De,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:o,disabled:r,hasError:t})=>({width:64,height:64,flexShrink:0,display:"flex",borderRadius:1,cursor:"pointer",alignItems:"center",color:e.palette.text.disabled,justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),border:`dashed 1px ${alpha(e.palette.grey[500],.16)}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...t&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),co=styled(De)(({theme:e})=>({padding:e.spacing(1),top:0,left:0,width:"100%",height:"100%",position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",transition:"all 0.3s ease-in-out",filter:"blur(0)","&:hover":{filter:"blur(3px)"}})),go=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"&&e!=="maxWidth"&&e!=="maxHeight"&&e!=="cropSize"})(({theme:e,aspectRatio:o,maxWidth:r,maxHeight:t,isLoading:n,isUploading:s})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,maxWidth:r,maxHeight:t,backgroundColor:e.palette.background.paper,aspectRatio:Math.abs(o),...Math.abs(o)>1?{width:"calc(100% - 16px)",height:void 0}:{width:void 0,height:"calc(100% - 16px)"},transition:"all 0.5s ease-in-out",...n||s?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),uo=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:o})=>({width:"100%",height:"100%",objectFit:"cover",top:0,left:0,filter:"blur(1.5rem)",transform:"scale(1.1)",position:"absolute",zIndex:0,transition:"opacity 0.3s ease-in-out",...e&&{opacity:0},...o&&{opacity:.7,filter:"blur(2rem)"}})),fo=styled(he)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Vo)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var $e=styled(De,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:o,hasFile:r})=>({top:0,gap:e.spacing(1),left:0,width:"100%",height:"100%",zIndex:9,display:"flex",borderRadius:"50%",position:"absolute",alignItems:"center",color:e.palette.text.disabled,flexDirection:"column",justifyContent:"center",backgroundColor:alpha(e.palette.grey[500],.08),transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.shorter}),"&:hover":{opacity:.92},...o&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),xo=styled(he)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center",opacity:.8});styled(he)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.divider,color:e.palette.text.disabled,height:160}));var ho=styled(De,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:o,disabled:r,isError:t,hasFile:n})=>({padding:e.spacing(1),margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${e.palette.divider}`,...o&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...t&&{borderColor:"error.main"},...n&&{...t&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),bo=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),Io=styled(a)(({theme:e})=>({backgroundColor:alpha(e.palette.grey[900],.72),color:e.palette.common.white,"&:hover":{backgroundColor:alpha(e.palette.grey[600],.64),color:e.palette.common.white},"& svg":{width:14,height:14}}));var Yo=({onRemove:e,sx:o,file:r,disableDrag:t,attributes:n,listeners:s,innerWidth:i,isDragging:d})=>{let p=r?.id;return p?jsx(Qo,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(lo,{width:i,isDragging:d,"data-testid":`preview-multi-img-${p}`,...j().inUp,sx:o,children:[jsx(a$2,{disableDrag:t,...n,...s}),jsx(Ee,{imageView:!0,file:r}),jsx(ke,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(Io,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${p}`):null},Po=memo(Yo);var ir=({file:e$1,thumbnail:o,onRemove:r,sx:t,disableDrag:n=!1})=>{let s=e$1.size||0,i=e$1.name||e$1.id,d=e$1.id,p=typeof e$1=="string",m=n?70:80,{attributes:l,listeners:u,setNodeRef:b,transform:F,transition:R,isDragging:I}=useSortable({id:d,disabled:n}),C={transform:x.Transform.toString(F),transition:R,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${m+8}px`,height:"68px"};return o&&e$1?jsx(He,{ref:b,style:C,children:jsx(Po,{innerWidth:m,isDragging:I,sx:t,file:e$1,disableDrag:n,attributes:l,listeners:u,onRemove:r})}):jsx(He,{ref:b,style:{...C,height:"80px",width:`${m+38}px`},children:jsxs(so,{width:m+30,isDragging:I,"data-testid":`preview-multi-img-${d}`,...j().inUp,sx:t,children:[jsx(a$2,{disableDrag:n,...l,...u}),e$1&&jsx(Ee,{file:e$1}),jsxs(he,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:i,children:jsx(Je,{variant:"subtitle2",noWrap:!0,children:i})}),jsx(Je,{variant:"caption",sx:{color:"text.secondary"},children:p?"":e(s)})]}),jsx(ke,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},Fo=memo(ir);var Ir=({thumbnail:e,files:o,onRemove:r,onReorder:t,sx:n})=>{let s=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),i=useCallback(p=>{let{active:m,over:l}=p;if(!(!m||!l||m.id===l.id)&&t){let u=o.findIndex(({id:F})=>F===m.id),b=o.findIndex(({id:F})=>F===l.id);u!==-1&&b!==-1&&t(u,b,o);}},[o,t]),d=jsx(AnimatePresence,{initial:!1,children:o.map(p=>jsx(Fo,{sx:n,id:`preview-file-${p.id}`,file:p,onRemove:r,thumbnail:e,disableDrag:!t},`preview-file-${p.id}`))});return t?jsx(DndContext,{sensors:s,collisionDetection:closestCenter,onDragEnd:i,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:o.map(p=>p.id),strategy:horizontalListSortingStrategy,children:d})}):d},_e=memo(Ir);var Ao=forwardRef(({onLoading:e,aspectRatio:o,cropSize:r,...t},n)=>{let{maxWidth:s,maxHeight:i}=useMemo(()=>r&&typeof r=="object"?{maxWidth:r.width,maxHeight:r.height}:r&&typeof r=="number"?{maxWidth:r,maxHeight:r}:{maxWidth:"100%",maxHeight:"100%"},[r]);a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof n=="object"&&n?.current?e?.(!n.current.complete):e?.(!1);},[n,e]);function d(){e?.(!1);}return jsx(go,{...t,maxWidth:s,maxHeight:i,ref:n,aspectRatio:o,onLoad:d,onError:d})});Ao.displayName="LoadingPreviewImage";var Do=Ao;var Dr=({file:e,aspectRatio:o=1,isUploading:r,isLoading:t,onLoading:n,cropSize:s,maxWidth:i,maxHeight:d})=>{let p=useRef(null),m=e?.id||"",l=e?.name||"",u=URL.createObjectURL(e);return m?jsxs(co,{className:"single-file-preview-box",children:[jsx(Do,{className:"single-file-preview-img",aspectRatio:o,cropSize:s,isLoading:t,isUploading:r,alt:l,src:u,ref:p,loading:"lazy",onLoading:n,onLoad:()=>n?.(!1),onError:()=>n?.(!1),maxWidth:i,maxHeight:d},`image-preview-${m}`),jsx(uo,{className:"single-file-preview-bg",alt:l,src:u,isLoading:t,isUploading:r})]}):null},Xe=memo(Dr);var _r=["pdf"],Sr=["txt"],Tr=["psd"],Or=["doc","docx"],Ur=["xls","xlsx"],yr=["zip","rar","iso"],Cr=["ai","eps"],Lr=["ppt","pptx"],Mr=["wav","aif","mp3","aac"],kr=["jpg","jpeg","gif","bmp","png","svg","webp"],zr=["m4v","avi","mpg","mp4","webm"];function qe(e){let o,r=_o(e);return Sr.includes(r)?o="txt":yr.includes(r)?o="zip":Mr.includes(r)?o="audio":kr.includes(r)?o="image":zr.includes(r)?o="video":Or.includes(r)?o="word":Ur.includes(r)?o="excel":Lr.includes(r)?o="powerpoint":_r.includes(r)?o="pdf":Tr.includes(r)?o="photoshop":Cr.includes(r)?o="illustrator":e?.startsWith("http")?o="image":o=_o(e),o}function So(e){let o;switch(qe(e)){case"folder":o="IC_FOLDER";break;case"txt":o="IC_TXT";break;case"zip":o="IC_ZIP";break;case"audio":o="IC_AUDIO";break;case"video":o="IC_VIDEO";break;case"word":o="IC_WORD";break;case"excel":o="IC_EXCEL";break;case"powerpoint":o="IC_POWER_POINT";break;case"pdf":o="IC_PDF";break;case"photoshop":o="IC_PTS";break;case"illustrator":o="IC_AI";break;case"image":o="IC_IMG";break;default:o="IC_FILE";}return o}function _o(e){return e&&e.split(".").pop()||""}function ea(e){return e.split("/").pop()}var Ne={root:"mnl__file__thumbnail__root",img:"mnl__file__thumbnail__img",icon:"mnl__file__thumbnail__icon",removeBtn:"mnl__file__thumbnail__remove__button",downloadBtn:"mnl__file__thumbnail__download__button"},Ee=({sx:e,file:o,tooltip:r,onRemove:t,imageView:n,slotProps:s,onDownload:i,...d})=>{let p=URL.createObjectURL(o),m=o?.name||"",u=o.type.startsWith("image/")?"image":qe(p),b=jsx(De,{component:"img",src:p,className:Ne.img,sx:{width:1,height:1,objectFit:"cover",borderRadius:"inherit",...s?.img}}),F=jsx(a$4,{icon:So(u),sx:{width:32,height:32,flexShrink:0,...e}}),R=jsxs(he,{component:"span",className:Ne.root,sx:{width:36,height:36,flexShrink:0,borderRadius:1.25,alignItems:"center",position:"relative",display:"inline-flex",justifyContent:"center",...e},...d,children:[u==="image"&&n?b:F,t&&jsx(Br,{onClick:t,className:Ne.removeBtn,sx:s?.removeBtn,children:jsx(a$4,{icon:"CLOSE_MARK_BUTTON",width:24})}),i&&jsx(qo,{onClick:i,className:Ne.downloadBtn,sx:s?.downloadBtn,size:"small",children:jsx(a$4,{icon:"ARROW_DOWN_CICLE",width:12})})]});return r?jsx(jr,{arrow:!0,title:m,slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,-12]}}]}},children:R}):R};var ma=e=>e.startsWith("image/"),To=(e,o=.8)=>new Promise((r,t)=>{let n=document.createElement("canvas"),s=n.getContext("2d"),i=new Image;i.onload=()=>{n.width=i.width,n.height=i.height,s?(s.drawImage(i,0,0),n.toBlob(d=>{if(d){let p=new File([d],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(p);}else t(new Error("Falha ao converter para WebP"));},"image/webp",o)):t(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},i.onerror=()=>t(new Error("Falha ao carregar imagem")),i.src=URL.createObjectURL(e);}),Oo=(e,o=.8,r,t)=>new Promise((n,s)=>{let i=document.createElement("canvas"),d=i.getContext("2d"),p=new Image;p.onload=()=>{let{width:m,height:l}=p;r&&m>r&&(l=l*r/m,m=r),t&&l>t&&(m=m*t/l,l=t),i.width=m,i.height=l,d?(d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(p,0,0,m,l),i.toBlob(u=>{if(u){let b=new File([u],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});n(b);}else s(new Error("Falha ao comprimir imagem"));},"image/webp",o)):s(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},p.onerror=()=>s(new Error("Falha ao carregar imagem")),p.src=URL.createObjectURL(e);}),Uo=e=>{let o=e.match(/filename\*=UTF-8''([^;]+)|filename="?([^";]+)"?/i);return o?.[1]||o?.[2]||""},yo=e=>`UTF-8''${encodeURIComponent(e)}`;var Vr=({onFilesSelect:e$1,onFileSelect:o,onReorder:r,onRemove:t,uploadFiles:n,filesPreview:s,dropzoneOptions:i,enableCrop:d=!1,customAspectRatio:p,convertToWebp:m=!0,cropSize:l,maxFiles:u,compressionQuality:b=.8,maxCompressedWidth:F,maxCompressedHeight:R})=>{let{showErrorMessage:I}=a$8(),C=useMemo(()=>p||(l&&typeof l!="number"?l.width/l.height:1),[p,l]),[v,c]=useState([]),[E,w]=useState(!1),[_,L]=useState(null),[f,h]=useState(null),[g,A]=useState(""),[M,S]=useState(!1),[T,N]=useState([]),[V,G]=useState(0),[se,oe]=useState(0),re=x=>{if(x.length<1)return;let P=x[0];L(P),G(y=>y+1);let D=new FileReader;D.onload=()=>{A(D.result),w(!0);},D.readAsDataURL(P);},le=(x,P)=>{h(P);},ge=async x=>!_||!f?null:new Promise(P=>{let D=document.createElement("canvas"),y=D.getContext("2d"),k=new Image;k.onload=async()=>{let{width:B,height:pe,x:Se,y:Wo}=f,Go=Math.abs(C),Te=B,Oe=pe;l&&typeof l=="object"?(Te=l.width,Oe=l.height):l&&typeof l=="number"&&(Te=l,Oe=l/Go),D.width=Te,D.height=Oe,y?(y.drawImage(k,Se,Wo,B,pe,0,0,Te,Oe),D.toBlob(async eo=>{if(eo){let Ze=new File([eo],_.name,{type:_.type,lastModified:Date.now()});if(m)try{Ze=await To(Ze,b);}catch(jo){I(jo,"Erro ao converter para WebP");}let oo=Ze;oo.id=x,P(oo);}else P(null);},"image/png")):P(null);},k.src=g;}),ue=async()=>{if(!(!_||!f||T.length===0)){S(!0);try{let x=T[0],P=await ge(x.id);if(P){let y=await n([P]);y&&(!e$1&&!o&&c(k=>[...k,...y]),e$1?.([...s||[],...y]),o?.(P));}w(!1),S(!1),A(""),L(null);let D=T.slice(1);N(D),re(D);}catch(x){I(x,"Erro ao processar imagem"),S(!1);}}},j=()=>{w(!1),S(!1),A(""),L(null),N([]),G(0),oe(0);},K=async x=>{if(x.length===0)return;let P=Object.keys(i?.accept||{}).some(y=>y.includes("image/")),D=v.length+x.length;if(u&&D>u){I(new Error(`M\xE1ximo de ${u} arquivos`),"Erro ao fazer upload");return}try{if(P&&d){let k=x.filter(B=>B.type.startsWith("image/")).map((B,pe)=>{let Se=B;return Se.id=`temp-crop-${Date.now()}-${pe}`,Se});oe(k.length),G(0),N(k),re(k);}else {let y=[];for(let B of x)if(B.type.startsWith("image/")&&m)try{let pe=await Oo(B,b,F,R);y.push(pe);}catch(pe){I(pe,"Erro ao comprimir imagem"),y.push(B);}else y.push(B);let k=await n(y);k&&(!e$1&&!o&&c(B=>[...B,...k]),e$1?.([...s||[],...k]),o?.(k[0]));}}catch(y){I(y,"Erro ao processar arquivos");}},J=x=>{if(!x.length)return;let P=x[0]?.errors[0]?.code,D=i?.maxSize||3145728;I(P==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(D)}`):P==="file-invalid-type"?new Error("Formato de arquivo n\xE3o suportado"):x[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},{getRootProps:te,getInputProps:Z,isDragActive:a,isDragReject:fe,fileRejections:ie}=useDropzone({onDrop:K,onDropRejected:J,...i}),we=x=>{if(!x){t||c([]),t?.(void 0);return}let P=v.filter(D=>D.id!==x.id);t||c(P),t?.(x);},H=(x,P,D)=>{r?.(x,P,D);},xe=useRef("");return useEffect(()=>{let x=s?.map(P=>P.id).join(",")||"";x!==xe.current&&(xe.current=x,c(s||[]));},[s]),{file:v?.[0],files:v,aspectRatio:C,dropzoneProps:{getRootProps:te,getInputProps:Z,isDragActive:a,isDragReject:fe,fileRejections:ie},cropState:{cropModalOpen:E,imagePreview:g,cropLoading:M,setCropModalOpen:w,onCropInitialized:le,handleCropSave:ue,handleCropCancel:j,currentImageIndex:V,totalPendingImages:se},setInitialFiles:c,handleRemove:we,handleReorder:H}},X=Vr;var Ve=(a=>(a.APPLICATION_OCTET_STREAM="application/octet-stream",a.IMAGE_JPEG="image/jpeg",a.IMAGE_JPG="image/jpg",a.IMAGE_PNG="image/png",a.IMAGE_GIF="image/gif",a.IMAGE_WEBP="image/webp",a.IMAGE_SVG="image/svg+xml",a.IMAGE_BMP="image/bmp",a.IMAGE_TIFF="image/tiff",a.IMAGE_ICO="image/x-icon",a.IMAGE_AVIF="image/avif",a.APPLICATION_PDF="application/pdf",a.TEXT_PLAIN="text/plain",a.TEXT_CSV="text/csv",a.APPLICATION_RTF="application/rtf",a.APPLICATION_MSWORD="application/msword",a.APPLICATION_DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",a.APPLICATION_MSEXCEL="application/vnd.ms-excel",a.APPLICATION_XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",a.APPLICATION_MSPOWERPOINT="application/vnd.ms-powerpoint",a.APPLICATION_PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",a.APPLICATION_ODT="application/vnd.oasis.opendocument.text",a.APPLICATION_ODS="application/vnd.oasis.opendocument.spreadsheet",a.APPLICATION_ODP="application/vnd.oasis.opendocument.presentation",a.APPLICATION_XML="application/xml",a.TEXT_XML="text/xml",a.TEXT_HTML="text/html",a.TEXT_CSS="text/css",a.APPLICATION_JSON="application/json",a.TEXT_JAVASCRIPT="text/javascript",a.APPLICATION_ZIP="application/zip",a.APPLICATION_GZIP="application/gzip",a.APPLICATION_RAR="application/vnd.rar",a.APPLICATION_7Z="application/x-7z-compressed",a.AUDIO_MPEG="audio/mpeg",a.AUDIO_WAV="audio/wav",a.AUDIO_OGG="audio/ogg",a.AUDIO_WEBM="audio/webm",a.AUDIO_AAC="audio/aac",a.VIDEO_MP4="video/mp4",a.VIDEO_MPEG="video/mpeg",a.VIDEO_OGG="video/ogg",a.VIDEO_WEBM="video/webm",a.VIDEO_QUICKTIME="video/quicktime",a))(Ve||{}),Be=(e=>(e["application/octet-stream"]="APPLICATION_OCTET_STREAM",e["image/jpeg"]="IMAGE_JPEG",e["image/jpg"]="IMAGE_JPG",e["image/png"]="IMAGE_PNG",e["image/gif"]="IMAGE_GIF",e["image/webp"]="IMAGE_WEBP",e["image/svg+xml"]="IMAGE_SVG",e["image/bmp"]="IMAGE_BMP",e["image/tiff"]="IMAGE_TIFF",e["image/x-icon"]="IMAGE_ICO",e["image/avif"]="IMAGE_AVIF",e["application/pdf"]="APPLICATION_PDF",e["text/plain"]="TEXT_PLAIN",e["text/csv"]="TEXT_CSV",e["application/rtf"]="APPLICATION_RTF",e["application/msword"]="APPLICATION_MSWORD",e["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]="APPLICATION_DOCX",e["application/vnd.ms-excel"]="APPLICATION_MSEXCEL",e["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]="APPLICATION_XLSX",e["application/vnd.ms-powerpoint"]="APPLICATION_MSPOWERPOINT",e["application/vnd.openxmlformats-officedocument.presentationml.presentation"]="APPLICATION_PPTX",e["application/vnd.oasis.opendocument.text"]="APPLICATION_ODT",e["application/vnd.oasis.opendocument.spreadsheet"]="APPLICATION_ODS",e["application/vnd.oasis.opendocument.presentation"]="APPLICATION_ODP",e["application/xml"]="APPLICATION_XML",e["text/xml"]="TEXT_XML",e["text/html"]="TEXT_HTML",e["text/css"]="TEXT_CSS",e["application/json"]="APPLICATION_JSON",e["text/javascript"]="TEXT_JAVASCRIPT",e["application/zip"]="APPLICATION_ZIP",e["application/gzip"]="APPLICATION_GZIP",e["application/vnd.rar"]="APPLICATION_RAR",e["application/x-7z-compressed"]="APPLICATION_7Z",e["audio/mpeg"]="AUDIO_MPEG",e["audio/wav"]="AUDIO_WAV",e["audio/ogg"]="AUDIO_OGG",e["audio/webm"]="AUDIO_WEBM",e["audio/aac"]="AUDIO_AAC",e["video/mp4"]="VIDEO_MP4",e["video/mpeg"]="VIDEO_MPEG",e["video/ogg"]="VIDEO_OGG",e["video/webm"]="VIDEO_WEBM",e["video/quicktime"]="VIDEO_QUICKTIME",e))(Be||{});var Yr=({createFilesMutation:e,filesDetails:o})=>{let{showErrorMessage:r}=a$8(),[t,n]=useState(!1),[s,i]=useState(!1),[d,p]=useState(null),[m,l]=useState([]),u=useMemo(()=>m?.[0],[m]),b=s||t,F=useCallback(async v=>{if(!v.length){l([]),i(!1);return}i(!0);try{let E=(await Promise.all(v.map(async({url:w,id:_,name:L})=>{try{if(!w)return null;let f=await fetch(w);if(!f.ok)throw new Error(f.statusText);let h=await f.blob(),g=null;if(!L){let S=f.headers.get("content-disposition")||void 0;if(S){let T=Uo(S);if(T)try{g=decodeURIComponent(T);}catch{g=T;}}}let A=g||L||_,M=new File([h],A,{type:h.type});return M.id=_,M.url=w,M}catch{return null}}))).filter(Boolean);l(E),i(!1);}catch(c){r(c,"Erro ao carregar arquivos"),l([]),i(!1);}},[r]),R=useRef("");useEffect(()=>{let v=o?.map(({id:c})=>c).join(",")||"";v!==R.current&&(async()=>(R.current=v,await F(o)))();},[o,F]);let I=async v=>{if(!v||!Array.isArray(v))throw new Error("Arquivos inv\xE1lidos");let c=v.filter(E=>E instanceof File);if(c?.length){n(!0);try{let E=c.map(f=>{let h=f.type||"application/octet-stream",g=Be[h];if(!g)throw new Error(`Tipo de arquivo n\xE3o suportado: ${h}`);return {file:f,mimeType:h,contentTypeEnum:g}}),w=await e({files:E.map(({file:f,contentTypeEnum:h})=>({content_type:h,name:f.name}))}).unwrap(),_=w.files.map((f,h)=>{let g=E[h].file,A=g;return A.id=f.id,A.url=URL.createObjectURL(g),A});return await(await Promise.all(w.files.map((f,h)=>{let{mimeType:g}=E[h],A=_[h];return fetch(f.url,{method:"PUT",headers:{"Content-Type":g,"Content-Disposition":`inline; filename*=${yo(A.name)}`,"X-File-Id":f.id},body:A})}))).forEach(async f=>{if(!f.ok)throw new Error("Erro no upload do arquivo.")}),_}catch(E){throw p(E),r(E,"Erro no upload"),E}finally{n(!1);}}},C=useMemo(()=>d&&d instanceof Error?d.message:d,[d]);return {setFilesPreview:l,uploadFiles:I,filesPreview:m,filePreview:u,isLoadingPreview:s,isUploadingFiles:t,isUploadOrLoadingFiles:b,uploadErrorText:C}},q=Yr;var ot=({sx:e,id:o,name:r,tabIndex:t,uploading:n,getRootProps:s,getInputProps:i,isDragActive:d,isError:p,disabled:m,dropZoneSxProps:l,dropZoneContent:u,children:b,...F})=>jsxs(Me,{children:[n&&jsx(a$7,{"data-testid":"uploading-progress-bar",sx:{zIndex:1}}),jsxs(De,{sx:{width:1,position:"relative",...e},children:[jsxs(ao,{...s(),"data-testid":"drop-zone-styled-area",isError:p,isDragActive:d,disabled:!!m,sx:l,...F,children:[jsx("input",{...i(),id:o,tabIndex:t,name:r}),u]}),b]})]}),de=ot;var it=({header:e,description:o,sx:r,...t})=>jsxs(he,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...t,children:[jsx(a$5,{sx:{width:220}}),jsxs("div",{children:[jsx(Je,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(Je,{variant:"body2",sx:{color:"text.secondary"},children:o||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(Je,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),me=memo(it);var pt=({onRemove:e,onReorder:o,onFilesSelect:r,createFilesMutation:t,filesDetails:n=[],id:s,disabled:i,error:d,helperText:p,thumbnail:m,dropZoneSxProps:l,uploading:u,tabIndex:b,maxFiles:F,placeholderAlt:R,placeholderProps:I,...C})=>{let{filesPreview:v,isUploadOrLoadingFiles:c,uploadErrorText:E,uploadFiles:w}=q({createFilesMutation:t,filesDetails:n}),{files:_,dropzoneProps:L,handleRemove:f,handleReorder:h}=X({onFilesSelect:r,onReorder:o,onRemove:e,filesPreview:v,dropzoneOptions:{multiple:!0,disabled:i,...C},maxFiles:F,uploadFiles:w}),{getRootProps:g,getInputProps:A,isDragActive:M,isDragReject:S}=L,T=!!_?.filter(V=>!!V.id).length,N=S||!!d||!!E;return jsxs(de,{id:s,uploading:u||c,disabled:i,dropZoneSxProps:l,tabIndex:b,getRootProps:g,getInputProps:A,isDragActive:M,isError:N,dropZoneContent:jsx(Fragment,{children:R?jsx(he,{children:R}):jsx(me,{header:I?.header,description:I?.description})}),children:[jsx(O,{disabled:i,helperText:p,isError:N}),d?jsx(O,{helperText:d,isError:!0}):null,E?jsx(O,{helperText:E,isError:!0}):null,T&&jsx(De,{sx:{my:3},children:jsx(_e,{files:_,thumbnail:!!m,onRemove:e?f:void 0,onReorder:o?h:void 0})})]})},dt=memo(pt);var ht=({onRemove:e,onReorder:o,onFilesSelect:r,createFilesMutation:t,filesDetails:n=[],id:s,disabled:i,error:d,helperText:p,dropZoneSxProps:m,placeholderProps:l,placeholderAlt:u,uploading:b,tabIndex:F,maxFiles:R,aspectRatio:I,enableCrop:C=!0,convertToWebp:v=!0,cropSize:c,name:E,label:w,..._})=>{let{filesPreview:L,isUploadOrLoadingFiles:f,uploadErrorText:h,uploadFiles:g}=q({createFilesMutation:t,filesDetails:n}),A=b||f,{files:M,dropzoneProps:S,cropState:T,aspectRatio:N,handleRemove:V,handleReorder:G}=X({onFilesSelect:r,onReorder:o,onRemove:e,filesPreview:L,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,..._},enableCrop:C,customAspectRatio:I,convertToWebp:v,maxFiles:R,cropSize:c,uploadFiles:g}),{getRootProps:se,getInputProps:oe,isDragActive:re,isDragReject:le}=S,{cropModalOpen:ge,imagePreview:ue,cropLoading:j,onCropInitialized:K,handleCropSave:J,handleCropCancel:te,currentImageIndex:Z,totalPendingImages:a}=T,fe=!!M?.filter(H=>!!H.id).length,ie=le||!!d||!!h,we=useMemo(()=>{let H=w??"Ajustar Imagem",xe=a>1||Z>1?` (${Z} de ${a})`:"";return `${H}${xe}`},[w,a,Z]);return jsxs(de,{id:s,name:E,uploading:A,disabled:i,dropZoneSxProps:m,tabIndex:F,getRootProps:se,getInputProps:oe,isDragActive:re,isError:ie,dropZoneContent:jsx(Fragment,{children:u?jsx(he,{children:u}):jsx(me,{header:l?.header,description:l?.description})}),children:[jsx(O,{disabled:i,helperText:p,isError:ie}),d?jsx(O,{helperText:d,isError:!0}):null,h?jsx(O,{helperText:h,isError:!0}):null,fe&&jsx(De,{sx:{my:3,ml:.5},children:jsx(_e,{files:M,thumbnail:!0,onRemove:V,onReorder:o?G:void 0})}),jsx(a$6,{open:ge,onClose:te,label:we,imageSrc:ue,aspectRatio:N,onInitialized:K,onSave:J,loading:j,cropSize:c})]})},bt=memo(ht);var wt=({onFileSelect:e$1,onRemove:o,createFilesMutation:r,fileDetails:t,id:n,disabled:s,error:i,helperText:d,sx:p,dropZoneSxProps:m$1,uploading:l,tabIndex:u,...b})=>{let{filesPreview:F,isUploadOrLoadingFiles:R,uploadErrorText:I,uploadFiles:C}=q({createFilesMutation:r,filesDetails:t?[t]:[]}),v=R||l,{file:c,dropzoneProps:E,handleRemove:w}=X({uploadFiles:C,onFileSelect:e$1,onRemove:o,filesPreview:F,dropzoneOptions:{multiple:!1,disabled:s,...b}}),{getRootProps:_,getInputProps:L,isDragActive:f,isDragReject:h}=E,g=useCallback(T=>{T.stopPropagation(),w(c||void 0);},[c,w]),A=!!c,M=typeof c=="string",S=h||!!i||!!I;return jsxs(de,{id:n,uploading:v,disabled:s,dropZoneSxProps:m$1,tabIndex:u,getRootProps:_,getInputProps:L,isDragActive:f,isError:S,dropZoneContent:jsxs(Fragment,{children:[!A&&jsx(me,{}),A&&jsxs(he,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:T=>`solid 1px ${T.palette.divider}`,...p},children:[jsx(Ee,{file:c}),jsxs(he,{flexGrow:1,sx:{minWidth:0},children:[jsx(Je,{variant:"subtitle2",noWrap:!0,children:M?c:c.name}),jsx(Je,{variant:"caption",sx:{color:"text.secondary"},children:M?"":e(c.size)})]}),o&&jsx(a$3,{title:"Remover arquivo",children:jsx(no,{edge:"end",size:"small",disabled:s,"aria-label":"Remover arquivo",onClick:g,children:jsx(a$4,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:[jsx(O,{disabled:s,helperText:d,isError:S}),i?jsx(O,{helperText:i,isError:!0}):null,I?jsx(O,{helperText:I,isError:!0}):null]})},At=memo(wt);var Ut=({onRemove:e,onFileSelect:o,createFilesMutation:r,fileDetails:t,id:n,disabled:s,error:i,helperText:d,dropZoneSxProps:p,placeholderProps:m,placeholderAlt:l,uploading:u,tabIndex:b,aspectRatio:F,enableCrop:R=!0,convertToWebp:I=!0,name:C,label:v,cropSize:c,sx:E,maxWidth:w,maxHeight:_,compressionQuality:L=.8,maxCompressedWidth:f,maxCompressedHeight:h,...g})=>{let{filesPreview:A,isUploadOrLoadingFiles:M,uploadErrorText:S,uploadFiles:T}=q({createFilesMutation:r,filesDetails:t?[t]:[]}),[N,V]=useState(!1),{file:G,dropzoneProps:se,cropState:oe,handleRemove:re,aspectRatio:le}=X({onFileSelect:o,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:s,...g},filesPreview:A,enableCrop:R,customAspectRatio:F,convertToWebp:I,cropSize:c,uploadFiles:T,compressionQuality:L,maxCompressedWidth:f,maxCompressedHeight:h}),{getRootProps:ge,getInputProps:ue,isDragActive:j,isDragReject:K}=se,{cropModalOpen:J,imagePreview:te,cropLoading:Z,onCropInitialized:a,handleCropSave:fe,handleCropCancel:ie}=oe,we=useCallback(()=>{re(G||void 0);},[G,re]),H=!!G,xe=K||!!i||!!S,x=u||M,P=H?{opacity:0}:{opacity:1},D=p?.width;return useEffect(()=>{H||V(!1);},[H]),jsxs(Me,{sx:{...E,...D&&{width:D}},children:[(x||N)&&jsx(a$7,{}),jsxs(de,{id:n,uploading:x,disabled:s,dropZoneSxProps:p,tabIndex:b,getRootProps:ge,getInputProps:ue,isDragActive:j,isError:xe,name:C,dropZoneContent:jsxs(Fragment,{children:[l?jsx(he,{sx:P,children:l}):jsx(me,{sx:P,header:m?.title,description:m?.description}),H&&jsx(Xe,{file:G,cropSize:c,isLoading:N,isUploading:x,onLoading:V,aspectRatio:le,maxWidth:w,maxHeight:_})]}),children:[jsx(O,{disabled:s,helperText:d,isError:xe}),i?jsx(O,{helperText:i,isError:!0}):null,S?jsx(O,{helperText:S,isError:!0}):null,H&&e&&jsx(po,{size:"small",onClick:we,disabled:s,label:"Remover arquivo",children:jsx(a$4,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$6,{open:J,onClose:ie,label:v??"Ajustar Imagem",imageSrc:te,aspectRatio:le,onInitialized:a,onSave:fe,loading:Z,cropSize:c})]})]})},yt=memo(Ut);var Bt=({onRemove:e,onFileSelect:o,createFilesMutation:r,fileDetails:t,disabled:n,label:s,id:i,tabIndex:d,error:p,helperText:m,sx:l,name:u,maxSize:b,uploading:F,aspectRatio:R=1,enableCrop:I=!0,convertToWebp:C=!0,cropSize:v,...c})=>{let[E,w]=useState(!1),{filesPreview:_,isUploadOrLoadingFiles:L,uploadErrorText:f,uploadFiles:h}=q({createFilesMutation:r,filesDetails:t?[t]:[]}),{file:g,dropzoneProps:A,cropState:M,handleRemove:S}=X({filesPreview:_,onFileSelect:o,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:n,maxSize:b,...c},enableCrop:I,customAspectRatio:R,convertToWebp:C,cropSize:v,uploadFiles:h}),{getRootProps:T,getInputProps:N,isDragActive:V,isDragReject:G}=A,{cropModalOpen:se,imagePreview:oe,cropLoading:re,onCropInitialized:le,handleCropSave:ge,handleCropCancel:ue}=M,j=G||!!p||!!f,K=E||L||F,J=!!e,te=useRef(t?.url||""),Z=useRef();useEffect(()=>{if(!g){te.current="",Z.current=void 0;return}if(Z.current===g.id)return;Z.current=g.id,w(!0);let ie=URL.createObjectURL(g);return te.current=ie,()=>{URL.revokeObjectURL(ie);}},[g]);let a=()=>{w(!1);},fe=useCallback(()=>J&&g?()=>S(g):T().onClick,[J,g,T,S]);return jsxs(Fragment,{children:[jsxs(he,{sx:{alignItems:"center"},children:[jsxs(ho,{sx:l,isError:j,isDragActive:V,hasFile:!!g,...T(),onClick:fe(),children:[jsxs(fo,{children:[K&&jsx(xo,{children:jsx(Nt,{size:135,thickness:2,color:"primary"})}),g&&jsx(bo,{alt:"Avatar Preview",src:te.current,onLoad:a,...K&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),!g&&!K&&jsxs($e,{isError:j,hasFile:!1,children:[jsx(a$4,{icon:"ADD_IMAGE",width:32}),jsx(Je,{variant:"caption",textAlign:"center",sx:{color:j?"error.main":"text.disabled"},children:"Adicionar foto"})]}),g&&!K&&jsxs($e,{isError:j,hasFile:!0,children:[jsx(a$4,{icon:J?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(Je,{variant:"caption",textAlign:"center",sx:{color:j?"error.main":"common.white"},children:J?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:u,id:i,tabIndex:d,...N()})]}),jsx(he,{sx:{alignItems:"center",mt:-.5},children:jsx(O,{helperText:m,disabled:n,isError:j})}),f?jsx(O,{helperText:f,isError:!0}):null,p?jsx(O,{helperText:p,isError:!0}):null]}),se&&oe&&jsx(a$6,{open:se,onClose:ue,label:s??"Ajustar Imagem",imageSrc:oe,aspectRatio:R,onInitialized:le,onSave:ge,loading:re,cropSize:v,cropShape:"round"})]})},Wt=memo(Bt);var Ht=({error:e,name:o,disabled:r,sx:t,...n})=>{let{getRootProps:s,getInputProps:i,isDragActive:d,isDragReject:p}=useDropzone({disabled:r,...n}),m=p||e;return jsxs(mo,{...s(),isDragActive:d,hasError:!!m,disabled:!!r,sx:t,"data-testid":"upload-box",children:[jsx("input",{name:o,...i()}),"Selecionar arquivo"]})},$t=memo(Ht);
40
38
 
41
- export { Pe as FileThumbnail, I as HelperText, De as MultiFilePreview, rt as MultipleFileUpload, dt as MultipleImageUpload, He as SingleFilePreview, ht as SingleFileUpload, Ct as SingleImageUpload, _t as UploadAvatar, Ot as UploadSimpleBox, Ne as fileFormat, Xi as fileNameByUrl, Do as fileThumb, Oe as fileThumbnailClasses, To as fileTypeByUrl, K as useDropzoneUploader };
39
+ export { Ve as ContentType, Be as FileContentType, Ee as FileThumbnail, O as HelperText, _e as MultiFilePreview, dt as MultipleFileUpload, bt as MultipleImageUpload, Xe as SingleFilePreview, At as SingleFileUpload, yt as SingleImageUpload, Wt as UploadAvatar, $t as UploadSimpleBox, Oo as compressImageWithoutCrop, To as convertToWebP, yo as encodeFilenameForHeader, qe as fileFormat, ea as fileNameByUrl, So as fileThumb, Ne as fileThumbnailClasses, _o as fileTypeByUrl, Uo as getFileNameFromContentDisposition, ma as isImageFile, X as useDropzoneUploader, q as useFileUploadService };
@@ -1,7 +1,7 @@
1
1
  import { a } from '../../../chunk-NV2X5CYP.js';
2
2
  import { a as a$2 } from '../../../chunk-C6LHLY2U.js';
3
- import { a as a$3 } from '../../../chunk-F5HXBPOO.js';
4
3
  import '../../../chunk-C6ZLQ63H.js';
4
+ import { a as a$3 } from '../../../chunk-F5HXBPOO.js';
5
5
  import { a as a$1 } from '../../../chunk-BFAYY2AM.js';
6
6
  import '../../../chunk-FO7JCJ76.js';
7
7
  import '../../../chunk-JJM24URR.js';
@@ -0,0 +1,8 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { PushNotificationProviderProps, PushNotificationContextData } from '../types/pushNotifications.js';
3
+ import 'react';
4
+
5
+ declare const PushNotificationProvider: <TMessage = unknown>({ children, originId, originType, bearerToken, vapidKey, serviceWorkerPath, serviceWorkerFile, pollingInterval, apiAdapters, onMessageReceived, onError, }: PushNotificationProviderProps<TMessage>) => react_jsx_runtime.JSX.Element;
6
+ declare function usePushNotifications<TMessage = unknown>(): PushNotificationContextData<TMessage>;
7
+
8
+ export { PushNotificationProvider, usePushNotifications };
@@ -0,0 +1,8 @@
1
+ import { a } from '../chunk-Q3ADZHO5.js';
2
+ import '../chunk-IHAHXNLH.js';
3
+ import { createContext, useState, useMemo, useEffect, useCallback, useContext } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ var j=createContext(void 0),ee=({children:l,originId:m,originType:M,bearerToken:p,vapidKey:C,serviceWorkerPath:S="/",serviceWorkerFile:T="service-worker.js",pollingInterval:N=5e3,apiAdapters:r,onMessageReceived:f,onError:i})=>{let[s,E]=useState(null),[x,k]=useState(null),[D,h]=useState(0),[L,b]=useState(!1),[B,v]=useState(!1),[I,F]=useState({subscriptions:[]}),[R,W]=useState(!1),z=useMemo(()=>!s||R,[s,R]);useEffect(()=>{if(!B||!s||!r.fetchMessages)return;let t=setInterval(async()=>{try{let a=(await r.fetchMessages(s))?.messages?.[0];a&&(k(a),h(o=>o+1),f?.(a));}catch(e){console.error("Erro ao buscar mensagens:",e);}},N);return ()=>clearInterval(t)},[B,s,r,N,f]);let y=useCallback(async t=>{try{let e=t?.toJSON().keys,a={origin_type:M,origin_id:m,endpoint:t?.endpoint??void 0,auth:e?.auth??void 0,p256dh:e?.p256dh??void 0},o=await r.registerClient(a);return E(o.id),b(!1),o.id}catch(e){return console.error("Erro ao registrar cliente:",e),b(!0),i?.(e),null}},[r,m,M,i]);useEffect(()=>{let t=!0,e=null;async function a$1(){if(!("serviceWorker"in navigator)||!("PushManager"in window)){console.warn("Push notifications n\xE3o suportadas, usando polling");let o=await y(null);t&&(E(o),v(!0));return}try{let o=await navigator.serviceWorker.register(`${S}${T}`);if(!t)return;e=async g=>{let P=g.data?.payload?.detail||g.data?.detail?.[0];if(P&&(k(P),h(d=>d+1),f?.(P)),g.data?.id?.value)try{await r.updateMessageStatus(g.data.id.value,{status:"DELIVERED"});}catch(d){console.error("Erro ao atualizar status da mensagem:",d),b(!0),i?.(d);}},navigator.serviceWorker.addEventListener("message",e);let K=await Notification.requestPermission(),H=null;K==="granted"?H=await o.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:a(C)}):(console.warn("Permiss\xE3o de notifica\xE7\xE3o negada, usando polling"),v(!0)),await y(H);}catch(o){console.error("Erro ao inicializar service worker:",o),v(!0),i?.(o);}}return p&&a$1(),()=>{t=!1,e&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",e);}},[p,y,r,C,S,T,f,i]);let n=useCallback(async()=>{if(s){W(!0);try{let t=await r.listSubscriptions(s);F(t);}catch(t){console.error("Erro ao listar inscri\xE7\xF5es:",t),i?.(t);}finally{W(!1);}}},[s,r,i]);useEffect(()=>{s&&n();},[s]);let O=useCallback(async t=>{if(s)try{await r.subscribeTopic(s,t),await n();}catch(e){console.error("Erro ao inscrever em t\xF3pico:",e),i?.(e);}},[s,r,n,i]),V=useCallback(async t=>{if(s)try{await r.unsubscribeTopic(s,t),await n();}catch(e){console.error("Erro ao desinscrever de t\xF3pico:",e),i?.(e);}},[s,r,n,i]),_=useCallback(async t=>{if(!(!s||t.length===0))try{await r.subscribeTopicsBatch(s,t),await n();}catch(e){console.error("Erro ao inscrever em t\xF3picos:",e),i?.(e);}},[s,r,n,i]),$=useCallback(async t=>{if(!(!s||t.length===0))try{await r.unsubscribeTopicsBatch(s,t),await n();}catch(e){console.error("Erro ao desinscrever de t\xF3picos:",e),i?.(e);}},[s,r,n,i]),q=useCallback(()=>{h(0);},[]),G=useMemo(()=>({clientId:s,subscribedTopics:I,isRegisterError:L,isLoading:z,lastMessage:x,newMessageCount:D,subscribeToTopic:O,unsubscribeFromTopic:V,subscribeTopicsBatch:_,unsubscribeTopicsBatch:$,resetMessageCount:q}),[s,I,L,z,x,D,O,V,_,$,q]);return jsx(j.Provider,{value:G,children:l})};function se(){let l=useContext(j);if(!l)throw new Error("usePushNotifications precisa estar dentro de PushNotificationProvider");return l}
7
+
8
+ export { ee as PushNotificationProvider, se as usePushNotifications };
@@ -0,0 +1,76 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ interface PushMessage<TPayload = unknown> {
4
+ message: string;
5
+ topic: string;
6
+ updatedAt: string;
7
+ createdAt: string;
8
+ payload: TPayload;
9
+ id: {
10
+ value: string;
11
+ };
12
+ }
13
+ interface SubscriptionItem {
14
+ topic: string;
15
+ }
16
+ interface SubscriptionsData {
17
+ subscriptions: SubscriptionItem[];
18
+ }
19
+ interface ClientRegistrationPayload {
20
+ origin_type: string;
21
+ origin_id: string;
22
+ endpoint?: string;
23
+ auth?: string;
24
+ p256dh?: string;
25
+ }
26
+ interface ClientRegistrationResult {
27
+ id: string;
28
+ }
29
+ declare enum MessageStatus {
30
+ SENT = "SENT",
31
+ DELIVERED = "DELIVERED",
32
+ READ = "READ"
33
+ }
34
+ interface MessageStatusPayload {
35
+ status: MessageStatus;
36
+ }
37
+ interface PushNotificationApiAdapters<TMessage = unknown> {
38
+ registerClient: (payload: ClientRegistrationPayload) => Promise<ClientRegistrationResult>;
39
+ subscribeTopic: (clientId: string, topic: string) => Promise<void>;
40
+ unsubscribeTopic: (clientId: string, topic: string) => Promise<void>;
41
+ subscribeTopicsBatch: (clientId: string, topics: string[]) => Promise<void>;
42
+ unsubscribeTopicsBatch: (clientId: string, topics: string[]) => Promise<void>;
43
+ listSubscriptions: (clientId: string) => Promise<SubscriptionsData>;
44
+ fetchMessages?: (clientId: string) => Promise<{
45
+ messages: PushMessage<TMessage>[];
46
+ }>;
47
+ updateMessageStatus: (messageId: string, status: MessageStatusPayload) => Promise<void>;
48
+ }
49
+ interface PushNotificationProviderProps<TMessage = unknown> {
50
+ children: ReactNode;
51
+ bearerToken: string;
52
+ originId: string;
53
+ originType: string;
54
+ vapidKey: string;
55
+ serviceWorkerPath?: string;
56
+ serviceWorkerFile?: string;
57
+ pollingInterval?: number;
58
+ apiAdapters: PushNotificationApiAdapters<TMessage>;
59
+ onMessageReceived?: (message: PushMessage<TMessage>) => void;
60
+ onError?: (error: Error) => void;
61
+ }
62
+ interface PushNotificationContextData<TMessage = unknown> {
63
+ clientId: string | null;
64
+ subscribedTopics: SubscriptionsData;
65
+ isLoading: boolean;
66
+ lastMessage: PushMessage<TMessage> | null;
67
+ newMessageCount: number;
68
+ isRegisterError: boolean;
69
+ subscribeToTopic: (topic: string) => Promise<void>;
70
+ unsubscribeFromTopic: (topic: string) => Promise<void>;
71
+ subscribeTopicsBatch: (topics: string[]) => Promise<void>;
72
+ unsubscribeTopicsBatch: (topics: string[]) => Promise<void>;
73
+ resetMessageCount: () => void;
74
+ }
75
+
76
+ export { ClientRegistrationPayload, ClientRegistrationResult, MessageStatus, MessageStatusPayload, PushMessage, PushNotificationApiAdapters, PushNotificationContextData, PushNotificationProviderProps, SubscriptionItem, SubscriptionsData };
@@ -0,0 +1 @@
1
+ export { a as MessageStatus } from '../chunk-IHAHXNLH.js';
@@ -0,0 +1,3 @@
1
+ declare function urlBase64ToUint8Array(base64String: string): Uint8Array;
2
+
3
+ export { urlBase64ToUint8Array };
@@ -0,0 +1 @@
1
+ export { a as urlBase64ToUint8Array } from '../chunk-Q3ADZHO5.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.6.95",
3
+ "version": "2.6.97",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,6 +0,0 @@
1
- import { a } from './chunk-GFJT57TO.js';
2
- import { useState, useMemo, useCallback, useRef, useEffect } from 'react';
3
-
4
- var M=(o=>(o.APPLICATION_OCTET_STREAM="application/octet-stream",o.IMAGE_JPEG="image/jpeg",o.IMAGE_JPG="image/jpg",o.IMAGE_PNG="image/png",o.IMAGE_GIF="image/gif",o.IMAGE_WEBP="image/webp",o.IMAGE_SVG="image/svg+xml",o.IMAGE_BMP="image/bmp",o.IMAGE_TIFF="image/tiff",o.IMAGE_ICO="image/x-icon",o.IMAGE_AVIF="image/avif",o.APPLICATION_PDF="application/pdf",o.TEXT_PLAIN="text/plain",o.TEXT_CSV="text/csv",o.APPLICATION_RTF="application/rtf",o.APPLICATION_MSWORD="application/msword",o.APPLICATION_DOCX="application/vnd.openxmlformats-officedocument.wordprocessingml.document",o.APPLICATION_MSEXCEL="application/vnd.ms-excel",o.APPLICATION_XLSX="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",o.APPLICATION_MSPOWERPOINT="application/vnd.ms-powerpoint",o.APPLICATION_PPTX="application/vnd.openxmlformats-officedocument.presentationml.presentation",o.APPLICATION_ODT="application/vnd.oasis.opendocument.text",o.APPLICATION_ODS="application/vnd.oasis.opendocument.spreadsheet",o.APPLICATION_ODP="application/vnd.oasis.opendocument.presentation",o.APPLICATION_XML="application/xml",o.TEXT_XML="text/xml",o.TEXT_HTML="text/html",o.TEXT_CSS="text/css",o.APPLICATION_JSON="application/json",o.TEXT_JAVASCRIPT="text/javascript",o.APPLICATION_ZIP="application/zip",o.APPLICATION_GZIP="application/gzip",o.APPLICATION_RAR="application/vnd.rar",o.APPLICATION_7Z="application/x-7z-compressed",o.AUDIO_MPEG="audio/mpeg",o.AUDIO_WAV="audio/wav",o.AUDIO_OGG="audio/ogg",o.AUDIO_WEBM="audio/webm",o.AUDIO_AAC="audio/aac",o.VIDEO_MP4="video/mp4",o.VIDEO_MPEG="video/mpeg",o.VIDEO_OGG="video/ogg",o.VIDEO_WEBM="video/webm",o.VIDEO_QUICKTIME="video/quicktime",o))(M||{}),R=(e=>(e["application/octet-stream"]="APPLICATION_OCTET_STREAM",e["image/jpeg"]="IMAGE_JPEG",e["image/jpg"]="IMAGE_JPG",e["image/png"]="IMAGE_PNG",e["image/gif"]="IMAGE_GIF",e["image/webp"]="IMAGE_WEBP",e["image/svg+xml"]="IMAGE_SVG",e["image/bmp"]="IMAGE_BMP",e["image/tiff"]="IMAGE_TIFF",e["image/x-icon"]="IMAGE_ICO",e["image/avif"]="IMAGE_AVIF",e["application/pdf"]="APPLICATION_PDF",e["text/plain"]="TEXT_PLAIN",e["text/csv"]="TEXT_CSV",e["application/rtf"]="APPLICATION_RTF",e["application/msword"]="APPLICATION_MSWORD",e["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]="APPLICATION_DOCX",e["application/vnd.ms-excel"]="APPLICATION_MSEXCEL",e["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]="APPLICATION_XLSX",e["application/vnd.ms-powerpoint"]="APPLICATION_MSPOWERPOINT",e["application/vnd.openxmlformats-officedocument.presentationml.presentation"]="APPLICATION_PPTX",e["application/vnd.oasis.opendocument.text"]="APPLICATION_ODT",e["application/vnd.oasis.opendocument.spreadsheet"]="APPLICATION_ODS",e["application/vnd.oasis.opendocument.presentation"]="APPLICATION_ODP",e["application/xml"]="APPLICATION_XML",e["text/xml"]="TEXT_XML",e["text/html"]="TEXT_HTML",e["text/css"]="TEXT_CSS",e["application/json"]="APPLICATION_JSON",e["text/javascript"]="TEXT_JAVASCRIPT",e["application/zip"]="APPLICATION_ZIP",e["application/gzip"]="APPLICATION_GZIP",e["application/vnd.rar"]="APPLICATION_RAR",e["application/x-7z-compressed"]="APPLICATION_7Z",e["audio/mpeg"]="AUDIO_MPEG",e["audio/wav"]="AUDIO_WAV",e["audio/ogg"]="AUDIO_OGG",e["audio/webm"]="AUDIO_WEBM",e["audio/aac"]="AUDIO_AAC",e["video/mp4"]="VIDEO_MP4",e["video/mpeg"]="VIDEO_MPEG",e["video/ogg"]="VIDEO_OGG",e["video/webm"]="VIDEO_WEBM",e["video/quicktime"]="VIDEO_QUICKTIME",e))(R||{});var Z=e=>e.startsWith("image/"),B=(e,s=.8)=>new Promise((l,p)=>{let P=document.createElement("canvas"),u=P.getContext("2d"),r=new Image;r.onload=()=>{P.width=r.width,P.height=r.height,u?(u.drawImage(r,0,0),P.toBlob(a=>{if(a){let g=new File([a],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});l(g);}else p(new Error("Falha ao converter para WebP"));},"image/webp",s)):p(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},r.onerror=()=>p(new Error("Falha ao carregar imagem")),r.src=URL.createObjectURL(e);}),H=(e,s=.8,l,p)=>new Promise((P,u)=>{let r=document.createElement("canvas"),a=r.getContext("2d"),g=new Image;g.onload=()=>{let{width:d,height:n}=g;l&&d>l&&(n=n*l/d,d=l),p&&n>p&&(d=d*p/n,n=p),r.width=d,r.height=n,a?(a.imageSmoothingEnabled=!0,a.imageSmoothingQuality="high",a.drawImage(g,0,0,d,n),r.toBlob(E=>{if(E){let _=new File([E],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});P(_);}else u(new Error("Falha ao comprimir imagem"));},"image/webp",s)):u(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},g.onerror=()=>u(new Error("Falha ao carregar imagem")),g.src=URL.createObjectURL(e);}),N=e=>{let s=e.match(/filename\*=UTF-8''([^;]+)|filename="?([^";]+)"?/i);return s?.[1]||s?.[2]||""},G=e=>`UTF-8''${encodeURIComponent(e)}`;var j=({createFilesMutation:e,filesDetails:s})=>{let{showErrorMessage:l}=a(),[p,P]=useState(!1),[u,r]=useState(!1),[a$1,g]=useState(null),[d,n]=useState([]),E=useMemo(()=>d?.[0],[d]),_=u||p,w=useCallback(async I=>{if(!I.length){n([]),r(!1);return}r(!0);try{let c=(await Promise.all(I.map(async({url:A,id:b,name:F})=>{try{if(!A)return null;let i=await fetch(A);if(!i.ok)throw new Error(i.statusText);let t=await i.blob(),m=null;if(!F){let S=i.headers.get("content-disposition")||void 0;if(S){let h=N(S);if(h)try{m=decodeURIComponent(h);}catch{m=h;}}}let x=m||F||b,O=new File([t],x,{type:t.type});return O.id=b,O.url=A,O}catch{return null}}))).filter(Boolean);n(c),r(!1);}catch(f){l(f,"Erro ao carregar arquivos"),n([]),r(!1);}},[l]),D=useRef("");useEffect(()=>{let I=s?.map(({id:f})=>f).join(",")||"";I!==D.current&&(async()=>(D.current=I,await w(s)))();},[s,w]);let z=async I=>{if(!I||!Array.isArray(I))throw new Error("Arquivos inv\xE1lidos");let f=I.filter(c=>c instanceof File);if(f?.length){P(!0);try{let c=f.map(i=>{let t=i.type||"application/octet-stream",m=R[t];if(!m)throw new Error(`Tipo de arquivo n\xE3o suportado: ${t}`);return {file:i,mimeType:t,contentTypeEnum:m}}),A=await e({files:c.map(({file:i,contentTypeEnum:t})=>({content_type:t,name:i.name}))}).unwrap(),b=A.files.map((i,t)=>{let m=c[t].file,x=m;return x.id=i.id,x.url=URL.createObjectURL(m),x});return await(await Promise.all(A.files.map((i,t)=>{let{mimeType:m}=c[t],x=b[t];return fetch(i.url,{method:"PUT",headers:{"Content-Type":m,"Content-Disposition":`inline; filename*=${G(x.name)}`,"X-File-Id":i.id},body:x})}))).forEach(async i=>{if(!i.ok)throw new Error("Erro no upload do arquivo.")}),b}catch(c){throw g(c),l(c,"Erro no upload"),c}finally{P(!1);}}},T=useMemo(()=>a$1&&a$1 instanceof Error?a$1.message:a$1,[a$1]);return {setFilesPreview:n,uploadFiles:z,filesPreview:d,filePreview:E,isLoadingPreview:u,isUploadingFiles:p,isUploadOrLoadingFiles:_,uploadErrorText:T}},ee=j;
5
-
6
- export { Z as a, B as b, H as c, N as d, G as e, M as f, R as g, ee as h };
@@ -1,7 +0,0 @@
1
- import 'react';
2
- export { u as default } from '../../../useFileUploadService-1a2d0cf5.js';
3
- import 'react-dropzone';
4
- import 'react-easy-crop';
5
- import '@dnd-kit/core';
6
- import '@mui/material/Stack';
7
- import '@mui/material/styles';
@@ -1,2 +0,0 @@
1
- export { h as default } from '../../../chunk-ORQNUG2V.js';
2
- import '../../../chunk-GFJT57TO.js';
@@ -1,358 +0,0 @@
1
- import * as react from 'react';
2
- import { DropzoneOptions, DropzoneRootProps, FileRejection, DropzoneInputProps, useDropzone } from 'react-dropzone';
3
- import { Area } from 'react-easy-crop';
4
- import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
5
- import { StackProps } from '@mui/material/Stack';
6
- import { SxProps, Theme } from '@mui/material/styles';
7
-
8
- interface ExtendFile extends File {
9
- id: string;
10
- url: string;
11
- }
12
- interface FileDetails {
13
- id: string;
14
- url: string;
15
- name?: string;
16
- }
17
- interface FileUpload {
18
- url: string;
19
- file: ExtendFile;
20
- contentType: string;
21
- resourceIds: string[];
22
- }
23
- type CropSize = {
24
- width: number;
25
- height: number;
26
- } | number;
27
- type CreateFilesMutation = (files: ExtendFile[]) => Promise<string[] | undefined>;
28
- interface FileCreateRequest {
29
- files: Array<{
30
- content_type: keyof typeof ContentType;
31
- name: string;
32
- }>;
33
- }
34
- interface FileGetResponse {
35
- id: string;
36
- name: string;
37
- organization_id: string;
38
- url: string;
39
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
40
- content_type: string;
41
- content_length: number;
42
- created_by: string;
43
- created_at: string;
44
- updated_by: string;
45
- updated_at: string;
46
- }
47
- interface FileCreateResponse {
48
- files: FileGetResponse[];
49
- }
50
- interface FileQueryRequest {
51
- ids: string[];
52
- }
53
- interface FileQueryResponse {
54
- files: FileGetResponse[];
55
- }
56
- interface SingleFilePreviewProps extends StackProps {
57
- file: ExtendFile;
58
- aspectRatio?: number;
59
- isLoading?: boolean;
60
- cropSize?: CropSize;
61
- onLoading?: (isLoading: boolean) => void;
62
- isUploading?: boolean;
63
- maxWidth?: number;
64
- maxHeight?: number;
65
- }
66
- interface LoadingPreviewImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
67
- aspectRatio: number;
68
- maxWidth?: number | string;
69
- maxHeight?: number | string;
70
- isLoading?: boolean;
71
- isUploading?: boolean;
72
- cropSize?: CropSize;
73
- onLoading?: (isLoading: boolean) => void;
74
- alt?: string;
75
- src?: string;
76
- loading: 'lazy';
77
- }
78
- interface PlaceholderProps extends StackProps {
79
- header?: React.ReactNode;
80
- description?: React.ReactNode;
81
- }
82
- interface FileUploadProps {
83
- createFilesMutation: (params: FileCreateRequest) => {
84
- unwrap: () => Promise<FileCreateResponse>;
85
- };
86
- filesDetails: FileDetails[];
87
- }
88
- interface SingleFileUploadProps extends DropzoneOptions {
89
- onRemove?: (file?: ExtendFile) => void;
90
- onFileSelect?: (file: ExtendFile) => void;
91
- createFilesMutation: FileUploadProps['createFilesMutation'];
92
- fileDetails?: FileDetails;
93
- placeholderProps?: PlaceholderProps;
94
- placeholderAlt?: React.ReactNode;
95
- name?: string;
96
- label?: string;
97
- id?: string;
98
- disabled?: boolean;
99
- error?: string;
100
- helperText?: string | React.ReactNode;
101
- sx?: SxProps<Theme>;
102
- dropZoneSxProps?: SxProps<Theme>;
103
- uploading?: boolean;
104
- tabIndex?: number;
105
- maxSize?: number;
106
- }
107
- interface SingleImageUploadProps extends SingleFileUploadProps {
108
- aspectRatio?: number;
109
- enableCrop?: boolean;
110
- convertToWebp?: boolean;
111
- cropSize?: CropSize;
112
- maxWidth?: number;
113
- maxHeight?: number;
114
- compressionQuality?: number;
115
- maxCompressedWidth?: number;
116
- maxCompressedHeight?: number;
117
- }
118
- interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'filesDetails' | 'onFileSelect'> {
119
- onFilesSelect?: (files: ExtendFile[]) => void;
120
- onRemoveAll?: (files?: ExtendFile[]) => void;
121
- onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
122
- filesDetails?: FileDetails[];
123
- maxFiles?: number;
124
- thumbnail?: boolean;
125
- }
126
- interface MultiImageUploadProps extends MultiFileUploadProps {
127
- aspectRatio?: number;
128
- enableCrop?: boolean;
129
- convertToWebp?: boolean;
130
- cropSize?: CropSize;
131
- maxWidth?: number;
132
- maxHeight?: number;
133
- compressionQuality?: number;
134
- maxCompressedWidth?: number;
135
- maxCompressedHeight?: number;
136
- }
137
- interface SortableItemProps extends StackProps {
138
- onRemove?: (file?: ExtendFile) => void;
139
- file: ExtendFile;
140
- thumbnail?: boolean;
141
- disableDrag?: boolean;
142
- }
143
- interface MultiFilePreviewProps extends StackProps {
144
- onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
145
- onRemove?: (file?: ExtendFile) => void;
146
- files: ExtendFile[];
147
- lastNode?: React.ReactNode;
148
- firstNode?: React.ReactNode;
149
- thumbnail: boolean;
150
- slotProps?: {
151
- thumbnail?: Omit<FileThumbnailProps, 'file'>;
152
- };
153
- }
154
- interface StyledDropZoneProps extends StackProps {
155
- isDragActive: boolean;
156
- isError: boolean;
157
- disabled: boolean;
158
- }
159
- type StyledDropZonePropsType = Omit<DropzoneRootProps, 'children' | 'onDrop' | 'onError'> & StyledDropZoneProps;
160
- interface RejectionFilesProps extends StackProps {
161
- files: FileRejection[];
162
- }
163
- interface ThumbnailBadgeProps {
164
- onRemove?: (file?: ExtendFile) => void;
165
- file: ExtendFile;
166
- attributes: DraggableAttributes;
167
- listeners: DraggableSyntheticListeners;
168
- innerWidth: number;
169
- isDragging: boolean;
170
- disableDrag?: boolean;
171
- sx?: SxProps<Theme>;
172
- }
173
- interface DropZoneProps {
174
- sx?: SxProps;
175
- uploading?: boolean;
176
- id?: string;
177
- tabIndex?: number;
178
- getRootProps: () => DropzoneRootProps;
179
- getInputProps: () => DropzoneInputProps;
180
- isDragActive: boolean;
181
- isError: boolean;
182
- disabled?: boolean;
183
- dropZoneSxProps?: SxProps<Theme>;
184
- dropZoneContent?: React.ReactNode;
185
- children?: React.ReactNode;
186
- name?: string;
187
- }
188
- interface HelperTextProps {
189
- helperText?: string | React.ReactNode;
190
- disabled?: boolean;
191
- isError?: boolean;
192
- }
193
- interface UseDropzoneUploaderProps {
194
- onReorder?: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
195
- onFileSelect?: (file: ExtendFile) => void;
196
- onFilesSelect?: (files: ExtendFile[]) => void;
197
- onRemove?: (file?: ExtendFile) => void;
198
- uploadFiles: (files: File[]) => Promise<ExtendFile[] | undefined>;
199
- filesPreview?: ExtendFile[];
200
- dropzoneOptions?: Omit<DropzoneOptions, 'onDrop' | 'onDropRejected'>;
201
- enableCrop?: boolean;
202
- customAspectRatio?: number;
203
- convertToWebp?: boolean;
204
- maxFiles?: number;
205
- cropSize?: {
206
- width: number;
207
- height: number;
208
- } | number;
209
- compressionQuality?: number;
210
- maxCompressedWidth?: number;
211
- maxCompressedHeight?: number;
212
- }
213
- interface UseDropzoneUploaderReturn {
214
- file: ExtendFile | null;
215
- files: ExtendFile[];
216
- aspectRatio: number;
217
- dropzoneProps: {
218
- getRootProps: ReturnType<typeof useDropzone>['getRootProps'];
219
- getInputProps: ReturnType<typeof useDropzone>['getInputProps'];
220
- isDragActive: boolean;
221
- isDragReject: boolean;
222
- fileRejections: readonly FileRejection[];
223
- };
224
- cropState: {
225
- cropModalOpen: boolean;
226
- imagePreview: string;
227
- cropLoading: boolean;
228
- setCropModalOpen: React.Dispatch<React.SetStateAction<boolean>>;
229
- onCropInitialized: (croppedArea: Area, croppedAreaPixels: Area) => void;
230
- handleCropSave: () => Promise<void>;
231
- handleCropCancel: () => void;
232
- currentImageIndex: number;
233
- totalPendingImages: number;
234
- };
235
- setInitialFiles?: (files: ExtendFile[]) => void;
236
- handleRemove: (fileToRemove?: ExtendFile) => void;
237
- handleReorder: (oldIndex: number, newIndex: number, files: ExtendFile[]) => void;
238
- }
239
- declare enum ContentType {
240
- APPLICATION_OCTET_STREAM = "application/octet-stream",
241
- IMAGE_JPEG = "image/jpeg",
242
- IMAGE_JPG = "image/jpg",
243
- IMAGE_PNG = "image/png",
244
- IMAGE_GIF = "image/gif",
245
- IMAGE_WEBP = "image/webp",
246
- IMAGE_SVG = "image/svg+xml",
247
- IMAGE_BMP = "image/bmp",
248
- IMAGE_TIFF = "image/tiff",
249
- IMAGE_ICO = "image/x-icon",
250
- IMAGE_AVIF = "image/avif",
251
- APPLICATION_PDF = "application/pdf",
252
- TEXT_PLAIN = "text/plain",
253
- TEXT_CSV = "text/csv",
254
- APPLICATION_RTF = "application/rtf",
255
- APPLICATION_MSWORD = "application/msword",
256
- APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
257
- APPLICATION_MSEXCEL = "application/vnd.ms-excel",
258
- APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
259
- APPLICATION_MSPOWERPOINT = "application/vnd.ms-powerpoint",
260
- APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
261
- APPLICATION_ODT = "application/vnd.oasis.opendocument.text",
262
- APPLICATION_ODS = "application/vnd.oasis.opendocument.spreadsheet",
263
- APPLICATION_ODP = "application/vnd.oasis.opendocument.presentation",
264
- APPLICATION_XML = "application/xml",
265
- TEXT_XML = "text/xml",
266
- TEXT_HTML = "text/html",
267
- TEXT_CSS = "text/css",
268
- APPLICATION_JSON = "application/json",
269
- TEXT_JAVASCRIPT = "text/javascript",
270
- APPLICATION_ZIP = "application/zip",
271
- APPLICATION_GZIP = "application/gzip",
272
- APPLICATION_RAR = "application/vnd.rar",
273
- APPLICATION_7Z = "application/x-7z-compressed",
274
- AUDIO_MPEG = "audio/mpeg",
275
- AUDIO_WAV = "audio/wav",
276
- AUDIO_OGG = "audio/ogg",
277
- AUDIO_WEBM = "audio/webm",
278
- AUDIO_AAC = "audio/aac",
279
- VIDEO_MP4 = "video/mp4",
280
- VIDEO_MPEG = "video/mpeg",
281
- VIDEO_OGG = "video/ogg",
282
- VIDEO_WEBM = "video/webm",
283
- VIDEO_QUICKTIME = "video/quicktime"
284
- }
285
- declare enum FileContentType {
286
- 'application/octet-stream' = "APPLICATION_OCTET_STREAM",
287
- 'image/jpeg' = "IMAGE_JPEG",
288
- 'image/jpg' = "IMAGE_JPG",
289
- 'image/png' = "IMAGE_PNG",
290
- 'image/gif' = "IMAGE_GIF",
291
- 'image/webp' = "IMAGE_WEBP",
292
- 'image/svg+xml' = "IMAGE_SVG",
293
- 'image/bmp' = "IMAGE_BMP",
294
- 'image/tiff' = "IMAGE_TIFF",
295
- 'image/x-icon' = "IMAGE_ICO",
296
- 'image/avif' = "IMAGE_AVIF",
297
- 'application/pdf' = "APPLICATION_PDF",
298
- 'text/plain' = "TEXT_PLAIN",
299
- 'text/csv' = "TEXT_CSV",
300
- 'application/rtf' = "APPLICATION_RTF",
301
- 'application/msword' = "APPLICATION_MSWORD",
302
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' = "APPLICATION_DOCX",
303
- 'application/vnd.ms-excel' = "APPLICATION_MSEXCEL",
304
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' = "APPLICATION_XLSX",
305
- 'application/vnd.ms-powerpoint' = "APPLICATION_MSPOWERPOINT",
306
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation' = "APPLICATION_PPTX",
307
- 'application/vnd.oasis.opendocument.text' = "APPLICATION_ODT",
308
- 'application/vnd.oasis.opendocument.spreadsheet' = "APPLICATION_ODS",
309
- 'application/vnd.oasis.opendocument.presentation' = "APPLICATION_ODP",
310
- 'application/xml' = "APPLICATION_XML",
311
- 'text/xml' = "TEXT_XML",
312
- 'text/html' = "TEXT_HTML",
313
- 'text/css' = "TEXT_CSS",
314
- 'application/json' = "APPLICATION_JSON",
315
- 'text/javascript' = "TEXT_JAVASCRIPT",
316
- 'application/zip' = "APPLICATION_ZIP",
317
- 'application/gzip' = "APPLICATION_GZIP",
318
- 'application/vnd.rar' = "APPLICATION_RAR",
319
- 'application/x-7z-compressed' = "APPLICATION_7Z",
320
- 'audio/mpeg' = "AUDIO_MPEG",
321
- 'audio/wav' = "AUDIO_WAV",
322
- 'audio/ogg' = "AUDIO_OGG",
323
- 'audio/webm' = "AUDIO_WEBM",
324
- 'audio/aac' = "AUDIO_AAC",
325
- 'video/mp4' = "VIDEO_MP4",
326
- 'video/mpeg' = "VIDEO_MPEG",
327
- 'video/ogg' = "VIDEO_OGG",
328
- 'video/webm' = "VIDEO_WEBM",
329
- 'video/quicktime' = "VIDEO_QUICKTIME"
330
- }
331
-
332
- type FileThumbnailProps = StackProps & {
333
- tooltip?: boolean;
334
- file: ExtendFile;
335
- imageView?: boolean;
336
- sx?: SxProps<Theme>;
337
- onDownload?: () => void;
338
- onRemove?: () => void;
339
- slotProps?: {
340
- img?: SxProps<Theme>;
341
- icon?: SxProps<Theme>;
342
- removeBtn?: SxProps<Theme>;
343
- downloadBtn?: SxProps<Theme>;
344
- };
345
- };
346
-
347
- declare const useFileUploadService: ({ createFilesMutation, filesDetails, }: FileUploadProps) => {
348
- setFilesPreview: react.Dispatch<react.SetStateAction<ExtendFile[]>>;
349
- uploadFiles: (files: File[]) => Promise<ExtendFile[] | undefined>;
350
- filesPreview: ExtendFile[];
351
- filePreview: ExtendFile;
352
- isLoadingPreview: boolean;
353
- isUploadingFiles: boolean;
354
- isUploadOrLoadingFiles: boolean;
355
- uploadErrorText: string;
356
- };
357
-
358
- export { ContentType as C, DropZoneProps as D, ExtendFile as E, FileThumbnailProps as F, HelperTextProps as H, LoadingPreviewImageProps as L, MultiFilePreviewProps as M, PlaceholderProps as P, RejectionFilesProps as R, SingleFilePreviewProps as S, ThumbnailBadgeProps as T, UseDropzoneUploaderProps as U, UseDropzoneUploaderReturn as a, MultiFileUploadProps as b, MultiImageUploadProps as c, SingleFileUploadProps as d, SingleImageUploadProps as e, FileContentType as f, FileDetails as g, FileUpload as h, CropSize as i, CreateFilesMutation as j, FileCreateRequest as k, FileGetResponse as l, FileCreateResponse as m, FileQueryRequest as n, FileQueryResponse as o, FileUploadProps as p, SortableItemProps as q, StyledDropZoneProps as r, StyledDropZonePropsType as s, useFileUploadService as u };