import 'core-js/modules/es.object.assign.js';
import 'core-js/modules/es.array.iterator.js';
import 'core-js/modules/web.dom-collections.iterator.js';
import { __rest } from '../../../_virtual/_tslib.js';
import { jsx } from 'react/jsx-runtime';
import { TextField, IconButton } from '@mui/material';
import { useState } from 'react';
import { IconFont } from '../IconFont/IconFont.js';

const VisibilityIcon = ({
  visible,
  clickHandler
}) => {
  return jsx(IconButton, Object.assign({
    onClick: clickHandler
  }, {
    children: jsx(IconFont, {
      name: visible ? 'visibility' : 'visibility_off',
      color: "primary.main"
    })
  }));
};
const InputField = _a => {
  var {
      value,
      type = 'text',
      InputProps
    } = _a,
    props = __rest(_a, ["value", "type", "InputProps"]);
  const [visible, setVisible] = useState(false);
  return jsx(TextField, Object.assign({
    value: value,
    InputProps: Object.assign(Object.assign({}, InputProps), {
      type: type === 'password' && visible ? 'text' : type,
      endAdornment: type === 'password' && jsx(VisibilityIcon, {
        visible: visible,
        clickHandler: () => setVisible(!visible)
      })
    })
  }, props));
};

export { InputField, InputField as default };
