"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _Label = _interopRequireDefault(require("../Label"));
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.

const GroupLabel = _ref => {
  let {
    group,
    onClose
  } = _ref;
  const {
    renderHeaderLabel,
    renderHeaderLabelTitle,
    closable = false,
    renderHeaderLabelTooltip = closable ? () => 'Close group' : undefined,
    intent
  } = group;
  if (!renderHeaderLabel && !renderHeaderLabelTitle) {
    return null;
  }
  const handleClick = closable ? onClose : undefined;
  const labelProps = {
    intent,
    onClick: handleClick,
    icon: closable ? 'cross-mark' : undefined,
    children: renderHeaderLabelTitle ? renderHeaderLabelTitle(group) : null,
    caps: false,
    size: 'md'
  };
  if (renderHeaderLabel) {
    return renderHeaderLabel(group, labelProps);
  }
  const wrapInTooltip = content => {
    if (!renderHeaderLabelTooltip) return content;
    const title = renderHeaderLabelTooltip(group);
    if (!title) return content;
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
      title: title,
      children: content
    });
  };
  const label = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Label.default, {
    ...labelProps
  });
  return wrapInTooltip(label);
};
var _default = exports.default = GroupLabel;