import{P as I}from"./index.fa58e261.js";import{E as M}from"./element-plus.73c9e9a6.js";import{F as T,_ as B,a as N}from"./index.fec21d03.js";import{u as G,d as H,b as O}from"./index.bd5cd373.js";import{_ as j}from"./index.b3eba7ba.js";import{D as q}from"./vuedraggable.917b44c2.js";import{d as J,r as i,_ as K,b as S,w as Q,G as z,n as W,af as U,o as X,c as Y,U as n,ab as Z,L as p,a as s,a3 as P,O as $,R as x,M as ee,H as le,a0 as ae,V as te,bl as oe,bk as se}from"./@vue.663bc523.js";import{e as ie}from"./@vueuse.4b5afb22.js";const ne=J({components:{Popup:I,Draggable:q,FileItem:T,Material:B,Preview:N},props:{modelValue:{type:[String,Array],default:()=>[]},type:{type:String,default:"image"},size:{type:String,default:"100px"},fileSize:{type:String,default:"100px"},limit:{type:Number,default:1},disabled:{type:Boolean,default:!1},hiddenUpload:{type:Boolean,default:!1},uploadClass:{type:String,default:""},excludeDomain:{type:Boolean,default:!1}},emits:["change","update:modelValue"],setup(e,{emit:t}){const g=i(),_=i(),w=i(""),y=i(!1),a=i([]),m=i([]),r=i(!0),c=i(-1),{disabled:f,limit:u,modelValue:C}=K(e),{getImageUrl:b}=G(),o=S(()=>{switch(e.type){case"image":return"\u56FE\u7247";case"video":return"\u89C6\u9891";default:return""}}),v=S(()=>e.limit-a.value.length>0),h=S(()=>r.value?u.value==-1?null:u.value-a.value.length:1),D=ie(()=>{const l=m.value.map(d=>e.excludeDomain?d.url:d.uri);r.value?a.value=[...a.value,...l]:a.value.splice(c.value,1,l.shift()),k()},1e3,!1),A=l=>{var d;f.value||(l>=0?(r.value=!1,c.value=l):r.value=!0,(d=g.value)==null||d.open())},F=l=>{m.value=l},k=()=>{const l=u.value!=1?a.value:a.value[0]||"";t("update:modelValue",l),t("change",l),V()},L=l=>{f.value||(a.value.splice(l,1),k())},R=l=>{w.value=l,y.value=!0},V=()=>{W(()=>{var l;e.hiddenUpload&&(a.value=[]),(l=_.value)==null||l.clearSelect()})};return Q(C,l=>{a.value=Array.isArray(l)?l:l==""?[]:[l]},{immediate:!0}),z("limit",e.limit),z("hiddenUpload",e.hiddenUpload),{popupRef:g,materialRef:_,fileList:a,tipsText:o,handleConfirm:D,meterialLimit:h,showUpload:v,showPopup:A,selectChange:F,deleteImg:L,previewUrl:w,showPreview:y,handlePreview:R,handleClose:V,getImageUrl:b}}});const E=e=>(oe("data-v-e9ee558c"),e=e(),se(),e),re={class:"material-select"},ue=["onClick"],de={class:"operation-btns text-xs text-center"},pe=E(()=>s("span",null,"\u4FEE\u6539",-1)),me=["onClick"],ce=E(()=>s("span",null,"\u6DFB\u52A0",-1)),fe={class:"material-wrap"};function ve(e,t,g,_,w,y){const a=U("file-item"),m=j,r=U("draggable"),c=O,f=B,u=M,C=I,b=U("preview");return X(),Y("div",re,[n(C,{ref:"popupRef",width:"830px","custom-class":"body-padding",title:`\u9009\u62E9${e.tipsText}`,onConfirm:e.handleConfirm,onClose:e.handleClose},Z({default:p(()=>[n(u,null,{default:p(()=>[s("div",fe,[n(f,{ref:"materialRef",type:e.type,"file-size":e.fileSize,limit:e.meterialLimit,onChange:e.selectChange},null,8,["type","file-size","limit","onChange"])])]),_:1})]),_:2},[e.hiddenUpload?void 0:{name:"trigger",fn:p(()=>[s("div",{class:"material-select__trigger clearfix",onClick:t[2]||(t[2]=P(()=>{},["stop"]))},[n(r,{class:"draggable",modelValue:e.fileList,"onUpdate:modelValue":t[0]||(t[0]=o=>e.fileList=o),animation:"300","item-key":"id"},{item:p(({element:o,index:v})=>[s("div",{class:$(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:h=>e.showPopup(v)},[n(m,{onClose:h=>e.deleteImg(v)},{default:p(()=>[n(a,{uri:e.excludeDomain?e.getImageUrl(o):o,"file-size":e.size,type:e.type},null,8,["uri","file-size","type"])]),_:2},1032,["onClose"]),s("div",de,[pe,x(" | "),s("span",{onClick:P(h=>e.handlePreview(o),["stop"])},"\u67E5\u770B",8,me)])],10,ue)]),_:1},8,["modelValue"]),ee(s("div",{class:$(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1,[e.uploadClass]:!0}]),onClick:t[1]||(t[1]=o=>e.showPopup(-1))},[le(e.$slots,"upload",{},()=>[s("div",{class:"upload-btn",style:ae({width:e.size,height:e.size})},[n(c,{size:25,name:"el-icon-Plus"}),ce],4)],!0)],2),[[te,e.showUpload]])])]),key:"0"}]),1032,["title","onConfirm","onClose"]),n(b,{modelValue:e.showPreview,"onUpdate:modelValue":t[3]||(t[3]=o=>e.showPreview=o),url:e.previewUrl,type:e.type},null,8,["modelValue","url","type"])])}const Ue=H(ne,[["render",ve],["__scopeId","data-v-e9ee558c"]]);export{Ue as M};