"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));

var _standaloneRadioProps = _interopRequireWildcard(require("./standaloneRadioProps"));

var _styles = require("@material-ui/core/styles");

var _classnames = _interopRequireDefault(require("classnames"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    radioIcon: {
      border: "1px solid",
      borderColor: theme.palette.grey.borders,
      width: theme.spacing(1.6),
      height: theme.spacing(1.6),
      borderRadius: "50%",
      ".MuiRadio-root:focus &, .MuiRadio-root:active &": {
        boxShadow: "0 0 4px ".concat(theme.palette.focus),
        outline: "none"
      }
    },
    radioIconChecked: {
      borderColor: "currentColor",
      "&:before": {
        content: "\" \"",
        backgroundColor: theme.palette.primary.main,
        width: theme.spacing(1),
        height: theme.spacing(1),
        position: "absolute",
        borderRadius: "50%",
        top: "50%",
        left: "50%",
        transform: "translate(-50%, -50%)"
      }
    },
    radioReadOnlyChecked: {
      "&:before": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(0.7),
        top: theme.spacing(0.4),
        width: theme.spacing(0.9),
        height: theme.spacing(0.3),
        backgroundColor: theme.palette.grey.dark,
        borderRadius: 3,
        transform: "rotate(46deg)"
      },
      "&:after": {
        content: "\" \"",
        position: "absolute",
        left: theme.spacing(1.6),
        top: theme.spacing(-0.4),
        width: theme.spacing(0.3),
        height: theme.spacing(1.4),
        backgroundColor: theme.palette.grey.dark,
        borderRadius: 3,
        transform: "rotate(33deg)"
      }
    },
    radioReadOnly: {
      display: "none"
    },
    root: {
      padding: "0"
    },
    cursorDefault: {
      cursor: "default"
    }
  };
});

var StandaloneRadio = function StandaloneRadio(_ref) {
  var _classNames, _classNames2;

  var radioProps = _ref.radioProps;
  var classes = useStyles();

  if ((0, _standaloneRadioProps.isStandaloneRadioProps)(radioProps) === false) {
    throw new TypeError("radioProps property is not of type RadioProps");
  }

  var checked = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.checked)) || false;
  var disabled = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.disabled)) || false;
  var onChange = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.onChange)) || null;
  var value = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.value)) || undefined;
  var size = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.size)) || "medium";
  var inputProps = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.inputProps)) || null;
  var name = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.name)) || null;
  var readOnly = (radioProps == null ? void 0 : radioProps.get(_standaloneRadioProps.default.propNames.readOnly)) || false;
  var clickHandler = onChange != null ? function (event) {
    return onChange(event.target.value, name);
  } : null;

  var radio = /*#__PURE__*/_react.default.createElement(_Radio.default, {
    checked: checked,
    disabled: disabled,
    onChange: clickHandler,
    value: value,
    size: size,
    inputProps: inputProps,
    name: name,
    checkedIcon: /*#__PURE__*/_react.default.createElement("span", {
      className: (0, _classnames.default)((_classNames = {}, _defineProperty(_classNames, "".concat(classes.radioIcon), !readOnly), _defineProperty(_classNames, "".concat(classes.radioIconChecked), !readOnly && checked), _defineProperty(_classNames, "".concat(classes.radioReadOnlyChecked), readOnly && checked), _classNames))
    }),
    icon: /*#__PURE__*/_react.default.createElement("span", {
      className: (0, _classnames.default)((_classNames2 = {}, _defineProperty(_classNames2, "".concat(classes.radioIcon), !readOnly), _defineProperty(_classNames2, "".concat(classes.radioReadOnly), readOnly), _classNames2))
    }),
    classes: {
      root: (0, _classnames.default)(classes.root, radioProps == null ? void 0 : radioProps.getStyle(_standaloneRadioProps.default.ruleNames.root), readOnly && checked ? classes.cursorDefault : null)
    }
  });

  return radio;
};

__signature__(StandaloneRadio, "useStyles{classes}", function () {
  return [useStyles];
});

__signature__(StandaloneRadio, "useStyles{classes}", function () {
  return [useStyles];
});

var _default = StandaloneRadio;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/StandaloneRadio.js");
  reactHotLoader.register(StandaloneRadio, "StandaloneRadio", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/StandaloneRadio.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/StandaloneRadio.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/StandaloneRadio.js");
  reactHotLoader.register(StandaloneRadio, "StandaloneRadio", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/StandaloneRadio.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/StandaloneRadio.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();