import React from 'react';
import { Box, TextField, InputAdornment } from '@mui/material';
import PropTypes from 'prop-types';
import { PROJECT } from '@blocklet/constant';
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function Version({
  readOnly,
  params,
  setParams,
  paramsErrTip,
  setParamsErrTip,
  loading
}) {
  const {
    t
  } = useLocaleContext();
  return /*#__PURE__*/_jsx(Box, {
    className: "section",
    sx: {
      display: 'flex',
      mt: 3
    },
    children: /*#__PURE__*/_jsxs(Box, {
      sx: {
        flex: 1
      },
      children: [/*#__PURE__*/_jsx(TextField, {
        required: true,
        disabled: loading || readOnly,
        label: `Blocklet ${t('common.version')}`,
        placeholder: `Blocklet ${t('common.version')}`,
        autoComplete: "off",
        variant: "outlined",
        fullWidth: true,
        value: params.blockletVersion || '',
        onChange: e => {
          setParamsErrTip({
            blockletVersion: ''
          });
          setParams({
            blockletVersion: e.target.value
          });
        },
        error: !!paramsErrTip.blockletVersion,
        helperText: paramsErrTip.blockletVersion || '',
        slotProps: {
          input: {
            'data-cy': 'blocklet-version',
            readOnly
          }
        }
      }), /*#__PURE__*/_jsx(TextField, {
        label: t('blocklet.publish.releaseNote'),
        autoComplete: "off",
        disabled: loading || readOnly,
        variant: "outlined",
        fullWidth: true,
        multiline: true,
        minRows: 4,
        required: true,
        value: params.note || '',
        onChange: e => {
          setParamsErrTip({
            note: ''
          });
          setParams({
            note: e.target.value.slice(0, PROJECT.MAX_NOTE_LENGTH)
          });
        },
        error: !!paramsErrTip.note,
        helperText: paramsErrTip.note || '',
        sx: {
          mt: 3
        },
        slotProps: {
          input: {
            'data-cy': 'release-note',
            readOnly,
            endAdornment: /*#__PURE__*/_jsxs(InputAdornment, {
              position: "end",
              children: [params?.note?.length || 0, " / ", PROJECT.MAX_NOTE_LENGTH]
            })
          }
        }
      })]
    })
  });
}
Version.propTypes = {
  readOnly: PropTypes.bool.isRequired,
  params: PropTypes.object.isRequired,
  setParams: PropTypes.func.isRequired,
  paramsErrTip: PropTypes.object.isRequired,
  setParamsErrTip: PropTypes.func.isRequired,
  loading: PropTypes.bool.isRequired
};
export default Version;