"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _constants = require("../../constants");
var _VerticalContext = _interopRequireDefault(require("../VerticalContext"));
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. 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 = _ref => {
  let {
    baseClassName = `${_constants.CLS_PREFIX}columns__column`,
    className,
    children,
    fill,
    ratio,
    style,
    width,
    minWidth,
    maxWidth,
    ...props
  } = _ref;
  const vertical = (0, _react.useContext)(_VerticalContext.default);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    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: children
  });
};
var _default = exports.default = Column;