import { jsx, jsxs, Fragment } from "react/jsx-runtime";
import { LayoutPageStickyContainer, Stack, ButtonList, Button, Icon, Divider } from "@contember/ui";
import { memo, useCallback } from "react";
import { DataGridColumnHiding } from "../DataGridColumnHiding.js";
import { dataGridDictionary } from "../dataGridDictionary.js";
import { DataGridFullFilters } from "../DataGridFullFilters.js";
import { useMessageFormatter } from "../../../../../../i18n/useMessageFormatter.js";
const DataGridContainerHeader = memo(({
  accessor,
  allowAggregateFilterControls,
  allowColumnVisibilityControls,
  desiredState,
  hasTile,
  pagingSummary,
  setFilter,
  setIsColumnHidden,
  setLayout
}) => {
  const { layout } = desiredState;
  const formatMessage = useMessageFormatter(dataGridDictionary);
  const setDefaultView = useCallback(() => setLayout("default"), [setLayout]);
  const setTileView = useCallback(() => setLayout("tiles"), [setLayout]);
  return /* @__PURE__ */ jsx(
    LayoutPageStickyContainer,
    {
      left: "var(--cui-layout-page-padding-left)",
      right: "var(--cui-layout-page-padding-right)",
      children: /* @__PURE__ */ jsxs(Stack, { wrap: true, align: "center", direction: "horizontal", justify: "space-between", children: [
        /* @__PURE__ */ jsxs(Stack, { gap: "small", direction: "horizontal", children: [
          hasTile && /* @__PURE__ */ jsxs(Fragment, { children: [
            /* @__PURE__ */ jsxs(ButtonList, { children: [
              /* @__PURE__ */ jsx(Button, { onClick: setTileView, size: "small", distinction: "seamless", intent: layout === "tiles" ? "primary" : "default", children: /* @__PURE__ */ jsx(Icon, { blueprintIcon: "grid-view" }) }),
              /* @__PURE__ */ jsx(Button, { onClick: setDefaultView, size: "small", distinction: "seamless", intent: layout === "default" ? "primary" : "default", children: /* @__PURE__ */ jsx(Icon, { blueprintIcon: "list" }) })
            ] }),
            /* @__PURE__ */ jsx(Divider, {})
          ] }),
          layout !== "tiles" && allowColumnVisibilityControls !== false && /* @__PURE__ */ jsx(
            DataGridColumnHiding,
            {
              desiredState,
              formatMessage,
              setIsColumnHidden
            }
          ),
          allowAggregateFilterControls !== false && /* @__PURE__ */ jsx(
            DataGridFullFilters,
            {
              desiredState,
              environment: accessor.environment,
              formatMessage,
              setFilter
            }
          )
        ] }),
        /* @__PURE__ */ jsx("div", { children: pagingSummary })
      ] })
    }
  );
});
DataGridContainerHeader.displayName = "DataGridContainerHeader";
export {
  DataGridContainerHeader
};
//# sourceMappingURL=DataGridContainerHeader.js.map
