'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var clsx = require('clsx');
var contexts = require('../inputs/contexts.js');
var jsxRuntime = require('react/jsx-runtime');

const Switch = props => {
  const inputAttributes = contexts.useInputAttributes({
    nonLabelable: true
  });
  const {
    checked,
    className,
    id = inputAttributes.id,
    'aria-label': ariaLabel,
    'aria-labelledby': ariaLabelledbyProp,
    'aria-describedby': ariaDescribedbyProp,
    onClick,
    disabled
  } = props;
  const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
  return /*#__PURE__*/jsxRuntime.jsx("button", {
    className: clsx.clsx('np-switch', {
      'np-switch--unchecked': !checked,
      'np-switch--checked': checked,
      disabled
    }, className),
    type: "button",
    role: "switch",
    ...inputAttributes,
    id: id,
    "aria-checked": Boolean(checked),
    "aria-label": ariaLabel,
    "aria-labelledby": ariaLabelledby,
    "aria-describedby": ariaDescribedbyProp,
    disabled: disabled,
    onClick: !disabled ? onClick : undefined,
    children: /*#__PURE__*/jsxRuntime.jsx("span", {
      className: "np-switch--thumb"
    })
  });
};

exports.default = Switch;
//# sourceMappingURL=Switch.js.map
