"use client";
import { jsx as e, jsxs as C } from "react/jsx-runtime";
import { forwardRef as y, createContext as F, useContext as K } from "react";
import { MinusIcon as w, CheckIcon as j } from "@phosphor-icons/react";
import { c as g } from "./cn-Bhsu1vx2.js";
import { L as E } from "./label-87HQArUG.js";
import { H as I, J as L, K as R, L as _, C as G, N as D, O as H } from "./vendor-base-ui-DWIDNgE1.js";
const J = {
  variant: {
    default: {
      classes: "[&:focus-within>span]:ring-kumo-ring [&:hover>span]:ring-kumo-ring",
      description: "Default checkbox appearance"
    },
    error: {
      classes: "[&>span]:ring-kumo-danger",
      description: "Error state for validation failures"
    }
  }
}, W = {
  variant: "default"
}, O = F({
  controlFirst: !0
}), A = y(
  ({
    className: c,
    checked: l,
    indeterminate: i,
    disabled: r,
    variant: m = "default",
    label: n,
    labelTooltip: u,
    controlFirst: d = !0,
    onCheckedChange: h,
    onValueChange: k,
    onChange: s,
    required: x,
    name: p,
    ...o
  }, b) => {
    if (process.env.NODE_ENV !== "production") {
      const t = !!n, a = !!o["aria-label"], f = !!o["aria-labelledby"];
      !t && !a && !f && console.warn(
        `[Kumo Checkbox]: Checkbox must have an accessible name. Provide either:
  - label prop: <Checkbox label='Accept terms' />
  - aria-label: <Checkbox aria-label='Select item' />
  - aria-labelledby for custom label association
  Note: When used inside Checkbox.Group, label is optional`
      );
    }
    const N = /* @__PURE__ */ e(
      I,
      {
        ref: b,
        name: p,
        checked: l,
        indeterminate: i,
        disabled: r,
        onCheckedChange: (t, a) => {
          if (h?.(t), k?.(t), s) {
            const f = Object.assign(a.event, {
              target: { checked: t }
            });
            s(f);
          }
        },
        className: g(
          "flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring",
          m === "error" ? "ring-kumo-danger" : "ring-kumo-line",
          !r && "hover:ring-kumo-ring focus-visible:ring-kumo-ring",
          "data-[checked]:bg-kumo-contrast data-[indeterminate]:bg-kumo-contrast",
          r && "cursor-not-allowed opacity-50",
          c
        ),
        ...o,
        children: /* @__PURE__ */ e(
          L,
          {
            className: "flex items-center justify-center text-kumo-inverse",
            render: (t, a) => {
              const f = a.indeterminate ? w : j;
              return /* @__PURE__ */ e("span", { ...t, children: (a.checked || a.indeterminate) && /* @__PURE__ */ e(f, { weight: "bold", size: 12 }) });
            }
          }
        )
      }
    );
    return n ? /* @__PURE__ */ e(R, { className: "inline-flex", children: /* @__PURE__ */ C(
      _,
      {
        className: g(
          "inline-flex items-center gap-2",
          d ? "flex-row" : "flex-row-reverse justify-end",
          r ? "cursor-not-allowed" : "cursor-pointer"
        ),
        children: [
          N,
          /* @__PURE__ */ e(
            E,
            {
              showOptional: x === !1,
              tooltip: u,
              asContent: !0,
              children: n
            }
          )
        ]
      }
    ) }) : N;
  }
);
A.displayName = "Checkbox";
const B = y(
  ({
    className: c,
    checked: l,
    indeterminate: i,
    disabled: r,
    variant: m = "default",
    label: n,
    value: u,
    onCheckedChange: d,
    onValueChange: h,
    name: k
  }, s) => {
    const { controlFirst: x } = K(O), p = (o) => {
      d?.(o), h?.(o);
    };
    return /* @__PURE__ */ C(
      "label",
      {
        className: g(
          "relative inline-flex items-center gap-2",
          // Control first (default): checkbox before label
          // Label first: label before checkbox using flex-row-reverse
          !x && "flex-row-reverse justify-end",
          r ? "cursor-not-allowed opacity-50" : "cursor-pointer",
          c
        ),
        children: [
          /* @__PURE__ */ e(
            I,
            {
              ref: s,
              value: u,
              name: k,
              checked: l,
              indeterminate: i,
              disabled: r,
              onCheckedChange: p,
              className: g(
                "peer flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring",
                m === "error" ? "ring-kumo-danger" : "ring-kumo-line",
                !r && "group-hover:ring-kumo-ring hover:ring-kumo-ring focus-visible:ring-kumo-ring",
                "data-[checked]:bg-kumo-contrast data-[indeterminate]:bg-kumo-contrast"
              ),
              children: /* @__PURE__ */ e(
                L,
                {
                  className: "flex items-center justify-center text-kumo-inverse",
                  render: (o, b) => {
                    const v = b.indeterminate ? w : j;
                    return /* @__PURE__ */ e("span", { ...o, children: (b.checked || b.indeterminate) && /* @__PURE__ */ e(v, { weight: "bold", size: 12 }) });
                  }
                }
              )
            }
          ),
          /* @__PURE__ */ e("span", { className: "text-base font-medium text-kumo-default", children: n })
        ]
      }
    );
  }
);
B.displayName = "Checkbox.Item";
function M({
  legend: c,
  children: l,
  error: i,
  description: r,
  defaultValue: m,
  value: n,
  onValueChange: u,
  allValues: d,
  disabled: h,
  controlFirst: k = !0,
  className: s
}) {
  return /* @__PURE__ */ e(O.Provider, { value: { controlFirst: k }, children: /* @__PURE__ */ e(
    G,
    {
      defaultValue: m,
      value: n,
      onValueChange: u,
      allValues: d,
      disabled: h,
      children: /* @__PURE__ */ C(
        D,
        {
          className: g(
            "flex flex-col gap-4 rounded-lg border border-kumo-line p-4",
            s
          ),
          children: [
            /* @__PURE__ */ e(H, { className: "text-lg font-medium text-kumo-default", children: c }),
            /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: l }),
            i && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-danger", children: i }),
            r && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-subtle", children: r })
          ]
        }
      )
    }
  ) });
}
const S = Object.assign(A, {
  Item: B,
  Group: M
});
S.displayName = "Checkbox";
export {
  S as C,
  J as K,
  W as a
};
//# sourceMappingURL=checkbox-BexIU_lZ.js.map
