"use strict";
const React = require("react");
const classNames = require("../_util/classNames.js");
const resizeObserver = require("../_util/resizeObserver.js");
const index = require("../ConfigProvider/index.js");
const index$6 = require("../../icon/react-icon/IconDragDotVertical/index.js");
const index$5 = require("../../icon/react-icon/IconDragDot/index.js");
const index$3 = require("../../icon/react-icon/IconCaretRight/index.js");
const index$4 = require("../../icon/react-icon/IconCaretLeft/index.js");
const index$2 = require("../../icon/react-icon/IconCaretDown/index.js");
const index$1 = require("../../icon/react-icon/IconCaretUp/index.js");
const is = require("../_util/is.js");
const omit = require("../_util/omit.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 __rest = globalThis && globalThis.__rest || function(s, e) {
  var t = {};
  for (var p in s)
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
      t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
function ResizeTrigger(props) {
  var _a, _b;
  var className = props.className, direction = props.direction, icon = props.icon, onMouseDown = props.onMouseDown, onResize = props.onResize, children = props.children, _c = props.collapsible, collapsible = _c === void 0 ? {} : _c, _d = props.resizable, resizable = _d === void 0 ? true : _d, renderChildren = props.renderChildren, rest = __rest(props, ["className", "direction", "icon", "onMouseDown", "onResize", "children", "collapsible", "resizable", "renderChildren"]);
  var _e = React.useContext(index.ConfigContext), getPrefixCls = _e.getPrefixCls, rtl = _e.rtl;
  var prefixCls = getPrefixCls("resizebox-trigger");
  var isHorizontal = direction === "horizontal";
  var rtlReverse = rtl && !isHorizontal;
  var classNames$1 = classNames(prefixCls, prefixCls + "-" + (isHorizontal ? "horizontal" : "vertical"), (_a = {}, _a[prefixCls + "-not-resizable"] = !resizable, _a), (_b = {}, _b[prefixCls + "-rtl"] = rtl, _b), className);
  var verticalTriggerIcon = rtlReverse ? [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {}, "prev"), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$4, {}, "next")] : [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$4, {}, "prev"), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {}, "next")];
  var prevCollapsedConfig = is.isObject(collapsible.prev) ? __assign(__assign({}, collapsible.prev), {
    icon: collapsible.prev.icon || (isHorizontal ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {}) : verticalTriggerIcon[0])
  }) : {};
  var nextCollapsedConfig = is.isObject(collapsible.next) ? __assign(__assign({}, collapsible.next), {
    icon: collapsible.next.icon || (isHorizontal ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {}) : verticalTriggerIcon[1])
  }) : {};
  var renderPrevCollapsedTrigger = function() {
    if (prevCollapsedConfig.icon && !prevCollapsedConfig.collapsed || nextCollapsedConfig.collapsed) {
      return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
        className: classNames(prefixCls + "-icon", classNames(prefixCls + "-prev")),
        onClick: prevCollapsedConfig.onClick,
        children: prevCollapsedConfig.icon
      });
    }
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
      className: classNames(prefixCls + "-icon-empty")
    });
  };
  var renderNextCollapsedTrigger = function() {
    if (nextCollapsedConfig.icon && !nextCollapsedConfig.collapsed || prevCollapsedConfig.collapsed) {
      return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
        className: classNames(prefixCls + "-icon", classNames(prefixCls + "-next")),
        onClick: nextCollapsedConfig.onClick,
        children: nextCollapsedConfig.icon
      });
    }
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
      className: classNames(prefixCls + "-icon-empty")
    });
  };
  var renderResizeTrigger = function() {
    if (resizable) {
      return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
        className: prefixCls + "-icon",
        children: icon || (isHorizontal ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$5, {}) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$6, {}))
      });
    }
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("span", {
      className: classNames(prefixCls + "-icon-empty")
    });
  };
  var prev = renderPrevCollapsedTrigger();
  var trigger = renderResizeTrigger();
  var next = renderNextCollapsedTrigger();
  var renderIcon = function() {
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
      className: prefixCls + "-icon-wrapper",
      children: [prev, trigger, next]
    });
  };
  if (!resizable) {
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: classNames$1,
      children: is.isFunction(renderChildren) ? renderChildren(prev, trigger, next) : children || renderIcon()
    });
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(resizeObserver, {
    onResize,
    children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      ...__assign({}, omit(rest, ["style"]), {
        className: classNames$1,
        onMouseDown
      }),
      children: is.isFunction(renderChildren) ? renderChildren(prev, trigger, next) : children || renderIcon()
    })
  });
}
module.exports = ResizeTrigger;
//# sourceMappingURL=resize-trigger.js.map
