import{c as l,I as w,_ as U,x as $,bB as S,aq as k,r as O,b as q,e as f,o as v,g as h,w as r,i as c,t as p,aF as B,B as L,aG as V,ac as C,aI as P}from"./app-DGDivIsO.js";var R={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"};function b(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(o);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(i){return Object.getOwnPropertyDescriptor(o,i).enumerable}))),n.forEach(function(i){j(e,i,o[i])})}return e}function j(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var m=function(t,o){var n=b({},t,o.attrs);return l(w,b({},n,{icon:R}),null)};m.displayName="UploadOutlined";m.inheritAttrs=!1;const I=$({props:{acceptFormat:{default:"image/*,.pdf",type:String},formData:null,folder:String,uploadField:{default:"file",type:String}},components:{UploadOutlined:m,DownloadOutlined:S,DeleteOutlined:k},setup(e,{emit:t}){const o=O([]),n=O(!1),{t:i}=q();return{fileList:o,loading:n,customRequest:u=>{const d=new FormData;d.append("file",u.file),d.append("folder",e.folder),n.value=!0,axiosAdmin.post("upload-file",d,{headers:{"Content-Type":"multipart/form-data"}}).then(a=>{o.value=[],n.value=!1,t("onFileUploaded",{file:a.data.file,file_url:a.data.file_url})}).catch(a=>{n.value=!1;var s=i("messages.uploading_failed");a.status==422&&(a.data&&a.data.error&&a.data.error.details&&a.data.error.details.file[0]||a.data&&a.data.error&&a.data.error.details&&a.data.error.details.image[0])&&(s=a.data.error.details.file[0]),B.error(s)})}}}}),M={key:0},N={key:1};function T(e,t,o,n,i,D){const u=f("UploadOutlined"),d=L,a=V,s=f("DownloadOutlined"),_=C,g=P,y=f("DeleteOutlined");return e.formData[e.uploadField]==null?(v(),h("div",M,[l(a,{accept:e.acceptFormat,"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=F=>e.fileList=F),name:"file",customRequest:e.customRequest},{default:r(()=>[l(d,{loading:e.loading},{icon:r(()=>[l(u)]),default:r(()=>[c(" "+p(e.$t("common.upload")),1)]),_:1},8,["loading"])]),_:1},8,["accept","file-list","customRequest"])])):(v(),h("div",N,[l(g,{href:e.formData[`${e.uploadField}_url`],target:"_blank"},{default:r(()=>[l(_,{color:"success"},{icon:r(()=>[l(s)]),default:r(()=>[c(" "+p(e.$t("common.download")),1)]),_:1})]),_:1},8,["href"]),l(g,{onClick:t[1]||(t[1]=()=>{e.formData[e.uploadField]=void 0,e.formData[`${e.uploadField}_url`]=void 0})},{default:r(()=>[l(_,{color:"error"},{icon:r(()=>[l(y)]),default:r(()=>[c(" "+p(e.$t("common.delete")),1)]),_:1})]),_:1})]))}const A=U(I,[["render",T]]);export{A as U,m as a};
