import{$ as e,$t as t,Bn as n,Bt as r,Cn as i,Gn as a,Or as o,Sn as s,Sr as c,St as l,Tr as u,Vn as d,Yt as f,Z as p,_r as m,an as h,cn as g,dn as _,fn as v,hn as y,ht as b,it as x,nn as S,pt as C,sn as ee,st as w,tn as T,ur as te,wr as ne,xn as E}from"./jsx-runtime-NwRKtVrk.js";import{y as D}from"./CopyOutlined-bJLUKQgS.js";import{_ as O,r as k}from"./statusUtils-G17j4Ng-.js";import{a as re}from"./useBreakpoint-BdDQSe50.js";import{r as ie}from"./ColorPresets-BBbJffTn.js";import{n as A}from"./button-CM-rzMOH.js";import{_t as j,gt as M,ht as N,jt as ae,mt as oe,pt as se}from"./es-Do50EHua.js";import{t as ce}from"./progress-B8Wo5U8C.js";var P=o(u()),F=o(ne()),I=((e,t)=>{if(e&&t){let n=Array.isArray(t)?t:t.split(`,`),r=e.name||``,i=e.type||``,o=i.replace(/\/.*$/,``);return n.some(e=>{let t=e.trim();if(/^\*(\/\*)?$/.test(e))return!0;if(t.charAt(0)===`.`){let e=r.toLowerCase(),n=t.toLowerCase(),i=[n];return(n===`.jpg`||n===`.jpeg`)&&(i=[`.jpg`,`.jpeg`]),i.some(t=>e.endsWith(t))}return/\/\*$/.test(t)?o===t.replace(/\/.*$/,``):i===t?!0:/^\w+$/.test(t)?(a(!1,`Upload takes an invalidate 'accept' type '${t}'.Skip for check.`),!0):!1})}return!0});function L(e,t){let n=`cannot ${e.method} ${e.action} ${t.status}'`,r=Error(n);return r.status=t.status,r.method=e.method,r.url=e.action,r}function R(e){let t=e.responseText||e.response;if(!t)return t;try{return JSON.parse(t)}catch{return t}}function z(e){let t=new XMLHttpRequest;e.onProgress&&t.upload&&(t.upload.onprogress=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),e.onProgress(t)});let n=new FormData;e.data&&Object.keys(e.data).forEach(t=>{let r=e.data[t];if(Array.isArray(r)){r.forEach(e=>{n.append(`${t}[]`,e)});return}n.append(t,r)}),e.file instanceof Blob?n.append(e.filename,e.file,e.file.name):n.append(e.filename,e.file),t.onerror=function(t){e.onError(t)},t.onload=function(){return t.status<200||t.status>=300?e.onError(L(e,t),R(t)):e.onSuccess(R(t),t)},t.open(e.method,e.action,!0),e.withCredentials&&`withCredentials`in t&&(t.withCredentials=!0);let r=e.headers||{};return r[`X-Requested-With`]!==null&&t.setRequestHeader(`X-Requested-With`,`XMLHttpRequest`),Object.keys(r).forEach(e=>{r[e]!==null&&t.setRequestHeader(e,r[e])}),t.send(n),{abort(){t.abort()}}}var B=async(e,t)=>{let n=[],r=[];e.forEach(e=>r.push(e.webkitGetAsEntry()));async function i(e){let t=e.createReader(),n=[];for(;;){let e=await new Promise(e=>{t.readEntries(e,()=>e([]))}),r=e.length;if(!r)break;for(let t=0;t{e.file(r=>{t(r)?(e.fullPath&&!r.webkitRelativePath&&(Object.defineProperties(r,{webkitRelativePath:{writable:!0}}),r.webkitRelativePath=e.fullPath.replace(/^\//,``),Object.defineProperties(r,{webkitRelativePath:{writable:!1}})),n(r)):n(null)})})}let o=async(e,t)=>{if(e){if(e.path=t||``,e.isFile){let t=await a(e);t&&n.push(t)}else if(e.isDirectory){let t=await i(e);r.push(...t)}}},s=0;for(;s{let{accept:n,directory:r}=this.props,i,a;if(typeof n==`string`)a=n;else{let{filter:e,format:t}=n||{};a=t,i=e===`native`?()=>!0:e}return(i||(r||t?e=>I(e,a):()=>!0))(e)};onChange=e=>{let{files:t}=e.target,n=[...t].filter(e=>this.filterFile(e));this.uploadFiles(n),this.reset()};onClick=e=>{let t=this.fileInput;if(!t)return;let n=e.target,{onClick:r}=this.props;n&&n.tagName===`BUTTON`&&(t.parentNode.focus(),n.blur()),t.click(),r&&r(e)};onKeyDown=e=>{e.key===`Enter`&&this.onClick(e)};onDataTransferFiles=async(e,t)=>{let{multiple:n,directory:r}=this.props,i=[...e.items||[]],a=[...e.files||[]];if((a.length>0||i.some(e=>e.kind===`file`))&&t?.(),r)a=await B(Array.prototype.slice.call(i),this.filterFile),this.uploadFiles(a);else{let e=[...a].filter(e=>this.filterFile(e,!0));n===!1&&(e=a.slice(0,1)),this.uploadFiles(e)}};onFilePaste=async e=>{let{pastable:t}=this.props;if(t&&e.type===`paste`){let t=e.clipboardData;return this.onDataTransferFiles(t,()=>{e.preventDefault()})}};onFileDragOver=e=>{e.preventDefault()};onFileDrop=async e=>{if(e.preventDefault(),e.type===`drop`){let t=e.dataTransfer;return this.onDataTransferFiles(t)}};componentDidMount(){this._isMounted=!0;let{pastable:e}=this.props;e&&document.addEventListener(`paste`,this.onFilePaste)}componentWillUnmount(){this._isMounted=!1,this.abort(),document.removeEventListener(`paste`,this.onFilePaste)}componentDidUpdate(e){let{pastable:t}=this.props;t&&!e.pastable?document.addEventListener(`paste`,this.onFilePaste):!t&&e.pastable&&document.removeEventListener(`paste`,this.onFilePaste)}uploadFiles=e=>{let t=[...e],n=t.map(e=>(e.uid=H(),this.processFile(e,t)));Promise.all(n).then(e=>{let{onBatchStart:t}=this.props;t?.(e.map(({origin:e,parsedFile:t})=>({file:e,parsedFile:t}))),e.filter(e=>e.parsedFile!==null).forEach(e=>{this.post(e)})})};processFile=async(e,t)=>{let{beforeUpload:n}=this.props,r=e;if(n){try{r=await n(e,t)}catch{r=!1}if(r===!1)return{origin:e,parsedFile:null,action:null,data:null}}let{action:i}=this.props,a;a=typeof i==`function`?await i(e):i;let{data:o}=this.props,s;s=typeof o==`function`?await o(e):o;let c=(typeof r==`object`||typeof r==`string`)&&r?r:e,l;l=c instanceof File?c:new File([c],e.name,{type:e.type});let u=l;return u.uid=e.uid,{origin:e,data:s,parsedFile:u,action:a}};post({data:e,origin:t,action:n,parsedFile:r}){if(!this._isMounted)return;let{onStart:i,customRequest:a,name:o,headers:s,withCredentials:c,method:l}=this.props,{uid:u}=t,d=a||z,f={action:n,filename:o,data:e,file:r,headers:s,withCredentials:c,method:l||`post`,onProgress:e=>{let{onProgress:t}=this.props;t?.(e,r)},onSuccess:(e,t)=>{let{onSuccess:n}=this.props;n?.(e,r,t),delete this.reqs[u]},onError:(e,t)=>{let{onError:n}=this.props;n?.(e,t,r),delete this.reqs[u]}};i(t),this.reqs[u]=d(f,{defaultRequest:z})}reset(){this.setState({uid:H()})}abort(e){let{reqs:t}=this;if(e){let n=e.uid?e.uid:e;t[n]&&t[n].abort&&t[n].abort(),delete t[n]}else Object.keys(t).forEach(e=>{t[e]&&t[e].abort&&t[e].abort(),delete t[e]})}saveFileInput=e=>{this.fileInput=e};render(){let{component:e,prefixCls:t,className:r,classNames:i={},disabled:a,id:o,name:s,style:l,styles:u={},multiple:d,accept:f,capture:p,children:m,directory:h,openFileDialogOnClick:g,onMouseEnter:_,onMouseLeave:v,hasControlInside:y,...b}=this.props,x=typeof f==`string`?f:f?.format,S=c(t,{[`${t}-disabled`]:a,[r]:r}),C=h?{directory:`directory`,webkitdirectory:`webkitdirectory`}:{},ee=a?{}:{onClick:g?this.onClick:()=>{},onKeyDown:g?this.onKeyDown:()=>{},onMouseEnter:_,onMouseLeave:v,onDrop:this.onFileDrop,onDragOver:this.onFileDragOver,tabIndex:y?void 0:`0`};return P.createElement(e,U({},ee,{className:S,role:y?void 0:`button`,style:l}),P.createElement(`input`,U({},n(b,{aria:!0,data:!0}),{id:o,name:s,disabled:a,type:`file`,ref:this.saveFileInput,onClick:e=>e.stopPropagation(),key:this.state.uid,style:{display:`none`,...u.input},className:i.input,accept:x},C,{multiple:d,onChange:this.onChange},p==null?{}:{capture:p})),m)}};function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t{this.uploader=e};render(){return P.createElement(W,G({},this.props,{ref:this.saveUploader}))}},q=e=>{let{componentCls:t,iconCls:n}=e;return{[`${t}-wrapper`]:{[`${t}-drag`]:{position:`relative`,width:`100%`,height:`100%`,textAlign:`center`,background:e.colorFillAlter,border:`${h(e.lineWidth)} dashed ${e.colorBorder}`,borderRadius:e.borderRadiusLG,cursor:`pointer`,transition:`border-color ${e.motionDurationSlow}`,[t]:{padding:e.padding},[`${t}-btn`]:{display:`table`,width:`100%`,height:`100%`,outline:`none`,borderRadius:e.borderRadiusLG,"&:focus-visible":{outline:`${h(e.lineWidthFocus)} solid ${e.colorPrimaryBorder}`}},[`${t}-drag-container`]:{display:`table-cell`,verticalAlign:`middle`},[` &:not(${t}-disabled):hover, &-hover:not(${t}-disabled) `]:{borderColor:e.colorPrimaryHover},[`p${t}-drag-icon`]:{marginBottom:e.margin,[n]:{color:e.colorPrimary,fontSize:e.uploadThumbnailSize}},[`p${t}-text`]:{margin:`0 0 ${h(e.marginXXS)}`,color:e.colorTextHeading,fontSize:e.fontSizeLG},[`p${t}-hint`]:{color:e.colorTextDescription,fontSize:e.fontSize},[`&${t}-disabled`]:{[`p${t}-drag-icon ${n}, p${t}-text, p${t}-hint `]:{color:e.colorTextDisabled}}}}}},J=e=>{let{componentCls:t,iconCls:n,fontSize:r,lineHeight:i,motionDurationSlow:a,calc:o}=e,s=`${t}-list-item`,c=`${s}-actions`,l=`${s}-action`;return{[`${t}-wrapper`]:{[`${t}-list`]:{...f(),lineHeight:e.lineHeight,[s]:{position:`relative`,height:o(e.lineHeight).mul(r).equal(),marginTop:e.marginXS,fontSize:r,display:`flex`,alignItems:`center`,transition:`background-color ${a}`,borderRadius:e.borderRadiusSM,"&:hover":{backgroundColor:e.controlItemBgHover},[`${s}-name`]:{...T,padding:`0 ${h(e.paddingXS)}`,lineHeight:i,flex:`auto`,transition:`all ${a}`},[c]:{whiteSpace:`nowrap`,[l]:{opacity:0},"@media (hover: none), (pointer: coarse)":{[l]:{opacity:1}},[n]:{color:e.actionsColor,transition:`all ${a}`},[` ${l}:focus-visible, &.picture ${l} `]:{opacity:1}},[`${t}-icon ${n}`]:{color:e.colorIcon,fontSize:r},[`${s}-progress`]:{position:`absolute`,bottom:e.calc(e.uploadProgressOffset).mul(-1).equal(),width:`100%`,paddingInlineStart:o(r).add(e.paddingXS).equal(),fontSize:r,lineHeight:0,pointerEvents:`none`,"> div":{margin:0}}},[`${s}:hover ${l}`]:{opacity:1},[`${s}-error`]:{color:e.colorError,[`${s}-name, ${t}-icon ${n}`]:{color:e.colorError},[c]:{[`${n}, ${n}:hover`]:{color:e.colorError},[l]:{opacity:1}}},[`${t}-list-item-container`]:{transition:[`opacity`,`height`].map(e=>`${e} ${a}`).join(`, `),"&::before":{display:`table`,width:0,height:0,content:`""`}}}}}},Y=e=>{let{componentCls:t}=e,n=new S(`uploadAnimateInlineIn`,{from:{width:0,height:0,padding:0,opacity:0,margin:e.calc(e.marginXS).div(-2).equal()}}),r=new S(`uploadAnimateInlineOut`,{to:{width:0,height:0,padding:0,opacity:0,margin:e.calc(e.marginXS).div(-2).equal()}}),i=`${t}-animate-inline`;return[{[`${t}-wrapper`]:{[`${i}-appear, ${i}-enter, ${i}-leave`]:{animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseInOutCirc,animationFillMode:`forwards`},[`${i}-appear, ${i}-enter`]:{animationName:n},[`${i}-leave`]:{animationName:r}}},{[`${t}-wrapper`]:O(e)},n,r]},de=e=>{let{componentCls:t,iconCls:n,uploadThumbnailSize:r,uploadProgressOffset:i,calc:a}=e,o=`${t}-list`,s=`${o}-item`;return{[`${t}-wrapper`]:{[` ${o}${o}-picture, ${o}${o}-picture-card, ${o}${o}-picture-circle `]:{[s]:{position:`relative`,height:a(r).add(a(e.lineWidth).mul(2)).add(a(e.paddingXS).mul(2)).equal(),padding:e.paddingXS,border:`${h(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusLG,"&:hover":{background:`transparent`},[`${s}-thumbnail`]:{...T,width:r,height:r,lineHeight:h(a(r).add(e.paddingSM).equal()),textAlign:`center`,flex:`none`,[n]:{fontSize:e.fontSizeHeading2,color:e.colorPrimary},img:{display:`block`,width:`100%`,height:`100%`,overflow:`hidden`}},[`${s}-progress`]:{bottom:a(e.fontSize).mul(e.lineHeight).div(2).add(i).equal(),width:`calc(100% - ${h(a(e.paddingSM).mul(2).equal())})`,marginTop:0,paddingInlineStart:a(r).add(e.paddingXS).equal()}},[`${s}-error`]:{borderColor:e.colorError,[`${s}-thumbnail ${n}`]:{[`svg path[fill='${m[0]}']`]:{fill:e.colorErrorBg},[`svg path[fill='${m.primary}']`]:{fill:e.colorError}}},[`${s}-uploading`]:{borderStyle:`dashed`,[`${s}-name`]:{marginBottom:i}}},[`${o}${o}-picture-circle ${s}`]:{[`&, &::before, ${s}-thumbnail`]:{borderRadius:`50%`}}}}},fe=e=>{let{componentCls:t,iconCls:n,fontSizeLG:r,colorTextLightSolid:i,calc:a}=e,o=`${t}-list`,s=`${o}-item`,c=e.uploadPicCardSize;return{[` ${t}-wrapper${t}-picture-card-wrapper, ${t}-wrapper${t}-picture-circle-wrapper `]:{...f(),display:`block`,[`${t}${t}-select`]:{width:c,height:c,textAlign:`center`,verticalAlign:`top`,backgroundColor:e.colorFillAlter,border:`${h(e.lineWidth)} dashed ${e.colorBorder}`,borderRadius:e.borderRadiusLG,cursor:`pointer`,transition:`border-color ${e.motionDurationSlow}`,[`> ${t}`]:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,textAlign:`center`},[`&:not(${t}-disabled):hover`]:{borderColor:e.colorPrimary}},[`${o}${o}-picture-card, ${o}${o}-picture-circle`]:{display:`flex`,flexWrap:`wrap`,"&:not(:empty)":{minHeight:c},"@supports not (gap: 1px)":{"& > *":{marginBlockEnd:e.marginXS,marginInlineEnd:e.marginXS}},"@supports (gap: 1px)":{gap:e.marginXS},[`${o}-item-container`]:{display:`inline-block`,width:c,height:c,verticalAlign:`top`},"&::after":{display:`none`},"&::before":{display:`none`},[s]:{height:`100%`,margin:0,"&::before":{position:`absolute`,zIndex:1,width:`calc(100% - ${h(a(e.paddingXS).mul(2).equal())})`,height:`calc(100% - ${h(a(e.paddingXS).mul(2).equal())})`,backgroundColor:e.colorBgMask,opacity:0,transition:`all ${e.motionDurationSlow}`,content:`" "`}},[`${s}:hover`]:{[`&::before, ${s}-actions`]:{opacity:1}},[`${s}-actions`]:{position:`absolute`,insetInlineStart:0,zIndex:10,width:`100%`,whiteSpace:`nowrap`,textAlign:`center`,opacity:0,transition:`all ${e.motionDurationSlow}`,[` ${n}-eye, ${n}-download, ${n}-delete `]:{zIndex:10,width:r,margin:`0 ${h(e.marginXXS)}`,fontSize:r,cursor:`pointer`,transition:`all ${e.motionDurationSlow}`,color:i,"&:hover":{color:i},svg:{verticalAlign:`baseline`}}},[`${s}-thumbnail, ${s}-thumbnail img`]:{position:`static`,display:`block`,width:`100%`,height:`100%`,objectFit:`contain`},[`${s}-name`]:{display:`none`,textAlign:`center`},[`${s}-file + ${s}-name`]:{position:`absolute`,bottom:e.margin,display:`block`,width:`calc(100% - ${h(a(e.paddingXS).mul(2).equal())})`},[`${s}-uploading`]:{[`&${s}`]:{backgroundColor:e.colorFillAlter},[`&::before, ${n}-eye, ${n}-download, ${n}-delete`]:{display:`none`}},[`${s}-progress`]:{bottom:e.marginXL,width:`calc(100% - ${h(a(e.paddingXS).mul(2).equal())})`,paddingInlineStart:0}}},[`${t}-wrapper${t}-picture-circle-wrapper`]:{[`${t}${t}-select`]:{borderRadius:`50%`}}}},pe=e=>{let{componentCls:t}=e;return{[`${t}-rtl`]:{direction:`rtl`}}},me=e=>{let{componentCls:n,colorTextDisabled:r}=e;return{[`${n}-wrapper`]:{...t(e),[n]:{outline:0,"input[type='file']":{cursor:`pointer`}},[`${n}-select`]:{display:`inline-block`},[`${n}-hidden`]:{display:`none`},[`${n}-disabled`]:{color:r,cursor:`not-allowed`}}}},he=l(`Upload`,e=>{let{fontSizeHeading3:t,marginXS:n,lineWidth:i,pictureCardSize:a,calc:o}=e,s=r(e,{uploadThumbnailSize:o(t).mul(2).equal(),uploadProgressOffset:o(o(n).div(2)).add(i).equal(),uploadPicCardSize:a});return[me(s),q(s),de(s),fe(s),J(s),Y(s),pe(s),ie(s)]},e=>({actionsColor:e.colorIcon,pictureCardSize:e.controlHeightLG*2.55}));function ge(e){return{...e,lastModified:e.lastModified,lastModifiedDate:e.lastModifiedDate,name:e.name,size:e.size,type:e.type,uid:e.uid,percent:0,originFileObj:e}}function _e(e,t){let n=E(t),r=n.findIndex(({uid:t})=>t===e.uid);return r===-1?n.push(e):n[r]=e,n}function ve(e,t){let n=e.uid===void 0?`name`:`uid`;return t.filter(t=>t[n]===e[n])[0]}function ye(e,t){let n=e.uid===void 0?`name`:`uid`,r=t.filter(t=>t[n]!==e[n]);return r.length===t.length?null:r}var be=(e=``)=>{let t=e.split(`/`),n=t[t.length-1].split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(n)||[``])[0]},xe=e=>e.indexOf(`image/`)===0,Se=[`.avif`,`.bmp`,`.dpg`,`.gif`,`.heic`,`.heif`,`.ico`,`.jfif`,`.jpg`,`.jpeg`,`.png`,`.svg`,`.tif`,`.tiff`,`.webp`],Ce=e=>{if(e.type&&!e.thumbUrl)return xe(e.type);let t=e.thumbUrl||e.url||``,n=be(t);return/^data:image\//.test(t)||Se.includes(n?.toLowerCase()||``)?!0:!(/^data:/.test(t)||n)},X=200;function we(e){return new Promise(t=>{if(!e.type||!xe(e.type)){t(``);return}let n=document.createElement(`canvas`);n.width=X,n.height=X,n.style.cssText=`position: fixed; left: 0; top: 0; width: ${X}px; height: ${X}px; z-index: 9999; display: none;`,document.body.appendChild(n);let r=n.getContext(`2d`),i=new Image;if(i.onload=()=>{let{width:e,height:a}=i,o=X,s=X,c=0,l=0;e>a?(s=X/e*a,l=-(s-o)/2):(o=X/a*e,c=-(o-s)/2),r.drawImage(i,c,l,o,s);let u=n.toDataURL();document.body.removeChild(n),window.URL.revokeObjectURL(i.src),t(u)},i.crossOrigin=`anonymous`,e.type.startsWith(`image/svg+xml`)){let t=new FileReader;t.onload=()=>{t.result&&typeof t.result==`string`&&(i.src=t.result)},t.readAsDataURL(e)}else if(e.type.startsWith(`image/gif`)){let n=new FileReader;n.onload=()=>{n.result&&t(n.result)},n.readAsDataURL(e)}else i.src=window.URL.createObjectURL(e)})}var Te=P.forwardRef(({prefixCls:e,className:t,style:n,classNames:r,styles:i,locale:a,listType:o,file:l,items:u,progress:d,iconRender:f,actionIconRender:p,itemRender:m,isImgUrl:h,showPreviewIcon:g,showRemoveIcon:_,showDownloadIcon:y,previewIcon:b,removeIcon:x,downloadIcon:S,extra:C,onPreview:w,onDownload:T,onClose:te},ne)=>{let{status:E}=l,[D,O]=P.useState(E);P.useEffect(()=>{E!==`removed`&&O(E)},[E]);let[re,ie]=P.useState(!1);P.useEffect(()=>{let e=setTimeout(()=>{ie(!0)},300);return()=>{clearTimeout(e)}},[]);let A=f(l),j=P.createElement(`div`,{className:`${e}-icon`},A);if(o===`picture`||o===`picture-card`||o===`picture-circle`)if(D===`uploading`||!l.thumbUrl&&!l.url){let t=c(`${e}-list-item-thumbnail`,{[`${e}-list-item-file`]:D!==`uploading`});j=P.createElement(`div`,{className:t},A)}else{let t=h?.(l)?P.createElement(`img`,{src:l.thumbUrl||l.url,alt:l.name,className:`${e}-list-item-image`,crossOrigin:l.crossOrigin}):A,n=c(`${e}-list-item-thumbnail`,{[`${e}-list-item-file`]:h&&!h(l)});j=P.createElement(`a`,{className:n,onClick:e=>w(l,e),href:l.url||l.thumbUrl,target:`_blank`,rel:`noopener noreferrer`},t)}let M=c(`${e}-list-item`,`${e}-list-item-${D}`,r?.item),N=typeof l.linkProps==`string`?JSON.parse(l.linkProps):l.linkProps,F=(v(_)?_(l):_)?p((v(x)?x(l):x)||P.createElement(oe,null),()=>te(l),e,a.removeFile,!0):null,I=(v(y)?y(l):y)&&D===`done`?p((v(S)?S(l):S)||P.createElement(se,null),()=>T(l),e,a.downloadFile):null,L=o!==`picture-card`&&o!==`picture-circle`&&P.createElement(`span`,{key:`download-delete`,className:c(`${e}-list-item-actions`,{picture:o===`picture`})},I,F),R=v(C)?C(l):C,z=R&&P.createElement(`span`,{className:`${e}-list-item-extra`},R),B=c(`${e}-list-item-name`),le=l.url?P.createElement(`a`,{key:`view`,target:`_blank`,rel:`noopener noreferrer`,className:B,title:l.name,...N,href:l.url,onClick:e=>w(l,e)},l.name,z):P.createElement(`span`,{key:`view`,className:B,onClick:e=>w(l,e),title:l.name},l.name,z),V=(v(g)?g(l):g)&&(l.url||l.thumbUrl)?P.createElement(`a`,{href:l.url||l.thumbUrl,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>w(l,e),title:a.previewFile},v(b)?b(l):b||P.createElement(ae,null)):null,H=(o===`picture-card`||o===`picture-circle`)&&D!==`uploading`&&P.createElement(`span`,{className:`${e}-list-item-actions`},V,D===`done`&&I,F),{getPrefixCls:U}=P.useContext(ee),W=U(),G=P.createElement(`div`,{className:M,style:i?.item},j,le,L,H,re&&P.createElement(s,{motionName:`${W}-fade`,visible:D===`uploading`,motionDeadline:2e3},({className:t})=>{let n=`percent`in l?P.createElement(ce,{type:`line`,percent:l.percent,"aria-label":l[`aria-label`],"aria-labelledby":l[`aria-labelledby`],...d}):null;return P.createElement(`div`,{className:c(`${e}-list-item-progress`,t)},n)})),K=l.response&&typeof l.response==`string`?l.response:l.error?.statusText||l.error?.message||a.uploadError,ue=D===`error`?P.createElement(k,{title:K,getPopupContainer:e=>e.parentNode},G):G;return P.createElement(`div`,{className:c(`${e}-list-item-container`,t),style:n,ref:ne},m?m(ue,l,u,{download:T.bind(null,l),preview:w.bind(null,l),remove:te.bind(null,l)}):ue)}),Ee=P.forwardRef((t,n)=>{let{listType:r=`text`,previewFile:a=we,onPreview:o,onDownload:l,onRemove:u,locale:f,iconRender:m,isImageUrl:h=Ce,prefixCls:g,items:_=[],showPreviewIcon:y=!0,showRemoveIcon:b=!0,showDownloadIcon:x=!1,removeIcon:S,previewIcon:C,downloadIcon:T,extra:te,progress:ne={size:[-1,2],showInfo:!1},appendAction:D,appendActionVisible:O=!0,itemRender:k,disabled:ie,classNames:ae,styles:oe}=t,[,se]=re(),[ce,F]=P.useState(!1),I=[`picture-card`,`picture-circle`].includes(r);P.useEffect(()=>{r.startsWith(`picture`)&&(_||[]).forEach(e=>{!(e.originFileObj instanceof File||e.originFileObj instanceof Blob)||e.thumbUrl!==void 0||(e.thumbUrl=``,a?.(e.originFileObj).then(t=>{e.thumbUrl=t||``,se()}))})},[r,_,a]),P.useEffect(()=>{F(!0)},[]);let L=(e,t)=>{if(o)return t?.preventDefault(),o(e)},R=e=>{v(l)?l(e):e.url&&window.open(e.url)},z=e=>{u?.(e)},B=t=>{if(m)return m(t,r);let n=t.status===`uploading`;if(r.startsWith(`picture`)){let i=r===`picture`?P.createElement(e,null):f.uploading,a=h?.(t)?P.createElement(N,null):P.createElement(j,null);return n?i:a}return n?P.createElement(e,null):P.createElement(M,null)},le=(e,t,n,r,i)=>{let a={type:`text`,size:`small`,title:r,onClick:n=>{t(),P.isValidElement(e)&&e.props.onClick?.(n)},className:`${n}-list-item-action`,disabled:i?ie:!1};return P.isValidElement(e)?P.createElement(A,{...a,icon:w(e,{...e.props,onClick:()=>{}})}):P.createElement(A,{...a},P.createElement(`span`,null,e))};P.useImperativeHandle(n,()=>({handlePreview:L,handleDownload:R}));let{getPrefixCls:V}=P.useContext(ee),H=V(`upload`,g),U=V(),W=c(`${H}-list`,`${H}-list-${r}`,ae?.list),G=P.useMemo(()=>d(p(U),[`onAppearEnd`,`onEnterEnd`,`onLeaveEnd`]),[U]),K={...I?{}:G,motionDeadline:2e3,motionName:`${H}-${I?`animate-inline`:`animate`}`,keys:E(_.map(e=>({key:e.uid,file:e}))),motionAppear:ce};return P.createElement(`div`,{className:W,style:oe?.list},P.createElement(i,{...K,component:!1},({key:e,file:t,className:n,style:i})=>P.createElement(Te,{key:e,locale:f,prefixCls:H,className:n,style:i,classNames:ae,styles:oe,file:t,items:_,progress:ne,listType:r,isImgUrl:h,showPreviewIcon:y,showRemoveIcon:b,showDownloadIcon:x,removeIcon:S,previewIcon:C,downloadIcon:T,extra:te,iconRender:B,actionIconRender:le,itemRender:k,onPreview:L,onDownload:R,onClose:z})),D&&P.createElement(s,{...K,visible:O,forceRender:!0},({className:e,style:t})=>w(D,n=>({className:c(n.className,e),style:{...t,pointerEvents:e?`none`:void 0,...n.style}}))))}),Z=`__LIST_IGNORE_${Date.now()}__`,De=P.forwardRef((e,t)=>{let n=g(`upload`),{fileList:r,defaultFileList:i,onRemove:a,showUploadList:o=!0,listType:s=`text`,onPreview:l,onDownload:u,onChange:d,onDrop:f,previewFile:p,disabled:m,locale:h,iconRender:S,isImageUrl:ee,progress:w,prefixCls:T,className:ne,type:O=`select`,children:k,style:re,itemRender:ie,maxCount:A,data:j={},multiple:M=!1,hasControlInside:N=!0,action:ae=``,accept:oe,supportServerRender:se=!0,rootClassName:ce,styles:I,classNames:L}=e,R=P.useContext(x),z=m??R,B=e.customRequest||n.customRequest,le=n.progress||w?{...n.progress,...w}:void 0,V=D(oe,n.accept,``),[H,U]=te(i,r),W=H||[],[G,K]=P.useState(`drop`),q=P.useRef(null),J=P.useRef(null);P.useMemo(()=>{let e=Date.now();(r||[]).forEach((t,n)=>{!t.uid&&!Object.isFrozen(t)&&(t.uid=`__AUTO__${e}_${n}__`)})},[r]);let Y=(e,t,n)=>{let r=E(t),i=!1;A===1?r=r.slice(-1):A&&(i=r.length>A,r=r.slice(0,A)),(0,F.flushSync)(()=>{U(r)});let a={file:e,fileList:r};n&&(a.event=n),(!i||e.status===`removed`||r.some(t=>t.uid===e.uid))&&(0,F.flushSync)(()=>{d?.(a)})},de=async(t,n)=>{let{beforeUpload:r}=e,i=t;if(r){let e=await r(t,n);if(e===!1)return!1;if(delete t[Z],e===Z)return Object.defineProperty(t,Z,{value:!0,configurable:!0}),!1;y(e)&&(i=e)}return i},fe=e=>{let t=e.filter(e=>!e.file[Z]);if(!t.length)return;let n=t.map(e=>ge(e.file)),r=E(W);n.forEach(e=>{r=_e(e,r)}),n.forEach((e,n)=>{let i=e;if(t[n].parsedFile)e.status=`uploading`;else{let{originFileObj:t}=e,n;try{n=new File([t],t.name,{type:t.type})}catch{n=new Blob([t],{type:t.type}),n.name=t.name,n.lastModifiedDate=new Date,n.lastModified=new Date().getTime()}n.uid=e.uid,i=n}Y(i,r)})},pe=(e,t,n)=>{try{typeof e==`string`&&(e=JSON.parse(e))}catch{}if(!ve(t,W))return;let r=ge(t);r.status=`done`,r.percent=100,r.response=e,r.xhr=n,Y(r,_e(r,W))},me=(e,t)=>{if(!ve(t,W))return;let n=ge(t);n.status=`uploading`,n.percent=e.percent,Y(n,_e(n,W),e)},be=(e,t,n)=>{if(!ve(n,W))return;let r=ge(n);r.error=e,r.response=t,r.status=`error`,Y(r,_e(r,W))},xe=e=>{let t;Promise.resolve(v(a)?a(e):a).then(n=>{if(n===!1)return;let r=ye(e,W);r&&(t={...e,status:`removed`},W?.forEach(e=>{let n=t.uid===void 0?`name`:`uid`;e[n]===t[n]&&!Object.isFrozen(e)&&(e.status=`removed`)}),q.current?.abort(t),Y(t,r))})},Se=e=>{K(e.type),e.type===`drop`&&f?.(e)};P.useImperativeHandle(t,()=>({onBatchStart:fe,onSuccess:pe,onProgress:me,onError:be,fileList:W,upload:q.current,nativeElement:J.current}));let{getPrefixCls:Ce,direction:X,className:we,style:Te,classNames:De,styles:Oe}=g(`upload`),Q=Ce(`upload`,T),ke={...e,listType:s,showUploadList:o,type:O,multiple:M,hasControlInside:N,supportServerRender:se,disabled:z},[Ae,je]=_([De,L],[Oe,I],{props:ke}),$={onBatchStart:fe,onError:be,onProgress:me,onSuccess:pe,...e,customRequest:B,data:j,multiple:M,action:ae,accept:V,supportServerRender:se,prefixCls:Q,disabled:z,beforeUpload:de,onChange:void 0,hasControlInside:N};delete $.className,delete $.style,(!k||z)&&delete $.id;let Me=`${Q}-wrapper`,[Ne,Pe]=he(Q,Me),[Fe]=C(`Upload`,b.Upload),{showRemoveIcon:Ie,showPreviewIcon:Le,showDownloadIcon:Re,removeIcon:ze,previewIcon:Be,downloadIcon:Ve,extra:He}=typeof o==`boolean`?{}:o,Ue=Ie===void 0?!z:Ie,We=(e,t)=>o?P.createElement(Ee,{classNames:Ae,styles:je,prefixCls:Q,listType:s,items:W,previewFile:p,onPreview:l,onDownload:u,onRemove:xe,showRemoveIcon:Ue,showPreviewIcon:Le,showDownloadIcon:Re,removeIcon:ze,previewIcon:Be,downloadIcon:Ve,iconRender:S,extra:He,locale:{...Fe,...h},isImageUrl:ee,progress:le,appendAction:e,appendActionVisible:t,itemRender:ie,disabled:z}):e,Ge=c(Me,ne,ce,Ne,Pe,we,Ae.root,{[`${Q}-rtl`]:X===`rtl`,[`${Q}-picture-card-wrapper`]:s===`picture-card`,[`${Q}-picture-circle-wrapper`]:s===`picture-circle`}),Ke={...je.root},qe={...Te,...re};if(O===`drag`){let e=c(Ne,Q,`${Q}-drag`,{[`${Q}-drag-uploading`]:W.some(e=>e.status===`uploading`),[`${Q}-drag-hover`]:G===`dragover`,[`${Q}-disabled`]:z,[`${Q}-rtl`]:X===`rtl`},Ae.trigger);return P.createElement(`span`,{className:Ge,ref:J,style:Ke},P.createElement(`div`,{className:e,style:{...qe,...je.trigger},onDrop:Se,onDragOver:Se,onDragLeave:Se},P.createElement(ue,{...$,ref:q,className:`${Q}-btn`},P.createElement(`div`,{className:`${Q}-drag-container`},k))),We())}let Je=c(Q,`${Q}-select`,{[`${Q}-disabled`]:z,[`${Q}-hidden`]:!k},Ae.trigger),Ye=P.createElement(`div`,{className:Je,style:{...qe,...je.trigger}},P.createElement(ue,{...$,ref:q}));return s===`picture-card`||s===`picture-circle`?P.createElement(`span`,{className:Ge,ref:J,style:Ke},We(Ye,!!k)):P.createElement(`span`,{className:Ge,ref:J,style:Ke},Ye,We())}),Oe=P.forwardRef((e,t)=>{let{style:n,height:r,hasControlInside:i=!1,children:a,...o}=e,s={...n,height:r};return P.createElement(De,{ref:t,hasControlInside:i,...o,style:s,type:`drag`},a)}),Q=De;Q.Dragger=Oe,Q.LIST_IGNORE=Z;export{Q as t};