import{_ as g,d as v,aT as y,R as h,f as r,Y as k,r as p,o,i as d,w as D,c as f,j as c,t as R,b8 as $,bz as q}from"./app-DyK1k-lL.js";const w=v({props:{formData:null,folder:String,imageField:{default:"image",type:String},url:{default:"upload-file",type:String}},components:{LoadingOutlined:y,PlusOutlined:h},setup(e,{emit:s}){const n=r([]),t=r(!1),{t:u}=k();return{fileList:n,loading:t,customRequest:i=>{const a=new FormData;a.append("image",i.file),a.append("folder",e.folder),t.value=!0,axiosAdmin.post(e.url,a,{headers:{"Content-Type":"multipart/form-data"}}).then(l=>{n.value=[],t.value=!1,s("onFileUploaded",{file:l.data.file,file_url:l.data.file_url})}).catch(()=>{t.value=!1,$.error(u("messages.uploading_failed"))})}}}}),F={key:0},L=["src"],B={key:1},C={class:"ant-upload-text"};function S(e,s,n,t,u,m){const i=p("loading-outlined"),a=p("plus-outlined"),l=q;return o(),d(l,{accept:"image/*","file-list":e.fileList,"onUpdate:fileList":s[0]||(s[0]=_=>e.fileList=_),name:"image","list-type":"picture-card",class:"avatar-uploader","show-upload-list":!1,customRequest:e.customRequest},{default:D(()=>[e.formData[e.imageField]!=null?(o(),f("div",F,[c("img",{style:{width:"128px"},src:e.formData[`${e.imageField}_url`],alt:"avatar"},null,8,L)])):(o(),f("div",B,[e.loading?(o(),d(i,{key:0})):(o(),d(a,{key:1})),c("div",C,R(e.$t("common.upload")),1)]))]),_:1},8,["file-list","customRequest"])}const b=g(w,[["render",S]]);export{b as U};
