import{_ as c}from"./FlashMessages-ByEdcHWZ.js";import{o as i,c as n,t as s,h as d,b as r,e as m,n as u}from"./app-CK3cEAAe.js";const f={props:{modelValue:File,label:String,accept:String,errors:{type:Array,default:()=>[]}},emits:["update:modelValue"],watch:{modelValue(e){e||(this.$refs.file.value="")}},methods:{filesize(e){var t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)*1+" "+["B","kB","MB","GB","TB"][t]},browse(){this.$refs.file.click()},change(e){this.$emit("update:modelValue",e.target.files[0])},remove(){this.$emit("update:modelValue",null)}}},h={key:0,class:"form-label"},g=["accept"],b={key:0,class:"p-1"},y={key:1,class:"flex items-center justify-between p-2"},x={class:"flex-1 pr-1 truncate"},_={class:"text-gray-500 text-xs"},v={key:1,class:"form-error"};function p(e,t,l,V,k,a){return i(),n("div",null,[l.label?(i(),n("label",h,s(l.label),1)):d("",!0),r("div",{class:u(["form-input p-0",{error:l.errors.length}])},[r("input",{ref:"file",type:"file",accept:l.accept,class:"hidden",onChange:t[0]||(t[0]=(...o)=>a.change&&a.change(...o))},null,40,g),l.modelValue?(i(),n("div",y,[r("div",x,[m(s(l.modelValue.name)+" ",1),r("span",_,"("+s(a.filesize(l.modelValue.size))+")",1)]),r("button",{type:"button",class:"px-4 py-1 text-white text-xs font-medium bg-gray-500 hover:bg-gray-700 rounded-sm",onClick:t[2]||(t[2]=(...o)=>a.remove&&a.remove(...o))},s(e.$t("Remove")),1)])):(i(),n("div",b,[r("button",{type:"button",class:"px-4 py-1 text-white text-xs font-medium bg-gray-500 hover:bg-gray-700 rounded-sm",onClick:t[1]||(t[1]=(...o)=>a.browse&&a.browse(...o))},s(e.$t("Browse")),1)]))],2),l.errors.length?(i(),n("div",v,s(l.errors[0]),1)):d("",!0)])}const C=c(f,[["render",p]]);export{C as F};
