"use strict";
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const styles_lib_components_Box_Box_cjs = require("../Box/Box.cjs");
const styles_lib_components_Accordion_Accordion_cjs = require("../Accordion/Accordion.cjs");
const styles_lib_components_Column_Column_css_cjs = require("./Column.css.cjs");
const optimizeResponsiveArray = (value) => {
  let lastValue;
  const values = value.map((v) => {
    if (v !== lastValue && v !== null) {
      lastValue = v;
      return v;
    }
    return null;
  });
  return [
    values[0] ?? null,
    values[1] ?? null,
    values[2] ?? null,
    values[3] ?? null
  ];
};
const validColumnsComponents = ["div", "span"];
const ColumnsContext = React.createContext({
  collapseMobile: false,
  collapseTablet: false,
  collapseDesktop: false,
  mobileSpace: "none",
  tabletSpace: "none",
  desktopSpace: "none",
  wideSpace: "none",
  collapsibleAlignmentChildProps: null,
  component: "div"
});
const Column = ({
  children,
  data,
  width,
  ...restProps
}) => {
  const {
    collapseMobile,
    collapseTablet,
    collapseDesktop,
    mobileSpace,
    tabletSpace,
    desktopSpace,
    wideSpace,
    collapsibleAlignmentChildProps,
    component
  } = React.useContext(ColumnsContext);
  return /* @__PURE__ */ jsxRuntime.jsx(
    styles_lib_components_Box_Box_cjs.Box,
    {
      component,
      display: component === "span" ? "block" : void 0,
      minWidth: 0,
      width: width !== "content" ? "full" : void 0,
      flexShrink: width === "content" ? 0 : void 0,
      flexGrow: 1,
      className: [
        styles_lib_components_Column_Column_css_cjs.column,
        width !== "content" ? styles_lib_components_Column_Column_css_cjs.width[width] : null
      ],
      ...styles_lib_components_Accordion_Accordion_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
      children: /* @__PURE__ */ jsxRuntime.jsx(
        styles_lib_components_Box_Box_cjs.Box,
        {
          component,
          paddingLeft: optimizeResponsiveArray([
            collapseMobile ? "none" : mobileSpace,
            collapseTablet ? "none" : tabletSpace,
            collapseDesktop ? "none" : desktopSpace,
            wideSpace
          ]),
          paddingTop: collapseMobile || collapseTablet || collapseDesktop ? optimizeResponsiveArray([
            collapseMobile ? mobileSpace : "none",
            collapseTablet ? tabletSpace : "none",
            collapseDesktop ? desktopSpace : "none",
            "none"
          ]) : void 0,
          height: "full",
          ...collapsibleAlignmentChildProps,
          className: styles_lib_components_Column_Column_css_cjs.columnContent,
          children
        }
      )
    }
  );
};
exports.Column = Column;
exports.ColumnsContext = ColumnsContext;
exports.optimizeResponsiveArray = optimizeResponsiveArray;
exports.validColumnsComponents = validColumnsComponents;
