// packages/block-library/src/separator/use-deprecated-opacity.js
import { useEffect, useState } from "@wordpress/element";
import { usePrevious } from "@wordpress/compose";
function useDeprecatedOpacity(opacity, currentColor, setAttributes) {
  const [deprecatedOpacityWithNoColor, setDeprecatedOpacityWithNoColor] = useState(false);
  const previousColor = usePrevious(currentColor);
  useEffect(() => {
    if (opacity === "css" && !currentColor && !previousColor) {
      setDeprecatedOpacityWithNoColor(true);
    }
  }, [currentColor, previousColor, opacity]);
  useEffect(() => {
    if (opacity === "css" && (deprecatedOpacityWithNoColor && currentColor || previousColor && currentColor !== previousColor)) {
      setAttributes({ opacity: "alpha-channel" });
      setDeprecatedOpacityWithNoColor(false);
    }
  }, [deprecatedOpacityWithNoColor, currentColor, previousColor]);
}
export {
  useDeprecatedOpacity as default
};
//# sourceMappingURL=use-deprecated-opacity.js.map
