import { defineComponent, computed, createVNode } from 'vue';
import { isEmpty } from 'lodash-es';
import '../../../utils/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import CompactItem from './Item.mjs';
import { spaceCompactProps } from './props.mjs';
import { SpaceCompactItemContext } from './context.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import { flattenChildren } from '../../../utils/vue/props.mjs';

var ACompact = /* @__PURE__ */ defineComponent({
  name: "ASpaceCompact",
  inheritAttrs: false,
  props: spaceCompactProps(),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls,
      direction: directionConfig
    } = useConfigInject("space-compact", props);
    const compactItemContext = SpaceCompactItemContext.useInject();
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const clx = computed(() => {
      return classNames(prefixCls.value, hashId.value, {
        [`${prefixCls.value}-rtl`]: directionConfig.value === "rtl",
        [`${prefixCls.value}-block`]: props.block,
        [`${prefixCls.value}-vertical`]: props.direction === "vertical"
      });
    });
    return () => {
      var _a;
      const childNodes = flattenChildren(((_a = slots.default) == null ? void 0 : _a.call(slots)) || []);
      if (childNodes.length === 0)
        return null;
      return wrapSSR(createVNode("div", {
        ...attrs,
        "class": [clx.value, attrs.class]
      }, [childNodes.map((child, i) => {
        var _a2;
        const key = child && child.key || `${prefixCls.value}-item-${i}`;
        const noCompactItemContext = !compactItemContext || isEmpty(compactItemContext);
        return createVNode(CompactItem, {
          "key": key,
          "compactSize": (_a2 = props.size) != null ? _a2 : "middle",
          "compactDirection": props.direction,
          "isFirstItem": i === 0 && (noCompactItemContext || (compactItemContext == null ? void 0 : compactItemContext.isFirstItem)),
          "isLastItem": i === childNodes.length - 1 && (noCompactItemContext || (compactItemContext == null ? void 0 : compactItemContext.isLastItem))
        }, {
          default: () => [child]
        });
      })]));
    };
  }
});

export { ACompact as default };
//# sourceMappingURL=Compact.mjs.map
