var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/floatingDock/index.tsx
var floatingDock_exports = {};
__export(floatingDock_exports, {
  FloatingDock: () => FloatingDock,
  default: () => floatingDock_default
});
module.exports = __toCommonJS(floatingDock_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_index = require("./index.less");
var DEFAULT_BOTTOM = 24;
var DEFAULT_HIDDEN_RATIO = 0.5;
var DEFAULT_BOUNDARY_PADDING = 8;
var DEFAULT_AUTO_DOCK_DELAY = 5e3;
var FloatingDock = (props) => {
  const {
    children,
    className,
    style,
    initialBottom = DEFAULT_BOTTOM,
    hiddenRatio = DEFAULT_HIDDEN_RATIO,
    boundaryPadding = DEFAULT_BOUNDARY_PADDING,
    autoDockDelay = DEFAULT_AUTO_DOCK_DELAY
  } = props;
  const autoDockTimerRef = (0, import_react.useRef)(null);
  const [expanded, setExpanded] = (0, import_react.useState)(false);
  const clearAutoDockTimer = (0, import_react.useCallback)(() => {
    if (autoDockTimerRef.current) {
      clearTimeout(autoDockTimerRef.current);
      autoDockTimerRef.current = null;
    }
  }, []);
  const scheduleAutoDock = (0, import_react.useCallback)(() => {
    clearAutoDockTimer();
    autoDockTimerRef.current = setTimeout(() => {
      setExpanded(false);
    }, autoDockDelay);
  }, [autoDockDelay, clearAutoDockTimer]);
  (0, import_react.useEffect)(() => clearAutoDockTimer, [clearAutoDockTimer]);
  const handleClickCapture = (0, import_react.useCallback)(() => {
    if (expanded) {
      scheduleAutoDock();
      return;
    }
    setExpanded(true);
    scheduleAutoDock();
  }, [expanded, scheduleAutoDock]);
  const handlePointerEnter = (0, import_react.useCallback)(() => {
    if (expanded) {
      scheduleAutoDock();
    }
  }, [expanded, scheduleAutoDock]);
  const finalStyle = {
    ...style,
    right: expanded ? boundaryPadding : 0,
    bottom: initialBottom,
    transform: expanded ? "translateX(0)" : `translateX(${hiddenRatio * 100}%)`
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-floating-dock", className, {
        "pisell-floating-dock-expanded": expanded
      }),
      style: finalStyle,
      onPointerEnter: handlePointerEnter,
      onClickCapture: handleClickCapture
    },
    children
  );
};
var floatingDock_default = FloatingDock;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FloatingDock
});
