import{defineComponent as Z,shallowRef as f,onMounted as ee,onBeforeUnmount as oe,watch as ne,computed as te,createVNode as n,Transition as le,withDirectives as re,vShow as ie}from"vue";import se from"@ant-design/icons-vue/DeleteOutlined";import ae from"@ant-design/icons-vue/DownloadOutlined";import ce from"@ant-design/icons-vue/EyeOutlined";import{getTransitionProps as ue}from"../../_util/transition.mjs";import{objectType as v,functionType as l,booleanType as w,stringType as me,arrayType as pe}from"../../_util/type.mjs";import de from"../../config-provider/hooks/useConfigInject.mjs";import fe from"../../progress/index.mjs";import ve from"../../tooltip/index.mjs";const we=()=>({prefixCls:String,locale:v(void 0),file:v(),items:pe(),listType:me(),isImgUrl:l(),showRemoveIcon:w(),showDownloadIcon:w(),showPreviewIcon:w(),removeIcon:l(),downloadIcon:l(),previewIcon:l(),iconRender:l(),actionIconRender:l(),itemRender:l(),onPreview:l(),onClose:l(),onDownload:l(),progress:v()}),Re=Z({compatConfig:{MODE:3},name:"ListItem",inheritAttrs:!1,props:we(),setup(c,{slots:i,attrs:S}){const g=f(!1),I=f();ee(()=>{I.value=setTimeout(()=>{g.value=!0},300)}),oe(()=>{clearTimeout(I.value)});const r=f(c.file?.status);ne(()=>c.file?.status,o=>{o!=="removed"&&(r.value=o)});const{rootPrefixCls:E}=de("upload",c),F=te(()=>ue(`${E.value}-fade`));return()=>{const{prefixCls:o,locale:u,listType:s,file:e,items:L,progress:_,iconRender:j=i.iconRender,actionIconRender:h=i.actionIconRender,itemRender:y=i.itemRender,isImgUrl:m,showPreviewIcon:A,showRemoveIcon:M,showDownloadIcon:B,previewIcon:C=i.previewIcon,removeIcon:b=i.removeIcon,downloadIcon:P=i.downloadIcon,onPreview:a,onDownload:k,onClose:$}=c,{class:R,style:J}=S,p=j({file:e});let d=n("div",{class:`${o}-text-icon`},[p]);if(s==="picture"||s==="picture-card")if(r.value==="uploading"||!e.thumbUrl&&!e.url){const t={[`${o}-list-item-thumbnail`]:!0,[`${o}-list-item-file`]:r.value!=="uploading"};d=n("div",{class:t},[p])}else{const t=m?.(e)?n("img",{src:e.thumbUrl||e.url,alt:e.name,class:`${o}-list-item-image`,crossorigin:e.crossOrigin},null):p,X={[`${o}-list-item-thumbnail`]:!0,[`${o}-list-item-file`]:m&&!m(e)};d=n("a",{class:X,onClick:Y=>a(e,Y),href:e.url||e.thumbUrl,target:"_blank",rel:"noopener noreferrer"},[t])}const V={[`${o}-list-item`]:!0,[`${o}-list-item-${r.value}`]:!0},q=typeof e.linkProps=="string"?JSON.parse(e.linkProps):e.linkProps,T=M?h({customIcon:b?b({file:e}):n(se,null,null),callback:()=>$(e),prefixCls:o,title:u.removeFile}):null,N=B&&r.value==="done"?h({customIcon:P?P({file:e}):n(ae,null,null),callback:()=>k(e),prefixCls:o,title:u.downloadFile}):null,D=s!=="picture-card"&&n("span",{key:"download-delete",class:[`${o}-list-item-actions`,{picture:s==="picture"}]},[N,T]),U=`${o}-list-item-name`,z=e.url?[n("a",{key:"view",target:"_blank",rel:"noopener noreferrer",class:U,title:e.name,...q,href:e.url,onClick:t=>a(e,t)},[e.name]),D]:[n("span",{key:"view",class:U,onClick:t=>a(e,t),title:e.name},[e.name]),D],G={pointerEvents:"none",opacity:.5},H=A?n("a",{href:e.url||e.thumbUrl,target:"_blank",rel:"noopener noreferrer",style:e.url||e.thumbUrl?void 0:G,onClick:t=>a(e,t),title:u.previewFile},[C?C({file:e}):n(ce,null,null)]):null,K=s==="picture-card"&&r.value!=="uploading"&&n("span",{class:`${o}-list-item-actions`},[H,r.value==="done"&&N,T]),O=n("div",{class:V},[d,z,K,g.value&&n(le,F.value,{default:()=>[re(n("div",{class:`${o}-list-item-progress`},["percent"in e?n(fe,{..._,type:"line",percent:e.percent},null):null]),[[ie,r.value==="uploading"]])]})]),Q={[`${o}-list-item-container`]:!0,[`${R}`]:!!R},W=e.response&&typeof e.response=="string"?e.response:e.error?.statusText||e.error?.message||u.uploadError,x=r.value==="error"?n(ve,{title:W,getPopupContainer:t=>t.parentNode},{default:()=>[O]}):O;return n("div",{class:Q,style:J},[y?y({originNode:x,file:e,fileList:L,actions:{download:k.bind(null,e),preview:a.bind(null,e),remove:$.bind(null,e)}}):x])}}});export{Re as default,we as listItemProps};
