function e(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 t(e,t){let n=[...t],r=n.findIndex(({uid:t})=>t===e.uid);return r===-1?n.push(e):n[r]=e,n}function n(e,t){let n=e.uid===void 0?`name`:`uid`;return t.filter(t=>t[n]===e[n])[0]}function r(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 i=(e=``)=>{let t=e.split(`/`),n=t[t.length-1].split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(n)||[``])[0]},a=e=>e.indexOf(`image/`)===0,o=e=>{if(e.type&&!e.thumbUrl)return a(e.type);let t=e.thumbUrl||e.url||``,n=i(t);return/^data:image\//.test(t)||/(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico)$/i.test(n)?!0:!(t.startsWith(`data:`)||n)},s=200;function c(e){return new Promise(t=>{if(!e.type||!a(e.type)){t(``);return}let n=document.createElement(`canvas`);n.width=s,n.height=s,n.style.cssText=`position: fixed; left: 0; top: 0; width: ${s}px; height: ${s}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=s,c=s,l=0,u=0;e>a?(c=s/e*a,u=-(c-o)/2):(o=s/a*e,l=-(o-c)/2),r.drawImage(i,l,u,o,c);let d=n.toDataURL();document.body.removeChild(n),t(d)},i.crossOrigin=`anonymous`,e.type.startsWith(`image/svg+xml`)){let t=new FileReader;t.addEventListener(`load`,()=>{t.result&&(i.src=t.result)}),t.readAsDataURL(e)}else i.src=window.URL.createObjectURL(e)})}export{e as file2Obj,n as getFileItem,o as isImageUrl,c as previewImage,r as removeFileItem,t as updateFileList};