'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var core = require('@linaria/core');
var react = require('@linaria/react');
var index$1 = require('../Button/index.js');
var index = require('../Tooltip/index.js');
var React = require('react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
  enumerable: true,
  configurable: true,
  writable: true,
  value
}) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
    if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  }
  return a;
};
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
    if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
  }
  return target;
};
const ButtonStyle = "E_4100_0_7_b1nip9bk";
const ButtonGroupContainer = /*#__PURE__*/react.styled('div')({
  name: "ButtonGroupContainer",
  class: "E_4100_0_7_bqamoqe",
  propsAsIs: false
});
const ButtonGroup = React__default.default.forwardRef((props, ref) => {
  const {
    className,
    options,
    size = "middle",
    "data-testid": dataTestId
  } = props;
  if (!options.length) {
    return null;
  }
  return /* @__PURE__ */React__default.default.createElement(ButtonGroupContainer, {
    "data-testid": dataTestId,
    className,
    ref
  }, options.map((button, index$2) => {
    const _a = button,
      {
        key,
        icon,
        type = "ordinary-onTint",
        children,
        danger,
        ghost,
        className: className2,
        hideTitle,
        title
      } = _a,
      buttonPropArgs = __objRest(_a, ["key", "icon", "type", "children", "danger", "ghost", "className", "hideTitle", "title"]);
    if (hideTitle) {
      return /* @__PURE__ */React__default.default.createElement(index, {
        key: key || index$2,
        overlay: title || children
      }, buttonPropArgs.disabled ? /* @__PURE__ */React__default.default.createElement("span", {
        style: {
          cursor: "not-allowed"
        }
      }, /* @__PURE__ */React__default.default.createElement(index$1, __spreadValues({
        style: {
          pointerEvents: "none"
        },
        type,
        size,
        danger,
        ghost,
        className: core.cx(ButtonStyle, className2),
        prefixIcon: icon
      }, buttonPropArgs))) : /* @__PURE__ */React__default.default.createElement(index$1, __spreadValues({
        type,
        size,
        danger,
        ghost,
        className: core.cx(ButtonStyle, className2),
        prefixIcon: icon
      }, buttonPropArgs)));
    }
    return /* @__PURE__ */React__default.default.createElement(index$1, __spreadValues({
      key: key || index$2,
      type,
      size,
      danger,
      ghost,
      className: core.cx(ButtonStyle, className2),
      prefixIcon: icon
    }, buttonPropArgs), (title || children) && /* @__PURE__ */React__default.default.createElement("span", {
      className: "button-group-item"
    }, title || children));
  }));
});
var ButtonGroup$1 = ButtonGroup;

exports.ButtonStyle = ButtonStyle;
exports.default = ButtonGroup$1;
