var b=(a,p,s)=>new Promise((t,d)=>{var l=o=>{try{r(s.next(o))}catch(f){d(f)}},i=o=>{try{r(s.throw(o))}catch(f){d(f)}},r=o=>o.done?t(o.value):Promise.resolve(o.value).then(l,i);r((s=s.apply(a,p)).next())});import{I as g}from"./index-D4Ne4xf-.js";import{f as V,d as L}from"./upload-Dh64kBvI.js";import{u as E,c as F}from"./index-CwU__2FH.js";import{ab as M,T as S,b as k}from"./element-plus-DNKe9-lk.js";import{l as U,r as v,m as u,M as y,O as I,q as w,u as n,R as m,p as h,U as x}from"./vue-chunks-DyZSmvoe.js";const N={class:"rounded-2xl border border-green-500/50 border-dashed w-20 h-20 flex items-center justify-center"},R={key:1,class:"relative rounded-2xl w-full h-full"},O=["src"],_={class:"absolute w-full h-full hover:bg-black hover:bg-opacity-40 flex items-center justify-center"},q={key:2,class:"flex items-center justify-center"},J=U({__name:"index",props:{accept:{type:String,default:"image/png, image/jpeg"},action:{type:String,default:V},showFileList:{type:Boolean,default:!1},modelValue:{type:String,default:""},formModel:{type:Object,default:()=>({})},onchange:{type:Function,default:()=>{}},isType:{type:Boolean,default:!0}},emits:["update:modelValue"],setup(a,{emit:p}){E();const s=p,t=v("start"),d=["image/jpeg","image/png","image/gif","image/webp","image/bmp","image/tiff","image/svg+xml"],l=v(0),i=a,r=v(i.isType?"image/jpeg":i.formModel.fileType),o=e=>/[\u4e00-\u9fa5]/.test(e.name)?(k.error("文件名称不呢带中文呢!"),!1):(r.value=e.type,t.value="pending",!0),f=e=>{var c;t.value="start",s("update:modelValue",""),k.error((c=e==null?void 0:e.data)==null?void 0:c.message)},C=()=>{F({urlList:[i.modelValue]})},T=e=>{l.value=100;const{data:c}=e;s("update:modelValue",c.key),i.onchange({value:c.key,fileType:n(r)}),t.value="start",l.value=0},j=e=>{l.value=e.percent/2},B=()=>b(this,null,function*(){try{t.value="pending",l.value<92&&(l.value=l.value+8),i.onchange({value:"",fileType:""}),yield L({key:i.modelValue}),t.value="start",s("update:modelValue","")}catch(e){}});return(e,c)=>(u(),y(n(S),{action:n(V),accept:a.accept,onError:f,onSuccess:T,beforeUpload:o,withCredentials:!0,showFileList:a.showFileList,"on-progress":j,disabled:!!a.modelValue},{default:I(()=>[w("div",N,[!a.modelValue&&t.value=="start"?(u(),y(n(g),{key:0,icon:"ant-design:cloud-upload-outlined"})):m("",!0),a.modelValue&&t.value=="start"?(u(),h("div",R,[d.includes(r.value)?(u(),h("img",{key:0,src:a.modelValue,class:"absolute w-full h-full"},null,8,O)):m("",!0),w("div",_,[d.includes(r.value)?(u(),y(n(g),{key:0,color:"#409eff",onClick:C,hoverColor:"#fff",icon:"ant-design:search-outlined",class:"mr-2"})):m("",!0),x(n(g),{onClick:B,color:"#409eff",hoverColor:"#fff",icon:"ep:delete"})])])):m("",!0),t.value!="start"?(u(),h("div",q,[x(n(M),{width:78,type:"circle","striped-flow":!0,percentage:l.value},null,8,["percentage"])])):m("",!0)])]),_:1},8,["action","accept","showFileList","disabled"]))}});export{J as _};
