/* eslint-disable react/require-default-props */
import { Box, FormControl, FormControlLabel, Radio, RadioGroup } from '@mui/material';
import { useEffect } from 'react';
import PropTypes from 'prop-types';
import { jsx as _jsx } from "react/jsx-runtime";
export default function ConfigXFrameOptions({
  value,
  onChange = () => {},
  disabled = false
}) {
  const defaultValue = 'sameorigin';
  const options = [{
    label: 'DENY',
    value: 'deny'
  }, {
    label: 'SAMEORIGIN (default)',
    value: 'sameorigin'
  }];
  const handleChange = e => {
    onChange({
      action: e.target.value
    });
  };
  useEffect(() => {
    if (value === true) {
      onChange({
        action: defaultValue
      });
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [value]);
  return /*#__PURE__*/_jsx(Box, {
    children: /*#__PURE__*/_jsx(FormControl, {
      children: /*#__PURE__*/_jsx(RadioGroup, {
        row: true,
        children: options.map(option => /*#__PURE__*/_jsx(FormControlLabel, {
          value: option.value,
          control: /*#__PURE__*/_jsx(Radio, {
            size: "small",
            disabled: disabled,
            checked: option.value === value?.action,
            onChange: handleChange,
            sx: {
              p: 0.75
            }
          }),
          label: option.label
        }, option.value))
      })
    })
  });
}
ConfigXFrameOptions.propTypes = {
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired,
  onChange: PropTypes.func,
  disabled: PropTypes.bool
};