import { jsxs as g, jsx as t } from "react/jsx-runtime";
import { useContext as A, useId as C, useState as I, createContext as j } from "react";
import { a as v } from "./heading-gqtQNo5n.mjs";
import { c as x } from "./bind-CU-R61T-.mjs";
import { l as H } from "./chevron-down.es-PCIIj6oG.mjs";
import { a as P } from "./paragraph-DNtj7OLr.mjs";
const S = {
  "purpur-accordion": "_purpur-accordion_mwmy0_1",
  "purpur-accordion__title": "_purpur-accordion__title_mwmy0_4",
  "purpur-accordion--negative": "_purpur-accordion--negative_mwmy0_13"
}, z = {
  "purpur-accordion-item": "_purpur-accordion-item_1du2l_1",
  "purpur-accordion-item__trigger": "_purpur-accordion-item__trigger_1du2l_4",
  "purpur-accordion-item__header": "_purpur-accordion-item__header_1du2l_10",
  "purpur-accordion-item__trigger__icon": "_purpur-accordion-item__trigger__icon_1du2l_43",
  "purpur-accordion-item__title": "_purpur-accordion-item__title_1du2l_49",
  "purpur-accordion-item__icon": "_purpur-accordion-item__icon_1du2l_50",
  "purpur-accordion-item__rotate": "_purpur-accordion-item__rotate_1du2l_64",
  "purpur-accordion-item__content": "_purpur-accordion-item__content_1du2l_67",
  "purpur-accordion-item__contentText": "_purpur-accordion-item__contentText_1du2l_82",
  "purpur-accordion-item__contentText--limit-width": "_purpur-accordion-item__contentText--limit-width_1du2l_85",
  "purpur-accordion-item--negative": "_purpur-accordion-item--negative_1du2l_107"
}, i = x.bind(z), r = "purpur-accordion-item", L = ({
  children: o,
  className: c,
  fullWidth: n = !1,
  title: _,
  titleTag: s = "h3",
  initialOpen: m = !1,
  onClick: a,
  onOpen: u,
  onClose: d,
  ...y
}) => {
  const N = A($), p = C(), [e, b] = I(!m), T = i([
    r,
    {
      [`${r}--negative`]: N
    },
    c
  ]);
  return /* @__PURE__ */ g("div", { className: T, ...y, children: [
    /* @__PURE__ */ t(
      v,
      {
        tag: s,
        variant: "title-100",
        className: i([`${r}__header`, `${r}__title`]),
        children: /* @__PURE__ */ g(
          "button",
          {
            type: "button",
            "data-state": e ? "open" : "close",
            onClick: (w) => {
              a && a(w), e ? u && u() : d && d(), b(!e);
            },
            className: i(`${r}__trigger`, c, {
              [`${r}__rotate`]: !e
            }),
            "aria-expanded": !e,
            "aria-controls": p,
            id: p + "button",
            children: [
              _,
              /* @__PURE__ */ t(H, { size: "md", className: i(`${r}__icon`), "aria-hidden": !0 })
            ]
          }
        )
      }
    ),
    /* @__PURE__ */ t(
      "div",
      {
        className: i(`${r}__content`, c),
        "aria-hidden": e,
        id: p,
        "aria-labelledby": p + "button",
        role: "region",
        children: /* @__PURE__ */ t(
          "div",
          {
            className: i(`${r}__contentText`, {
              [`${r}__contentText--limit-width`]: !n
            }),
            children: typeof o == "string" ? /* @__PURE__ */ t(P, { variant: "paragraph-200", children: o }) : o
          }
        )
      }
    )
  ] });
}, h = x.bind(S), l = "purpur-accordion", $ = j(!1), f = ({
  children: o,
  className: c,
  negative: n = !1,
  title: _,
  titleTag: s = "h2",
  titleVariant: m = "title-300",
  schema: a,
  ...u
}) => {
  const d = h([
    l,
    {
      [`${l}--negative`]: n
    },
    c
  ]);
  return /* @__PURE__ */ g("div", { className: d, ...u, children: [
    _ && /* @__PURE__ */ t(v, { tag: s, variant: m, className: h(`${l}__title`), children: _ }),
    /* @__PURE__ */ t($.Provider, { value: n, children: o }),
    a && /* @__PURE__ */ t(
      "script",
      {
        type: "application/ld+json",
        dangerouslySetInnerHTML: {
          __html: a
        }
      }
    )
  ] });
};
f.Item = L;
f.displayName = "Accordion";
export {
  f as A,
  $ as N
};
//# sourceMappingURL=accordion-DWflnyWa.mjs.map
