"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useDisabledState = void 0;
var _react = require("react");
var _styleFunctions = require("../../theme/src/style-functions");
var _useDynamicStateStyle = require("./useDynamicStateStyle");
/**
 * Hook to manage a disabled state and compose extra styling while a component is disabled
 * @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 'disabled' state instead of the local state value
 * @returns The props object with updated styles according the current 'disabled' state
 */
const useDisabledState = (props, styleFunctions = _styleFunctions.boxStyleFunctions, activeComponentType = "basic", animateable = true, parentStateValue = undefined) => {
  // Initialize the disabled state to false
  const [disabled, setDisabled] = (0, _react.useState)(false);

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

  // Compose extra styling while a component is disabled
  const propsWithDisabledStyles = (0, _useDynamicStateStyle.useDynamicStateStyle)(props, "_disabled", finalDisabledFlag, styleFunctions, activeComponentType, animateable);

  // Return the disabled state, a function to update the disabled state, and the props with updated styles
  return {
    disabled,
    setDisabled,
    propsWithDisabledStyles
  };
};
exports.useDisabledState = useDisabledState;
//# sourceMappingURL=useDisabledState.js.map