const e=require("../../_util/props-util/initDefaultProps.js"),t=require("../../_util/props-util/index.js"),n=require("../../config-provider/hooks/useConfigInject.js"),r=require("../../_util/transition.js"),i=require("../../_util/collapseMotion.js"),a=require("../../button/index.js"),o=require("../interface.js"),s=require("../utils.js"),c=require("./ListItem.js");let l=require("vue"),u=require("@antsoo-lib/icons");var d=(e,{slots:n})=>t.filterEmpty(n.default?.())[0],f=(0,l.defineComponent)({compatConfig:{MODE:3},name:`AUploadList`,props:e.default(o.uploadListProps(),{listType:`text`,progress:{strokeWidth:2,showInfo:!1},showRemoveIcon:!0,showDownloadIcon:!1,showPreviewIcon:!0,previewFile:s.previewImage,isImageUrl:s.isImageUrl,items:[],appendActionVisible:!0}),setup(e,{slots:o,expose:s}){let f=(0,l.shallowRef)(!1);(0,l.onMounted)(()=>{f.value});let p=(0,l.shallowRef)([]);(0,l.watch)(()=>e.items,(e=[])=>{p.value=e.slice()},{immediate:!0,deep:!0}),(0,l.watchEffect)(()=>{if(e.listType!==`picture`&&e.listType!==`picture-card`)return;let t=!1;(e.items||[]).forEach((n,r)=>{typeof document>`u`||typeof window>`u`||!window.FileReader||!window.File||!(n.originFileObj instanceof File||n.originFileObj instanceof Blob)||n.thumbUrl!==void 0||(n.thumbUrl=``,e.previewFile&&e.previewFile(n.originFileObj).then(e=>{let i=e||``;i!==n.thumbUrl&&(p.value[r].thumbUrl=i,t=!0)}))}),t&&(0,l.triggerRef)(p)});let m=(t,n)=>{if(e.onPreview)return n?.preventDefault(),e.onPreview(t)},h=t=>{typeof e.onDownload==`function`?e.onDownload(t):t.url&&window.open(t.url)},g=t=>{e.onRemove?.(t)},_=({file:t})=>{let n=e.iconRender||o.iconRender;if(n)return n({file:t,listType:e.listType});let r=t.status===`uploading`,i=e.isImageUrl&&e.isImageUrl(t)?(0,l.createVNode)(u.PictureTwoTone,null,null):(0,l.createVNode)(u.FileTwoTone,null,null),a=r?(0,l.createVNode)(u.LoadingOutlined,null,null):(0,l.createVNode)(u.PaperClipOutlined,null,null);return e.listType===`picture`?a=r?(0,l.createVNode)(u.LoadingOutlined,null,null):i:e.listType===`picture-card`&&(a=r?e.locale.uploading:i),a},v=n=>{let{customIcon:r,callback:i,prefixCls:o,title:s}=n,c={type:`text`,size:`small`,title:s,onClick:e=>{i();try{e?.currentTarget?.blur?.()}catch{}},class:`${o}-list-item-action`};return s===e.locale?.downloadFile&&(c.disabled=!1),t.isValidElement(r)?(0,l.createVNode)(a.default,c,{icon:()=>r}):(0,l.createVNode)(a.default,c,{default:()=>[(0,l.createVNode)(`span`,null,[r])]})};s({handlePreview:m,handleDownload:h});let{prefixCls:y,rootPrefixCls:b}=n.default(`upload`,e),x=(0,l.computed)(()=>({[`${y.value}-list`]:!0,[`${y.value}-list-${e.listType}`]:!0})),S=(0,l.computed)(()=>{let t={...i.default(`${b.value}-motion-collapse`)};delete t.onAfterAppear,delete t.onAfterEnter,delete t.onAfterLeave;let n={...r.getTransitionGroupProps(`${y.value}-${e.listType===`picture-card`?`animate-inline`:`animate`}`),class:x.value,appear:f.value};return e.listType===`picture-card`?n:{...t,...n}});return()=>{let{listType:t,locale:n,isImageUrl:r,showPreviewIcon:i,showRemoveIcon:a,showDownloadIcon:s,removeIcon:u,previewIcon:f,downloadIcon:b,progress:x,appendAction:C,itemRender:w,appendActionVisible:T}=e,E=C?.(),D=p.value;return(0,l.createVNode)(l.TransitionGroup,{...S.value,tag:`div`},{default:()=>[D.map(e=>{let{uid:d}=e;return(0,l.createVNode)(c.default,{key:d,locale:n,prefixCls:y.value,file:e,items:D,progress:x,listType:t,isImgUrl:r,showPreviewIcon:i,showRemoveIcon:a,showDownloadIcon:s,onPreview:m,onDownload:h,onClose:g,removeIcon:u,previewIcon:f,downloadIcon:b,itemRender:w},{...o,iconRender:_,actionIconRender:v})}),C?(0,l.withDirectives)((0,l.createVNode)(d,{key:`__ant_upload_appendAction`},{default:()=>E}),[[l.vShow,!!T]]):null]})}}});exports.default=f;