import{booleanType as e,tuple as t}from"../_util/type.mjs";import n from"../_util/classNames.mjs";import{flattenChildren as r}from"../_util/props-util/index.mjs";import i from"../config-provider/hooks/useConfigInject.mjs";import a from"../_util/vue-types/index.mjs";import o from"../_util/createContext.mjs";import s from"./style/index.mjs";import{computed as c,createVNode as l,defineComponent as u}from"vue";import{isEmpty as d}from"lodash-es";var f=()=>({compactSize:String,compactDirection:a.oneOf(t(`horizontal`,`vertical`)).def(`horizontal`),isFirstItem:e(),isLastItem:e()}),p=o(null),m=(e,t)=>{let r=p.useInject(),i=c(()=>{if(!r||d(r))return``;let{compactDirection:i,isFirstItem:a,isLastItem:o}=r,s=i===`vertical`?`-vertical-`:`-`;return n({[`${e.value}-compact${s}item`]:!0,[`${e.value}-compact${s}first-item`]:a,[`${e.value}-compact${s}last-item`]:o,[`${e.value}-compact${s}item-rtl`]:t.value===`rtl`})});return{compactSize:c(()=>r?.compactSize),compactDirection:c(()=>r?.compactDirection),compactItemClassnames:i}},h=u({name:`NoCompactStyle`,setup(e,{slots:t}){return p.useProvide(null),()=>t.default?.()}}),g=()=>({prefixCls:String,size:{type:String},direction:a.oneOf(t(`horizontal`,`vertical`)).def(`horizontal`),align:a.oneOf(t(`start`,`end`,`center`,`baseline`)),block:{type:Boolean,default:void 0}}),_=u({name:`CompactItem`,props:f(),setup(e,{slots:t}){return p.useProvide(e),()=>t.default?.()}}),v=u({name:`ASpaceCompact`,inheritAttrs:!1,props:g(),setup(e,{attrs:t,slots:a}){let{prefixCls:o,direction:u}=i(`space-compact`,e),f=p.useInject(),[m,h]=s(o),g=c(()=>n(o.value,h.value,{[`${o.value}-rtl`]:u.value===`rtl`,[`${o.value}-block`]:e.block,[`${o.value}-vertical`]:e.direction===`vertical`}));return()=>{let n=r(a.default?.()||[]);return n.length===0?null:m(l(`div`,{...t,class:[g.value,t.class]},[n.map((t,r)=>{let i=t&&t.key||`${o.value}-item-${r}`,a=!f||d(f);return l(_,{key:i,compactSize:e.size??`middle`,compactDirection:e.direction,isFirstItem:r===0&&(a||f?.isFirstItem),isLastItem:r===n.length-1&&(a||f?.isLastItem)},{default:()=>[t]})})]))}}});export{h as NoCompactStyle,p as SpaceCompactItemContext,v as default,f as spaceCompactItemProps,g as spaceCompactProps,m as useCompactItemContext};