import { defineComponent, computed, createVNode } from 'vue';
import { omit } from 'lodash-es';
import '../../config-provider/index.mjs';
import useStyle from '../style/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import { isPresetSize } from './gapSize.mjs';
import { flexProps } from './props.mjs';
import createFlexClassNames from './util.mjs';
import { useConfigContextInject } from '../../config-provider/src/context/context.mjs';

var AFlex = /* @__PURE__ */ defineComponent({
  name: "AFlex",
  inheritAttrs: false,
  props: flexProps(),
  setup(props, {
    slots,
    attrs
  }) {
    const {
      flex: ctxFlex,
      direction: ctxDirection
    } = useConfigContextInject();
    const {
      prefixCls
    } = useConfigInject("flex", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const mergedCls = computed(() => {
      var _a;
      return [prefixCls.value, hashId.value, createFlexClassNames(prefixCls.value, props), {
        [`${prefixCls.value}-rtl`]: ctxDirection.value === "rtl",
        [`${prefixCls.value}-gap-${props.gap}`]: isPresetSize(props.gap),
        [`${prefixCls.value}-vertical`]: (_a = props.vertical) != null ? _a : ctxFlex == null ? void 0 : ctxFlex.value.vertical
      }];
    });
    return () => {
      const {
        flex,
        gap,
        component: Component = "div",
        ...othersProps
      } = props;
      const mergedStyle = {};
      if (flex)
        mergedStyle.flex = flex;
      if (gap && !isPresetSize(gap))
        mergedStyle.gap = `${gap}px`;
      return wrapSSR(createVNode(Component, {
        "class": [attrs.class, mergedCls.value],
        "style": [attrs.style, mergedStyle],
        ...omit(othersProps, ["justify", "wrap", "align", "vertical"])
      }, {
        default: () => {
          var _a;
          return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
        }
      }));
    };
  }
});

export { AFlex as default };
//# sourceMappingURL=Flex.mjs.map
