"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 f } from "./cn-Bhsu1vx2.js";
import { L as E } from "./label-Cd6nCDWj.js";
import { K as I, L, N as R, O as _, C as G, P as D, Q as M } from "./vendor-base-ui-Bsg5ebHI.js";
const Q = {
  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: s,
    checked: l,
    indeterminate: i,
    disabled: r,
    variant: m = "default",
    label: o,
    labelTooltip: d,
    controlFirst: u = !0,
    onCheckedChange: h,
    onValueChange: k,
    onChange: c,
    required: x,
    name: p,
    ...n
  }, g) => {
    if (process.env.NODE_ENV !== "production") {
      const t = !!o, a = !!n["aria-label"], b = !!n["aria-labelledby"];
      !t && !a && !b && 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: g,
        name: p,
        checked: l,
        indeterminate: i,
        disabled: r,
        onCheckedChange: (t, a) => {
          if (h?.(t), k?.(t), c) {
            const b = Object.assign(a.event, {
              target: { checked: t }
            });
            c(b);
          }
        },
        className: f(
          "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-[checked]:ring-kumo-contrast data-[indeterminate]:bg-kumo-contrast data-[indeterminate]:ring-kumo-contrast",
          r && "cursor-not-allowed opacity-50",
          s
        ),
        ...n,
        children: /* @__PURE__ */ e(
          L,
          {
            className: "flex items-center justify-center text-kumo-inverse",
            render: (t, a) => {
              const b = a.indeterminate ? w : j;
              return /* @__PURE__ */ e("span", { ...t, children: (a.checked || a.indeterminate) && /* @__PURE__ */ e(b, { weight: "bold", size: 12 }) });
            }
          }
        )
      }
    );
    return o ? /* @__PURE__ */ e(R, { className: "inline-flex", children: /* @__PURE__ */ C(
      _,
      {
        className: f(
          "inline-flex items-center gap-2",
          u ? "flex-row" : "flex-row-reverse justify-end",
          r ? "cursor-not-allowed" : "cursor-pointer"
        ),
        children: [
          N,
          /* @__PURE__ */ e(
            E,
            {
              showOptional: x === !1,
              tooltip: d,
              asContent: !0,
              children: o
            }
          )
        ]
      }
    ) }) : N;
  }
);
A.displayName = "Checkbox";
const B = y(
  ({
    className: s,
    checked: l,
    indeterminate: i,
    disabled: r,
    variant: m = "default",
    label: o,
    value: d,
    onCheckedChange: u,
    onValueChange: h,
    name: k
  }, c) => {
    const { controlFirst: x } = K(O), p = (n) => {
      u?.(n), h?.(n);
    };
    return /* @__PURE__ */ C(
      "label",
      {
        className: f(
          "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",
          s
        ),
        children: [
          /* @__PURE__ */ e(
            I,
            {
              ref: c,
              value: d,
              name: k,
              checked: l,
              indeterminate: i,
              disabled: r,
              onCheckedChange: p,
              className: f(
                "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-[checked]:ring-kumo-contrast data-[indeterminate]:bg-kumo-contrast data-[indeterminate]:ring-kumo-contrast"
              ),
              children: /* @__PURE__ */ e(
                L,
                {
                  className: "flex items-center justify-center text-kumo-inverse",
                  render: (n, g) => {
                    const v = g.indeterminate ? w : j;
                    return /* @__PURE__ */ e("span", { ...n, children: (g.checked || g.indeterminate) && /* @__PURE__ */ e(v, { weight: "bold", size: 12 }) });
                  }
                }
              )
            }
          ),
          /* @__PURE__ */ e("span", { className: "text-base font-medium text-kumo-default", children: o })
        ]
      }
    );
  }
);
B.displayName = "Checkbox.Item";
function P({
  legend: s,
  children: l,
  error: i,
  description: r,
  defaultValue: m,
  value: o,
  onValueChange: d,
  allValues: u,
  disabled: h,
  controlFirst: k = !0,
  className: c
}) {
  return /* @__PURE__ */ e(O.Provider, { value: { controlFirst: k }, children: /* @__PURE__ */ e(
    G,
    {
      defaultValue: m,
      value: o,
      onValueChange: d,
      allValues: u,
      disabled: h,
      children: /* @__PURE__ */ C(
        D,
        {
          className: f(
            "flex flex-col gap-4 rounded-lg border border-kumo-line p-4",
            c
          ),
          children: [
            /* @__PURE__ */ e(M, { className: "text-lg font-medium text-kumo-default", children: s }),
            /* @__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: P
});
S.displayName = "Checkbox";
export {
  S as C,
  Q as K,
  W as a
};
//# sourceMappingURL=checkbox-CfFoTNFI.js.map
