"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

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

var _classnames = _interopRequireDefault(require("classnames"));

var _constants = require("../../constants");

var _VerticalContext = _interopRequireDefault(require("../VerticalContext"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }

// Copyright 1999-2020. Plesk International GmbH. All rights reserved.
const normalize = value => String(Number(value)) === String(value) ? `${value}px` : value;
/**
 * `Column` component is a part of [Columns](#!/Columns).
 * @since 2.6.0
 */


const Column = ({
  baseClassName = `${_constants.CLS_PREFIX}columns__column`,
  className,
  children,
  fill,
  ratio,
  style,
  width,
  minWidth,
  maxWidth,
  ...props
}) => {
  const vertical = (0, _react.useContext)(_VerticalContext.default);
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    className: (0, _classnames.default)(baseClassName, {
      [`${baseClassName}--fill`]: fill && !vertical,
      [`${baseClassName}--ratio-${ratio}`]: ratio && !vertical,
      [`${baseClassName}--has-width`]: width && !vertical
    }, className),
    style: vertical ? style : {
      width: normalize(width),
      flexBasis: normalize(minWidth),
      maxWidth: normalize(maxWidth),
      ...style
    }
  }, props), children);
};

var _default = Column;
exports.default = _default;