var _excluded = ["code", "fn", "exName", "name", "children", "icon", "confirmText", "confirmConfig", "render"],
  _excluded2 = ["exName", "name", "type", "icon", "ghost", "danger", "disabled", "loading", "fn", "code", "rowParams", "isHide"],
  _excluded3 = ["code", "fn", "exName", "name", "children", "icon", "confirmText", "confirmConfig"];
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React, { useState, useEffect, useContext, useMemo } from "react";
import { IconNode } from "../components";
import SpecIcon from "../SpecIcon";
import PopConfirmTitle from "./PopConfirmTitle";
import { Button, Dropdown, Menu, Popconfirm } from "antd";
import { DownOutlined, QuestionCircleOutlined } from "@ant-design/icons";
import { removeNoPermission, btnIsDisabled } from "../utils/filterPermission";
import useStyle from "./styles";
import classNames from "classnames";
import { FanContext } from "../ConfigContext";
import { useLanguageObject } from "../hooks/use-language";

// 参数API

var ButtonGroup = function ButtonGroup(props) {
  var lang = useLanguageObject(); // 当前使用的语言包
  var InitFanContext = useContext(FanContext);
  var providerConfig = InitFanContext['ButtonGroup'] || {}; // 使用上下文（全局配置）设置扩展的配置项
  var _providerConfig$props = _objectSpread(_objectSpread({}, providerConfig), props),
    _providerConfig$props2 = _providerConfig$props.type,
    type = _providerConfig$props2 === void 0 ? 'button' : _providerConfig$props2,
    _providerConfig$props3 = _providerConfig$props.rowParams,
    rowParams = _providerConfig$props3 === void 0 ? {
      text: undefined,
      record: undefined,
      rowIndex: undefined
    } : _providerConfig$props3,
    codes = _providerConfig$props.codes,
    permissionCodes = _providerConfig$props.permissionCodes,
    _providerConfig$props4 = _providerConfig$props.dropdownConfig,
    dropdownConfig = _providerConfig$props4 === void 0 ? {} : _providerConfig$props4,
    _providerConfig$props5 = _providerConfig$props.moreText,
    moreText = _providerConfig$props5 === void 0 ? '更多' : _providerConfig$props5,
    _providerConfig$props6 = _providerConfig$props.size,
    size = _providerConfig$props6 === void 0 ? 'default' : _providerConfig$props6,
    moreIcon = _providerConfig$props.moreIcon,
    _providerConfig$props7 = _providerConfig$props.showTextIcon,
    showTextIcon = _providerConfig$props7 === void 0 ? false : _providerConfig$props7,
    className = _providerConfig$props.className,
    style = _providerConfig$props.style,
    unlimited = _providerConfig$props.unlimited;
  var _props$options = props.options,
    options = _props$options === void 0 ? [] : _props$options,
    _props$min = props.min,
    min = _props$min === void 0 ? 3 : _props$min; // 最小展示长度不能小于2
  if (!options) return null; // 没有配置list返回null
  var _useState = useState(-1),
    _useState2 = _slicedToArray(_useState, 2),
    popVisibleIndex = _useState2[0],
    setPopVisibleIndex = _useState2[1];
  var _useState3 = useState({}),
    _useState4 = _slicedToArray(_useState3, 2),
    popRow = _useState4[0],
    setPopRow = _useState4[1];
  // const [resetList, setResetList] = useState<any[]>([])
  var resetList = useMemo(function () {
    //   // codes在方法内，再合并默认的权限配置
    //   // 重组选项options集合数据，排除：无权限（有配置code,并且不包含permissionCodes内）的数据及，isHide 为true的数据
    return _toConsumableArray(removeNoPermission(options, permissionCodes, codes, rowParams)) || [];
  }, [options, codes, permissionCodes, rowParams]);
  useEffect(function () {
    setPopVisibleIndex(-1);
  }, [rowParams]);

  // 递归转换原来的数组结构
  var deepTransButtonMenus = function deepTransButtonMenus(groupArray) {
    if (!Array.isArray(groupArray)) {
      return [];
    }
    return groupArray.map(function (vItem, i) {
      var code = vItem.code,
        fn = vItem.fn,
        exName = vItem.exName,
        name = vItem.name,
        children = vItem.children,
        icon = vItem.icon,
        confirmText = vItem.confirmText,
        confirmConfig = vItem.confirmConfig,
        render = vItem.render,
        others = _objectWithoutProperties(vItem, _excluded);
      var uniqueId = "".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
      return _objectSpread(_objectSpread({}, others), {}, {
        key: code ? code + i + uniqueId : i + uniqueId,
        //  // 使用 useRef 保持 ID 的稳定性（只在组件挂载时生成一次）
        icon: icon ? /*#__PURE__*/React.createElement(IconNode, {
          icon: icon
        }) : null,
        // exName为null时，将不显示名称
        label: /*#__PURE__*/React.createElement("a", {
          onClick: function onClick(event) {
            return fn && fn(_objectSpread(_objectSpread({}, vItem), {}, {
              event: event
            }));
          }
        }, exName || name),
        children: children && children.length > 0 ? deepTransButtonMenus(children) : undefined
      });
    });
  };

  // 渲染按钮多层级形式 (用于筛选)
  var buttonMenu = function buttonMenu(group) {
    return /*#__PURE__*/React.createElement(Menu, null, group.map(function (item, index) {
      if (item.children) {
        return /*#__PURE__*/React.createElement(Menu.SubMenu, {
          title: item.exName || item.name,
          key: index
        }, item.children.map(function (child, childIndex) {
          return /*#__PURE__*/React.createElement(Menu.Item, {
            key: child.name + childIndex
          }, /*#__PURE__*/React.createElement("a", {
            onClick: child.fn ? function () {
              return child.fn(child);
            } : undefined
          }, /*#__PURE__*/React.createElement(IconNode, {
            icon: child.icon
          }), " ", child.exName || child.name));
        }));
      }
      return /*#__PURE__*/React.createElement(Menu.Item, {
        key: item.name + index
      }, /*#__PURE__*/React.createElement("a", {
        onClick: item.fn ? function () {
          return item.fn(item);
        } : undefined
      }, /*#__PURE__*/React.createElement(IconNode, {
        icon: item.icon
      }), " ", item.exName || item.name));
    }));
  };
  // 渲染按钮形式 (用于筛选)
  var RenderButtonList = function RenderButtonList(item) {
    var exName = item.exName,
      name = item.name,
      type = item.type,
      icon = item.icon,
      ghost = item.ghost,
      danger = item.danger,
      disabled = item.disabled,
      loading = item.loading,
      fn = item.fn,
      code = item.code,
      rowParams = item.rowParams,
      isHide = item.isHide,
      others = _objectWithoutProperties(item, _excluded2);
    if (Array.isArray(item.children) && item.children.length > 0) {
      // overlay={buttonMenu(item.children)}
      return /*#__PURE__*/React.createElement(Dropdown, _extends({
        menu: {
          items: deepTransButtonMenus(item.children)
        },
        placement: "bottomRight"
      }, (item === null || item === void 0 ? void 0 : item.dropdownConfig) || dropdownConfig || {}), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        size: size
        // icon={item?.icon ? <IconNode icon={item?.icon}/> : null}
      }, item.exName || item.name, " ", /*#__PURE__*/React.createElement(SpecIcon, {
        name: "down"
      })));
    }
    return /*#__PURE__*/React.createElement(Button, _extends({
      type: type || 'primary',
      danger: danger,
      ghost: ghost,
      loading: loading,
      onClick: fn ? function (event) {
        return fn(_objectSpread(_objectSpread({}, item), {}, {
          event: event
        }));
      } : null,
      size: size
    }, others, {
      icon: icon ? /*#__PURE__*/React.createElement(IconNode, {
        icon: icon
      }) : null,
      disabled: btnIsDisabled(disabled, rowParams)
    }), exName || name);
  };
  /*const textMenuItems =  (group) => {
    return (group || []).map((gItem: any, gIndex) => {
      return {
        disabled: btnIsDisabled(gItem.disabled, rowParams),
        label: gItem.hasOwnProperty('confirmText') || gItem.hasOwnProperty('confirmConfig') ?
          // @ts-ignore
          <a disabled={btnIsDisabled(gItem.disabled, rowParams)}
             onClick={gItem.fn ? () => {
               setPopVisibleIndex(rowParams.rowIndex)
               setPopRow(gItem)
             } : null}>
            {gItem.render ? gItem.render(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : (gItem.exName || gItem.name)}
          </a>
          : <a className="spec-button-group-text"
               onClick={gItem.fn ? () => gItem.fn(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : null}
            // @ts-ignore
               disabled={btnIsDisabled(gItem.disabled, rowParams)}>
            {gItem.render ? gItem.render(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : (gItem.exName || gItem.name)}
          </a>,
        key: gIndex + (gItem.exName || gItem.name),
        children: gItem.children ? (gItem.children || []).map((child: any, childIndex: number) => {
          return {
            label: <a onClick={child.fn ? () => child.fn(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : null}>
              {child.render ? child.render(...Object.keys(rowParams).map((pItem) => rowParams[pItem])) : (child.exName || child.name)}
            </a>,
            key: childIndex
          }
        }) : undefined
      }
    })
  }*/
  // 渲染文本形式多级菜单列表（用于表格）
  var textMenu = function textMenu(group) {
    return /*#__PURE__*/React.createElement(Menu, {
      className: "spec-button-text-dropdown"
    }, group.map(function (gItem, gIndex) {
      if (gItem.children) {
        return /*#__PURE__*/React.createElement(Menu.SubMenu, {
          title: gItem.exName || gItem.name,
          key: gItem.name + gIndex
        }, gItem.children.map(function (child, childIndex) {
          return /*#__PURE__*/React.createElement(Menu.Item, {
            key: child.name + childIndex
          }, /*#__PURE__*/React.createElement("a", {
            onClick: child.fn ? function () {
              return child.fn.apply(child, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
                return rowParams[pItem];
              })));
            } : undefined
          }, child.render ? child.render.apply(child, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
            return rowParams[pItem];
          }))) : child.exName || child.name));
        }));
      }
      return /*#__PURE__*/React.createElement(Menu.Item, {
        key: gIndex,
        disabled: btnIsDisabled(gItem.disabled, rowParams)
      }, gItem.hasOwnProperty('confirmText') || gItem.hasOwnProperty('confirmConfig') ?
      /*#__PURE__*/
      // @ts-ignore
      React.createElement("a", {
        disabled: btnIsDisabled(gItem.disabled, rowParams),
        onClick: gItem.fn ? function () {
          // @ts-ignore
          setPopVisibleIndex(rowParams === null || rowParams === void 0 ? void 0 : rowParams.rowIndex);
          setPopRow(gItem);
        } : undefined
      }, gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
        return rowParams[pItem];
      }))) : gItem.exName || gItem.name) : /*#__PURE__*/React.createElement("a", {
        className: 'spec-button-group-text',
        onClick: gItem.fn ? function () {
          return gItem.fn.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
            return rowParams[pItem];
          })));
        } : undefined
        // @ts-ignore
        ,
        disabled: btnIsDisabled(gItem.disabled, rowParams)
      }, gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
        return rowParams[pItem];
      }))) : gItem.exName || gItem.name));
    }));
  };
  // 自定义渲染显示的文本
  var renderCustomLabel = function renderCustomLabel(gItem, hideIcon) {
    return gItem.render ? gItem.render.apply(gItem, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
      return rowParams[pItem];
    }))) : /*#__PURE__*/React.createElement(React.Fragment, null, !hideIcon && gItem.icon && showTextIcon ? /*#__PURE__*/React.createElement(IconNode, {
      icon: gItem.icon
    }) : '', " ", gItem.exName || gItem.name);
  };
  // 递归转换原来的数组结构
  var deepTransTextMenus = function deepTransTextMenus(groupArray) {
    if (!Array.isArray(groupArray)) {
      return [];
    }
    return groupArray.map(function (vItem, i) {
      var code = vItem.code,
        fn = vItem.fn,
        exName = vItem.exName,
        name = vItem.name,
        children = vItem.children,
        icon = vItem.icon,
        confirmText = vItem.confirmText,
        confirmConfig = vItem.confirmConfig,
        others = _objectWithoutProperties(vItem, _excluded3);
      var uniqueId = "".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
      return {
        danger: others.danger,
        disabled: btnIsDisabled(others.disabled, rowParams),
        key: code ? code + i + uniqueId : i + uniqueId,
        icon: icon && showTextIcon ? /*#__PURE__*/React.createElement(IconNode, {
          icon: icon,
          style: {
            marginRight: '4px'
          }
        }) : null,
        // 不显示图标
        label: /*#__PURE__*/React.createElement("a", {
          onClick: function onClick(event) {
            // 配置二次确认
            if (vItem.hasOwnProperty('confirmText') || vItem.hasOwnProperty('confirmConfig')) {
              // @ts-ignore
              fn ? (setPopVisibleIndex(rowParams.rowIndex), setPopRow(vItem)) : null;
            } else {
              fn && fn.apply(void 0, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
                return rowParams[pItem];
              })).concat([_objectSpread(_objectSpread({}, vItem), {}, {
                event: event
              })]));
            }
          }
        }, renderCustomLabel(vItem, true)),
        title: vItem.exName || vItem.name,
        children: children && children.length > 0 ? deepTransTextMenus(children) : undefined
      };
    });
  };

  // 渲染文本形式 列表（用于表格）
  var RenderTextList = function RenderTextList(item) {
    if (Array.isArray(item.children) && item.children.length > 0) {
      return /*#__PURE__*/React.createElement(Dropdown, _extends({
        menu: {
          items: deepTransTextMenus(item.children)
        },
        placement: "bottomRight"
      }, (item === null || item === void 0 ? void 0 : item.dropdownConfig) || dropdownConfig || {}), /*#__PURE__*/React.createElement("a", {
        className: 'spec-button-group-text'
      }, renderCustomLabel(item, true), " ", /*#__PURE__*/React.createElement(SpecIcon, {
        name: "down"
      })));
    }
    return /*#__PURE__*/React.createElement(React.Fragment, null, item.hasOwnProperty('confirmText') || item.hasOwnProperty('confirmConfig') ? /*#__PURE__*/React.createElement(Popconfirm, _extends({
      placement: "topRight",
      icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null)
    }, item.hasOwnProperty('confirmConfig') ? item.confirmConfig : {}, {
      // 弹出扩展配置
      title: /*#__PURE__*/React.createElement(PopConfirmTitle, _extends({}, item, {
        extraRow: rowParams
      })),
      onCancel: function onCancel(event) {
        if (item.hasOwnProperty('confirmConfig') && item.confirmConfig.onCancel) {
          if (type === 'action') {
            var _item$confirmConfig;
            (_item$confirmConfig = item.confirmConfig).onCancel.apply(_item$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
              return rowParams[pItem];
            })).concat([_objectSpread(_objectSpread({}, item), {}, {
              event: event
            })]));
          }
          if (type === 'text') {
            item.confirmConfig.onCancel(_objectSpread(_objectSpread({}, item), {}, {
              event: event
            }));
          }
        }
      },
      onConfirm: function onConfirm(event) {
        if (item.hasOwnProperty('confirmConfig') && item.confirmConfig.onConfirm) {
          var _item$confirmConfig2;
          (_item$confirmConfig2 = item.confirmConfig).onConfirm.apply(_item$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
            return rowParams[pItem];
          })));
        } else if (item.fn) {
          if (type === 'action') {
            item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
              return rowParams[pItem];
            })).concat([_objectSpread(_objectSpread({}, item), {}, {
              event: event
            })]));
          }
          if (type === 'text') {
            item.fn(_objectSpread(_objectSpread({}, item), {}, {
              event: event
            }));
          }
        }
      }
    }), /*#__PURE__*/React.createElement("a", {
      className: 'spec-button-group-text',
      key: item.index,
      title: item.exName || item.name
      // @ts-ignore
      ,
      disabled: btnIsDisabled(item.disabled, rowParams)
    }, renderCustomLabel(item))) : /*#__PURE__*/React.createElement("a", {
      className: 'spec-button-group-text',
      title: item.exName || item.name,
      key: item.index
      // @ts-ignore
      ,
      disabled: btnIsDisabled(item.disabled, rowParams),
      onClick: item.fn ? function (event) {
        if (type === 'action') {
          item.fn.apply(item, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
            return rowParams[pItem];
          })).concat([_objectSpread(_objectSpread({}, item), {}, {
            event: event
          })]));
        }
        if (type === 'text') {
          item.fn(_objectSpread(_objectSpread({}, item), {}, {
            event: event
          }));
        }
      } : undefined
    }, renderCustomLabel(item)));
  };
  var RenderCustomNode = function RenderCustomNode(item) {
    var render = item.render,
      rowParams = item.rowParams;
    if (typeof render === 'function') {
      return render.apply(void 0, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
        return rowParams[pItem];
      })));
    } else {
      return render;
    }
  };
  // 渲染展示的按钮列表
  var renderDisplayButton = function renderDisplayButton(item, index) {
    /*渲染自定义*/
    if (item.render) {
      return /*#__PURE__*/React.createElement(RenderCustomNode, _extends({
        key: index
      }, item, {
        rowParams: rowParams
      }));
    }
    /*渲染按钮形式*/
    if (type === 'button') {
      return /*#__PURE__*/React.createElement(RenderButtonList, _extends({
        key: index
      }, item, {
        rowParams: rowParams
      }));
    }

    /*渲染文本形式(包含表格操作列的按钮）type='text' 或 type='action'*/
    return /*#__PURE__*/React.createElement(RenderTextList, _extends({
      key: index
    }, item));
  };
  if (min < 2) min = 2;
  var componentName = 'spec-button-group';
  var _useStyle = useStyle(componentName),
    _useStyle2 = _slicedToArray(_useStyle, 2),
    wrapSSR = _useStyle2[0],
    hashId = _useStyle2[1];
  var ButtonGroupGroupNode = function ButtonGroupGroupNode() {
    if (resetList.length === 0) {
      return /*#__PURE__*/React.createElement(React.Fragment, null, type !== 'button' ? '-' : null);
    }
    // 数量超出时渲染
    if (!unlimited && resetList.length > min) {
      var forGroup = resetList.slice(0, min - 1);
      var forDrop = resetList.slice(min - 1);
      return /*#__PURE__*/React.createElement("span", {
        className: classNames(componentName, className || '', hashId),
        style: style
      }, forGroup.map(function (item, index) {
        return index < min - 1 ? renderDisplayButton(item, index) : null;
      }), type === 'button' ? /*#__PURE__*/React.createElement(Dropdown, _extends({
        menu: {
          items: deepTransButtonMenus(forDrop)
        },
        placement: "bottomRight"
      }, dropdownConfig), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        size: size
      }, moreText || (lang === null || lang === void 0 ? void 0 : lang['global.more.text']) || '更多', moreIcon || /*#__PURE__*/React.createElement(DownOutlined, null))) : /*#__PURE__*/React.createElement(Popconfirm, _extends({
        placement: "topRight",
        open: popVisibleIndex === rowParams.rowIndex,
        icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
        trigger: "click"
      }, popRow.hasOwnProperty('confirmConfig') ? popRow.confirmConfig : {}, {
        // 弹出扩展配置
        title: /*#__PURE__*/React.createElement(PopConfirmTitle, _extends({}, popRow, {
          extraRow: rowParams
        })),
        onCancel: function onCancel(event) {
          setPopVisibleIndex(-1);
          // 优先调用其 confirmConfig 配置的 onCancel 事件
          if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onCancel) {
            if (type === 'action') {
              var _popRow$confirmConfig;
              (_popRow$confirmConfig = popRow.confirmConfig).onCancel.apply(_popRow$confirmConfig, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
                return rowParams[pItem];
              })).concat([_objectSpread(_objectSpread({}, popRow), {}, {
                event: event
              })]));
            }
            if (type === 'text') {
              popRow.confirmConfig.onCancel(_objectSpread(_objectSpread({}, popRow), {}, {
                event: event
              }));
            }
          }
        },
        onConfirm: function onConfirm(event) {
          setPopVisibleIndex(-1);
          // 优先调用其 confirmConfig 配置的 onConfirm 事件
          if (popRow.hasOwnProperty('confirmConfig') && popRow.confirmConfig.onConfirm) {
            if (type === 'action') {
              var _popRow$confirmConfig2;
              (_popRow$confirmConfig2 = popRow.confirmConfig).onConfirm.apply(_popRow$confirmConfig2, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
                return rowParams[pItem];
              })).concat([_objectSpread(_objectSpread({}, popRow), {}, {
                event: event
              })]));
            }
            if (type === 'text') {
              popRow.confirmConfig.onCancel(_objectSpread(_objectSpread({}, popRow), {}, {
                event: event
              }));
            }
          } else if (popRow.fn) {
            if (type === 'action') {
              popRow.fn.apply(popRow, _toConsumableArray(Object.keys(rowParams).map(function (pItem) {
                return rowParams[pItem];
              })).concat([_objectSpread(_objectSpread({}, popRow), {}, {
                event: event
              })]));
            }
            if (type === 'text') {
              popRow.fn(_objectSpread(_objectSpread({}, popRow), {}, {
                event: event
              }));
            }
          }
        }
      }), /*#__PURE__*/React.createElement(Dropdown, _extends({
        menu: {
          items: deepTransTextMenus(forDrop)
        },
        placement: "bottomRight"
      }, dropdownConfig), /*#__PURE__*/React.createElement("a", {
        className: 'spec-button-group-text'
      }, moreText || (lang === null || lang === void 0 ? void 0 : lang['global.more.text']) || '更多', moreIcon || /*#__PURE__*/React.createElement(DownOutlined, null)))));
    }
    return /*#__PURE__*/React.createElement("span", {
      className: classNames(componentName, className || '', hashId),
      style: style
    }, resetList.map(function (item, index) {
      return renderDisplayButton(item, index);
    }));
  };
  return wrapSSR(ButtonGroupGroupNode());
};
export default ButtonGroup;