function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["checked", "children", "className", "error", "indeterminate", "style", "requiredMark", "tooltip"],
  _excluded2 = ["checked", "children", "className", "disabled", "error", "indeterminate", "style"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import { useLabel } from '@react-aria/label';
import React from 'react';
import { Required } from '../Required/Required';
import { StyledCheckboxContainer, StyledCheckboxInput, StyledCheckboxLabel, StyledCheckboxLabelWrapper, StyledFakeCheckboxInput, StyledFakeCheckboxLabel } from './Checkbox.styles';
import { CheckboxTooltip } from './CheckboxTooltip';

/**


 We use checkboxes to provide users with the ability to either select or
 deselect multiple values from a list of options (e.g. items on list pages),
 or to select or deselect a single option (e.g. settings on configure pages).

 @since 10.19.0

 @see [Storybook](https://stories.core.procore.com/?path=/story/core-react_demos-checkbox--demo)

 @see [Design Guidelines](https://design.procore.com/checkbox)

 */
export var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref) {
  var checked = _ref.checked,
    children = _ref.children,
    className = _ref.className,
    _ref$error = _ref.error,
    error = _ref$error === void 0 ? false : _ref$error,
    _ref$indeterminate = _ref.indeterminate,
    indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
    style = _ref.style,
    requiredMark = _ref.requiredMark,
    tooltip = _ref.tooltip,
    props = _objectWithoutProperties(_ref, _excluded);
  var _useLabel = useLabel(_objectSpread(_objectSpread({}, props), {}, {
      // to always generate labelProps, so checkbox icon can be clickable for empty labels
      label: true
    })),
    fieldProps = _useLabel.fieldProps,
    labelProps = _useLabel.labelProps;
  return /*#__PURE__*/React.createElement(StyledCheckboxContainer, {
    className: className,
    style: style
  }, /*#__PURE__*/React.createElement(StyledCheckboxInput, _extends({}, props, fieldProps, {
    type: "checkbox",
    checked: checked,
    $error: error,
    $indeterminate: indeterminate,
    ref: ref
  })), /*#__PURE__*/React.createElement(StyledCheckboxLabelWrapper, {
    $hasLabel: Boolean(children)
  }, /*#__PURE__*/React.createElement(StyledCheckboxLabel, labelProps, children, requiredMark && /*#__PURE__*/React.createElement(Required, null)), tooltip && /*#__PURE__*/React.createElement(CheckboxTooltip, {
    overlay: tooltip
  })));
});
Checkbox.displayName = 'Checkbox';

/**
 *  This checkbox was created to be used as a non-interactive Checkbox component
 *  for VoiceOver inside MenuImperative.CheckboxItem.
 *
 *  @since 11.3.0
 */

export var FakeCheckbox = /*#__PURE__*/React.forwardRef(function FakeCheckbox(_ref2, ref) {
  var _ref2$checked = _ref2.checked,
    checked = _ref2$checked === void 0 ? false : _ref2$checked,
    children = _ref2.children,
    className = _ref2.className,
    _ref2$disabled = _ref2.disabled,
    disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
    _ref2$error = _ref2.error,
    error = _ref2$error === void 0 ? false : _ref2$error,
    _ref2$indeterminate = _ref2.indeterminate,
    indeterminate = _ref2$indeterminate === void 0 ? false : _ref2$indeterminate,
    style = _ref2.style,
    props = _objectWithoutProperties(_ref2, _excluded2);
  return /*#__PURE__*/React.createElement(StyledCheckboxContainer, {
    className: className,
    style: style
  }, /*#__PURE__*/React.createElement(StyledFakeCheckboxInput, _extends({}, props, {
    $checked: checked,
    $disabled: disabled,
    $error: error,
    $indeterminate: indeterminate,
    ref: ref
  })), /*#__PURE__*/React.createElement(StyledFakeCheckboxLabel, {
    $checked: checked,
    $disabled: disabled
  }, children));
});
FakeCheckbox.displayName = 'FakeCheckbox';
//# sourceMappingURL=Checkbox.js.map