"use strict";
const React = require("react");
const index$1 = require("../Button/index.js");
const index$2 = require("./index.js");
const index$3 = require("../../icon/react-icon/IconMore/index.js");
const index = require("../ConfigProvider/index.js");
const useMergeProps = require("../_util/hooks/useMergeProps.js");
const pick = require("../_util/pick.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var __read = globalThis && globalThis.__read || function(o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m)
    return o;
  var i = m.call(o), r, ar = [], e;
  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
      ar.push(r.value);
  } catch (error) {
    e = {
      error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"]))
        m.call(i);
    } finally {
      if (e)
        throw e.error;
    }
  }
  return ar;
};
var defaultProps = {
  position: "br",
  trigger: "hover",
  type: "default",
  icon: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {}),
  unmountOnExit: true
};
function Button(baseProps, ref) {
  var _a;
  var componentConfig = React.useContext(index.ConfigContext).componentConfig;
  var props = useMergeProps(baseProps, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig["Dropdown.Button"]);
  var className = props.className, style = props.style, children = props.children, disabled = props.disabled, droplist = props.droplist, _b = props.position, position = _b === void 0 ? "br" : _b, _c = props.trigger, trigger = _c === void 0 ? "hover" : _c, _d = props.type, type = _d === void 0 ? "default" : _d, size = props.size, _e = props.icon, icon = _e === void 0 ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {}) : _e, _f = props.unmountOnExit, unmountOnExit = _f === void 0 ? true : _f, onClick = props.onClick, onVisibleChange = props.onVisibleChange, buttonProps = props.buttonProps, buttonsRender = props.buttonsRender;
  var leftButton = /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {
    ...__assign({
      disabled,
      type,
      size,
      onClick
    }, buttonProps),
    children
  });
  var rightButton = /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {
    disabled,
    type,
    size,
    icon
  });
  if (buttonsRender) {
    _a = __read(buttonsRender([leftButton, rightButton]), 2), leftButton = _a[0], rightButton = _a[1];
  }
  var disableTrigger = disabled || !rightButton || rightButton.props && rightButton.props.loading;
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(index$1.Group, {
    ...__assign({
      className,
      style,
      ref
    }, pick.pickDataAttributes(props)),
    children: [leftButton, /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {
      disabled,
      droplist,
      position,
      trigger,
      unmountOnExit,
      onVisibleChange,
      triggerProps: {
        disabled: disableTrigger
      },
      children: rightButton
    })]
  });
}
var ButtonComponent = React.forwardRef(Button);
ButtonComponent.displayName = "DropdownButton";
const Button$1 = ButtonComponent;
module.exports = Button$1;
//# sourceMappingURL=button.js.map
