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