"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.masonryItemProps = exports.default = void 0;
var _vue = require("vue");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _vcResizeObserver = _interopRequireDefault(require("../vc-resize-observer"));
const masonryItemProps = () => ({
  prefixCls: String,
  item: Object,
  style: Object,
  className: String,
  index: Number,
  column: Number,
  onResize: Function,
  itemRender: Function
});
exports.masonryItemProps = masonryItemProps;
const MasonryItem = (0, _vue.defineComponent)({
  name: 'AMasonryItem',
  props: masonryItemProps(),
  setup(props, {
    slots,
    expose
  }) {
    const itemPrefix = (0, _vue.computed)(() => `${props.prefixCls}-item`);
    const itemRef = (0, _vue.ref)();
    expose({
      itemRef
    });
    return () => {
      var _a;
      const {
        itemRender = slots.itemRender,
        item,
        index,
        column,
        style,
        className,
        onResize
      } = props;
      const renderNode = (_a = item.children) !== null && _a !== void 0 ? _a : itemRender === null || itemRender === void 0 ? void 0 : itemRender({
        itemInfo: (0, _extends2.default)((0, _extends2.default)({}, item), {
          index,
          column
        })
      });
      let returnNode = (0, _vue.createVNode)("div", {
        "ref": itemRef,
        "style": style,
        "class": [itemPrefix.value, className]
      }, [renderNode]);
      if (onResize) {
        const _returnNode = function () {
          return returnNode;
        }();
        returnNode = (0, _vue.createVNode)(_vcResizeObserver.default, {
          "onResize": onResize
        }, {
          default: () => [_returnNode]
        });
      }
      return returnNode;
    };
  }
});
var _default = exports.default = MasonryItem;