import{A as d}from"./AmaTRG5a.js";import{u as g}from"./BHvLfWtM.js";import{v as c}from"./B2895E6R.js";import{_ as y,O as h,c as n,b as s,f as _,e as p,t as x,D as u,o}from"./Bgmy51Qv.js";const I={setup(t){const{t:e}=h();return{propBtnText:t.btnText||e("profile.upload")}},name:"FileUpload",data(){return{uploadMessage:null}},mixins:[g,c],components:{AjaxButton:d},props:{btnType:{type:String,default:"outline"},fileUploading:{type:Boolean,default:!1},imageUrl:{type:String,default:""},image:{type:String,default:""},imageTitle:{type:String,default:""},onlyIcon:{type:String,default:null},btnText:{type:String,default:null}},computed:{previewImageUrl(){return this.imageUrl||this.getImageURL(this.imageName)||""},imageName(){var t;return(t=this.image)!=null&&t.trim()?this.image:this.defaultImage}},methods:{fileChanged(t){const e=t.target.files[0];e&&(this.uploadMessage=this.isValidImage(e),this.uploadMessage||this.$emit("file-upload",e))}}},U={class:"file-input"},b=["src","alt"],T={key:0,class:"error mb-10"};function v(t,e,a,m,i,l){const f=d;return o(),n("div",{class:u(["file-wrapper",{"has-error":i.uploadMessage}])},[s("div",null,[s("div",U,[s("input",{type:"file",accept:"image/*",onChange:e[0]||(e[0]=(...r)=>l.fileChanged&&l.fileChanged(...r)),ref:"fileInput"},null,544),a.fileUploading?p("",!0):(o(),n("img",{key:0,src:l.previewImageUrl,alt:a.imageTitle},null,8,b))]),i.uploadMessage?(o(),n("span",T,x(i.uploadMessage),1)):p("",!0)]),_(f,{class:u(["w-100",`${a.btnType}-btn`]),type:"button",color:"primary",text:m.propBtnText,"only-icon":a.onlyIcon,"fetching-data":a.fileUploading,onClicked:e[1]||(e[1]=r=>t.$refs.fileInput.click())},null,8,["class","text","only-icon","fetching-data"])],2)}const M=y(I,[["render",v]]);export{M as F};
