"use strict";

exports.__esModule = true;
exports.useFocusedState = void 0;
var _react = require("react");
var useFocusedState = exports.useFocusedState = function useFocusedState(_ref) {
  var _ref$defaultState = _ref.defaultState,
    defaultState = _ref$defaultState === void 0 ? false : _ref$defaultState,
    onBlur = _ref.onBlur,
    onFocus = _ref.onFocus;
  var _useState = (0, _react.useState)(defaultState),
    focused = _useState[0],
    setFocused = _useState[1];
  var handleFocus = (0, _react.useCallback)(function (e) {
    if (!focused) {
      setFocused(true);
    }
    if (onFocus) {
      onFocus(e);
    }
  }, [onFocus, focused]);
  var handleBlur = (0, _react.useCallback)(function (e) {
    setFocused(false);
    if (onBlur) {
      onBlur(e);
    }
  }, [onBlur]);
  return [focused, handleFocus, handleBlur];
};