"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
require("react");
require("clsx");
const useProps = require("../../../core/MantineProvider/use-props/use-props.cjs");
const factory = require("../../../core/factory/factory.cjs");
const Input = require("../../Input/Input.cjs");
const InputsGroupFieldset = require("../../InputsGroupFieldset/InputsGroupFieldset.cjs");
const SwitchGroup_context = require("../SwitchGroup.context.cjs");
const useUncontrolled = require("../../../../../../../../@mantine_hooks@7.15.2_react@18.3.1/node_modules/@mantine/hooks/esm/use-uncontrolled/use-uncontrolled.cjs");
const defaultProps = {};
const SwitchGroup = factory.factory((props, ref) => {
  const { value, defaultValue, onChange, size, wrapperProps, children, readOnly, ...others } = useProps.useProps("SwitchGroup", defaultProps, props);
  const [_value, setValue] = useUncontrolled.useUncontrolled({
    value,
    defaultValue,
    finalValue: [],
    onChange
  });
  const handleChange = (event) => {
    const itemValue = event.currentTarget.value;
    !readOnly && setValue(
      _value.includes(itemValue) ? _value.filter((item) => item !== itemValue) : [..._value, itemValue]
    );
  };
  return /* @__PURE__ */ jsxRuntime.jsx(SwitchGroup_context.SwitchGroupProvider, { value: { value: _value, onChange: handleChange, size }, children: /* @__PURE__ */ jsxRuntime.jsx(
    Input.Input.Wrapper,
    {
      size,
      ref,
      ...wrapperProps,
      ...others,
      labelElement: "div",
      __staticSelector: "SwitchGroup",
      children: /* @__PURE__ */ jsxRuntime.jsx(InputsGroupFieldset.InputsGroupFieldset, { role: "group", children })
    }
  ) });
});
SwitchGroup.classes = Input.Input.Wrapper.classes;
SwitchGroup.displayName = "@mantine/core/SwitchGroup";
exports.SwitchGroup = SwitchGroup;
