import { jsxs as _, Fragment as I, jsx as o } from "react/jsx-runtime";
import { useState as O, forwardRef as v, isValidElement as A, Children as C, cloneElement as x } from "react";
import { a as z } from "./heading-gqtQNo5n.mjs";
import { I as E, a as S, R as D } from "./index-DSf4qCR-.mjs";
import { c as G } from "./bind-CU-R61T-.mjs";
import { a as R } from "./paragraph-DNtj7OLr.mjs";
import { S as L } from "./skeleton-CDGzLI-T.mjs";
const P = {
  "purpur-radio-card-group": "_purpur-radio-card-group_19msf_1",
  "purpur-radio-card-group--vertical": "_purpur-radio-card-group--vertical_19msf_5",
  "purpur-radio-card-group--horizontal": "_purpur-radio-card-group--horizontal_19msf_9",
  "purpur-radio-card-group--radio-left": "_purpur-radio-card-group--radio-left_19msf_18",
  "purpur-radio-card-group__item": "_purpur-radio-card-group__item_19msf_18",
  "purpur-radio-card-group__item-bottom-container": "_purpur-radio-card-group__item-bottom-container_19msf_21",
  "purpur-radio-card-group__item-top-container": "_purpur-radio-card-group__item-top-container_19msf_24",
  "purpur-radio-card-group__container": "_purpur-radio-card-group__container_19msf_35",
  "purpur-radio-card-group__item-container": "_purpur-radio-card-group__item-container_19msf_42",
  "purpur-radio-card-group__item-radio": "_purpur-radio-card-group__item-radio_19msf_77",
  "purpur-radio-card-group__item-content": "_purpur-radio-card-group__item-content_19msf_108",
  "purpur-radio-card-group__item-title": "_purpur-radio-card-group__item-title_19msf_121",
  "purpur-radio-card-group__item-indicator": "_purpur-radio-card-group__item-indicator_19msf_141",
  "purpur-radio-card-group__item-image-container": "_purpur-radio-card-group__item-image-container_19msf_151",
  "purpur-radio-card-group__item-image": "_purpur-radio-card-group__item-image_19msf_151",
  "purpur-radio-card-group__item-image--loaded": "_purpur-radio-card-group__item-image--loaded_19msf_164",
  "purpur-radio-card-group__item-image-placeholder": "_purpur-radio-card-group__item-image-placeholder_19msf_167",
  "purpur-radio-card-group__item-image-placeholder--loaded": "_purpur-radio-card-group__item-image-placeholder--loaded_19msf_172",
  "purpur-radio-card-group__item-children": "_purpur-radio-card-group__item-children_19msf_175"
}, a = G.bind(P), f = "purpur-radio-card-group__item-image", j = (r) => !!r?.src && !!r.altText, k = ({
  src: r,
  altText: p,
  noPlaceholder: n,
  loading: i = "lazy",
  ["data-testid"]: e
}) => {
  const [u, s] = O(!1), l = () => s(!0), c = a(f, {
    [`${f}--loaded`]: u
  }), g = a(`${f}-placeholder`, {
    [`${f}-placeholder--loaded`]: u
  });
  return /* @__PURE__ */ _(I, { children: [
    /* @__PURE__ */ o(
      "img",
      {
        "data-testid": e,
        className: c,
        src: r,
        alt: p,
        loading: i,
        onLoad: l
      }
    ),
    !n && /* @__PURE__ */ o(L, { className: g })
  ] });
}, t = "purpur-radio-card-group__item", $ = (r, { disabled: p }) => typeof r == "function" ? r({ disabled: p }) : r, N = v(
  ({ title: r, ...p }, n) => {
    const { ["data-testid"]: i, body: e, children: u, disabled: s, id: l, image: c, value: g } = p, d = { ...p };
    return /* @__PURE__ */ _("div", { className: a(`${t}-container`), ref: n, children: [
      /* @__PURE__ */ _(
        E,
        {
          className: a(t),
          "data-testid": i,
          disabled: s,
          id: l,
          value: g,
          children: [
            c && /* @__PURE__ */ o("span", { className: a(`${t}-image-container`), children: j(c) ? /* @__PURE__ */ o(k, { ...c, "data-testid": i && `${i}-image` }) : $(c, d) }),
            /* @__PURE__ */ _("span", { className: a(`${t}-content`), children: [
              /* @__PURE__ */ _("span", { className: a(`${t}-top-container`), children: [
                typeof r == "string" ? /* @__PURE__ */ o(
                  R,
                  {
                    className: a(`${t}-title`),
                    "data-testid": i && `${i}-title`,
                    variant: "paragraph-100",
                    disabled: s,
                    children: r
                  }
                ) : $(r, d),
                /* @__PURE__ */ o("span", { className: a(`${t}-radio`), children: /* @__PURE__ */ o(S, { className: a(`${t}-indicator`) }) })
              ] }),
              e && /* @__PURE__ */ o("span", { className: a(`${t}-bottom-container`), children: typeof e == "string" ? /* @__PURE__ */ o(
                R,
                {
                  "data-testid": i && `${i}-body`,
                  variant: "paragraph-100",
                  disabled: s,
                  children: e
                }
              ) : $(e, d) })
            ] })
          ]
        }
      ),
      u
    ] });
  }
);
N.displayName = "RadioCardItem";
const q = (r) => A(r) && r?.type === N, K = ["horizontal", "vertical"], M = ["right", "left"], h = "purpur-radio-card-group", w = v(
  ({
    "data-testid": r,
    "aria-labelledby": p,
    children: n,
    className: i,
    items: e,
    heading: u,
    headingTag: s = "h2",
    loop: l = !0,
    orientation: c = "vertical",
    radioPosition: g = "right",
    ...d
  }, y) => {
    const b = C.toArray(n).filter(q);
    return /* @__PURE__ */ _("div", { className: a(i, `${h}__container`), ref: y, children: [
      u && /* @__PURE__ */ _(
        z,
        {
          "data-testid": r ? `${r}-heading` : void 0,
          id: `${d.id}-heading`,
          tag: s,
          variant: "subsection-100",
          children: [
            d.required && /* @__PURE__ */ o("span", { "aria-hidden": !0, children: "* " }),
            u
          ]
        }
      ),
      (!!e?.length || b.length) && /* @__PURE__ */ _(
        D,
        {
          ...d,
          "aria-labelledby": p || (u ? `${d.id}-heading` : void 0),
          className: a(
            h,
            `${h}--${c}`,
            `${h}--radio-${g}`
          ),
          "data-testid": r,
          loop: l,
          children: [
            e?.map((m) => /* @__PURE__ */ o(
              N,
              {
                ...m,
                disabled: m.disabled || d.disabled,
                "data-testid": r ? `${r}-item` : void 0
              },
              m.id
            )),
            C.map(
              b,
              (m) => x(m, { disabled: m.props.disabled || d.disabled })
            )
          ]
        }
      )
    ] });
  }
);
w.displayName = "RadioCardGroup";
export {
  K as R,
  M as a,
  w as b,
  N as c
};
//# sourceMappingURL=radio-card-group-DkaMcmen.mjs.map
