var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellGlobalSearch/hooks/useResizablePane.ts
var useResizablePane_exports = {};
__export(useResizablePane_exports, {
  useResizablePane: () => useResizablePane
});
module.exports = __toCommonJS(useResizablePane_exports);
var import_react = require("react");
var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
function useResizablePane(options) {
  const { initialRatio = 0.34, minRatio = 0.24, maxRatio = 0.6 } = options || {};
  const [ratio, setRatio] = (0, import_react.useState)(
    () => clamp(initialRatio, minRatio, maxRatio)
  );
  const [resizing, setResizing] = (0, import_react.useState)(false);
  const containerRef = (0, import_react.useRef)(null);
  const onResizerMouseDown = (0, import_react.useCallback)(
    (e) => {
      e.preventDefault();
      e.stopPropagation();
      const container = containerRef.current;
      if (!container) return;
      setResizing(true);
      const prevUserSelect = document.body.style.userSelect;
      const prevCursor = document.body.style.cursor;
      document.body.style.userSelect = "none";
      document.body.style.cursor = "col-resize";
      const onMove = (ev) => {
        const rect = container.getBoundingClientRect();
        if (rect.width <= 0) return;
        const next = clamp(
          (rect.right - ev.clientX) / rect.width,
          minRatio,
          maxRatio
        );
        setRatio(next);
      };
      const onUp = () => {
        setResizing(false);
        document.removeEventListener("mousemove", onMove);
        document.removeEventListener("mouseup", onUp);
        document.body.style.userSelect = prevUserSelect;
        document.body.style.cursor = prevCursor;
      };
      document.addEventListener("mousemove", onMove);
      document.addEventListener("mouseup", onUp);
    },
    [minRatio, maxRatio]
  );
  return {
    ratio,
    rightWidth: `${(ratio * 100).toFixed(2)}%`,
    containerRef,
    onResizerMouseDown,
    resizing
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useResizablePane
});
