import { jsxs, jsx } from "react/jsx-runtime";
import { DialogProvider, Portal, HoveringToolbar } from "@contember/ui";
import { memo } from "react";
import { HoveringToolbarContents } from "./HoveringToolbarContents.js";
import { useToolbarState } from "../editorSelection/useToolbarsState.js";
const HoveringToolbars = memo(({
  blockButtons,
  inlineButtons,
  shouldDisplayInlineToolbar: shouldDisplayInlineToolbarProp,
  showLabels,
  toolbarScheme,
  ...props
}) => {
  const { inlineToolbarRef, blockToolbarActive, inlineToolbarActive } = useToolbarState();
  const shouldDisplayInlineToolbar = inlineToolbarActive && (shouldDisplayInlineToolbarProp === void 0 || shouldDisplayInlineToolbarProp());
  return /* @__PURE__ */ jsxs(DialogProvider, { children: [
    /* @__PURE__ */ jsx(Portal, { children: inlineButtons && /* @__PURE__ */ jsx(HoveringToolbar, { scheme: toolbarScheme, isActive: shouldDisplayInlineToolbar, ref: inlineToolbarRef, scope: "contextual", children: /* @__PURE__ */ jsx(HoveringToolbarContents, { buttons: inlineButtons, showLabels }) }) }),
    blockButtons && /* @__PURE__ */ jsxs(HoveringToolbar, { scheme: toolbarScheme, isActive: blockToolbarActive, children: [
      Array.isArray(blockButtons) && /* @__PURE__ */ jsx(HoveringToolbarContents, { buttons: blockButtons, showLabels }),
      Array.isArray(blockButtons) || blockButtons
    ] })
  ] });
});
export {
  HoveringToolbars
};
//# sourceMappingURL=HoveringToolbars.js.map
