"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Radio = void 0;
var _element = require("@wordpress/element");
var _react = _interopRequireWildcard(require("@ariakit/react"));
var Ariakit = _react;
var _button = _interopRequireDefault(require("../button"));
var _context = require("./context");
var _deprecated36pxSize = require("../utils/deprecated-36px-size");
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/**
 * WordPress dependencies
 */

/**
 * External dependencies
 */

/**
 * Internal dependencies
 */

function UnforwardedRadio({
  value,
  children,
  ...props
}, ref) {
  const {
    store,
    disabled
  } = (0, _element.useContext)(_context.RadioGroupContext);
  const selectedValue = (0, _react.useStoreState)(store, 'value');
  const isChecked = selectedValue !== undefined && selectedValue === value;
  (0, _deprecated36pxSize.maybeWarnDeprecated36pxSize)({
    componentName: 'Radio',
    size: undefined,
    __next40pxDefaultSize: props.__next40pxDefaultSize
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Ariakit.Radio, {
    disabled: disabled,
    store: store,
    ref: ref,
    value: value,
    render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
      variant: isChecked ? 'primary' : 'secondary',
      ...props
    }),
    children: children || value
  });
}

/**
 * @deprecated Use `RadioControl` or `ToggleGroupControl` instead.
 */
const Radio = exports.Radio = (0, _element.forwardRef)(UnforwardedRadio);
var _default = exports.default = Radio;
//# sourceMappingURL=radio.js.map