/*
 * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Button } from "@base-ui/react/button";
import React, { memo, useCallback } from "react";
import { CollapseIcon, ResetIcon } from "./FilterIcons.js";
import styles from "./FilterListHeader.module.css";
function FilterListHeaderInner({
  title,
  titleIcon,
  collapsed = false,
  onCollapsedChange,
  showResetButton,
  onReset,
  showActiveFilterCount,
  activeFilterCount = 0,
  canReset,
  hasVisibilityChanges = false
}) {
  const handleCollapseClick = useCallback(() => {
    onCollapsedChange?.(!collapsed);
  }, [onCollapsedChange, collapsed]);
  const resetDisabled = canReset != null ? !canReset : activeFilterCount === 0 && !hasVisibilityChanges;
  return /*#__PURE__*/React.createElement("div", {
    className: styles.header
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.titleContainer
  }, titleIcon && /*#__PURE__*/React.createElement("span", {
    className: styles.titleIcon
  }, titleIcon), title && /*#__PURE__*/React.createElement("span", {
    className: styles.title
  }, title), showActiveFilterCount && activeFilterCount > 0 && /*#__PURE__*/React.createElement("span", {
    className: styles.activeCount
  }, "(", activeFilterCount, ")")), /*#__PURE__*/React.createElement("div", {
    className: styles.actions
  }, showResetButton && /*#__PURE__*/React.createElement(Button, {
    className: styles.resetButton,
    onClick: onReset,
    disabled: resetDisabled
  }, /*#__PURE__*/React.createElement(ResetIcon, null), " Reset filters"), onCollapsedChange != null && /*#__PURE__*/React.createElement(Button, {
    className: styles.collapseButton,
    onClick: handleCollapseClick,
    "aria-expanded": !collapsed,
    "aria-label": collapsed ? "Expand filters" : "Collapse filters"
  }, /*#__PURE__*/React.createElement(CollapseIcon, null))));
}
export const FilterListHeader = /*#__PURE__*/memo(FilterListHeaderInner);
//# sourceMappingURL=FilterListHeader.js.map