@zydon/common 2.4.27 → 2.4.28

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 };
@@ -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-a88ac60d.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-a88ac60d.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, P as PlaceholderProps, R as RejectionFilesProps, o as SortableItemProps, p as StyledDropZoneProps, q as StyledDropZonePropsType, T as ThumbnailBadgeProps } from '../../types-a88ac60d.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';
@@ -15,22 +15,22 @@ import '../../chunk-CHLVIVDD.js';
15
15
  import '../../chunk-ILHUUK4X.js';
16
16
  import { a as a$7 } from '../../chunk-ONZBWH3C.js';
17
17
  import { memo, useRef, useEffect, useMemo, useCallback, useState } from 'react';
18
- import So from '@mui/material/FormHelperText';
18
+ import Fo from '@mui/material/FormHelperText';
19
19
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
20
20
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
21
21
  import { restrictToHorizontalAxis, restrictToParentElement, restrictToWindowEdges } from '@dnd-kit/modifiers';
22
22
  import { useSortable, sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
23
23
  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';
24
+ import ie from '@mui/material/Stack';
25
+ import Te from '@mui/material/Typography';
26
+ import me from '@mui/material/Box';
27
+ import _o from '@mui/material/IconButton';
28
+ import Oo from '@mui/material/Paper';
29
29
  import { styled, alpha } from '@mui/material/styles';
30
- import ko from '@mui/material/Badge';
30
+ import Co from '@mui/material/Badge';
31
31
  import { useDropzone } from 'react-dropzone';
32
32
  import qr from '@mui/material/CircularProgress';
33
33
 
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);
34
+ var So=({helperText:e,disabled:t,isError:r})=>e?jsx(Fo,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,N=memo(So);var Ae=styled(ie)({position:"relative",width:"100%",borderRadius:8,overflow:"hidden","&:hover .actions":{display:"flex"}}),Ee=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: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(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(_o)(({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]}})),Le=styled("div")({position:"relative",zIndex:1,"&:hover":{zIndex:2}}),He=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)"})),Ke=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)"})),Je=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)}})),Qe=styled(me,{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}})),Ye=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)"}})),eo=styled("img",{shouldForwardProp:e=>e!=="aspectRatio"&&e!=="isLoading"&&e!=="isUploading"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,isLoading:i,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>=a?"100%":`calc(100% * ${t})`,width:r>a?`calc(${t} * 100%)`:"100%",transition:"all 0.5s ease-in-out",...i||l?{opacity:0,filter:"blur(1.5rem)",transform:"translate(-50%, -50%) scale(0.7)"}:{},"&:hover":{transition:"all 0.2s ease-in-out"}})),oo=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)"}})),ro=styled(ie)({width:"100%",height:"100%",position:"relative",overflow:"hidden",borderRadius:"50%",justifyContent:"center",alignItems:"center"});styled(Oo)(({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)}})),to=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 io=styled(me,{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)"}}})),ao=styled("img")({width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover",transition:"all 0.3s ease-in-out"}),no=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,sx:t,file:r,disableDrag:a,attributes:i,listeners:l,innerWidth:p,isDragging:g})=>{let n=r?.id||r?.url||"";return jsx(Co,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Ke,{width:p,isDragging:g,"data-testid":`preview-multi-img-${n}`,...j().inUp,sx:t,children:[jsx(a$1,{disableDrag:a,...i,...l}),jsx(f,{tooltip:!0,imageView:!0,file:r}),jsx(Ee,{sx:{position:"absolute",right:3,top:3,zIndex:1},children:e&&jsx(no,{size:"small",label:"Remover arquivo",onClick:()=>e(r),icon:"DELETE_MARK_BUTTON_02"})})]})},`badge-${n}`)},so=memo(zo);var Bo=({file:e$1,thumbnail:t,onRemove:r,sx:a$3,disableDrag:i=!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=i?70:80,{attributes:c,listeners:P,setNodeRef:d,transform:m,transition:D,isDragging:I}=useSortable({id:g,disabled:i}),E={transform:x.Transform.toString(m),transition:D,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${s+8}px`,height:"68px"};return t&&e$1?jsx(Le,{ref:d,style:E,children:jsx(so,{innerWidth:s,isDragging:I,sx:a$3,file:e$1,disableDrag:i,attributes:c,listeners:P,onRemove:r})}):jsx(Le,{ref:d,style:{...E,height:"80px",width:`${s+38}px`},children:jsxs(He,{width:s+30,isDragging:I,"data-testid":`preview-multi-img-${g}`,...j().inUp,sx:a$3,children:[jsx(a$1,{disableDrag:i,...c,...P}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$2,{title:p,children:jsx(Te,{variant:"subtitle2",noWrap:!0,children:p})}),jsx(Te,{variant:"caption",sx:{color:"text.secondary"},children:n?"":e(l)})]}),jsx(Ee,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},co=memo(Bo);var er=({thumbnail:e,files:t,onRemove:r,onReorder:a,sx:i})=>{let l=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates}));if(!t?.length)return null;let p=n=>{let{active:s,over:c}=n;if(!(!s||!c||s.id===c.id)&&a){let P=t.findIndex(({id:m})=>m===s.id),d=t.findIndex(({id:m})=>m===c.id);P!==-1&&d!==-1&&a(P,d);}},g=jsx(AnimatePresence,{initial:!1,children:t.map(n=>jsx(co,{sx:i,file:n,onRemove:r,thumbnail:e,disableDrag:!a},n.id))});return a?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(er);var ir=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:l})=>{let p=useRef(null),g=typeof e=="string"?e:e.name,n=typeof e=="string"?e:URL.createObjectURL(e);useEffect(()=>{p.current&&!p.current.complete?i?.(!0):i?.(!1);},[p,i]);let s=typeof l=="number"?l*t:l?.width,c=typeof l=="number"?l:l?.height;return jsxs(Ye,{children:[jsx(eo,{aspectRatio:t,isLoading:a,isUploading:r,height:c,width:s,alt:g,src:n,ref:p,onLoad:()=>i?.(!1),onError:()=>i?.(!1)}),jsx(oo,{alt:g,src:n,isLoading:a,isUploading:r})]})},ze=memo(ir);var oi=e=>e.startsWith("image/"),uo=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),l=i.getContext("2d"),p=new Image;p.onload=()=>{i.width=p.width,i.height=p.height,l?(l.drawImage(p,0,0),i.toBlob(g=>{if(g){let n=new File([g],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(n);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},p.onerror=()=>a(new Error("Falha ao carregar imagem")),p.src=URL.createObjectURL(e);});var sr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:l=!1,customAspectRatio:p,convertToWebp:g=!0,maxFiles:n,cropSize:s})=>{let{showErrorMessage:c}=a$7(),P=useMemo(()=>p||(s&&typeof s!="number"?s.width/s.height:1),[p,s]),[d,m]=useState([]),[D,I]=useState(!1),[E,R]=useState(null),[h,f]=useState(null),[u,x]=useState(""),[F,S]=useState(!1),[v,M]=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)?m(e$1.filter(o=>o instanceof File)):e$1 instanceof File?m([e$1]):e$1===null&&m([]));},[e$1]);let Z=useCallback(()=>{if(v.length>0&&l){let o=v[0];R(o),_(b=>b+1);let w=new FileReader;w.onload=()=>{x(w.result),I(!0);},w.readAsDataURL(o);}},[v,l]);useEffect(()=>{Z();},[Z]);let ee=useCallback((o,w)=>{f(w);},[]),oe=async()=>!E||!h?null:new Promise(o=>{let w=document.createElement("canvas"),b=w.getContext("2d"),W=new Image;W.onload=async()=>{let{width:de,height:V,x:Eo,y:wo}=h,xe=de,Pe=V;s&&(typeof s=="number"?(xe=s,Pe=s/P):(xe=s.width,Pe=s.height)),w.width=xe,w.height=Pe,b?(b.drawImage(W,Eo,wo,de,V,0,0,xe,Pe),w.toBlob(async We=>{if(We){let Me=new File([We],E.name,{type:E.type,lastModified:Date.now()});if(g)try{Me=await uo(Me);}catch(Do){c(Do,"Erro ao converter para WebP");}o(Me);}else o(null);},"image/png")):o(null);},W.src=u;}),re=async()=>{if(!(!E||!h)){S(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let b=n?[...O,o].slice(0,n):[...O,o];m(b),r?.(b);}else m([o]),t?.(o);let w=v.slice(1);M(w),I(!1),x(""),R(null),w.length>0&&setTimeout(()=>Z(),100);}catch(o){c(o,"Erro ao processar imagem");}finally{S(!1);}}},C=()=>{I(!1),x(""),R(null),M([]),_(0);},z=useCallback(o=>{if(o.length===0)return;if(i?.accept&&Object.keys(i.accept).some(b=>b.includes("image/"))&&l)if(Array.isArray(e$1)||e$1===void 0&&r){let b=o.filter(V=>V.type.startsWith("image/")),W=O.map(V=>V.name),de=b.filter(V=>!W.includes(V.name));if(de.length===0){c("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}M(de),_(0);}else {let b=o[0];R(b);let W=new FileReader;W.onload=()=>{x(W.result),I(!0);},W.readAsDataURL(b);}else if(Array.isArray(e$1)||e$1===void 0&&r){let b=n?[...O,...o].slice(0,n):[...O,...o];m(b),r?.(b);}else {let b=o[0];m([b]),t?.(b);}},[e$1,O,t,r,l,n,i,c]),T=useCallback(o=>{if(!o.length)return;let w=o[0]?.errors[0]?.code,b=i?.maxSize||3145728;c(w==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(b)}`):w==="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,c]),{getRootProps:U,getInputProps:X,isDragActive:j,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:z,onDropRejected:T,...i}),Oe=useCallback(o=>{if(!o){m([]),a?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let w=d.filter(b=>b.name!==o.name);m(w),a?.(o),r&&r(w);}else m([]),a?.(o);},[e$1,d,r,a]),Ao=useCallback(()=>{m([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:q,files:O,aspectRatio:P,dropzoneProps:{getRootProps:U,getInputProps:X,isDragActive:j,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:D,imagePreview:u,cropLoading:F,setCropModalOpen:I,onCropInitialized:ee,handleCropSave:re,handleCropCancel:C,currentImageIndex:G,totalPendingImages:v.length},handleRemove:Oe,clearFiles:Ao,setFiles:m}},k=sr;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||{}),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 dr=({createFilesMutation:e,files:t,file:r,skip:a})=>{let{showErrorMessage:i}=a$7(),[l,p]=useState(!1),[g,n]=useState(!1),[s,c]=useState(null),[P,d]=useState(void 0),m=useMemo(()=>P?.[0],[P]),D=useMemo(()=>{if(!a)return r?[r]:t},[r,t,a]),I=useCallback(async h=>{if(!h?.length){d(void 0);return}try{n(!0);let f=await Promise.all(h.map(async({url:u,name:x,id:F},S)=>{let M=await(await fetch(u)).blob(),G=x||u.split("/").pop()||"image",_=new File([M],G,{type:M.type});return _.id=F,_.url=u,_.index=S,_}));d(f);}catch(f){console.error("Erro ao carregar preview dos arquivos:",f),d(void 0);}finally{n(!1);}},[]),E=g||l;return useEffect(()=>{I(D);},[D,I]),{filesPreview:P,filePreview:m,uploadFiles:async h=>{if(h?.length){p(!0);try{let f=h[0].type||"application/octet-stream",u=De[f];if(!u)throw new Error(`Tipo de arquivo n\xE3o suportado: ${f}`);let x=await e({files:[{content_type:u,name:h[0].name}]}).unwrap(),F=x.files.map(v=>v.id);return (await Promise.all(h.map(v=>fetch(x.files[0].url,{method:"PUT",headers:{"Content-Type":f},body:v})))).forEach(v=>{if(!v.ok)throw new Error(`Erro no upload: ${v.statusText}`)}),I(x.files),F}catch(f){throw c(f),i(f,"Erro no upload"),f}finally{p(!1);}}},isUploadingFiles:l,isLoadingPreview:g,isUploadOrLoadingFiles:E,uploadFilesError:s}},cr=dr;var gr=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:l,getInputProps:p,isDragActive:g,isError:n,disabled:s,dropZoneSxProps:c,dropZoneContent:P,children:d,...m})=>jsxs(Ae,{children:[i&&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:c,...m,children:[jsx("input",{...p(),id:t,tabIndex:a,name:r}),P]}),d]})]}),K=gr;var xr=({header:e,description:t,sx:r,...a})=>jsxs(ie,{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(Te,{gutterBottom:!0,variant:"h5",children:e||"Soltar ou selecionar arquivos"}),jsx(Te,{variant:"body2",sx:{color:"text.secondary"},children:t||jsxs(Fragment,{children:["Solte os arquivos aqui ou clique",jsx(Te,{variant:"body2",component:"span",sx:{mx:.5,color:"primary.main",textDecoration:"underline"},children:"procurar"}),"na sua m\xE1quina"]})})]})]}),J=memo(xr);var hr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:l,helperText:p,files:g,thumbnail:n,dropZoneSxProps:s,uploading:c,tabIndex:P,maxFiles:d,...m})=>{let{files:D,dropzoneProps:I,handleRemove:E}=k({filesToUpload:g,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...m},maxFiles:d}),{getRootProps:R,getInputProps:h,isDragActive:f,isDragReject:u}=I,x=!!D?.length,F=u||!!l;return jsxs(K,{id:a,uploading:c,disabled:i,dropZoneSxProps:s,tabIndex:P,getRootProps:R,getInputProps:h,isDragActive:f,isError:F,dropZoneContent:jsx(J,{}),children:[jsx(N,{disabled:i,helperText:p,isError:F}),x&&jsx(me,{sx:{my:3},children:jsx(ue,{files:D,thumbnail:!!n,onRemove:e?E:void 0,onReorder:t})})]})},vr=memo(hr);var Fr=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:l,helperText:p,files:g,dropZoneSxProps:n,placeholderProps:s,placeholderAlt:c,uploading:P,tabIndex:d,maxFiles:m,aspectRatio:D,enableCrop:I=!0,convertToWebp:E=!0,cropSize:R,name:h,label:f,...u})=>{let{files:x,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:M}=k({filesToUpload:g,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...u},enableCrop:I,customAspectRatio:D,convertToWebp:E,maxFiles:m,cropSize:R}),{getRootProps:G,getInputProps:_,isDragActive:O,isDragReject:q}=F,{cropModalOpen:Z,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:C,handleCropCancel:z,currentImageIndex:T,totalPendingImages:U}=S,X=!!x?.length,j=q||!!l,ye=useMemo(()=>{let _e=f??"Ajustar Imagem",Oe=U>1?` (${T} de ${U})`:"";return `${_e}${Oe}`},[f,U,T]);return jsxs(K,{id:a,name:h,uploading:P,disabled:i,dropZoneSxProps:n,tabIndex:d,getRootProps:G,getInputProps:_,isDragActive:O,isError:j,dropZoneContent:jsx(Fragment,{children:c?jsx(ie,{children:c}):jsx(J,{header:s?.header,description:s?.description})}),children:[jsx(N,{disabled:i,helperText:p,isError:j}),X&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:x,thumbnail:!0,onRemove:v,onReorder:r})})}),jsx(a$4,{open:Z,onClose:z,label:ye,imageSrc:ee,aspectRatio:M,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})},Sr=memo(Fr);var Lr=({onFileSelect:e$1,onRemove:t,file:r,id:a,disabled:i,error:l,helperText:p,sx:g,dropZoneSxProps:n,uploading:s,tabIndex:c,...P})=>{let{file:d,dropzoneProps:m$1,handleRemove:D}=k({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...P}}),{getRootProps:I,getInputProps:E,isDragActive:R,isDragReject:h}=m$1,f$1=useCallback(S=>{S.stopPropagation(),D(d||void 0);},[d,D]),u=!!d,x=typeof d=="string",F=h||!!l;return jsx(K,{id:a,uploading:s,disabled:i,dropZoneSxProps:n,tabIndex:c,getRootProps:I,getInputProps:E,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(Te,{variant:"subtitle2",noWrap:!0,children:x?d:d.name}),jsx(Te,{variant:"caption",sx:{color:"text.secondary"},children:x?"":e(d.size)})]}),t&&jsx(a$2,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:f$1,children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(N,{disabled:i,helperText:p,isError:F})})},Cr=memo(Lr);var Br=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:l,helperText:p,dropZoneSxProps:g,placeholderProps:n,placeholderAlt:s,uploading:c,tabIndex:P,aspectRatio:d,enableCrop:m=!0,convertToWebp:D=!0,name:I,label:E,cropSize:R,...h})=>{let[f,u]=useState(!1),{file:x,dropzoneProps:F,cropState:S,handleRemove:v,aspectRatio:M}=k({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...h},enableCrop:m,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,T=useCallback(()=>{v(x||void 0);},[x,v]),U=!!x,X=q||!!l,j=U?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(c||f)&&jsx(a$6,{}),jsxs(K,{id:a,uploading:c,disabled:i,dropZoneSxProps:g,tabIndex:P,getRootProps:G,getInputProps:_,isDragActive:O,isError:X,name:I,dropZoneContent:jsxs(Fragment,{children:[s?jsx(ie,{sx:j,children:s}):jsx(J,{sx:j,header:n?.title,description:n?.description}),U&&jsx(ze,{file:x,cropSize:R,isLoading:f,isUploading:c,onLoading:u,aspectRatio:M})]}),children:[jsx(N,{disabled:i,helperText:p,isError:X}),U&&e&&jsx(Je,{size:"small",onClick:T,disabled:i,label:"Remover arquivo",children:jsx(a$5,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$4,{open:Z,onClose:z,label:E??"Ajustar Imagem",imageSrc:ee,aspectRatio:M,onInitialized:re,onSave:C,loading:oe,cropSize:R})]})]})},Gr=memo(Br);var Xr=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:l,tabIndex:p,error:g,helperText:n,sx:s,name:c,maxSize:P,uploading:d,aspectRatio:m=1,enableCrop:D=!0,convertToWebp:I=!0,cropSize:E,...R})=>{let[h,f]=useState(!1),{file:u,dropzoneProps:x,cropState:F,handleRemove:S}=k({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:P,...R},enableCrop:D,customAspectRatio:m,convertToWebp:I,cropSize:E}),{getRootProps:v,getInputProps:M,isDragActive:G,isDragReject:_}=x,{cropModalOpen:O,imagePreview:q,cropLoading:Z,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=F,C=_||!!g,z=h||d,T=!!t,U=useMemo(()=>u?(f(!0),URL.createObjectURL(u)):"",[u]),X=()=>{f(!1);},j=()=>T&&u?()=>S(u):v().onClick;return jsxs(Fragment,{children:[jsxs(io,{sx:s,isError:C,isDragActive:G,hasFile:!!u,...v(),onClick:j(),children:[jsxs(ro,{children:[u&&jsx(ao,{alt:"Avatar Preview",src:U,onLoad:X,...z&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&z&&jsx(to,{children:jsx(qr,{size:135,thickness:1,color:"primary"})}),!u&&!z&&jsxs(Ce,{isError:C,hasFile:!1,children:[jsx(a$5,{icon:"ADD_IMAGE",width:32}),jsx(Te,{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:T?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(Te,{variant:"caption",textAlign:"center",sx:{color:C?"error.main":"common.white"},children:T?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:c,id:l,tabIndex:p,...M()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(N,{helperText:n,disabled:a,isError:C})}),u&&!z&&jsx(ie,{direction:"row",justifyContent:"center",spacing:1,sx:{pt:1,mb:-1},children:jsx(Te,{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:i??"Ajustar Imagem",imageSrc:q,aspectRatio:m,onInitialized:ee,onSave:oe,loading:Z,cropSize:E,cropShape:"round"})]})},Vr=memo(Xr);var Qr=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:l,getInputProps:p,isDragActive:g,isDragReject:n}=useDropzone({disabled:r,...i}),s=n||e;return jsxs(Qe,{...l(),isDragActive:g,hasError:!!s,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...p()}),"Selecionar arquivo"]})},Yr=memo(Qr);
35
35
 
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 };
36
+ export { Ne as ContentType, De as FileContentType, N as HelperText, ue as MultiFilePreview, vr as MultipleFileUpload, Sr as MultipleImageUpload, ze as SingleFilePreview, Cr as SingleFileUpload, Gr as SingleImageUpload, Vr as UploadAvatar, Yr as UploadSimpleBox, uo as convertToWebP, oi as isImageFile, k as useDropzoneUploader, cr as useFileUploadService };
@@ -0,0 +1,296 @@
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 PlaceholderProps extends StackProps {
83
+ header?: React.ReactNode;
84
+ description?: React.ReactNode;
85
+ }
86
+ interface SingleFileUploadProps extends DropzoneOptions {
87
+ onFileSelect: (file?: File) => void;
88
+ onRemove?: (file?: File) => void;
89
+ placeholderProps?: PlaceholderProps;
90
+ placeholderAlt?: React.ReactNode;
91
+ file?: File;
92
+ name?: string;
93
+ label?: string;
94
+ id?: string;
95
+ disabled?: boolean;
96
+ error?: string;
97
+ helperText?: string | React.ReactNode;
98
+ sx?: SxProps<Theme>;
99
+ dropZoneSxProps?: SxProps;
100
+ uploading?: boolean;
101
+ tabIndex?: number;
102
+ maxSize?: number;
103
+ }
104
+ interface SingleImageUploadProps extends SingleFileUploadProps {
105
+ aspectRatio?: number;
106
+ enableCrop?: boolean;
107
+ convertToWebp?: boolean;
108
+ cropSize?: CropSize;
109
+ }
110
+ interface MultiFileUploadProps extends Omit<SingleFileUploadProps, 'file' | 'onFileSelect'> {
111
+ onFilesSelect: (files?: File[] | ExtendFile[]) => void;
112
+ onRemoveAll?: (files?: File[] | ExtendFile[]) => void;
113
+ onReorder?: (oldIndex: number, newIndex: number) => void;
114
+ files?: File[] | ExtendFile[];
115
+ maxFiles?: number;
116
+ thumbnail?: boolean;
117
+ }
118
+ interface MultiImageUploadProps extends MultiFileUploadProps {
119
+ aspectRatio?: number;
120
+ enableCrop?: boolean;
121
+ convertToWebp?: boolean;
122
+ cropSize?: CropSize;
123
+ }
124
+ interface SortableItemProps extends StackProps {
125
+ onRemove?: (file?: File) => void;
126
+ file?: ExtendFile;
127
+ thumbnail?: boolean;
128
+ disableDrag?: boolean;
129
+ }
130
+ interface MultiFilePreviewProps extends StackProps {
131
+ onReorder?: (oldIndex: number, newIndex: number) => void;
132
+ onRemove?: (file?: ExtendFile) => void;
133
+ files: ExtendFile[];
134
+ lastNode?: React.ReactNode;
135
+ firstNode?: React.ReactNode;
136
+ thumbnail: boolean;
137
+ slotProps?: {
138
+ thumbnail?: Omit<FileThumbnailProps, 'file'>;
139
+ };
140
+ }
141
+ interface StyledDropZoneProps extends StackProps {
142
+ isDragActive: boolean;
143
+ isError: boolean;
144
+ disabled: boolean;
145
+ }
146
+ type StyledDropZonePropsType = Omit<DropzoneRootProps, 'children' | 'onDrop' | 'onError'> & StyledDropZoneProps;
147
+ interface RejectionFilesProps extends StackProps {
148
+ files: FileRejection[];
149
+ }
150
+ interface ThumbnailBadgeProps {
151
+ onRemove?: (file?: ExtendFile) => void;
152
+ file: ExtendFile;
153
+ attributes: DraggableAttributes;
154
+ listeners: DraggableSyntheticListeners;
155
+ innerWidth: number;
156
+ isDragging: boolean;
157
+ disableDrag?: boolean;
158
+ sx?: SxProps<Theme>;
159
+ }
160
+ interface DropZoneProps {
161
+ sx?: SxProps;
162
+ uploading?: boolean;
163
+ id?: string;
164
+ tabIndex?: number;
165
+ getRootProps: () => DropzoneRootProps;
166
+ getInputProps: () => DropzoneInputProps;
167
+ isDragActive: boolean;
168
+ isError: boolean;
169
+ disabled?: boolean;
170
+ dropZoneSxProps?: SxProps;
171
+ dropZoneContent?: React.ReactNode;
172
+ children?: React.ReactNode;
173
+ name?: string;
174
+ }
175
+ interface FileUploadProps {
176
+ createFilesMutation: (params: FileCreateRequest) => {
177
+ unwrap: () => Promise<FileCreateResponse>;
178
+ };
179
+ files?: FileGetResponse[];
180
+ file?: FileGetResponse;
181
+ skip?: boolean;
182
+ }
183
+ interface HelperTextProps {
184
+ helperText?: string | React.ReactNode;
185
+ disabled?: boolean;
186
+ isError?: boolean;
187
+ }
188
+ declare enum ContentType {
189
+ APPLICATION_OCTET_STREAM = "application/octet-stream",
190
+ IMAGE_JPEG = "image/jpeg",
191
+ IMAGE_JPG = "image/jpg",
192
+ IMAGE_PNG = "image/png",
193
+ IMAGE_GIF = "image/gif",
194
+ IMAGE_WEBP = "image/webp",
195
+ IMAGE_SVG = "image/svg+xml",
196
+ IMAGE_BMP = "image/bmp",
197
+ IMAGE_TIFF = "image/tiff",
198
+ IMAGE_ICO = "image/x-icon",
199
+ IMAGE_AVIF = "image/avif",
200
+ APPLICATION_PDF = "application/pdf",
201
+ TEXT_PLAIN = "text/plain",
202
+ TEXT_CSV = "text/csv",
203
+ APPLICATION_RTF = "application/rtf",
204
+ APPLICATION_MSWORD = "application/msword",
205
+ APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
206
+ APPLICATION_MSEXCEL = "application/vnd.ms-excel",
207
+ APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
208
+ APPLICATION_MSPOWERPOINT = "application/vnd.ms-powerpoint",
209
+ APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
210
+ APPLICATION_ODT = "application/vnd.oasis.opendocument.text",
211
+ APPLICATION_ODS = "application/vnd.oasis.opendocument.spreadsheet",
212
+ APPLICATION_ODP = "application/vnd.oasis.opendocument.presentation",
213
+ APPLICATION_XML = "application/xml",
214
+ TEXT_XML = "text/xml",
215
+ TEXT_HTML = "text/html",
216
+ TEXT_CSS = "text/css",
217
+ APPLICATION_JSON = "application/json",
218
+ TEXT_JAVASCRIPT = "text/javascript",
219
+ APPLICATION_ZIP = "application/zip",
220
+ APPLICATION_GZIP = "application/gzip",
221
+ APPLICATION_RAR = "application/vnd.rar",
222
+ APPLICATION_7Z = "application/x-7z-compressed",
223
+ AUDIO_MPEG = "audio/mpeg",
224
+ AUDIO_WAV = "audio/wav",
225
+ AUDIO_OGG = "audio/ogg",
226
+ AUDIO_WEBM = "audio/webm",
227
+ AUDIO_AAC = "audio/aac",
228
+ VIDEO_MP4 = "video/mp4",
229
+ VIDEO_MPEG = "video/mpeg",
230
+ VIDEO_OGG = "video/ogg",
231
+ VIDEO_WEBM = "video/webm",
232
+ VIDEO_QUICKTIME = "video/quicktime"
233
+ }
234
+ declare enum FileContentType {
235
+ 'application/octet-stream' = "APPLICATION_OCTET_STREAM",
236
+ 'image/jpeg' = "IMAGE_JPEG",
237
+ 'image/jpg' = "IMAGE_JPG",
238
+ 'image/png' = "IMAGE_PNG",
239
+ 'image/gif' = "IMAGE_GIF",
240
+ 'image/webp' = "IMAGE_WEBP",
241
+ 'image/svg+xml' = "IMAGE_SVG",
242
+ 'image/bmp' = "IMAGE_BMP",
243
+ 'image/tiff' = "IMAGE_TIFF",
244
+ 'image/x-icon' = "IMAGE_ICO",
245
+ 'image/avif' = "IMAGE_AVIF",
246
+ 'application/pdf' = "APPLICATION_PDF",
247
+ 'text/plain' = "TEXT_PLAIN",
248
+ 'text/csv' = "TEXT_CSV",
249
+ 'application/rtf' = "APPLICATION_RTF",
250
+ 'application/msword' = "APPLICATION_MSWORD",
251
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' = "APPLICATION_DOCX",
252
+ 'application/vnd.ms-excel' = "APPLICATION_MSEXCEL",
253
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' = "APPLICATION_XLSX",
254
+ 'application/vnd.ms-powerpoint' = "APPLICATION_MSPOWERPOINT",
255
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' = "APPLICATION_PPTX",
256
+ 'application/vnd.oasis.opendocument.text' = "APPLICATION_ODT",
257
+ 'application/vnd.oasis.opendocument.spreadsheet' = "APPLICATION_ODS",
258
+ 'application/vnd.oasis.opendocument.presentation' = "APPLICATION_ODP",
259
+ 'application/xml' = "APPLICATION_XML",
260
+ 'text/xml' = "TEXT_XML",
261
+ 'text/html' = "TEXT_HTML",
262
+ 'text/css' = "TEXT_CSS",
263
+ 'application/json' = "APPLICATION_JSON",
264
+ 'text/javascript' = "TEXT_JAVASCRIPT",
265
+ 'application/zip' = "APPLICATION_ZIP",
266
+ 'application/gzip' = "APPLICATION_GZIP",
267
+ 'application/vnd.rar' = "APPLICATION_RAR",
268
+ 'application/x-7z-compressed' = "APPLICATION_7Z",
269
+ 'audio/mpeg' = "AUDIO_MPEG",
270
+ 'audio/wav' = "AUDIO_WAV",
271
+ 'audio/ogg' = "AUDIO_OGG",
272
+ 'audio/webm' = "AUDIO_WEBM",
273
+ 'audio/aac' = "AUDIO_AAC",
274
+ 'video/mp4' = "VIDEO_MP4",
275
+ 'video/mpeg' = "VIDEO_MPEG",
276
+ 'video/ogg' = "VIDEO_OGG",
277
+ 'video/webm' = "VIDEO_WEBM",
278
+ 'video/quicktime' = "VIDEO_QUICKTIME"
279
+ }
280
+
281
+ type FileThumbnailProps = StackProps & {
282
+ tooltip?: boolean;
283
+ file: ExtendFile;
284
+ imageView?: boolean;
285
+ sx?: SxProps<Theme>;
286
+ onDownload?: () => void;
287
+ onRemove?: () => void;
288
+ slotProps?: {
289
+ img?: SxProps<Theme>;
290
+ icon?: SxProps<Theme>;
291
+ removeBtn?: SxProps<Theme>;
292
+ downloadBtn?: SxProps<Theme>;
293
+ };
294
+ };
295
+
296
+ export { ContentType as C, DropZoneProps as D, ExtendFile as E, FileThumbnailProps as F, HelperTextProps as H, 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.28",
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 };