import { o as _ } from "./rolldown-runtime.js";
import { i as y, t as j } from "./vendor/react.js";
import { t as C } from "./minus.js";
import { t as N } from "./dist.js";
import { t as x } from "./utils.js";
import { t as w } from "./FieldTooltip.js";
import { n as F, t as z } from "./field-props.js";
import { n as q, t as P } from "./CheckboxIndicator.js";
import { a as E, n as I, o as V, s as D, t as M, u as O } from "./Field.js";
import { n as R } from "./selection-group.js";
var l = /* @__PURE__ */ _(y(), 1), e = j(), S = N("relative flex shrink-0 items-center justify-center border shadow-xs transition-[border-color,background-color,color,box-shadow] duration-200 ease-out motion-reduce:transition-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50", {
  variants: {
    variant: {
      primary: "",
      secondary: "",
      info: "",
      success: "",
      warning: "",
      destructive: ""
    },
    size: {
      sm: "size-4 rounded-[4px]",
      md: "size-5 rounded-[5px]",
      lg: "size-6 rounded-[6px]"
    },
    checked: {
      true: "",
      false: ""
    }
  },
  compoundVariants: [
    {
      checked: !1,
      className: "bg-background border-border hover:border-primary hover:bg-primary/10"
    },
    {
      variant: "primary",
      checked: !0,
      className: "border-primary bg-primary text-primary-foreground hover:bg-primary/90"
    },
    {
      variant: "secondary",
      checked: !0,
      className: "border-border bg-background text-foreground hover:bg-muted"
    },
    {
      variant: "info",
      checked: !0,
      className: "border-info bg-info text-info-foreground hover:bg-info/90"
    },
    {
      variant: "success",
      checked: !0,
      className: "border-success bg-success text-success-foreground hover:bg-success/90"
    },
    {
      variant: "warning",
      checked: !0,
      className: "border-warning bg-warning text-warning-foreground hover:bg-warning/90"
    },
    {
      variant: "destructive",
      checked: !0,
      className: "border-destructive bg-destructive text-destructive-foreground hover:bg-destructive/90"
    }
  ],
  defaultVariants: {
    variant: "primary",
    size: "sm",
    checked: !1
  }
}), g = {
  sm: "size-3",
  md: "size-3.5",
  lg: "size-4"
}, f = l.forwardRef(({ className: u, variant: i, size: s = "sm", checked: n, defaultChecked: h = !1, onCheckedChange: o, ...t }, c) => {
  const [m, d] = l.useState(h), a = n !== void 0, r = a ? n : m, b = O()?.state === "destructive", v = i ?? (b ? "destructive" : "primary"), k = l.useCallback((p) => {
    a || d(p), o?.(p);
  }, [a, o]);
  return /* @__PURE__ */ (0, e.jsx)(q, {
    ref: c,
    "data-slot": "checkbox",
    "data-size": s,
    "data-variant": v,
    checked: r,
    onCheckedChange: k,
    className: x(S({
      variant: v,
      size: s,
      checked: r
    }), 'before:content-[""] before:absolute before:-inset-[4px] before:rounded-[inherit]', "focus-visible:ring-4 focus-visible:ring-bg-secondary focus-visible:shadow-[0_0_0_2px_var(--card),0_0_0_4px_var(--border)]", "dark:focus-visible:ring-bg-tertiary dark:focus-visible:shadow-[0_0_0_2px_var(--card),0_0_0_4px_var(--border)]", r && "delight-check-bounce", u),
    ...t,
    children: /* @__PURE__ */ (0, e.jsx)(P, {
      "data-slot": "checkbox-indicator",
      className: "flex items-center justify-center text-current",
      children: t.indeterminate ? /* @__PURE__ */ (0, e.jsx)(C, {
        className: x(g[s], "animate-[scale-in_150ms_ease-out] motion-reduce:animate-none"),
        strokeWidth: 3
      }) : /* @__PURE__ */ (0, e.jsx)(R, { className: g[s] })
    })
  });
});
f.displayName = "CheckboxControl";
var B = l.forwardRef((u, i) => {
  const [s, n] = F(u), { ref: h, ...o } = n;
  if (!z(s)) return /* @__PURE__ */ (0, e.jsx)(f, {
    ref: i,
    ...o,
    required: s.required
  });
  const { label: t, required: c, labelIcon: m, tooltip: d, description: a, error: r, fieldClassName: b } = s;
  return /* @__PURE__ */ (0, e.jsxs)(M, {
    layout: "inline",
    state: r ? "destructive" : void 0,
    disabled: o.disabled,
    className: b,
    children: [
      /* @__PURE__ */ (0, e.jsx)(f, {
        ref: i,
        ...o,
        required: c
      }),
      t && /* @__PURE__ */ (0, e.jsxs)(D, {
        required: c,
        labelIcon: m,
        children: [t, d && /* @__PURE__ */ (0, e.jsx)(w, { content: d })]
      }),
      (r || a) && /* @__PURE__ */ (0, e.jsxs)(I, { children: [r && /* @__PURE__ */ (0, e.jsx)(V, { children: r }), !r && a && /* @__PURE__ */ (0, e.jsx)(E, { children: a })] })
    ]
  });
});
B.displayName = "Checkbox";
export {
  B as t
};

//# sourceMappingURL=Checkbox.js.map