import e from"../../_util/hooks/useMergedState.mjs";import t from"./Preview.mjs";import{mergeDefaultValue as n}from"./Image.mjs";import{Fragment as r,computed as i,createVNode as a,defineComponent as o,inject as s,provide as c,reactive as l,ref as u,shallowRef as d,watch as f,watchEffect as p}from"vue";var m=Symbol(`previewGroupContext`),h={provide:e=>{c(m,e)},inject:()=>s(m,{isPreviewGroup:d(!1),previewUrls:i(()=>new Map),setPreviewUrls:()=>{},current:u(null),setCurrent:()=>{},setShowPreview:()=>{},setMousePosition:()=>{},registerImage:null,rootClassName:``})},g=()=>({previewPrefixCls:String,preview:{type:[Boolean,Object],default:!0},icons:{type:Object,default:()=>({})}}),_=o({compatConfig:{MODE:3},name:`PreviewGroup`,inheritAttrs:!1,props:g(),setup(o,{slots:s}){let c=i(()=>{let e={visible:void 0,onVisibleChange:()=>{},getContainer:void 0,current:0};return typeof o.preview==`object`?n(o.preview,e):e}),m=l(new Map),g=u(),_=i(()=>c.value.visible),v=i(()=>c.value.getContainer),[y,b]=e(!!_.value,{value:_,onChange:(e,t)=>{c.value.onVisibleChange?.(e,t)}}),x=u(null),S=i(()=>_.value!==void 0),C=i(()=>Array.from(m.keys())),w=i(()=>C.value[c.value.current]),T=i(()=>new Map(Array.from(m).filter(([,{canPreview:e}])=>!!e).map(([e,{url:t}])=>[e,t]))),E=(e,t,n=!0)=>{m.set(e,{url:t,canPreview:n})},D=e=>{g.value=e},O=e=>{x.value=e},k=(e,t,n=!0)=>(m.set(e,{url:t,canPreview:n}),()=>{m.delete(e)}),A=e=>{e?.stopPropagation(),b(!1),O(null)};return f(w,e=>{D(e)},{immediate:!0,flush:`post`}),p(()=>{y.value&&S.value&&D(w.value)},{flush:`post`}),h.provide({isPreviewGroup:d(!0),previewUrls:T,setPreviewUrls:E,current:g,setCurrent:D,setShowPreview:b,setMousePosition:O,registerImage:k}),()=>{let{...e}=c.value;return a(r,null,[s.default&&s.default(),a(t,{...e,"ria-hidden":!y.value,visible:y.value,prefixCls:o.previewPrefixCls,onClose:A,mousePosition:x.value,src:T.value.get(g.value),icons:o.icons,getContainer:v.value},null)])}}});export{h as context,_ as default,g as imageGroupProps};