import { isVNode, defineComponent, computed, ref, onUnmounted, createVNode, mergeProps } from 'vue';
import ResizeObserver from '../vc-resize-observer/index.mjs';
import classNames from '../_util/classNames.mjs';
import PropTypes from '../_util/vue-types/index.mjs';

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const UNDEFINED = void 0;
var Item = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Item",
  props: {
    prefixCls: String,
    item: PropTypes.any,
    renderItem: Function,
    responsive: Boolean,
    itemKey: {
      type: [String, Number]
    },
    registerSize: Function,
    display: Boolean,
    order: Number,
    component: PropTypes.any,
    invalidate: Boolean
  },
  setup(props, {
    slots,
    expose
  }) {
    const mergedHidden = computed(() => props.responsive && !props.display);
    const itemNodeRef = ref();
    expose({
      itemNodeRef
    });
    function internalRegisterSize(width) {
      props.registerSize(props.itemKey, width);
    }
    onUnmounted(() => {
      internalRegisterSize(null);
    });
    return () => {
      var _a;
      const {
        prefixCls,
        invalidate,
        item,
        renderItem,
        responsive,
        registerSize,
        itemKey,
        display,
        order,
        component: Component = "div",
        ...restProps
      } = props;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
      const childNode = renderItem && item !== UNDEFINED ? renderItem(item) : children;
      let overflowStyle;
      if (!invalidate) {
        overflowStyle = {
          opacity: mergedHidden.value ? 0 : 1,
          height: mergedHidden.value ? 0 : UNDEFINED,
          overflowY: mergedHidden.value ? "hidden" : UNDEFINED,
          order: responsive ? order : UNDEFINED,
          pointerEvents: mergedHidden.value ? "none" : UNDEFINED,
          position: mergedHidden.value ? "absolute" : UNDEFINED
        };
      }
      const overflowProps = {};
      if (mergedHidden.value)
        overflowProps["aria-hidden"] = true;
      return createVNode(ResizeObserver, {
        "disabled": !responsive,
        "onResize": ({
          offsetWidth
        }) => {
          internalRegisterSize(offsetWidth);
        }
      }, {
        default: () => createVNode(Component, mergeProps({
          "class": classNames(!invalidate && prefixCls),
          "style": overflowStyle
        }, overflowProps, restProps, {
          "ref": itemNodeRef
        }), _isSlot(childNode) ? childNode : {
          default: () => [childNode]
        })
      });
    };
  }
});

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