@zydon/common 2.4.27 → 2.4.29

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,11 @@
1
+ import { a } from './chunk-YQ6K2DEP.js';
2
+ import y from '@mui/material/Box';
3
+ import v from '@mui/material/ButtonBase';
4
+ import P from '@mui/material/IconButton';
5
+ import L from '@mui/material/Stack';
6
+ import D from '@mui/material/Tooltip';
7
+ import { jsx, jsxs } from 'react/jsx-runtime';
8
+
9
+ var g=["pdf"],x=["txt"],R=["psd"],C=["doc","docx"],F=["xls","xlsx"],k=["zip","rar","iso"],w=["ai","eps"],A=["ppt","pptx"],B=["wav","aif","mp3","aac"],E=["jpg","jpeg","gif","bmp","png","svg","webp"],M=["m4v","avi","mpg","mp4","webm"];function l(t){let e,o=u(t);return x.includes(o)?e="txt":k.includes(o)?e="zip":B.includes(o)?e="audio":E.includes(o)?e="image":M.includes(o)?e="video":C.includes(o)?e="word":F.includes(o)?e="excel":A.includes(o)?e="powerpoint":g.includes(o)?e="pdf":R.includes(o)?e="photoshop":w.includes(o)?e="illustrator":t?.startsWith("http")?e="image":e=u(t),e}function d(t){let e;switch(l(t)){case"folder":e="IC_FOLDER";break;case"txt":e="IC_TXT";break;case"zip":e="IC_ZIP";break;case"audio":e="IC_AUDIO";break;case"video":e="IC_VIDEO";break;case"word":e="IC_WORD";break;case"excel":e="IC_EXCEL";break;case"powerpoint":e="IC_POWER_POINT";break;case"pdf":e="IC_PDF";break;case"photoshop":e="IC_PTS";break;case"illustrator":e="IC_AI";break;case"image":e="IC_IMG";break;default:e="IC_FILE";}return e}function u(t){return t&&t.split(".").pop()||""}function W(t){return t.split("/").pop()}var r={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"},K=({sx:t,file:e,tooltip:o,onRemove:c,imageView:I,slotProps:a$1,onDownload:m,...h})=>{let n=e?.url,p=n||URL.createObjectURL(e),b=e?.name||n?.split("/").pop()||"",_=e.type.startsWith("image/")?"image":l(n||p),T=jsx(y,{component:"img",src:p,className:r.img,sx:{width:1,height:1,objectFit:"cover",borderRadius:"inherit",...a$1?.img}}),O=jsx(a,{icon:d(_),sx:{width:32,height:32,flexShrink:0,...t}}),f=jsxs(L,{component:"span",className:r.root,sx:{width:36,height:36,flexShrink:0,borderRadius:1.25,alignItems:"center",position:"relative",display:"inline-flex",justifyContent:"center",...t},...h,children:[_==="image"&&I?T:O,c&&jsx(v,{onClick:c,className:r.removeBtn,sx:a$1?.removeBtn,children:jsx(a,{icon:"CLOSE_MARK_BUTTON",width:24})}),m&&jsx(P,{onClick:m,className:r.downloadBtn,sx:a$1?.downloadBtn,size:"small",children:jsx(a,{icon:"ARROW_DOWN_CICLE",width:12})})]});return o?jsx(D,{arrow:!0,title:b,slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,-12]}}]}},children:f}):f};
10
+
11
+ export { l as a, d as b, u as c, W as d, r as e, K as f };
@@ -0,0 +1,5 @@
1
+ import { useEffect } from 'react';
2
+
3
+ var e=o=>{useEffect(o,[]);},u=e;
4
+
5
+ export { u as a };
@@ -1,8 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { F as FileThumbnailProps } from '../../types-fc6b8325.js';
3
- export { E as ExtendFile } from '../../types-fc6b8325.js';
2
+ import { F as FileThumbnailProps } from '../../types-9d4e2f3e.js';
4
3
  import '@mui/material/Stack';
5
4
  import '@mui/material/styles';
5
+ import 'react-dropzone';
6
+ import '@dnd-kit/core';
6
7
 
7
8
  declare const fileThumbnailClasses: {
8
9
  root: string;
@@ -17,24 +18,5 @@ declare function fileFormat(fileUrl: string): string;
17
18
  declare function fileThumb(fileUrl: string): string;
18
19
  declare function fileTypeByUrl(fileUrl: string): string;
19
20
  declare function fileNameByUrl(fileUrl: string): string | undefined;
20
- declare function fileData(file: File | string): {
21
- key: string;
22
- preview: string;
23
- name: string | undefined;
24
- type: string;
25
- size: undefined;
26
- path: string;
27
- lastModified: undefined;
28
- lastModifiedDate: undefined;
29
- } | {
30
- key: string;
31
- name: string;
32
- size: number;
33
- path: string | undefined;
34
- type: string;
35
- preview: string | undefined;
36
- lastModified: number;
37
- lastModifiedDate: Date | undefined;
38
- };
39
21
 
40
- export { FileThumbnail, FileThumbnailProps, fileData, fileFormat, fileNameByUrl, fileThumb, fileThumbnailClasses, fileTypeByUrl };
22
+ export { FileThumbnail, FileThumbnailProps, fileFormat, fileNameByUrl, fileThumb, fileThumbnailClasses, fileTypeByUrl };
@@ -1,3 +1,3 @@
1
- export { g as FileThumbnail, e as fileData, a as fileFormat, d as fileNameByUrl, b as fileThumb, f as fileThumbnailClasses, c as fileTypeByUrl } from '../../chunk-CBYQFWT2.js';
1
+ export { f as FileThumbnail, a as fileFormat, d as fileNameByUrl, b as fileThumb, e as fileThumbnailClasses, c as fileTypeByUrl } from '../../chunk-IOF7MNRL.js';
2
2
  import '../../chunk-YQ6K2DEP.js';
3
3
  import '../../chunk-CHLVIVDD.js';
@@ -1,280 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { DropzoneOptions, DropzoneRootProps, FileRejection, DropzoneInputProps, useDropzone } from 'react-dropzone';
4
- import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
5
- import { StackProps } from '@mui/material/Stack';
6
- import { SxProps, Theme } from '@mui/material/styles';
7
- import { F as FileThumbnailProps } from '../../types-fc6b8325.js';
3
+ import { H as HelperTextProps, M as MultiFilePreviewProps, S as SingleFilePreviewProps, a as FileUploadProps, E as ExtendFile, b as MultiFileUploadProps, c as MultiImageUploadProps, d as SingleFileUploadProps, e as SingleImageUploadProps } from '../../types-9d4e2f3e.js';
4
+ export { C as ContentType, i as CreateFilesMutation, h as CropSize, D as DropZoneProps, f as FileContentType, j as FileCreateRequest, k as FileCreateResponse, n as FileGetResponse, l as FileQueryRequest, m as FileQueryResponse, g as FileUpload, L as LoadingPreviewImageProps, P as PlaceholderProps, R as RejectionFilesProps, o as SortableItemProps, p as StyledDropZoneProps, q as StyledDropZonePropsType, T as ThumbnailBadgeProps } from '../../types-9d4e2f3e.js';
5
+ import { DropzoneOptions, useDropzone, FileRejection } from 'react-dropzone';
8
6
  import { Area } from 'react-easy-crop';
9
-
10
- interface FileUpload {
11
- url: string;
12
- file: File;
13
- contentType: string;
14
- resourceIds: string[];
15
- }
16
- type CropSize = {
17
- width: number;
18
- height: number;
19
- } | number;
20
- type CreateFilesMutation = (files: File[]) => Promise<string[] | undefined>;
21
- interface FileCreateRequest {
22
- files: Array<{
23
- content_type: keyof typeof ContentType;
24
- name: string;
25
- }>;
26
- }
27
- interface FileCreateResponse {
28
- files: Array<{
29
- id: string;
30
- name: string;
31
- organization_id: string;
32
- url: string;
33
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
34
- content_type: string;
35
- content_length: number;
36
- created_by: string;
37
- created_at: string;
38
- updated_by: string;
39
- updated_at: string;
40
- }>;
41
- }
42
- interface FileQueryRequest {
43
- ids: string[];
44
- }
45
- interface FileQueryResponse {
46
- files: Array<{
47
- id: string;
48
- name: string;
49
- organization_id: string;
50
- url: string;
51
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
52
- content_type: string;
53
- content_length: number;
54
- created_by: string;
55
- created_at: string;
56
- updated_by: string;
57
- updated_at: string;
58
- }>;
59
- }
60
- interface FileGetResponse {
61
- id: string;
62
- name: string;
63
- organization_id: string;
64
- url: string;
65
- status: 'PENDING' | 'COMPLETED' | 'FAILED';
66
- content_type: string;
67
- content_length: number;
68
- created_by: string;
69
- created_at: string;
70
- updated_by: string;
71
- updated_at: string;
72
- }
73
- interface SingleFilePreviewProps extends StackProps {
74
- file: File | string;
75
- aspectRatio?: number;
76
- isLoading?: boolean;
77
- cropSize?: CropSize;
78
- onLoading?: (isLoading: boolean) => void;
79
- isUploading?: boolean;
80
- }
81
- interface PlaceholderProps extends StackProps {
82
- header?: React.ReactNode;
83
- description?: React.ReactNode;
84
- }
85
- interface SingleFileUploadProps extends DropzoneOptions {
86
- onFileSelect: (file?: File) => void;
87
- onRemove?: (file?: File) => void;
88
- placeholderProps?: PlaceholderProps;
89
- placeholderAlt?: React.ReactNode;
90
- file?: File;
91
- name?: string;
92
- label?: string;
93
- id?: string;
94
- disabled?: boolean;
95
- error?: string;
96
- helperText?: string | React.ReactNode;
97
- sx?: SxProps<Theme>;
98
- dropZoneSxProps?: SxProps;
99
- uploading?: boolean;
100
- tabIndex?: number;
101
- maxSize?: number;
102
- }
103
- interface SingleImageUploadProps extends SingleFileUploadProps {
104
- aspectRatio?: number;
105
- enableCrop?: boolean;
106
- convertToWebp?: boolean;
107
- cropSize?: CropSize;
108
- }
109
- interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'file' | 'onFileSelect'> {
110
- onFilesSelect: (files?: File[]) => void;
111
- onRemoveAll?: (files?: File[]) => void;
112
- onReorder?: (oldIndex: number, newIndex: number) => void;
113
- files?: File[];
114
- maxFiles?: number;
115
- thumbnail?: boolean;
116
- }
117
- interface MultiImageUploadProps extends MultiFileUploadProps {
118
- aspectRatio?: number;
119
- enableCrop?: boolean;
120
- convertToWebp?: boolean;
121
- cropSize?: CropSize;
122
- }
123
- interface SortableItemProps extends StackProps {
124
- onRemove?: (file?: File) => void;
125
- file?: File;
126
- thumbnail?: boolean;
127
- disableDrag?: boolean;
128
- }
129
- interface MultiFilePreviewProps extends StackProps {
130
- onReorder?: (oldIndex: number, newIndex: number) => void;
131
- onRemove?: (file?: File) => void;
132
- files: File[];
133
- lastNode?: React.ReactNode;
134
- firstNode?: React.ReactNode;
135
- thumbnail: boolean;
136
- slotProps?: {
137
- thumbnail?: Omit<FileThumbnailProps, 'file'>;
138
- };
139
- }
140
- interface StyledDropZoneProps extends StackProps {
141
- isDragActive: boolean;
142
- isError: boolean;
143
- disabled: boolean;
144
- }
145
- type StyledDropZonePropsType = Omit<DropzoneRootProps, 'children' | 'onDrop' | 'onError'> & StyledDropZoneProps;
146
- interface RejectionFilesProps extends StackProps {
147
- files: FileRejection[];
148
- }
149
- interface ThumbnailBadgeProps {
150
- onRemove?: (file?: File) => void;
151
- file: File;
152
- attributes: DraggableAttributes;
153
- listeners: DraggableSyntheticListeners;
154
- innerWidth: number;
155
- isDragging: boolean;
156
- disableDrag?: boolean;
157
- sx?: SxProps<Theme>;
158
- }
159
- interface DropZoneProps {
160
- sx?: SxProps;
161
- uploading?: boolean;
162
- id?: string;
163
- tabIndex?: number;
164
- getRootProps: () => DropzoneRootProps;
165
- getInputProps: () => DropzoneInputProps;
166
- isDragActive: boolean;
167
- isError: boolean;
168
- disabled?: boolean;
169
- dropZoneSxProps?: SxProps;
170
- dropZoneContent?: React.ReactNode;
171
- children?: React.ReactNode;
172
- name?: string;
173
- }
174
- interface FileUploadProps {
175
- createFilesMutation: (params: FileCreateRequest) => {
176
- unwrap: () => Promise<FileCreateResponse>;
177
- };
178
- files?: FileGetResponse[];
179
- file?: FileGetResponse;
180
- }
181
- interface HelperTextProps {
182
- helperText?: string | React.ReactNode;
183
- disabled?: boolean;
184
- isError?: boolean;
185
- }
186
- declare enum ContentType {
187
- APPLICATION_OCTET_STREAM = "application/octet-stream",
188
- IMAGE_JPEG = "image/jpeg",
189
- IMAGE_JPG = "image/jpg",
190
- IMAGE_PNG = "image/png",
191
- IMAGE_GIF = "image/gif",
192
- IMAGE_WEBP = "image/webp",
193
- IMAGE_SVG = "image/svg+xml",
194
- IMAGE_BMP = "image/bmp",
195
- IMAGE_TIFF = "image/tiff",
196
- IMAGE_ICO = "image/x-icon",
197
- IMAGE_AVIF = "image/avif",
198
- APPLICATION_PDF = "application/pdf",
199
- TEXT_PLAIN = "text/plain",
200
- TEXT_CSV = "text/csv",
201
- APPLICATION_RTF = "application/rtf",
202
- APPLICATION_MSWORD = "application/msword",
203
- APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
204
- APPLICATION_MSEXCEL = "application/vnd.ms-excel",
205
- APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
206
- APPLICATION_MSPOWERPOINT = "application/vnd.ms-powerpoint",
207
- APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
208
- APPLICATION_ODT = "application/vnd.oasis.opendocument.text",
209
- APPLICATION_ODS = "application/vnd.oasis.opendocument.spreadsheet",
210
- APPLICATION_ODP = "application/vnd.oasis.opendocument.presentation",
211
- APPLICATION_XML = "application/xml",
212
- TEXT_XML = "text/xml",
213
- TEXT_HTML = "text/html",
214
- TEXT_CSS = "text/css",
215
- APPLICATION_JSON = "application/json",
216
- TEXT_JAVASCRIPT = "text/javascript",
217
- APPLICATION_ZIP = "application/zip",
218
- APPLICATION_GZIP = "application/gzip",
219
- APPLICATION_RAR = "application/vnd.rar",
220
- APPLICATION_7Z = "application/x-7z-compressed",
221
- AUDIO_MPEG = "audio/mpeg",
222
- AUDIO_WAV = "audio/wav",
223
- AUDIO_OGG = "audio/ogg",
224
- AUDIO_WEBM = "audio/webm",
225
- AUDIO_AAC = "audio/aac",
226
- VIDEO_MP4 = "video/mp4",
227
- VIDEO_MPEG = "video/mpeg",
228
- VIDEO_OGG = "video/ogg",
229
- VIDEO_WEBM = "video/webm",
230
- VIDEO_QUICKTIME = "video/quicktime"
231
- }
232
- declare enum FileContentType {
233
- 'application/octet-stream' = "APPLICATION_OCTET_STREAM",
234
- 'image/jpeg' = "IMAGE_JPEG",
235
- 'image/jpg' = "IMAGE_JPG",
236
- 'image/png' = "IMAGE_PNG",
237
- 'image/gif' = "IMAGE_GIF",
238
- 'image/webp' = "IMAGE_WEBP",
239
- 'image/svg+xml' = "IMAGE_SVG",
240
- 'image/bmp' = "IMAGE_BMP",
241
- 'image/tiff' = "IMAGE_TIFF",
242
- 'image/x-icon' = "IMAGE_ICO",
243
- 'image/avif' = "IMAGE_AVIF",
244
- 'application/pdf' = "APPLICATION_PDF",
245
- 'text/plain' = "TEXT_PLAIN",
246
- 'text/csv' = "TEXT_CSV",
247
- 'application/rtf' = "APPLICATION_RTF",
248
- 'application/msword' = "APPLICATION_MSWORD",
249
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' = "APPLICATION_DOCX",
250
- 'application/vnd.ms-excel' = "APPLICATION_MSEXCEL",
251
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' = "APPLICATION_XLSX",
252
- 'application/vnd.ms-powerpoint' = "APPLICATION_MSPOWERPOINT",
253
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation' = "APPLICATION_PPTX",
254
- 'application/vnd.oasis.opendocument.text' = "APPLICATION_ODT",
255
- 'application/vnd.oasis.opendocument.spreadsheet' = "APPLICATION_ODS",
256
- 'application/vnd.oasis.opendocument.presentation' = "APPLICATION_ODP",
257
- 'application/xml' = "APPLICATION_XML",
258
- 'text/xml' = "TEXT_XML",
259
- 'text/html' = "TEXT_HTML",
260
- 'text/css' = "TEXT_CSS",
261
- 'application/json' = "APPLICATION_JSON",
262
- 'text/javascript' = "TEXT_JAVASCRIPT",
263
- 'application/zip' = "APPLICATION_ZIP",
264
- 'application/gzip' = "APPLICATION_GZIP",
265
- 'application/vnd.rar' = "APPLICATION_RAR",
266
- 'application/x-7z-compressed' = "APPLICATION_7Z",
267
- 'audio/mpeg' = "AUDIO_MPEG",
268
- 'audio/wav' = "AUDIO_WAV",
269
- 'audio/ogg' = "AUDIO_OGG",
270
- 'audio/webm' = "AUDIO_WEBM",
271
- 'audio/aac' = "AUDIO_AAC",
272
- 'video/mp4' = "VIDEO_MP4",
273
- 'video/mpeg' = "VIDEO_MPEG",
274
- 'video/ogg' = "VIDEO_OGG",
275
- 'video/webm' = "VIDEO_WEBM",
276
- 'video/quicktime' = "VIDEO_QUICKTIME"
277
- }
7
+ import '@mui/material/Stack';
8
+ import '@mui/material/styles';
9
+ import '@dnd-kit/core';
278
10
 
279
11
  declare const _default$8: react.MemoExoticComponent<({ helperText, disabled, isError }: HelperTextProps) => react_jsx_runtime.JSX.Element | null>;
280
12
 
@@ -325,9 +57,9 @@ interface UseDropzoneUploaderReturn {
325
57
  }
326
58
  declare const useDropzoneUploader: ({ filesToUpload, onFileSelect, onFilesSelect, onRemove, dropzoneOptions, enableCrop, customAspectRatio, convertToWebp, maxFiles, cropSize, }: UseDropzoneUploaderProps) => UseDropzoneUploaderReturn;
327
59
 
328
- declare const useFileUploadService: ({ createFilesMutation, files, file, }: FileUploadProps) => {
329
- filesPreview: File[] | undefined;
330
- filePreview: File | undefined;
60
+ declare const useFileUploadService: ({ createFilesMutation, files, file, skip, }: FileUploadProps) => {
61
+ filesPreview: File[] | ExtendFile[] | undefined;
62
+ filePreview: File | ExtendFile | undefined;
331
63
  uploadFiles: (files: File[]) => Promise<string[] | undefined>;
332
64
  isUploadingFiles: boolean;
333
65
  isLoadingPreview: boolean;
@@ -350,4 +82,4 @@ declare const _default: react.MemoExoticComponent<({ error, name, disabled, sx,
350
82
  declare const isImageFile: (mimeType: string) => boolean;
351
83
  declare const convertToWebP: (file: File, quality?: number) => Promise<File>;
352
84
 
353
- export { ContentType, CreateFilesMutation, CropSize, DropZoneProps, FileContentType, FileCreateRequest, FileCreateResponse, FileGetResponse, FileQueryRequest, FileQueryResponse, FileUpload, FileUploadProps, _default$8 as HelperText, HelperTextProps, _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, convertToWebP, isImageFile, useDropzoneUploader, useFileUploadService };
85
+ export { ExtendFile, FileUploadProps, _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, convertToWebP, isImageFile, useDropzoneUploader, useFileUploadService };
@@ -1,8 +1,8 @@
1
1
  import { a as a$3 } from '../../chunk-H5L4ARDB.js';
2
2
  import { a } from '../../chunk-AV36ZLPF.js';
3
- import { e as e$1 } from '../../chunk-ANAHA3L6.js';
3
+ import { e } from '../../chunk-ANAHA3L6.js';
4
4
  import { a as a$2 } from '../../chunk-IPOTBSM7.js';
5
- import { e, g } from '../../chunk-CBYQFWT2.js';
5
+ import { f } from '../../chunk-IOF7MNRL.js';
6
6
  import { a as a$4 } from '../../chunk-6VHUXLMC.js';
7
7
  import '../../chunk-4WWRGU3D.js';
8
8
  import '../../chunk-DNLTCAWK.js';
@@ -13,24 +13,25 @@ import { j } from '../../chunk-DMQW3LDF.js';
13
13
  import { a as a$5 } from '../../chunk-YQ6K2DEP.js';
14
14
  import '../../chunk-CHLVIVDD.js';
15
15
  import '../../chunk-ILHUUK4X.js';
16
+ import { a as a$8 } from '../../chunk-S7QQBC4I.js';
16
17
  import { a as a$7 } from '../../chunk-ONZBWH3C.js';
17
- import { memo, useRef, useEffect, useMemo, useCallback, useState } from 'react';
18
- import So from '@mui/material/FormHelperText';
18
+ import { memo, useRef, useMemo, useCallback, useState, useEffect } from 'react';
19
+ import _o from '@mui/material/FormHelperText';
19
20
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
20
21
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
21
22
  import { restrictToHorizontalAxis, restrictToParentElement, restrictToWindowEdges } from '@dnd-kit/modifiers';
22
23
  import { useSortable, sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
23
24
  import { m, AnimatePresence } from 'framer-motion';
24
- import ae from '@mui/material/Stack';
25
- import Be from '@mui/material/Typography';
26
- import ge from '@mui/material/Box';
27
- import Oo from '@mui/material/IconButton';
28
- import Mo from '@mui/material/Paper';
25
+ import ie from '@mui/material/Stack';
26
+ import ke from '@mui/material/Typography';
27
+ import me from '@mui/material/Box';
28
+ import Mo from '@mui/material/IconButton';
29
+ import Co from '@mui/material/Paper';
29
30
  import { styled, alpha } from '@mui/material/styles';
30
- import ko from '@mui/material/Badge';
31
+ import Uo from '@mui/material/Badge';
31
32
  import { useDropzone } from 'react-dropzone';
32
- import qr from '@mui/material/CircularProgress';
33
+ import Kr from '@mui/material/CircularProgress';
33
34
 
34
- var yo=({helperText:e,disabled:t,isError:r})=>e?jsx(So,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,k=memo(yo);var De=styled(ae)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),we=styled(ae)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),Ve=styled(ge,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:t,isError:r,disabled:a})=>({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:`1px dashed ${alpha(e.palette.grey[500],.32)}`,...t&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...a&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(ae)(({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:"#fff"}}}));var He=styled(Oo)(({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]}})),Ce=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),Ke=styled(ae,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:t,isDragging:r})=>({width:t,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)"})),Je=styled(m.div)(({theme:e,width:t,isDragging:r})=>({width:t,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)"})),Qe=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)}})),Ye=styled(ge,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:t,disabled:r,hasError:a})=>({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)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...a&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),eo=styled(ge)(({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)"}})),oo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,isLoading:i,isUploading:n})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,aspectRatio:t,maxWidth:"calc(100% - 16px)",maxHeight:"calc(100% - 16px)",backgroundColor:e.palette.background.paper,height:r>=a?"100%":`calc(100% * ${t})`,width:r>a?`calc(${t} * 100%)`:"100%",transition:"all 0.5s ease-in-out",...i||n?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),ro=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:t})=>({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},...t&&{opacity:.7,filter:"blur(2rem)"}})),to=styled(ae)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Mo)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var ke=styled(ge,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:t,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},...t&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),io=styled(ae)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center"});styled(ae)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.grey[200],color:e.palette.text.disabled,height:160}));var ao=styled(ge,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:t,disabled:r,isError:a,hasFile:i})=>({padding:1,margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${alpha(e.palette.grey[500],.2)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...a&&{borderColor:"error.main"},...i&&{...a&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),no=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),so=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 zo=({onRemove:e$1,sx:t,file:r,disableDrag:a,attributes:i,listeners:n,innerWidth:l,isDragging:g$1})=>{let{key:p}=e(r);return jsx(ko,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Je,{width:l,isDragging:g$1,"data-testid":`preview-multi-img-${p}`,...j().inUp,sx:t,children:[jsx(a$1,{disableDrag:a,...i,...n}),jsx(g,{tooltip:!0,imageView:!0,file:r}),jsx(we,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e$1&&jsx(so,{size:"small",label:"Remover arquivo",onClick:()=>e$1(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${p}`)},lo=memo(zo);var Go=({file:e$2,thumbnail:t,onRemove:r,sx:a$3,disableDrag:i=!1})=>{let{key:n,name:l="",size:g$1=0}=e(e$2||""),p=typeof e$2=="string",s=i?70:80,{attributes:d,listeners:P,setNodeRef:m,transform:c,transition:I,isDragging:D}=useSortable({id:n,disabled:i}),R={transform:x.Transform.toString(c),transition:I,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${s+8}px`,height:"68px"};return t&&e$2?jsx(Ce,{ref:m,style:R,children:jsx(lo,{innerWidth:s,isDragging:D,sx:a$3,file:e$2,disableDrag:i,attributes:d,listeners:P,onRemove:r})}):jsx(Ce,{ref:m,style:{...R,height:"80px",width:`${s+38}px`},children:jsxs(Ke,{width:s+30,isDragging:D,"data-testid":`preview-multi-img-${n}`,...j().inUp,sx:a$3,children:[jsx(a$1,{disableDrag:i,...d,...P}),e$2&&jsx(g,{file:e$2}),jsxs(ae,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$2,{title:l,children:jsx(Be,{variant:"subtitle2",noWrap:!0,children:l})}),jsx(Be,{variant:"caption",sx:{color:"text.secondary"},children:p?"":e$1(g$1)})]}),jsx(we,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$2),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo(Go);var or=({thumbnail:e$1,files:t,onRemove:r,onReorder:a,sx:i})=>{let n=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates}));if(!t?.length)return null;let l=p=>{let{active:s,over:d}=p;if(!(!s||!d||s.id===d.id)&&a){let P=t.findIndex(c=>{let{key:I}=e(c);return I===s.id}),m=t.findIndex(c=>{let{key:I}=e(c);return I===d.id});P!==-1&&m!==-1&&a(P,m);}},g=jsx(AnimatePresence,{initial:!1,children:t.map(p=>jsx(mo,{sx:i,file:p,onRemove:r,thumbnail:e$1,disableDrag:!a},e(p).key))});return a?jsx(DndContext,{sensors:n,collisionDetection:closestCenter,onDragEnd:l,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(p=>e(p).key),strategy:horizontalListSortingStrategy,children:g})}):g},fe=memo(or);var ar=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:n})=>{let l=useRef(null),g=typeof e=="string"?e:e.name,p=typeof e=="string"?e:URL.createObjectURL(e);useEffect(()=>{l.current&&!l.current.complete?i?.(!0):i?.(!1);},[l,i]);let s=typeof n=="number"?n*t:n?.width,d=typeof n=="number"?n:n?.height;return jsxs(eo,{children:[jsx(oo,{aspectRatio:t,isLoading:a,isUploading:r,height:d,width:s,alt:g,src:p,ref:l,onLoad:()=>i?.(!1),onError:()=>i?.(!1)}),jsx(ro,{alt:g,src:p,isLoading:a,isUploading:r})]})},ze=memo(ar);var ri=e=>e.startsWith("image/"),fo=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),n=i.getContext("2d"),l=new Image;l.onload=()=>{i.width=l.width,i.height=l.height,n?(n.drawImage(l,0,0),i.toBlob(g=>{if(g){let p=new File([g],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(p);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},l.onerror=()=>a(new Error("Falha ao carregar imagem")),l.src=URL.createObjectURL(e);});var lr=({filesToUpload:e,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:n=!1,customAspectRatio:l,convertToWebp:g=!0,maxFiles:p,cropSize:s})=>{let{showErrorMessage:d}=a$7(),P=useMemo(()=>l||(s&&typeof s!="number"?s.width/s.height:1),[l,s]),[m,c]=useState([]),[I,D]=useState(!1),[R,f]=useState(null),[x,w]=useState(null),[u,h]=useState(""),[F,v]=useState(!1),[_,U]=useState([]),[ee,B]=useState(0),y=useMemo(()=>e&&Array.isArray(e)?e.filter(o=>o instanceof File):e&&e instanceof File?[e]:m,[e,m]),X=useMemo(()=>e&&Array.isArray(e)?null:e&&e instanceof File?e:m[0]||null,[e,m]);useEffect(()=>{e&&(Array.isArray(e)?c(e.filter(o=>o instanceof File)):e instanceof File?c([e]):e===null&&c([]));},[e]);let G=useCallback(()=>{if(_.length>0&&n){let o=_[0];f(o),B(b=>b+1);let E=new FileReader;E.onload=()=>{h(E.result),D(!0);},E.readAsDataURL(o);}},[_,n]);useEffect(()=>{G();},[G]);let oe=useCallback((o,E)=>{w(E);},[]),re=async()=>!R||!x?null:new Promise(o=>{let E=document.createElement("canvas"),b=E.getContext("2d"),j=new Image;j.onload=async()=>{let{width:ce,height:V,x:wo,y:Eo}=x,xe=ce,be=V;s&&(typeof s=="number"?(xe=s,be=s/P):(xe=s.width,be=s.height)),E.width=xe,E.height=be,b?(b.drawImage(j,wo,Eo,ce,V,0,0,xe,be),E.toBlob(async $e=>{if($e){let Le=new File([$e],R.name,{type:R.type,lastModified:Date.now()});if(g)try{Le=await fo(Le);}catch(Ro){d(Ro,"Erro ao converter para WebP");}o(Le);}else o(null);},"image/png")):o(null);},j.src=u;}),te=async()=>{if(!(!R||!x)){v(!0);try{let o=await re();if(o)if(Array.isArray(e)||e===void 0&&r){let b=p?[...y,o].slice(0,p):[...y,o];c(b),r?.(b);}else c([o]),t?.(o);let E=_.slice(1);U(E),D(!1),h(""),f(null),E.length>0&&setTimeout(()=>G(),100);}catch(o){d(o,"Erro ao processar imagem");}finally{v(!1);}}},M=()=>{D(!1),h(""),f(null),U([]),B(0);},L=useCallback(o=>{if(o.length===0)return;if(i?.accept&&Object.keys(i.accept).some(b=>b.includes("image/"))&&n)if(Array.isArray(e)||e===void 0&&r){let b=o.filter(V=>V.type.startsWith("image/")),j=y.map(V=>V.name),ce=b.filter(V=>!j.includes(V.name));if(ce.length===0){d("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}U(ce),B(0);}else {let b=o[0];f(b);let j=new FileReader;j.onload=()=>{h(j.result),D(!0);},j.readAsDataURL(b);}else if(Array.isArray(e)||e===void 0&&r){let b=p?[...y,...o].slice(0,p):[...y,...o];c(b),r?.(b);}else {let b=o[0];c([b]),t?.(b);}},[e,y,t,r,n,p,i,d]),N=useCallback(o=>{if(!o.length)return;let E=o[0]?.errors[0]?.code,b=i?.maxSize||3145728;d(E==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e$1(b)}`):E==="file-invalid-type"?new Error("Formato de arquivo n\xE3o suportado"):o[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},[i?.maxSize,d]),{getRootProps:C,getInputProps:q,isDragActive:Z,isDragReject:_e,fileRejections:Oe}=useDropzone({onDrop:L,onDropRejected:N,...i}),Me=useCallback(o=>{if(!o){c([]),a?.(void 0);return}if(Array.isArray(e)||e===void 0&&r){let E=m.filter(b=>b.name!==o.name);c(E),a?.(o),r&&r(E);}else c([]),a?.(o);},[e,m,r,a]),Do=useCallback(()=>{c([]),Array.isArray(e)&&r?r([]):!Array.isArray(e)&&t&&t?.(null);},[e,r,t]);return {file:X,files:y,aspectRatio:P,dropzoneProps:{getRootProps:C,getInputProps:q,isDragActive:Z,isDragReject:_e,fileRejections:Oe},cropState:{cropModalOpen:I,imagePreview:u,cropLoading:F,setCropModalOpen:D,onCropInitialized:oe,handleCropSave:te,handleCropCancel:M,currentImageIndex:ee,totalPendingImages:_.length},handleRemove:Me,clearFiles:Do,setFiles:c}},z=lr;var Ne=(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))(Ne||{}),Re=(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))(Re||{});var cr=({createFilesMutation:e,files:t,file:r})=>{let{showErrorMessage:a}=a$7(),[i,n]=useState(!1),[l,g]=useState(!1),[p,s]=useState(null),[d,P]=useState(void 0),m=useMemo(()=>d?.[0],[d]),c=useMemo(()=>r?[r]:t,[r,t]),I=useCallback(async f=>{if(!f?.length){P(void 0);return}try{g(!0);let x=await Promise.all(f.map(async({url:w,name:u})=>{let F=await(await fetch(w)).blob(),v=u||w.split("/").pop()||"image";return new File([F],v,{type:F.type})}));P(x);}catch(x){console.error("Erro ao carregar preview dos arquivos:",x),P(void 0);}finally{g(!1);}},[]),D=l||i;return useEffect(()=>{I(c);},[c,I]),{filesPreview:d,filePreview:m,uploadFiles:async f=>{if(f?.length){n(!0);try{let x=f[0].type||"application/octet-stream",w=Re[x];if(!w)throw new Error(`Tipo de arquivo n\xE3o suportado: ${x}`);let u=await e({files:[{content_type:w,name:f[0].name}]}).unwrap(),h=u.files.map(v=>v.id);return (await Promise.all(f.map(v=>fetch(u.files[0].url,{method:"PUT",headers:{"Content-Type":x},body:v})))).forEach(v=>{if(!v.ok)throw new Error(`Erro no upload: ${v.statusText}`)}),P(f),h}catch(x){throw s(x),a(x,"Erro no upload"),x}finally{n(!1);}}},isUploadingFiles:i,isLoadingPreview:l,isUploadOrLoadingFiles:D,uploadFilesError:p}},mr=cr;var ur=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:n,getInputProps:l,isDragActive:g,isError:p,disabled:s,dropZoneSxProps:d,dropZoneContent:P,children:m,...c})=>jsxs(De,{children:[i&&jsx(a$6,{"data-testid":"uploading-progress-bar"}),jsxs(ge,{sx:{width:1,position:"relative",...e},children:[jsxs(Ve,{...n(),"data-testid":"drop-zone-styled-area",isError:p,isDragActive:g,disabled:!!s,sx:d,...c,children:[jsx("input",{...l(),id:t,tabIndex:a,name:r}),P]}),m]})]}),K=ur;var xr=({header:e,description:t,sx:r,...a})=>jsxs(ae,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...a,children:[jsx(a$3,{sx:{width:220}}),jsxs("div",{children:[jsx(Be,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(Be,{variant:"body2",sx:{color:"text.secondary"},children:t||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(Be,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),J=memo(xr);var vr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:n,helperText:l,files:g,thumbnail:p,dropZoneSxProps:s,uploading:d,tabIndex:P,maxFiles:m,...c})=>{let{files:I,dropzoneProps:D,handleRemove:R}=z({filesToUpload:g,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...c},maxFiles:m}),{getRootProps:f,getInputProps:x,isDragActive:w,isDragReject:u}=D,h=!!I?.length,F=u||!!n;return jsxs(K,{id:a,uploading:d,disabled:i,dropZoneSxProps:s,tabIndex:P,getRootProps:f,getInputProps:x,isDragActive:w,isError:F,dropZoneContent:jsx(J,{}),children:[jsx(k,{disabled:i,helperText:l,isError:F}),h&&jsx(ge,{sx:{my:3},children:jsx(fe,{files:I,thumbnail:!!p,onRemove:e?R:void 0,onReorder:t})})]})},Ar=memo(vr);var Sr=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:n,helperText:l,files:g,dropZoneSxProps:p,placeholderProps:s,placeholderAlt:d,uploading:P,tabIndex:m,maxFiles:c,aspectRatio:I,enableCrop:D=!0,convertToWebp:R=!0,cropSize:f,name:x,label:w,...u})=>{let{files:h,dropzoneProps:F,cropState:v,handleRemove:_,aspectRatio:U}=z({filesToUpload:g,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...u},enableCrop:D,customAspectRatio:I,convertToWebp:R,maxFiles:c,cropSize:f}),{getRootProps:ee,getInputProps:B,isDragActive:y,isDragReject:X}=F,{cropModalOpen:G,imagePreview:oe,cropLoading:re,onCropInitialized:te,handleCropSave:M,handleCropCancel:L,currentImageIndex:N,totalPendingImages:C}=v,q=!!h?.length,Z=X||!!n,_e=useMemo(()=>{let Oe=w??"Ajustar Imagem",Me=C>1?` (${N} de ${C})`:"";return `${Oe}${Me}`},[w,C,N]);return jsxs(K,{id:a,name:x,uploading:P,disabled:i,dropZoneSxProps:p,tabIndex:m,getRootProps:ee,getInputProps:B,isDragActive:y,isError:Z,dropZoneContent:jsx(Fragment,{children:d?jsx(ae,{children:d}):jsx(J,{header:s?.header,description:s?.description})}),children:[jsx(k,{disabled:i,helperText:l,isError:Z}),q&&jsx(Fragment,{children:jsx(ge,{sx:{my:3,ml:.5},children:jsx(fe,{files:h,thumbnail:!0,onRemove:_,onReorder:r})})}),jsx(a$4,{open:G,onClose:L,label:_e,imageSrc:oe,aspectRatio:U,onInitialized:te,onSave:M,loading:re,cropSize:f})]})},yr=memo(Sr);var Cr=({onFileSelect:e,onRemove:t,file:r,id:a,disabled:i,error:n,helperText:l,sx:g$1,dropZoneSxProps:p,uploading:s,tabIndex:d,...P})=>{let{file:m$1,dropzoneProps:c,handleRemove:I}=z({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...P}}),{getRootProps:D,getInputProps:R,isDragActive:f,isDragReject:x}=c,w=useCallback(v=>{v.stopPropagation(),I(m$1||void 0);},[m$1,I]),u=!!m$1,h=typeof m$1=="string",F=x||!!n;return jsx(K,{id:a,uploading:s,disabled:i,dropZoneSxProps:p,tabIndex:d,getRootProps:D,getInputProps:R,isDragActive:f,isError:F,dropZoneContent:jsxs(Fragment,{children:[!u&&jsx(J,{}),u&&jsxs(ae,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:v=>`solid 1px ${v.palette.divider}`,...g$1},children:[jsx(g,{file:m$1}),jsxs(ae,{flexGrow:1,sx:{minWidth:0},children:[jsx(Be,{variant:"subtitle2",noWrap:!0,children:h?m$1:m$1.name}),jsx(Be,{variant:"caption",sx:{color:"text.secondary"},children:h?"":e$1(m$1.size)})]}),t&&jsx(a$2,{title:"Remover arquivo",children:jsx(He,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:w,children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(k,{disabled:i,helperText:l,isError:F})})},kr=memo(Cr);var Gr=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:n,helperText:l,dropZoneSxProps:g,placeholderProps:p,placeholderAlt:s,uploading:d,tabIndex:P,aspectRatio:m,enableCrop:c=!0,convertToWebp:I=!0,name:D,label:R,cropSize:f,...x})=>{let[w,u]=useState(!1),{file:h,dropzoneProps:F,cropState:v,handleRemove:_,aspectRatio:U}=z({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...x},enableCrop:c,customAspectRatio:m,convertToWebp:I,cropSize:f}),{getRootProps:ee,getInputProps:B,isDragActive:y,isDragReject:X}=F,{cropModalOpen:G,imagePreview:oe,cropLoading:re,onCropInitialized:te,handleCropSave:M,handleCropCancel:L}=v,N=useCallback(()=>{_(h||void 0);},[h,_]),C=!!h,q=X||!!n,Z=C?{opacity:0}:{opacity:1};return jsxs(De,{children:[(d||w)&&jsx(a$6,{}),jsxs(K,{id:a,uploading:d,disabled:i,dropZoneSxProps:g,tabIndex:P,getRootProps:ee,getInputProps:B,isDragActive:y,isError:q,name:D,dropZoneContent:jsxs(Fragment,{children:[s?jsx(ae,{sx:Z,children:s}):jsx(J,{sx:Z,header:p?.title,description:p?.description}),C&&jsx(ze,{file:h,cropSize:f,isLoading:w,isUploading:d,onLoading:u,aspectRatio:U})]}),children:[jsx(k,{disabled:i,helperText:l,isError:q}),C&&e&&jsx(Qe,{size:"small",onClick:N,disabled:i,label:"Remover arquivo",children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$4,{open:G,onClose:L,label:R??"Ajustar Imagem",imageSrc:oe,aspectRatio:U,onInitialized:te,onSave:M,loading:re,cropSize:f})]})]})},Zr=memo(Gr);var Vr=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:n,tabIndex:l,error:g,helperText:p,sx:s,name:d,maxSize:P,uploading:m,aspectRatio:c=1,enableCrop:I=!0,convertToWebp:D=!0,cropSize:R,...f})=>{let[x,w]=useState(!1),{file:u,dropzoneProps:h,cropState:F,handleRemove:v}=z({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:P,...f},enableCrop:I,customAspectRatio:c,convertToWebp:D,cropSize:R}),{getRootProps:_,getInputProps:U,isDragActive:ee,isDragReject:B}=h,{cropModalOpen:y,imagePreview:X,cropLoading:G,onCropInitialized:oe,handleCropSave:re,handleCropCancel:te}=F,M=B||!!g,L=x||m,N=!!t,C=useMemo(()=>u?(w(!0),URL.createObjectURL(u)):"",[u]),q=()=>{w(!1);},Z=()=>N&&u?()=>v(u):_().onClick;return jsxs(Fragment,{children:[jsxs(ao,{sx:s,isError:M,isDragActive:ee,hasFile:!!u,..._(),onClick:Z(),children:[jsxs(to,{children:[u&&jsx(no,{alt:"Avatar Preview",src:C,onLoad:q,...L&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&L&&jsx(io,{children:jsx(qr,{size:135,thickness:1,color:"primary"})}),!u&&!L&&jsxs(ke,{isError:M,hasFile:!1,children:[jsx(a$5,{icon:"ADD_IMAGE",width:32}),jsx(Be,{variant:"caption",textAlign:"center",sx:{color:M?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!L&&jsxs(ke,{isError:M,hasFile:!0,children:[jsx(a$5,{icon:N?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(Be,{variant:"caption",textAlign:"center",sx:{color:M?"error.main":"common.white"},children:N?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:d,id:n,tabIndex:l,...U()}),jsx(ae,{spacing:.5,sx:{pt:1},children:jsx(k,{helperText:p,disabled:a,isError:M})}),u&&!L&&jsx(ae,{direction:"row",justifyContent:"center",spacing:1,sx:{pt:1,mb:-1},children:jsx(Be,{variant:"caption",component:"span",sx:{px:.75,cursor:"pointer",borderRadius:.75,color:"error.main","&:hover":{color:"error.dark",bgcolor:"background.default"}},onClick:()=>v(u),children:"Remover"})})]}),y&&X&&jsx(a$4,{open:y,onClose:te,label:i??"Ajustar Imagem",imageSrc:X,aspectRatio:c,onInitialized:oe,onSave:re,loading:G,cropSize:R,cropShape:"round"})]})},Hr=memo(Vr);var Yr=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:n,getInputProps:l,isDragActive:g,isDragReject:p}=useDropzone({disabled:r,...i}),s=p||e;return jsxs(Ye,{...n(),isDragActive:g,hasError:!!s,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...l()}),"Selecionar arquivo"]})},et=memo(Yr);
35
+ var Oo=({helperText:e,disabled:t,isError:r})=>e?jsx(_o,{error:r,sx:i=>({mx:"14px",color:t?i.palette.grey[500]:void 0}),children:e}):null,U=memo(Oo);var Ae=styled(ie)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),we=styled(ie)({position:"absolute",top:4,right:4,gap:.5,"& svg":{width:16,height:16}}),Xe=styled(me,{shouldForwardProp:e=>!["isDragActive","isError","disabled"].includes(e)})(({theme:e,isDragActive:t,isError:r,disabled:i})=>({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:`1px dashed ${alpha(e.palette.grey[500],.32)}`,...t&&{opacity:.72},...r&&{color:e.palette.error.main,backgroundColor:e.palette.error.lighter,borderColor:e.palette.error.light},...i&&{opacity:.48,pointerEvents:"none"},"&:hover":{opacity:.72}}));styled(ie)(({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:"#fff"}}}));var Ve=styled(Mo)(({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]}})),Me=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),Ke=styled(ie,{shouldForwardProp:e=>!["isDragging"].includes(e)})(({theme:e,width:t,isDragging:r})=>({width:t,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)"})),Je=styled(m.div)(({theme:e,width:t,isDragging:r})=>({width:t,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)"})),Qe=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)}})),Ye=styled(me,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="disabled"&&e!=="hasError"})(({theme:e,isDragActive:t,disabled:r,hasError:i})=>({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)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{color:e.palette.error.main,borderColor:e.palette.error.main,backgroundColor:alpha(e.palette.error.main,.08)},"&:hover":{opacity:.72}})),eo=styled(me)(({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)"}})),oo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"})(({theme:e,aspectRatio:t,height:r=1,width:i=1,isLoading:a,isUploading:l})=>({borderRadius:e.shape.borderRadius,objectFit:"cover",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) scale(1)",filter:"blur(0)",zIndex:1,aspectRatio:t,maxWidth:"calc(100% - 16px)",maxHeight:"calc(100% - 16px)",backgroundColor:e.palette.background.paper,height:r>=i?"100%":`calc(100% * ${t})`,width:r>i?`calc(${t} * 100%)`:"100%",transition:"all 0.5s ease-in-out",...a||l?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),ro=styled("img",{shouldForwardProp:e=>e!=="isLoading"&&e!=="isUploading"})(({isLoading:e,isUploading:t})=>({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},...t&&{opacity:.7,filter:"blur(2rem)"}})),to=styled(ie)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Co)(({theme:e})=>({py:1,px:2,mt:3,textAlign:"left",borderStyle:"dashed",borderColor:"error.main",backgroundColor:alpha(e.palette.error.main,.08)}));var Ce=styled(me,{shouldForwardProp:e=>e!=="isError"&&e!=="hasFile"})(({theme:e,isError:t,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},...t&&{color:e.palette.error.main},...r&&{zIndex:9,opacity:0,color:e.palette.common.white,backgroundColor:alpha(e.palette.common.black,.54)}})),io=styled(ie)({top:0,left:0,right:0,bottom:0,position:"absolute",zIndex:10,alignItems:"center",justifyContent:"center"});styled(ie)(({theme:e})=>({padding:20,justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch",borderRadius:12,background:e.palette.grey[200],color:e.palette.text.disabled,height:160}));var ao=styled(me,{shouldForwardProp:e=>e!=="isDragActive"&&e!=="isError"&&e!=="hasFile"})(({theme:e,isDragActive:t,disabled:r,isError:i,hasFile:a})=>({padding:1,margin:"auto",width:144,height:144,cursor:"pointer",overflow:"hidden",borderRadius:"50%",border:`1px dashed ${alpha(e.palette.grey[500],.2)}`,...t&&{opacity:.72},...r&&{opacity:.48,pointerEvents:"none"},...i&&{borderColor:"error.main"},...a&&{...i&&{bgcolor:alpha(e.palette.error.main,.08)},"&:hover .upload-placeholder":{opacity:1},"& img":{filter:"blur(0)"},"&:hover img":{filter:"blur(3px)"}}})),no=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),so=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 No=({onRemove:e,sx:t,file:r,disableDrag:i,attributes:a,listeners:l,innerWidth:p,isDragging:g})=>{let n=r?.id||r?.url||"";return jsx(Uo,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Je,{width:p,isDragging:g,"data-testid":`preview-multi-img-${n}`,...j().inUp,sx:t,children:[jsx(a$1,{disableDrag:i,...a,...l}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(we,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(so,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${n}`)},lo=memo(No);var jo=({file:e$1,thumbnail:t,onRemove:r,sx:i,disableDrag:a$3=!1})=>{let l=e$1?.size||0,p=e$1?.name||e$1?.url||"",g=e$1?.id||e$1?.url||"",n=typeof e$1=="string",s=a$3?70:80,{attributes:m,listeners:f$1,setNodeRef:d,transform:c,transition:D,isDragging:b}=useSortable({id:g,disabled:a$3}),w={transform:x.Transform.toString(c),transition:D,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${s+8}px`,height:"68px"};return t&&e$1?jsx(Me,{ref:d,style:w,children:jsx(lo,{innerWidth:s,isDragging:b,sx:i,file:e$1,disableDrag:a$3,attributes:m,listeners:f$1,onRemove:r})}):jsx(Me,{ref:d,style:{...w,height:"80px",width:`${s+38}px`},children:jsxs(Ke,{width:s+30,isDragging:b,"data-testid":`preview-multi-img-${g}`,...j().inUp,sx:i,children:[jsx(a$1,{disableDrag:a$3,...m,...f$1}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$2,{title:p,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:p})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:n?"":e(l)})]}),jsx(we,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo(jo);var tr=({thumbnail:e,files:t,onRemove:r,onReorder:i,sx:a})=>{let l=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates}));if(!t?.length)return null;let p=n=>{let{active:s,over:m}=n;if(!(!s||!m||s.id===m.id)&&i){let f=t.findIndex(({id:c})=>c===s.id),d=t.findIndex(({id:c})=>c===m.id);f!==-1&&d!==-1&&i(f,d);}},g=jsx(AnimatePresence,{initial:!1,children:t.map(n=>jsx(mo,{sx:a,file:n,onRemove:r,thumbnail:e,disableDrag:!i},n.id))});return i?jsx(DndContext,{sensors:l,collisionDetection:closestCenter,onDragEnd:p,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(n=>n.id),strategy:horizontalListSortingStrategy,children:g})}):g},ue=memo(tr);var ir=({...e})=>(a$8(()=>{e.onLoading?.(!0);}),jsx(oo,{...e})),uo=ir;var lr=({file:e,aspectRatio:t=1,isUploading:r,isLoading:i,onLoading:a,cropSize:l})=>{let p=useRef(null),g=useRef(null),n=typeof e=="string"?e:e.name,s=typeof e=="string"?e:URL.createObjectURL(e),m=typeof l=="number"?l*t:l?.width,f=typeof l=="number"?l:l?.height,d=useMemo(()=>`image-preview-${n}-${i}-${r}-rnd-${Math.random()}`,[n,i,r]),c=()=>{setTimeout(()=>{a?.(!1);},0);};return jsxs(eo,{ref:p,children:[jsx(uo,{aspectRatio:t,isLoading:i,isUploading:r,height:f,width:m,maxWidth:`calc(${p.current?.offsetWidth||m}px - 16px)`,maxHeight:`calc(${p.current?.offsetHeight||f}px - 16px)`,alt:n,src:s,ref:g,loading:"lazy",onLoad:c,onError:c},d),jsx(ro,{alt:n,src:s,isLoading:i,isUploading:r})]})},ze=memo(lr);var di=e=>e.startsWith("image/"),Po=(e,t=.8)=>new Promise((r,i)=>{let a=document.createElement("canvas"),l=a.getContext("2d"),p=new Image;p.onload=()=>{a.width=p.width,a.height=p.height,l?(l.drawImage(p,0,0),a.toBlob(g=>{if(g){let n=new File([g],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(n);}else i(new Error("Falha ao converter para WebP"));},"image/webp",t)):i(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},p.onerror=()=>i(new Error("Falha ao carregar imagem")),p.src=URL.createObjectURL(e);});var cr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:i,dropzoneOptions:a,enableCrop:l=!1,customAspectRatio:p,convertToWebp:g=!0,maxFiles:n,cropSize:s})=>{let{showErrorMessage:m}=a$7(),f=useMemo(()=>p||(s&&typeof s!="number"?s.width/s.height:1),[p,s]),[d,c]=useState([]),[D,b]=useState(!1),[w,R]=useState(null),[h,x]=useState(null),[u,P]=useState(""),[F,S]=useState(!1),[v,L]=useState([]),[G,_]=useState(0),O=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:d,[e$1,d]),q=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:d[0]||null,[e$1,d]);useEffect(()=>{e$1&&(Array.isArray(e$1)?c(e$1.filter(o=>o instanceof File)):e$1 instanceof File?c([e$1]):e$1===null&&c([]));},[e$1]);let Z=useCallback(()=>{if(v.length>0&&l){let o=v[0];R(o),_(I=>I+1);let E=new FileReader;E.onload=()=>{P(E.result),b(!0);},E.readAsDataURL(o);}},[v,l]);useEffect(()=>{Z();},[Z]);let ee=useCallback((o,E)=>{x(E);},[]),oe=async()=>!w||!h?null:new Promise(o=>{let E=document.createElement("canvas"),I=E.getContext("2d"),W=new Image;W.onload=async()=>{let{width:de,height:X,x:Ro,y:Fo}=h,xe=de,Pe=X;s&&(typeof s=="number"?(xe=s,Pe=s/f):(xe=s.width,Pe=s.height)),E.width=xe,E.height=Pe,I?(I.drawImage(W,Ro,Fo,de,X,0,0,xe,Pe),E.toBlob(async We=>{if(We){let Le=new File([We],w.name,{type:w.type,lastModified:Date.now()});if(g)try{Le=await Po(Le);}catch(So){m(So,"Erro ao converter para WebP");}o(Le);}else o(null);},"image/png")):o(null);},W.src=u;}),re=async()=>{if(!(!w||!h)){S(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let I=n?[...O,o].slice(0,n):[...O,o];c(I),r?.(I);}else c([o]),t?.(o);let E=v.slice(1);L(E),b(!1),P(""),R(null),E.length>0&&setTimeout(()=>Z(),100);}catch(o){m(o,"Erro ao processar imagem");}finally{S(!1);}}},C=()=>{b(!1),P(""),R(null),L([]),_(0);},z=useCallback(o=>{if(o.length===0)return;if(a?.accept&&Object.keys(a.accept).some(I=>I.includes("image/"))&&l)if(Array.isArray(e$1)||e$1===void 0&&r){let I=o.filter(X=>X.type.startsWith("image/")),W=O.map(X=>X.name),de=I.filter(X=>!W.includes(X.name));if(de.length===0){m("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}L(de),_(0);}else {let I=o[0];R(I);let W=new FileReader;W.onload=()=>{P(W.result),b(!0);},W.readAsDataURL(I);}else if(Array.isArray(e$1)||e$1===void 0&&r){let I=n?[...O,...o].slice(0,n):[...O,...o];c(I),r?.(I);}else {let I=o[0];c([I]),t?.(I);}},[e$1,O,t,r,l,n,a,m]),k=useCallback(o=>{if(!o.length)return;let E=o[0]?.errors[0]?.code,I=a?.maxSize||3145728;m(E==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(I)}`):E==="file-invalid-type"?new Error("Formato de arquivo n\xE3o suportado"):o[0]?.errors[0]||new Error("Erro ao enviar arquivo"),"Erro ao fazer upload");},[a?.maxSize,m]),{getRootProps:T,getInputProps:H,isDragActive:j,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:z,onDropRejected:k,...a}),Oe=useCallback(o=>{if(!o){c([]),i?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let E=d.filter(I=>I.name!==o.name);c(E),i?.(o),r&&r(E);}else c([]),i?.(o);},[e$1,d,r,i]),Do=useCallback(()=>{c([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:q,files:O,aspectRatio:f,dropzoneProps:{getRootProps:T,getInputProps:H,isDragActive:j,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:D,imagePreview:u,cropLoading:F,setCropModalOpen:b,onCropInitialized:ee,handleCropSave:re,handleCropCancel:C,currentImageIndex:G,totalPendingImages:v.length},handleRemove:Oe,clearFiles:Do,setFiles:c}},N=cr;var Ue=(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))(Ue||{}),De=(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))(De||{});var ur=({createFilesMutation:e,files:t,file:r,skip:i})=>{let{showErrorMessage:a}=a$7(),[l,p]=useState(!1),[g,n]=useState(!1),[s,m]=useState(null),[f,d]=useState(void 0),c=useMemo(()=>f?.[0],[f]),D=useMemo(()=>{if(!i)return r?[r]:t},[r,t,i]),b=useCallback(async h=>{if(!h?.length){d(void 0);return}try{n(!0);let x=await Promise.all(h.map(async({url:u,name:P,id:F},S)=>{let L=await(await fetch(u)).blob(),G=P||u.split("/").pop()||"image",_=new File([L],G,{type:L.type});return _.id=F,_.url=u,_.index=S,_}));d(x);}catch(x){console.error("Erro ao carregar preview dos arquivos:",x),d(void 0);}finally{n(!1);}},[]),w=g||l;return useEffect(()=>{b(D);},[D,b]),{filesPreview:f,filePreview:c,uploadFiles:async h=>{if(h?.length){p(!0);try{let x=h[0].type||"application/octet-stream",u=De[x];if(!u)throw new Error(`Tipo de arquivo n\xE3o suportado: ${x}`);let P=await e({files:[{content_type:u,name:h[0].name}]}).unwrap(),F=P.files.map(v=>v.id);return (await Promise.all(h.map(v=>fetch(P.files[0].url,{method:"PUT",headers:{"Content-Type":x},body:v})))).forEach(v=>{if(!v.ok)throw new Error(`Erro no upload: ${v.statusText}`)}),b(P.files),F}catch(x){throw m(x),a(x,"Erro no upload"),x}finally{p(!1);}}},isUploadingFiles:l,isLoadingPreview:g,isUploadOrLoadingFiles:w,uploadFilesError:s}},fr=ur;var Pr=({sx:e,id:t,name:r,tabIndex:i,uploading:a,getRootProps:l,getInputProps:p,isDragActive:g,isError:n,disabled:s,dropZoneSxProps:m,dropZoneContent:f,children:d,...c})=>jsxs(Ae,{children:[a&&jsx(a$6,{"data-testid":"uploading-progress-bar"}),jsxs(me,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...l(),"data-testid":"drop-zone-styled-area",isError:n,isDragActive:g,disabled:!!s,sx:m,...c,children:[jsx("input",{...p(),id:t,tabIndex:i,name:r}),f]}),d]})]}),K=Pr;var hr=({header:e,description:t,sx:r,...i})=>jsxs(ie,{spacing:5,alignItems:"center",justifyContent:"center",direction:{xs:"column",md:"row"},sx:{width:1,textAlign:{xs:"center",md:"left"},...r},...i,children:[jsx(a$3,{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:t||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"]})})]})]}),J=memo(hr);var Er=({onRemove:e,onReorder:t,onFilesSelect:r,id:i,disabled:a,error:l,helperText:p,files:g,thumbnail:n,dropZoneSxProps:s,uploading:m,tabIndex:f,maxFiles:d,...c})=>{let{files:D,dropzoneProps:b,handleRemove:w}=N({filesToUpload:g,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:a,...c},maxFiles:d}),{getRootProps:R,getInputProps:h,isDragActive:x,isDragReject:u}=b,P=!!D?.length,F=u||!!l;return jsxs(K,{id:i,uploading:m,disabled:a,dropZoneSxProps:s,tabIndex:f,getRootProps:R,getInputProps:h,isDragActive:x,isError:F,dropZoneContent:jsx(J,{}),children:[jsx(U,{disabled:a,helperText:p,isError:F}),P&&jsx(me,{sx:{my:3},children:jsx(ue,{files:D,thumbnail:!!n,onRemove:e?w:void 0,onReorder:t})})]})},Dr=memo(Er);var Or=({onFilesSelect:e,onRemove:t,onReorder:r,id:i,disabled:a,error:l,helperText:p,files:g,dropZoneSxProps:n,placeholderProps:s,placeholderAlt:m,uploading:f,tabIndex:d,maxFiles:c,aspectRatio:D,enableCrop:b=!0,convertToWebp:w=!0,cropSize:R,name:h,label:x,...u})=>{let{files:P,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:L}=N({filesToUpload:g,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:a,...u},enableCrop:b,customAspectRatio:D,convertToWebp:w,maxFiles:c,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z,currentImageIndex:k,totalPendingImages:T}=S,H=!!P?.length,j=q||!!l,ye=useMemo(()=>{let _e=x??"Ajustar Imagem",Oe=T>1?` (${k} de ${T})`:"";return `${_e}${Oe}`},[x,T,k]);return jsxs(K,{id:i,name:h,uploading:f,disabled:a,dropZoneSxProps:n,tabIndex:d,getRootProps:G,getInputProps:_,isDragActive:O,isError:j,dropZoneContent:jsx(Fragment,{children:m?jsx(ie,{children:m}):jsx(J,{header:s?.header,description:s?.description})}),children:[jsx(U,{disabled:a,helperText:p,isError:j}),H&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:P,thumbnail:!0,onRemove:v,onReorder:r})})}),jsx(a$4,{open:Z,onClose:z,label:ye,imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})},Lr=memo(Or);var Ur=({onFileSelect:e$1,onRemove:t,file:r,id:i,disabled:a,error:l,helperText:p,sx:g,dropZoneSxProps:n,uploading:s,tabIndex:m$1,...f$1})=>{let{file:d,dropzoneProps:c,handleRemove:D}=N({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:a,...f$1}}),{getRootProps:b,getInputProps:w,isDragActive:R,isDragReject:h}=c,x=useCallback(S=>{S.stopPropagation(),D(d||void 0);},[d,D]),u=!!d,P=typeof d=="string",F=h||!!l;return jsx(K,{id:i,uploading:s,disabled:a,dropZoneSxProps:n,tabIndex:m$1,getRootProps:b,getInputProps:w,isDragActive:R,isError:F,dropZoneContent:jsxs(Fragment,{children:[!u&&jsx(J,{}),u&&jsxs(ie,{component:m.div,...j().inUp,spacing:2,direction:"row",alignItems:"center",sx:{my:1,px:1,py:.75,borderRadius:.75,border:S=>`solid 1px ${S.palette.divider}`,...g},children:[jsx(f,{file:d}),jsxs(ie,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:P?d:d.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:P?"":e(d.size)})]}),t&&jsx(a$2,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:a,"aria-label":"Remover arquivo",onClick:x,children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(U,{disabled:a,helperText:p,isError:F})})},Nr=memo(Ur);var Wr=({onRemove:e,onFileSelect:t,file:r,id:i,disabled:a,error:l,helperText:p,dropZoneSxProps:g,placeholderProps:n,placeholderAlt:s,uploading:m,tabIndex:f,aspectRatio:d,enableCrop:c=!0,convertToWebp:D=!0,name:b,label:w,cropSize:R,...h})=>{let[x,u]=useState(!1),{file:P,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:L}=N({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,...h},enableCrop:c,customAspectRatio:d,convertToWebp:D,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z}=S,k=useCallback(()=>{v(P||void 0);},[P,v]),T=!!P,H=q||!!l,j=T?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(m||x)&&jsx(a$6,{}),jsxs(K,{id:i,uploading:m,disabled:a,dropZoneSxProps:g,tabIndex:f,getRootProps:G,getInputProps:_,isDragActive:O,isError:H,name:b,dropZoneContent:jsxs(Fragment,{children:[s?jsx(ie,{sx:j,children:s}):jsx(J,{sx:j,header:n?.title,description:n?.description}),T&&jsx(ze,{file:P,cropSize:R,isLoading:x,isUploading:m,onLoading:u,aspectRatio:L})]}),children:[jsx(U,{disabled:a,helperText:p,isError:H}),T&&e&&jsx(Qe,{size:"small",onClick:k,disabled:a,label:"Remover arquivo",children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$4,{open:Z,onClose:z,label:w??"Ajustar Imagem",imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})]})},$r=memo(Wr);var Jr=({onFileSelect:e,onRemove:t,file:r,disabled:i,label:a,id:l,tabIndex:p,error:g,helperText:n,sx:s,name:m,maxSize:f,uploading:d,aspectRatio:c=1,enableCrop:D=!0,convertToWebp:b=!0,cropSize:w,...R})=>{let[h,x]=useState(!1),{file:u,dropzoneProps:P,cropState:F,handleRemove:S}=N({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,maxSize:f,...R},enableCrop:D,customAspectRatio:c,convertToWebp:b,cropSize:w}),{getRootProps:v,getInputProps:L,isDragActive:G,isDragReject:_}=P,{cropModalOpen:O,imagePreview:q,cropLoading:Z,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=F,C=_||!!g,z=h||d,k=!!t,T=useMemo(()=>u?(x(!0),URL.createObjectURL(u)):"",[u]),H=()=>{x(!1);},j=()=>k&&u?()=>S(u):v().onClick;return jsxs(Fragment,{children:[jsxs(ao,{sx:s,isError:C,isDragActive:G,hasFile:!!u,...v(),onClick:j(),children:[jsxs(to,{children:[u&&jsx(no,{alt:"Avatar Preview",src:T,onLoad:H,...z&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&z&&jsx(io,{children:jsx(Kr,{size:135,thickness:1,color:"primary"})}),!u&&!z&&jsxs(Ce,{isError:C,hasFile:!1,children:[jsx(a$5,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!z&&jsxs(Ce,{isError:C,hasFile:!0,children:[jsx(a$5,{icon:k?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"common.white"},children:k?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:m,id:l,tabIndex:p,...L()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(U,{helperText:n,disabled:i,isError:C})}),u&&!z&&jsx(ie,{direction:"row",justifyContent:"center",spacing:1,sx:{pt:1,mb:-1},children:jsx(ke,{variant:"caption",component:"span",sx:{px:.75,cursor:"pointer",borderRadius:.75,color:"error.main","&:hover":{color:"error.dark",bgcolor:"background.default"}},onClick:()=>S(u),children:"Remover"})})]}),O&&q&&jsx(a$4,{open:O,onClose:re,label:a??"Ajustar Imagem",imageSrc:q,aspectRatio:c,onInitialized:ee,onSave:oe,loading:Z,cropSize:w,cropShape:"round"})]})},Qr=memo(Jr);var rt=({error:e,name:t,disabled:r,sx:i,...a})=>{let{getRootProps:l,getInputProps:p,isDragActive:g,isDragReject:n}=useDropzone({disabled:r,...a}),s=n||e;return jsxs(Ye,{...l(),isDragActive:g,hasError:!!s,disabled:!!r,sx:i,"data-testid":"upload-box",children:[jsx("input",{name:t,...p()}),"Selecionar arquivo"]})},tt=memo(rt);
35
36
 
36
- export { Ne as ContentType, Re as FileContentType, k as HelperText, fe as MultiFilePreview, Ar as MultipleFileUpload, yr as MultipleImageUpload, ze as SingleFilePreview, kr as SingleFileUpload, Zr as SingleImageUpload, Hr as UploadAvatar, et as UploadSimpleBox, fo as convertToWebP, ri as isImageFile, z as useDropzoneUploader, mr as useFileUploadService };
37
+ export { Ue as ContentType, De as FileContentType, U as HelperText, ue as MultiFilePreview, Dr as MultipleFileUpload, Lr as MultipleImageUpload, ze as SingleFilePreview, Nr as SingleFileUpload, $r as SingleImageUpload, Qr as UploadAvatar, tt as UploadSimpleBox, Po as convertToWebP, di as isImageFile, N as useDropzoneUploader, fr as useFileUploadService };
@@ -1,5 +1 @@
1
- import { useEffect } from 'react';
2
-
3
- var e=o=>{useEffect(o,[]);},u=e;
4
-
5
- export { u as default };
1
+ export { a as default } from '../chunk-S7QQBC4I.js';
@@ -0,0 +1,311 @@
1
+ import { StackProps } from '@mui/material/Stack';
2
+ import { SxProps, Theme } from '@mui/material/styles';
3
+ import { DropzoneOptions, DropzoneRootProps, FileRejection, DropzoneInputProps } from 'react-dropzone';
4
+ import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
5
+
6
+ interface FileUpload {
7
+ url: string;
8
+ file: File;
9
+ contentType: string;
10
+ resourceIds: string[];
11
+ }
12
+ interface ExtendFile extends File {
13
+ id?: string;
14
+ url?: string;
15
+ index?: number;
16
+ }
17
+ type CropSize = {
18
+ width: number;
19
+ height: number;
20
+ } | number;
21
+ type CreateFilesMutation = (files: File[] | ExtendFile[]) => Promise<string[] | undefined>;
22
+ interface FileCreateRequest {
23
+ files: Array<{
24
+ content_type: keyof typeof ContentType;
25
+ name: string;
26
+ }>;
27
+ }
28
+ interface FileCreateResponse {
29
+ files: Array<{
30
+ id: string;
31
+ name: string;
32
+ organization_id: string;
33
+ url: string;
34
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
35
+ content_type: string;
36
+ content_length: number;
37
+ created_by: string;
38
+ created_at: string;
39
+ updated_by: string;
40
+ updated_at: string;
41
+ }>;
42
+ }
43
+ interface FileQueryRequest {
44
+ ids: string[];
45
+ }
46
+ interface FileQueryResponse {
47
+ files: Array<{
48
+ id: string;
49
+ name: string;
50
+ organization_id: string;
51
+ url: string;
52
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
53
+ content_type: string;
54
+ content_length: number;
55
+ created_by: string;
56
+ created_at: string;
57
+ updated_by: string;
58
+ updated_at: string;
59
+ }>;
60
+ }
61
+ interface FileGetResponse {
62
+ id: string;
63
+ name: string;
64
+ organization_id: string;
65
+ url: string;
66
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
67
+ content_type: string;
68
+ content_length: number;
69
+ created_by: string;
70
+ created_at: string;
71
+ updated_by: string;
72
+ updated_at: string;
73
+ }
74
+ interface SingleFilePreviewProps extends StackProps {
75
+ file: File | string;
76
+ aspectRatio?: number;
77
+ isLoading?: boolean;
78
+ cropSize?: CropSize;
79
+ onLoading?: (isLoading: boolean) => void;
80
+ isUploading?: boolean;
81
+ }
82
+ interface LoadingPreviewImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
83
+ aspectRatio: number;
84
+ height?: number | string;
85
+ width?: number | string;
86
+ maxWidth?: number | string;
87
+ maxHeight?: number | string;
88
+ isLoading?: boolean;
89
+ isUploading?: boolean;
90
+ cropSize?: CropSize;
91
+ onLoading?: (isLoading: boolean) => void;
92
+ alt?: string;
93
+ src?: string;
94
+ loading: 'lazy';
95
+ ref?: React.RefObject<HTMLImageElement>;
96
+ }
97
+ interface PlaceholderProps extends StackProps {
98
+ header?: React.ReactNode;
99
+ description?: React.ReactNode;
100
+ }
101
+ interface SingleFileUploadProps extends DropzoneOptions {
102
+ onFileSelect: (file?: File) => void;
103
+ onRemove?: (file?: File) => void;
104
+ placeholderProps?: PlaceholderProps;
105
+ placeholderAlt?: React.ReactNode;
106
+ file?: File;
107
+ name?: string;
108
+ label?: string;
109
+ id?: string;
110
+ disabled?: boolean;
111
+ error?: string;
112
+ helperText?: string | React.ReactNode;
113
+ sx?: SxProps<Theme>;
114
+ dropZoneSxProps?: SxProps;
115
+ uploading?: boolean;
116
+ tabIndex?: number;
117
+ maxSize?: number;
118
+ }
119
+ interface SingleImageUploadProps extends SingleFileUploadProps {
120
+ aspectRatio?: number;
121
+ enableCrop?: boolean;
122
+ convertToWebp?: boolean;
123
+ cropSize?: CropSize;
124
+ }
125
+ interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'file' | 'onFileSelect'> {
126
+ onFilesSelect: (files?: File[] | ExtendFile[]) => void;
127
+ onRemoveAll?: (files?: File[] | ExtendFile[]) => void;
128
+ onReorder?: (oldIndex: number, newIndex: number) => void;
129
+ files?: File[] | ExtendFile[];
130
+ maxFiles?: number;
131
+ thumbnail?: boolean;
132
+ }
133
+ interface MultiImageUploadProps extends MultiFileUploadProps {
134
+ aspectRatio?: number;
135
+ enableCrop?: boolean;
136
+ convertToWebp?: boolean;
137
+ cropSize?: CropSize;
138
+ }
139
+ interface SortableItemProps extends StackProps {
140
+ onRemove?: (file?: File) => void;
141
+ file?: ExtendFile;
142
+ thumbnail?: boolean;
143
+ disableDrag?: boolean;
144
+ }
145
+ interface MultiFilePreviewProps extends StackProps {
146
+ onReorder?: (oldIndex: number, newIndex: number) => void;
147
+ onRemove?: (file?: ExtendFile) => void;
148
+ files: ExtendFile[];
149
+ lastNode?: React.ReactNode;
150
+ firstNode?: React.ReactNode;
151
+ thumbnail: boolean;
152
+ slotProps?: {
153
+ thumbnail?: Omit<FileThumbnailProps, 'file'>;
154
+ };
155
+ }
156
+ interface StyledDropZoneProps extends StackProps {
157
+ isDragActive: boolean;
158
+ isError: boolean;
159
+ disabled: boolean;
160
+ }
161
+ type StyledDropZonePropsType = Omit<DropzoneRootProps, 'children' | 'onDrop' | 'onError'> & StyledDropZoneProps;
162
+ interface RejectionFilesProps extends StackProps {
163
+ files: FileRejection[];
164
+ }
165
+ interface ThumbnailBadgeProps {
166
+ onRemove?: (file?: ExtendFile) => void;
167
+ file: ExtendFile;
168
+ attributes: DraggableAttributes;
169
+ listeners: DraggableSyntheticListeners;
170
+ innerWidth: number;
171
+ isDragging: boolean;
172
+ disableDrag?: boolean;
173
+ sx?: SxProps<Theme>;
174
+ }
175
+ interface DropZoneProps {
176
+ sx?: SxProps;
177
+ uploading?: boolean;
178
+ id?: string;
179
+ tabIndex?: number;
180
+ getRootProps: () => DropzoneRootProps;
181
+ getInputProps: () => DropzoneInputProps;
182
+ isDragActive: boolean;
183
+ isError: boolean;
184
+ disabled?: boolean;
185
+ dropZoneSxProps?: SxProps;
186
+ dropZoneContent?: React.ReactNode;
187
+ children?: React.ReactNode;
188
+ name?: string;
189
+ }
190
+ interface FileUploadProps {
191
+ createFilesMutation: (params: FileCreateRequest) => {
192
+ unwrap: () => Promise<FileCreateResponse>;
193
+ };
194
+ files?: FileGetResponse[];
195
+ file?: FileGetResponse;
196
+ skip?: boolean;
197
+ }
198
+ interface HelperTextProps {
199
+ helperText?: string | React.ReactNode;
200
+ disabled?: boolean;
201
+ isError?: boolean;
202
+ }
203
+ declare enum ContentType {
204
+ APPLICATION_OCTET_STREAM = "application/octet-stream",
205
+ IMAGE_JPEG = "image/jpeg",
206
+ IMAGE_JPG = "image/jpg",
207
+ IMAGE_PNG = "image/png",
208
+ IMAGE_GIF = "image/gif",
209
+ IMAGE_WEBP = "image/webp",
210
+ IMAGE_SVG = "image/svg+xml",
211
+ IMAGE_BMP = "image/bmp",
212
+ IMAGE_TIFF = "image/tiff",
213
+ IMAGE_ICO = "image/x-icon",
214
+ IMAGE_AVIF = "image/avif",
215
+ APPLICATION_PDF = "application/pdf",
216
+ TEXT_PLAIN = "text/plain",
217
+ TEXT_CSV = "text/csv",
218
+ APPLICATION_RTF = "application/rtf",
219
+ APPLICATION_MSWORD = "application/msword",
220
+ APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
221
+ APPLICATION_MSEXCEL = "application/vnd.ms-excel",
222
+ APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
223
+ APPLICATION_MSPOWERPOINT = "application/vnd.ms-powerpoint",
224
+ APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
225
+ APPLICATION_ODT = "application/vnd.oasis.opendocument.text",
226
+ APPLICATION_ODS = "application/vnd.oasis.opendocument.spreadsheet",
227
+ APPLICATION_ODP = "application/vnd.oasis.opendocument.presentation",
228
+ APPLICATION_XML = "application/xml",
229
+ TEXT_XML = "text/xml",
230
+ TEXT_HTML = "text/html",
231
+ TEXT_CSS = "text/css",
232
+ APPLICATION_JSON = "application/json",
233
+ TEXT_JAVASCRIPT = "text/javascript",
234
+ APPLICATION_ZIP = "application/zip",
235
+ APPLICATION_GZIP = "application/gzip",
236
+ APPLICATION_RAR = "application/vnd.rar",
237
+ APPLICATION_7Z = "application/x-7z-compressed",
238
+ AUDIO_MPEG = "audio/mpeg",
239
+ AUDIO_WAV = "audio/wav",
240
+ AUDIO_OGG = "audio/ogg",
241
+ AUDIO_WEBM = "audio/webm",
242
+ AUDIO_AAC = "audio/aac",
243
+ VIDEO_MP4 = "video/mp4",
244
+ VIDEO_MPEG = "video/mpeg",
245
+ VIDEO_OGG = "video/ogg",
246
+ VIDEO_WEBM = "video/webm",
247
+ VIDEO_QUICKTIME = "video/quicktime"
248
+ }
249
+ declare enum FileContentType {
250
+ 'application/octet-stream' = "APPLICATION_OCTET_STREAM",
251
+ 'image/jpeg' = "IMAGE_JPEG",
252
+ 'image/jpg' = "IMAGE_JPG",
253
+ 'image/png' = "IMAGE_PNG",
254
+ 'image/gif' = "IMAGE_GIF",
255
+ 'image/webp' = "IMAGE_WEBP",
256
+ 'image/svg+xml' = "IMAGE_SVG",
257
+ 'image/bmp' = "IMAGE_BMP",
258
+ 'image/tiff' = "IMAGE_TIFF",
259
+ 'image/x-icon' = "IMAGE_ICO",
260
+ 'image/avif' = "IMAGE_AVIF",
261
+ 'application/pdf' = "APPLICATION_PDF",
262
+ 'text/plain' = "TEXT_PLAIN",
263
+ 'text/csv' = "TEXT_CSV",
264
+ 'application/rtf' = "APPLICATION_RTF",
265
+ 'application/msword' = "APPLICATION_MSWORD",
266
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' = "APPLICATION_DOCX",
267
+ 'application/vnd.ms-excel' = "APPLICATION_MSEXCEL",
268
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' = "APPLICATION_XLSX",
269
+ 'application/vnd.ms-powerpoint' = "APPLICATION_MSPOWERPOINT",
270
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' = "APPLICATION_PPTX",
271
+ 'application/vnd.oasis.opendocument.text' = "APPLICATION_ODT",
272
+ 'application/vnd.oasis.opendocument.spreadsheet' = "APPLICATION_ODS",
273
+ 'application/vnd.oasis.opendocument.presentation' = "APPLICATION_ODP",
274
+ 'application/xml' = "APPLICATION_XML",
275
+ 'text/xml' = "TEXT_XML",
276
+ 'text/html' = "TEXT_HTML",
277
+ 'text/css' = "TEXT_CSS",
278
+ 'application/json' = "APPLICATION_JSON",
279
+ 'text/javascript' = "TEXT_JAVASCRIPT",
280
+ 'application/zip' = "APPLICATION_ZIP",
281
+ 'application/gzip' = "APPLICATION_GZIP",
282
+ 'application/vnd.rar' = "APPLICATION_RAR",
283
+ 'application/x-7z-compressed' = "APPLICATION_7Z",
284
+ 'audio/mpeg' = "AUDIO_MPEG",
285
+ 'audio/wav' = "AUDIO_WAV",
286
+ 'audio/ogg' = "AUDIO_OGG",
287
+ 'audio/webm' = "AUDIO_WEBM",
288
+ 'audio/aac' = "AUDIO_AAC",
289
+ 'video/mp4' = "VIDEO_MP4",
290
+ 'video/mpeg' = "VIDEO_MPEG",
291
+ 'video/ogg' = "VIDEO_OGG",
292
+ 'video/webm' = "VIDEO_WEBM",
293
+ 'video/quicktime' = "VIDEO_QUICKTIME"
294
+ }
295
+
296
+ type FileThumbnailProps = StackProps & {
297
+ tooltip?: boolean;
298
+ file: ExtendFile;
299
+ imageView?: boolean;
300
+ sx?: SxProps<Theme>;
301
+ onDownload?: () => void;
302
+ onRemove?: () => void;
303
+ slotProps?: {
304
+ img?: SxProps<Theme>;
305
+ icon?: SxProps<Theme>;
306
+ removeBtn?: SxProps<Theme>;
307
+ downloadBtn?: SxProps<Theme>;
308
+ };
309
+ };
310
+
311
+ 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, FileUploadProps as a, MultiFileUploadProps as b, MultiImageUploadProps as c, SingleFileUploadProps as d, SingleImageUploadProps as e, FileContentType as f, FileUpload as g, CropSize as h, CreateFilesMutation as i, FileCreateRequest as j, FileCreateResponse as k, FileQueryRequest as l, FileQueryResponse as m, FileGetResponse as n, SortableItemProps as o, StyledDropZoneProps as p, StyledDropZonePropsType as q };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.4.27",
3
+ "version": "2.4.29",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,11 +0,0 @@
1
- import { a as a$1 } from './chunk-YQ6K2DEP.js';
2
- import D from '@mui/material/Box';
3
- import P from '@mui/material/ButtonBase';
4
- import L from '@mui/material/IconButton';
5
- import N from '@mui/material/Stack';
6
- import S from '@mui/material/Tooltip';
7
- import { jsx, jsxs } from 'react/jsx-runtime';
8
-
9
- var O=["pdf"],F=["txt"],y=["psd"],R=["doc","docx"],C=["xls","xlsx"],k=["zip","rar","iso"],w=["ai","eps"],M=["ppt","pptx"],E=["wav","aif","mp3","aac"],A=["jpg","jpeg","gif","bmp","png","svg","webp"],B=["m4v","avi","mpg","mp4","webm"];function p(t){let e,o=a(t);return F.includes(o)?e="txt":k.includes(o)?e="zip":E.includes(o)?e="audio":A.includes(o)?e="image":B.includes(o)?e="video":R.includes(o)?e="word":C.includes(o)?e="excel":M.includes(o)?e="powerpoint":O.includes(o)?e="pdf":y.includes(o)?e="photoshop":w.includes(o)?e="illustrator":t?.startsWith("http")?e="image":e=a(t),e}function f(t){let e;switch(p(t)){case"folder":e="IC_FOLDER";break;case"txt":e="IC_TXT";break;case"zip":e="IC_ZIP";break;case"audio":e="IC_AUDIO";break;case"video":e="IC_VIDEO";break;case"word":e="IC_WORD";break;case"excel":e="IC_EXCEL";break;case"powerpoint":e="IC_POWER_POINT";break;case"pdf":e="IC_PDF";break;case"photoshop":e="IC_PTS";break;case"illustrator":e="IC_AI";break;case"image":e="IC_IMG";break;default:e="IC_FILE";}return e}function a(t){return t&&t.split(".").pop()||""}function v(t){return t.split("/").pop()}function u(t){return typeof t=="string"?{key:t,preview:t,name:v(t),type:a(t),size:void 0,path:t,lastModified:void 0,lastModifiedDate:void 0}:{key:`key:${t.name}${t.lastModified||Date.now()}`,name:t.name,size:t.size,path:t.path,type:t.type,preview:t.preview,lastModified:t.lastModified,lastModifiedDate:t.lastModifiedDate}}var s={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"},K=({sx:t,file:e,tooltip:o,onRemove:m,imageView:h,slotProps:r,onDownload:c,...I})=>{let l=typeof e=="string"?e:URL.createObjectURL(e),{name:b,path:g}=u(e),d=typeof e!="string"&&e.type.startsWith("image/")?"image":p(g||l),T=jsx(D,{component:"img",src:l,className:s.img,sx:{width:1,height:1,objectFit:"cover",borderRadius:"inherit",...r?.img}}),x=jsx(a$1,{icon:f(d),sx:{width:32,height:32,flexShrink:0,...t}}),_=jsxs(N,{component:"span",className:s.root,sx:{width:36,height:36,flexShrink:0,borderRadius:1.25,alignItems:"center",position:"relative",display:"inline-flex",justifyContent:"center",...t},...I,children:[d==="image"&&h?T:x,m&&jsx(P,{onClick:m,className:s.removeBtn,sx:r?.removeBtn,children:jsx(a$1,{icon:"CLOSE_MARK_BUTTON",width:24})}),c&&jsx(L,{onClick:c,className:s.downloadBtn,sx:r?.downloadBtn,size:"small",children:jsx(a$1,{icon:"ARROW_DOWN_CICLE",width:12})})]});return o?jsx(S,{arrow:!0,title:b,slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,-12]}}]}},children:_}):_};
10
-
11
- export { p as a, f as b, a as c, v as d, u as e, s as f, K as g };
@@ -1,24 +0,0 @@
1
- import { StackProps } from '@mui/material/Stack';
2
- import { SxProps, Theme } from '@mui/material/styles';
3
-
4
- interface ExtendFile extends File {
5
- path?: string;
6
- preview?: string;
7
- lastModifiedDate?: Date;
8
- }
9
- type FileThumbnailProps = StackProps & {
10
- tooltip?: boolean;
11
- file: File | string;
12
- imageView?: boolean;
13
- sx?: SxProps<Theme>;
14
- onDownload?: () => void;
15
- onRemove?: () => void;
16
- slotProps?: {
17
- img?: SxProps<Theme>;
18
- icon?: SxProps<Theme>;
19
- removeBtn?: SxProps<Theme>;
20
- downloadBtn?: SxProps<Theme>;
21
- };
22
- };
23
-
24
- export { ExtendFile as E, FileThumbnailProps as F };