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