import s from"./FormGroup.efd02a6a.js";import a from"./Label.9d0d3ee0.js";import o from"./Button.f17dffc9.js";import l from"./ErrorText.b141a597.js";import i from"./HelperText.14a7ed0b.js";import n from"./IconClipboard.8551be1b.js";import p from"./IconKey.455a255f.js";import{n as u}from"./plugin-vue2_normalizer.000ba15c.js";const d="w-full border-medium-emphasis text-body h-10 px-2 border rounded bg-surface-1 focus:outline-none focus:border-primary",f={props:{id:{type:String,required:!1},label:{type:String,required:!0},required:{type:Boolean,default:()=>!1},errors:{type:Array},helperText:{type:String},placeholder:{type:String},value:File,loading:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},accept:String},components:{FormGroup:s,Label:a,ErrorText:l,HelperText:i,IconClipboard:n,IconKey:p,Button:o},data(){return{defaultClasses:d}},watch:{value(r){r||(this.$refs.file.value="")}},methods:{filesize(r){var e=Math.floor(Math.log(r)/Math.log(1024));return(r/Math.pow(1024,e)).toFixed(2)*1+" "+["B","kB","MB","GB","TB"][e]},browse(){this.$refs.file.click()},change(r){this.$emit("input",r.target.files[0])},remove(){this.$emit("input",null)}}};var c=function(){var e=this,t=e._self._c;return t("FormGroup",{staticClass:"relative max-w-lg"},[t("Label",{attrs:{errors:e.errors,forId:e.id}},[e._v(e._s(e.label))]),t("input",{ref:"file",staticClass:"hidden",class:[e.defaultClasses,e.disabled||e.loading?"opacity-50":"",e.loading?"cursor-wait":""],attrs:{id:e.id,type:"file",accept:e.accept},on:{change:e.change}}),e.value?t("div",{staticClass:"flex items-center justify-between p-2"},[t("div",{staticClass:"flex-1 pr-1"},[e._v(e._s(e.value.name)+" "),t("span",{staticClass:"text-gray-500 text-xs"},[e._v("("+e._s(e.filesize(e.value.size))+")")])]),t("Button",{staticClass:"px-4 py-1 rounded-sm text-xs font-medium text-white",attrs:{variant:"danger",type:"button"},on:{click:e.remove}},[e._v(" Remove ")])],1):t("div",{staticClass:"p-2"},[t("Button",{staticClass:"px-4 py-1 rounded-sm text-xs font-medium text-white",attrs:{type:"button"},on:{click:e.browse}},[e._v(" Browse ")])],1),e.errors?t("ErrorText",[e._v(e._s(e.errors[0]))]):e._e(),e.helperText&&!e.errors?t("HelperText",[e._v(e._s(e.helperText))]):e._e()],1)},m=[],_=u(f,c,m,!1,null,null,null,null);const w=_.exports;export{w as default};
