// src/components/user-action/Checkbox.tsx
import { useState } from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { Check, Minus } from "lucide-react";
import clsx2 from "clsx";

// src/components/user-action/Label.tsx
import clsx from "clsx";
import { jsx } from "react/jsx-runtime";
var styleMapping = {
  labelSmall: "textstyle-label-sm",
  labelMedium: "textstyle-label-md",
  labelBig: "textstyle-label-lg"
};
var Label = ({
  children,
  name,
  labelType = "labelSmall",
  className,
  ...props
}) => {
  return /* @__PURE__ */ jsx("label", { ...props, className: clsx(styleMapping[labelType], className), children: children ? children : name });
};

// src/components/user-action/Checkbox.tsx
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
var checkboxSizeMapping = {
  small: "size-4",
  medium: "size-6",
  large: "size-8"
};
var checkboxIconSizeMapping = {
  small: "size-3",
  medium: "size-5",
  large: "size-7"
};
var Checkbox = ({
  id,
  label,
  checked,
  disabled,
  onChange,
  onChangeTristate,
  size = "medium",
  className = "",
  containerClassName
}) => {
  const usedSizeClass = checkboxSizeMapping[size];
  const innerIconSize = checkboxIconSizeMapping[size];
  const propagateChange = (checked2) => {
    if (onChangeTristate) {
      onChangeTristate(checked2);
    }
    if (onChange) {
      onChange(checked2 === "indeterminate" ? false : checked2);
    }
  };
  const changeValue = () => {
    const newValue = checked === "indeterminate" ? false : !checked;
    propagateChange(newValue);
  };
  return /* @__PURE__ */ jsxs("div", { className: clsx2("row justify-center items-center", containerClassName), children: [
    /* @__PURE__ */ jsx2(
      CheckboxPrimitive.Root,
      {
        onCheckedChange: propagateChange,
        checked,
        disabled,
        id,
        className: clsx2(usedSizeClass, `items-center border-2 rounded outline-none `, {
          "text-disabled-text border-disabled-outline bg-disabled-background cursor-not-allowed": disabled,
          "focus:border-primary": !disabled,
          "bg-surface": !disabled && !checked,
          "bg-primary/30 border-primary text-primary": !disabled && checked === true || checked === "indeterminate",
          "hover:border-primary focus:hover:border-primary": !disabled && !checked
        }, className),
        children: /* @__PURE__ */ jsxs(CheckboxPrimitive.Indicator, { children: [
          checked === true && /* @__PURE__ */ jsx2(Check, { className: innerIconSize }),
          checked === "indeterminate" && /* @__PURE__ */ jsx2(Minus, { className: innerIconSize })
        ] })
      }
    ),
    label && /* @__PURE__ */ jsx2(
      Label,
      {
        ...label,
        className: clsx2("cursor-pointer", label.className),
        htmlFor: id,
        onClick: changeValue
      }
    )
  ] });
};
var CheckboxUncontrolled = ({
  onChange,
  onChangeTristate,
  defaultValue = false,
  ...props
}) => {
  const [checked, setChecked] = useState(defaultValue);
  const handleChange = (checked2) => {
    if (onChangeTristate) {
      onChangeTristate(checked2);
    }
    if (onChange) {
      onChange(checked2 === "indeterminate" ? false : checked2);
    }
    setChecked(checked2);
  };
  return /* @__PURE__ */ jsx2(
    Checkbox,
    {
      ...props,
      checked,
      onChangeTristate: handleChange
    }
  );
};
export {
  Checkbox,
  CheckboxUncontrolled
};
//# sourceMappingURL=Checkbox.mjs.map