import { jsx, jsxs } from "react/jsx-runtime";
import { useMemo } from "react";
/* empty css                             */
import RadioGroup from "../../node_modules/@mui/material/RadioGroup/RadioGroup.js";
import FormControlLabel from "../../node_modules/@mui/material/FormControlLabel/FormControlLabel.js";
import Radio from "../../node_modules/@mui/material/Radio/Radio.js";
function RadioButton({ selfProps: { icon, label, ...selfProps }, parentProps }) {
  const radioButtonClassName = useMemo(() => {
    let retVal = "ia-styles ia-radioButton";
    if (selfProps.disabled ?? parentProps.isDisabled) retVal += " ia-radioButton-disabled";
    if (selfProps.value === parentProps.selectedOption) retVal += " ia-radioButton-selected";
    return retVal;
  }, [selfProps.disabled, selfProps.value, parentProps.isDisabled, parentProps.selectedOption]);
  const { value, disabled: _optDisabled, ...restSelf } = selfProps;
  const labelContent = icon != null ? /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 }, children: [
    icon,
    label
  ] }) : label;
  const isDisabled = selfProps.disabled ?? parentProps.isDisabled ?? parentProps.disabled ?? false;
  return /* @__PURE__ */ jsx(
    FormControlLabel,
    {
      className: radioButtonClassName,
      control: /* @__PURE__ */ jsx(Radio, { disableRipple: true }),
      disabled: isDisabled,
      label: labelContent,
      value,
      ...restSelf
    }
  );
}
function RadioButtonGroup({
  options,
  isDisabled,
  disabled,
  selectedOption,
  value,
  onChange,
  name,
  orientation = "column",
  className = "",
  "data-testid": dataTestId,
  ...args
}) {
  const resolvedValue = value ?? selectedOption ?? "";
  const groupDisabled = isDisabled ?? disabled ?? false;
  const orientationClass = orientation === "row" ? "orientation-row" : "orientation-column";
  return /* @__PURE__ */ jsx(
    RadioGroup,
    {
      "aria-labelledby": name,
      className: `ia-styles ia-radioGroup ${orientationClass} ${className}`.trim(),
      "data-testid": dataTestId,
      name,
      value: resolvedValue,
      onChange,
      ...args,
      children: options.map((opt) => /* @__PURE__ */ jsx(
        RadioButton,
        {
          parentProps: {
            ...args,
            isDisabled: groupDisabled,
            disabled: groupDisabled,
            selectedOption: resolvedValue
          },
          selfProps: opt
        },
        opt.value
      ))
    }
  );
}
RadioButtonGroup.displayName = "RadioButtonGroup";
export {
  RadioButtonGroup
};
