import { useCommand } from './2RSXSRCN.js';
import { createHook, forwardRef as forwardRef2, createElement } from './LMDWO4NN.js';
import { useTagName, useMergeRefs } from './ABQUS43J.js';
import { __spreadProps, __spreadValues } from './3YLGPPWQ.js';
import { isButton } from '../../../../../../@ariakit_core@0.4.15/node_modules/@ariakit/core/esm/__chunks/DTR5TSDJ.js';
import { useRef, useState, useEffect } from 'react';

var TagName = "button";
var useButton = createHook(
  function useButton2(props) {
    const ref = useRef(null);
    const tagName = useTagName(ref, TagName);
    const [isNativeButton, setIsNativeButton] = useState(
      () => !!tagName && isButton({ tagName, type: props.type })
    );
    useEffect(() => {
      if (!ref.current) return;
      setIsNativeButton(isButton(ref.current));
    }, []);
    props = __spreadProps(__spreadValues({
      role: !isNativeButton && tagName !== "a" ? "button" : void 0
    }, props), {
      ref: useMergeRefs(ref, props.ref)
    });
    props = useCommand(props);
    return props;
  }
);
forwardRef2(function Button2(props) {
  const htmlProps = useButton(props);
  return createElement(TagName, htmlProps);
});

export { useButton };
//# sourceMappingURL=PCKO3OQ5.js.map
