"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const React = require("react");
const ReactDOM = require("react-dom");
const ResizeObserver_es = require("../../../../../../resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js");
const dom = require("../_util/dom.js");
const is = require("../_util/is.js");
const pick = require("../_util/pick.js");
const keycode = require("../_util/keycode.js");
const portal = require("./portal.js");
const resizeObserver = require("../_util/resizeObserver.js");
const classNames = require("../_util/classNames.js");
const index = require("../ConfigProvider/index.js");
const getPopupStyle = require("./getPopupStyle.js");
const throttleByRaf = require("../_util/throttleByRaf.js");
const raf = require("../_util/raf.js");
const mergeProps = require("../_util/mergeProps.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");
const CSSTransition = require("../../../../../../react-transition-group@4.4.5_biqbaboplfbrettd7655fr4n2y/node_modules/react-transition-group/esm/CSSTransition.js");
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
var __extends = globalThis && globalThis.__extends || function() {
  var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function(d2, b2) {
      d2.__proto__ = b2;
    } || function(d2, b2) {
      for (var p in b2)
        if (Object.prototype.hasOwnProperty.call(b2, p))
          d2[p] = b2[p];
    };
    return extendStatics(d, b);
  };
  return function(d, b) {
    if (typeof b !== "function" && b !== null)
      throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
    extendStatics(d, b);
    function __() {
      this.constructor = d;
    }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();
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);
};
function getDOMPos(dom2) {
  if (!dom2) {
    return {};
  }
  var _a = dom2.getBoundingClientRect(), width = _a.width, height = _a.height, left = _a.left, right = _a.right;
  return {
    width,
    height,
    left,
    right
  };
}
var EventsByTriggerNeed = ["onClick", "onMouseEnter", "onMouseLeave", "onMouseMove", "onFocus", "onBlur", "onContextMenu", "onKeyDown"];
function splitChildrenStyle(obj, keys) {
  var picked = {};
  var omitted = __assign({}, obj);
  keys.forEach(function(key) {
    if (obj && key in obj) {
      picked[key] = obj[key];
      delete omitted[key];
    }
  });
  return {
    picked,
    omitted
  };
}
var defaultProps = {
  blurToHide: true,
  clickToClose: true,
  classNames: "fadeIn",
  trigger: "hover",
  position: "bottom",
  duration: 200,
  unmountOnExit: true,
  popupAlign: {},
  popupHoverStay: true,
  clickOutsideToClose: true,
  escToClose: false,
  mouseLeaveToClose: true,
  containerScrollToClose: false,
  getDocument: function() {
    return window.document;
  },
  autoFixPosition: true,
  mouseEnterDelay: 100,
  mouseLeaveDelay: 100,
  autoFitPosition: true
};
var Trigger = function(_super) {
  __extends(Trigger2, _super);
  function Trigger2(props, context) {
    var _this = _super.call(this, props, context) || this;
    _this.delayTimer = null;
    _this.updatePositionTimer = null;
    _this.popupOpen = false;
    _this.mousedownToHide = false;
    _this.hasPopupMouseDown = false;
    _this.unmount = false;
    _this.isDidMount = false;
    _this.mouseLocation = {
      clientX: 0,
      clientY: 0
    };
    _this.observerContainer = null;
    _this.scrollElements = null;
    _this.resizeObserver = new ResizeObserver_es(function() {
      _this.handleUpdatePosition();
    });
    _this.childrenDom = null;
    _this.childrenDomSize = {};
    _this.getMergedProps = function(baseProps) {
      var componentConfig = _this.context.componentConfig;
      var props2 = mergeProps(baseProps || _this.props, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Trigger);
      return props2;
    };
    _this.getRootElement = function() {
      _this.childrenDom = ReactDOM.findDOMNode(_this);
      return _this.childrenDom;
    };
    _this.offScrollListeners = function() {
      (_this.scrollElements || []).forEach(function(item) {
        dom.off(item, "scroll", _this.handleScroll);
      });
      _this.scrollElements = null;
    };
    _this.offWindowResize = function() {
      _this.handleWindowResize = false;
      dom.off(window, "resize", _this.handleUpdatePosition);
    };
    _this.offContainerResize = function() {
      if (_this.resizeObserver && _this.observerContainer) {
        _this.resizeObserver.unobserve(_this.observerContainer);
        _this.observerContainer = null;
      }
    };
    _this.handleScroll = function() {
      var currentProps = _this.getMergedProps();
      if (currentProps.containerScrollToClose) {
        _this.setPopupVisible(false);
      } else if (currentProps.updateOnScroll) {
        _this.handleUpdatePosition();
      }
    };
    _this.onContainersScroll = function() {
      var _a;
      if (_this.scrollElements) {
        return;
      }
      _this.scrollElements = dom.getScrollElements(_this.childrenDom, (_a = _this.popupContainer) === null || _a === void 0 ? void 0 : _a.parentNode);
      _this.scrollElements.forEach(function(item) {
        dom.on(item, "scroll", _this.handleScroll);
      });
    };
    _this.onContainerResize = function() {
      var _a;
      var containerParent = (_a = _this.popupContainer) === null || _a === void 0 ? void 0 : _a.parentNode;
      if (_this.resizeObserver && _this.observerContainer !== containerParent) {
        _this.offContainerResize();
        containerParent && _this.resizeObserver.observe(containerParent);
        _this.observerContainer = containerParent;
      }
    };
    _this.handleUpdatePosition = throttleByRaf(function() {
      _this.updatePopupPosition();
    });
    _this.isClickTrigger = function() {
      var trigger = _this.getMergedProps().trigger;
      return [].concat(trigger).indexOf("click") > -1;
    };
    _this.isFocusTrigger = function() {
      var trigger = _this.getMergedProps().trigger;
      return [].concat(trigger).indexOf("focus") > -1;
    };
    _this.isHoverTrigger = function() {
      var trigger = _this.getMergedProps().trigger;
      return [].concat(trigger).indexOf("hover") > -1;
    };
    _this.isContextMenuTrigger = function() {
      var trigger = _this.getMergedProps().trigger;
      return [].concat(trigger).indexOf("contextMenu") > -1;
    };
    _this.isMouseLeaveToClose = function() {
      return _this.isHoverTrigger() && _this.getMergedProps().mouseLeaveToClose;
    };
    _this.isPopupHoverHide = function() {
      return _this.isHoverTrigger() && !_this.getMergedProps().popupHoverStay;
    };
    _this.isClickToHide = function() {
      return (_this.isClickTrigger() || _this.isContextMenuTrigger()) && _this.getMergedProps().clickToClose;
    };
    _this.isBlurToHide = function() {
      return _this.isFocusTrigger() && _this.getMergedProps().blurToHide;
    };
    _this.clearTimer = function() {
      if (_this.updatePositionTimer) {
        if (_this.updatePositionTimer.cancel) {
          _this.updatePositionTimer.cancel();
        } else {
          clearTimeout(_this.updatePositionTimer);
          _this.updatePositionTimer = null;
        }
      }
      if (_this.delayTimer) {
        clearTimeout(_this.delayTimer);
        _this.delayTimer = null;
      }
      if (_this.mouseDownTimeout) {
        clearTimeout(_this.mouseDownTimeout);
        _this.mouseDownTimeout = null;
      }
    };
    _this.offClickOutside = function() {
      if (_this.handleClickOutside) {
        var getDocument = _this.getMergedProps().getDocument;
        var root = is.isFunction(getDocument) && getDocument();
        dom.off(root, "mousedown", _this.onClickOutside);
        _this.handleClickOutside = false;
      }
    };
    _this.getTransformOrigin = function(position) {
      var _a, _b;
      var content = _this.triggerRef;
      if (!content)
        return {};
      var _c = _this.getMergedProps(), showArrow = _c.showArrow, classNames2 = _c.classNames;
      var top = showArrow && ((_a = _this.arrowStyle) === null || _a === void 0 ? void 0 : _a.top) || 0;
      var left = showArrow && ((_b = _this.arrowStyle) === null || _b === void 0 ? void 0 : _b.left) || 0;
      top = top ? top + "px" : "";
      left = left ? left + "px" : "";
      var transformOrigin = {
        top: (left || "50%") + " 100% 0",
        tl: (left || "15px") + " 100% 0",
        tr: (left || content.clientWidth - 15 + "px") + " 100% 0",
        bottom: (left || "50%") + " 0 0",
        bl: (left || "15px") + " 0 0",
        br: (left || content.clientWidth - 15 + "px") + " 0 0",
        left: "100% " + (top || "50%") + " 0",
        lt: "100% " + (top || "15px") + " 0",
        lb: "100% " + (top || content.clientHeight - 15 + "px") + " 0",
        right: "0 " + (top || "50%") + " 0",
        rt: "0 " + (top || "15px") + " 0",
        rb: "0 " + (top || content.clientHeight - 15 + "px") + " 0"
      };
      if (classNames2 && classNames2.indexOf("zoom") > -1) {
        return {
          transformOrigin: transformOrigin[position]
        };
      }
      if (classNames2 === "slideDynamicOrigin") {
        var origin_1 = "0% 0%";
        if (["top", "tl", "tr"].indexOf(position) > -1) {
          origin_1 = "100% 100%";
        }
        return {
          transformOrigin: origin_1
        };
      }
      return {};
    };
    _this.getTransformTranslate = function() {
      if (_this.getMergedProps().classNames !== "slideDynamicOrigin") {
        return "";
      }
      switch (_this.realPosition) {
        case "bottom":
        case "bl":
        case "br":
          return "scaleY(0.9) translateY(-4px)";
        case "top":
        case "tl":
        case "tr":
          return "scaleY(0.9) translateY(4px)";
        default:
          return "";
      }
    };
    _this.getPopupStyle = function() {
      if (_this.unmount || !_this.popupContainer) {
        return;
      }
      var mountContainer = _this.popupContainer;
      var content = _this.triggerRef;
      var child = _this.getRootElement();
      var _a = getPopupStyle(_this.getMergedProps(), content, child, mountContainer, _this.mouseLocation), style = _a.style, arrowStyle = _a.arrowStyle, realPosition = _a.realPosition;
      _this.realPosition = realPosition || _this.getMergedProps().position;
      _this.arrowStyle = arrowStyle || {};
      return __assign(__assign({}, style), _this.getTransformOrigin(_this.realPosition));
    };
    _this.showPopup = function(callback) {
      if (callback === void 0) {
        callback = function() {
        };
      }
      var popupStyle = _this.getPopupStyle();
      _this.setState({
        popupStyle
      }, callback);
    };
    _this.update = throttleByRaf(function(callback) {
      if (_this.unmount || !_this.state.popupVisible) {
        return;
      }
      var popupStyle = _this.getPopupStyle();
      _this.setState({
        popupStyle
      }, function() {
        callback && callback();
      });
    });
    _this.updatePopupPosition = function(delay, callback) {
      if (delay === void 0) {
        delay = 0;
      }
      var currentVisible = _this.state.popupVisible;
      if (!currentVisible) {
        return;
      }
      if (delay < 4) {
        _this.updatePositionTimer = _this.update(callback);
        return;
      }
      _this.updatePositionTimer = setTimeout(function() {
        var popupStyle = _this.getPopupStyle();
        _this.setState({
          popupStyle
        }, function() {
          callback && callback();
        });
      }, delay);
    };
    _this.setPopupVisible = function(visible, delay, callback) {
      if (delay === void 0) {
        delay = 0;
      }
      var mergedProps2 = _this.getMergedProps();
      var onVisibleChange = mergedProps2.onVisibleChange;
      var currentVisible = _this.state.popupVisible;
      if (visible !== currentVisible) {
        _this.delayToDo(delay, function() {
          onVisibleChange && onVisibleChange(visible);
          if (!("popupVisible" in mergedProps2)) {
            if (visible) {
              _this.setState({
                popupVisible: true
              }, function() {
                _this.showPopup(callback);
              });
            } else {
              _this.setState({
                popupVisible: false
              }, function() {
                callback && callback();
              });
            }
          } else {
            callback && callback();
          }
        });
      } else {
        callback && callback();
      }
    };
    _this.delayToDo = function(delay, callback) {
      if (delay) {
        _this.clearDelayTimer();
        _this.delayTimer = setTimeout(function() {
          callback();
          _this.clearDelayTimer();
        }, delay);
      } else {
        callback();
      }
    };
    _this.onClickOutside = function(e) {
      var _a = _this.getMergedProps(), onClickOutside = _a.onClickOutside, clickOutsideToClose = _a.clickOutsideToClose;
      var triggerNode = _this.triggerRef;
      var childrenDom = _this.getRootElement();
      if (!dom.contains(triggerNode, e.target) && !dom.contains(childrenDom, e.target) && !_this.hasPopupMouseDown) {
        onClickOutside && onClickOutside();
        if (clickOutsideToClose) {
          if (!_this.isBlurToHide() && !_this.isHoverTrigger()) {
            _this.setPopupVisible(false);
          }
        }
      }
    };
    _this.onKeyDown = function(e) {
      var keyCode = e.keyCode || e.which;
      _this.triggerPropsEvent("onKeyDown", e);
      if (keyCode === keycode.Esc.code) {
        _this.onPressEsc(e);
      }
    };
    _this.onPressEsc = function(e) {
      var escToClose = _this.getMergedProps().escToClose;
      if (escToClose && e && e.key === keycode.Esc.key && _this.state.popupVisible) {
        _this.setPopupVisible(false);
      }
    };
    _this.onMouseEnter = function(e) {
      var mouseEnterDelay = _this.getMergedProps().mouseEnterDelay;
      _this.triggerPropsEvent("onMouseEnter", e);
      _this.clearDelayTimer();
      _this.setPopupVisible(true, mouseEnterDelay || 0);
    };
    _this.onMouseMove = function(e) {
      _this.triggerPropsEvent("onMouseMove", e);
      _this.setMouseLocation(e);
      if (_this.state.popupVisible) {
        _this.update();
      }
    };
    _this.onMouseLeave = function(e) {
      var mouseLeaveDelay = _this.getMergedProps().mouseLeaveDelay;
      _this.clearDelayTimer();
      _this.triggerPropsEvent("onMouseLeave", e);
      if (_this.isMouseLeaveToClose()) {
        if (_this.state.popupVisible) {
          _this.setPopupVisible(false, mouseLeaveDelay || 0);
        }
      }
    };
    _this.onPopupMouseEnter = function() {
      _this.clearDelayTimer();
    };
    _this.onPopupMouseLeave = function(e) {
      _this.onMouseLeave(e);
    };
    _this.setMouseLocation = function(e) {
      if (_this.getMergedProps().alignPoint) {
        _this.mouseLocation = {
          clientX: e.clientX,
          clientY: e.clientY
        };
      }
    };
    _this.onContextMenu = function(e) {
      e.preventDefault();
      _this.triggerPropsEvent("onContextMenu", e);
      _this.setMouseLocation(e);
      if (!_this.state.popupVisible) {
        _this.setPopupVisible(true, 0);
      } else {
        _this.getMergedProps().alignPoint && _this.update();
      }
    };
    _this.hideContextMenu = function(e) {
      var popupVisible2 = _this.state.popupVisible;
      if (popupVisible2) {
        _this.mousedownToHide = true;
      }
      _this.triggerPropsEvent("onClick", e);
      if (_this.isClickToHide() && popupVisible2) {
        _this.setPopupVisible(!popupVisible2, 0);
      }
    };
    _this.onClick = function(e) {
      var popupVisible2 = _this.state.popupVisible;
      if (popupVisible2) {
        _this.mousedownToHide = true;
      }
      _this.triggerPropsEvent("onClick", e);
      _this.setMouseLocation(e);
      if (!_this.isClickToHide() && popupVisible2) {
        return;
      }
      _this.setPopupVisible(!popupVisible2, 0);
    };
    _this.onFocus = function(e) {
      var focusDelay = _this.getMergedProps().focusDelay;
      var onFocus = function() {
        _this.triggerPropsEvent("onFocus", e);
      };
      _this.clearDelayTimer();
      if (!_this.mousedownToHide) {
        if (_this.state.popupVisible) {
          onFocus && onFocus();
        } else {
          _this.setPopupVisible(true, focusDelay || 0, onFocus);
        }
      }
      _this.mousedownToHide = false;
    };
    _this.onBlur = function(e) {
      _this.setPopupVisible(false, 200, function() {
        return _this.triggerPropsEvent("onBlur", e);
      });
    };
    _this.onResize = function() {
      if (_this.getMergedProps().autoFixPosition && _this.state.popupVisible) {
        _this.updatePopupPosition();
      }
    };
    _this.onPopupMouseDown = function() {
      _this.hasPopupMouseDown = true;
      clearTimeout(_this.mouseDownTimeout);
      _this.mouseDownTimeout = setTimeout(function() {
        _this.hasPopupMouseDown = false;
      }, 0);
    };
    _this.getChild = function() {
      var children = _this.props.children;
      var element = children;
      var elementType = element && typeof element !== "string" && element.type;
      var child = children;
      if (["string", "number"].indexOf(typeof children) > -1 || React__default.default.Children.count(children) > 1) {
        child = /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
          children
        });
      } else if (element && elementType && (elementType.__BYTE_BUTTON === true || elementType.__BYTE_CHECKBOX === true || elementType.__BYTE_SWITCH === true || elementType.__BYTE_RADIO === true || elementType === "button") && element.props.disabled) {
        var _a = splitChildrenStyle(element.props.style, ["position", "left", "right", "top", "bottom", "float", "display", "zIndex"]), picked = _a.picked, omitted = _a.omitted;
        child = /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
          className: element.props.className,
          style: __assign(__assign({
            display: "inline-block"
          }, picked), {
            cursor: "not-allowed"
          }),
          children: React__default.default.cloneElement(element, {
            style: __assign(__assign({}, omitted), {
              pointerEvents: "none"
            }),
            className: void 0
          })
        });
      }
      return child || /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {});
    };
    _this.appendToContainer = function(node) {
      raf.caf(_this.rafId);
      if (_this.isDidMount) {
        var getGlobalPopupContainer = _this.context.getPopupContainer;
        var getPopupContainer = _this.getMergedProps().getPopupContainer;
        var gpc = getPopupContainer || getGlobalPopupContainer;
        var rootElement = _this.getRootElement();
        var parent_1 = gpc(rootElement);
        if (parent_1) {
          parent_1.appendChild(node);
          return;
        }
      }
      _this.rafId = raf.raf(function() {
        _this.appendToContainer(node);
      });
    };
    _this.getContainer = function() {
      var popupContainer = document.createElement("div");
      popupContainer.style.width = "100%";
      popupContainer.style.position = "absolute";
      popupContainer.style.top = "0";
      popupContainer.style.left = "0";
      _this.popupContainer = popupContainer;
      _this.appendToContainer(popupContainer);
      return popupContainer;
    };
    _this.triggerPropsEvent = function(eventName, e) {
      var child = _this.getChild();
      var childHandler = child && child.props && child.props[eventName];
      var props2 = _this.getMergedProps();
      if (is.isFunction(childHandler)) {
        childHandler(e);
      }
      if (is.isFunction(props2[eventName])) {
        props2[eventName](e);
      }
    };
    _this.triggerOriginEvent = function(eventName) {
      var child = _this.getChild();
      var childHandler = child && child.props && child.props[eventName];
      var propsHandler = _this.getMergedProps()[eventName];
      if (is.isFunction(propsHandler) && is.isFunction(childHandler)) {
        return function(e) {
          childHandler(e);
          propsHandler(e);
        };
      }
      return childHandler || propsHandler;
    };
    var mergedProps = _this.getMergedProps(props);
    var popupVisible = "popupVisible" in mergedProps ? mergedProps.popupVisible : mergedProps.defaultPopupVisible;
    _this.popupOpen = !!popupVisible;
    _this.state = {
      popupVisible: !!popupVisible,
      popupStyle: {}
    };
    return _this;
  }
  Trigger2.getDerivedStateFromProps = function(nextProps, state) {
    if ("popupVisible" in nextProps && nextProps.popupVisible !== state.popupVisible) {
      return {
        popupVisible: nextProps.popupVisible
      };
    }
    return null;
  };
  Trigger2.prototype.componentDidMount = function() {
    this.componentDidUpdate(this.getMergedProps());
    this.isDidMount = true;
    this.unmount = false;
    this.childrenDom = this.getRootElement();
    if (this.state.popupVisible) {
      this.childrenDomSize = getDOMPos(this.childrenDom);
    }
  };
  Trigger2.prototype.componentDidUpdate = function(_prevProps) {
    var prevProps = this.getMergedProps(_prevProps);
    var currentProps = this.getMergedProps();
    if (!prevProps.popupVisible && currentProps.popupVisible) {
      this.update();
    }
    var popupVisible = this.state.popupVisible;
    this.popupOpen = popupVisible;
    var getDocument = currentProps.getDocument;
    if (!popupVisible) {
      this.offClickOutside();
      this.offContainerResize();
      this.offWindowResize();
      this.offScrollListeners();
      return;
    }
    var rect = getDOMPos(this.childrenDom);
    if (JSON.stringify(rect) !== JSON.stringify(this.childrenDomSize)) {
      this.updatePopupPosition();
      this.childrenDomSize = rect;
    }
    this.onContainerResize();
    if (currentProps.updateOnScroll || currentProps.containerScrollToClose) {
      this.onContainersScroll();
    }
    if (!this.handleWindowResize) {
      dom.on(window, "resize", this.handleUpdatePosition);
      this.handleWindowResize = true;
    }
    if (!this.handleClickOutside) {
      var root = is.isFunction(getDocument) && getDocument();
      if (root) {
        dom.on(root, "mousedown", this.onClickOutside);
        this.handleClickOutside = true;
      }
    }
  };
  Trigger2.prototype.componentWillUnmount = function() {
    this.unmount = true;
    this.offClickOutside();
    this.clearTimer();
    this.offWindowResize();
    this.offScrollListeners();
    this.offContainerResize();
    raf.caf(this.rafId);
  };
  Trigger2.prototype.clearDelayTimer = function() {
    if (this.delayTimer) {
      clearTimeout(this.delayTimer);
      this.delayTimer = null;
    }
  };
  Trigger2.prototype.render = function() {
    var _a, _b, _c;
    var _this = this;
    var _d;
    var _e = this.getMergedProps(), children = _e.children, style = _e.style, className = _e.className, arrowProps = _e.arrowProps, disabled = _e.disabled, popup = _e.popup, classNames$1 = _e.classNames, duration = _e.duration, unmountOnExit = _e.unmountOnExit, alignPoint = _e.alignPoint, autoAlignPopupWidth = _e.autoAlignPopupWidth, position = _e.position, childrenPrefix = _e.childrenPrefix, showArrow = _e.showArrow, dropdownPopupStyle = _e.popupStyle;
    var isExistChildren = children || children === 0;
    var _f = this.context, getPrefixCls = _f.getPrefixCls, zIndex = _f.zIndex, rtl = _f.rtl;
    var _g = this.state, popupVisible = _g.popupVisible, popupStyle = _g.popupStyle;
    if (!popup) {
      return null;
    }
    var mergeProps2 = {};
    var popupEventProps = {
      onMouseDown: this.onPopupMouseDown
    };
    if (this.isHoverTrigger() && !disabled) {
      mergeProps2.onMouseEnter = this.onMouseEnter;
      mergeProps2.onMouseLeave = this.onMouseLeave;
      if (alignPoint) {
        mergeProps2.onMouseMove = this.onMouseMove;
      }
      if (!this.isPopupHoverHide()) {
        popupEventProps.onMouseEnter = this.onPopupMouseEnter;
        popupEventProps.onMouseLeave = this.onPopupMouseLeave;
      }
    } else {
      mergeProps2.onMouseEnter = this.triggerOriginEvent("onMouseEnter");
      mergeProps2.onMouseLeave = this.triggerOriginEvent("onMouseLeave");
    }
    if (this.isContextMenuTrigger() && !disabled) {
      mergeProps2.onContextMenu = this.onContextMenu;
      mergeProps2.onClick = this.hideContextMenu;
    } else {
      mergeProps2.onContextMenu = this.triggerOriginEvent("onContextMenu");
    }
    if (this.isClickTrigger() && !disabled) {
      mergeProps2.onClick = this.onClick;
    } else {
      mergeProps2.onClick = mergeProps2.onClick || this.triggerOriginEvent("onClick");
    }
    if (this.isFocusTrigger() && !disabled) {
      mergeProps2.onFocus = this.onFocus;
      if (this.isBlurToHide()) {
        mergeProps2.onBlur = this.onBlur;
      }
    } else {
      mergeProps2.onFocus = this.triggerOriginEvent("onFocus");
      mergeProps2.onBlur = this.triggerOriginEvent("onBlur");
    }
    if (!disabled) {
      mergeProps2.onKeyDown = this.onKeyDown;
    } else {
      mergeProps2.onKeyDown = this.triggerOriginEvent("onKeyDown");
    }
    var child = this.getChild();
    var popupChildren = React__default.default.Children.only(popup());
    if (child.props.className) {
      mergeProps2.className = child.props.className;
    }
    if (childrenPrefix && popupVisible) {
      mergeProps2.className = mergeProps2.className ? mergeProps2.className + " " + childrenPrefix + "-open" : childrenPrefix + "-open";
    }
    if (this.isFocusTrigger()) {
      mergeProps2.tabIndex = disabled ? -1 : 0;
    }
    var prefixCls = getPrefixCls("trigger");
    var popupClassName = classNames(prefixCls, childrenPrefix, prefixCls + "-position-" + position, (_a = {}, _a[prefixCls + "-rtl"] = rtl, _a), className);
    var childrenComponent = isExistChildren && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(resizeObserver, {
      onResize: this.onResize,
      children: React__default.default.cloneElement(child, __assign({}, mergeProps2))
    });
    var portalContent = React__default.default.createElement(CSSTransition, {
      in: !!popupVisible,
      timeout: duration,
      classNames: classNames$1,
      unmountOnExit,
      appear: true,
      mountOnEnter: true,
      onEnter: function(e) {
        e.style.display = "initial";
        e.style.pointerEvents = "none";
        if (classNames$1 === "slideDynamicOrigin") {
          e.style.transform = _this.getTransformTranslate();
        }
      },
      onEntering: function(e) {
        if (classNames$1 === "slideDynamicOrigin") {
          e.style.transform = "";
        }
      },
      onEntered: function(e) {
        e.style.pointerEvents = "auto";
        _this.forceUpdate();
      },
      onExit: function(e) {
        e.style.pointerEvents = "none";
      },
      onExited: function(e) {
        e.style.display = "none";
        if (unmountOnExit) {
          _this.triggerRef = null;
        }
        _this.setState({
          popupStyle: {}
        });
      }
    }, React__default.default.createElement(resizeObserver, {
      onResize: this.onResize
    }, React__default.default.createElement("span", __assign({
      ref: function(node) {
        return _this.triggerRef = node;
      },
      "trigger-placement": this.realPosition,
      style: __assign(__assign(__assign({
        width: autoAlignPopupWidth && (style === null || style === void 0 ? void 0 : style.width) === void 0 ? (_d = this.childrenDomSize) === null || _d === void 0 ? void 0 : _d.width : ""
      }, popupStyle), {
        position: "absolute",
        zIndex: zIndex || ""
      }), style)
    }, popupEventProps, {
      className: popupClassName
    }, pick.pickDataAttributes(this.props)), React__default.default.createElement(popupChildren.type, __assign({
      ref: popupChildren.ref
    }, popupChildren.props, {
      style: __assign(__assign({}, popupChildren.props.style), dropdownPopupStyle)
    })), (showArrow || arrowProps) && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: classNames(prefixCls + "-arrow-container", (_b = {}, _b[childrenPrefix + "-arrow-container"] = childrenPrefix, _b)),
      children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
        ...__assign({}, arrowProps, {
          className: classNames(prefixCls + "-arrow", (_c = {}, _c[childrenPrefix + "-arrow"] = childrenPrefix, _c), arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.className),
          style: __assign(__assign({}, this.arrowStyle), arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.style)
        })
      })
    }))));
    var portal$1 = popupVisible || this.triggerRef ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(portal, {
      getContainer: this.getContainer,
      children: portalContent
    }) : null;
    return isExistChildren ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
      children: [childrenComponent, portal$1]
    }) : portal$1;
  };
  Trigger2.displayName = "Trigger";
  Trigger2.contextType = index.ConfigContext;
  return Trigger2;
}(React.PureComponent);
const Trigger$1 = Trigger;
exports.EventsByTriggerNeed = EventsByTriggerNeed;
exports.default = Trigger$1;
//# sourceMappingURL=index.js.map
