"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useFocusedState = void 0;
var _react = require("react");
var _styleFunctions = require("../../theme/src/style-functions");
var _useDynamicStateStyle = require("./useDynamicStateStyle");
/**
 * Hook to manage a focused state and compose extra styling while a component is focused
 * @param props The props object of a component
 * @param styleFunctions List of style functions supported by the component. By default, boxStyleFunctions are used
 * @param activeComponentType Type of the component inside which the hook is used. By default, this value is set to 'basic'
 * @param animateable Whether the styles should be dynamically animated using Moti. By default, this value is set to 'true'
 * @param parentStateValue A override value to control the 'focused' state instead of the local state value
 * @returns The props object with updated styles according the current 'focused' state
 */
const useFocusedState = (props, styleFunctions = _styleFunctions.boxStyleFunctions, activeComponentType = "basic", animateable = true, parentStateValue = undefined) => {
  // Initialize the focused state
  const [focused, setFocused] = (0, _react.useState)(false);

  // Override the focused state if the parentStateValue is provided
  let finalFocusedFlag;
  if (parentStateValue !== undefined) {
    finalFocusedFlag = parentStateValue;
  } else {
    finalFocusedFlag = focused;
  }

  // Compose extra styling while a component is focused
  const propsWithFocusedStyles = (0, _useDynamicStateStyle.useDynamicStateStyle)(props, "_focused", finalFocusedFlag, styleFunctions, activeComponentType, animateable);

  // Return the props object with updated styles according the current 'focused' state
  return {
    focused,
    setFocused,
    propsWithFocusedStyles
  };
};
exports.useFocusedState = useFocusedState;
//# sourceMappingURL=useFocusedState.js.map