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