import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{$t as t,An as n,Bn as r,Ct as i,Dr as a,Er as o,Et as s,Kt as c,Ln as l,Mt as u,Nt as d,Pn as f,Vn as p,Wt as m,Xn as h,Zn as g,Zt as _,at as v,et as y,ht as b,nt as x,pt as S,st as C,tr as w,xn as T,xt as ee,yr as te,zn as ne}from"./jsx-runtime-ADHq9IcL.js";import{_ as E,t as D}from"./tooltip-CRuv8UNz.js";import{g as O}from"./style-Der9vtsK.js";import{a as k}from"./useBreakpoint-Dhidjsjf.js";import{r as re}from"./ColorPresets-wH0crouI.js";import{n as ie}from"./button-CcpWP-mq.js";import{t as A}from"./EyeOutlined-DUuSYbtj.js";import{n as j,t as M}from"./PictureOutlined-5m8FAlCn.js";import{t as N}from"./progress-C2fffzqa.js";import{t as ae}from"./FileOutlined-e-Jre-Gv.js";import{t as oe}from"./DeleteOutlined-D3Fhpkuo.js";import{t as se}from"./DownloadOutlined-CA51LTon.js";var P=e(a()),ce=e(o()),F=((e,t)=>{if(e&&t){let n=Array.isArray(t)?t:t.split(`,`),r=e.name||``,i=e.type||``,a=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)?a===t.replace(/\/.*$/,``):i===t?!0:/^\w+$/.test(t)?(w(!1,`Upload takes an invalidate 'accept' type '${t}'.Skip for check.`),!0):!1})}return!0});function I(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 L(e){let t=e.responseText||e.response;if(!t)return t;try{return JSON.parse(t)}catch{return t}}function R(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(I(e,t),L(t)):e.onSuccess(L(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 z=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=>F(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 z(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=V(),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||R,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:R})}reset(){this.setState({uid:V()})}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:n,classNames:r={},disabled:i,id:a,name:o,style:s,styles:c={},multiple:l,accept:u,capture:d,children:f,directory:m,openFileDialogOnClick:g,onMouseEnter:_,onMouseLeave:v,hasControlInside:y,...b}=this.props,x=typeof u==`string`?u:u?.format,S=p(t,{[`${t}-disabled`]:i,[n]:n}),C=m?{directory:`directory`,webkitdirectory:`webkitdirectory`}:{},w=i?{}:{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,H({},w,{className:S,role:y?void 0:`button`,style:s}),P.createElement(`input`,H({},h(b,{aria:!0,data:!0}),{id:a,name:o,disabled:i,type:`file`,ref:this.saveFileInput,onClick:e=>e.stopPropagation(),key:this.state.uid,style:{display:`none`,...c.input},className:r.input,accept:x},C,{multiple:l,onChange:this.onChange},d==null?{}:{capture:d})),f)}};function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t{this.uploader=e};render(){return P.createElement(U,W({},this.props,{ref:this.saveUploader}))}},ue=e=>{let{componentCls:t,iconCls:n}=e;return{[`${t}-wrapper`]:{[`${t}-drag`]:{position:`relative`,width:`100%`,height:`100%`,textAlign:`center`,background:e.colorFillAlter,border:`${f(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:`${f(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 ${f(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}}}}}},q=e=>{let{componentCls:n,iconCls:r,fontSize:i,lineHeight:a,motionDurationSlow:o,calc:s}=e,l=`${n}-list-item`,u=`${l}-actions`,d=`${l}-action`;return{[`${n}-wrapper`]:{[`${n}-list`]:{...c(),lineHeight:e.lineHeight,[l]:{position:`relative`,height:s(e.lineHeight).mul(i).equal(),marginTop:e.marginXS,fontSize:i,display:`flex`,alignItems:`center`,transition:`background-color ${o}`,borderRadius:e.borderRadiusSM,"&:hover":{backgroundColor:e.controlItemBgHover},[`${l}-name`]:{...t,padding:`0 ${f(e.paddingXS)}`,lineHeight:a,flex:`auto`,transition:`all ${o}`},[u]:{whiteSpace:`nowrap`,[d]:{opacity:0},"@media (hover: none), (pointer: coarse)":{[d]:{opacity:1}},[r]:{color:e.actionsColor,transition:`all ${o}`},[` ${d}:focus-visible, &.picture ${d} `]:{opacity:1}},[`${n}-icon ${r}`]:{color:e.colorIcon,fontSize:i},[`${l}-progress`]:{position:`absolute`,bottom:e.calc(e.uploadProgressOffset).mul(-1).equal(),width:`100%`,paddingInlineStart:s(i).add(e.paddingXS).equal(),fontSize:i,lineHeight:0,pointerEvents:`none`,"> div":{margin:0}}},[`${l}:hover ${d}`]:{opacity:1},[`${l}-error`]:{color:e.colorError,[`${l}-name, ${n}-icon ${r}`]:{color:e.colorError},[u]:{[`${r}, ${r}:hover`]:{color:e.colorError},[d]:{opacity:1}}},[`${n}-list-item-container`]:{transition:[`opacity`,`height`].map(e=>`${e} ${o}`).join(`, `),"&::before":{display:`table`,width:0,height:0,content:`""`}}}}}},J=e=>{let{componentCls:t}=e,r=new n(`uploadAnimateInlineIn`,{from:{width:0,height:0,padding:0,opacity:0,margin:e.calc(e.marginXS).div(-2).equal()}}),i=new n(`uploadAnimateInlineOut`,{to:{width:0,height:0,padding:0,opacity:0,margin:e.calc(e.marginXS).div(-2).equal()}}),a=`${t}-animate-inline`;return[{[`${t}-wrapper`]:{[`${a}-appear, ${a}-enter, ${a}-leave`]:{animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseInOutCirc,animationFillMode:`forwards`},[`${a}-appear, ${a}-enter`]:{animationName:r},[`${a}-leave`]:{animationName:i}}},{[`${t}-wrapper`]:E(e)},r,i]},Y=e=>{let{componentCls:n,iconCls:r,uploadThumbnailSize:i,uploadProgressOffset:a,calc:o}=e,s=`${n}-list`,c=`${s}-item`;return{[`${n}-wrapper`]:{[` ${s}${s}-picture, ${s}${s}-picture-card, ${s}${s}-picture-circle `]:{[c]:{position:`relative`,height:o(i).add(o(e.lineWidth).mul(2)).add(o(e.paddingXS).mul(2)).equal(),padding:e.paddingXS,border:`${f(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusLG,"&:hover":{background:`transparent`},[`${c}-thumbnail`]:{...t,width:i,height:i,lineHeight:f(o(i).add(e.paddingSM).equal()),textAlign:`center`,flex:`none`,[r]:{fontSize:e.fontSizeHeading2,color:e.colorPrimary},img:{display:`block`,width:`100%`,height:`100%`,overflow:`hidden`}},[`${c}-progress`]:{bottom:o(e.fontSize).mul(e.lineHeight).div(2).add(a).equal(),width:`calc(100% - ${f(o(e.paddingSM).mul(2).equal())})`,marginTop:0,paddingInlineStart:o(i).add(e.paddingXS).equal()}},[`${c}-error`]:{borderColor:e.colorError,[`${c}-thumbnail${c}-file ${r}`]:{color:e.colorError}},[`${c}-uploading`]:{borderStyle:`dashed`,[`${c}-name`]:{marginBottom:a}}},[`${s}${s}-picture-circle ${c}`]:{[`&, &::before, ${c}-thumbnail`]:{borderRadius:`50%`}}}}},de=e=>{let{componentCls:t,iconCls:n,fontSizeLG:r,colorTextLightSolid:i,calc:a}=e,o=`${t}-list`,s=`${o}-item`,l=e.uploadPicCardSize;return{[` ${t}-wrapper${t}-picture-card-wrapper, ${t}-wrapper${t}-picture-circle-wrapper `]:{...c(),display:`block`,[`${t}${t}-select`]:{width:l,height:l,textAlign:`center`,verticalAlign:`top`,backgroundColor:e.colorFillAlter,border:`${f(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:l},"@supports not (gap: 1px)":{"& > *":{marginBlockEnd:e.marginXS,marginInlineEnd:e.marginXS}},"@supports (gap: 1px)":{gap:e.marginXS},[`${o}-item-container`]:{display:`inline-block`,width:l,height:l,verticalAlign:`top`},"&::after":{display:`none`},"&::before":{display:`none`},[s]:{height:`100%`,margin:0,"&::before":{position:`absolute`,zIndex:1,width:`calc(100% - ${f(a(e.paddingXS).mul(2).equal())})`,height:`calc(100% - ${f(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 ${f(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% - ${f(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% - ${f(a(e.paddingXS).mul(2).equal())})`,paddingInlineStart:0}}},[`${t}-wrapper${t}-picture-circle-wrapper`]:{[`${t}${t}-select`]:{borderRadius:`50%`}}}},fe=e=>{let{componentCls:t}=e;return{[`${t}-rtl`]:{direction:`rtl`}}},pe=e=>{let{componentCls:t,colorTextDisabled:n}=e;return{[`${t}-wrapper`]:{..._(e),[t]:{outline:0,"input[type='file']":{cursor:`pointer`}},[`${t}-select`]:{display:`inline-block`},[`${t}-hidden`]:{display:`none`},[`${t}-disabled`]:{color:n,cursor:`not-allowed`}}}},me=m(`Upload`,e=>{let{fontSizeHeading3:t,marginXS:n,lineWidth:r,pictureCardSize:i,calc:a}=e,o=T(e,{uploadThumbnailSize:a(t).mul(2).equal(),uploadProgressOffset:a(a(n).div(2)).add(r).equal(),uploadPicCardSize:i});return[pe(o),ue(o),Y(o),de(o),q(o),J(o),fe(o),re(o)]},e=>({actionsColor:e.colorIcon,pictureCardSize:e.controlHeightLG*2.55}));function he(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 ge(e,t){let n=r(t),i=n.findIndex(({uid:t})=>t===e.uid);return i===-1?n.push(e):n[i]=e,n}function _e(e,t){let n=e.uid===void 0?`name`:`uid`;return t.filter(t=>t[n]===e[n])[0]}function ve(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 ye=(e=``)=>{let t=e.split(`/`),n=t[t.length-1].split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(n)||[``])[0]},be=e=>e.indexOf(`image/`)===0,xe=[`.avif`,`.bmp`,`.dpg`,`.gif`,`.heic`,`.heif`,`.ico`,`.jfif`,`.jpg`,`.jpeg`,`.png`,`.svg`,`.tif`,`.tiff`,`.webp`],Se=e=>{if(e.type&&!e.thumbUrl)return be(e.type);let t=e.thumbUrl||e.url||``,n=ye(t||e.name);return/^data:image\//.test(t)||xe.includes(n?.toLowerCase()||``)?!0:!(/^data:/.test(t)||n)},X=200;function Ce(e){return new Promise(t=>{if(!e.type||!be(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 we=P.forwardRef(({prefixCls:e,className:t,style:n,classNames:r,styles:a,locale:o,listType:s,file:c,items:d,progress:f,iconRender:m,actionIconRender:h,itemRender:g,isImgUrl:_,showPreviewIcon:v,showRemoveIcon:y,showDownloadIcon:b,previewIcon:x,removeIcon:S,downloadIcon:C,extra:w,onPreview:T,onDownload:ee,onClose:te},ne)=>{let{status:E}=c,[O,k]=P.useState(E);P.useEffect(()=>{E!==`removed`&&k(E)},[E]);let[re,ie]=P.useState(!1);P.useEffect(()=>{let e=setTimeout(()=>{ie(!0)},300);return()=>{clearTimeout(e)}},[]);let j=m(c),M=P.createElement(`div`,{className:`${e}-icon`},j);if(s===`picture`||s===`picture-card`||s===`picture-circle`)if(O===`uploading`||!c.thumbUrl&&!c.url){let t=p(`${e}-list-item-thumbnail`,{[`${e}-list-item-file`]:O!==`uploading`});M=P.createElement(`div`,{className:t},j)}else{let t=_?.(c)?P.createElement(`img`,{src:c.thumbUrl||c.url,alt:c.name,className:`${e}-list-item-image`,crossOrigin:c.crossOrigin}):j,n=p(`${e}-list-item-thumbnail`,{[`${e}-list-item-file`]:_&&!_(c)});M=P.createElement(`a`,{className:n,onClick:e=>T(c,e),href:c.url||c.thumbUrl,target:`_blank`,rel:`noopener noreferrer`},t)}let ae=p(`${e}-list-item`,`${e}-list-item-${O}`,r?.item),ce=typeof c.linkProps==`string`?JSON.parse(c.linkProps):c.linkProps,F=(i(y)?y(c):y)?h((i(S)?S(c):S)||P.createElement(oe,null),()=>te(c),e,o.removeFile,!0):null,I=(i(b)?b(c):b)&&O===`done`?h((i(C)?C(c):C)||P.createElement(se,null),()=>ee(c),e,o.downloadFile):null,L=s!==`picture-card`&&s!==`picture-circle`&&P.createElement(`span`,{key:`download-delete`,className:p(`${e}-list-item-actions`,{picture:s===`picture`})},I,F),R=i(w)?w(c):w,z=R&&P.createElement(`span`,{className:`${e}-list-item-extra`},R),B=p(`${e}-list-item-name`),le=c.url?P.createElement(`a`,{key:`view`,target:`_blank`,rel:`noopener noreferrer`,className:B,title:c.name,...ce,href:c.url,onClick:e=>T(c,e)},c.name,z):P.createElement(`span`,{key:`view`,role:`button`,tabIndex:0,className:B,onClick:e=>T(c,e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(c,e))},title:c.name},c.name,z),V=(i(v)?v(c):v)&&(c.url||c.thumbUrl)?P.createElement(`a`,{href:c.url||c.thumbUrl,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>T(c,e),title:o.previewFile},i(x)?x(c):x||P.createElement(A,null)):null,H=(s===`picture-card`||s===`picture-circle`)&&O!==`uploading`&&P.createElement(`span`,{className:`${e}-list-item-actions`},V,O===`done`&&I,F),{getPrefixCls:U}=P.useContext(l),W=U(),G=P.createElement(`div`,{className:ae,style:a?.item},M,le,L,H,re&&P.createElement(u,{motionName:`${W}-fade`,visible:O===`uploading`,motionDeadline:2e3},({className:t})=>{let n=`percent`in c?P.createElement(N,{type:`line`,percent:c.percent,"aria-label":c[`aria-label`],"aria-labelledby":c[`aria-labelledby`],...f}):null;return P.createElement(`div`,{className:p(`${e}-list-item-progress`,t)},n)})),K=c.response&&typeof c.response==`string`?c.response:c.error?.statusText||c.error?.message||o.uploadError,ue=O===`error`?P.createElement(D,{title:K,getPopupContainer:e=>e.parentNode},G):G;return P.createElement(`div`,{className:p(`${e}-list-item-container`,t),style:n,ref:ne},g?g(ue,c,d,{download:ee.bind(null,c),preview:T.bind(null,c),remove:te.bind(null,c)}):ue)}),Te=P.forwardRef((e,t)=>{let{listType:n=`text`,previewFile:a=Ce,onPreview:o,onDownload:s,onRemove:c,locale:f,iconRender:m,isImageUrl:h=Se,prefixCls:_,items:v=[],showPreviewIcon:b=!0,showRemoveIcon:S=!0,showDownloadIcon:w=!1,removeIcon:T,previewIcon:ee,downloadIcon:te,extra:ne,progress:E={size:[-1,2],showInfo:!1},appendAction:D,appendActionVisible:O=!0,itemRender:re,disabled:A,classNames:N,styles:oe}=e,[,se]=k(),[ce,F]=P.useState(!1),I=[`picture-card`,`picture-circle`].includes(n);P.useEffect(()=>{n.startsWith(`picture`)&&(v||[]).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()}))})},[n,v,a]),P.useEffect(()=>{F(!0)},[]);let L=(e,t)=>{if(o)return t?.preventDefault(),o(e)},R=e=>{i(s)?s(e):e.url&&window.open(e.url)},z=e=>{c?.(e)},B=e=>{if(m)return m(e,n);let t=e.status===`uploading`;if(n.startsWith(`picture`)){let r=n===`picture`?P.createElement(x,null):f.uploading,i=h?.(e)?P.createElement(M,null):P.createElement(ae,null);return t?r:i}return t?P.createElement(x,null):P.createElement(j,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?A:!1};return P.isValidElement(e)?P.createElement(ie,{...a,icon:C(e,{...e.props,onClick:()=>{}})}):P.createElement(ie,{...a},P.createElement(`span`,null,e))};P.useImperativeHandle(t,()=>({handlePreview:L,handleDownload:R}));let{getPrefixCls:V}=P.useContext(l),H=V(`upload`,_),U=V(),W=p(`${H}-list`,`${H}-list-${n}`,N?.list),G=P.useMemo(()=>g(y(U),[`onAppearEnd`,`onEnterEnd`,`onLeaveEnd`]),[U]),K={...I?{}:G,motionDeadline:2e3,motionName:`${H}-${I?`animate-inline`:`animate`}`,keys:r(v.map(e=>({key:e.uid,file:e}))),motionAppear:ce};return P.createElement(`div`,{className:W,style:oe?.list},P.createElement(d,{...K,component:!1},({key:e,file:t,className:r,style:i})=>P.createElement(we,{key:e,locale:f,prefixCls:H,className:r,style:i,classNames:N,styles:oe,file:t,items:v,progress:E,listType:n,isImgUrl:h,showPreviewIcon:b,showRemoveIcon:S,showDownloadIcon:w,removeIcon:T,previewIcon:ee,downloadIcon:te,extra:ne,iconRender:B,actionIconRender:le,itemRender:re,onPreview:L,onDownload:R,onClose:z})),D&&P.createElement(u,{...K,visible:O,forceRender:!0},({className:e,style:t})=>C(D,n=>({className:p(n.className,e),style:{...t,pointerEvents:e?`none`:void 0,...n.style}}))))}),Z=`__LIST_IGNORE_${Date.now()}__`,Ee=P.forwardRef((e,t)=>{let n=ne(`upload`),{fileList:a,defaultFileList:o,onRemove:c,showUploadList:l=!0,listType:u=`text`,onPreview:d,onDownload:f,onChange:m,onDrop:h,previewFile:g,disabled:_,locale:y,iconRender:x,isImageUrl:C,progress:w,prefixCls:T,className:E,type:D=`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:F,styles:I,classNames:L}=e,R=P.useContext(v),z=_??R,B=e.customRequest||n.customRequest,le=n.progress||w?{...n.progress,...w}:void 0,V=O(oe,n.accept,``),[H,U]=te(o,a),W=H||[],[G,ue]=P.useState(`drop`),q=P.useRef(null),J=P.useRef(null);P.useMemo(()=>{let e=Date.now();(a||[]).forEach((t,n)=>{!t.uid&&!Object.isFrozen(t)&&(t.uid=`__AUTO__${e}_${n}__`)})},[a]);let Y=(e,t,n)=>{let i=r(t),a=!1;A===1?i=i.slice(-1):A&&(a=i.length>A,i=i.slice(0,A)),(0,ce.flushSync)(()=>{U(i)});let o={file:e,fileList:i};n&&(o.event=n),(!a||e.status===`removed`||i.some(t=>t.uid===e.uid))&&(0,ce.flushSync)(()=>{m?.(o)})},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;s(e)&&(i=e)}return i},fe=e=>{let t=e.filter(e=>!e.file[Z]);if(!t.length)return;let n=t.map(e=>he(e.file)),i=r(W);n.forEach(e=>{i=ge(e,i)}),n.forEach((e,n)=>{let r=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,r=n}Y(r,i)})},pe=(e,t,n)=>{try{typeof e==`string`&&(e=JSON.parse(e))}catch{}if(!_e(t,W))return;let r=he(t);r.status=`done`,r.percent=100,r.response=e,r.xhr=n;let i=ge(r,W);Y(r,i)},ye=(e,t)=>{if(!_e(t,W))return;let n=he(t);n.status=`uploading`,n.percent=e.percent;let r=ge(n,W);Y(n,r,e)},be=(e,t,n)=>{if(!_e(n,W))return;let r=he(n);r.error=e,r.response=t,r.status=`error`;let i=ge(r,W);Y(r,i)},xe=e=>{let t;Promise.resolve(i(c)?c(e):c).then(n=>{if(n===!1)return;let r=ve(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=>{ue(e.type),e.type===`drop`&&h?.(e)};P.useImperativeHandle(t,()=>({onBatchStart:fe,onSuccess:pe,onProgress:ye,onError:be,fileList:W,upload:q.current,nativeElement:J.current}));let{getPrefixCls:X,direction:Ce,className:we,style:Ee,classNames:De,styles:Oe}=ne(`upload`),Q=X(`upload`,T),ke={...e,listType:u,showUploadList:l,type:D,multiple:M,hasControlInside:N,supportServerRender:se,disabled:z},[Ae,je]=ee([De,L],[Oe,I],{props:ke}),$={onBatchStart:fe,onError:be,onProgress:ye,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]=me(Q,Me),[Fe]=S(`Upload`,b.Upload),{showRemoveIcon:Ie,showPreviewIcon:Le,showDownloadIcon:Re,removeIcon:ze,previewIcon:Be,downloadIcon:Ve,extra:He}=typeof l==`boolean`?{}:l,Ue=Ie===void 0?!z:Ie,We=(e,t)=>l?P.createElement(Te,{classNames:Ae,styles:je,prefixCls:Q,listType:u,items:W,previewFile:g,onPreview:d,onDownload:f,onRemove:xe,showRemoveIcon:Ue,showPreviewIcon:Le,showDownloadIcon:Re,removeIcon:ze,previewIcon:Be,downloadIcon:Ve,iconRender:x,extra:He,locale:{...Fe,...y},isImageUrl:C,progress:le,appendAction:e,appendActionVisible:t,itemRender:ie,disabled:z}):e,Ge=p(Me,E,F,Ne,Pe,we,Ae.root,{[`${Q}-rtl`]:Ce===`rtl`,[`${Q}-picture-card-wrapper`]:u===`picture-card`,[`${Q}-picture-circle-wrapper`]:u===`picture-circle`}),Ke={...je.root},qe={...Ee,...re};if(D===`drag`){let e=p(Ne,Q,`${Q}-drag`,{[`${Q}-drag-uploading`]:W.some(e=>e.status===`uploading`),[`${Q}-drag-hover`]:G===`dragover`,[`${Q}-disabled`]:z,[`${Q}-rtl`]:Ce===`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(K,{...$,ref:q,className:`${Q}-btn`},P.createElement(`div`,{className:`${Q}-drag-container`},k))),We())}let Je=p(Q,`${Q}-select`,{[`${Q}-disabled`]:z,[`${Q}-hidden`]:!k},Ae.trigger),Ye=P.createElement(`div`,{className:Je,style:{...qe,...je.trigger}},P.createElement(K,{...$,ref:q}));return u===`picture-card`||u===`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())}),De=P.forwardRef((e,t)=>{let{style:n,height:r,hasControlInside:i=!1,children:a,...o}=e,s={...n,height:r};return P.createElement(Ee,{ref:t,hasControlInside:i,...o,style:s,type:`drag`},a)}),Oe=Ee;Oe.Dragger=De,Oe.LIST_IGNORE=Z;export{Oe as t};