import{F as g}from"./BushelAlert-BByTFixJ.js";import{o as y,_ as v,q as l,K as p,D as f,t as a,L as u,M as c,v as b,N as x,J as m,x as U,y as k,G as _,H as s}from"./BButtonGroup-Di2rf30B.js";const S={components:{FileUpload:g},props:{extensions:{type:String,default:"gif,jpg,jpeg,png,pdf"},accept:{type:String,default:"image/png,image/gif,image/jpeg,application/pdf"},disabled:{type:Boolean,default:!1},allowDelete:{type:Boolean,default:!1},inputId:{type:String,default:"avatar"},fileUrl:{type:[String,Object]},resetImage:{type:Boolean,required:!1,default:!1},noOverlay:{type:Boolean,default:!1},docLabel:{type:String,required:!1},downloadPath:{type:String,required:!1}},emits:["createDocument","deleteDocument"],data(){return{tempName:null,files:[],edit:!1,cropper:!1}},computed:{isAString(){return!!(this.fileUrl&&(typeof this.fileUrl=="string"||this.fileUrl instanceof String))},displayName(){if(this.isAString){const t=this.fileUrl.lastIndexOf("/"),e=this.fileUrl.indexOf("-",t);return this.fileUrl.substring(e+1)}return this.fileUrl&&this.fileUrl.name?this.fileUrl.name:""}},methods:{...y({setSnackbar:"ui/setSnackbar"}),createFile(t,e){const i=new FileReader;i.readAsDataURL(t),i.onload=function(){e(i.result)},i.onerror=function(o){}},inputFile(t,e,i){t&&!e&&this.$nextTick(function(){this.tempName=null,this.addingLabel=!0,this.save()})},inputFilter(t,e,i){if(t&&!e&&!/\.(gif|jpg|jpeg|png|webp|pdf)$/i.test(t.name))return this.setSnackbar({variant:"info",message:"Non-Supported File Type"}),i();if(t&&(!e||t.file!==e.file)){t.url="";const o=window.URL||window.webkitURL;o&&o.createObjectURL&&(t.url=o.createObjectURL(t.file))}},save(){this.addingLabel=!1;const t=this.files[0];this.createFile(t.file,e=>{const i={file:e,name:t.name.replace(/\s+/g,"-"),ext:t.name.substring(t.name.lastIndexOf("."),t.name.length),mime_type:t.type,label:this.docLabel,size:t.size};this.tempName=i.name,this.$emit("createDocument",i),this.label=null,this.files=[],this.addingLabel=!1})},removeImage(){const t={inputId:this.inputId,fileUrl:this.fileUrl,file:this.files&&this.files[0]};this.$emit("deleteDocument",t)}}},w={key:0},I={key:1,class:"example-avatar p-1 text-center"},D=["src"],L={key:1},N={key:2,class:"example-avatar p-1"},F={class:"avatar-upload"},O={class:"text-left"},j=["for"],C={key:0,class:"m-auto mt-2 position-relative w-100"},R=["href","download"],A={key:1,class:"m-auto"},B={key:0},V={key:1},q={class:"text-center p-2"};function z(t,e,i,o,r,n){const h=_("file-upload");return s(),l("div",null,[i.docLabel?(s(),l("label",w,p(i.docLabel),1)):f("",!0),i.disabled?(s(),l("div",I,[i.fileUrl?(s(),l("img",{key:0,src:i.fileUrl,class:"avatar-upload-photo"},null,8,D)):(s(),l("div",L,e[2]||(e[2]=[a("p",{class:"text-primary"},"No Current Upload",-1)])))])):(s(),l("div",N,[u(a("div",{class:b([i.noOverlay?"drop-active-no-overlay":"drop-active"])},e[3]||(e[3]=[a("h3",null,"Drop files to upload",-1)]),2),[[c,t.$refs.upload&&t.$refs.upload.dropActive]]),u(a("div",F,[a("div",O,[a("label",{for:i.inputId,class:"w-100 d-flex",style:{height:"100px"}},[r.files.length||i.fileUrl?(s(),l("div",C,[n.isAString?(s(),l("a",{key:0,href:i.downloadPath?`/b-api/${i.downloadPath}/${i.fileUrl}`:"",download:n.displayName,target:"_blank"},e[4]||(e[4]=[a("button",{class:"btn btn-primary btn-sm",style:{position:"absolute","max-height":"80px",top:"-21px",right:"25px",transform:"translate(-50%, -50%)"}},[a("i",{class:"text-white fa fa-download"})],-1)]),8,R)):f("",!0),i.allowDelete?(s(),l("button",{key:1,class:"btn btn-danger btn-sm",style:{position:"absolute","max-height":"80px",top:"-21px",right:"-13px",transform:"translate(-50%, -50%)"},onClick:e[0]||(e[0]=x((...d)=>n.removeImage&&n.removeImage(...d),["prevent"]))}," X ")):f("",!0),m(" "+p(n.displayName),1)])):(s(),l("div",A,[t.$refs.upload&&!t.$refs.upload.dropActive&&i.noOverlay?(s(),l("div",B,e[5]||(e[5]=[a("h4",{class:"pt-2 d-inline"},"Click or Drop File",-1)]))):(s(),l("div",V,e[6]||(e[6]=[a("h4",{class:"pt-2 d-inline"},"Drop File Here",-1)]))),e[7]||(e[7]=a("i",{class:"fas fa-cloud-upload-alt d-block pt-2"},null,-1))]))],8,j)]),a("div",q,[U(h,{ref:"upload",modelValue:r.files,"onUpdate:modelValue":e[1]||(e[1]=d=>r.files=d),extensions:i.extensions,accept:i.accept,"input-id":i.inputId,class:"btn btn-primary",drop:!r.edit,onInputFilter:n.inputFilter,onInputFile:n.inputFile},{default:k(()=>e[8]||(e[8]=[m(" Click or Drop File ")])),_:1},8,["modelValue","extensions","accept","input-id","drop","onInputFilter","onInputFile"])])],512),[[c,!r.edit]])]))])}const H=v(S,[["render",z],["__scopeId","data-v-fd44ff92"]]);export{H as S};
