"use client";
import { jsx as e, jsxs as C } from "react/jsx-runtime";
import { forwardRef as N, createContext as B, useContext as F } from "react";
import { MinusIcon as y, CheckIcon as w } from "@phosphor-icons/react";
import { c as b } from "./cn-ct4n7r74mh8y0f48.js";
import { L as K } from "./label-eooot7dhtfvw7n3x.js";
import { K as j, L, N as E, O as R, C as _, P as G, Q as M } from "./vendor-base-ui-kxxocm122zr4pipe.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 = B({
  controlFirst: !0
}), A = N(
  ({
    className: s,
    checked: c,
    indeterminate: o,
    disabled: t,
    variant: l = "default",
    label: a,
    labelTooltip: d,
    controlFirst: m = !0,
    onCheckedChange: u,
    onValueChange: h,
    onChange: i,
    required: f,
    name: g,
    ...r
  }, x) => {
    if (process.env.NODE_ENV !== "production") {
      const n = !!a, k = !!r["aria-label"], p = !!r["aria-labelledby"];
      !n && !k && !p && 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 v = /* @__PURE__ */ e(
      j,
      {
        ref: x,
        name: g,
        checked: c,
        indeterminate: o,
        disabled: t,
        onCheckedChange: (n, k) => {
          if (u?.(n), h?.(n), i) {
            const p = Object.assign(k.event, {
              target: { checked: n }
            });
            i(p);
          }
        },
        className: b(
          "relative flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring after:absolute after:-inset-x-3 after:-inset-y-2",
          l === "error" ? "ring-kumo-danger" : "ring-kumo-line",
          !t && "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",
          t && "cursor-not-allowed opacity-50",
          s
        ),
        ...r,
        children: /* @__PURE__ */ e(
          L,
          {
            keepMounted: !0,
            className: "flex items-center justify-center text-kumo-inverse data-[unchecked]:invisible",
            render: (n, k) => /* @__PURE__ */ e("span", { ...n, children: k.indeterminate ? /* @__PURE__ */ e(y, { weight: "bold", size: 12 }) : /* @__PURE__ */ e(w, { weight: "bold", size: 12 }) })
          }
        )
      }
    );
    return a ? /* @__PURE__ */ e(E, { className: "inline-flex", children: /* @__PURE__ */ C(
      R,
      {
        className: b(
          "!m-0 !min-h-0 !text-base inline-flex items-center gap-2",
          m ? "flex-row" : "flex-row-reverse justify-end",
          t ? "cursor-not-allowed" : "cursor-pointer"
        ),
        children: [
          v,
          /* @__PURE__ */ e(
            K,
            {
              showOptional: f === !1,
              tooltip: d,
              asContent: !0,
              children: a
            }
          )
        ]
      }
    ) }) : v;
  }
);
A.displayName = "Checkbox";
const I = N(
  ({
    className: s,
    checked: c,
    indeterminate: o,
    disabled: t,
    variant: l = "default",
    label: a,
    value: d,
    onCheckedChange: m,
    onValueChange: u,
    name: h
  }, i) => {
    const { controlFirst: f } = F(O), g = (r) => {
      m?.(r), u?.(r);
    };
    return /* @__PURE__ */ C(
      "label",
      {
        className: b(
          "m-0 relative inline-flex items-center gap-2",
          // Control first (default): checkbox before label
          // Label first: label before checkbox using flex-row-reverse
          !f && "flex-row-reverse justify-end",
          t ? "cursor-not-allowed opacity-50" : "cursor-pointer",
          s
        ),
        children: [
          /* @__PURE__ */ e(
            j,
            {
              ref: i,
              value: d,
              name: h,
              checked: c,
              indeterminate: o,
              disabled: t,
              onCheckedChange: g,
              className: b(
                "peer relative flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring after:absolute after:-inset-x-3 after:-inset-y-2",
                l === "error" ? "ring-kumo-danger" : "ring-kumo-line",
                !t && "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,
                {
                  keepMounted: !0,
                  className: "flex items-center justify-center text-kumo-inverse data-[unchecked]:invisible",
                  render: (r, x) => /* @__PURE__ */ e("span", { ...r, children: x.indeterminate ? /* @__PURE__ */ e(y, { weight: "bold", size: 12 }) : /* @__PURE__ */ e(w, { weight: "bold", size: 12 }) })
                }
              )
            }
          ),
          /* @__PURE__ */ e("span", { className: "text-base font-medium text-kumo-default", children: a })
        ]
      }
    );
  }
);
I.displayName = "Checkbox.Item";
function z({
  legend: s,
  children: c,
  error: o,
  description: t,
  defaultValue: l,
  value: a,
  onValueChange: d,
  allValues: m,
  disabled: u,
  controlFirst: h = !0,
  className: i
}) {
  return /* @__PURE__ */ e(O.Provider, { value: { controlFirst: h }, children: /* @__PURE__ */ e(
    _,
    {
      defaultValue: l,
      value: a,
      onValueChange: d,
      allValues: m,
      disabled: u,
      children: /* @__PURE__ */ C(
        G,
        {
          className: b(
            "flex flex-col gap-4 rounded-lg border border-kumo-line p-4",
            i
          ),
          children: [
            /* @__PURE__ */ e(M, { className: "text-lg font-medium text-kumo-default", children: s }),
            /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: c }),
            o && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-danger", children: o }),
            t && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-subtle", children: t })
          ]
        }
      )
    }
  ) });
}
const D = Object.assign(A, {
  Item: I,
  Group: z
});
D.displayName = "Checkbox";
export {
  D as C,
  Q as K,
  W as a
};
//# sourceMappingURL=checkbox-khvh0efmlzvlo6qi.js.map
