"use client";
import {
  usePopoverAnchor
} from "./4POTBZ2J.js";
import {
  useDialogDisclosure
} from "./APVORPDK.js";
import {
  PopoverScopedContextProvider,
  usePopoverProviderContext
} from "./JMU4N4M5.js";
import {
  createElement,
  createHook,
  forwardRef
} from "./GWSL6KNJ.js";
import {
  useEvent,
  useWrapElement
} from "./KPHZR4MB.js";

// src/popover/popover-disclosure.tsx
import { invariant } from "@ariakit/core/utils/misc";
import { jsx } from "react/jsx-runtime";
var TagName = "button";
var usePopoverDisclosure = createHook(function usePopoverDisclosure2({ store, ...props }) {
  const context = usePopoverProviderContext();
  store = store || context;
  invariant(
    store,
    process.env.NODE_ENV !== "production" && "PopoverDisclosure must receive a `store` prop or be wrapped in a PopoverProvider component."
  );
  const onClickProp = props.onClick;
  const onClick = useEvent((event) => {
    store == null ? void 0 : store.setAnchorElement(event.currentTarget);
    onClickProp == null ? void 0 : onClickProp(event);
  });
  props = useWrapElement(
    props,
    (element) => /* @__PURE__ */ jsx(PopoverScopedContextProvider, { value: store, children: element }),
    [store]
  );
  props = {
    ...props,
    onClick
  };
  props = usePopoverAnchor({ store, ...props });
  props = useDialogDisclosure({ store, ...props });
  return props;
});
var PopoverDisclosure = forwardRef(function PopoverDisclosure2(props) {
  const htmlProps = usePopoverDisclosure(props);
  return createElement(TagName, htmlProps);
});

export {
  usePopoverDisclosure,
  PopoverDisclosure
};
