import{d as g,o as i,i as p,j as _,b as y,e as t,k as u}from"./index.9838a17e.js";import{r as c,aa as b,ac as D,n as F}from"./index.02c939b6.js";import{_ as w}from"./ElSpinner.vue_vue_type_style_index_0_lang.786c1ff1.js";const V={key:0,class:"p-12"},k={class:"space-y-1 text-center"},M=t("div",{class:"text-theme-400 text-center"},[t("div",{class:"i-carbon-upload inline-block text-2xl"})],-1),B={class:"text-theme-500 flex text-sm"},C={class:"text-theme-700 hover:text-theme-600 relative cursor-pointer rounded-md font-medium"},N=t("span",null,"Upload a file",-1),j=t("p",{class:"pl-1"},"or drag and drop",-1),G={class:"text-theme-500 text-xs"},$=g({__name:"InputMediaUpload",props:{modelValue:{type:[String],default:""},factorMedia:{type:Object,required:!0},allowedFile:{type:String,default:"PDF, PNG, JPG, GIF up to 10MB"}},emits:["update:modelValue"],setup(l,{emit:m}){const f=l,r=c(),s=c(!1),v=(a="")=>{m("update:modelValue",a)},n=async a=>{var o,d;if(!a)return;s.value=!0;const e=await f.factorMedia.uploadFiles({files:a});((o=e[0])==null?void 0:o.status)=="success"&&v((d=e[0].data)==null?void 0:d.url),s.value=!1},h=async a=>{const e=a.target;await n(e.files)},x=async a=>{var o;await n((o=a.dataTransfer)==null?void 0:o.files)};return(a,e)=>(i(),p("div",{class:"media-body",onDragover:e[2]||(e[2]=u(()=>{},["prevent"])),onDrop:e[3]||(e[3]=u(()=>{},["prevent"]))},[b(s)?(i(),p("div",V,[_(w,{class:"text-theme-200 m-auto h-12 w-12"})])):y("v-if",!0),t("label",{for:"file-upload",class:F(["border-theme-200 hover:bg-theme-50 hover:border-theme-300 mt-1 flex cursor-pointer justify-center rounded-md border-2 border-dashed px-4 py-6",[]]),onDrop:x,onDragover:e[0]||(e[0]=o=>r.value=!0),onDragleave:e[1]||(e[1]=o=>r.value=!1)},[t("div",k,[M,t("div",B,[t("div",C,[N,t("input",{id:"file-upload",name:"file-upload",type:"file",class:"sr-only",accept:"image/*",multiple:"",onChange:h},null,32)]),j]),t("p",G,D(l.allowedFile),1)])],32)],32))}});export{$ as default};
