@zydon/common 2.4.44 → 2.4.45
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { F as FileThumbnailProps } from '../../types-
|
|
2
|
+
import { F as FileThumbnailProps } from '../../types-d4c32eea.js';
|
|
3
3
|
import '@mui/material/Stack';
|
|
4
4
|
import '@mui/material/styles';
|
|
5
5
|
import 'react-dropzone';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { H as HelperTextProps, M as MultiFilePreviewProps, S as SingleFilePreviewProps, a as FileUploadProps, E as ExtendFile, b as MultiFileUploadProps, c as MultiImageUploadProps, d as SingleFileUploadProps, e as SingleImageUploadProps } from '../../types-
|
|
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-
|
|
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-d4c32eea.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-d4c32eea.js';
|
|
5
5
|
import { DropzoneOptions, useDropzone, FileRejection } from 'react-dropzone';
|
|
6
6
|
import { Area } from 'react-easy-crop';
|
|
7
7
|
import '@mui/material/Stack';
|
|
@@ -32,6 +32,6 @@ import ko from '@mui/material/Badge';
|
|
|
32
32
|
import { useDropzone } from 'react-dropzone';
|
|
33
33
|
import Yr from '@mui/material/CircularProgress';
|
|
34
34
|
|
|
35
|
-
var Mo=({helperText:e,disabled:t,isError:r})=>e?jsx(Lo,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,k=memo(Mo);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: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(zo)(({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: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(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"&&e!=="maxWidth"&&e!=="maxHeight"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,maxWidth:i,maxHeight:l,isLoading:d,isUploading:c})=>({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:i,maxHeight:l,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",...d||c?{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(No)(({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: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 Bo=({onRemove:e,sx:t,file:r,disableDrag:a,attributes:i,listeners:l,innerWidth:d,isDragging:c})=>{let s=r?.id||r?.url;return s?jsx(ko,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Je,{width:d,isDragging:c,"data-testid":`preview-multi-img-${s}`,...j().inUp,sx:t,children:[jsx(a$2,{disableDrag:a,...i,...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-${s}`):null},lo=memo(Bo);var $o=({file:e$1,thumbnail:t,onRemove:r,sx:a$1,disableDrag:i=!1})=>{let l=e$1?.size||0,d=e$1?.name||e$1?.url||e$1?.id,c=e$1?.id||e$1?.url||"",s=typeof e$1=="string",n=i?70:80,{attributes:p,listeners:x$1,setNodeRef:m,transform:g,transition:E,isDragging:v}=useSortable({id:c,disabled:i}),b={transform:x.Transform.toString(g),transition:E,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${n+8}px`,height:"68px"};return t&&e$1?jsx(Me,{ref:m,style:b,children:jsx(lo,{innerWidth:n,isDragging:v,sx:a$1,file:e$1,disableDrag:i,attributes:p,listeners:x$1,onRemove:r})}):jsx(Me,{ref:m,style:{...b,height:"80px",width:`${n+38}px`},children:jsxs(Ke,{width:n+30,isDragging:v,"data-testid":`preview-multi-img-${c}`,...j().inUp,sx:a$1,children:[jsx(a$2,{disableDrag:i,...p,...x$1}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:d,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:d})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:s?"":e(l)})]}),jsx(we,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo($o);var ar=({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 d=s=>{let{active:n,over:p}=s;if(!(!n||!p||n.id===p.id)&&a){let x=t.findIndex(({id:g})=>g===n.id),m=t.findIndex(({id:g})=>g===p.id);x!==-1&&m!==-1&&a(x,m);}},c=jsx(AnimatePresence,{initial:!1,children:t.map(s=>jsx(mo,{sx:i,file:s,onRemove:r,thumbnail:e,disableDrag:!a},s.id))});return a?jsx(DndContext,{sensors:l,collisionDetection:closestCenter,onDragEnd:d,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(s=>s.id),strategy:horizontalListSortingStrategy,children:c})}):c},ue=memo(ar);var fo=forwardRef(({onLoading:e,width:t,height:r,...a},i)=>{let[l,d]=useState("calc(100% - 16px)"),[c,s]=useState("calc(100% - 16px)");a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof i=="object"&&i?.current?e?.(!i.current.complete):e?.(!1);},[i,e]);function n(){if(typeof i=="object"&&i?.current&&t&&r){let{width:p,height:x}=i.current.getBoundingClientRect(),m=Number(t)<p?t:p,g=Number(r)<x?r:x;d(`calc(${m}px - 16px)`),s(`calc(${g}px - 16px)`);}e?.(!1);}return jsx(oo,{...a,ref:i,maxWidth:l,maxHeight:c,onLoad:n,onError:n})});fo.displayName="LoadingPreviewImage";var xo=fo;var mr=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:l})=>{let d=useRef(null),c=e?.id||e?.url||e?.name,s=e?.name||e?.url||e?.id,n=e?.url||URL.createObjectURL(e),p=typeof l=="number"?l*t:l?.width,x=typeof l=="number"?l:l?.height,m=useMemo(()=>`image-preview-${c}-${r}`,[c,r]);return c?jsxs(eo,{children:[jsx(xo,{aspectRatio:t,isLoading:a,isUploading:r,height:x,width:p,alt:s,src:n,ref:d,loading:"lazy",onLoading:i},m),jsx(ro,{alt:s,src:n,isLoading:a,isUploading:r})]}):null},ze=memo(mr);var ui=e=>e.startsWith("image/"),Io=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),l=i.getContext("2d"),d=new Image;d.onload=()=>{i.width=d.width,i.height=d.height,l?(l.drawImage(d,0,0),i.toBlob(c=>{if(c){let s=new File([c],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(s);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},d.onerror=()=>a(new Error("Falha ao carregar imagem")),d.src=URL.createObjectURL(e);});var fr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:l=!1,customAspectRatio:d,convertToWebp:c=!0,maxFiles:s,cropSize:n})=>{let{showErrorMessage:p}=a$8(),x=useMemo(()=>d||(n&&typeof n!="number"?n.width/n.height:1),[d,n]),[m,g]=useState([]),[E,v]=useState(!1),[b,P]=useState(null),[y,_]=useState(null),[u,f]=useState(""),[A,D]=useState(!1),[F,L]=useState([]),[O,z]=useState(0),R=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:m,[e$1,m]),M=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:m[0]||null,[e$1,m]);useEffect(()=>{e$1&&(Array.isArray(e$1)?g(e$1.filter(o=>o instanceof File)):e$1 instanceof File?g([e$1]):e$1===null&&g([]));},[e$1]);let j=useCallback(()=>{if(F.length>0&&l){let o=F[0];P(o),z(I=>I+1);let w=new FileReader;w.onload=()=>{f(w.result),v(!0);},w.readAsDataURL(o);}},[F,l]);useEffect(()=>{j();},[j]);let ee=useCallback((o,w)=>{_(w);},[]),oe=async()=>!b||!y?null:new Promise(o=>{let w=document.createElement("canvas"),I=w.getContext("2d"),$=new Image;$.onload=async()=>{let{width:de,height:X,x:So,y:yo}=y,xe=de,Pe=X;n&&(typeof n=="number"?(xe=n,Pe=n/x):(xe=n.width,Pe=n.height)),w.width=xe,w.height=Pe,I?(I.drawImage($,So,yo,de,X,0,0,xe,Pe),w.toBlob(async We=>{if(We){let Le=new File([We],b.name,{type:b.type,lastModified:Date.now()});if(c)try{Le=await Io(Le);}catch(_o){p(_o,"Erro ao converter para WebP");}o(Le);}else o(null);},"image/png")):o(null);},$.src=u;}),re=async()=>{if(!(!b||!y)){D(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let I=s?[...R,o].slice(0,s):[...R,o];g(I),r?.(I);}else g([o]),t?.(o);let w=F.slice(1);L(w),v(!1),f(""),P(null),w.length>0&&setTimeout(()=>j(),100);}catch(o){p(o,"Erro ao processar imagem");}finally{D(!1);}}},N=()=>{v(!1),f(""),P(null),L([]),z(0);},U=useCallback(o=>{if(o.length===0)return;if(i?.accept&&Object.keys(i.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/")),$=R.map(X=>X.name),de=I.filter(X=>!$.includes(X.name));if(de.length===0){p("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}L(de),z(0);}else {let I=o[0];P(I);let $=new FileReader;$.onload=()=>{f($.result),v(!0);},$.readAsDataURL(I);}else if(Array.isArray(e$1)||e$1===void 0&&r){let I=s?[...R,...o].slice(0,s):[...R,...o];g(I),r?.(I);}else {let I=o[0];g([I]),t?.(I);}},[e$1,R,t,r,l,s,i,p]),G=useCallback(o=>{if(!o.length)return;let w=o[0]?.errors[0]?.code,I=i?.maxSize||3145728;p(w==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(I)}`):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,p]),{getRootProps:T,getInputProps:q,isDragActive:W,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:U,onDropRejected:G,...i}),Oe=useCallback(o=>{if(!o){g([]),a?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let w=m.filter(I=>I.name!==o.name);g(w),a?.(o),r&&r(w);}else g([]),a?.(o);},[e$1,m,r,a]),Ro=useCallback(()=>{g([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:M,files:R,aspectRatio:x,dropzoneProps:{getRootProps:T,getInputProps:q,isDragActive:W,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:E,imagePreview:u,cropLoading:A,setCropModalOpen:v,onCropInitialized:ee,handleCropSave:re,handleCropCancel:N,currentImageIndex:O,totalPendingImages:F.length},handleRemove:Oe,clearFiles:Ro,setFiles:g}},B=fr;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 Pr=({createFilesMutation:e,queryFiles:t,fileIds:r,files:a,file:i,skip:l})=>{let{showErrorMessage:d}=a$8(),[c,s]=useState(!1),[n,p]=useState(!1),[x,m]=useState(null),[g,E]=useState(void 0),v=useMemo(()=>g?.[0],[g]),b=useMemo(()=>{if(!l)return i?[i]:a},[i,a,l]),P=useCallback(async u=>{if(!u?.length){E(void 0),p(!1);return}try{p(!0);let f=await Promise.all(u.map(async({url:A,name:D,id:F},L)=>{let z=await(await fetch(A)).blob(),R=D||A.split("/").pop()||"image",M=new File([z],R,{type:z.type});return M.id=F,M.url=A,M.index=L,M}));E(f);}catch(f){console.error("Erro ao carregar preview dos arquivos:",f),E(void 0);}finally{p(!1);}},[]);useEffect(()=>{!r?.length||!t?P(void 0):t({ids:r}).unwrap().then(u=>{p(!0),P(u);});},[r,t,P]);let y=n||c;return useEffect(()=>{P(b);},[b,P]),{filesPreview:g,filePreview:v,uploadFiles:async u=>{if(u?.length){s(!0);try{let f=u[0].type||"application/octet-stream",A=De[f];if(!A)throw new Error(`Tipo de arquivo n\xE3o suportado: ${f}`);let D=await e({files:[{content_type:A,name:u[0].name}]}).unwrap(),F=D.files.map(O=>O.id);return (await Promise.all(u.map(O=>fetch(D.files[0].url,{method:"PUT",headers:{"Content-Type":f},body:O})))).forEach(O=>{if(!O.ok)throw new Error(`Erro no upload: ${O.statusText}`)}),P(D.files),F}catch(f){throw m(f),d(f,"Erro no upload"),f}finally{s(!1);}}},isUploadingFiles:c,isLoadingPreview:n,isUploadOrLoadingFiles:y,uploadFilesError:x}},Ir=Pr;var hr=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:l,getInputProps:d,isDragActive:c,isError:s,disabled:n,dropZoneSxProps:p,dropZoneContent:x,children:m,...g})=>jsxs(Ae,{children:[i&&jsx(a$7,{"data-testid":"uploading-progress-bar"}),jsxs(me,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...l(),"data-testid":"drop-zone-styled-area",isError:s,isDragActive:c,disabled:!!n,sx:p,...g,children:[jsx("input",{...d(),id:t,tabIndex:a,name:r}),x]}),m]})]}),K=hr;var wr=({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$4,{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(wr);var Rr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:l,helperText:d,files:c,thumbnail:s,dropZoneSxProps:n,uploading:p,tabIndex:x,maxFiles:m,...g})=>{let{files:E,dropzoneProps:v,handleRemove:b}=B({filesToUpload:c,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...g},maxFiles:m}),{getRootProps:P,getInputProps:y,isDragActive:_,isDragReject:u}=v,f=!!E?.length,A=u||!!l;return jsxs(K,{id:a,uploading:p,disabled:i,dropZoneSxProps:n,tabIndex:x,getRootProps:P,getInputProps:y,isDragActive:_,isError:A,dropZoneContent:jsx(J,{}),children:[jsx(k,{disabled:i,helperText:d,isError:A}),f&&jsx(me,{sx:{my:3},children:jsx(ue,{files:E,thumbnail:!!s,onRemove:e?b:void 0,onReorder:t})})]})},Sr=memo(Rr);var Cr=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:l,helperText:d,files:c,dropZoneSxProps:s,placeholderProps:n,placeholderAlt:p,uploading:x,tabIndex:m,maxFiles:g,aspectRatio:E,enableCrop:v=!0,convertToWebp:b=!0,cropSize:P,name:y,label:_,...u})=>{let{files:f,dropzoneProps:A,cropState:D,handleRemove:F,aspectRatio:L}=B({filesToUpload:c,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...u},enableCrop:v,customAspectRatio:E,convertToWebp:b,maxFiles:g,cropSize:P}),{getRootProps:O,getInputProps:z,isDragActive:R,isDragReject:M}=A,{cropModalOpen:j,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:N,handleCropCancel:U,currentImageIndex:G,totalPendingImages:T}=D,q=!!f?.length,W=M||!!l,ye=useMemo(()=>{let _e=_??"Ajustar Imagem",Oe=T>1?` (${G} de ${T})`:"";return `${_e}${Oe}`},[_,T,G]);return jsxs(K,{id:a,name:y,uploading:x,disabled:i,dropZoneSxProps:s,tabIndex:m,getRootProps:O,getInputProps:z,isDragActive:R,isError:W,dropZoneContent:jsx(Fragment,{children:p?jsx(ie,{children:p}):jsx(J,{header:n?.header,description:n?.description})}),children:[jsx(k,{disabled:i,helperText:d,isError:W}),q&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:f,thumbnail:!0,onRemove:F,onReorder:r})})}),jsx(a$5,{open:j,onClose:U,label:ye,imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:N,loading:oe,cropSize:P})]})},zr=memo(Cr);var Br=({onFileSelect:e$1,onRemove:t,file:r,id:a,disabled:i,error:l,helperText:d,sx:c,dropZoneSxProps:s,uploading:n,tabIndex:p,...x})=>{let{file:m$1,dropzoneProps:g,handleRemove:E}=B({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...x}}),{getRootProps:v,getInputProps:b,isDragActive:P,isDragReject:y}=g,_=useCallback(D=>{D.stopPropagation(),E(m$1||void 0);},[m$1,E]),u=!!m$1,f$1=typeof m$1=="string",A=y||!!l;return jsx(K,{id:a,uploading:n,disabled:i,dropZoneSxProps:s,tabIndex:p,getRootProps:v,getInputProps:b,isDragActive:P,isError:A,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:D=>`solid 1px ${D.palette.divider}`,...c},children:[jsx(f,{file:m$1}),jsxs(ie,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:f$1?m$1:m$1.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:f$1?"":e(m$1.size)})]}),t&&jsx(a$3,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:_,children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(k,{disabled:i,helperText:d,isError:A})})},Gr=memo(Br);var qr=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:l,helperText:d,dropZoneSxProps:c,placeholderProps:s,placeholderAlt:n,uploading:p,tabIndex:x,aspectRatio:m,enableCrop:g=!0,convertToWebp:E=!0,name:v,label:b,cropSize:P,...y})=>{let[_,u]=useState(!1),{file:f,dropzoneProps:A,cropState:D,handleRemove:F,aspectRatio:L}=B({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...y},enableCrop:g,customAspectRatio:m,convertToWebp:E,cropSize:P}),{getRootProps:O,getInputProps:z,isDragActive:R,isDragReject:M}=A,{cropModalOpen:j,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:N,handleCropCancel:U}=D,G=useCallback(()=>{F(f||void 0);},[f,F]),T=!!f,q=M||!!l,W=T?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(p||_)&&jsx(a$7,{}),jsxs(K,{id:a,uploading:p,disabled:i,dropZoneSxProps:c,tabIndex:x,getRootProps:O,getInputProps:z,isDragActive:R,isError:q,name:v,dropZoneContent:jsxs(Fragment,{children:[n?jsx(ie,{sx:W,children:n}):jsx(J,{sx:W,header:s?.title,description:s?.description}),T&&jsx(ze,{file:f,cropSize:P,isLoading:_,isUploading:p,onLoading:u,aspectRatio:L})]}),children:[jsx(k,{disabled:i,helperText:d,isError:q}),T&&e&&jsx(Qe,{size:"small",onClick:G,disabled:i,label:"Remover arquivo",children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$5,{open:j,onClose:U,label:b??"Ajustar Imagem",imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:N,loading:oe,cropSize:P})]})]})},Xr=memo(qr);var et=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:l,tabIndex:d,error:c,helperText:s,sx:n,name:p,maxSize:x,uploading:m,aspectRatio:g=1,enableCrop:E=!0,convertToWebp:v=!0,cropSize:b,...P})=>{let[y,_]=useState(!1),{file:u,dropzoneProps:f,cropState:A,handleRemove:D}=B({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:x,...P},enableCrop:E,customAspectRatio:g,convertToWebp:v,cropSize:b}),{getRootProps:F,getInputProps:L,isDragActive:O,isDragReject:z}=f,{cropModalOpen:R,imagePreview:M,cropLoading:j,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=A,N=z||!!c,U=y||m,G=!!t,T=useMemo(()=>u?(_(!0),URL.createObjectURL(u)):"",[u]),q=()=>{_(!1);},W=()=>G&&u?()=>D(u):F().onClick;return jsxs(Fragment,{children:[jsxs(ao,{sx:n,isError:N,isDragActive:O,hasFile:!!u,...F(),onClick:W(),children:[jsxs(to,{children:[u&&jsx(no,{alt:"Avatar Preview",src:T,onLoad:q,...U&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&U&&jsx(io,{children:jsx(Yr,{size:135,thickness:1,color:"primary"})}),!u&&!U&&jsxs(Ce,{isError:N,hasFile:!1,children:[jsx(a$6,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:N?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!U&&jsxs(Ce,{isError:N,hasFile:!0,children:[jsx(a$6,{icon:G?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:N?"error.main":"common.white"},children:G?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:p,id:l,tabIndex:d,...L()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(k,{helperText:s,disabled:a,isError:N})}),u&&!U&&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:()=>D(u),children:"Remover"})})]}),R&&M&&jsx(a$5,{open:R,onClose:re,label:i??"Ajustar Imagem",imageSrc:M,aspectRatio:g,onInitialized:ee,onSave:oe,loading:j,cropSize:b,cropShape:"round"})]})},ot=memo(et);var at=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:l,getInputProps:d,isDragActive:c,isDragReject:s}=useDropzone({disabled:r,...i}),n=s||e;return jsxs(Ye,{...l(),isDragActive:c,hasError:!!n,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...d()}),"Selecionar arquivo"]})},nt=memo(at);
|
|
35
|
+
var Mo=({helperText:e,disabled:t,isError:r})=>e?jsx(Lo,{error:r,sx:a=>({mx:"14px",color:t?a.palette.grey[500]:void 0}),children:e}):null,k=memo(Mo);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: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(zo)(({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: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(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"&&e!=="maxWidth"&&e!=="maxHeight"})(({theme:e,aspectRatio:t,height:r=1,width:a=1,maxWidth:i,maxHeight:l,isLoading:d,isUploading:c})=>({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:i,maxHeight:l,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",...d||c?{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(No)(({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: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 Bo=({onRemove:e,sx:t,file:r,disableDrag:a,attributes:i,listeners:l,innerWidth:d,isDragging:c})=>{let s=r?.id||r?.url;return s?jsx(ko,{anchorOrigin:{vertical:"top",horizontal:"left"},children:jsxs(Je,{width:d,isDragging:c,"data-testid":`preview-multi-img-${s}`,...j().inUp,sx:t,children:[jsx(a$2,{disableDrag:a,...i,...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-${s}`):null},lo=memo(Bo);var $o=({file:e$1,thumbnail:t,onRemove:r,sx:a$1,disableDrag:i=!1})=>{let l=e$1?.size||0,d=e$1?.name||e$1?.url||e$1?.id,c=e$1?.id||e$1?.url||"",s=typeof e$1=="string",n=i?70:80,{attributes:p,listeners:x$1,setNodeRef:m,transform:g,transition:E,isDragging:v}=useSortable({id:c,disabled:i}),b={transform:x.Transform.toString(g),transition:E,display:"inline-block",alignItems:"center",justifyContent:"center",width:`${n+8}px`,height:"68px"};return t&&e$1?jsx(Me,{ref:m,style:b,children:jsx(lo,{innerWidth:n,isDragging:v,sx:a$1,file:e$1,disableDrag:i,attributes:p,listeners:x$1,onRemove:r})}):jsx(Me,{ref:m,style:{...b,height:"80px",width:`${n+38}px`},children:jsxs(Ke,{width:n+30,isDragging:v,"data-testid":`preview-multi-img-${c}`,...j().inUp,sx:a$1,children:[jsx(a$2,{disableDrag:i,...p,...x$1}),e$1&&jsx(f,{file:e$1}),jsxs(ie,{flexGrow:1,sx:{width:"100%"},children:[jsx(a$3,{title:d,children:jsx(ke,{variant:"subtitle2",noWrap:!0,children:d})}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:s?"":e(l)})]}),jsx(we,{children:r&&jsx(a,{size:"small",label:"Remover arquivo",onClick:()=>r(e$1),icon:"DELETE_MARK_BUTTON_02"})})]})})},mo=memo($o);var ar=({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 d=s=>{let{active:n,over:p}=s;if(!(!n||!p||n.id===p.id)&&a){let x=t.findIndex(({id:g})=>g===n.id),m=t.findIndex(({id:g})=>g===p.id);x!==-1&&m!==-1&&a(x,m);}},c=jsx(AnimatePresence,{initial:!1,children:t.map(s=>jsx(mo,{sx:i,file:s,onRemove:r,thumbnail:e,disableDrag:!a},s.id))});return a?jsx(DndContext,{sensors:l,collisionDetection:closestCenter,onDragEnd:d,modifiers:[restrictToHorizontalAxis,restrictToParentElement,restrictToWindowEdges],children:jsx(SortableContext,{items:t.map(s=>s.id),strategy:horizontalListSortingStrategy,children:c})}):c},ue=memo(ar);var fo=forwardRef(({onLoading:e,width:t,height:r,...a},i)=>{let[l,d]=useState("calc(100% - 16px)"),[c,s]=useState("calc(100% - 16px)");a$1(()=>{e?.(!0);}),useLayoutEffect(()=>{typeof i=="object"&&i?.current?e?.(!i.current.complete):e?.(!1);},[i,e]);function n(){if(typeof i=="object"&&i?.current&&t&&r){let{width:p,height:x}=i.current.getBoundingClientRect(),m=Number(t)<p?t:p,g=Number(r)<x?r:x;d(`calc(${m}px - 16px)`),s(`calc(${g}px - 16px)`);}e?.(!1);}return jsx(oo,{...a,ref:i,maxWidth:l,maxHeight:c,onLoad:n,onError:n})});fo.displayName="LoadingPreviewImage";var xo=fo;var mr=({file:e,aspectRatio:t=1,isUploading:r,isLoading:a,onLoading:i,cropSize:l})=>{let d=useRef(null),c=e?.id||e?.url||e?.name,s=e?.name||e?.url||e?.id,n=e?.url||URL.createObjectURL(e),p=typeof l=="number"?l*t:l?.width,x=typeof l=="number"?l:l?.height,m=useMemo(()=>`image-preview-${c}-${r}`,[c,r]);return c?jsxs(eo,{children:[jsx(xo,{aspectRatio:t,isLoading:a,isUploading:r,height:x,width:p,alt:s,src:n,ref:d,loading:"lazy",onLoading:i},m),jsx(ro,{alt:s,src:n,isLoading:a,isUploading:r})]}):null},ze=memo(mr);var ui=e=>e.startsWith("image/"),Io=(e,t=.8)=>new Promise((r,a)=>{let i=document.createElement("canvas"),l=i.getContext("2d"),d=new Image;d.onload=()=>{i.width=d.width,i.height=d.height,l?(l.drawImage(d,0,0),i.toBlob(c=>{if(c){let s=new File([c],e.name.replace(/\.[^/.]+$/,".webp"),{type:"image/webp",lastModified:Date.now()});r(s);}else a(new Error("Falha ao converter para WebP"));},"image/webp",t)):a(new Error("N\xE3o foi poss\xEDvel obter contexto do canvas"));},d.onerror=()=>a(new Error("Falha ao carregar imagem")),d.src=URL.createObjectURL(e);});var fr=({filesToUpload:e$1,onFileSelect:t,onFilesSelect:r,onRemove:a,dropzoneOptions:i,enableCrop:l=!1,customAspectRatio:d,convertToWebp:c=!0,maxFiles:s,cropSize:n})=>{let{showErrorMessage:p}=a$8(),x=useMemo(()=>d||(n&&typeof n!="number"?n.width/n.height:1),[d,n]),[m,g]=useState([]),[E,v]=useState(!1),[b,P]=useState(null),[y,_]=useState(null),[u,f]=useState(""),[A,D]=useState(!1),[F,L]=useState([]),[O,z]=useState(0),R=useMemo(()=>e$1&&Array.isArray(e$1)?e$1.filter(o=>o instanceof File):e$1&&e$1 instanceof File?[e$1]:m,[e$1,m]),M=useMemo(()=>e$1&&Array.isArray(e$1)?null:e$1&&e$1 instanceof File?e$1:m[0]||null,[e$1,m]);useEffect(()=>{e$1&&(Array.isArray(e$1)?g(e$1.filter(o=>o instanceof File)):e$1 instanceof File?g([e$1]):e$1===null&&g([]));},[e$1]);let j=useCallback(()=>{if(F.length>0&&l){let o=F[0];P(o),z(I=>I+1);let w=new FileReader;w.onload=()=>{f(w.result),v(!0);},w.readAsDataURL(o);}},[F,l]);useEffect(()=>{j();},[j]);let ee=useCallback((o,w)=>{_(w);},[]),oe=async()=>!b||!y?null:new Promise(o=>{let w=document.createElement("canvas"),I=w.getContext("2d"),$=new Image;$.onload=async()=>{let{width:de,height:X,x:So,y:yo}=y,xe=de,Pe=X;n&&(typeof n=="number"?(xe=n,Pe=n/x):(xe=n.width,Pe=n.height)),w.width=xe,w.height=Pe,I?(I.drawImage($,So,yo,de,X,0,0,xe,Pe),w.toBlob(async We=>{if(We){let Le=new File([We],b.name,{type:b.type,lastModified:Date.now()});if(c)try{Le=await Io(Le);}catch(_o){p(_o,"Erro ao converter para WebP");}o(Le);}else o(null);},"image/png")):o(null);},$.src=u;}),re=async()=>{if(!(!b||!y)){D(!0);try{let o=await oe();if(o)if(Array.isArray(e$1)||e$1===void 0&&r){let I=s?[...R,o].slice(0,s):[...R,o];g(I),r?.(I);}else g([o]),t?.(o);let w=F.slice(1);L(w),v(!1),f(""),P(null),w.length>0&&setTimeout(()=>j(),100);}catch(o){p(o,"Erro ao processar imagem");}finally{D(!1);}}},N=()=>{v(!1),f(""),P(null),L([]),z(0);},U=useCallback(o=>{if(o.length===0)return;if(i?.accept&&Object.keys(i.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/")),$=R.map(X=>X.name),de=I.filter(X=>!$.includes(X.name));if(de.length===0){p("Todos os arquivos selecionados j\xE1 foram adicionados","Arquivos duplicados");return}L(de),z(0);}else {let I=o[0];P(I);let $=new FileReader;$.onload=()=>{f($.result),v(!0);},$.readAsDataURL(I);}else if(Array.isArray(e$1)||e$1===void 0&&r){let I=s?[...R,...o].slice(0,s):[...R,...o];g(I),r?.(I);}else {let I=o[0];g([I]),t?.(I);}},[e$1,R,t,r,l,s,i,p]),G=useCallback(o=>{if(!o.length)return;let w=o[0]?.errors[0]?.code,I=i?.maxSize||3145728;p(w==="file-too-large"?new Error(`O arquivo excede o tamanho m\xE1ximo de ${e(I)}`):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,p]),{getRootProps:T,getInputProps:q,isDragActive:W,isDragReject:ye,fileRejections:_e}=useDropzone({onDrop:U,onDropRejected:G,...i}),Oe=useCallback(o=>{if(!o){g([]),a?.(void 0);return}if(Array.isArray(e$1)||e$1===void 0&&r){let w=m.filter(I=>I.name!==o.name);g(w),a?.(o),r&&r(w);}else g([]),a?.(o);},[e$1,m,r,a]),Ro=useCallback(()=>{g([]),Array.isArray(e$1)&&r?r([]):!Array.isArray(e$1)&&t&&t?.(null);},[e$1,r,t]);return {file:M,files:R,aspectRatio:x,dropzoneProps:{getRootProps:T,getInputProps:q,isDragActive:W,isDragReject:ye,fileRejections:_e},cropState:{cropModalOpen:E,imagePreview:u,cropLoading:A,setCropModalOpen:v,onCropInitialized:ee,handleCropSave:re,handleCropCancel:N,currentImageIndex:O,totalPendingImages:F.length},handleRemove:Oe,clearFiles:Ro,setFiles:g}},B=fr;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 Pr=({createFilesMutation:e,queryFiles:t,fileIds:r,files:a,file:i,skip:l})=>{let{showErrorMessage:d}=a$8(),[c,s]=useState(!1),[n,p]=useState(!1),[x,m]=useState(null),[g,E]=useState(void 0),v=useMemo(()=>g?.[0],[g]),b=useMemo(()=>{if(!l)return i?[i]:a},[i,a,l]),P=useCallback(async u=>{if(!u?.length){E(void 0),p(!1);return}try{p(!0);let f=await Promise.all(u.map(async({url:A,name:D,id:F},L)=>{let z=await(await fetch(A)).blob(),R=D||A.split("/").pop()||"image",M=new File([z],R,{type:z.type});return M.id=F,M.url=A,M.index=L,M}));E(f);}catch(f){console.error("Erro ao carregar preview dos arquivos:",f),E(void 0);}finally{p(!1);}},[]);useEffect(()=>{!r?.length||!t?P(void 0):t({ids:r}).unwrap().then(({files:u})=>{p(!0),P(u);});},[r,t,P]);let y=n||c;return useEffect(()=>{P(b);},[b,P]),{filesPreview:g,filePreview:v,uploadFiles:async u=>{if(u?.length){s(!0);try{let f=u[0].type||"application/octet-stream",A=De[f];if(!A)throw new Error(`Tipo de arquivo n\xE3o suportado: ${f}`);let D=await e({files:[{content_type:A,name:u[0].name}]}).unwrap(),F=D.files.map(O=>O.id);return (await Promise.all(u.map(O=>fetch(D.files[0].url,{method:"PUT",headers:{"Content-Type":f},body:O})))).forEach(O=>{if(!O.ok)throw new Error(`Erro no upload: ${O.statusText}`)}),P(D.files),F}catch(f){throw m(f),d(f,"Erro no upload"),f}finally{s(!1);}}},isUploadingFiles:c,isLoadingPreview:n,isUploadOrLoadingFiles:y,uploadFilesError:x}},Ir=Pr;var hr=({sx:e,id:t,name:r,tabIndex:a,uploading:i,getRootProps:l,getInputProps:d,isDragActive:c,isError:s,disabled:n,dropZoneSxProps:p,dropZoneContent:x,children:m,...g})=>jsxs(Ae,{children:[i&&jsx(a$7,{"data-testid":"uploading-progress-bar"}),jsxs(me,{sx:{width:1,position:"relative",...e},children:[jsxs(Xe,{...l(),"data-testid":"drop-zone-styled-area",isError:s,isDragActive:c,disabled:!!n,sx:p,...g,children:[jsx("input",{...d(),id:t,tabIndex:a,name:r}),x]}),m]})]}),K=hr;var wr=({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$4,{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(wr);var Rr=({onRemove:e,onReorder:t,onFilesSelect:r,id:a,disabled:i,error:l,helperText:d,files:c,thumbnail:s,dropZoneSxProps:n,uploading:p,tabIndex:x,maxFiles:m,...g})=>{let{files:E,dropzoneProps:v,handleRemove:b}=B({filesToUpload:c,onFilesSelect:r,onRemove:e,dropzoneOptions:{multiple:!0,disabled:i,...g},maxFiles:m}),{getRootProps:P,getInputProps:y,isDragActive:_,isDragReject:u}=v,f=!!E?.length,A=u||!!l;return jsxs(K,{id:a,uploading:p,disabled:i,dropZoneSxProps:n,tabIndex:x,getRootProps:P,getInputProps:y,isDragActive:_,isError:A,dropZoneContent:jsx(J,{}),children:[jsx(k,{disabled:i,helperText:d,isError:A}),f&&jsx(me,{sx:{my:3},children:jsx(ue,{files:E,thumbnail:!!s,onRemove:e?b:void 0,onReorder:t})})]})},Sr=memo(Rr);var Cr=({onFilesSelect:e,onRemove:t,onReorder:r,id:a,disabled:i,error:l,helperText:d,files:c,dropZoneSxProps:s,placeholderProps:n,placeholderAlt:p,uploading:x,tabIndex:m,maxFiles:g,aspectRatio:E,enableCrop:v=!0,convertToWebp:b=!0,cropSize:P,name:y,label:_,...u})=>{let{files:f,dropzoneProps:A,cropState:D,handleRemove:F,aspectRatio:L}=B({filesToUpload:c,onFilesSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!0,disabled:i,...u},enableCrop:v,customAspectRatio:E,convertToWebp:b,maxFiles:g,cropSize:P}),{getRootProps:O,getInputProps:z,isDragActive:R,isDragReject:M}=A,{cropModalOpen:j,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:N,handleCropCancel:U,currentImageIndex:G,totalPendingImages:T}=D,q=!!f?.length,W=M||!!l,ye=useMemo(()=>{let _e=_??"Ajustar Imagem",Oe=T>1?` (${G} de ${T})`:"";return `${_e}${Oe}`},[_,T,G]);return jsxs(K,{id:a,name:y,uploading:x,disabled:i,dropZoneSxProps:s,tabIndex:m,getRootProps:O,getInputProps:z,isDragActive:R,isError:W,dropZoneContent:jsx(Fragment,{children:p?jsx(ie,{children:p}):jsx(J,{header:n?.header,description:n?.description})}),children:[jsx(k,{disabled:i,helperText:d,isError:W}),q&&jsx(Fragment,{children:jsx(me,{sx:{my:3,ml:.5},children:jsx(ue,{files:f,thumbnail:!0,onRemove:F,onReorder:r})})}),jsx(a$5,{open:j,onClose:U,label:ye,imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:N,loading:oe,cropSize:P})]})},zr=memo(Cr);var Br=({onFileSelect:e$1,onRemove:t,file:r,id:a,disabled:i,error:l,helperText:d,sx:c,dropZoneSxProps:s,uploading:n,tabIndex:p,...x})=>{let{file:m$1,dropzoneProps:g,handleRemove:E}=B({filesToUpload:r,onFileSelect:e$1,onRemove:t,dropzoneOptions:{multiple:!1,disabled:i,...x}}),{getRootProps:v,getInputProps:b,isDragActive:P,isDragReject:y}=g,_=useCallback(D=>{D.stopPropagation(),E(m$1||void 0);},[m$1,E]),u=!!m$1,f$1=typeof m$1=="string",A=y||!!l;return jsx(K,{id:a,uploading:n,disabled:i,dropZoneSxProps:s,tabIndex:p,getRootProps:v,getInputProps:b,isDragActive:P,isError:A,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:D=>`solid 1px ${D.palette.divider}`,...c},children:[jsx(f,{file:m$1}),jsxs(ie,{flexGrow:1,sx:{minWidth:0},children:[jsx(ke,{variant:"subtitle2",noWrap:!0,children:f$1?m$1:m$1.name}),jsx(ke,{variant:"caption",sx:{color:"text.secondary"},children:f$1?"":e(m$1.size)})]}),t&&jsx(a$3,{title:"Remover arquivo",children:jsx(Ve,{edge:"end",size:"small",disabled:i,"aria-label":"Remover arquivo",onClick:_,children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})})})]})]}),children:jsx(k,{disabled:i,helperText:d,isError:A})})},Gr=memo(Br);var qr=({onRemove:e,onFileSelect:t,file:r,id:a,disabled:i,error:l,helperText:d,dropZoneSxProps:c,placeholderProps:s,placeholderAlt:n,uploading:p,tabIndex:x,aspectRatio:m,enableCrop:g=!0,convertToWebp:E=!0,name:v,label:b,cropSize:P,...y})=>{let[_,u]=useState(!1),{file:f,dropzoneProps:A,cropState:D,handleRemove:F,aspectRatio:L}=B({filesToUpload:r,onFileSelect:t,onRemove:e,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:i,...y},enableCrop:g,customAspectRatio:m,convertToWebp:E,cropSize:P}),{getRootProps:O,getInputProps:z,isDragActive:R,isDragReject:M}=A,{cropModalOpen:j,imagePreview:ee,cropLoading:oe,onCropInitialized:re,handleCropSave:N,handleCropCancel:U}=D,G=useCallback(()=>{F(f||void 0);},[f,F]),T=!!f,q=M||!!l,W=T?{opacity:0}:{opacity:1};return jsxs(Ae,{children:[(p||_)&&jsx(a$7,{}),jsxs(K,{id:a,uploading:p,disabled:i,dropZoneSxProps:c,tabIndex:x,getRootProps:O,getInputProps:z,isDragActive:R,isError:q,name:v,dropZoneContent:jsxs(Fragment,{children:[n?jsx(ie,{sx:W,children:n}):jsx(J,{sx:W,header:s?.title,description:s?.description}),T&&jsx(ze,{file:f,cropSize:P,isLoading:_,isUploading:p,onLoading:u,aspectRatio:L})]}),children:[jsx(k,{disabled:i,helperText:d,isError:q}),T&&e&&jsx(Qe,{size:"small",onClick:G,disabled:i,label:"Remover arquivo",children:jsx(a$6,{icon:"DELETE_MARK_BUTTON_02",width:16})}),jsx(a$5,{open:j,onClose:U,label:b??"Ajustar Imagem",imageSrc:ee,aspectRatio:L,onInitialized:re,onSave:N,loading:oe,cropSize:P})]})]})},Xr=memo(qr);var et=({onFileSelect:e,onRemove:t,file:r,disabled:a,label:i,id:l,tabIndex:d,error:c,helperText:s,sx:n,name:p,maxSize:x,uploading:m,aspectRatio:g=1,enableCrop:E=!0,convertToWebp:v=!0,cropSize:b,...P})=>{let[y,_]=useState(!1),{file:u,dropzoneProps:f,cropState:A,handleRemove:D}=B({filesToUpload:r,onFileSelect:e,onRemove:t,dropzoneOptions:{accept:{"image/*":[".jpeg",".jpg",".png",".gif",".webp"]},multiple:!1,disabled:a,maxSize:x,...P},enableCrop:E,customAspectRatio:g,convertToWebp:v,cropSize:b}),{getRootProps:F,getInputProps:L,isDragActive:O,isDragReject:z}=f,{cropModalOpen:R,imagePreview:M,cropLoading:j,onCropInitialized:ee,handleCropSave:oe,handleCropCancel:re}=A,N=z||!!c,U=y||m,G=!!t,T=useMemo(()=>u?(_(!0),URL.createObjectURL(u)):"",[u]),q=()=>{_(!1);},W=()=>G&&u?()=>D(u):F().onClick;return jsxs(Fragment,{children:[jsxs(ao,{sx:n,isError:N,isDragActive:O,hasFile:!!u,...F(),onClick:W(),children:[jsxs(to,{children:[u&&jsx(no,{alt:"Avatar Preview",src:T,onLoad:q,...U&&{sx:{filter:"blur(5px) !important",scale:1.2,opacity:.7}}}),u&&U&&jsx(io,{children:jsx(Yr,{size:135,thickness:1,color:"primary"})}),!u&&!U&&jsxs(Ce,{isError:N,hasFile:!1,children:[jsx(a$6,{icon:"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:N?"error.main":"text.disabled"},children:"Adicionar foto"})]}),u&&!U&&jsxs(Ce,{isError:N,hasFile:!0,children:[jsx(a$6,{icon:G?"DELETE_MARK_BUTTON_02":"ADD_IMAGE",width:32}),jsx(ke,{variant:"caption",textAlign:"center",sx:{color:N?"error.main":"common.white"},children:G?"Remover foto":"Alterar foto"})]})]}),jsx("input",{name:p,id:l,tabIndex:d,...L()}),jsx(ie,{spacing:.5,sx:{pt:1},children:jsx(k,{helperText:s,disabled:a,isError:N})}),u&&!U&&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:()=>D(u),children:"Remover"})})]}),R&&M&&jsx(a$5,{open:R,onClose:re,label:i??"Ajustar Imagem",imageSrc:M,aspectRatio:g,onInitialized:ee,onSave:oe,loading:j,cropSize:b,cropShape:"round"})]})},ot=memo(et);var at=({error:e,name:t,disabled:r,sx:a,...i})=>{let{getRootProps:l,getInputProps:d,isDragActive:c,isDragReject:s}=useDropzone({disabled:r,...i}),n=s||e;return jsxs(Ye,{...l(),isDragActive:c,hasError:!!n,disabled:!!r,sx:a,"data-testid":"upload-box",children:[jsx("input",{name:t,...d()}),"Selecionar arquivo"]})},nt=memo(at);
|
|
36
36
|
|
|
37
37
|
export { Ue as ContentType, De as FileContentType, k as HelperText, ue as MultiFilePreview, Sr as MultipleFileUpload, zr as MultipleImageUpload, ze as SingleFilePreview, Gr as SingleFileUpload, Xr as SingleImageUpload, ot as UploadAvatar, nt as UploadSimpleBox, Io as convertToWebP, ui as isImageFile, B as useDropzoneUploader, Ir as useFileUploadService };
|
|
@@ -191,7 +191,7 @@ interface FileUploadProps {
|
|
|
191
191
|
unwrap: () => Promise<FileCreateResponse>;
|
|
192
192
|
};
|
|
193
193
|
queryFiles?: (params: FileQueryRequest) => {
|
|
194
|
-
unwrap: () => Promise<
|
|
194
|
+
unwrap: () => Promise<FileQueryResponse>;
|
|
195
195
|
};
|
|
196
196
|
fileIds?: string[];
|
|
197
197
|
files?: FileGetResponse[];
|