"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 _reactMeasure = _interopRequireDefault(require("react-measure"));
var _constants = require("../../constants");
var _VerticalContext = _interopRequireWildcard(require("../VerticalContext"));
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.

/**
 * `Columns` component is used for creating of multi-column layouts.
 * @since 2.6.0
 */
const Columns = _ref => {
  let {
    baseClassName = `${_constants.CLS_PREFIX}columns`,
    className,
    children,
    vertical: verticalProp,
    gap,
    ...props
  } = _ref;
  // eslint-disable-next-line prefer-const
  let [vertical, setVertical] = (0, _react.useState)(false);
  const verticalContext = (0, _react.useContext)(_VerticalContext.default);
  if (verticalProp === undefined) {
    verticalProp = typeof verticalContext === 'undefined' ? _VerticalContext.VERTICAL_BREAKPOINT : verticalContext;
  }
  if (typeof verticalProp === 'boolean') {
    vertical = verticalProp;
  }
  const handleResize = _ref2 => {
    let {
      bounds
    } = _ref2;
    setVertical(bounds.width < verticalProp);
  };
  const createRoot = measureRef => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    ref: measureRef,
    className: (0, _classnames.default)(baseClassName, {
      [`${baseClassName}--vertical`]: vertical,
      [`${baseClassName}--gap-${gap}`]: gap
    }, className),
    ...props,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VerticalContext.default.Provider, {
      value: vertical,
      children: children
    })
  });
  if (typeof verticalProp === 'number') {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMeasure.default, {
      bounds: true,
      onResize: handleResize,
      children: _ref3 => {
        let {
          measureRef
        } = _ref3;
        return createRoot(measureRef);
      }
    });
  }
  return createRoot();
};
var _default = exports.default = Columns;