"use client";
import { jsx as e, jsxs as p } from "react/jsx-runtime";
import { forwardRef as I, createContext as C, useContext as G } from "react";
import { c as o } from "./cn-ct4n7r74mh8y0f48.js";
import { r as x } from "./resolve-variant-gw6eh7fa4st8ej7m.js";
import { R as L, U as O, Q as w, br as v, bs as N } from "./vendor-base-ui-ie71jahf0czyf58j.js";
const R = {
  variant: {
    default: {
      classes: "ring-kumo-hairline",
      description: "Default radio appearance"
    },
    error: {
      classes: "ring-kumo-danger",
      description: "Error state for validation failures"
    }
  },
  appearance: {
    default: {
      classes: "",
      description: "Standard inline radio item"
    },
    card: {
      classes: "rounded-lg border border-kumo-hairline bg-kumo-base p-3 transition-colors hover:bg-kumo-tint has-[[data-checked]]:border-kumo-interact has-[[data-checked]]:bg-kumo-tint",
      description: "Choice card appearance with border, padding, and highlighted selection state"
    }
  }
}, f = {
  variant: "default",
  appearance: "default"
};
function P({
  variant: t = f.variant,
  appearance: r = f.appearance
} = {}) {
  return o(
    x(R.variant, t, f.variant).classes,
    x(R.appearance, r, f.appearance).classes
  );
}
const y = C({
  controlPosition: void 0,
  appearance: "default"
}), A = I(
  ({
    className: t,
    disabled: r,
    variant: a = "default",
    appearance: s,
    label: n,
    description: i,
    value: c
  }, l) => {
    const { controlPosition: g, appearance: u } = G(y), d = (s ?? u) === "card", m = g ?? (d ? "end" : "start");
    return d ? /* @__PURE__ */ p(
      "label",
      {
        className: o(
          "m-0 group relative flex items-start gap-3 rounded-lg border border-kumo-hairline bg-kumo-base p-3 transition-colors has-[[data-checked]]:border-kumo-interact has-[[data-checked]]:bg-kumo-tint",
          m === "start" && "flex-row-reverse",
          a === "error" && "border-kumo-danger has-[[data-checked]]:border-kumo-danger has-[[data-checked]]:bg-kumo-base",
          r ? "cursor-not-allowed opacity-50" : o(
            "has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-50 cursor-pointer",
            a !== "error" && "hover:not-has-[[data-disabled]]:bg-kumo-tint"
          ),
          t
        ),
        children: [
          /* @__PURE__ */ p("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
            /* @__PURE__ */ e("span", { className: "text-base font-medium text-kumo-default", children: n }),
            i && /* @__PURE__ */ e("span", { className: "text-sm text-kumo-subtle", children: i })
          ] }),
          /* @__PURE__ */ e(
            v,
            {
              ref: l,
              value: c,
              disabled: r,
              className: o(
                "relative mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-0 bg-kumo-base ring ring-2 focus:outline-none focus:ring-kumo-focus focus-visible:ring-2 focus-visible:ring-kumo-brand",
                a === "error" ? "ring-kumo-danger" : "ring-kumo-line",
                !r && a !== "error" && "group-hover:ring-kumo-hairline focus-visible:outline-offset-3",
                !r && a === "error" && "focus-visible:outline-offset-3",
                "data-[checked]:bg-kumo-contrast"
              ),
              children: /* @__PURE__ */ e(
                N,
                {
                  keepMounted: !0,
                  className: "flex items-center justify-center",
                  children: /* @__PURE__ */ e("span", { className: "h-2 w-2 rounded-full bg-kumo-base" })
                }
              )
            }
          )
        ]
      }
    ) : /* @__PURE__ */ p(
      "label",
      {
        className: o(
          "m-0 group relative inline-flex items-center gap-2",
          // "start" (default): radio before label
          // "end": label before radio using flex-row-reverse
          m === "end" && "flex-row-reverse justify-end",
          r ? "cursor-not-allowed opacity-50" : "cursor-pointer",
          t
        ),
        children: [
          /* @__PURE__ */ e(
            v,
            {
              ref: l,
              value: c,
              disabled: r,
              className: o(
                "relative flex h-4 w-4 items-center justify-center rounded-full border-0 bg-kumo-base ring focus:outline-none after:absolute after:-inset-x-3 after:-inset-y-2",
                a === "error" ? "ring-kumo-danger" : "ring-kumo-line",
                !r && a !== "error" && "group-hover:ring-kumo-hairline focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:outline-offset-3",
                !r && a === "error" && "focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:outline-offset-3",
                "data-[checked]:bg-kumo-contrast"
              ),
              children: /* @__PURE__ */ e(
                N,
                {
                  keepMounted: !0,
                  className: "flex items-center justify-center",
                  children: /* @__PURE__ */ e("span", { className: "h-2 w-2 rounded-full bg-kumo-base" })
                }
              )
            }
          ),
          /* @__PURE__ */ e("span", { className: "text-base text-kumo-default", children: n })
        ]
      }
    );
  }
);
A.displayName = "Radio.Item";
function j({ children: t, className: r }) {
  return /* @__PURE__ */ e(
    w,
    {
      className: o("text-base font-medium text-kumo-default", r),
      children: t
    }
  );
}
j.displayName = "Radio.Legend";
function h({
  legend: t,
  children: r,
  orientation: a = "vertical",
  appearance: s = "default",
  error: n,
  description: i,
  defaultValue: c,
  value: l,
  onValueChange: g,
  disabled: u,
  controlPosition: b,
  name: d,
  className: m
}) {
  return /* @__PURE__ */ e(y.Provider, { value: { controlPosition: b, appearance: s }, children: /* @__PURE__ */ e(
    L,
    {
      defaultValue: c,
      value: l,
      onValueChange: (k) => g?.(k),
      disabled: u,
      name: d,
      children: /* @__PURE__ */ p(
        O,
        {
          disabled: u,
          className: o("flex flex-col gap-4", m),
          children: [
            t && /* @__PURE__ */ e(w, { className: "text-base font-medium text-kumo-default", children: t }),
            /* @__PURE__ */ e(
              "div",
              {
                className: o(
                  a === "vertical" ? o("flex flex-col", s === "card" ? "gap-3" : "gap-2") : s === "card" ? "grid grid-cols-2 gap-3" : "flex flex-row flex-wrap gap-2"
                ),
                children: r
              }
            ),
            n && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-danger", children: n }),
            i && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-subtle", children: i })
          ]
        }
      )
    }
  ) });
}
h.displayName = "Radio.Group";
const U = Object.assign(h, {
  Item: A,
  Group: h,
  Legend: j
});
export {
  R as K,
  U as R,
  h as a,
  f as b,
  P as r
};
//# sourceMappingURL=radio-f95mt237ru8fyc03.js.map
