"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkZUAO4DW3cjs = require('./chunk-ZUAO4DW3.cjs');


var _chunkMFKERIW4cjs = require('./chunk-MFKERIW4.cjs');


var _chunkWF7Z2VITcjs = require('./chunk-WF7Z2VIT.cjs');


var _chunkRSHN4K6Ncjs = require('./chunk-RSHN4K6N.cjs');

// src/components/Collapsible.tsx
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);
var _react = require('react');
var _jsxruntime = require('@emotion/react/jsx-runtime');
function Collapsible({
  children,
  className,
  text,
  color,
  open,
  handleToggle,
  openIcon,
  closeIcon,
  full,
  buttonTextElement,
  contentIndent = true
}) {
  const [isOpen, setIsOpen] = _react.useState.call(void 0, open);
  const handleClick = () => {
    if (handleToggle) {
      handleToggle(!isOpen);
    }
    setIsOpen(!isOpen);
  };
  _react.useEffect.call(void 0, () => {
    setIsOpen(open);
  }, [open]);
  const iconName = openIcon && closeIcon ? isOpen ? closeIcon : openIcon : "Chevron";
  const iconWidth = iconName === "Close" ? 12 : 14;
  let textElement = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {});
  if (buttonTextElement) {
    textElement = buttonTextElement;
  } else if (text) {
    textElement = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text, { color, children: text });
  }
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, StyledCollapsible, { className, children: [
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, StyledCollapsibleButton, { onClick: handleClick, children: [
      textElement,
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
        IconContainer,
        {
          isOpen,
          useCustomIcon: openIcon !== void 0 && closeIcon !== void 0,
          children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWF7Z2VITcjs.Icon, { width: iconWidth, name: iconName })
        }
      )
    ] }),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsingContainer, { isOpen, full, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InnerPadding, { contentIndent, children }) })
  ] });
}
var StyledCollapsible = _styled2.default.div`
  display: flex;
  flex-direction: column;
`;
var StyledCollapsibleButton = _styled2.default.button`
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  cursor: pointer;
  ${_chunkRSHN4K6Ncjs.standardBorderRadius.call(void 0, 8)}
  padding: 0;
`;
var IconContainer = _styled2.default.div`
  ${(props) => {
  if (props.useCustomIcon) {
    return;
  }
  return props.isOpen ? `transform: rotate(0deg);` : `transform: rotate(-90deg);`;
}}
  transition: transform 0.25s ease-out;
  width: 20px;
`;
var CollapsingContainer = _styled2.default.div`
  overflow: scroll;
  opacity: 0;
  animation-duration: 0.4s;
  animation-fill-mode: forwards;

  ${(props) => props.isOpen ? `height: 100%; animation-name: fadeIn;` : `height: 0; animation-name: fadeOut;`}
  ${(props) => props.full ? `height: ${props.isOpen ? "100vh" : 0};` : ""}

  ${_chunkMFKERIW4cjs.overflowAutoWithoutScrollbars}

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes fadeOut {
    from {
      opacity: 1;
      transform: none;
    }
    to {
      opacity: 0;
      transform: translateY(-10px);
      visibility: hidden;
    }
  }
`;
var InnerPadding = _styled2.default.div`
  padding: ${_chunkZUAO4DW3cjs.Spacing.px["3xs"]} 0 ${_chunkZUAO4DW3cjs.Spacing.px["3xs"]}
    ${(props) => props.contentIndent ? _chunkZUAO4DW3cjs.Spacing.px.md : "0"};
  gap: ${_chunkZUAO4DW3cjs.Spacing.px["4xs"]};
  display: flex;
  flex-direction: column;
`;
var Text = _styled2.default.span`
  ${(props) => props.color ? `color: ${props.color};` : ""}
  line-height: inherit;
`;






exports.Collapsible = Collapsible; exports.StyledCollapsible = StyledCollapsible; exports.StyledCollapsibleButton = StyledCollapsibleButton; exports.CollapsingContainer = CollapsingContainer;
