"use client";
import { j as n } from "../../../node_modules/.pnpm/react@19.1.0/node_modules/react/jsx-runtime.mjs";
import { useState as D, useEffect as w } from "react";
import f from "../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.mjs";
import { ReactComponent as C } from "../../assets/images/DownArrow.svg.mjs";
import { ReactComponent as S } from "../../assets/images/ArrowTop.svg.mjs";
import i from "./Collapse.module.scss.mjs";
const e = ({
  title: h,
  subtitle: j,
  isOpen: t,
  onToggle: u,
  classNames: o,
  children: b,
  ...x
}) => {
  const [r, p] = D(!1);
  w(() => {
    t !== void 0 && p(t);
  }, [t]);
  const v = () => {
    const d = t === void 0 ? !r : !t;
    p(d), u == null || u(d);
  };
  w(() => {
    t !== void 0 && p(t);
  }, [t]);
  const y = (d) => {
    (d.key === " " || d.key === "Enter") && (d.preventDefault(), v());
  };
  return /* @__PURE__ */ n.jsxs(
    "div",
    {
      className: f(
        i.root,
        o == null ? void 0 : o.root,
        r ? o == null ? void 0 : o.open : o == null ? void 0 : o.closed
      ),
      children: [
        /* @__PURE__ */ n.jsxs(
          "button",
          {
            ...x,
            className: f(
              i.toggleButton,
              o == null ? void 0 : o.toggleButton,
              r && i.buttonOpen
            ),
            onClick: v,
            onKeyDown: y,
            tabIndex: 0,
            role: "button",
            "aria-expanded": r || t,
            children: [
              /* @__PURE__ */ n.jsxs("div", { className: i.info, children: [
                /* @__PURE__ */ n.jsx("span", { className: f("title", i.buttonTitle, o == null ? void 0 : o.title), children: h }),
                j && /* @__PURE__ */ n.jsx("span", { className: f(i.subtitle, o == null ? void 0 : o.subtitle), children: j })
              ] }),
              r ? /* @__PURE__ */ n.jsx(S, { className: i.arrowTopIcon }) : /* @__PURE__ */ n.jsx(C, { className: i.arrowDownIcon })
            ]
          }
        ),
        r ? /* @__PURE__ */ n.jsx("div", { className: f(i.content, o == null ? void 0 : o.content), children: b }) : null
      ]
    }
  );
};
export {
  e as default
};
//# sourceMappingURL=index.mjs.map
