import React from "react";
import { _ChartToolbarRenderer as ChartToolbarRenderer } from "@dynatrace/strato-components-preview/charts";
import { MapDownloadDataButton } from "./buttons/MapDownloadDataButton.js";
import { MapResetButton } from "./buttons/MapResetButton.js";
import { MapZoomInOutButtons } from "./buttons/MapZoomInOutButtons.js";
import { MapZoomToFitButton } from "./buttons/MapZoomToFitButton.js";
import { initialA11yToolbarTabIndexContext } from "./constants.js";
import { useMapConfig } from "../../hooks/use-map-config.js";
import { MapInitialViewProvider } from "../../providers/map-initial-view.provider.js";
import { useMapOverlayState } from "../../store/selectors.js";
import { useSetStateTooltip } from "../../store/store.js";
const defaultToolbarPlacement = "top-right";
const MapToolbar = () => {
  const { toolbar: toolbarConfig, interactions: interactionsConfig } = useMapConfig();
  const { mouseInBounds } = useMapOverlayState();
  const setTooltipState = useSetStateTooltip();
  const isZoomEnabled = interactionsConfig?.zoom?.enabled ?? false;
  const isZoomToFitEnabled = interactionsConfig?.zoomToFit?.enabled ?? false;
  const isDownloadDataEnabled = toolbarConfig?.downloadData ?? false;
  const hasControls = isZoomEnabled || isZoomToFitEnabled || isDownloadDataEnabled;
  const handleMouseEnter = () => {
    setTooltipState({
      enabled: false
    });
  };
  const handleMouseLeave = () => {
    setTooltipState({
      enabled: true
    });
  };
  return hasControls ? /* @__PURE__ */ React.createElement(MapInitialViewProvider, null, /* @__PURE__ */ React.createElement(
    ChartToolbarRenderer,
    {
      visible: mouseInBounds,
      collapsed: toolbarConfig?.collapsed,
      draggable: toolbarConfig?.draggable,
      placement: toolbarConfig?.placement ?? defaultToolbarPlacement,
      initialA11yState: initialA11yToolbarTabIndexContext,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave
    },
    isZoomEnabled && /* @__PURE__ */ React.createElement(MapZoomInOutButtons, null),
    isZoomEnabled && /* @__PURE__ */ React.createElement(MapResetButton, null),
    isZoomToFitEnabled && /* @__PURE__ */ React.createElement(MapZoomToFitButton, null),
    isDownloadDataEnabled && /* @__PURE__ */ React.createElement(MapDownloadDataButton, null)
  )) : null;
};
MapToolbar["displayName"] = "MapToolbar";
export {
  MapToolbar
};
//# sourceMappingURL=MapToolbar.js.map
