Files
xin-procurement/public/assets/upload-BEJwuAwh.js
T
2026-10-30 10:51:09 +08:00

21 lines
27 KiB
JavaScript

import{o as e}from"./request-xrnk7ZJV.js";import{$n as t,Bn as n,Ct as r,Er as i,Et as a,Ft as o,Hn as s,It as c,Ln as l,Nn as u,Nr as d,Pr as f,Qn as p,Un as m,Wn as h,Yt as g,ar as _,at as v,en as y,et as b,ht as x,jr as S,kt as C,nn as w,nr as T,nt as ee,pt as te,qt as E,rr as ne,st as re,wn as D,wr as O,wt as k}from"./jsx-runtime-OfKoVykY.js";import{_ as A,t as ie}from"./tooltip-DI_m69zk.js";import{g as ae}from"./style-CSZsuTOx.js";import{a as j}from"./useBreakpoint-DER0GTnn.js";import{r as M}from"./ColorPresets-BWkFn7Wc.js";import{n as N}from"./button-DsOd0cni.js";import{t as oe}from"./EyeOutlined-CdD0jpIv.js";import{t as se}from"./progress-9y9Eke6u.js";import{at as ce,ct as P,ot as le,st as ue,vt as de}from"./index-DMEx4_h0.js";var F=e(f()),I=e(d()),fe=((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)?(_(!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];Array.isArray(r)?r.forEach(e=>{n.append(`${t}[]`,e)}):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<r;t++)n.push(e[t])}return n}async function a(e){return new Promise(n=>{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<r.length;)await o(r[s]),s++;return n},V=+new Date,pe=0;function H(){return`rc-upload-${V}-${++pe}`}function U(){return U=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},U.apply(this,arguments)}var me=class extends F.Component{state={uid:H()};reqs={};fileInput;_isMounted;filterFile=(e,t=!1)=>{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=>fe(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: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=h(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 F.createElement(e,U({},w,{className:S,role:y?void 0:`button`,style:s}),F.createElement(`input`,U({},p(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<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(this,arguments)}function G(){}var he=class extends F.Component{static defaultProps={component:`span`,prefixCls:`rc-upload`,data:{},headers:{},name:`file`,multipart:!1,onStart:G,onError:G,onSuccess:G,multiple:!1,beforeUpload:null,customRequest:null,withCredentials:!1,openFileDialogOnClick:!0,hasControlInside:!1};uploader;abort(e){this.uploader.abort(e)}saveUploader=e=>{this.uploader=e};render(){return F.createElement(me,W({},this.props,{ref:this.saveUploader}))}},K=e=>{let{componentCls:t,iconCls:n}=e;return{[`${t}-wrapper`]:{[`${t}-drag`]:{position:`relative`,width:`100%`,height:`100%`,textAlign:`center`,background:e.colorFillAlter,border:`${l(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:`${l(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 ${l(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:t,iconCls:n,fontSize:r,lineHeight:i,motionDurationSlow:a,calc:o}=e,s=`${t}-list-item`,c=`${s}-actions`,u=`${s}-action`;return{[`${t}-wrapper`]:{[`${t}-list`]:{...g(),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`]:{...w,padding:`0 ${l(e.paddingXS)}`,lineHeight:i,flex:`auto`,transition:`all ${a}`},[c]:{whiteSpace:`nowrap`,[u]:{opacity:0},"@media (hover: none), (pointer: coarse)":{[u]:{opacity:1}},[n]:{color:e.actionsColor,transition:`all ${a}`},[`
${u}:focus-visible,
&.picture ${u}
`]:{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 ${u}`]:{opacity:1},[`${s}-error`]:{color:e.colorError,[`${s}-name, ${t}-icon ${n}`]:{color:e.colorError},[c]:{[`${n}, ${n}:hover`]:{color:e.colorError},[u]:{opacity:1}}},[`${t}-list-item-container`]:{transition:[`opacity`,`height`].map(e=>`${e} ${a}`).join(`, `),"&::before":{display:`table`,width:0,height:0,content:`""`}}}}}},ge=e=>{let{componentCls:t}=e,n=new u(`uploadAnimateInlineIn`,{from:{width:0,height:0,padding:0,opacity:0,margin:e.calc(e.marginXS).div(-2).equal()}}),r=new u(`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`]:A(e)},n,r]},_e=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:`${l(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusLG,"&:hover":{background:`transparent`},[`${s}-thumbnail`]:{...w,width:r,height:r,lineHeight:l(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% - ${l(a(e.paddingSM).mul(2).equal())})`,marginTop:0,paddingInlineStart:a(r).add(e.paddingXS).equal()}},[`${s}-error`]:{borderColor:e.colorError,[`${s}-thumbnail${s}-file ${n}`]:{color:e.colorError}},[`${s}-uploading`]:{borderStyle:`dashed`,[`${s}-name`]:{marginBottom:i}}},[`${o}${o}-picture-circle ${s}`]:{[`&, &::before, ${s}-thumbnail`]:{borderRadius:`50%`}}}}},ve=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
`]:{...g(),display:`block`,[`${t}${t}-select`]:{width:c,height:c,textAlign:`center`,verticalAlign:`top`,backgroundColor:e.colorFillAlter,border:`${l(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% - ${l(a(e.paddingXS).mul(2).equal())})`,height:`calc(100% - ${l(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 ${l(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% - ${l(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% - ${l(a(e.paddingXS).mul(2).equal())})`,paddingInlineStart:0}}},[`${t}-wrapper${t}-picture-circle-wrapper`]:{[`${t}${t}-select`]:{borderRadius:`50%`}}}},ye=e=>{let{componentCls:t}=e;return{[`${t}-rtl`]:{direction:`rtl`}}},be=e=>{let{componentCls:t,colorTextDisabled:n}=e;return{[`${t}-wrapper`]:{...y(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`}}}},xe=E(`Upload`,e=>{let{fontSizeHeading3:t,marginXS:n,lineWidth:r,pictureCardSize:i,calc:a}=e,o=D(e,{uploadThumbnailSize:a(t).mul(2).equal(),uploadProgressOffset:a(a(n).div(2)).add(r).equal(),uploadPicCardSize:i});return[be(o),K(o),_e(o),ve(o),q(o),ge(o),ye(o),M(o)]},e=>({actionsColor:e.colorIcon,pictureCardSize:e.controlHeightLG*2.55}));function J(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 Se(e,t){let n=m(t),r=n.findIndex(({uid:t})=>t===e.uid);return r===-1?n.push(e):n[r]=e,n}function Ce(e,t){let n=e.uid===void 0?`name`:`uid`;return t.filter(t=>t[n]===e[n])[0]}function we(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 Te=(e=``)=>{let t=e.split(`/`),n=t[t.length-1].split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(n)||[``])[0]},Y=e=>e.indexOf(`image/`)===0,Ee=[`.avif`,`.bmp`,`.dpg`,`.gif`,`.heic`,`.heif`,`.ico`,`.jfif`,`.jpg`,`.jpeg`,`.png`,`.svg`,`.tif`,`.tiff`,`.webp`],De=e=>{if(e.type&&!e.thumbUrl)return Y(e.type);let t=e.thumbUrl||e.url||``,n=Te(t||e.name);return/^data:image\//.test(t)||Ee.includes(n?.toLowerCase()||``)?!0:!(/^data:/.test(t)||n)},X=200;function Oe(e){return new Promise(t=>{if(!e.type||!Y(e.type)){t(``);return}if(e.type.startsWith(`image/gif`)){let n=new FileReader;n.onload=()=>{n.result&&t(n.result)},n.readAsDataURL(e);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`,i.onerror=()=>{document.body.removeChild(n),window.URL.revokeObjectURL(i.src),t(``)},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 i.src=window.URL.createObjectURL(e)})}var ke=F.forwardRef(({prefixCls:e,className:t,style:r,classNames:i,styles:s,locale:c,listType:l,file:u,items:d,progress:f,iconRender:p,actionIconRender:m,itemRender:g,isImgUrl:_,showPreviewIcon:v,showRemoveIcon:y,showDownloadIcon:b,previewIcon:x,removeIcon:S,downloadIcon:C,extra:w,onPreview:T,hasPreview:ee,onDownload:te,onClose:E},re)=>{let{status:D}=u,[k,A]=F.useState(D);F.useEffect(()=>{D!==`removed`&&A(D)},[D]);let[ae,j]=O(!1);F.useEffect(()=>{j(!0,{ms:300})},[]);let M=p(u),N=F.createElement(`div`,{className:`${e}-icon`},M);if(l===`picture`||l===`picture-card`||l===`picture-circle`){if(k===`uploading`||!u.thumbUrl&&!u.url){let t=h(`${e}-list-item-thumbnail`,{[`${e}-list-item-file`]:k!==`uploading`});N=F.createElement(`div`,{className:t},M)}else{let t=_?.(u)?F.createElement(`img`,{src:u.thumbUrl||u.url,alt:u.name,className:`${e}-list-item-image`,crossOrigin:u.crossOrigin}):M,n=h(`${e}-list-item-thumbnail`,{[`${e}-list-item-file`]:_&&!_(u)});N=F.createElement(`a`,{className:n,onClick:e=>T(u,e),href:u.url||u.thumbUrl,target:`_blank`,rel:`noopener noreferrer`},t)}}let le=h(`${e}-list-item`,`${e}-list-item-${k}`,i?.item),ue=typeof u.linkProps==`string`?JSON.parse(u.linkProps):u.linkProps,de=(a(y)?y(u):y)?m((a(S)?S(u):S)||F.createElement(P,null),()=>E(u),e,c.removeFile,!0):null,I=(a(b)?b(u):b)&&k===`done`?m((a(C)?C(u):C)||F.createElement(ce,null),()=>te(u),e,c.downloadFile):null,fe=l!==`picture-card`&&l!==`picture-circle`&&F.createElement(`span`,{key:`download-delete`,className:h(`${e}-list-item-actions`,{picture:l===`picture`})},I,de),L=a(w)?w(u):w,R=ne(L)&&F.createElement(`span`,{className:`${e}-list-item-extra`},L),z=h(`${e}-list-item-name`),B=ee?{role:`button`,tabIndex:0,onClick:e=>T(u,e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(u,e))}}:{},V=u.url?F.createElement(`a`,{key:`view`,target:`_blank`,rel:`noopener noreferrer`,className:z,title:u.name,...ue,href:u.url,onClick:e=>{ue?.onClick?.(e),e.defaultPrevented||T(u,e)}},u.name,R):F.createElement(`span`,{key:`view`,className:z,...B,title:u.name},u.name,R),pe=(a(v)?v(u):v)&&(u.url||u.thumbUrl)?F.createElement(`a`,{href:u.url||u.thumbUrl,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>T(u,e),title:c.previewFile,"aria-label":c.previewFile||void 0},a(x)?x(u):x||F.createElement(oe,null)):null,H=(l===`picture-card`||l===`picture-circle`)&&k!==`uploading`&&F.createElement(`span`,{className:`${e}-list-item-actions`},pe,k===`done`&&I,de),{getPrefixCls:U}=F.useContext(n),me=U(),W=F.createElement(`div`,{className:le,style:s?.item},N,V,fe,H,ae&&F.createElement(o,{motionName:`${me}-fade`,visible:k===`uploading`,motionDeadline:2e3},({className:t})=>{let n=`percent`in u?F.createElement(se,{type:`line`,percent:u.percent,"aria-label":u[`aria-label`],"aria-labelledby":u[`aria-labelledby`],...f}):null;return F.createElement(`div`,{className:h(`${e}-list-item-progress`,t)},n)})),G=u.response&&typeof u.response==`string`?u.response:u.error?.statusText||u.error?.message||c.uploadError,he=k===`error`?F.createElement(ie,{title:G,getPopupContainer:e=>e.parentNode},W):W;return F.createElement(`div`,{className:h(`${e}-list-item-container`,t),style:r,ref:re},g?g(he,u,d,{download:te.bind(null,u),preview:T.bind(null,u),remove:E.bind(null,u)}):he)}),Ae=F.forwardRef((e,r)=>{let{listType:i=`text`,previewFile:s=Oe,onPreview:l,onDownload:u,onRemove:d,locale:f,iconRender:p,isImageUrl:g=De,prefixCls:_,items:v=[],showPreviewIcon:y=!0,showRemoveIcon:x=!0,showDownloadIcon:S=!1,removeIcon:C,previewIcon:w,downloadIcon:T,extra:te,progress:E={size:[-1,2],showInfo:!1},appendAction:ne,appendActionVisible:D=!0,itemRender:O,disabled:k,classNames:A,styles:ie}=e,[,ae]=j(),[M,oe]=F.useState(!1),se=[`picture-card`,`picture-circle`].includes(i);F.useEffect(()=>{i.startsWith(`picture`)&&(v||[]).forEach(e=>{(e.originFileObj instanceof File||e.originFileObj instanceof Blob)&&e.thumbUrl===void 0&&(e.thumbUrl=``,s?.(e.originFileObj).then(t=>{e.thumbUrl=t||``,ae()}))})},[i,v,s]),F.useEffect(()=>{oe(!0)},[]);let ce=(e,t)=>{if(l)return t?.preventDefault(),l(e)},P=e=>{a(u)?u(e):e.url&&window.open(e.url,`_blank`,`noopener`)},I=e=>{d?.(e)},fe=e=>{if(p)return p(e,i);let t=e.status===`uploading`;if(i.startsWith(`picture`)){let n=i===`picture`?F.createElement(ee,null):f.uploading,r=g?.(e)?F.createElement(le,null):F.createElement(de,null);return t?n:r}return t?F.createElement(ee,null):F.createElement(ue,null)},L=(e,t,n,r,i)=>{let a={type:`text`,size:`small`,title:r,"aria-label":r||void 0,onClick:n=>{t(),F.isValidElement(e)&&e.props.onClick?.(n)},className:`${n}-list-item-action`,disabled:i?k:!1};return F.isValidElement(e)?F.createElement(N,{...a,icon:re(e,{...e.props,onClick:()=>{}})}):F.createElement(N,{...a},F.createElement(`span`,null,e))};F.useImperativeHandle(r,()=>({handlePreview:ce,handleDownload:P}));let{getPrefixCls:R}=F.useContext(n),z=R(`upload`,_),B=R(),V=h(`${z}-list`,`${z}-list-${i}`,A?.list),pe=F.useMemo(()=>t(b(B),[`onAppearEnd`,`onEnterEnd`,`onLeaveEnd`]),[B]),H={...se?{}:pe,motionDeadline:2e3,motionName:`${z}-${se?`animate-inline`:`animate`}`,keys:m(v.map(e=>({key:e.uid,file:e}))),motionAppear:M};return F.createElement(`div`,{className:V,style:ie?.list},F.createElement(c,{...H,component:!1},({key:e,file:t,className:n,style:r})=>F.createElement(ke,{key:e,locale:f,prefixCls:z,className:n,style:r,classNames:A,styles:ie,file:t,items:v,progress:E,listType:i,isImgUrl:g,showPreviewIcon:y,showRemoveIcon:x,showDownloadIcon:S,removeIcon:C,previewIcon:w,downloadIcon:T,extra:te,iconRender:fe,actionIconRender:L,itemRender:O,onPreview:ce,hasPreview:!!l,onDownload:P,onClose:I})),ne&&F.createElement(o,{...H,visible:D,forceRender:!0},({className:e,style:t})=>re(ne,n=>({className:h(n.className,e),style:{...t,pointerEvents:e?`none`:void 0,...n.style}}))))}),Z=`__LIST_IGNORE_${Date.now()}__`,je=F.forwardRef((e,t)=>{let n=s(`upload`),{fileList:o,defaultFileList:c,onRemove:l,showUploadList:u=!0,listType:d=`text`,onPreview:f,onDownload:p,onChange:g,onDrop:_,previewFile:y,disabled:b,locale:w,iconRender:T,isImageUrl:ee,progress:E,prefixCls:ne,className:re,type:D=`select`,children:O,style:A,itemRender:ie,maxCount:j,data:M={},multiple:N=!1,hasControlInside:oe=!0,action:se=``,accept:ce,supportServerRender:P=!0,rootClassName:le,styles:ue,classNames:de}=e,fe=F.useContext(v),L=b??fe,R=e.customRequest||n.customRequest,z=n.progress||E?{...n.progress,...E}:void 0,B=ae(ce,n.accept,``),[V,pe]=i(c,o),H=V||[],U=S(()=>H),[me,W]=F.useState(`drop`),G=F.useRef(null),K=F.useRef(null);F.useMemo(()=>{let e=Date.now();(o||[]).forEach((t,n)=>{!t.uid&&!Object.isFrozen(t)&&(t.uid=`__AUTO__${e}_${n}__`)})},[o]);let q=(e,t,n)=>{let r=m(t),i=!1;j===1?r=r.slice(-1):j&&(i=r.length>j,r=r.slice(0,j)),(0,I.flushSync)(()=>{pe(r)});let a={file:e,fileList:r};n&&(a.event=n),(!i||e.status===`removed`||r.some(t=>t.uid===e.uid))&&(0,I.flushSync)(()=>{g?.(a)})},ge=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;C(e)&&(i=e)}return i},_e=e=>{let t=e.filter(e=>!e.file[Z]);if(!t.length)return;let n=t.map(e=>J(e.file)),r=m(H);n.forEach(e=>{r=Se(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}q(i,r)})},ve=(e,t,n)=>{try{typeof e==`string`&&(e=JSON.parse(e))}catch{}if(!Ce(t,H))return;let r=J(t);r.status=`done`,r.percent=100,r.response=e,r.xhr=n;let i=Se(r,H);q(r,i)},ye=(e,t)=>{if(!Ce(t,H))return;let n=J(t);n.status=`uploading`,n.percent=e.percent;let r=Se(n,H);q(n,r,e)},be=(e,t,n)=>{if(!Ce(n,H))return;let r=J(n);r.error=e,r.response=t,r.status=`error`;let i=Se(r,H);q(r,i)},Te=e=>{let t;Promise.resolve(a(l)?l(e):l).then(n=>{if(n===!1)return;let r=U(),i=we(e,r);i&&(t={...e,status:`removed`},r.forEach(e=>{let n=t.uid===void 0?`name`:`uid`;e[n]===t[n]&&!Object.isFrozen(e)&&(e.status=`removed`)}),G.current?.abort(t),q(t,i))})},Y=e=>{W(e.type),e.type===`drop`&&_?.(e)};F.useImperativeHandle(t,()=>({onBatchStart:_e,onSuccess:ve,onProgress:ye,onError:be,fileList:H,upload:G.current,nativeElement:K.current}));let{getPrefixCls:Ee,direction:De,className:X,style:Oe,classNames:ke,styles:je}=s(`upload`),Q=Ee(`upload`,ne),Me={...e,listType:d,showUploadList:u,type:D,multiple:N,hasControlInside:oe,supportServerRender:P,disabled:L},Ne=k(Oe,`trigger`),Pe=k(A,`trigger`),[Fe,Ie]=r([ke,de],[je,Ne,ue,Pe],{props:Me}),$={onBatchStart:_e,onError:be,onProgress:ye,onSuccess:ve,...e,customRequest:R,data:M,multiple:N,action:se,accept:B,supportServerRender:P,prefixCls:Q,disabled:L,beforeUpload:ge,onChange:void 0,hasControlInside:oe};delete $.className,delete $.style,(!O||L)&&delete $.id;let Le=`${Q}-wrapper`,[Re,ze]=xe(Q,Le),[Be]=te(`Upload`,x.Upload),{showRemoveIcon:Ve,showPreviewIcon:He,showDownloadIcon:Ue,removeIcon:We,previewIcon:Ge,downloadIcon:Ke,extra:qe}=typeof u==`boolean`?{}:u,Je=Ve===void 0?!L:Ve,Ye=(e,t)=>u?F.createElement(Ae,{classNames:Fe,styles:Ie,prefixCls:Q,listType:d,items:H,previewFile:y,onPreview:f,onDownload:p,onRemove:Te,showRemoveIcon:Je,showPreviewIcon:He,showDownloadIcon:Ue,removeIcon:We,previewIcon:Ge,downloadIcon:Ke,iconRender:T,extra:qe,locale:{...Be,...w},isImageUrl:ee,progress:z,appendAction:e,appendActionVisible:t,itemRender:ie,disabled:L}):e,Xe=h(Le,re,le,Re,ze,X,Fe.root,{[`${Q}-rtl`]:De===`rtl`,[`${Q}-picture-card-wrapper`]:d===`picture-card`,[`${Q}-picture-circle-wrapper`]:d===`picture-circle`}),Ze={...Ie.root};if(D===`drag`){let e=h(Re,Q,`${Q}-drag`,{[`${Q}-drag-uploading`]:H.some(e=>e.status===`uploading`),[`${Q}-drag-hover`]:me===`dragover`,[`${Q}-disabled`]:L,[`${Q}-rtl`]:De===`rtl`},Fe.trigger);return F.createElement(`span`,{className:Xe,ref:K,style:Ze},F.createElement(`div`,{className:e,style:Ie.trigger,onDrop:Y,onDragOver:Y,onDragLeave:Y},F.createElement(he,{...$,ref:G,className:`${Q}-btn`},F.createElement(`div`,{className:`${Q}-drag-container`},O))),Ye())}let Qe=h(Q,`${Q}-select`,{[`${Q}-disabled`]:L,[`${Q}-hidden`]:!O},Fe.trigger),$e=F.createElement(`div`,{className:Qe,style:Ie.trigger},F.createElement(he,{...$,ref:G}));return d===`picture-card`||d===`picture-circle`?F.createElement(`span`,{className:Xe,ref:K,style:Ze},Ye($e,!!O)):F.createElement(`span`,{className:Xe,ref:K,style:Ze},$e,Ye())}),Q=F.forwardRef((e,t)=>{let{style:n,height:r,hasControlInside:i=!1,children:a,...o}=e,s={...n,...T(r)&&{height:r}};return F.createElement(je,{ref:t,hasControlInside:i,...o,style:s,type:`drag`},a)}),Me=je;Me.Dragger=Q,Me.LIST_IGNORE=Z;export{Me as t};