import{_ as g,Y as d,b as r,o as u,c,a as s,z as m,t as p,d as f,n as h}from"./app-583c7dce.js";const _={name:"ImageUploader",props:{data:{},value:{}},watch:{value:{handler:"initComponent",immediate:!0}},methods:{changed(){this.$emit("getFile",this.fieldValue)},initComponent(){typeof this.value=="string"&&(this.value?(this.imageUrl=this.value,this.getDataUrl(this.value).then(t=>this.fieldValue=t)):(this.imageUrl="",this.fieldValue="")),this.value||(this.imageUrl="",this.fieldValue="")},getDataUrl(t){let l=d.splitNameBySlas(t),i=this.data.generateFileUrl?d.getAppUrl(t.split("/").filter(e=>e).join("/")):t;return new Promise((e,o)=>{fetch(i).then(a=>a.blob()).then(a=>this.blobToFile(a,l)).then(a=>{a.url=URL.createObjectURL(a),e(a)})})},blobToFile(t,l){const i=new Date,e=i.getTime();return t.name=l,t.lastModified=e,t.lastModifiedDate=i,t.webkitRelativePath="",t}},setup(t,{emit:l}){const i=r(0),e=r(null),o=r(null);return{imageUrl:e,getFile:n=>{o.value=n.target.files[0],e.value=URL.createObjectURL(o.value),l("getFile",o.value)},uploadProgress:i}}},v={class:"uploading flex-column justify-content-center align-items-center overflow-hidden"},U={class:"position-absolute top-50 left-50 translate-middle fw-semibold text-white"},b={class:"image-area rounded d-flex"},y=["src"],F={class:"input-area"};function w(t,l,i,e,o,a){return u(),c("div",{class:h(["image-uploader-wrapper position-relative",{"is-uploading":e.uploadProgress>0&&e.uploadProgress<100}])},[s("div",v,[s("span",{class:"h-100 upload-percentage position-absolute top-0 left-0",style:m({width:`${e.uploadProgress}%`})},null,4),s("span",U,p(e.uploadProgress)+"%",1)]),s("div",b,[e.imageUrl?(u(),c("img",{key:0,src:e.imageUrl,class:"img-fluid rounded mx-auto my-auto h-100"},null,8,y)):f("",!0)]),s("div",F,[s("label",{id:"upload-label",onClick:l[0]||(l[0]=n=>t.$refs.file.click())},p(i.data.label||t.$t("choice_your_file")),1),s("input",{ref:"file",type:"file",class:"form-control d-none",onChange:l[1]||(l[1]=(...n)=>e.getFile&&e.getFile(...n))},null,544)])],2)}const P=g(_,[["render",w]]);export{P as I};
