"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.elementType = exports.name = exports["default"] = void 0;

var _reactIntl = require("react-intl");

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

var _rjsfCore = require("@visma/rjsf-core");

var _jsxRuntime = require("react/jsx-runtime");

function CheckboxWidget(_ref) {
  var _options$element, _options$element2, _options$element3, _options$element4, _options$element5;

  var options = _ref.options,
      _onChange = _ref.onChange,
      value = _ref.value,
      id = _ref.id,
      rawErrors = _ref.rawErrors;
  var required = (_options$element = options.element) === null || _options$element === void 0 ? void 0 : _options$element.required;
  var useLabel = (_options$element2 = options.element) === null || _options$element2 === void 0 ? void 0 : _options$element2.useLabel;
  var label = (_options$element3 = options.element) === null || _options$element3 === void 0 ? void 0 : _options$element3.label;
  var consentMessage = (_options$element4 = options.element) === null || _options$element4 === void 0 ? void 0 : _options$element4.yes;
  var title = (useLabel ? label : options.element.title) + (required ? ' *' : '');
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_core.Typography, {
      component: "p",
      variant: "subtitle1",
      children: title
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), (useLabel === false || useLabel === undefined) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.Typography, {
      component: "span",
      variant: "subtitle1",
      children: label
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.FormHelperText, {
      id: "".concat(id, "__description"),
      component: "span",
      variant: "contained",
      children: options === null || options === void 0 ? void 0 : (_options$element5 = options.element) === null || _options$element5 === void 0 ? void 0 : _options$element5.description
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.FormControlLabel, {
      control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.Checkbox, {
        onChange: function onChange(event, value) {
          value === null ? _onChange(undefined) : _onChange(value);
        },
        checked: value
      }),
      label: consentMessage,
      "aria-labelledby": _rjsfCore.utils.ariaDescribedBy(id, options, rawErrors)
    })]
  });
}

var _default = function _default() {
  return {
    schema: {
      type: 'boolean',
      "enum": [true],
      "default": false,
      additionalType: 'consent'
    },
    uiSchema: {
      'ui:widget': CheckboxWidget
    }
  };
};

exports["default"] = _default;
var name = (0, _reactIntl.defineMessage)({
  id: "fsEr4O",
  defaultMessage: [{
    "type": 0,
    "value": "Suostumus"
  }]
});
exports.name = name;
var elementType = 'field';
exports.elementType = elementType;
//# sourceMappingURL=consent.cjs.map