"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const styles_1 = require("@mui/material/styles");
const material_1 = require("@mui/material");
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
const PREFIX = 'SCPasswordTextField';
const Root = (0, styles_1.styled)(material_1.TextField, {
    name: PREFIX,
    slot: 'Root',
    overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
function PasswordTextField(props) {
    var _a;
    // STATE
    const [showPassword, setShowPassword] = (0, react_1.useState)(false);
    // HANDLERS
    const handleClick = () => {
        setShowPassword(!showPassword);
    };
    // RENDER
    return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ type: showPassword ? 'text' : 'password' }, props, { InputProps: {
            endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(_a = props === null || props === void 0 ? void 0 : props.InputProps) === null || _a === void 0 ? void 0 : _a.endAdornment, (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ "aria-label": "toggle password visibility", onClick: handleClick, edge: "end" }, { children: showPassword ? (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "visibility_off" }) : (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "visibility" }) })) }))] }))
        } })));
}
exports.default = PasswordTextField;
