"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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"));

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


const Column = ({
  baseClassName = "".concat(_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, {
      ["".concat(baseClassName, "--fill")]: fill && !vertical,
      ["".concat(baseClassName, "--ratio-").concat(ratio)]: ratio && !vertical,
      ["".concat(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;