"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Item;

var React = _interopRequireWildcard(require("react"));

var _ = require(".");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var spaceSize = {
  small: 8,
  middle: 16,
  large: 24
};

function Item(_a) {
  var _b;

  var _c;

  var className = _a.className,
      direction = _a.direction,
      index = _a.index,
      size = _a.size,
      marginDirection = _a.marginDirection,
      children = _a.children,
      split = _a.split;
  var latestIndex = React.useContext(_.LastIndexContext);

  if (children === null || children === undefined) {
    return null;
  }

  var style = index >= latestIndex ? {} : (_b = {}, _b[direction === 'vertical' ? 'marginBottom' : marginDirection] = ((_c = typeof size === 'string' ? spaceSize[size] : size) !== null && _c !== void 0 ? _c : 0) / (split ? 2 : 1), _b);
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: className,
    style: style
  }, children), index < latestIndex && split && /*#__PURE__*/React.createElement("span", {
    className: className + "-split",
    style: style
  }, split));
}