"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_AccordionItem_cjs = require("../Accordion/AccordionItem.cjs");
const styles_lib_components_Heading_Heading_cjs = require("../Heading/Heading.cjs");
const styles_lib_css_breakpoints_cjs = require("../../css/breakpoints.cjs");
const styles_lib_components_Accordion_Accordion_cjs = require("../Accordion/Accordion.cjs");
const styles_lib_components_Hidden_Hidden_css_cjs = require("./Hidden.css.cjs");
const styles_lib_components_Column_Column_cjs = require("../Column/Column.cjs");
const resolveResponsiveRangeProps = (props) => {
  const { above, below } = props;
  if (!above && !below) {
    return [false, false, false, false];
  }
  const startIndex = above ? styles_lib_css_breakpoints_cjs.breakpointNames.indexOf(above) + 1 : 0;
  const endIndex = below ? styles_lib_css_breakpoints_cjs.breakpointNames.indexOf(below) - 1 : styles_lib_css_breakpoints_cjs.breakpointNames.length - 1;
  const range = styles_lib_css_breakpoints_cjs.breakpointNames.slice(startIndex, endIndex + 1);
  const includeMobile = range.indexOf("mobile") >= 0;
  const includeTablet = range.indexOf("tablet") >= 0;
  const includeDesktop = range.indexOf("desktop") >= 0;
  const includeWide = range.indexOf("wide") >= 0;
  return [includeMobile, includeTablet, includeDesktop, includeWide];
};
const Hidden = ({
  children,
  component,
  above,
  below,
  screen,
  print,
  inline: inlineProp,
  data,
  ...restProps
}) => {
  if (process.env.NODE_ENV === "development" && screen) {
    console.warn(
      `You used the "screen" prop on Hidden, but this probably doesn't do what you expect. If you're trying to provide content to screen readers without rendering it to the screen, use the <HiddenVisually> component instead. The "screen" prop is likely to be deprecated in a future release.`
    );
  }
  const inText = Boolean(React.useContext(styles_lib_components_Accordion_AccordionItem_cjs.TextContext));
  const inHeading = Boolean(React.useContext(styles_lib_components_Heading_Heading_cjs.HeadingContext));
  const hiddenOnScreen = Boolean(screen);
  const hiddenOnPrint = Boolean(print);
  const [hiddenOnMobile, hiddenOnTablet, hiddenOnDesktop, hiddenOnWide] = resolveResponsiveRangeProps({ above, below });
  const inline = inlineProp ?? (inText || inHeading);
  const display = inline ? "inline" : "block";
  return /* @__PURE__ */ jsxRuntime.jsx(
    styles_lib_components_Box_Box_cjs.Box,
    {
      display: hiddenOnScreen ? "none" : styles_lib_components_Column_Column_cjs.optimizeResponsiveArray([
        hiddenOnMobile ? "none" : display,
        hiddenOnTablet ? "none" : display,
        hiddenOnDesktop ? "none" : display,
        hiddenOnWide ? "none" : display
      ]),
      className: hiddenOnPrint ? styles_lib_components_Hidden_Hidden_css_cjs.hiddenOnPrint : void 0,
      component: component || (inline ? "span" : "div"),
      ...styles_lib_components_Accordion_Accordion_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
      children
    }
  );
};
exports.Hidden = Hidden;
exports.resolveResponsiveRangeProps = resolveResponsiveRangeProps;
